aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)