tg-prepare 1.1.0__tar.gz → 2.1.0b2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of tg-prepare might be problematic. Click here for more details.
- {tg_prepare-1.1.0/tg_prepare.egg-info → tg_prepare-2.1.0b2}/PKG-INFO +3 -3
- {tg_prepare-1.1.0 → tg_prepare-2.1.0b2}/setup.py +4 -3
- {tg_prepare-1.1.0 → tg_prepare-2.1.0b2/tg_prepare.egg-info}/PKG-INFO +3 -3
- tg_prepare-2.1.0b2/tg_prepare.egg-info/SOURCES.txt +83 -0
- tg_prepare-2.1.0b2/tg_prepare.egg-info/projects/.secret_key +1 -0
- {tg_prepare-1.1.0 → tg_prepare-2.1.0b2}/tg_prepare.egg-info/requires.txt +2 -2
- {tg_prepare-1.1.0 → tg_prepare-2.1.0b2}/tgp_backend/__init__.py +3 -4
- tg_prepare-2.1.0b2/tgp_backend/config.py +31 -0
- {tg_prepare-1.1.0 → tg_prepare-2.1.0b2}/tgp_backend/directories.py +6 -8
- {tg_prepare-1.1.0 → tg_prepare-2.1.0b2}/tgp_backend/nextcloud.py +40 -19
- {tg_prepare-1.1.0 → tg_prepare-2.1.0b2}/tgp_backend/project.py +172 -45
- tg_prepare-2.1.0b2/tgp_backend/session_manager.py +47 -0
- tg_prepare-2.1.0b2/tgp_backend/util.py +131 -0
- tg_prepare-2.1.0b2/tgp_ui/app.py +130 -0
- tg_prepare-2.1.0b2/tgp_ui/routes/__init__.py +0 -0
- tg_prepare-2.1.0b2/tgp_ui/routes/collection.py +272 -0
- tg_prepare-2.1.0b2/tgp_ui/routes/data.py +228 -0
- tg_prepare-2.1.0b2/tgp_ui/routes/project.py +102 -0
- tg_prepare-2.1.0b2/tgp_ui/routes/publication.py +129 -0
- tg_prepare-2.1.0b2/tgp_ui/routes/tabs.py +34 -0
- tg_prepare-2.1.0b2/tgp_ui/routes/views.py +62 -0
- tg_prepare-2.1.0b2/tgp_ui/static/css/navbar.css +92 -0
- tg_prepare-2.1.0b2/tgp_ui/static/img/textgrid-logo.svg +1 -0
- tg_prepare-2.1.0b2/tgp_ui/static/js/collectionManager.js +60 -0
- tg_prepare-2.1.0b2/tgp_ui/static/js/fileManager.js +186 -0
- tg_prepare-2.1.0b2/tgp_ui/static/js/main.js +36 -0
- tg_prepare-2.1.0b2/tgp_ui/static/js/modalManager.js +105 -0
- tg_prepare-2.1.0b2/tgp_ui/static/js/navbarManager.js +151 -0
- tg_prepare-2.1.0b2/tgp_ui/static/js/projectManager.js +60 -0
- tg_prepare-2.1.0b2/tgp_ui/static/js/require.js +5 -0
- tg_prepare-2.1.0b2/tgp_ui/static/js/sidebarManager.js +32 -0
- tg_prepare-2.1.0b2/tgp_ui/static/js/tabManager.js +79 -0
- tg_prepare-2.1.0b2/tgp_ui/templates/details/empty_container.html +16 -0
- tg_prepare-2.1.0b2/tgp_ui/templates/details/manage_collection.html +205 -0
- tg_prepare-2.1.0b2/tgp_ui/templates/includes/set_session_id_form.html +16 -0
- tg_prepare-2.1.0b2/tgp_ui/templates/includes/upload_form.html +131 -0
- tg_prepare-2.1.0b2/tgp_ui/templates/layout.html +61 -0
- tg_prepare-2.1.0b2/tgp_ui/templates/macros.html +101 -0
- tg_prepare-2.1.0b2/tgp_ui/templates/modal/delete_project.html +25 -0
- tg_prepare-2.1.0b2/tgp_ui/templates/modal/empty_container.html +9 -0
- tg_prepare-2.1.0b2/tgp_ui/templates/modal/file_explorer_content.html +34 -0
- tg_prepare-2.1.0b2/tgp_ui/templates/modal/file_explorer_main.html +22 -0
- tg_prepare-2.1.0b2/tgp_ui/templates/modal/file_explorer_nextcloud.html +27 -0
- tg_prepare-2.1.0b2/tgp_ui/templates/modal/github_modal.html +29 -0
- tg_prepare-2.1.0b2/tgp_ui/templates/modal/nextcloud_login.html +48 -0
- tg_prepare-2.1.0b2/tgp_ui/templates/modal/tei_explorer.html +58 -0
- tg_prepare-2.1.0b2/tgp_ui/templates/modal/xpath_parser.html +52 -0
- tg_prepare-2.1.0b2/tgp_ui/templates/project_main.html +36 -0
- tg_prepare-2.1.0b2/tgp_ui/templates/project_navbar.html +81 -0
- tg_prepare-1.1.0/tgp_ui/templates/projects.html → tg_prepare-2.1.0b2/tgp_ui/templates/projects_main.html +13 -28
- tg_prepare-2.1.0b2/tgp_ui/templates/tab_final_upload.html +29 -0
- tg_prepare-2.1.0b2/tgp_ui/templates/tabs/check_result.html +90 -0
- tg_prepare-2.1.0b2/tgp_ui/templates/tabs/edit_project.html +113 -0
- tg_prepare-2.1.0b2/tgp_ui/templates/tabs/empty_container.html +12 -0
- tg_prepare-2.1.0b2/tgp_ui/templates/tabs/import_data.html +138 -0
- tg_prepare-2.1.0b2/tgp_ui/templates/tabs/manage_collections.html +88 -0
- tg_prepare-2.1.0b2/tgp_ui/templates/tabs/select_directories.html +41 -0
- tg_prepare-2.1.0b2/tgp_ui/templates/tabs/upload.html +42 -0
- tg_prepare-2.1.0b2/tgp_ui/templates/tabs/validate_metadata.html +227 -0
- tg_prepare-1.1.0/tg_prepare.egg-info/SOURCES.txt +0 -46
- tg_prepare-1.1.0/tgp_backend/util.py +0 -83
- tg_prepare-1.1.0/tgp_ui/app.py +0 -422
- tg_prepare-1.1.0/tgp_ui/static/js/main.js +0 -489
- tg_prepare-1.1.0/tgp_ui/templates/collection.html +0 -194
- tg_prepare-1.1.0/tgp_ui/templates/file_upload.html +0 -24
- tg_prepare-1.1.0/tgp_ui/templates/layout.html +0 -100
- tg_prepare-1.1.0/tgp_ui/templates/macros.html +0 -94
- tg_prepare-1.1.0/tgp_ui/templates/nxc_file_tree.html +0 -33
- tg_prepare-1.1.0/tgp_ui/templates/project.html +0 -26
- tg_prepare-1.1.0/tgp_ui/templates/storage.html +0 -49
- tg_prepare-1.1.0/tgp_ui/templates/tei_explorer.html +0 -48
- tg_prepare-1.1.0/tgp_ui/templates/xpath_parser_modal_content.html +0 -37
- {tg_prepare-1.1.0 → tg_prepare-2.1.0b2}/LICENSE +0 -0
- {tg_prepare-1.1.0 → tg_prepare-2.1.0b2}/MANIFEST.in +0 -0
- {tg_prepare-1.1.0 → tg_prepare-2.1.0b2}/README.md +0 -0
- {tg_prepare-1.1.0 → tg_prepare-2.1.0b2}/pyproject.toml +0 -0
- {tg_prepare-1.1.0 → tg_prepare-2.1.0b2}/setup.cfg +0 -0
- {tg_prepare-1.1.0 → tg_prepare-2.1.0b2}/tg_prepare.egg-info/dependency_links.txt +0 -0
- {tg_prepare-1.1.0 → tg_prepare-2.1.0b2}/tg_prepare.egg-info/entry_points.txt +0 -0
- {tg_prepare-1.1.0 → tg_prepare-2.1.0b2}/tg_prepare.egg-info/top_level.txt +0 -0
- {tg_prepare-1.1.0 → tg_prepare-2.1.0b2}/tgp_backend/auth.py +0 -0
- {tg_prepare-1.1.0 → tg_prepare-2.1.0b2}/tgp_backend/cli.py +0 -0
- {tg_prepare-1.1.0 → tg_prepare-2.1.0b2}/tgp_backend/interfaces.py +0 -0
- {tg_prepare-1.1.0 → tg_prepare-2.1.0b2}/tgp_backend/tgclient.py +0 -0
- {tg_prepare-1.1.0 → tg_prepare-2.1.0b2}/tgp_ui/__init__.py +0 -0
- {tg_prepare-1.1.0 → tg_prepare-2.1.0b2}/tgp_ui/static/css/bootstrap-icons.min.css +0 -0
- {tg_prepare-1.1.0 → tg_prepare-2.1.0b2}/tgp_ui/static/css/bootstrap.min.css +0 -0
- {tg_prepare-1.1.0 → tg_prepare-2.1.0b2}/tgp_ui/static/css/bootstrap.min.css.map +0 -0
- {tg_prepare-1.1.0 → tg_prepare-2.1.0b2}/tgp_ui/static/css/main.css +0 -0
- {tg_prepare-1.1.0 → tg_prepare-2.1.0b2}/tgp_ui/static/css/simpleXML.css +0 -0
- {tg_prepare-1.1.0 → tg_prepare-2.1.0b2}/tgp_ui/static/img/favicon.ico +0 -0
- {tg_prepare-1.1.0 → tg_prepare-2.1.0b2}/tgp_ui/static/js/bootstrap.bundle.min.js +0 -0
- {tg_prepare-1.1.0 → tg_prepare-2.1.0b2}/tgp_ui/static/js/jquery.min.js +0 -0
- {tg_prepare-1.1.0 → tg_prepare-2.1.0b2}/tgp_ui/static/js/simpleXML.js +0 -0
- {tg_prepare-1.1.0 → tg_prepare-2.1.0b2}/tgp_ui/templates/file_tree.html +0 -0
- {tg_prepare-1.1.0 → tg_prepare-2.1.0b2}/tgp_ui/templates/nxc_login.html +0 -0
- {tg_prepare-1.1.0 → tg_prepare-2.1.0b2}/tgp_ui/templates/nxc_tab.html +0 -0
- {tg_prepare-1.1.0 → tg_prepare-2.1.0b2}/tgp_ui/templates/publication.html +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tg_prepare
|
|
3
|
-
Version:
|
|
3
|
+
Version: 2.1.0b2
|
|
4
4
|
Summary: Simple UI to handle TextGrid imports visually.
|
|
5
5
|
Author: Ralf Klammer, Moritz Wilhelm
|
|
6
6
|
Author-email: ralf.klammer@tu-dresden.de, moritz.wilhelm@tu-dresden.de
|
|
@@ -8,8 +8,8 @@ License-File: LICENSE
|
|
|
8
8
|
Requires-Dist: click
|
|
9
9
|
Requires-Dist: flask
|
|
10
10
|
Requires-Dist: flask_json
|
|
11
|
-
Requires-Dist: tg_model
|
|
12
|
-
Requires-Dist: tgclients
|
|
11
|
+
Requires-Dist: tg_model==3.8.0.b2
|
|
12
|
+
Requires-Dist: tgclients
|
|
13
13
|
Requires-Dist: tgadmin
|
|
14
14
|
Requires-Dist: nextcloud-api-wrapper
|
|
15
15
|
Dynamic: author
|
|
@@ -7,17 +7,18 @@ from setuptools import setup, find_packages
|
|
|
7
7
|
|
|
8
8
|
setup(
|
|
9
9
|
name="tg_prepare",
|
|
10
|
-
version="
|
|
10
|
+
version="2.1.0.b2",
|
|
11
11
|
description="Simple UI to handle TextGrid imports visually.",
|
|
12
12
|
author="Ralf Klammer, Moritz Wilhelm",
|
|
13
13
|
author_email="ralf.klammer@tu-dresden.de, moritz.wilhelm@tu-dresden.de",
|
|
14
14
|
packages=find_packages(),
|
|
15
|
+
include_package_data=True,
|
|
15
16
|
install_requires=[
|
|
16
17
|
"click",
|
|
17
18
|
"flask",
|
|
18
19
|
"flask_json",
|
|
19
|
-
"tg_model
|
|
20
|
-
"tgclients
|
|
20
|
+
"tg_model==3.8.0.b2",
|
|
21
|
+
"tgclients",
|
|
21
22
|
"tgadmin",
|
|
22
23
|
"nextcloud-api-wrapper",
|
|
23
24
|
],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tg_prepare
|
|
3
|
-
Version:
|
|
3
|
+
Version: 2.1.0b2
|
|
4
4
|
Summary: Simple UI to handle TextGrid imports visually.
|
|
5
5
|
Author: Ralf Klammer, Moritz Wilhelm
|
|
6
6
|
Author-email: ralf.klammer@tu-dresden.de, moritz.wilhelm@tu-dresden.de
|
|
@@ -8,8 +8,8 @@ License-File: LICENSE
|
|
|
8
8
|
Requires-Dist: click
|
|
9
9
|
Requires-Dist: flask
|
|
10
10
|
Requires-Dist: flask_json
|
|
11
|
-
Requires-Dist: tg_model
|
|
12
|
-
Requires-Dist: tgclients
|
|
11
|
+
Requires-Dist: tg_model==3.8.0.b2
|
|
12
|
+
Requires-Dist: tgclients
|
|
13
13
|
Requires-Dist: tgadmin
|
|
14
14
|
Requires-Dist: nextcloud-api-wrapper
|
|
15
15
|
Dynamic: author
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
MANIFEST.in
|
|
3
|
+
README.md
|
|
4
|
+
pyproject.toml
|
|
5
|
+
setup.py
|
|
6
|
+
tg_prepare.egg-info/PKG-INFO
|
|
7
|
+
tg_prepare.egg-info/SOURCES.txt
|
|
8
|
+
tg_prepare.egg-info/dependency_links.txt
|
|
9
|
+
tg_prepare.egg-info/entry_points.txt
|
|
10
|
+
tg_prepare.egg-info/requires.txt
|
|
11
|
+
tg_prepare.egg-info/top_level.txt
|
|
12
|
+
tg_prepare.egg-info/projects/.secret_key
|
|
13
|
+
tgp_backend/__init__.py
|
|
14
|
+
tgp_backend/auth.py
|
|
15
|
+
tgp_backend/cli.py
|
|
16
|
+
tgp_backend/config.py
|
|
17
|
+
tgp_backend/directories.py
|
|
18
|
+
tgp_backend/interfaces.py
|
|
19
|
+
tgp_backend/nextcloud.py
|
|
20
|
+
tgp_backend/project.py
|
|
21
|
+
tgp_backend/session_manager.py
|
|
22
|
+
tgp_backend/tgclient.py
|
|
23
|
+
tgp_backend/util.py
|
|
24
|
+
tgp_ui/__init__.py
|
|
25
|
+
tgp_ui/app.py
|
|
26
|
+
tgp_ui/routes/__init__.py
|
|
27
|
+
tgp_ui/routes/collection.py
|
|
28
|
+
tgp_ui/routes/data.py
|
|
29
|
+
tgp_ui/routes/project.py
|
|
30
|
+
tgp_ui/routes/publication.py
|
|
31
|
+
tgp_ui/routes/tabs.py
|
|
32
|
+
tgp_ui/routes/views.py
|
|
33
|
+
tgp_ui/static/css/bootstrap-icons.min.css
|
|
34
|
+
tgp_ui/static/css/bootstrap.min.css
|
|
35
|
+
tgp_ui/static/css/bootstrap.min.css.map
|
|
36
|
+
tgp_ui/static/css/main.css
|
|
37
|
+
tgp_ui/static/css/navbar.css
|
|
38
|
+
tgp_ui/static/css/simpleXML.css
|
|
39
|
+
tgp_ui/static/img/favicon.ico
|
|
40
|
+
tgp_ui/static/img/textgrid-logo.svg
|
|
41
|
+
tgp_ui/static/js/bootstrap.bundle.min.js
|
|
42
|
+
tgp_ui/static/js/collectionManager.js
|
|
43
|
+
tgp_ui/static/js/fileManager.js
|
|
44
|
+
tgp_ui/static/js/jquery.min.js
|
|
45
|
+
tgp_ui/static/js/main.js
|
|
46
|
+
tgp_ui/static/js/modalManager.js
|
|
47
|
+
tgp_ui/static/js/navbarManager.js
|
|
48
|
+
tgp_ui/static/js/projectManager.js
|
|
49
|
+
tgp_ui/static/js/require.js
|
|
50
|
+
tgp_ui/static/js/sidebarManager.js
|
|
51
|
+
tgp_ui/static/js/simpleXML.js
|
|
52
|
+
tgp_ui/static/js/tabManager.js
|
|
53
|
+
tgp_ui/templates/file_tree.html
|
|
54
|
+
tgp_ui/templates/layout.html
|
|
55
|
+
tgp_ui/templates/macros.html
|
|
56
|
+
tgp_ui/templates/nxc_login.html
|
|
57
|
+
tgp_ui/templates/nxc_tab.html
|
|
58
|
+
tgp_ui/templates/project_main.html
|
|
59
|
+
tgp_ui/templates/project_navbar.html
|
|
60
|
+
tgp_ui/templates/projects_main.html
|
|
61
|
+
tgp_ui/templates/publication.html
|
|
62
|
+
tgp_ui/templates/tab_final_upload.html
|
|
63
|
+
tgp_ui/templates/details/empty_container.html
|
|
64
|
+
tgp_ui/templates/details/manage_collection.html
|
|
65
|
+
tgp_ui/templates/includes/set_session_id_form.html
|
|
66
|
+
tgp_ui/templates/includes/upload_form.html
|
|
67
|
+
tgp_ui/templates/modal/delete_project.html
|
|
68
|
+
tgp_ui/templates/modal/empty_container.html
|
|
69
|
+
tgp_ui/templates/modal/file_explorer_content.html
|
|
70
|
+
tgp_ui/templates/modal/file_explorer_main.html
|
|
71
|
+
tgp_ui/templates/modal/file_explorer_nextcloud.html
|
|
72
|
+
tgp_ui/templates/modal/github_modal.html
|
|
73
|
+
tgp_ui/templates/modal/nextcloud_login.html
|
|
74
|
+
tgp_ui/templates/modal/tei_explorer.html
|
|
75
|
+
tgp_ui/templates/modal/xpath_parser.html
|
|
76
|
+
tgp_ui/templates/tabs/check_result.html
|
|
77
|
+
tgp_ui/templates/tabs/edit_project.html
|
|
78
|
+
tgp_ui/templates/tabs/empty_container.html
|
|
79
|
+
tgp_ui/templates/tabs/import_data.html
|
|
80
|
+
tgp_ui/templates/tabs/manage_collections.html
|
|
81
|
+
tgp_ui/templates/tabs/select_directories.html
|
|
82
|
+
tgp_ui/templates/tabs/upload.html
|
|
83
|
+
tgp_ui/templates/tabs/validate_metadata.html
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"94c9d50a8949b627be9608827a66d0025919e013d89236b092de90dd0b79fd12"
|
|
@@ -4,15 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
import logging
|
|
6
6
|
|
|
7
|
-
from .
|
|
7
|
+
from .config import LOG_LEVEL
|
|
8
8
|
|
|
9
9
|
log = logging.getLogger(__name__)
|
|
10
10
|
|
|
11
|
-
log_level = config("log", "level", default="INFO")
|
|
12
11
|
log_config = dict(
|
|
13
|
-
level=
|
|
12
|
+
level=LOG_LEVEL,
|
|
14
13
|
format="%(asctime)s %(name)-10s %(levelname)-4s %(message)s",
|
|
15
14
|
)
|
|
16
15
|
|
|
17
16
|
logging.basicConfig(**log_config)
|
|
18
|
-
logging.getLogger("").setLevel(
|
|
17
|
+
logging.getLogger("").setLevel(LOG_LEVEL)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Copyright (C) 2023-2024 TU-Dresden (ZIH)
|
|
3
|
+
# ralf.klammer@tu-dresden.de
|
|
4
|
+
import logging
|
|
5
|
+
|
|
6
|
+
from configparser import ConfigParser
|
|
7
|
+
|
|
8
|
+
log = logging.getLogger(__name__)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def get_config_value(section, parameter, default=None):
|
|
12
|
+
_config = ConfigParser()
|
|
13
|
+
_config.read("config.ini")
|
|
14
|
+
|
|
15
|
+
if section not in _config:
|
|
16
|
+
log.warn("Section: %s not in *.ini -> using default" % section)
|
|
17
|
+
return default
|
|
18
|
+
config_val = _config[section].get(parameter)
|
|
19
|
+
if not config_val:
|
|
20
|
+
log.info(
|
|
21
|
+
"Parameter: %s not in section: (%s) of *.ini -> using default: %s"
|
|
22
|
+
% (parameter, section, default)
|
|
23
|
+
)
|
|
24
|
+
return default
|
|
25
|
+
else:
|
|
26
|
+
return config_val
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
LOG_LEVEL = get_config_value("log", "level", default="INFO")
|
|
30
|
+
MAIN_PATH = get_config_value("main", "path", default="./projects")
|
|
31
|
+
MAX_FILENAME_LENGTH = get_config_value("main", "maxFileNameLength", default=15)
|
|
@@ -6,13 +6,11 @@ import logging
|
|
|
6
6
|
import os
|
|
7
7
|
import re
|
|
8
8
|
|
|
9
|
-
from tgp_backend.
|
|
10
|
-
|
|
9
|
+
from tgp_backend.config import MAX_FILENAME_LENGTH
|
|
10
|
+
from tgp_backend.util import get_file_extension
|
|
11
11
|
|
|
12
12
|
log = logging.getLogger(__name__)
|
|
13
13
|
|
|
14
|
-
maxFileNameLength = config("main", "maxFileNameLength", default=15)
|
|
15
|
-
|
|
16
14
|
|
|
17
15
|
def generateList(path=None):
|
|
18
16
|
# path = path if path else config("main", "path", default="/tmp")
|
|
@@ -38,12 +36,12 @@ def generateList(path=None):
|
|
|
38
36
|
curDir = path
|
|
39
37
|
|
|
40
38
|
for d in dList:
|
|
41
|
-
if len(d["name"]) >
|
|
39
|
+
if len(d["name"]) > MAX_FILENAME_LENGTH:
|
|
42
40
|
dots = "..."
|
|
43
41
|
else:
|
|
44
42
|
dots = ""
|
|
45
43
|
temp_dir = {}
|
|
46
|
-
temp_dir["f"] = d["name"][0:
|
|
44
|
+
temp_dir["f"] = d["name"][0:MAX_FILENAME_LENGTH] + dots
|
|
47
45
|
temp_dir["name"] = d["name"]
|
|
48
46
|
temp_dir["f_url"] = re.sub("#", "|HASHTAG|", d["fullpath"])
|
|
49
47
|
temp_dir["currentDir"] = curDir
|
|
@@ -61,12 +59,12 @@ def generateList(path=None):
|
|
|
61
59
|
pass
|
|
62
60
|
if not image:
|
|
63
61
|
image = "files_icon/unknown-icon.png"
|
|
64
|
-
if len(f["name"]) >
|
|
62
|
+
if len(f["name"]) > MAX_FILENAME_LENGTH:
|
|
65
63
|
dots = "..."
|
|
66
64
|
else:
|
|
67
65
|
dots = ""
|
|
68
66
|
temp_file = {}
|
|
69
|
-
temp_file["f"] = f["name"][0:
|
|
67
|
+
temp_file["f"] = f["name"][0:MAX_FILENAME_LENGTH] + dots
|
|
70
68
|
temp_file["name"] = f["name"]
|
|
71
69
|
temp_file["name_stripped"] = f["name"].replace(f".{tp}", "")
|
|
72
70
|
temp_file["f_url"] = re.sub("#", "|HASHTAG|", f["fullpath"])
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
# moritz.wilhelm@tu-dresden.de
|
|
5
5
|
|
|
6
6
|
import logging
|
|
7
|
-
|
|
8
7
|
import nextcloud
|
|
9
8
|
import os
|
|
10
9
|
|
|
@@ -14,21 +13,21 @@ log = logging.getLogger(__name__)
|
|
|
14
13
|
class Nextcloud:
|
|
15
14
|
def __init__(
|
|
16
15
|
self,
|
|
17
|
-
|
|
16
|
+
url=None,
|
|
18
17
|
username=None,
|
|
19
18
|
password=None,
|
|
20
|
-
|
|
19
|
+
folder=None,
|
|
21
20
|
**kwargs,
|
|
22
21
|
):
|
|
23
22
|
self._nxc = None
|
|
24
23
|
self._root = None
|
|
25
|
-
self.
|
|
24
|
+
self.url = url
|
|
26
25
|
self.username = username
|
|
27
26
|
self.password = password
|
|
28
|
-
self.root_dir =
|
|
27
|
+
self.root_dir = folder
|
|
29
28
|
|
|
30
29
|
def test_connection(self):
|
|
31
|
-
if all([self.
|
|
30
|
+
if all([self.url, self.username, self.password]):
|
|
32
31
|
return str(self.nxc.list_folders().status_code).startswith("2")
|
|
33
32
|
return False
|
|
34
33
|
|
|
@@ -36,7 +35,7 @@ class Nextcloud:
|
|
|
36
35
|
def nxc(self):
|
|
37
36
|
if self._nxc is None:
|
|
38
37
|
self._nxc = nextcloud.NextCloud(
|
|
39
|
-
endpoint=self.
|
|
38
|
+
endpoint=self.url,
|
|
40
39
|
user=self.username,
|
|
41
40
|
password=self.password,
|
|
42
41
|
)
|
|
@@ -51,29 +50,51 @@ class Nextcloud:
|
|
|
51
50
|
raise "Could not find the Root Directory"
|
|
52
51
|
return self._root
|
|
53
52
|
|
|
54
|
-
def nxc_list_files_and_folders(self):
|
|
53
|
+
def nxc_list_files_and_folders(self, get_selectable=False):
|
|
54
|
+
|
|
55
|
+
selectable_folders = []
|
|
55
56
|
|
|
56
|
-
def
|
|
57
|
+
def recursive_list(item, depth=0):
|
|
57
58
|
items = []
|
|
58
59
|
for d in item.list():
|
|
59
60
|
if d.isdir():
|
|
60
|
-
children =
|
|
61
|
+
children = recursive_list(d, depth=depth + 1)
|
|
62
|
+
contains_xml = any(
|
|
63
|
+
f.get("name", "").endswith(".xml") for f in children
|
|
64
|
+
)
|
|
65
|
+
item = {
|
|
66
|
+
"type": "folder",
|
|
67
|
+
"name": d.basename(),
|
|
68
|
+
"depth": depth,
|
|
69
|
+
"path": d.get_relative_path(),
|
|
70
|
+
"contains_xml": contains_xml,
|
|
71
|
+
"children": {
|
|
72
|
+
"count": len(children),
|
|
73
|
+
"list": children,
|
|
74
|
+
},
|
|
75
|
+
}
|
|
76
|
+
items.append(item)
|
|
77
|
+
if contains_xml:
|
|
78
|
+
selectable_folders.append(item)
|
|
79
|
+
else:
|
|
61
80
|
items.append(
|
|
62
81
|
{
|
|
63
|
-
"type": "
|
|
82
|
+
"type": "file",
|
|
64
83
|
"name": d.basename(),
|
|
65
|
-
"
|
|
66
|
-
"children": {
|
|
67
|
-
"count": len(children),
|
|
68
|
-
"list": children,
|
|
69
|
-
},
|
|
84
|
+
"depth": depth,
|
|
70
85
|
}
|
|
71
86
|
)
|
|
72
|
-
else:
|
|
73
|
-
items.append({"type": "file", "name": d.basename()})
|
|
74
87
|
return items
|
|
75
88
|
|
|
76
|
-
|
|
89
|
+
result = recursive_list(self.root)
|
|
90
|
+
if get_selectable:
|
|
91
|
+
return selectable_folders
|
|
92
|
+
else:
|
|
93
|
+
return result
|
|
94
|
+
|
|
95
|
+
def get_selectable_folders(self):
|
|
96
|
+
|
|
97
|
+
return self.nxc_list_files_and_folders(get_selectable=True)
|
|
77
98
|
|
|
78
99
|
def download_nxc_files(self, file_paths, projectname):
|
|
79
100
|
for path in file_paths:
|