safe-file-example 0.3.1__tar.gz → 1.0.0__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.
Files changed (42) hide show
  1. {safe_file_example-0.3.1 → safe_file_example-1.0.0}/.gitlab-ci.yml +2 -1
  2. safe_file_example-1.0.0/.trivyignore +3 -0
  3. safe_file_example-1.0.0/CHANGELOG.md +85 -0
  4. {safe_file_example-0.3.1 → safe_file_example-1.0.0}/PKG-INFO +37 -25
  5. {safe_file_example-0.3.1 → safe_file_example-1.0.0}/README.md +34 -22
  6. {safe_file_example-0.3.1 → safe_file_example-1.0.0}/pyproject.toml +5 -3
  7. safe_file_example-1.0.0/safe/config.py +11 -0
  8. safe_file_example-0.3.1/safe/modules/export_module.py → safe_file_example-1.0.0/safe/export_logic/export_executor.py +19 -13
  9. safe_file_example-1.0.0/safe/export_logic/export_handler.py +207 -0
  10. {safe_file_example-0.3.1/safe/modules → safe_file_example-1.0.0/safe/export_logic}/list_export_module.py +29 -12
  11. safe_file_example-1.0.0/safe/import_logic/import_executor.py +139 -0
  12. safe_file_example-1.0.0/safe/import_logic/import_handler.py +187 -0
  13. safe_file_example-1.0.0/safe/main.py +108 -0
  14. safe_file_example-1.0.0/safe/modules/__init__.py +1 -0
  15. {safe_file_example-0.3.1 → safe_file_example-1.0.0}/safe/modules/helper_functions.py +11 -5
  16. safe_file_example-1.0.0/safe/modules/ldap.py +55 -0
  17. safe_file_example-1.0.0/safe/modules/token_logic.py +56 -0
  18. safe_file_example-1.0.0/tests/__init__.py +1 -0
  19. safe_file_example-0.3.1/tests/test_export_module.py → safe_file_example-1.0.0/tests/export_tests/test_export_executor.py +6 -6
  20. safe_file_example-1.0.0/tests/export_tests/test_export_handler.py +431 -0
  21. {safe_file_example-0.3.1/tests → safe_file_example-1.0.0/tests/export_tests}/test_list_export_module.py +4 -3
  22. safe_file_example-0.3.1/tests/test_import_module.py → safe_file_example-1.0.0/tests/import_tests/test_import_executor.py +44 -77
  23. safe_file_example-1.0.0/tests/import_tests/test_import_handler.py +533 -0
  24. safe_file_example-1.0.0/tests/test_ldap.py +90 -0
  25. safe_file_example-1.0.0/tests/test_main.py +4 -0
  26. safe_file_example-1.0.0/tests/test_token_logic.py +118 -0
  27. {safe_file_example-0.3.1 → safe_file_example-1.0.0}/uv.lock +67 -67
  28. safe_file_example-0.3.1/CHANGELOG.md +0 -56
  29. safe_file_example-0.3.1/safe/main.py +0 -446
  30. safe_file_example-0.3.1/safe/modules/import_module.py +0 -84
  31. safe_file_example-0.3.1/safe/modules/ldap.py +0 -41
  32. safe_file_example-0.3.1/tests/test_ldap.py +0 -62
  33. safe_file_example-0.3.1/tests/test_main.py +0 -956
  34. {safe_file_example-0.3.1 → safe_file_example-1.0.0}/.gitignore +0 -0
  35. {safe_file_example-0.3.1 → safe_file_example-1.0.0}/.pre-commit-config.yaml +0 -0
  36. {safe_file_example-0.3.1 → safe_file_example-1.0.0}/LICENSE +0 -0
  37. {safe_file_example-0.3.1 → safe_file_example-1.0.0}/safe/__init__.py +0 -0
  38. {safe_file_example-0.3.1 → safe_file_example-1.0.0}/safe/assets/safe_logo.png +0 -0
  39. {safe_file_example-0.3.1/safe/modules → safe_file_example-1.0.0/safe/export_logic}/__init__.py +0 -0
  40. {safe_file_example-0.3.1/tests → safe_file_example-1.0.0/safe/import_logic}/__init__.py +0 -0
  41. {safe_file_example-0.3.1 → safe_file_example-1.0.0}/tests/conftest.py +0 -0
  42. {safe_file_example-0.3.1 → safe_file_example-1.0.0}/tests/test_helper_functions.py +0 -0
@@ -9,6 +9,7 @@ include:
9
9
  - template: Jobs/Dependency-Scanning.gitlab-ci.yml
10
10
  - template: Jobs/SAST.gitlab-ci.yml
11
11
 
12
+
12
13
  variables:
13
14
  PIP_CACHE_DIR: "$CI_PROJECT_DIR/.pip-cache"
14
15
  TRIVY_CACHE_DIR: ".cache/trivy"
@@ -44,7 +45,7 @@ build-safe-cli:
44
45
  - python --version
45
46
  - uv --version
46
47
  script:
47
- - echo "Building safe-file-example package..."
48
+ - echo "Building nortre-cli package..."
48
49
  - uv build
49
50
  artifacts:
50
51
  paths:
@@ -0,0 +1,3 @@
1
+ CVE-2026-97687
2
+ CVE-2026-97689
3
+ CVE-2026-97688
@@ -0,0 +1,85 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/2.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ### Types of changes
8
+
9
+ - `Added` for new features.
10
+ - `Changed` for changes in existing functionality. (The behavior worked as intended, and now works differently.)
11
+ - `Deprecated` for soon-to-be removed features.
12
+ - `Removed` for now removed features.
13
+ - `Fixed` for bug fixes. (The behavior was wrong, and is now correct.)
14
+ - `Security` for vulnerabilities. (The change addresses a vulnerability. It could fit under Fixed or Changed, but its urgency and audience are different.)
15
+
16
+ ## [1.0.0] - 2026-10-19
17
+
18
+ ### Changed
19
+ - Replaced `--file-path` command in import with `--filename` to unify the commands with export. `--help` has been updated to reflect this.
20
+ - Colored text in CLI:
21
+ - Red: Errors and critical information/warnings
22
+ - Yellow: Non critical information/warnings
23
+ - Green: Success messages
24
+ - White: Standard message, input prompts and job updates
25
+ - Timeout value error is now less verbose and will occur quicker upon no connection.
26
+ - Updated the help documentation for methods and included example usage for import and export.
27
+ - Added options for viewing help by using --man and --manual in addition to --help.
28
+ - Changed name from safe-file-example to nortre-cli. Commands that can be used are now: safe-cli and safe-file-example.
29
+ - Added spinner when exporting files.
30
+ - Changed import progress from progress-bars to a spinner.
31
+ - Updated the display of the numbered menus to improve visibility
32
+
33
+ ### Added
34
+ - Exit codes: 0 = success, 1 = complete failure, 2 = partial failure
35
+ - The server requests to check access to server and retrieve export file options now displays a spinner to indicate activity.
36
+
37
+ ### Security
38
+ - Security enhancements.
39
+
40
+ ### Fixed
41
+ - Fixed wrong error display when token is expired.
42
+
43
+
44
+ ## [0.3.1] - 2026-09-29
45
+
46
+ ### Fixed
47
+ - Fixed an issue with the URL of SAFE File API.
48
+
49
+
50
+ ## [0.3.0] - 2026-09-25 [YANKED]
51
+
52
+ ### Added
53
+ - Added support for batch importing multiple files via both interactive and non-interactive methods.
54
+ - Added progress indicators for file import operations.
55
+ - Added command `exit` to exit the interactive mode in CLI.
56
+
57
+ ### Fixed
58
+ - Display of file size in menu when exporting files is now limited to one decimal.
59
+
60
+
61
+ ## [0.2.1] - 2026-08-06
62
+
63
+ ### Changed
64
+ - Updated project dependencies.
65
+
66
+
67
+ ## [0.2.0] - 2026-05-11
68
+
69
+ ### Added
70
+ - Added a VPN usage reminder on application startup.
71
+ - Added a JWT token security reminder on application startup.
72
+ - Added automatic version checks on application startup.
73
+ - Added human-friendly display of file size in export file selection.
74
+
75
+
76
+ ## [0.1.1] - 2026-04-20
77
+ - Initial release
78
+
79
+
80
+ [1.0.0]: https://git.app.uib.no/itpublic/python/nortre-cli/-/compare/0.3.1...1.0.0?from_project_id=1062
81
+ [0.3.1]: https://git.app.uib.no/itpublic/python/nortre-cli/-/compare/0.3.0...0.3.1?from_project_id=1062
82
+ [0.3.0]: https://git.app.uib.no/itpublic/python/nortre-cli/-/compare/0.2.1...0.3.0?from_project_id=1062
83
+ [0.2.1]: https://git.app.uib.no/itpublic/python/nortre-cli/-/compare/0.2.0...0.2.1?from_project_id=1062
84
+ [0.2.0]: https://git.app.uib.no/itpublic/python/nortre-cli/-/compare/0.1.1...0.2.0?from_project_id=1062
85
+ [0.1.1]: https://git.app.uib.no/itpublic/python/nortre-cli/-/tree/0.1.1?ref_type=tags
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: safe-file-example
3
- Version: 0.3.1
3
+ Version: 1.0.0
4
4
  Summary: A python package for interacting with SAFE File transfer API
5
- Project-URL: Homepage, https://git.app.uib.no/itpublic/python/safe-file-example
5
+ Project-URL: Homepage, https://git.app.uib.no/itpublic/python/nortre-cli
6
6
  Author-email: Dip Paul <dip.paul@uib.no>, Eirik Halseth <eirik.halseth@uib.no>, Elena Nicole Jacobsen <Elena.Nicole.Jacobsen@uib.no>, Kai Imoda Waløen <kai.waloen@uib.no>, Lukas Lussand Iversen <lukas.lussand.iversen@uib.no>, Marco Antonio Corrales Cardenas <marco.corrales@uib.no>
7
7
  License-File: LICENSE
8
8
  Classifier: Operating System :: OS Independent
@@ -16,7 +16,7 @@ Requires-Dist: idna==3.18
16
16
  Requires-Dist: markdown-it-py==4.2.0
17
17
  Requires-Dist: mdurl==0.1.2
18
18
  Requires-Dist: pygments==2.20.0
19
- Requires-Dist: pyjwt==2.13.0
19
+ Requires-Dist: pyjwt==2.15.0
20
20
  Requires-Dist: requests==2.34.2
21
21
  Requires-Dist: rich==15.0.0
22
22
  Requires-Dist: shellingham==1.5.4
@@ -24,92 +24,103 @@ Requires-Dist: typer==0.27.1
24
24
  Requires-Dist: urllib3==2.7.0
25
25
  Description-Content-Type: text/markdown
26
26
 
27
- # `safe-file-example`
27
+ # `nortre-cli`
28
+
29
+ ## Deprecation warning
30
+ This pip package will be depricated at the end of 2026. Please transfer over to the new package located at https://pypi.org/project/nortre-cli/
31
+
28
32
  ## Description
29
33
 
30
34
  A python package for interacting with SAFE File transfer API
31
35
 
36
+
32
37
  ## Current Functionalities
33
38
 
34
39
  - Generate a JWT Token
35
- - Import a File
36
- - Export a File
40
+ - Import file/s
41
+ - Export a file
42
+ - Exit
43
+
37
44
 
38
45
  ## Prerequisite
39
46
 
40
47
  - Having minimum Python 3.12 installed in your system and setting up a Python Virtual Environment.
41
48
 
49
+
42
50
  ## Workflow
43
51
 
44
52
  - Activate your Python Virtual Environment,
45
53
  - Then run the following command.
46
54
 
47
55
  ```bash
48
- pip install safe-file-example
56
+ pip install nortre-cli
49
57
  ```
50
58
  - To see all the available commands and options run the following
51
59
 
52
60
  ```bash
53
- safe-file-example
61
+ safe-cli
54
62
  ```
55
63
 
56
-
57
64
  **Usage**:
58
65
 
59
66
  ```console
60
- $ safe-file-example [OPTIONS] COMMAND [ARGS]...
67
+ $ safe-cli [OPTIONS] COMMAND [ARGS]...
61
68
  ```
62
69
 
63
70
  **Options**:
64
71
 
65
- * `--help`: Show this message and exit.
72
+ * `--help`, `--man`, `--manual`: Show help and exit.
66
73
 
67
74
  **Commands**:
68
75
 
69
76
  * `get-token`: Get and store access token
70
- * `import-file`: Import a file
77
+ * `import-file`: Import file/s
71
78
  * `export-file`: Export a file
72
79
  * `interactive`: Run interactive mode
80
+ * `exit`: Exits the cli
81
+
73
82
 
74
- ## `safe-file-example get-token`
83
+ ## `safe-cli get-token`
75
84
 
76
85
  Get and store access token
77
86
 
78
87
  **Usage**:
79
88
 
80
89
  ```console
81
- $ safe-file-example get-token [OPTIONS]
90
+ $ safe-cli get-token [OPTIONS]
82
91
  ```
83
92
 
84
93
  **Options**:
85
94
 
86
- * `--help`: Show this message and exit.
95
+ * `--help`, `--man`, `--manual`: Show help and exit.
96
+
87
97
 
88
- ## `safe-file-example import-file`
98
+ ## `safe-cli import-file`
89
99
 
90
100
  Import a file
91
101
 
92
102
  **Usage**:
93
103
 
94
104
  ```console
95
- $ safe-file-example import-file [OPTIONS]
105
+ $ safe-cli import-file [OPTIONS]
96
106
  ```
97
107
 
98
108
  **Options**:
99
109
 
100
110
  * `--server TEXT`: Server name
101
- * `--file-path FILE`: Path to file to import
111
+ * `--filename FILE`: Path to file to be imported
102
112
  * `-i, --interactive`: Run import interactively
103
- * `--help`: Show this message and exit.
113
+ * `--help`, `--man`, `--manual`: Show help and exit.
104
114
 
105
- ## `safe-file-example export-file`
115
+
116
+ ## `safe-cli export-file`
106
117
 
107
118
  Export a file
108
119
 
109
120
  **Usage**:
110
121
 
111
122
  ```console
112
- $ safe-file-example export-file [OPTIONS]
123
+ $ safe-cli export-file [OPTIONS]
113
124
  ```
114
125
 
115
126
  **Options**:
@@ -118,18 +129,19 @@ $ safe-file-example export-file [OPTIONS]
118
129
  * `--filename TEXT`: Filename to export
119
130
  * `--output-dir DIRECTORY`: Output directory
120
131
  * `-i, --interactive`: Run export interactively
121
- * `--help`: Show this message and exit.
132
+ * `--help`, `--man`, `--manual`: Show help and exit.
133
+
122
134
 
123
- ## `safe-file-example interactive`
135
+ ## `safe-cli interactive`
124
136
 
125
137
  Run interactive mode
126
138
 
127
139
  **Usage**:
128
140
 
129
141
  ```console
130
- $ safe-file-example interactive [OPTIONS]
142
+ $ safe-cli interactive [OPTIONS]
131
143
  ```
132
144
 
133
145
  **Options**:
134
146
 
135
- * `--help`: Show this message and exit.
147
+ * `--help`, `--man`, `--manual`: Show help and exit.
@@ -1,89 +1,100 @@
1
- # `safe-file-example`
1
+ # `nortre-cli`
2
+
3
+ ## Deprecation warning
4
+ This pip package will be depricated at the end of 2026. Please transfer over to the new package located at https://pypi.org/project/nortre-cli/
5
+
2
6
  ## Description
3
7
 
4
8
  A python package for interacting with SAFE File transfer API
5
9
 
10
+
6
11
  ## Current Functionalities
7
12
 
8
13
  - Generate a JWT Token
9
- - Import a File
10
- - Export a File
14
+ - Import file/s
15
+ - Export a file
16
+ - Exit
17
+
11
18
 
12
19
  ## Prerequisite
13
20
 
14
21
  - Having minimum Python 3.12 installed in your system and setting up a Python Virtual Environment.
15
22
 
23
+
16
24
  ## Workflow
17
25
 
18
26
  - Activate your Python Virtual Environment,
19
27
  - Then run the following command.
20
28
 
21
29
  ```bash
22
- pip install safe-file-example
30
+ pip install nortre-cli
23
31
  ```
24
32
  - To see all the available commands and options run the following
25
33
 
26
34
  ```bash
27
- safe-file-example
35
+ safe-cli
28
36
  ```
29
37
 
30
-
31
38
  **Usage**:
32
39
 
33
40
  ```console
34
- $ safe-file-example [OPTIONS] COMMAND [ARGS]...
41
+ $ safe-cli [OPTIONS] COMMAND [ARGS]...
35
42
  ```
36
43
 
37
44
  **Options**:
38
45
 
39
- * `--help`: Show this message and exit.
46
+ * `--help`, `--man`, `--manual`: Show help and exit.
40
47
 
41
48
  **Commands**:
42
49
 
43
50
  * `get-token`: Get and store access token
44
- * `import-file`: Import a file
51
+ * `import-file`: Import file/s
45
52
  * `export-file`: Export a file
46
53
  * `interactive`: Run interactive mode
54
+ * `exit`: Exits the cli
55
+
47
56
 
48
- ## `safe-file-example get-token`
57
+ ## `safe-cli get-token`
49
58
 
50
59
  Get and store access token
51
60
 
52
61
  **Usage**:
53
62
 
54
63
  ```console
55
- $ safe-file-example get-token [OPTIONS]
64
+ $ safe-cli get-token [OPTIONS]
56
65
  ```
57
66
 
58
67
  **Options**:
59
68
 
60
- * `--help`: Show this message and exit.
69
+ * `--help`, `--man`, `--manual`: Show help and exit.
70
+
61
71
 
62
- ## `safe-file-example import-file`
72
+ ## `safe-cli import-file`
63
73
 
64
74
  Import a file
65
75
 
66
76
  **Usage**:
67
77
 
68
78
  ```console
69
- $ safe-file-example import-file [OPTIONS]
79
+ $ safe-cli import-file [OPTIONS]
70
80
  ```
71
81
 
72
82
  **Options**:
73
83
 
74
84
  * `--server TEXT`: Server name
75
- * `--file-path FILE`: Path to file to import
85
+ * `--filename FILE`: Path to file to be imported
76
86
  * `-i, --interactive`: Run import interactively
77
- * `--help`: Show this message and exit.
87
+ * `--help`, `--man`, `--manual`: Show help and exit.
78
88
 
79
- ## `safe-file-example export-file`
89
+
90
+ ## `safe-cli export-file`
80
91
 
81
92
  Export a file
82
93
 
83
94
  **Usage**:
84
95
 
85
96
  ```console
86
- $ safe-file-example export-file [OPTIONS]
97
+ $ safe-cli export-file [OPTIONS]
87
98
  ```
88
99
 
89
100
  **Options**:
@@ -92,18 +103,19 @@ $ safe-file-example export-file [OPTIONS]
92
103
  * `--filename TEXT`: Filename to export
93
104
  * `--output-dir DIRECTORY`: Output directory
94
105
  * `-i, --interactive`: Run export interactively
95
- * `--help`: Show this message and exit.
106
+ * `--help`, `--man`, `--manual`: Show help and exit.
107
+
96
108
 
97
- ## `safe-file-example interactive`
109
+ ## `safe-cli interactive`
98
110
 
99
111
  Run interactive mode
100
112
 
101
113
  **Usage**:
102
114
 
103
115
  ```console
104
- $ safe-file-example interactive [OPTIONS]
116
+ $ safe-cli interactive [OPTIONS]
105
117
  ```
106
118
 
107
119
  **Options**:
