Skip to content

Commit

Permalink
feat: add min && max version judage
Browse files Browse the repository at this point in the history
  • Loading branch information
ihandmine committed Sep 19, 2022
1 parent 27d309d commit 5d0c10a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions anti_useragent/useragent/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ def __init__(self,
):
self.settings = self._settings

self.min_version = min_version
self.max_version = max_version

if min_version:
self.min_version = min_version
assert isinstance(self.min_version, int), 'Min Version must be int'
if max_version:
self.max_version = max_version
assert isinstance(self.max_version, int), 'Max Version must be int'
if platform:
assert isinstance(platform or "", str), 'Platform must be string or NoneType'

if all([min_version, max_version]) and min_version > max_version:
raise Exception("Max Version must lg than Min Version")
assert isinstance(platform or "", str), 'Platform must be string or NoneType'

if all([platform, (platform not in self.settings.get('PLATFORM'))]):
raise TypeError('Unknown platform type: %s' % platform)
Expand Down

0 comments on commit 5d0c10a

Please sign in to comment.