Skip to content

Commit

Permalink
fix issues with rstrip
Browse files Browse the repository at this point in the history
  • Loading branch information
xmnlab committed Jun 26, 2024
1 parent 62dccc7 commit 9df3c54
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/umlizer/class_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,11 @@ def _extract_module_name(module_path: str) -> tuple[str, str]:
module_split = module_path.split(os.sep)
module_path = os.sep.join(module_split[:-1])
module_filename = module_split[-1]
module_name = module_filename.rstrip('.py')

if module_filename.endswith('.py'):
module_name = module_filename[:-3]
else:
module_name = module_filename
return module_path, module_name


Expand Down
11 changes: 11 additions & 0 deletions src/umlizer/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ def class_(
)
),
] = '',
django_settings: Annotated[
str,
typer.Option(
help='Django settings module (eg. "config.settings.dev").'
),
] = '',
verbose: Annotated[
bool, typer.Option(help='Active the verbose mode.')
] = False,
Expand All @@ -117,6 +123,11 @@ def class_(
source = make_absolute(source)
target = make_absolute(target) / 'class_graph'

if django_settings:
from umlizer.plugins import django

django.setup(django_settings)

classes_nodes = class_graph.load_classes_definition(
source, exclude=exclude, verbose=verbose
)
Expand Down
1 change: 1 addition & 0 deletions src/umlizer/plugins/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Set of functions for integrating to another libraries."""
18 changes: 18 additions & 0 deletions src/umlizer/plugins/django.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""Set of functions for integrating to django."""

import os


def setup(settings_module: str) -> None:
"""
Set up the Django environment.
Parameters
----------
settings_module : str
The Django settings module to use.
"""
import django

os.environ['DJANGO_SETTINGS_MODULE'] = settings_module
django.setup()

0 comments on commit 9df3c54

Please sign in to comment.