rapidframework-lib 1.0.8.1__py3-none-any.whl → 1.0.8.2__py3-none-any.whl

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.
@@ -1,25 +1,33 @@
1
- from ..template import Template
2
- from subprocess import run
3
- from os import chdir
1
+ # from ..template import Template
2
+ # from subprocess import run
3
+ # from os import chdir
4
4
 
5
5
 
6
- class DjangoManager(Template):
7
- def __init__(self, **kwargs):
8
- super().__init__(**kwargs)
6
+ # class DjangoManager(Template):
7
+ # extra_libs = ["Pillow"]
8
+ # example = False
9
9
 
10
- def run_manage(self, commands: list):
11
- chdir(f"{self.source_dir}/{self.project_name}")
12
- for command in commands:
13
- run(("uv run manage.py " + command.strip()).split(" "))
10
+ # def run_manage(self, commands: list):
11
+ # manage_py = f"{self.source_dir}/{self.project_name}/manage.py"
12
+ # for command in commands:
13
+ # full_command = ["python", manage_py] + command.strip().split(" ")
14
+ # run(full_command, check=True)
14
15
 
15
- def setup_framework(self):
16
- run(["uvx", "--from", "django", "django-admin", "startproject", self.project_name])
17
- self.run_manage([f"startapp {self.name}", "makemigrations", "migrate"])
18
- return super().setup_framework(f"{self.source_dir}/{self.project_name}/{self.name}", \
19
- extra_files=[f"{self.project_name}/{self.name}/urls.py"])
20
-
21
- def install_framework(self, **kwargs):
22
- return super().install_framework(libs=["Pillow"], **kwargs)
23
-
24
- def create_example(self, name, example_id) -> None:
25
- return None
16
+ # def setup_framework(self):
17
+ # run([
18
+ # "python", "-m", "django", "startproject",
19
+ # self.project_name, self.source_dir
20
+ # ], check=True)
21
+
22
+ # chdir(f"{self.source_dir}/{self.project_name}")
23
+ # self.run_manage([f"startapp {self.name}", "makemigrations", "migrate"])
24
+
25
+ # self.extra_files.append(f"{self.project_name}/{self.name}/urls.py")
26
+
27
+ # return super().setup_framework(
28
+ # source_dir=f"{self.source_dir}/{self.project_name}/{self.name}",
29
+ # extra_files=self.extra_files
30
+ # )
31
+ """
32
+ The class is being redeveloped for better performance and capabilities
33
+ """
@@ -1,17 +1,11 @@
1
1
  from ..template import Template
2
2
 
3
-
4
3
  class FastapiManager(Template):
5
- def __init__(self, extra_libs: list = \
6
- ["sqlalchemy", "databases", "python-multipart", "aiofiles"], **kwargs):
7
-
8
- self.extra_libs = extra_libs
9
- super().__init__(**kwargs)
10
-
11
- def setup_framework(self, extra_dirs=["db"]):
12
- return super().setup_framework(extra_dirs=extra_dirs)
4
+ extra_libs = ["sqlalchemy", "python-multipart", "databases", "python-multipart", "aiofiles", "uvicorn", "jinja2", "bcrypt"]
5
+ extra_dirs = ["db"]
6
+
7
+ class StarletteManager(FastapiManager):
8
+ extra_libs = ["aiomysql"]
13
9
 
