• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ValeriyMenshikov / restcodegen / 18805103363

25 Oct 2025 03:38PM UTC coverage: 63.12% (-1.5%) from 64.627%
18805103363

push

github

web-flow
Merge pull request #7 from ValeriyMenshikov/release/issue-5

Closes #5
Closes #6

22 of 58 new or added lines in 9 files covered. (37.93%)

8 existing lines in 4 files now uncovered.

433 of 686 relevant lines covered (63.12%)

1.89 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/restcodegen/generator/base.py
1
import shutil
×
2
from pathlib import Path
×
3

4
from jinja2 import Environment, FileSystemLoader
×
5

6
from restcodegen.generator import TEMPLATES
×
7
from restcodegen.generator.log import LOGGER
×
8
from restcodegen.generator.utils import (
×
9
    get_version,
10
    name_to_snake,
11
    rename_python_builtins,
12
    snake_to_camel,
13
)
14

15

16
class BaseGenerator:
×
17
    BASE_PATH: Path
×
18

19
    def __init__(self) -> None:
×
20
        if not self.BASE_PATH.exists():
×
21
            LOGGER.debug("base directory does not exists, creating...")
×
22
            self.BASE_PATH.mkdir(parents=True)
×
23

24
        core_init_path = self.BASE_PATH / "__init__.py"
×
25
        if not core_init_path.exists():
×
26
            core_init_path.touch()
×
27

28
        if not (self.BASE_PATH.parent / "__init__.py").exists():
×
29
            (self.BASE_PATH.parent / "__init__.py").touch()
×
30

31
    def __del__(self) -> None:
×
32
        """Removes empty directories."""
33
        files_count = sum(1 for _ in self.BASE_PATH.glob("*"))
×
34
        if files_count == 1:
×
35
            shutil.rmtree(self.BASE_PATH)
×
36

37

38
class BaseTemplateGenerator(BaseGenerator):
×
NEW
39
    def __init__(self, templates_dir: str | None = None):
×
40
        super().__init__()
×
NEW
41
        self.templates_dir = Path(templates_dir) if templates_dir is not None else TEMPLATES
×
42
        self.version = get_version()
×
NEW
43
        self.env = Environment(loader=FileSystemLoader(self.templates_dir), autoescape=True)  # type: ignore
×
UNCOV
44
        self.env.filters["to_snake_case"] = name_to_snake
×
45
        self.env.filters["to_camel_case"] = snake_to_camel
×
46
        self.env.filters["rename_python_builtins"] = rename_python_builtins
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc