From 86e738ad08f1023ea09fb85135a402798161ac8e Mon Sep 17 00:00:00 2001 From: Eriks K Date: Wed, 18 Aug 2021 09:11:23 +0300 Subject: [PATCH] Browser UA version update gitignore Updated constants Requirements update --- .gitignore | 1 + erepublik/access_points.py | 24 +++++++++++------------- erepublik/constants.py | 6 ++++++ erepublik/utils.py | 22 +++++++++++----------- requirements_dev.txt | 19 ++++++++++--------- 5 files changed, 39 insertions(+), 33 deletions(-) diff --git a/.gitignore b/.gitignore index 1a1fde0..6fba780 100644 --- a/.gitignore +++ b/.gitignore @@ -103,3 +103,4 @@ ENV/ debug/ log/ *dump.json +.idea/ diff --git a/erepublik/access_points.py b/erepublik/access_points.py index b9b035a..90db204 100644 --- a/erepublik/access_points.py +++ b/erepublik/access_points.py @@ -110,15 +110,13 @@ class SlowRequests(Session): def get_random_user_agent() -> str: windows_x64 = "Windows NT 10.0; Win64; x64" linux_x64 = "X11; Linux x86_64" - android_11 = "Android 11; Mobile" - android_10 = "Android 10; Mobile" - android_9 = "Android 9; Mobile" + android = [f"Android {version}; Mobile" for version in range(8, 12)] - firefox_tmplt = "Mozilla/5.0 ({osystem}; rv:{version}.0) Gecko/20100101 Firefox/{version}.0" - ff_version = range(85, 92) + firefox_template = "Mozilla/5.0 ({osystem}; rv:{version}.0) Gecko/20100101 Firefox/{version}.0" + firefox_versions = range(85, 92) - chrome_tmplt = "Mozilla/5.0 ({osystem}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{version} Safari/537.36" - chrome_version = [ + chrome_template = "Mozilla/5.0 ({osystem}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{version} Safari/537.36" + chrome_versions = [ "85.0.4183.121", "86.0.4240.183", "87.0.4280.141", @@ -126,15 +124,15 @@ class SlowRequests(Session): "89.0.4389.128", "90.0.4430.18", "91.0.4472.73", - "92.0.4515.14", + "92.0.4515.159", ] uas = [] - for osystem in [windows_x64, linux_x64, android_9, android_10, android_11]: - for version in ff_version: - uas.append(firefox_tmplt.format(osystem=osystem, version=version)) - for version in chrome_version: - uas.append(chrome_tmplt.format(osystem=osystem, version=version)) + for osystem in [windows_x64, linux_x64, *android]: + for version in firefox_versions: + uas.append(firefox_template.format(osystem=osystem, version=version)) + for version in chrome_versions: + uas.append(chrome_template.format(osystem=osystem, version=version)) return random.choice(uas) diff --git a/erepublik/constants.py b/erepublik/constants.py index 4893ba5..b26cbcc 100644 --- a/erepublik/constants.py +++ b/erepublik/constants.py @@ -8,7 +8,9 @@ __all__ = [ "min_datetime", "max_datetime", "Country", + "Rank", "AIR_RANKS", + "AIR_RANK_POINTS", "COUNTRIES", "FOOD_ENERGY", "GROUND_RANKS", @@ -199,6 +201,10 @@ class Rank: def as_dict(self): return dict(id=self.id, name=self.name, rank_points=self.rank_points, is_air=self.is_air) + @property + def __dict__(self): + return self.as_dict + def __str__(self): return f"{'Air' if self.is_air else 'Ground'}Rank<#{self.id} {self.name}>" diff --git a/erepublik/utils.py b/erepublik/utils.py index 58ffe73..70922e2 100644 --- a/erepublik/utils.py +++ b/erepublik/utils.py @@ -23,33 +23,33 @@ except ImportError: import json __all__ = [ + "ErepublikJSONEncoder", "VERSION", + "b64json", "calculate_hit", "date_from_eday", - "eday_from_date", "deprecation", - "get_final_hit_dmg", - "write_file", + "eday_from_date", "get_air_hit_dmg_value", "get_file", + "get_final_hit_dmg", "get_ground_hit_dmg_value", "get_sleep_seconds", "good_timedelta", - "slugify", "interactive_sleep", "json", + "json_decode_object_hook", + "json_dump", + "json_dumps", + "json_load", + "json_loads", "localize_dt", "localize_timestamp", "normalize_html_json", "now", "silent_sleep", - "json_decode_object_hook", - "json_load", - "json_loads", - "json_dump", - "json_dumps", - "b64json", - "ErepublikJSONEncoder", + "slugify", + "write_file", ] VERSION: str = __version__ diff --git a/requirements_dev.txt b/requirements_dev.txt index 0d5c612..53f7a21 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -2,20 +2,21 @@ bump2version==1.0.1 coverage==5.5 edx-sphinx-theme==3.0.0 flake8==3.9.2 -ipython>=7.25.0 +ipython>=7.26.0 jedi!=0.18.0 -isort==5.9.2 -pip==21.1.3 -pre-commit==2.13.0 +isort==5.9.3 +pip==21.2.4 +pre-commit==2.14.0 pur==5.4.2 -PyInstaller==4.4 +PyInstaller==4.5.1 PySocks==1.7.1 pytest==6.2.4 pytz==2021.1 requests==2.26.0 requests-toolbelt==0.9.1 -responses==0.13.3 +responses==0.13.4 setuptools==57.4.0 -Sphinx==4.1.1 -twine==3.4.1 -wheel==0.36.2 +Sphinx==4.1.2 +twine==3.4.2 +wheel==0.37.0 +black==21.7b0