Skip to content

Commit

Permalink
Initial setup (#2)
Browse files Browse the repository at this point in the history
* Initial setup

* Code ♥️

* 🩹

* 🩹
  • Loading branch information
lord-haffi authored Nov 7, 2023
1 parent 4fe9c79 commit 24686cd
Show file tree
Hide file tree
Showing 195 changed files with 14,726 additions and 59 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,6 @@ dmypy.json
# vscode settings
.vscode/

src/_your_package_version.py
src/_bo4e_python_generator_version.py

unittests/output
8 changes: 4 additions & 4 deletions dev_requirements/requirements-linting.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
#
# pip-compile requirements-linting.in
#
astroid==3.0.0
astroid==3.0.1
# via pylint
dill==0.3.7
# via pylint
isort==5.12.0
# via pylint
mccabe==0.7.0
# via pylint
platformdirs==3.1.0
platformdirs==3.11.0
# via pylint
pylint==3.0.1
pylint==3.0.2
# via -r dev_requirements/requirements-linting.in
tomlkit==0.11.6
tomlkit==0.12.2
# via pylint
4 changes: 2 additions & 2 deletions dev_requirements/requirements-tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ exceptiongroup==1.1.3
# via pytest
iniconfig==2.0.0
# via pytest
packaging==23.0
packaging==23.2
# via pytest
pluggy==1.0.0
pluggy==1.3.0
# via pytest
pytest==7.4.3
# via -r dev_requirements/requirements-tests.in
Expand Down
4 changes: 2 additions & 2 deletions dev_requirements/requirements-type_check.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#
# pip-compile requirements-type_check.in
#
mypy==1.6.0
mypy==1.6.1
# via -r dev_requirements/requirements-type_check.in
mypy-extensions==1.0.0
# via mypy
typing-extensions==4.7.1
typing-extensions==4.8.0
# via mypy
25 changes: 18 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[project]
name = "your-favourite-package-name"
description = "Description of your package"
name = "BO4E-Python-Generator"
description = "This tool auto generates (customizable) pydantic v2 Code to implement the BO4E-Schemas."
license = { text = "MIT" }
requires-python = ">=3.11"
authors = [{ name = "your name", email = "[email protected]" }]
keywords = ["your", "important", "keywords"]
authors = [{ name = "Hochfrequenz Unternehmensberatung GmbH", email = "[email protected]" }]
keywords = ["bo4e", "code-generator"]
classifiers = [
"Development Status :: 4 - Beta",
"Environment :: Console",
Expand All @@ -16,20 +16,31 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dependencies = [] # add all the dependencies from requirements.in here, too
dependencies = [
"datamodel-code-generator",
"click",
] # add all the dependencies from requirements.in here, too
dynamic = ["readme", "version"]

[project.urls]
Changelog = "https://github.com/Hochfrequenz/python_template_repository/releases"
Homepage = "https://github.com/Hochfrequenz/python_template_repository"

[project.scripts]
bo4e-generator = "bo4e_generator.__main__:main"

[tool.black]
line-length = 120

[tool.isort]
line_length = 120
profile = "black"

[tool.pylint]
disable = [
"R0903", # disable too-few-public-methods
]

[tool.pylint."MESSAGES CONTROL"]
max-line-length = 120

Expand All @@ -47,7 +58,7 @@ fragments = [{ path = "README.md" }]
source = "vcs"

[tool.hatch.build.hooks.vcs]
version-file = "src/_your_package_version.py"
version-file = "src/_bo4e_generator_version.py"
template = '''
version = "{version}"
'''
Expand All @@ -57,4 +68,4 @@ exclude = ["/unittests"]

[tool.hatch.build.targets.wheel]
only-include = ["src"]
sources = ["src"]
sources = ["src"]
2 changes: 2 additions & 0 deletions requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
datamodel-code-generator
click
108 changes: 105 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,108 @@
#
# This file is autogenerated by pip-compile with python 3.10
# To update, run:
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile requirements.in
# pip-compile '.\requirements.in'
#
annotated-types==0.6.0
# via pydantic
argcomplete==3.1.2
# via datamodel-code-generator
attrs==23.1.0
# via jsonschema
black==23.9.1
# via datamodel-code-generator
certifi==2023.7.22
# via requests
chardet==5.2.0
# via prance
charset-normalizer==3.3.0
# via requests
click==8.1.7
# via
# -r .\requirements.in
# black
colorama==0.4.6
# via click
datamodel-code-generator==0.22.1
# via -r .\requirements.in
dnspython==2.4.2
# via email-validator
email-validator==2.0.0.post2
# via pydantic
genson==1.2.2
# via datamodel-code-generator
idna==3.4
# via
# email-validator
# requests
inflect==5.6.2
# via datamodel-code-generator
isort==5.12.0
# via datamodel-code-generator
jinja2==3.1.2
# via datamodel-code-generator
jsonschema==4.17.3
# via
# jsonschema-spec
# openapi-schema-validator
# openapi-spec-validator
jsonschema-spec==0.1.6
# via openapi-spec-validator
lazy-object-proxy==1.9.0
# via openapi-spec-validator
markupsafe==2.1.3
# via jinja2
mypy-extensions==1.0.0
# via black
openapi-schema-validator==0.4.4
# via openapi-spec-validator
openapi-spec-validator==0.5.7
# via datamodel-code-generator
packaging==23.2
# via
# black
# datamodel-code-generator
# prance
pathable==0.4.3
# via jsonschema-spec
pathspec==0.11.2
# via black
platformdirs==3.11.0
# via black
prance==23.6.21.0
# via datamodel-code-generator
pydantic[email]==2.4.2
# via
# datamodel-code-generator
# pydantic
pydantic-core==2.10.1
# via pydantic
pyrsistent==0.19.3
# via jsonschema
pysnooper==1.2.0
# via datamodel-code-generator
pyyaml==6.0.1
# via jsonschema-spec
requests==2.31.0
# via
# jsonschema-spec
# prance
rfc3339-validator==0.1.4
# via openapi-schema-validator
ruamel-yaml==0.17.35
# via prance
ruamel-yaml-clib==0.2.8
# via ruamel-yaml
six==1.16.0
# via
# prance
# rfc3339-validator
toml==0.10.2
# via datamodel-code-generator
typing-extensions==4.8.0
# via
# pydantic
# pydantic-core
urllib3==2.0.6
# via requests
Empty file added src/bo4e_generator/__init__.py
Empty file.
51 changes: 51 additions & 0 deletions src/bo4e_generator/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"""
This module is the entry point for the CLI bo4e-generator.
"""
from pathlib import Path

import click

from bo4e_generator.parser import create_init_files, generate_bo4e_schema
from bo4e_generator.schema import get_namespace


def generate_bo4e_schemas(input_directory: Path, output_directory: Path):
"""
Generate all BO4E schemas from the given input directory and save them in the given output directory.
"""
namespace = get_namespace(input_directory, output_directory)
for schema_metadata in namespace.values():
result = generate_bo4e_schema(schema_metadata, namespace)
schema_metadata.save(result)
print(f"Generated {schema_metadata}")
create_init_files(output_directory)
print(f"Generated __init__.py files in {output_directory}")


@click.command()
@click.option(
"--input-dir",
"-i",
type=click.Path(exists=True, file_okay=False, path_type=Path),
help="Input directory which contains the JSON schemas.",
required=True,
)
@click.option(
"--output-dir",
"-o",
type=click.Path(exists=False, file_okay=False, path_type=Path),
help="Output directory for the generated python files.",
required=True,
)
@click.help_option()
@click.version_option(package_name="BO4E-Python-Generator")
def main(input_dir: Path, output_dir: Path):
"""
CLI entry point for the bo4e-generator.
"""
generate_bo4e_schemas(input_dir, output_dir)


if __name__ == "__main__":
# pylint: disable=no-value-for-parameter
main()
Loading

0 comments on commit 24686cd

Please sign in to comment.