Skip to content

Support for v1.10.0 #15

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

Merged
merged 17 commits into from
Apr 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ lib/*.egg-info
.tox
.coverage
.eggs
.mypy_cache
venv
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ matrix:
env: TOXENV=flake8
dist: xenial
sudo: true
- python: 3.7
env: TOXENV=mypy
dist: xenial
sudo: true
before_install:
- git submodule update --init
install:
Expand Down
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
all: test
.PHONY: test flake8 mypy autopep8
all: autopep8 test mypy flake8

TIMESTAMP=$(shell date +%Y%m%d-%H%M%S)

Expand All @@ -8,3 +9,12 @@ lib/woothee/dataset.py: woothee/dataset.yaml

test: lib/woothee/dataset.py
python setup.py test

flake8:
tox -eflake8

mypy:
tox -emypy

autopep8:
tox -eautopep8
5 changes: 5 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ limitations under the License.
History
-------

1.10.0(Apr 12, 2019)
~~~~~~~~~~~~~~~~~~~~

* `#15 Support for v1.10.0 <https://github.com/woothee/woothee-python/pull/15>`_

1.8.0(Jul 5, 2018)
~~~~~~~~~~~~~~~~~~~~

Expand Down
7 changes: 4 additions & 3 deletions lib/woothee/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import (division, print_function,
absolute_import, unicode_literals)
from typing import Dict

from . import dataset
from . import browser
Expand All @@ -10,8 +11,8 @@
from . import appliance
from . import misc

VERSION = (1, 8, 0)
__version__ = '1.8.0'
VERSION = (1, 10, 0)
__version__ = '1.10.0'

FILLED = {
dataset.ATTRIBUTE_NAME: dataset.VALUE_UNKNOWN,
Expand All @@ -32,7 +33,7 @@ def is_crawler(useragent):


def exec_parse(useragent):
result = {}
result = {} # type: Dict[str, str]

if not useragent or useragent == '-':
return result
Expand Down
20 changes: 20 additions & 0 deletions lib/woothee/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Stubs for woothee (Python 3)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.

from typing import Text, AnyStr, Tuple, Dict

VERSION: Tuple
FILLED: Dict[Text, Text]

def parse(useragent: AnyStr) -> Dict[AnyStr, AnyStr]: ...
def is_crawler(useragent: AnyStr) -> bool: ...
def exec_parse(useragent: AnyStr) -> Dict[AnyStr, AnyStr]: ...
def try_crawler(useragent: AnyStr, result: Dict[AnyStr, AnyStr]) -> bool: ...
def try_browser(useragent: AnyStr, result: Dict[AnyStr, AnyStr]) -> bool: ...
def try_os(useragent: AnyStr, result: Dict[AnyStr, AnyStr]) -> bool: ...
def try_mobilephone(useragent: AnyStr, result: Dict[AnyStr, AnyStr]) -> bool: ...
def try_appliance(useragent: AnyStr, result: Dict[AnyStr, AnyStr]) -> bool: ...
def try_misc(useragent: AnyStr, result: Dict[AnyStr, AnyStr]) -> bool: ...
def try_rare_cases(useragent: AnyStr, result: Dict[AnyStr, AnyStr]) -> bool: ...
def fill_result(result: Dict[AnyStr, AnyStr]) -> Dict[AnyStr, AnyStr]: ...
9 changes: 9 additions & 0 deletions lib/woothee/appliance.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Stubs for woothee.appliance (Python 3)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.

from typing import Dict, AnyStr

def challenge_playstation(ua: AnyStr, result: Dict[AnyStr, AnyStr]) -> bool: ...
def challenge_nintendo(ua: AnyStr, result: Dict[AnyStr, AnyStr]) -> bool: ...
def challenge_digitaltv(ua: AnyStr, result: Dict[AnyStr, AnyStr]) -> bool: ...
2 changes: 1 addition & 1 deletion lib/woothee/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def challenge_safari_chrome(ua, result):
version = dataset.VALUE_UNKNOWN

# Edge
obj = re.search(r'Edge\/([.0-9]+)', ua)
obj = re.search(r'(?:Edge|Edg|EdgiOS|EdgA)\/([.0-9]+)', ua)
if obj:
version = obj.group(1)
util.update_map(result, dataset.get('Edge'))
Expand Down
14 changes: 14 additions & 0 deletions lib/woothee/browser.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Stubs for woothee.browser (Python 3)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.

from typing import Dict, AnyStr

def challenge_msie(ua: AnyStr, result: Dict[AnyStr, AnyStr]) -> bool: ...
def challenge_yandexbrowser(ua: AnyStr, result: Dict[AnyStr, AnyStr]) -> bool: ...
def challenge_safari_chrome(ua: AnyStr, result: Dict[AnyStr, AnyStr]) -> bool: ...
def challenge_firefox(ua: AnyStr, result: Dict[AnyStr, AnyStr]) -> bool: ...
def challenge_opera(ua: AnyStr, result: Dict[AnyStr, AnyStr]) -> bool: ...
def challenge_webview(ua: AnyStr, result: Dict[AnyStr, AnyStr]) -> bool: ...
def challenge_sleipnir(ua: AnyStr, result: Dict[AnyStr, AnyStr]) -> bool: ...
def challenge_vivaldi(ua: AnyStr, result: Dict[AnyStr, AnyStr]) -> bool: ...
9 changes: 9 additions & 0 deletions lib/woothee/crawler.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Stubs for woothee.crawler (Python 3)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.

from typing import Dict, AnyStr

def challenge_google(ua: AnyStr, result: Dict[AnyStr, AnyStr]) -> bool: ...
def challenge_crawlers(ua: AnyStr, result: Dict[AnyStr, AnyStr]) -> bool: ...
def challenge_maybe_crawler(ua: AnyStr, result: Dict[AnyStr, AnyStr]) -> bool: ...
2 changes: 1 addition & 1 deletion lib/woothee/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@


def _init():
# GENERATED from dataset.yaml at Wed Jul 4 23:02:52 2018 by hattori
# GENERATED from dataset.yaml at Fri Apr 12 23:12:13 2019 by tell_k
obj = {'label': 'MSIE', 'name': 'Internet Explorer', 'type': 'browser'} # NOQA
obj['vendor'] = 'Microsoft'
DATASET[obj['label']] = obj
Expand Down
35 changes: 35 additions & 0 deletions lib/woothee/dataset.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Stubs for woothee.dataset (Python 3)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.

from typing import Text, List, Dict

KEY_LABEL: Text
KEY_NAME: Text
KEY_TYPE: Text
KEY_CATEGORY: Text
KEY_OS: Text
KEY_OS_VERSION: Text
KEY_VENDOR: Text
KEY_VERSION: Text
TYPE_BROWSER: Text
TYPE_OS: Text
TYPE_FULL: Text
CATEGORY_PC: Text
CATEGORY_SMARTPHONE: Text
CATEGORY_MOBILEPHONE: Text
CATEGORY_CRAWLER: Text
CATEGORY_APPLIANCE: Text
CATEGORY_MISC: Text
ATTRIBUTE_NAME: Text
ATTRIBUTE_CATEGORY: Text
ATTRIBUTE_OS: Text
ATTRIBUTE_OS_VERSION: Text
ATTRIBUTE_VENDOR: Text
ATTRIBUTE_VERSION: Text
VALUE_UNKNOWN: Text
CATEGORY_LIST: List[Text]
ATTRIBUTE_LIST: List[Text]
DATASET: Dict[Text, Text]

def get(label: Text) -> Dict[Text, Text]: ...
10 changes: 10 additions & 0 deletions lib/woothee/misc.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Stubs for woothee.misc (Python 3)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.

from typing import Dict, AnyStr

def challenge_desktoptools(ua: AnyStr, result: Dict[AnyStr, AnyStr]) -> bool: ...
def challenge_smartphone_patterns(ua: AnyStr, result: Dict[AnyStr, AnyStr]) -> bool: ...
def challenge_http_library(ua: AnyStr, result: Dict[AnyStr, AnyStr]) -> bool: ...
def challenge_maybe_rss_reader(ua: AnyStr, result: Dict[AnyStr, AnyStr]) -> bool: ...
11 changes: 11 additions & 0 deletions lib/woothee/mobilephone.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Stubs for woothee.mobilephone (Python 3)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.

from typing import Dict, AnyStr

def challenge_docomo(ua: AnyStr, result: Dict[AnyStr, AnyStr]) -> bool: ...
def challenge_au(ua: AnyStr, result: Dict[AnyStr, AnyStr]) -> bool: ...
def challenge_softbank(ua: AnyStr, result: Dict[AnyStr, AnyStr]) -> bool: ...
def challenge_willcom(ua: AnyStr, result: Dict[AnyStr, AnyStr]) -> bool: ...
def challenge_misc(ua: AnyStr, result: Dict[AnyStr, AnyStr]) -> bool: ...
2 changes: 1 addition & 1 deletion lib/woothee/os.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def challenge_linux(ua, result):
os_version = None
if 'Android' in ua:
data = dataset.get('Android')
regex = re.compile(r"Android[- ](\d+\.\d+(?:\.\d+)?)")
regex = re.compile(r"Android[- ](\d+(?:\.\d+(?:\.\d+)?)?)")
m = regex.search(ua)
if m:
os_version = m.group(1)
Expand Down
13 changes: 13 additions & 0 deletions lib/woothee/os.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Stubs for woothee.os (Python 3)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.

from typing import Dict, AnyStr

def challenge_windows(ua: AnyStr, result: Dict[AnyStr, AnyStr]) -> bool: ...
def challenge_osx(ua: AnyStr, result: Dict[AnyStr, AnyStr]) -> bool: ...
def challenge_linux(ua: AnyStr, result: Dict[AnyStr, AnyStr]) -> bool: ...
def challenge_smartphone(ua: AnyStr, result: Dict[AnyStr, AnyStr]) -> bool: ...
def challenge_mobilephone(ua: AnyStr, result: Dict[AnyStr, AnyStr]) -> bool: ...
def challenge_appliance(ua: AnyStr, result: Dict[AnyStr, AnyStr]) -> bool: ...
def challenge_misc(ua: AnyStr, result: Dict[AnyStr, AnyStr]) -> bool: ...
Empty file added lib/woothee/py.typed
Empty file.
11 changes: 11 additions & 0 deletions lib/woothee/util.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Stubs for woothee.util (Python 3)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.

from typing import Dict, AnyStr

def update_map(target: Dict[AnyStr, AnyStr], source: Dict[AnyStr, AnyStr]) -> None: ...
def update_category(target: Dict[AnyStr, AnyStr], category: AnyStr) -> None: ...
def update_version(target: Dict[AnyStr, AnyStr], version: AnyStr) -> None: ...
def update_os(target: Dict[AnyStr, AnyStr], os: AnyStr) -> None: ...
def update_os_version(target: Dict[AnyStr, AnyStr], version: AnyStr) -> None: ...
5 changes: 5 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[mypy]
python_version = 2.7
ignore_missing_imports = True
incremental = True
check_untyped_defs = True
2 changes: 1 addition & 1 deletion scripts/dataset_yaml2py.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

fp = open(dataset_file, 'rb')
try:
for datasets in yaml.load_all(fp):
for datasets in yaml.safe_load_all(fp):
for dataset in datasets:
label = dataset['label']
name = dataset['name']
Expand Down
5 changes: 5 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ strict = 1

[aliases]
release = sdist bdist_wheel
test=pytest

[tool:pytest]
addopts = -vv --cov lib/woothee --cov-report term-missing
python_files = tests/*.py
24 changes: 17 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import os
import re
import sys
from setuptools import setup, Command, find_packages


Expand All @@ -20,18 +21,24 @@
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.2",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Software Development :: Libraries :: Python Modules",
]


install_requires = ['six>=1.8.0']

if sys.version_info < (3, 5):
install_requires.append('typing')


class DatasetCommand(Command):

description = 'generate dataset.py'
Expand All @@ -51,21 +58,24 @@ def run(self):
sys.path.insert(0, scripts_dir)
import dataset_yaml2py # NOQA


setup(
name='woothee',
version=version,
description='Cross-language UserAgent classifier library, python implementation', # NOQA
description='Cross-language UserAgent classifier library, python implementation', # NOQA
author='tell-k',
author_email='ffk2005@gmail.com',
url='https://github.com/woothee/woothee-python',
license='Apache License 2.0',
packages=find_packages('lib'),
package_dir={'': 'lib'},
package_data={
'woothee': ['py.typed', '*.pyi'],
},
platforms='any',
install_requires=["six>=1.8.0"],
setup_requires=['PyYAML>=3.10', "six>=1.8.0"],
tests_require=['mock'],
test_suite='tests',
install_requires=install_requires,
setup_requires=['PyYAML>=3.10', 'six>=1.8.0', 'pytest-runner'],
tests_require=['pytest', 'pytest-cov', 'pytest-mock'],
long_description=long_description,
classifiers=classifiers,
keywords=['web', 'user-agent', 'parser'],
Expand Down
Loading