14
- def install_framework(self, **kwargs):
15
- self.extra_libs.extend(["uvicorn", "jinja2", "bcrypt"])
16
- return super().install_framework(libs=\
17
- self.extra_libs, **kwargs)
10
+ class LitestarManager(StarletteManager):
11
+ extra_libs = ["msgspec", "starlette", "httpx"]
@@ -0,0 +1,29 @@
1
+ from ..template import Template
2
+
3
+ class PyramidManager(Template):
4
+ extra_libs = ["sqlalchemy", "alembic", "pyramid_tm", "pyramid_jinja2", "pyramid_authsanity"]
5
+
6
+ class TornadoManager(Template):
7
+ extra_libs = ["motor", "aiomysql", "pytest-tornado", "aiofiles"]
8
+
9
+ class Web2pyManager(Template): ...
10
+
11
+ class GrokManager(Template):
12
+ extra_libs = ["z3c.sqlalchemy", "zope.sqlalchemy", "alembic"]
13
+
14
+ class FlaskManager(Template):
15
+ extra_libs = ["flask_sqlalchemy", "flask_migrate", "flask_wtf", "flask_login"]
16
+ extra_dirs = ["db"]
17
+
18
+ class CherryPyManager(Template):
19
+ extra_libs = ["sqlalchemy", "alembic", "Jinja2", "authlib"]
20
+
21
+ class BottleManager(Template):
22
+ extra_libs = ["sqlalchemy", "bottle-sqlalchemy", "alembic", "bottle-login", "wtforms"]
23
+ extra_libs = ["db"]
24
+
25
+ class SocketifyManager(Template):
26
+ extra_libs = ["ormar", "databases", "pydantic", "jinja2", "authlib"]
27
+
28
+ class TurboGears2Manager(Template):
29
+ extra_libs = ["sqlalchemy", "alembic", "tgext.auth", "tgext.admin"]
rapidframework/main.py CHANGED
@@ -43,23 +43,20 @@ class Main:
43
43
  #
44
44
  self.args = self.parser.parse_args()
45
45
  #
46
- self.framework_manager = self._load_framework_manager()
46
+ self.framework_manager = find_manager_class(self.args.framework)
47
47
 
48
48
  def _discover_frameworks(self):
49
49
  return sorted(set([cls.__name__.removesuffix("Manager").lower() for cls in all_subclasses(Template)]))
50
50
 
51
- def _load_framework_manager(self):
52
- return find_manager_class(self.args.framework)(name=self.args.name)
53
-
54
51
  def run(self):
55
52
  example_id = 1 if self.args.example is None else self.args.example
56
53
  #
54
+ framework = self.framework_manager(self.args.name)
55
+ #
57
56
  if hasattr(self.framework_manager, "install_framework"):
58
- self.framework_manager.install_framework(version=self.args.version)
59
-
57
+ framework.install_framework(version=self.args.version)
60
58
  if hasattr(self.framework_manager, "create_example"):
61
- self.framework_manager.create_example(self.args.name, example_id)
62
-
59
+ framework.create_example(example_id)
63
60
 
64
61
  def main_entry_point():
65
62
  Main().run()
@@ -1,55 +1,79 @@
1
1
  from os import path
2
2
  from .config import AutoManager
3
3
  from .config import Config
4
-
4
+ from typing import Optional, List
5
5
 
6
6
  cfg = Config()
7
7
 
8
-
9
8
  class Template:
9
+ extra_libs: List[str] = []
10
+ extra_dirs: List[str] = []
11
+ extra_files: List[str] = []
12
+ example: bool = True
13
+
14
+ def __init_subclass__(cls, **kwargs):
15
+ super().__init_subclass__(**kwargs)
16
+ cls.framework_name = cls.__name__.lower().replace("manager", "")
17
+
18
+ bases = [base for base in cls.__mro__[1:] if issubclass(base, Template)]
19
+
20
+ cls.extra_libs = sum([getattr(base, "extra_libs", []) for base in reversed(bases)], []) + cls.extra_libs
21
+ cls.extra_dirs = sum([getattr(base, "extra_dirs", []) for base in reversed(bases)], []) + cls.extra_dirs
22
+ cls.extra_files = sum([getattr(base, "extra_files", []) for base in reversed(bases)], []) + cls.extra_files
23
+
24
+ cls.example = getattr(cls, "example", True)
25
+
10
26
  def __init__(
11
27
  self,
12
- framework_name: str | None = None,
13
- source_dir=cfg.source_dir,
14
- project_name=cfg.project_name,
15
- **kwargs
28
+ name: str,
29
+ framework_name: Optional[str] = None,
30
+ source_dir = cfg.source_dir,
31
+ project_name = cfg.project_name
16
32
  ):
