Skip to content

Commit 26136f2

Browse files
committed
fix codestyle and docstrings
1 parent 5181990 commit 26136f2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+4760
-4767
lines changed

examples/random_examples/advanced_app.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,30 @@
88

99

1010
class UsersPageController(PageController):
11-
def get(self, request, response, **kwargs):
12-
return "users get"
11+
def get(self, request, response, **kwargs):
12+
return "users get"
1313

14-
def post(self, request, response, **kwargs):
15-
return "users post"
14+
def post(self, request, response, **kwargs):
15+
return "users post"
1616

1717

1818
url_patterns = [URL(path="/users", controller=UsersPageController)]
1919
settings = Settings(
20-
BASE_DIR=os.path.dirname(os.path.abspath(__file__)), TEMPLATES_DIR="templates"
20+
BASE_DIR=os.path.dirname(os.path.abspath(__file__)), TEMPLATES_DIR="templates"
2121
)
2222
echonext = EchoNext(
23-
__name__,
24-
settings,
25-
middlewares,
26-
urls=url_patterns,
27-
application_type=ApplicationType.HTML,
23+
__name__,
24+
settings,
25+
middlewares,
26+
urls=url_patterns,
27+
application_type=ApplicationType.HTML,
2828
)
2929

3030

3131
@echonext.route_page("/book")
3232
class BooksResource(PageController):
33-
def get(self, request, response, **kwargs):
34-
return f"Books Page: {request.GET}"
33+
def get(self, request, response, **kwargs):
34+
return f"Books Page: {request.GET}"
3535

36-
def post(self, request, response, **kwargs):
37-
return "Endpoint to create a book"
36+
def post(self, request, response, **kwargs):
37+
return "Endpoint to create a book"

examples/random_examples/example_locale.py

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -10,74 +10,74 @@
1010

1111

1212
class UsersView(PageController):
13-
def get(self, request, response, *args, **kwargs):
14-
return render_template(
15-
request,
16-
"index.html",
17-
user_name="User",
18-
session_id=request.session_id,
19-
friends=["Bob", "Anna", "John"],
20-
)
13+
def get(self, request, response, *args, **kwargs):
14+
return render_template(
15+
request,
16+
"index.html",
17+
user_name="User",
18+
session_id=request.session_id,
19+
friends=["Bob", "Anna", "John"],
20+
)
2121

22-
def post(self, request, response, *args, **kwargs):
23-
raise MethodNotAllow(f"Request {request.path}: method not allow")
22+
def post(self, request, response, *args, **kwargs):
23+
raise MethodNotAllow(f"Request {request.path}: method not allow")
2424

2525

2626
url_patterns = [URL(path="/users", controller=UsersView)]
2727
config_loader = SettingsLoader(SettingsConfigType.PYMODULE, "el_config.py")
2828
settings = config_loader.get_settings()
2929
static_files = [StaticFile(settings, "styles.css")]
3030
echonext = EchoNext(
31-
__name__,
32-
settings,
33-
middlewares,
34-
urls=url_patterns,
35-
application_type=ApplicationType.HTML,
36-
static_files=static_files,
31+
__name__,
32+
settings,
33+
middlewares,
34+
urls=url_patterns,
35+
application_type=ApplicationType.HTML,
36+
static_files=static_files,
3737
)
3838
apidoc = APIDocumentation(echonext)
3939

4040

4141
@echonext.route_page("/api-docs")
4242
def api_docs(request, response):
43-
ui = APIDocUI(apidoc.generate_spec())
44-
return ui.generate_html_page()
43+
ui = APIDocUI(apidoc.generate_spec())
44+
return ui.generate_html_page()
4545

4646

4747
@echonext.route_page("/book")
4848
class BooksResource(PageController):
49-
"""
50-
This class describes a books resource.
51-
"""
49+
"""
50+
This class describes a books resource.
51+
"""
5252

53-
def get(self, request, response, **kwargs):
54-
"""
55-
get queries
53+
def get(self, request, response, **kwargs):
54+
"""
55+
get queries
5656
57-
:param request: The request
58-
:type request: Request
59-
:param response: The response
60-
:type response: Response
61-
:param kwargs: The keywords arguments
62-
:type kwargs: dictionary
57+
:param request: The request
58+
:type request: Request
59+
:param response: The response
60+
:type response: Response
61+
:param kwargs: The keywords arguments
62+
:type kwargs: dictionary
6363
64-
:returns: result
65-
:rtype: str
66-
"""
67-
return echonext.i18n_loader.get_string("title %{name}", name=str(request.GET))
64+
:returns: result
65+
:rtype: str
66+
"""
67+
return echonext.i18n_loader.get_string("title %{name}", name=str(request.GET))
6868

69-
def post(self, request, response, **kwargs):
70-
"""
71-
post queries
69+
def post(self, request, response, **kwargs):
70+
"""
71+
post queries
7272
73-
:param request: The request
74-
:type request: Request
75-
:param response: The response
76-
:type response: Response
77-
:param kwargs: The keywords arguments
78-
:type kwargs: dictionary
73+
:param request: The request
74+
:type request: Request
75+
:param response: The response
76+
:type response: Response
77+
:param kwargs: The keywords arguments
78+
:type kwargs: dictionary
7979
80-
:returns: result
81-
:rtype: str
82-
"""
83-
return echonext.l10n_loader.format_currency(1305.50)
80+
:returns: result
81+
:rtype: str
82+
"""
83+
return echonext.l10n_loader.format_currency(1305.50)

examples/random_examples/hashing.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
old_hash = hasher.hash("TEXT")
55
new_hash = hasher.hash("TEXT")
66

7-
if hasher.verify("TEXT", new_hash): # true
8-
print("Yes!")
7+
if hasher.verify("TEXT", new_hash): # true
8+
print("Yes!")
99

1010
if hasher.verify("TEXT2", old_hash): # false
11-
print("Yes!")
11+
print("Yes!")
1212

1313

1414
hasher = SaltedHasher(HashAlgorithm.BLAKE2S, salt="bob")
1515
old_hash = hasher.hash("TEXT")
1616
new_hash = hasher.hash("TEXT")
1717

18-
if hasher.verify("TEXT", new_hash): # true
19-
print("Yes!")
18+
if hasher.verify("TEXT", new_hash): # true
19+
print("Yes!")
2020

2121
if hasher.verify("TEXT2", old_hash): # false
22-
print("Yes!")
22+
print("Yes!")

examples/random_examples/modern.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,43 +12,43 @@
1212

1313

1414
class IndexController(PageController):
15-
def get(self, request, response, **kwargs):
16-
return "Hello"
15+
def get(self, request, response, **kwargs):
16+
return "Hello"
1717

18-
def post(self, request, response, **kwargs):
19-
return "Hello"
18+
def post(self, request, response, **kwargs):
19+
return "Hello"
2020

2121

2222
def say_hello(name: str, phrase: str = "Hello"):
23-
return f"{phrase} {name}"
23+
return f"{phrase} {name}"
2424

2525

2626
class Hello_Dependency:
27-
def __init__(self, say_hello):
28-
self.say_hello = say_hello
27+
def __init__(self, say_hello):
28+
self.say_hello = say_hello
2929

3030

3131
container = Container()
3232
container.register("say_hello", CallableProvider(say_hello))
3333

3434
url_patterns = [URL(path="/", controller=IndexController)]
3535
settings = Settings(
36-
BASE_DIR=os.path.dirname(os.path.abspath(__file__)), TEMPLATES_DIR="templates"
36+
BASE_DIR=os.path.dirname(os.path.abspath(__file__)), TEMPLATES_DIR="templates"
3737
)
3838
echonext = EchoNext(
39-
__name__,
40-
settings,
41-
middlewares,
42-
urls=url_patterns,
43-
application_type=ApplicationType.HTML,
39+
__name__,
40+
settings,
41+
middlewares,
42+
urls=url_patterns,
43+
application_type=ApplicationType.HTML,
4444
)
4545

4646

4747
@echonext.route_page("/hello/{name}")
4848
def hello(
49-
request,
50-
response,
51-
name: str = "World",
52-
depend: Depends = Depends(container, Hello_Dependency),
49+
request,
50+
response,
51+
name: str = "World",
52+
depend: Depends = Depends(container, Hello_Dependency),
5353
):
54-
response.body = depend().say_hello(name)
54+
response.body = depend().say_hello(name)

examples/random_examples/security.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
passwords = ["AngryPassword", "S0mesd7623tds@&6^@_", "PassWord", "Pass"]
66

77
for password in passwords:
8-
print("Base:", password)
9-
print("Crypted:", pspc.crypt(password))
10-
print("Decrypted:", pspc.decrypt(pspc.crypt(password)))
11-
print()
8+
print("Base:", password)
9+
print("Crypted:", pspc.crypt(password))
10+
print("Decrypted:", pspc.decrypt(pspc.crypt(password)))
11+
print()

examples/random_examples/simple_api.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,32 @@
99

1010

1111
class UsersPageController(PageController):
12-
def get(self, request, response, **kwargs):
13-
return Response(request, body={"users": "get"})
12+
def get(self, request, response, **kwargs):
13+
return Response(request, body={"users": "get"})
1414

15-
def post(self, request, response, **kwargs):
16-
return {"users": "post"}
15+
def post(self, request, response, **kwargs):
16+
return {"users": "post"}
1717

1818

1919
url_patterns = [URL(path="/users", controller=UsersPageController)]
2020

2121
settings = Settings(
22-
BASE_DIR=os.path.dirname(os.path.abspath(__file__)), TEMPLATES_DIR="templates"
22+
BASE_DIR=os.path.dirname(os.path.abspath(__file__)), TEMPLATES_DIR="templates"
2323
)
2424

2525
echonext = EchoNext(
26-
__name__,
27-
settings,
28-
middlewares,
29-
urls=url_patterns,
30-
application_type=ApplicationType.JSON,
26+
__name__,
27+
settings,
28+
middlewares,
29+
urls=url_patterns,
30+
application_type=ApplicationType.JSON,
3131
)
3232

3333

3434
@echonext.route_page("/book")
3535
class BooksResource(PageController):
36-
def get(self, request, response, **kwargs):
37-
return {"params": request.GET, "page": "books"}
36+
def get(self, request, response, **kwargs):
37+
return {"params": request.GET, "page": "books"}
3838

39-
def post(self, request, response, **kwargs):
40-
return {"params": request.POST, "page": "books"}
39+
def post(self, request, response, **kwargs):
40+
return {"params": request.POST, "page": "books"}

examples/random_examples/simple_app.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,35 @@
88
from pyechonext.middleware import middlewares
99

1010
settings = Settings(
11-
BASE_DIR=os.path.dirname(os.path.abspath(__file__)), TEMPLATES_DIR="templates"
11+
BASE_DIR=os.path.dirname(os.path.abspath(__file__)), TEMPLATES_DIR="templates"
1212
)
1313
echonext = EchoNext(
14-
__name__, settings, middlewares, application_type=ApplicationType.HTML
14+
__name__, settings, middlewares, application_type=ApplicationType.HTML
1515
)
1616
session = SQLiteSession("echonext.db")
1717

1818

1919
class User(SessionModel):
20-
__tablename__ = "Users"
20+
__tablename__ = "Users"
2121

22-
id = IntegerField(primary_key=True)
23-
name = TextField(null=False)
24-
cash = RealField(null=False, default=0.0)
22+
id = IntegerField(primary_key=True)
23+
name = TextField(null=False)
24+
cash = RealField(null=False, default=0.0)
2525

26-
def __repr__(self):
27-
return f"<User {self.pk}>"
26+
def __repr__(self):
27+
return f"<User {self.pk}>"
2828

2929

3030
@echonext.route_page("/")
3131
def home(request, response):
32-
user = User(name="John", cash=100.0)
33-
session.add(user)
34-
session.commit()
35-
return "Hello from the HOME page"
32+
user = User(name="John", cash=100.0)
33+
session.add(user)
34+
session.commit()
35+
return "Hello from the HOME page"
3636

3737

3838
@echonext.route_page("/users")
3939
def about(request, response):
40-
users = session.get_all_by_model(User)
40+
users = session.get_all_by_model(User)
4141

42-
return f"Users: {[f'{user.name}: {user.cash}$' for user in users]}"
42+
return f"Users: {[f'{user.name}: {user.cash}$' for user in users]}"

0 commit comments

Comments
 (0)