Skip to content

Commit

Permalink
[feature] version 0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tsiresymila1 committed Feb 26, 2024
1 parent a443f22 commit 319e485
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 4 deletions.
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<p align="center">
<a href="https://nestipy.com/" target="blank"><img src="nestipy.png" width="200" alt="Nestipy Logo" /></a>
</p>

## Description

Nestipy is a framework for building efficient, scalable <a href="https://python.org" target="_blank">Python</a>
server-side applications. It uses modern Python typing combines with elements of OOP (Object Oriented Programming), FP (
Functional Programming).

<p>Under the hood, Nestipy makes use of <a href="https://litestar.dev/" target="_blank">Litestar</a>, but also provides compatibility with a wide range of other libraries, like <a href="https://fastapi.tiangolo.com/" target="_blank">FastAPI</a>, allowing for easy use of the myriad of third-party plugins which are available.</p>

## Philosophy

<p>Nestipy aims to provide an application architecture out of the box which allows for effortless creation of highly testable, scalable, and loosely coupled and easily maintainable applications. The architecture is heavily inspired by Angular.</p>

## Getting started

```cmd
pip install nestipy
nestipy new my_app
cd my_app
python main.py
```

## Questions

## Issues

Please make sure to read the [Issue Reporting Checklist](https://github.com/tsiresymila/nestipy) before opening an
issue. Issues not conforming to the guidelines may be closed immediately.

## Support

Nestipy is an MIT-licensed open source project. It can grow thanks to the sponsors and support from the amazing backers.
If you'd like to join them, please [read more here](https://docs.nestipy.com/support).

## Stay in touch

- Author - [Tsiresy Mila](https://tsiresymila.vercel.app)

## License

Nestipy is [MIT licensed](LICENSE).
Binary file added nestipy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 5 additions & 4 deletions src/nestipy/cli/handler.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os.path
from pathlib2 import Path

from nestipy.common.templates.generator import TemplateGenerator

Expand Down Expand Up @@ -39,6 +38,7 @@ def generate_resource_graphql(self, name):
def generate_module(self, name: str, prefix: str = None):
path = self.mkdir(name)
self.generate(name, path, 'module', prefix=prefix)
self.modify_app_module(name)

def generate_controller(self, name: str, prefix: str = None):
path = self.mkdir(name)
Expand Down Expand Up @@ -73,14 +73,14 @@ def generate(self, name, parent_path, template, prefix: str = None):
@classmethod
def modify_app_module(cls, name):
name = str(name)
app_path = os.path.join(os.getcwd(), 'app_module.py')
app_path = os.path.join(os.getcwd(), 'src', 'app_module.py')
if os.path.exists(app_path):
new_import = f"{str(name).capitalize()}Module"
with open(app_path, 'r') as file:
file_content = file.read()
file.close()
module_pattern = r'@Module\(([^)]*)\)'
text_to_add = f'from src/{name.lower()}_module import {name.capitalize()}Module'
text_to_add = f'from .{name.lower()}.{name.lower()}_module import {name.capitalize()}Module'
import re
match = re.search(module_pattern, file_content)
if match:
Expand All @@ -96,7 +96,8 @@ def modify_app_module(cls, name):
else:
# If imports=[] doesn't exist, add imports directly
modified_content = file_content.replace(match.group(0),
text_to_add + '\n@Module(imports=[' + new_import + '],')
text_to_add + f'\n@Module(\n\timports=[{new_import}],'
f'{existing_imports_str})')
with open(app_path, 'w') as file2:
file2.write(modified_content)
file2.close()
Expand Down
3 changes: 3 additions & 0 deletions src/nestipy/core/platform/platform_litestar.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ def controller_to_extend_litestar_controller(ctrl):
if not inspect.ismethod(value) and not inspect.isfunction(value) and not inspect.isbuiltin(
value) and name != '__slots__':
class_attrs[name] = value

if not hasattr(ctrl, 'tags'):
class_attrs['tags'] = [str(ctrl.__name__).replace('Controller', '')]
return type(ctrl.__name__, (Controller,),
{**class_attrs, "__module__": ctrl.__module__})

Expand Down

0 comments on commit 319e485

Please sign in to comment.