17
- if framework_name is None:
18
- self.framework_name = self.__class__.__name__.lower().replace("manager", "")
19
- else:
20
- self.framework_name = framework_name
21
- #
33
+ self.name = name
34
+ self.framework_name = framework_name or self.__class__.framework_name
22
35
  self.source_dir = source_dir
23
36
  self.project_name = project_name
24
- self.name = kwargs.get("name")
25
- #
26
37
  self.AutoManager = AutoManager()
27
- #
28
-
38
+ self.extra_libs = self.__class__.extra_libs
39
+ self.extra_dirs = self.__class__.extra_dirs
40
+ self.extra_files = self.__class__.extra_files
41
+ self.example = self.__class__.example
42
+
29
43
  def install_framework(self, **kwargs):
30
44
  version = f"=={kwargs.get('version')}" if kwargs.get('version') else ""
31
45
  libs_to_install: list = kwargs.get("libs") or []
32
46
  #
33
47
  libs_to_install.extend([f"{self.framework_name}{version}"])
34
- print("Getting libs")
48
+ libs_to_install.extend(self.extra_libs)
49
+ #
35
50
  self.AutoManager.install_libs(libs_to_install)
36
51
  #
37
52
  self.setup_framework()
38
53
 
39
- def setup_framework(self, source_dir=cfg.source_dir, extra_dirs=[], extra_files: list=None):
40
- cfg.create_dirs(source_dir, extra_dirs)
41
- if extra_files is not None:
42
- cfg.create_files(extra_files)
54
+ def setup_framework(self, source_dir: list = None, extra_dirs: list = None, extra_files: list = None):
55
+ source_dir = source_dir or self.source_dir
56
+ #
57
+ dirs = (extra_dirs or []) + self.extra_dirs
58
+ files = (extra_files or []) + self.extra_files
59
+ #
60
+ if dirs:
61
+ cfg.create_dirs(source_dir, dirs)
62
+ if files:
63
+ cfg.create_files(files)
43
64
 
44
- def create_example(self, name, example_id):
45
- from pkgutil import get_data
65
+ def create_example(self, example_id):
66
+ if self.__class__.example:
67
+ from pkgutil import get_data
46
68
 
47
- example_code = get_data(
48
- "rapidframework",
49
- f"frameworks/examples/{self.framework_name}_{example_id}.py",
50
- ).decode("utf-8")
69
+ example_code = get_data(
70
+ "rapidframework",
71
+ f"frameworks/examples/{self.framework_name}_{example_id}.py",
72
+ ).decode("utf-8")
51
73
 
52
- with open(
53
- path.join(cfg.source_dir, name + ".py"), "w", encoding="utf-8"
54
- ) as example_file:
55
- example_file.write(example_code)
74
+ with open(
75
+ path.join(self.source_dir, self.name + ".py"), "w", encoding="utf-8"
76
+ ) as example_file:
77
+ example_file.write(example_code)
78
+ else:
79
+ raise Exception("Example method is'n allowed for this framework !")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rapidframework-lib
3
- Version: 1.0.8.1
3
+ Version: 1.0.8.2
4
4
  Description-Content-Type: text/markdown
5
5
  License-File: LICENSE
6
6
  Requires-Dist: msgspec
@@ -31,7 +31,7 @@ rapidframework fastapi --name App --version 0.115.12 --example 1
31
31
 
32
32
  ## Features
33
33
 
34
- - 📦 Create projects based on popular frameworks: **Flask**, **Django**, **FastAPI**.
34
+ - 📦 Create projects based on popular frameworks: **Flask**, **Django**, **FastAPI**, etc.
35
35
  - 🎨 Support for custom templates via the `Template` class.
36
36
  - 🚀 Built-in examples to get started quickly.
