default data directory

This commit is contained in:
Daniel Langbein 2021-03-02 12:28:17 +01:00
parent fa0575ff6f
commit 154f2ed333
4 changed files with 17 additions and 9 deletions

View File

@ -6,6 +6,7 @@ from pathlib import Path
from langfingaz import parseMeetings, bbbRequest, saveData
from langfingaz.util import util as util
import langfingaz.util.fileUtil as fileUtil
def sleepFiveMin(verbose=False):
@ -17,7 +18,7 @@ def sleepFiveMin(verbose=False):
util.sleep(fiveMinutes)
def v2(folder: Path = saveData.getDefaultFolder()):
def v2(folder: Path = fileUtil.getDataDir()):
print("BBB meetingData logger started!")
while True:
@ -33,7 +34,7 @@ def v2(folder: Path = saveData.getDefaultFolder()):
sleepFiveMin(verbose=True)
def v1(folder: Path = saveData.getDefaultFolder()):
def v1(folder: Path = fileUtil.getDataDir()):
while True:
saveData.requestAndSaveMeetingData(folder)
print('.')

View File

@ -17,7 +17,11 @@ def getDefaultPlotFolder() -> Path:
return fileUtil.getProjectBaseDir().joinpath("plot")
def plotMeetings(dataDir: Path = fileUtil.getProjectBaseDir().joinpath("data")):
def plotMeetings(dataDir: Path = fileUtil.getDataDir()):
"""
plot BBB meetings of the last month
"""
bbbStati: List[BbbStatus] = []
for file in dataDir.iterdir():

View File

@ -5,11 +5,7 @@ import langfingaz.util.fileUtil as fileUtil
from langfingaz import bbbRequest
def getDefaultFolder() -> Path:
return fileUtil.getProjectBaseDir().joinpath("data")
def requestAndSaveMeetingData(folder: Path = getDefaultFolder()) -> Path:
def requestAndSaveMeetingData(folder: Path = fileUtil.getDataDir()) -> Path:
"""
save a new xml file in the given folder
@ -21,7 +17,7 @@ def requestAndSaveMeetingData(folder: Path = getDefaultFolder()) -> Path:
return saveMeetingsData(bbbRequest.requestMeetingData(), folder)
def saveMeetingsData(dataStr: str, folder: Path = getDefaultFolder()) -> Path:
def saveMeetingsData(dataStr: str, folder: Path = fileUtil.getDataDir()) -> Path:
"""
save a new xml file in the given folder

View File

@ -11,6 +11,13 @@ def getProjectBaseDir() -> Path:
return getWorkingDir().parent.parent.parent
def getDataDir() -> Path:
"""
:return: The default data directory
"""
return getProjectBaseDir().joinpath("data")
def readFirstLine(file: Path) -> str:
"""
:param file: Path to file