-
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?
Conversation
temp = [] | ||
for key in self.cmdList: | ||
temp.append((self.cmdList[key]['order'], key)) | ||
temp = [(self.cmdList[key]['order'], key) for key in self.cmdList] |
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.
Function device.sortCommands
refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension
)
d = {} | ||
d['UDID'] = self.UDID | ||
if self.customName: | ||
d['name'] = self.customName | ||
else: | ||
d['name'] = self.name | ||
d['ip'] = self.IP | ||
d['owner'] = self.owner | ||
d['location'] = self.location | ||
d['geo'] = self.GEO | ||
d['status'] = ['success', 'warning', 'danger'][self.status] | ||
d = { | ||
'UDID': self.UDID, | ||
'name': self.customName or self.name, | ||
'ip': self.IP, | ||
'owner': self.owner, | ||
'location': self.location, | ||
'geo': self.GEO, | ||
'status': ['success', 'warning', 'danger'][self.status], | ||
} | ||
|
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.
Function device.populate
refactored with the following changes:
- Simplify if expression by using or (
or-if-exp-identity
) - Merge dictionary assignment with declaration (
merge-dict-assign
) - Replace if statement with if expression (
assign-if-exp
) - Ensure constant in comparison is on the right (
flip-comparison
)
|
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.
Function device.checkTimeout
refactored with the following changes:
- Merge dictionary assignment with declaration (
merge-dict-assign
)
MY_ADDR = s.getsockname()[0] + ":8080" | ||
MY_ADDR = f"{s.getsockname()[0]}:8080" |
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 53-89
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
) - Replace dict() with {} (
dict-literal
)
drop_list = [] | ||
for key in sorted(mdm_commands.iterkeys()): | ||
drop_list.append([key, key]) | ||
drop_list = [[key, key] for key in sorted(mdm_commands.iterkeys())] |
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.
Function get_commands.POST
refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension
)
problem_detect += ') Jailbreak detected for ' | ||
problem_detect += ') Jailbreak detected for ' | ||
problem_detect += web.ctx.ip | ||
|
||
problems.insert(0, problem_detect) | ||
out = "\nproblems = %s" % problems | ||
fd = open('problems.py', 'w') | ||
fd.write(out) | ||
fd.close() | ||
with open('problems.py', 'w') as fd: | ||
fd.write(out) |
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.
Function do_problem.GET
refactored with the following changes:
- Simplify conditional into switch-like form (
switch
) - Use
with
when opening file to ensure closure (ensure-file-closed
)
if 'CA.crt' in os.listdir('.'): | ||
web.header('Content-Type', 'application/octet-stream;charset=utf-8') | ||
web.header('Content-Disposition', 'attachment;filename="CA.crt"') | ||
return open('CA.crt', "rb").read() | ||
else: | ||
if 'CA.crt' not in os.listdir('.'): | ||
raise web.notfound() | ||
web.header('Content-Type', 'application/octet-stream;charset=utf-8') | ||
web.header('Content-Disposition', 'attachment;filename="CA.crt"') | ||
return open('CA.crt', "rb").read() |
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.
Function mdm_ca.GET
refactored with the following changes:
- Swap if/else branches (
swap-if-else-branches
) - Remove unnecessary else after guard condition (
remove-unnecessary-else
)
if 'Manifest.plist' in os.listdir('.'): | ||
web.header('Content-Type', 'text/xml;charset=utf-8') | ||
return open('Manifest.plist', "rb").read() | ||
else: | ||
if 'Manifest.plist' not in os.listdir('.'): | ||
raise web.notfound() | ||
web.header('Content-Type', 'text/xml;charset=utf-8') | ||
return open('Manifest.plist', "rb").read() |
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.
Function app_manifest.GET
refactored with the following changes:
- Swap if/else branches (
swap-if-else-branches
) - Remove unnecessary else after guard condition (
remove-unnecessary-else
)
if 'MyApp.ipa' in os.listdir('.'): | ||
web.header('Content-Type', 'application/octet-stream;charset=utf-8') | ||
web.header('Content-Disposition', 'attachment;filename="MyApp.ipa"') | ||
return open('MyApp.ipa', "rb").read() | ||
else: | ||
if 'MyApp.ipa' not in os.listdir('.'): | ||
return web.ok | ||
web.header('Content-Type', 'application/octet-stream;charset=utf-8') | ||
web.header('Content-Disposition', 'attachment;filename="MyApp.ipa"') | ||
return open('MyApp.ipa', "rb").read() |
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.
Function app_ipa.GET
refactored with the following changes:
- Swap if/else branches (
swap-if-else-branches
) - Remove unnecessary else after guard condition (
remove-unnecessary-else
)
fd = open(LOGFILE, "a") | ||
fd.write(datetime.now().ctime()) | ||
fd.write(" %s\n" % repr(out)) | ||
fd.close() | ||
with open(LOGFILE, "a") as fd: | ||
fd.write(datetime.now().ctime()) | ||
fd.write(" %s\n" % repr(out)) |
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.
Function log_data
refactored with the following changes:
- Use
with
when opening file to ensure closure (ensure-file-closed
)
Branch
master
refactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
master
branch, then run:Help us improve this pull request!