37
37
 
@@ -1,23 +1,13 @@
1
1
  rapidframework/__init__.py,sha256=0f6S18Vy0QQs3VW9m4A6sNDfHoYGvf9Dzk32xlZ5RNs,151
2
2
  rapidframework/config.py,sha256=lNptfXPi50MELfL2BnaQFa9-ea6lv7R9abqipFwqwYE,2767
3
- rapidframework/main.py,sha256=eVafBtS7oeoR5Ti2omA7Wy3sWpUblk7A13SKqfTJZBI,2159
4
- rapidframework/template.py,sha256=-M7Utp0pvVdjiEFur914fOjOfEe-mYZS-lFGMiZr_ws,1696
3
+ rapidframework/main.py,sha256=P5MT1oCo-ntw9RT0V364wiRH_5-I5TiKvzqCik8doxo,2069
4
+ rapidframework/template.py,sha256=pRMEFgVY5YfxxCqMgqlil11AlJpx46H9A6rswkOS3iY,2925
5
5
  rapidframework/__pycache__/main.cpython-313.pyc,sha256=J3Y41E5fOwmGEQtwgTq-NBUl0s0VxCvDC5KUnCGvIdU,3891
6
6
  rapidframework/configs/managers.json,sha256=EEBDjTVQuNXGIF_oIXuNVpXK4kTk2HsRb2aPrbmUjo4,664
7
7
  rapidframework/frameworks/__init__.py,sha256=CJETvRzO000nPloWwKFd-AnLmR5PM9SSZUyB-C4M8a4,464
8
- rapidframework/frameworks/bottle.py,sha256=C6n0TOBnq27wlusBnK0F0YtuorINOUNJzvHMesJpqyM,327
9
- rapidframework/frameworks/cherrypy.py,sha256=qgcphhuZL9YGwyT1lu3izBeWqhu0DyQt3OaqKjbZqG4,302
10
- rapidframework/frameworks/django.py,sha256=-Cb5bvwHbnJIk8Tx4PDY4wk1v6_GZWwbkr-JFDvnhP8,956
11
- rapidframework/frameworks/fastapi.py,sha256=ionnghpdyq3CngCvp4Lq8zUz5AmcKNe6mA3SctZKkDU,583
12
- rapidframework/frameworks/flask.py,sha256=5p7fO7EnmcbEsvytAso55hPt7gWmGEdteFIu1uvA0SE,318
13
- rapidframework/frameworks/grok.py,sha256=lXrDDKIJg9QVUUKx8vcpSOBxWHUiYAKC8aBR4oPSpqk,301
14
- rapidframework/frameworks/litestar.py,sha256=tssP54TeOlBKr7dPi8vwttbTuJC1Gyme6Hapiai78LQ,266
15
- rapidframework/frameworks/pyramid.py,sha256=ikmgRRluBUPBj1uq5BBl7CAvG4mYtVieYqnyRBWGnAo,335
16
- rapidframework/frameworks/socketify.py,sha256=eyg-FnObKil7isb-B_B_hsqN44ADBvknyLXTBJ9COT4,314
17
- rapidframework/frameworks/starlette.py,sha256=1Pd-G8OZSmz8p2nnro14ge3m7avXMn6ZIQYvfWv5H-A,288
18
- rapidframework/frameworks/tornado.py,sha256=5WvPV3KntAt1WrQiURl12WikXPgL5xOa4OWwQGKSDqI,233
19
- rapidframework/frameworks/turbogears2.py,sha256=NUtV_EtCaAcytyeRpqkUlOYYSHsadqF5fxHVqWmCo0k,313
20
- rapidframework/frameworks/web2py.py,sha256=aaewCYr8kk4p7gRlLzLn_xZCdBGFX5eMvVyk7h_7Hm0,134
8
+ rapidframework/frameworks/django.py,sha256=8uY20KU608Ku5tTQPlCrxI8ye7Pz7XS4jhZ9vVJmYOM,1110
9
+ rapidframework/frameworks/fastapi.py,sha256=uAbUCzJxIgYnfmsq2SSxc_tvKsKQpBY9F3ahr1Vxhrg,389
10
+ rapidframework/frameworks/simple_frameworks.py,sha256=9PEu-ZvA17pT7QLQTnfQ_2PGjCDbi8ECaaSO1MPp2Lg,1023
21
11
  rapidframework/frameworks/examples/__init__.py,sha256=ovguP4wzQEDNguczwiZnhMm4dRRVcvnzmHrfQtlRCNQ,15
22
12
  rapidframework/frameworks/examples/bottle_1.py,sha256=AhEqgse_IinZ0jx211y0ybyxB0dknGI-x6zhIOQ4Qos,118
23
13
  rapidframework/frameworks/examples/cherrypy_1.py,sha256=BKNIPXOgWFTpnwyFK46NMDmPtFnhAARAPAkwgQ-0CYQ,146
@@ -31,9 +21,9 @@ rapidframework/frameworks/examples/starlette_1.py,sha256=6T9tUyXJ329qHl3ZYgNOCy5
31
21
  rapidframework/frameworks/examples/tornado_1.py,sha256=vnOqnzcFyCFSMl_5x4pyfbYi6PL9EMQBn9Mv_6yXpZM,368
32
22
  rapidframework/frameworks/examples/turbogears2_1.py,sha256=IytFwU7N-qSi3CDQDrN2wNHDAfV60swOw44_D-UDr-I,435
33
23
  rapidframework/frameworks/examples/web2py_1.py,sha256=fscmfjeH9HUb96aDGZBLS88e9Fx_nbU1usLDb0GWbRs,41
34
- rapidframework_lib-1.0.8.1.dist-info/licenses/LICENSE,sha256=lXsPzvyEfL6vjzMMCRYi7gpsIjpSUYUsDF-MvMHyhc0,1070
35
- rapidframework_lib-1.0.8.1.dist-info/METADATA,sha256=Vz8yDMEpPe7OXH6IbctscljhqkcfjjqQFigUYt3xdzA,1241
36
- rapidframework_lib-1.0.8.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
37
- rapidframework_lib-1.0.8.1.dist-info/entry_points.txt,sha256=UaOaGJ-BDCxtmNoPp-u_TnXXLbnXtrB13PYr5BgqmHA,72
38
- rapidframework_lib-1.0.8.1.dist-info/top_level.txt,sha256=7PXDkFZsYowz4aB2xVaSso4qD45jd2kHn6x3xxhMMNs,15
39
- rapidframework_lib-1.0.8.1.dist-info/RECORD,,
24
+ rapidframework_lib-1.0.8.2.dist-info/licenses/LICENSE,sha256=lXsPzvyEfL6vjzMMCRYi7gpsIjpSUYUsDF-MvMHyhc0,1070
25
+ rapidframework_lib-1.0.8.2.dist-info/METADATA,sha256=Zgf5i3IZUmq8nprCwJa8D1fVKe8M2S0t7WtD47Tub5k,1246
26
+ rapidframework_lib-1.0.8.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
27
+ rapidframework_lib-1.0.8.2.dist-info/entry_points.txt,sha256=UaOaGJ-BDCxtmNoPp-u_TnXXLbnXtrB13PYr5BgqmHA,72
28
+ rapidframework_lib-1.0.8.2.dist-info/top_level.txt,sha256=7PXDkFZsYowz4aB2xVaSso4qD45jd2kHn6x3xxhMMNs,15
29
+ rapidframework_lib-1.0.8.2.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- from ..template import Template
2
-
3
-
4
- class BottleManager(Template):
5
- def __init__(self, **kwargs):
6
- super().__init__(**kwargs)
7
-
8
- def install_framework(self, **kwargs):
9
- return super().install_framework(libs=\
10
- ["sqlalchemy", "bottle-sqlalchemy", "alembic", "bottle-login", "wtforms"], **kwargs)
@@ -1,10 +0,0 @@
1
- from ..template import Template
2
-
3
-
4
- class CherryPyManager(Template):
5
- def __init__(self, **kwargs):
6
- super().__init__(**kwargs)
7
-
8
- def install_framework(self, **kwargs):
9
- return super().install_framework(libs=\
10
- ["sqlalchemy", "alembic", "Jinja2", "authlib"], **kwargs)
@@ -1,10 +0,0 @@
1
- from ..template import Template
2
-
3
-
4
- class FlaskManager(Template):
5
- def __init__(self, **kwargs):
6
- super().__init__(**kwargs)
7
-
8
- def install_framework(self, **kwargs):
9
- return super().install_framework(libs=\
10
- ["flask_sqlalchemy", "flask_migrate", "flask_wtf", "flask_login"], **kwargs)
@@ -1,11 +0,0 @@
1
- from ..template import Template
2
-
3
-
4
- class GrokManager(Template):
5
- def __init__(self, **kwargs):
6
- super().__init__(**kwargs)
7
-
8
- def install_framework(self, **kwargs):
9
- return super().install_framework(libs=\
10
- ["z3c.sqlalchemy", "zope.sqlalchemy", "alembic"], **kwargs)
11
-
@@ -1,6 +0,0 @@
1
- from .starlette import StarletteManager
2
-
3
- class LitestarManager(StarletteManager):
4
- def __init__(self, extra_libs=None, **kwargs):
5
- extra_libs = (extra_libs or []) + ["msgspec", "starlette", "httpx"]
6
- super().__init__(extra_libs=extra_libs, **kwargs)
@@ -1,11 +0,0 @@
1
- from ..template import Template
2
-
3
-
4
- class PyramidManager(Template):
5
- def __init__(self, **kwargs):
6
- super().__init__(**kwargs)
7
-
8
- def install_framework(self, **kwargs):
9
- return super().install_framework(libs=\
10
- ["sqlalchemy", "alembic", "pyramid_tm", "pyramid_jinja2", "pyramid_authsanity"], **kwargs)
11
-
@@ -1,11 +0,0 @@
1
- from ..template import Template
2
-
3
-
4
- class SocketifyManager(Template):
5
- def __init__(self, **kwargs):
6
- super().__init__(**kwargs)
7
-
8
- def install_framework(self, **kwargs):
9
- return super().install_framework(libs=\
10
- ["ormar", "databases", "pydantic", "jinja2", "authlib"], **kwargs)
11
-
@@ -1,9 +0,0 @@
1
- from .fastapi import FastapiManager
2
-
3
-
4
- class StarletteManager(FastapiManager):
5
- def __init__(self, extra_libs = \
6
- ["sqlalchemy", "aiomysql", "python-multipart", "aiofiles"], **kwargs):
7
-
8
- self.extra_libs = extra_libs
9
- super().__init__(extra_libs, **kwargs)
@@ -1,7 +0,0 @@
1
- from .fastapi import FastapiManager
2
-
3
-
4
- class TornadoManager(FastapiManager):
5
- def __init__(self, extra_libs = \
6
- ["motor", "aiomysql", "pytest-tornado", "aiofiles"], **kwargs):
7
- super().__init__(extra_libs, **kwargs)
@@ -1,10 +0,0 @@
1
- from ..template import Template
2
-
3
-
4
- class TurboGears2Manager(Template):
5
- def __init__(self, **kwargs):
6
- super().__init__(**kwargs)
7
-
8
- def install_framework(self, **kwargs):
9
- return super().install_framework(libs=\
10
- ["sqlalchemy", "alembic", "tgext.auth", "tgext.admin"], **kwargs)
@@ -1,6 +0,0 @@
1
- from ..template import Template
2
-
3
-
4
- class Web2pyManager(Template):
5
- def __init__(self, **kwargs):
6
- super().__init__(**kwargs)