-
Notifications
You must be signed in to change notification settings - Fork 45
fix: TimeDelta calculations #270
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
Merged my branches together but here are my comments so they are easy to find:
|
@AxelMurilllo could you please provide a code example for testing? |
Heres a simple script for testing TimeDelta and uninitiated objects .max_level attribute. I used the "Barbarian" as an example as it is the only home village troop with an upgrade time in minutes. Make sure that your static data is updated!
|
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.
Pull Request Overview
This PR refactors the TimeDelta class to simplify its time normalization logic and adds handling for None types. Additionally, it updates the APK download process to use synchronous requests with BeautifulSoup for parsing and adjusts the upgrade_time initialization in the JSON meta loader to match the new TimeDelta API.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
coc/static/update_static.py | Updated the APK download function to use requests and improved error handling in download logic. |
coc/static/apk_source.py | Added a new function to retrieve the direct APK download URL from APKMirror. |
coc/miscmodels.py | Refactored the TimeDelta class to calculate total seconds in a single calculation. |
coc/abc.py | Modified upgrade_time initialization to use the updated TimeDelta constructor parameters. |
Comments suppressed due to low confidence (1)
coc/abc.py:281
- If the API provides an 'UpgradeTimeS', consider including it in the TimeDelta initialization to maintain consistency with the previous behavior.
TimeDelta(
|
||
# download the APK using the direct URL | ||
print("[+] Downloading APK file...") | ||
response = session.get(direct_url, stream=True) |
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.
Consider verifying the HTTP response status (e.g., checking response.status_code) before processing the content to ensure the request succeeded.
response = session.get(direct_url, stream=True) | |
response = session.get(direct_url, stream=True) | |
response.raise_for_status() # Ensure the request was successful |
Copilot uses AI. Check for mistakes.
|
||
dl_button = variant_soup.select_one("a.downloadButton") | ||
if not dl_button: | ||
raise Exception("ERROR:Download button not found on variant page") |
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.
Consider adding a space after 'ERROR:' in the exception message for consistency.
raise Exception("ERROR:Download button not found on variant page") | |
raise Exception("ERROR: Download button not found on variant page") |
Copilot uses AI. Check for mistakes.
Previous TimeDelta class constructor: