-
Notifications
You must be signed in to change notification settings - Fork 0
Sourcery refactored master branch #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,25 +25,30 @@ def vlog(self, msg, *args): | |
|
||
|
||
pass_context = click.make_pass_decorator(Context, ensure = True) | ||
cmd_folder = os.path.join(BASE_DIR + '/cli', 'commands') | ||
cmd_folder = os.path.join(f'{BASE_DIR}/cli', 'commands') | ||
|
||
|
||
class CLI(click.MultiCommand): | ||
|
||
def list_commands(self, ctx): | ||
rv = [] | ||
for filename in os.listdir(cmd_folder): | ||
if filename.endswith('.py') and \ | ||
filename.startswith('cmd_'): | ||
rv.append(filename[4:-3]) | ||
rv = [ | ||
filename[4:-3] | ||
for filename in os.listdir(cmd_folder) | ||
if filename.endswith('.py') and filename.startswith('cmd_') | ||
] | ||
Comment on lines
-34
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
rv.sort() | ||
return rv | ||
|
||
def get_command(self, ctx, name): | ||
try: | ||
if sys.version_info[0] == 2: | ||
name = name.encode('ascii', 'replace') | ||
mod = __import__('cli.commands.cmd_' + name, locals = None, globals = None, fromlist = ['cli']) | ||
mod = __import__( | ||
f'cli.commands.cmd_{name}', | ||
locals=None, | ||
globals=None, | ||
fromlist=['cli'], | ||
) | ||
Comment on lines
-46
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
except ImportError: | ||
return | ||
return mod.cli | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,7 +38,7 @@ def make_api(api_name: str, model): | |
f"class {api_name.capitalize()}View(Resource):\n" | ||
f" pass") | ||
|
||
with open(f'api/__init__.py', 'a+') as f: | ||
with open('api/__init__.py', 'a+') as f: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
f.write( | ||
f'from api.{api_name.capitalize()} import {api_name.capitalize()}View\n') | ||
f.write( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,7 +144,7 @@ class {model_name.capitalize()}(Model): | |
pass | ||
''') | ||
|
||
with open(f'models/__init__.py', 'a+') as f: | ||
with open('models/__init__.py', 'a+') as f: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
f.write( | ||
f'from models.{model_name.capitalize()} import {model_name.capitalize()}\n') | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ def list_(): | |
|
||
output[rule.endpoint] = route | ||
|
||
endpoint_padding = max(len(endpoint) for endpoint in output.keys()) + 2 | ||
endpoint_padding = max(len(endpoint) for endpoint in output) + 2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
for key in sorted(output): | ||
if 'debugtoolbar' not in key and 'debug_toolbar' not in key: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,7 +61,9 @@ | |
|
||
formatter = logging.Formatter( | ||
"[%(asctime)s] {%(pathname)s:%(lineno)d} %(levelname)s - %(message)s") | ||
handler = RotatingFileHandler(LOG_DIR + '/app.log', maxBytes = 1000000, backupCount = 5) | ||
handler = RotatingFileHandler( | ||
f'{LOG_DIR}/app.log', maxBytes=1000000, backupCount=5 | ||
) | ||
Comment on lines
-64
to
+66
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
handler.setLevel(logging.DEBUG) | ||
handler.setFormatter(formatter) | ||
app.logger.addHandler(handler) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,9 +105,7 @@ def __ne__(self, other): | |
Checks the inequality of two `UserMixin` objects using `get_id`. | ||
""" | ||
equal = self.__eq__(other) | ||
if equal is NotImplemented: | ||
return NotImplemented | ||
return not equal | ||
return NotImplemented if equal is NotImplemented else not equal | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
|
||
class AnonymousUserMixin: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,8 +105,4 @@ def get_mimes(extension=None): | |
|
||
def get_extensions(mime_type=None): | ||
"""Returns possible extensions for the given mime_type""" | ||
exts = [] | ||
for ext in _mime_types: | ||
if mime_type in _mime_types[ext]: | ||
exts.append(ext) | ||
return exts | ||
return [ext for ext in _mime_types if mime_type in _mime_types[ext]] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,7 @@ class User(Model): | |
# __guarded__ = ['id', 'password', 'password_again'] | ||
|
||
def __repr__(self): | ||
return '<User {}>'.format(self.username) | ||
return f'<User {self.username}>' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
@property | ||
def rolenames(self): | ||
|
@@ -56,8 +56,7 @@ def rolenames(self): | |
|
||
@classmethod | ||
def lookup(cls, username): | ||
result = cls.query().where('username', username).first_or_fail() | ||
if result: | ||
if result := cls.query().where('username', username).first_or_fail(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
return result | ||
else: | ||
return None | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines
28-28
refactored with the following changes:use-fstring-for-concatenation
)