From 154f2ed33377ea4cfb5037b150f126fe4370b17b Mon Sep 17 00:00:00 2001 From: langfingaz Date: Tue, 2 Mar 2021 12:28:17 +0100 Subject: [PATCH] default data directory --- src/langfingaz/logMeetingData.py | 5 +++-- src/langfingaz/plotMeetings.py | 6 +++++- src/langfingaz/saveData.py | 8 ++------ src/langfingaz/util/fileUtil.py | 7 +++++++ 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/langfingaz/logMeetingData.py b/src/langfingaz/logMeetingData.py index bca3803..0be165e 100755 --- a/src/langfingaz/logMeetingData.py +++ b/src/langfingaz/logMeetingData.py @@ -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('.') diff --git a/src/langfingaz/plotMeetings.py b/src/langfingaz/plotMeetings.py index aeca0d4..2aa00b5 100644 --- a/src/langfingaz/plotMeetings.py +++ b/src/langfingaz/plotMeetings.py @@ -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(): diff --git a/src/langfingaz/saveData.py b/src/langfingaz/saveData.py index a0c74d8..2dc1741 100644 --- a/src/langfingaz/saveData.py +++ b/src/langfingaz/saveData.py @@ -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 diff --git a/src/langfingaz/util/fileUtil.py b/src/langfingaz/util/fileUtil.py index c4493c3..dbb9d08 100644 --- a/src/langfingaz/util/fileUtil.py +++ b/src/langfingaz/util/fileUtil.py @@ -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