-
Notifications
You must be signed in to change notification settings - Fork 17
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
Sourcery Starbot ⭐ refactored arindas/mac-on-linux-with-qemu #29
Conversation
plist_data = plist_raw.text.encode('UTF-8') | ||
return plist_data | ||
return plist_raw.text.encode('UTF-8') |
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 Filesystem.fetch_plist
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
if sys.version_info > (3, 0): | ||
root = plistlib.loads(catalog_data) | ||
else: | ||
root = plistlib.readPlistFromString(catalog_data) | ||
return root | ||
return ( | ||
plistlib.loads(catalog_data) | ||
if sys.version_info > (3, 0) | ||
else plistlib.readPlistFromString(catalog_data) | ||
) |
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 Filesystem.parse_plist
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
) - Replace if statement with if expression (
assign-if-exp
)
# Iterate to find valid OSInstall packages | ||
ospackages = [] | ||
products = root['Products'] | ||
for product in products: | ||
if products.get(product, {}).get('ExtendedMetaInfo', {}).get('InstallAssistantPackageIdentifiers', {}).get('OSInstall', {}) == 'com.apple.mpkg.OSInstall': | ||
ospackages.append(product) | ||
|
||
ospackages = [ | ||
product | ||
for product in products | ||
if products.get(product, {}) | ||
.get('ExtendedMetaInfo', {}) | ||
.get('InstallAssistantPackageIdentifiers', {}) | ||
.get('OSInstall', {}) | ||
== 'com.apple.mpkg.OSInstall' | ||
] | ||
|
||
# Iterate for an specific version | ||
candidates = [] | ||
for product in ospackages: | ||
meta_url = products.get(product, {}).get('ServerMetadataURL', {}) | ||
if self.version in Filesystem.parse_plist(Filesystem.fetch_plist(meta_url)).get('CFBundleShortVersionString', {}): | ||
candidates.append(product) | ||
|
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 SoftwareService.getosinstall
refactored with the following changes:
- Move assignment closer to its usage within a block (
move-assign-in-block
) - Convert for loop into list comprehension (
list-comprehension
)
This removes the following comments ( why? ):
# Iterate to find valid OSInstall packages
if keyword: | ||
for item in packages: | ||
if keyword in item.get("URL"): | ||
Filesystem.download_file(item.get("URL"), item.get("Size"), path) | ||
else: | ||
for item in packages: | ||
for item in packages: | ||
if keyword and keyword in item.get("URL") or not keyword: |
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 MacOSProduct.fetchpackages
refactored with the following changes:
- Hoist repeated code outside conditional statement (
hoist-statement-from-if
) - Merge duplicate blocks in conditional (
merge-duplicate-blocks
)
Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨
Here's your pull request refactoring your most popular Python repo.
If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.
Review changes via command line
To manually merge these changes, make sure you're on the
main
branch, then run: