sji 0.1.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.
- sji-0.1.0/LICENSE +21 -0
- sji-0.1.0/PKG-INFO +115 -0
- sji-0.1.0/README.md +65 -0
- sji-0.1.0/pyproject.toml +32 -0
- sji-0.1.0/setup.cfg +4 -0
- sji-0.1.0/setup.py +34 -0
- sji-0.1.0/sji/__init__.py +9 -0
- sji-0.1.0/sji/sji.py +67 -0
- sji-0.1.0/sji.egg-info/PKG-INFO +115 -0
- sji-0.1.0/sji.egg-info/SOURCES.txt +10 -0
- sji-0.1.0/sji.egg-info/dependency_links.txt +1 -0
- sji-0.1.0/sji.egg-info/top_level.txt +1 -0
sji-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 matzek92
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
sji-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sji
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: SJI - Eine einfache Python-Bibliothek für Job-Initialisierung
|
|
5
|
+
Home-page: https://github.com/matzek92/simple-job-init
|
|
6
|
+
Author: matzek92
|
|
7
|
+
Author-email: matzek92 <your.email@example.com>
|
|
8
|
+
License: MIT License
|
|
9
|
+
|
|
10
|
+
Copyright (c) 2025 matzek92
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
in the Software without restriction, including without limitation the rights
|
|
15
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
furnished to do so, subject to the following conditions:
|
|
18
|
+
|
|
19
|
+
The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
copies or substantial portions of the Software.
|
|
21
|
+
|
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
SOFTWARE.
|
|
29
|
+
|
|
30
|
+
Project-URL: Homepage, https://github.com/matzek92/simple-job-init
|
|
31
|
+
Project-URL: Repository, https://github.com/matzek92/simple-job-init.git
|
|
32
|
+
Keywords: job,task,simple
|
|
33
|
+
Classifier: Development Status :: 3 - Alpha
|
|
34
|
+
Classifier: Intended Audience :: Developers
|
|
35
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
36
|
+
Classifier: Operating System :: OS Independent
|
|
37
|
+
Classifier: Programming Language :: Python :: 3
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
42
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
43
|
+
Requires-Python: >=3.8
|
|
44
|
+
Description-Content-Type: text/markdown
|
|
45
|
+
License-File: LICENSE
|
|
46
|
+
Dynamic: author
|
|
47
|
+
Dynamic: home-page
|
|
48
|
+
Dynamic: license-file
|
|
49
|
+
Dynamic: requires-python
|
|
50
|
+
|
|
51
|
+
# SJI
|
|
52
|
+
|
|
53
|
+
Eine einfache Python-Bibliothek für die Initialisierung von Jobs/Skripten (Logging, Konfiguration, Ordnerstruktur).
|
|
54
|
+
|
|
55
|
+
## Installation
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
pip install sji
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Verwendung
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
from sji import SimpleJobInit
|
|
65
|
+
|
|
66
|
+
# __file__ an SimpleJobInit übergeben
|
|
67
|
+
sji = SimpleJobInit(__file__)
|
|
68
|
+
|
|
69
|
+
# Logger verwenden
|
|
70
|
+
sji.logger.info("Starte Job...")
|
|
71
|
+
|
|
72
|
+
# Konfiguration lesen (INI)
|
|
73
|
+
cfg = sji.config
|
|
74
|
+
value = cfg.get('section', 'key', fallback='default')
|
|
75
|
+
|
|
76
|
+
# Persistente Datei-Pfade erhalten
|
|
77
|
+
csv_path = sji.get_persistent_file_path('csv')
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Dabei werden automatisch erzeugt/genutzt:
|
|
81
|
+
- logs/<skriptname>.log (mit optionaler Rotation)
|
|
82
|
+
- tmp/ Verzeichnis
|
|
83
|
+
- <skriptname>.config.ini für Einstellungen
|
|
84
|
+
|
|
85
|
+
## Minimalbeispiel für die INI-Datei
|
|
86
|
+
|
|
87
|
+
Datei: `<skriptname>.config.ini` im selben Verzeichnis wie das Skript
|
|
88
|
+
|
|
89
|
+
```ini
|
|
90
|
+
[logging]
|
|
91
|
+
level = INFO
|
|
92
|
+
log_rotation_when = midnight
|
|
93
|
+
log_rotation_backup_count = 7
|
|
94
|
+
|
|
95
|
+
[section]
|
|
96
|
+
key = some-value
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## API
|
|
100
|
+
|
|
101
|
+
### Klasse: SimpleJobInit
|
|
102
|
+
|
|
103
|
+
- `SimpleJobInit(script_file_path: str)`
|
|
104
|
+
- Initialisiert Logging, lädt/prüft INI-Config, erzeugt Ordner (logs, tmp)
|
|
105
|
+
- Eigenschaften
|
|
106
|
+
- `logger`: konfigurierter `logging.Logger`
|
|
107
|
+
- `config`: `configparser.ConfigParser`
|
|
108
|
+
- Methoden
|
|
109
|
+
- `get_persistent_file_path(file_ending: str) -> str`: gibt Pfad `<skriptname>.<file_ending>` zurück
|
|
110
|
+
|
|
111
|
+
## Lizenz
|
|
112
|
+
|
|
113
|
+
MIT-Lizenz - siehe [LICENSE](LICENSE) für Details.
|
|
114
|
+
|
|
115
|
+
- Project build with support of AI (Cursor IDE).
|
sji-0.1.0/README.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# SJI
|
|
2
|
+
|
|
3
|
+
Eine einfache Python-Bibliothek für die Initialisierung von Jobs/Skripten (Logging, Konfiguration, Ordnerstruktur).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install sji
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Verwendung
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
from sji import SimpleJobInit
|
|
15
|
+
|
|
16
|
+
# __file__ an SimpleJobInit übergeben
|
|
17
|
+
sji = SimpleJobInit(__file__)
|
|
18
|
+
|
|
19
|
+
# Logger verwenden
|
|
20
|
+
sji.logger.info("Starte Job...")
|
|
21
|
+
|
|
22
|
+
# Konfiguration lesen (INI)
|
|
23
|
+
cfg = sji.config
|
|
24
|
+
value = cfg.get('section', 'key', fallback='default')
|
|
25
|
+
|
|
26
|
+
# Persistente Datei-Pfade erhalten
|
|
27
|
+
csv_path = sji.get_persistent_file_path('csv')
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Dabei werden automatisch erzeugt/genutzt:
|
|
31
|
+
- logs/<skriptname>.log (mit optionaler Rotation)
|
|
32
|
+
- tmp/ Verzeichnis
|
|
33
|
+
- <skriptname>.config.ini für Einstellungen
|
|
34
|
+
|
|
35
|
+
## Minimalbeispiel für die INI-Datei
|
|
36
|
+
|
|
37
|
+
Datei: `<skriptname>.config.ini` im selben Verzeichnis wie das Skript
|
|
38
|
+
|
|
39
|
+
```ini
|
|
40
|
+
[logging]
|
|
41
|
+
level = INFO
|
|
42
|
+
log_rotation_when = midnight
|
|
43
|
+
log_rotation_backup_count = 7
|
|
44
|
+
|
|
45
|
+
[section]
|
|
46
|
+
key = some-value
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## API
|
|
50
|
+
|
|
51
|
+
### Klasse: SimpleJobInit
|
|
52
|
+
|
|
53
|
+
- `SimpleJobInit(script_file_path: str)`
|
|
54
|
+
- Initialisiert Logging, lädt/prüft INI-Config, erzeugt Ordner (logs, tmp)
|
|
55
|
+
- Eigenschaften
|
|
56
|
+
- `logger`: konfigurierter `logging.Logger`
|
|
57
|
+
- `config`: `configparser.ConfigParser`
|
|
58
|
+
- Methoden
|
|
59
|
+
- `get_persistent_file_path(file_ending: str) -> str`: gibt Pfad `<skriptname>.<file_ending>` zurück
|
|
60
|
+
|
|
61
|
+
## Lizenz
|
|
62
|
+
|
|
63
|
+
MIT-Lizenz - siehe [LICENSE](LICENSE) für Details.
|
|
64
|
+
|
|
65
|
+
- Project build with support of AI (Cursor IDE).
|
sji-0.1.0/pyproject.toml
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=45", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "sji"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "SJI - Eine einfache Python-Bibliothek für Job-Initialisierung"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {file = "LICENSE"}
|
|
11
|
+
authors = [
|
|
12
|
+
{name = "matzek92", email = "your.email@example.com"},
|
|
13
|
+
]
|
|
14
|
+
keywords = ["job", "task", "simple"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 3 - Alpha",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"License :: OSI Approved :: MIT License",
|
|
19
|
+
"Operating System :: OS Independent",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.8",
|
|
22
|
+
"Programming Language :: Python :: 3.9",
|
|
23
|
+
"Programming Language :: Python :: 3.10",
|
|
24
|
+
"Programming Language :: Python :: 3.11",
|
|
25
|
+
"Programming Language :: Python :: 3.12",
|
|
26
|
+
]
|
|
27
|
+
requires-python = ">=3.8"
|
|
28
|
+
dependencies = []
|
|
29
|
+
|
|
30
|
+
[project.urls]
|
|
31
|
+
Homepage = "https://github.com/matzek92/simple-job-init"
|
|
32
|
+
Repository = "https://github.com/matzek92/simple-job-init.git"
|
sji-0.1.0/setup.cfg
ADDED
sji-0.1.0/setup.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Setup-Konfiguration für Simple Job Init.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from setuptools import setup, find_packages
|
|
6
|
+
|
|
7
|
+
with open("README.md", "r", encoding="utf-8") as fh:
|
|
8
|
+
long_description = fh.read()
|
|
9
|
+
|
|
10
|
+
setup(
|
|
11
|
+
name="sji",
|
|
12
|
+
version="0.1.0",
|
|
13
|
+
author="matzek92",
|
|
14
|
+
author_email="matthias@kasperidus.de",
|
|
15
|
+
description="SJI - Eine einfache Python-Bibliothek für Job-Initialisierung",
|
|
16
|
+
long_description=long_description,
|
|
17
|
+
long_description_content_type="text/markdown",
|
|
18
|
+
url="https://github.com/matzek92/simple-job-init",
|
|
19
|
+
packages=find_packages(),
|
|
20
|
+
classifiers=[
|
|
21
|
+
"Development Status :: 3 - Alpha",
|
|
22
|
+
"Intended Audience :: Developers",
|
|
23
|
+
"License :: OSI Approved :: MIT License",
|
|
24
|
+
"Operating System :: OS Independent",
|
|
25
|
+
"Programming Language :: Python :: 3",
|
|
26
|
+
"Programming Language :: Python :: 3.8",
|
|
27
|
+
"Programming Language :: Python :: 3.9",
|
|
28
|
+
"Programming Language :: Python :: 3.10",
|
|
29
|
+
"Programming Language :: Python :: 3.11",
|
|
30
|
+
"Programming Language :: Python :: 3.12",
|
|
31
|
+
],
|
|
32
|
+
python_requires=">=3.8",
|
|
33
|
+
install_requires=[],
|
|
34
|
+
)
|
sji-0.1.0/sji/sji.py
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Einfache Helper-Funktionen für Job-Initialisierung.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from typing import Dict, Any
|
|
6
|
+
from datetime import datetime
|
|
7
|
+
import uuid
|
|
8
|
+
import os
|
|
9
|
+
import logging
|
|
10
|
+
from logging.handlers import TimedRotatingFileHandler
|
|
11
|
+
import configparser
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class SimpleJobInit(object):
|
|
16
|
+
|
|
17
|
+
def __init__(self, script_file_path: str):
|
|
18
|
+
|
|
19
|
+
self._script_file_path = script_file_path
|
|
20
|
+
self._script_dir = os.path.dirname(script_file_path)
|
|
21
|
+
self._script_basename = os.path.basename(script_file_path).replace(".py", "")
|
|
22
|
+
|
|
23
|
+
self._log_folder = os.path.join(self._script_dir, "logs")
|
|
24
|
+
if not os.path.exists(self._log_folder):
|
|
25
|
+
os.makedirs(self._log_folder)
|
|
26
|
+
self._log_filepath = os.path.join(self._log_folder, f"{self._script_basename}.log")
|
|
27
|
+
|
|
28
|
+
self._config_filepath = os.path.join(self._script_dir, f"{self._script_basename}.config.ini")
|
|
29
|
+
self._config = configparser.ConfigParser()
|
|
30
|
+
if os.path.isfile(self._config_filepath):
|
|
31
|
+
self._config.read(self._config_filepath)
|
|
32
|
+
else:
|
|
33
|
+
raise ValueError("Config file {} missing...".format(self._config_filepath))
|
|
34
|
+
|
|
35
|
+
logging.basicConfig(level=logging.INFO, format='[%(asctime)s][%(levelname)s][%(name)s][%(module)s - %(funcName)s] %(message)s')
|
|
36
|
+
self._logger = logging.getLogger(self._script_basename)
|
|
37
|
+
|
|
38
|
+
if self._config.has_section('logging'):
|
|
39
|
+
|
|
40
|
+
logging_config = self._config['logging']
|
|
41
|
+
level = logging_config.get('level', logging.INFO)
|
|
42
|
+
self._logger.setLevel(level)
|
|
43
|
+
self._logger.addHandler(logging.StreamHandler())
|
|
44
|
+
log_rotation_when = logging_config.get('log_rotation_when', 'midnight')
|
|
45
|
+
log_rotation_backup_count = logging_config.get('log_rotation_backup_count', 0)
|
|
46
|
+
log_file_handler = TimedRotatingFileHandler(self._log_filepath, encoding='utf-8', when=log_rotation_when, backupCount=log_rotation_backup_count)
|
|
47
|
+
self._logger.addHandler(log_file_handler)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
self._tmp_folder = os.path.join(self._script_dir, "tmp")
|
|
51
|
+
if not os.path.exists(self._tmp_folder):
|
|
52
|
+
os.makedirs(self._tmp_folder)
|
|
53
|
+
self._persistent_files_path_stub = os.path.join(self._script_dir, f"{self._script_basename}")
|
|
54
|
+
|
|
55
|
+
@property
|
|
56
|
+
def logger(self):
|
|
57
|
+
return self._logger
|
|
58
|
+
|
|
59
|
+
@property
|
|
60
|
+
def config(self):
|
|
61
|
+
return self._config
|
|
62
|
+
|
|
63
|
+
def get_tmp_file_path(self, file_name: str):
|
|
64
|
+
return os.path.join(self._tmp_folder, file_name)
|
|
65
|
+
|
|
66
|
+
def get_persistent_file_path(self, file_ending: str):
|
|
67
|
+
return f"{self._persistent_files_path_stub}.{file_ending}"
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sji
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: SJI - Eine einfache Python-Bibliothek für Job-Initialisierung
|
|
5
|
+
Home-page: https://github.com/matzek92/simple-job-init
|
|
6
|
+
Author: matzek92
|
|
7
|
+
Author-email: matzek92 <your.email@example.com>
|
|
8
|
+
License: MIT License
|
|
9
|
+
|
|
10
|
+
Copyright (c) 2025 matzek92
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
in the Software without restriction, including without limitation the rights
|
|
15
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
furnished to do so, subject to the following conditions:
|
|
18
|
+
|
|
19
|
+
The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
copies or substantial portions of the Software.
|
|
21
|
+
|
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
SOFTWARE.
|
|
29
|
+
|
|
30
|
+
Project-URL: Homepage, https://github.com/matzek92/simple-job-init
|
|
31
|
+
Project-URL: Repository, https://github.com/matzek92/simple-job-init.git
|
|
32
|
+
Keywords: job,task,simple
|
|
33
|
+
Classifier: Development Status :: 3 - Alpha
|
|
34
|
+
Classifier: Intended Audience :: Developers
|
|
35
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
36
|
+
Classifier: Operating System :: OS Independent
|
|
37
|
+
Classifier: Programming Language :: Python :: 3
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
42
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
43
|
+
Requires-Python: >=3.8
|
|
44
|
+
Description-Content-Type: text/markdown
|
|
45
|
+
License-File: LICENSE
|
|
46
|
+
Dynamic: author
|
|
47
|
+
Dynamic: home-page
|
|
48
|
+
Dynamic: license-file
|
|
49
|
+
Dynamic: requires-python
|
|
50
|
+
|
|
51
|
+
# SJI
|
|
52
|
+
|
|
53
|
+
Eine einfache Python-Bibliothek für die Initialisierung von Jobs/Skripten (Logging, Konfiguration, Ordnerstruktur).
|
|
54
|
+
|
|
55
|
+
## Installation
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
pip install sji
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Verwendung
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
from sji import SimpleJobInit
|
|
65
|
+
|
|
66
|
+
# __file__ an SimpleJobInit übergeben
|
|
67
|
+
sji = SimpleJobInit(__file__)
|
|
68
|
+
|
|
69
|
+
# Logger verwenden
|
|
70
|
+
sji.logger.info("Starte Job...")
|
|
71
|
+
|
|
72
|
+
# Konfiguration lesen (INI)
|
|
73
|
+
cfg = sji.config
|
|
74
|
+
value = cfg.get('section', 'key', fallback='default')
|
|
75
|
+
|
|
76
|
+
# Persistente Datei-Pfade erhalten
|
|
77
|
+
csv_path = sji.get_persistent_file_path('csv')
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Dabei werden automatisch erzeugt/genutzt:
|
|
81
|
+
- logs/<skriptname>.log (mit optionaler Rotation)
|
|
82
|
+
- tmp/ Verzeichnis
|
|
83
|
+
- <skriptname>.config.ini für Einstellungen
|
|
84
|
+
|
|
85
|
+
## Minimalbeispiel für die INI-Datei
|
|
86
|
+
|
|
87
|
+
Datei: `<skriptname>.config.ini` im selben Verzeichnis wie das Skript
|
|
88
|
+
|
|
89
|
+
```ini
|
|
90
|
+
[logging]
|
|
91
|
+
level = INFO
|
|
92
|
+
log_rotation_when = midnight
|
|
93
|
+
log_rotation_backup_count = 7
|
|
94
|
+
|
|
95
|
+
[section]
|
|
96
|
+
key = some-value
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## API
|
|
100
|
+
|
|
101
|
+
### Klasse: SimpleJobInit
|
|
102
|
+
|
|
103
|
+
- `SimpleJobInit(script_file_path: str)`
|
|
104
|
+
- Initialisiert Logging, lädt/prüft INI-Config, erzeugt Ordner (logs, tmp)
|
|
105
|
+
- Eigenschaften
|
|
106
|
+
- `logger`: konfigurierter `logging.Logger`
|
|
107
|
+
- `config`: `configparser.ConfigParser`
|
|
108
|
+
- Methoden
|
|
109
|
+
- `get_persistent_file_path(file_ending: str) -> str`: gibt Pfad `<skriptname>.<file_ending>` zurück
|
|
110
|
+
|
|
111
|
+
## Lizenz
|
|
112
|
+
|
|
113
|
+
MIT-Lizenz - siehe [LICENSE](LICENSE) für Details.
|
|
114
|
+
|
|
115
|
+
- Project build with support of AI (Cursor IDE).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
sji
|