Skip to content

Sourcery Starbot ⭐ refactored wilsonusman/rockauto_api#1

Open
SourceryAI wants to merge 1 commit intowilsonusman:mainfrom
SourceryAI:main
Open

Sourcery Starbot ⭐ refactored wilsonusman/rockauto_api#1
SourceryAI wants to merge 1 commit intowilsonusman:mainfrom
SourceryAI:main

Conversation

@SourceryAI
Copy link
Copy Markdown

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:

git fetch https://github.com/sourcery-ai-bot/rockauto_api main
git merge --ff-only FETCH_HEAD
git reset HEAD^

Comment thread rockauto.py
Comment on lines -112 to +128
categories_list = []

browser = mechanize.Browser()
page_content = browser.open( search_link ).read()
browser.close()

soup = BeautifulSoup(page_content, features='html5lib').find_all('a', attrs={'class', 'navlabellink'})[4:]

for x in soup:
categories_list.append( {'make': search_make, 'year': search_year, 'model': search_model, 'engine': search_engine, 'category': x.get_text(), 'link': 'https://www.rockauto.com' + str( x.get('href') ) })

return categories_list
return [
{
'make': search_make,
'year': search_year,
'model': search_model,
'engine': search_engine,
'category': x.get_text(),
'link': 'https://www.rockauto.com' + str(x.get('href')),
}
for x in soup
]
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function get_categories refactored with the following changes:

Comment thread rockauto.py
Comment on lines -131 to +149
sub_categories_list = []

browser = mechanize.Browser()
page_content = browser.open( search_link ).read()
browser.close()

soup = BeautifulSoup(page_content, features='html5lib').find_all('a', attrs={'class', 'navlabellink'})[5:]

for x in soup:
sub_categories_list.append( {'make': search_make, 'year': search_year, 'model': search_model, 'engine': search_engine, 'category': search_category, 'sub_category': x.get_text(), 'link': 'https://www.rockauto.com' + str( x.get('href') ) })

return sub_categories_list No newline at end of file
return [
{
'make': search_make,
'year': search_year,
'model': search_model,
'engine': search_engine,
'category': search_category,
'sub_category': x.get_text(),
'link': 'https://www.rockauto.com' + str(x.get('href')),
}
for x in soup
] No newline at end of file
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function get_sub_categories refactored with the following changes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant