From e74ff560ba30fbf029a21f320dd37b3b345f451e Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Tue, 27 Sep 2022 21:08:08 -0300 Subject: Changed to using local org files --- bofa.py | 5 ++--- nextcloud.py | 8 -------- org.py | 23 +++++------------------ settings.py | 7 ++++--- 4 files changed, 11 insertions(+), 32 deletions(-) delete mode 100644 nextcloud.py diff --git a/bofa.py b/bofa.py index 3d47411..3a84427 100644 --- a/bofa.py +++ b/bofa.py @@ -2,13 +2,12 @@ from pyexcel_ods3 import get_data -from nextcloud import NextCloudConnection from settings import EXPENSES_FILENAME -class BofaData(NextCloudConnection): +class BofaData(): def get(self) -> None: - with self.client.open(EXPENSES_FILENAME, mode="rb") as expenses: + with open(EXPENSES_FILENAME, "rb") as expenses: data = get_data(expenses) main_page = data.get("Main") diff --git a/nextcloud.py b/nextcloud.py deleted file mode 100644 index 5a530df..0000000 --- a/nextcloud.py +++ /dev/null @@ -1,8 +0,0 @@ -from webdav4.client import Client - -from settings import NEXTCLOUD_PASSWORD, NEXTCLOUD_URL, NEXTCLOUD_USERNAME - - -class NextCloudConnection: - def __init__(self): - self.client = Client(NEXTCLOUD_URL, auth=(NEXTCLOUD_USERNAME, NEXTCLOUD_PASSWORD)) diff --git a/org.py b/org.py index dde53ae..898bae4 100644 --- a/org.py +++ b/org.py @@ -1,16 +1,14 @@ import locale -import os from datetime import datetime from orgparse import loads -from nextcloud import NextCloudConnection from settings import ORG_CAPTURE_FILENAME, ORG_LINKS_FILENAME, ORG_PLAN_FILENAME locale.setlocale(locale.LC_ALL, "es_ES.utf8") -class OrgData(NextCloudConnection): +class OrgData(): def _generate_today(self): today = datetime.today() today_ymd = today.strftime("%Y-%m-%d") @@ -20,8 +18,6 @@ class OrgData(NextCloudConnection): def add_new_todo(self, keyword: str, description: str, outcome: str, extra: str) -> None: - self.client.download_file(ORG_CAPTURE_FILENAME, "./capture.org") - today = self._generate_today() todo_template = f""" @@ -35,15 +31,12 @@ class OrgData(NextCloudConnection): """ - with open("./capture.org", "a") as capture_file: + print(ORG_CAPTURE_FILENAME) + with open(ORG_CAPTURE_FILENAME, "a") as capture_file: capture_file.write(todo_template) - self.client.upload_file("./capture.org", ORG_CAPTURE_FILENAME, overwrite=True) - - os.remove("./capture.org") - def list_plan(self, filename: str) -> str: - with self.client.open(ORG_PLAN_FILENAME.replace("{filename}", filename), mode="r") as agenda: + with open(ORG_PLAN_FILENAME.replace("{filename}", filename), "r") as agenda: plan = agenda.read() plan = loads(plan) @@ -52,11 +45,5 @@ class OrgData(NextCloudConnection): def add_new_link(self, link: str) -> None: - self.client.download_file(ORG_LINKS_FILENAME, "./links.org") - - with open("./links.org", "a") as capture_file: + with open(ORG_LINKS_FILENAME, "a") as capture_file: capture_file.write(link) - - self.client.upload_file("./links.org", ORG_LINKS_FILENAME, overwrite=True) - - os.remove("./links.org") diff --git a/settings.py b/settings.py index d6866b7..727b2c5 100644 --- a/settings.py +++ b/settings.py @@ -22,9 +22,10 @@ NEXTCLOUD_URL = os.environ.get("NEXTCLOUD_URL") NEXTCLOUD_USERNAME = os.environ.get("NEXTCLOUD_USERNAME") NEXTCLOUD_PASSWORD = os.environ.get("NEXTCLOUD_PASSWORD") -ORG_CAPTURE_FILENAME = os.environ.get("ORG_CAPTURE_FILENAME") -ORG_PLAN_FILENAME = os.environ.get("ORG_PLAN_FILENAME") -ORG_LINKS_FILENAME = os.environ.get("ORG_LINKS_FILENAME") +ORG_LOCATION = os.environ.get("ORG_LOCATION") +ORG_CAPTURE_FILENAME = f"{ORG_LOCATION}/{os.environ.get('ORG_CAPTURE_FILENAME')}" +ORG_PLAN_FILENAME = f"{ORG_LOCATION}/{os.environ.get('ORG_PLAN_FILENAME')}" +ORG_LINKS_FILENAME = f"{ORG_LOCATION}/{os.environ.get('ORG_LINKS_FILENAME')}" PROMETEO_API_KEY = os.environ.get("PROMETEO_API_KEY") PROMETEO_URL = os.environ.get("PROMETEO_URL") -- cgit v1.2.3