Skip to content

Commit b9f248a

Browse files
committed
Initial Commit
0 parents  commit b9f248a

8 files changed

+423
-0
lines changed

.gitignore

+165
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
docs/_uild/
74+
75+
# PyBuilder
76+
.pybuilder/
77+
target/
78+
79+
# Jupyter Notebook
80+
.ipynb_checkpoints
81+
82+
# IPython
83+
profile_default/
84+
ipython_config.py
85+
86+
# pyenv
87+
# For a library or package, you might want to ignore these files since the code is
88+
# intended to run in multiple environments; otherwise, check them in:
89+
# .python-version
90+
91+
# pipenv
92+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
94+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
95+
# install all needed dependencies.
96+
#Pipfile.lock
97+
98+
# poetry
99+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
100+
# This is especially recommended for binary packages to ensure reproducibility, and is more
101+
# commonly ignored for libraries.
102+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
103+
#poetry.lock
104+
105+
# pdm
106+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
107+
#pdm.lock
108+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
109+
# in version control.
110+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
111+
.pdm.toml
112+
.pdm-python
113+
.pdm-build/
114+
115+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
116+
__pypackages__/
117+
118+
# Celery stuff
119+
celerybeat-schedule
120+
celerybeat.pid
121+
122+
# SageMath parsed files
123+
*.sage.py
124+
125+
# Environments
126+
.env
127+
.venv
128+
env/
129+
venv/
130+
ENV/
131+
env.bak/
132+
venv.bak/
133+
134+
# Spyder project settings
135+
.spyderproject
136+
.spyproject
137+
138+
# Rope project settings
139+
.ropeproject
140+
141+
# mkdocs documentation
142+
/site
143+
144+
# mypy
145+
.mypy_cache/
146+
.dmypy.json
147+
dmypy.json
148+
149+
# Pyre type checker
150+
.pyre/
151+
152+
# pytype static type analyzer
153+
.pytype/
154+
155+
# Cython debug symbols
156+
cython_debug/
157+
158+
# PyCharm
159+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
160+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
161+
# and can be added to the global gitignore or merged into this file. For a more nuclear
162+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
163+
.idea/
164+
165+
upload_files/

.pre-commit-config.yaml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.5.1
4+
hooks:
5+
# Run the formatter.
6+
- id: ruff-format
7+
# Run the linter.
8+
- id: ruff
9+
args:
10+
- --fix
11+
- --unsafe-fixes
12+
- repo: https://github.com/RobertCraigie/pyright-python
13+
rev: v1.1.372
14+
hooks:
15+
- id: pyright
16+
name: pyright
17+
files: ^(?!(tests)).*\.py$
18+
additional_dependencies:
19+
- aioftp~=0.22
20+
- aiorem~=0.0.2
21+
- pydantic-settings~=2.3
22+
- repo: https://github.com/asottile/pyupgrade
23+
rev: v3.16.0
24+
hooks:
25+
- id: pyupgrade
26+
args:
27+
- --py312-plus

README.rst

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
``akadressen-upload``
2+
=====================
3+
4+
Small helper script to upload new AkaDressen files to internal section of the `AkaBlas <https://akablas.de>`_ Homepage.
5+
It requires Python 3.12+.
6+
7+
Setting in up
8+
-------------
9+
10+
Create a file ``.env`` with the following contents:
11+
12+
.. code-block::
13+
14+
FTP_host=<host address of the ftp server>
15+
FTP_USERNAME=<username>
16+
FTP_PASSWORD=<password>
17+
SOURCE_PATH=<path to the folder containing the files to upload>
18+
TARGET_PATH=<path to the folder on the ftp server where the files should be uploaded>
19+
20+
Usage
21+
-----
22+
23+
Run the script with the following command:
24+
25+
.. code-block:: shell
26+
27+
python main.py
28+
29+
How It Works
30+
------------
31+
32+
The script does the following:
33+
34+
1. Rename all files starting with ``latest_``. The new prefix is the modification date of the file.
35+
2. Upload all files to the ftp server. The files will be prefixed with ``latest_``.

main.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import asyncio
2+
import logging
3+
4+
from uploader import AkaDressenUploader
5+
6+
logging.basicConfig(
7+
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.INFO
8+
)
9+
10+
11+
async def do_upload():
12+
async with AkaDressenUploader() as uploader:
13+
await uploader.do_akadressen_upload()
14+
15+
16+
if __name__ == "__main__":
17+
asyncio.run(do_upload())

pyproject.toml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "akadressen-upload"
7+
verison = "0.0.1"
8+
description = 'Simple helper to upload new AkaDressen to the Hompage'
9+
readme = "README.rst"
10+
requires-python = ">=3.12"
11+
license = "MIT"
12+
authors = [
13+
{ name = "Hinrich Mahler", email = "[email protected]" },
14+
]
15+
classifiers = [
16+
"Development Status :: 4 - Beta",
17+
"Programming Language :: Python",
18+
"Programming Language :: Python :: 3.12",
19+
"Intended Audience :: Developers",
20+
"Operating System :: OS Independent",
21+
]
22+
dependencies = [
23+
"aioftp~=0.22",
24+
"aiorem~=0.0.2",
25+
"pydantic-settings~=2.3",
26+
]
27+
28+
# RUFF:
29+
[tool.ruff]
30+
line-length = 99
31+
show-fixes = true
32+
33+
[tool.ruff.lint]
34+
preview = true
35+
explicit-preview-rules = true
36+
select = ["E", "F", "I", "PL", "UP", "RUF", "PTH", "C4", "B", "PIE", "SIM", "RET", "RSE",
37+
"G", "ISC", "PT", "ASYNC", "TCH", "SLOT", "PERF", "PYI", "FLY", "AIR", "RUF022",
38+
"RUF023", "Q", "INP", "W", "YTT", "DTZ", "ARG"]
39+
ignore = ["ISC001"]
40+
41+
[tool.ruff.lint.isort]
42+
split-on-trailing-comma = false
43+
44+
[tool.ruff.format]
45+
docstring-code-format = true
46+
skip-magic-trailing-comma = true
47+
48+
# MYPY:
49+
[tool.mypy]
50+
warn_unused_ignores = true
51+
warn_unused_configs = true
52+
disallow_untyped_defs = true
53+
disallow_incomplete_defs = true
54+
disallow_untyped_decorators = true
55+
show_error_codes = true
56+
python_version = "3.12"

uploader/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
__all__ = ["AkaDressenUploader", "Settings"]
2+
3+
from ._settings import Settings
4+
from ._uploader import AkaDressenUploader

uploader/_settings.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from pathlib import Path
2+
3+
from pydantic_settings import BaseSettings, SettingsConfigDict
4+
5+
6+
class Settings(BaseSettings):
7+
"""Settings to use. They can also be specified in a `.env` file."""
8+
9+
model_config = SettingsConfigDict(env_file=".env")
10+
11+
ftp_host: str
12+
"""The host address of the FTP server."""
13+
ftp_port: int = 21
14+
"""The port of the FTP server. Default is 21."""
15+
ftp_username: str
16+
"""The username for the FTP server."""
17+
ftp_password: str
18+
"""The password for the FTP server."""
19+
source_path: Path
20+
"""The path to the source files that will be uploaded."""
21+
target_path: Path
22+
"""The path on the FTP server where the files will be uploaded."""

0 commit comments

Comments
 (0)