aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Arakaki Giovanini <mail@gabrielgio.me>2022-10-01 13:47:39 +0200
committerGabriel Arakaki Giovanini <mail@gabrielgio.me>2022-10-01 13:47:39 +0200
commitc6cd5e6d8d174931aafc47ad26435574dd90fe9d (patch)
tree569534b3d86d7af9a631f357213c2465796ea52b
parentd41454406672931e47f72202eab1424fc6f8f1f6 (diff)
downloadreddit-nextcloud-importer-c6cd5e6d8d174931aafc47ad26435574dd90fe9d.tar.gz
reddit-nextcloud-importer-c6cd5e6d8d174931aafc47ad26435574dd90fe9d.tar.bz2
reddit-nextcloud-importer-c6cd5e6d8d174931aafc47ad26435574dd90fe9d.zip
feat: Remove importer
I don't want to deal with pain of python modules *now*
-rw-r--r--reddit-nextcloud-importer/__main__.py20
-rw-r--r--reddit-nextcloud-importer/importer/__init__.py0
-rw-r--r--reddit-nextcloud-importer/importer/uploader.py19
3 files changed, 19 insertions, 20 deletions
diff --git a/reddit-nextcloud-importer/__main__.py b/reddit-nextcloud-importer/__main__.py
index 2f34b3a..abddfdd 100644
--- a/reddit-nextcloud-importer/__main__.py
+++ b/reddit-nextcloud-importer/__main__.py
@@ -9,7 +9,9 @@ from nextcloud import NextCloud
from praw.models.util import stream_generator
from gallery_dl.job import DownloadJob
-from importer.uploader import upload_file, create_folders
+from functools import reduce
+
+from nextcloud import NextCloud
levels = {
'critical': logging.CRITICAL,
@@ -56,6 +58,22 @@ parser.add_argument('-l', '--log-level',
help=f'it will set log level.')
+def _create_folder(folder: str, nxc: NextCloud) -> str:
+ nxc.create_folder(folder, True)
+ return folder
+
+
+def create_folders(path: str, nxc: NextCloud):
+ # remove first "/" if there is one.
+ path = path if path[0] != '/' else path[1:]
+ folders = path.split("/")
+ reduce(lambda x, y: _create_folder(f"{x}/{y}", nxc), folders, "")
+
+
+def upload_file(local_filename: str, remote_filename: str, nxc: NextCloud):
+ nxc.upload_file(local_filename, remote_filename)
+
+
def get_list_of_files(dirName):
# create a list of file and sub directories
# names in the given directory
diff --git a/reddit-nextcloud-importer/importer/__init__.py b/reddit-nextcloud-importer/importer/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/reddit-nextcloud-importer/importer/__init__.py
+++ /dev/null
diff --git a/reddit-nextcloud-importer/importer/uploader.py b/reddit-nextcloud-importer/importer/uploader.py
deleted file mode 100644
index 7c7641a..0000000
--- a/reddit-nextcloud-importer/importer/uploader.py
+++ /dev/null
@@ -1,19 +0,0 @@
-from functools import reduce
-
-from nextcloud import NextCloud
-
-
-def _create_folder(folder: str, nxc: NextCloud) -> str:
- nxc.create_folder(folder, True)
- return folder
-
-
-def create_folders(path: str, nxc: NextCloud):
- # remove first "/" if there is one.
- path = path if path[0] != '/' else path[1:]
- folders = path.split("/")
- reduce(lambda x, y: _create_folder(f"{x}/{y}", nxc), folders, "")
-
-
-def upload_file(local_filename: str, remote_filename: str, nxc: NextCloud):
- nxc.upload_file(local_filename, remote_filename)