108
120
 
109
- * `--help`: Show this message and exit.
121
+ * `--help`, `--man`, `--manual`: Show help and exit.
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "safe-file-example"
7
- version = "0.3.1"
7
+ version = "1.0.0"
8
8
  authors = [
9
9
  { name="Dip Paul", email="dip.paul@uib.no" },
10
10
  { name="Eirik Halseth", email="eirik.halseth@uib.no" },
@@ -26,7 +26,7 @@ dependencies = [
26
26
  "markdown-it-py==4.2.0",
27
27
  "mdurl==0.1.2",
28
28
  "Pygments==2.20.0",
29
- "PyJWT==2.13.0",
29
+ "PyJWT==2.15.0",
30
30
  "requests==2.34.2",
31
31
  "rich==15.0.0",
32
32
  "shellingham==1.5.4",
@@ -40,11 +40,13 @@ classifiers = [
40
40
  ]
41
41
 
42
42
  [project.urls]
43
- Homepage = "https://git.app.uib.no/itpublic/python/safe-file-example"
43
+ Homepage = "https://git.app.uib.no/itpublic/python/nortre-cli"
44
44
 
45
45
  [project.scripts]
46
+ safe-cli="safe.main:app"
46
47
  safe-file-example="safe.main:app"
47
48
 
49
+
48
50
  [tool.hatch.build.targets.wheel]
49
51
  packages = ["safe"]
50
52
  include = [
@@ -0,0 +1,11 @@
1
+ import importlib.resources
2
+ import os
3
+
4
+ # Global variables across whole project that can be imported where it is needed:
5
+ config_dir = os.path.expanduser("~/.safe-cli")
6
+ token_file = os.path.join(config_dir, "token.json")
7
+ base_url = "https://api.safe.uib.no/v1"
8
+ logo_path = importlib.resources.files("safe.assets").joinpath("safe_logo.png")
9
+
10
+ # Global stylings
11
+ rich_panel_expand: bool = False
@@ -1,8 +1,13 @@
1
- from pathlib import Path
2
1
  import os
3
- import shutil
2
+ from pathlib import Path
3
+
4
4
  import requests
5
5
 
6
+ from rich.console import Console
7
+ from rich import print as rich_print
8
+
9
+ console = Console()
10
+
6
11
 
7
12
  def write_file_to_disk(
8
13
  download_path: Path,
@@ -11,8 +16,6 @@ def write_file_to_disk(
11
16
  server: str,
12
17
  filename: str,
13
18
  chunk_size: int = 8 * 1024 * 1024,
14
- connect_timeout: float = 15,
15
- read_timeout: float = 600,
16
19
  ) -> bool:
17
20
  print(f"Starting download to {download_path}")
18
21
 
@@ -27,13 +30,16 @@ def write_file_to_disk(
27
30
  }
28
31
 
29
32
  try:
30
- with requests.get(
31
- download_url,
32
- headers=headers,
33
- params=params,
34
- stream=True,
35
- timeout=(connect_timeout, read_timeout),
36
- ) as response:
33
+ with (
34
+ console.status(f"Exporting {filename}..."),
35
+ requests.get(
36
+ download_url,
37
+ headers=headers,
38
+ params=params,
39
+ stream=True,
40
+ timeout=(15, 600),
41
+ ) as response,
42
+ ):
37
43
  response.raise_for_status()
38
44
 
39
45
  with open(temp_path, "wb") as f:
@@ -42,7 +48,7 @@ def write_file_to_disk(
42
48
  f.write(chunk)
43
49
 
44
50
  os.replace(temp_path, download_path)
45
- print("Download completed:", download_path)
51
+ rich_print(f"[bold green]Download completed: {download_path}[/bold green]")
46
52
  return True
47
53
 
48
54
  except Exception:
@@ -51,5 +57,5 @@ def write_file_to_disk(
51
57
  temp_path.unlink()
52
58
  except Exception:
53
59
  pass
54
- print("Download failed")
60
+ rich_print("[bold red]Download failed[/bold red]")
55
61
  return False