Skip to content
This repository was archived by the owner on Apr 27, 2020. It is now read-only.

Commit 9dbe41b

Browse files
committed
Merge branch 'release/0.2.0'
2 parents 30de1a9 + 9c66936 commit 9dbe41b

17 files changed

+588
-51
lines changed

.pyup.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# configure updates globally, default is all
2+
update: all # allowed [all, insecure, False]
3+
4+
# configure dependency pinning globally, default is True
5+
pin: True # allowed [True, False]
6+
7+
# set the default branch, default is the default branch on GitHub
8+
branch: develop
9+
10+
# update schedule, default is not set
11+
# the bot will visit the repo once and bundle all updates in a single PR for the given
12+
# day/week/month
13+
schedule: "every day" # allowed ["every day", "every week", "every two weeks", "every month"]
14+
15+
# configure requirement files search, default is True
16+
# the bot will search for files ending with .txt/.pip with a requirements in their file paths
17+
search: False # allowed [True, False]
18+
19+
# adding requirements files manually, default is empty
20+
requirements:
21+
- requirements.txt:
22+
- requirements_dev.txt:
23+
24+
# add a label to pull requests, default is not set
25+
# requires private repo permissions, even on public repos
26+
label_prs: requirement-update
27+
28+
# assign users to pull requests, default is not set
29+
# requires private repo permissions, even on public repos
30+
assignees:
31+
- nightexcessive
32+
33+
# configure the branch prefix the bot is using, default is pyup-
34+
branch_prefix: pyup/
35+
36+
# allow to close stale PRs, default is True
37+
close_prs: True

.travis.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
deploy:
2-
true:
3-
python: 2.7
4-
repo: nightexcessive/modemscraper
5-
tags: true
6-
distributions: sdist bdist_wheel
7-
password:
8-
secure: FOums9R8tT7ASMIz1PLfiHFWYsPqOxJ0mm4DQaD6tfIJheW3isIWxVg0s1SC+r9iGGGMvhYVkY+OPA+i+YxsQIixdetnCZ1XtUS28XZhJYTBY1HIl5KpV2j8qDfI3CHOsv4wgbMDav/3F/cZEDf6Vn6hzKmfAeBMAddDk+bBmAfCr/unybfN+JAjDEd4ixEe5LM8ppUSr62XemFGNSnOw1QHlKa2Tq8udCQf+zmgdyys8Po0QT4wb/OB5oevddF6jwuqPw8i22RQyHDU+Q8ApsjU14m9KFMAPiwBx8+Uh9dkpVk+sGYJ6epFmLQcBkAwgee5T0sn0GHVQX5BwHI8jk0TPzEBANHHGIoHdU87OZ0rwJuj/fA86t7OPFgwp1iQ0ElxRHYvAI67e15IEZujDLZgV5BOFmXASMQck5t8K4CXCTEui9puUL3Pv7U53avdlXMPkrXlJN2sENfWXUzXjhLhnEagrOuUTiZGdwYc35C4Knh4iQbvRdN85FtqZVWvnEkSC94S4G5HWcds18djpm8JtKcSketgaBalrmOOjurcbA9JUGzZhCsU4RiOsKD6hDkQ/r4eDM/p59yXavWBKKXncqLeueyGmzdWMwb+J8P9zuDZDSGkPnwiJ/T/lW3xWwtqaKw2u3COmzgtIWJJZAsrfFjyw2e9LIwpZWrFdp4=
92
provider: pypi
103
user: nightexcessive
11-
install: pip install -U tox-travis
4+
password:
5+
secure: FOums9R8tT7ASMIz1PLfiHFWYsPqOxJ0mm4DQaD6tfIJheW3isIWxVg0s1SC+r9iGGGMvhYVkY+OPA+i+YxsQIixdetnCZ1XtUS28XZhJYTBY1HIl5KpV2j8qDfI3CHOsv4wgbMDav/3F/cZEDf6Vn6hzKmfAeBMAddDk+bBmAfCr/unybfN+JAjDEd4ixEe5LM8ppUSr62XemFGNSnOw1QHlKa2Tq8udCQf+zmgdyys8Po0QT4wb/OB5oevddF6jwuqPw8i22RQyHDU+Q8ApsjU14m9KFMAPiwBx8+Uh9dkpVk+sGYJ6epFmLQcBkAwgee5T0sn0GHVQX5BwHI8jk0TPzEBANHHGIoHdU87OZ0rwJuj/fA86t7OPFgwp1iQ0ElxRHYvAI67e15IEZujDLZgV5BOFmXASMQck5t8K4CXCTEui9puUL3Pv7U53avdlXMPkrXlJN2sENfWXUzXjhLhnEagrOuUTiZGdwYc35C4Knh4iQbvRdN85FtqZVWvnEkSC94S4G5HWcds18djpm8JtKcSketgaBalrmOOjurcbA9JUGzZhCsU4RiOsKD6hDkQ/r4eDM/p59yXavWBKKXncqLeueyGmzdWMwb+J8P9zuDZDSGkPnwiJ/T/lW3xWwtqaKw2u3COmzgtIWJJZAsrfFjyw2e9LIwpZWrFdp4=
6+
distributions: sdist bdist_wheel
7+
on:
8+
tags: true
9+
10+
install: pip install -U tox-travis coveralls
1211
language: python
1312
python:
13+
- 3.6
1414
- 3.5
1515
- 3.4
1616
- 3.3
1717
- 2.7
18-
- 2.6
1918
script: tox
19+
after_success:
20+
- coveralls

HISTORY.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
History
33
=======
44

5+
0.2.0 (2017-06-30)
6+
------------------
7+
8+
* Added parser module supported by Pint
9+
* Added CI support + coverage information with Coveralls
10+
511
0.1.0 (2017-06-29)
612
------------------
713

README.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ Modem Scraper
99
.. image:: https://img.shields.io/travis/nightexcessive/modemscraper.svg
1010
:target: https://travis-ci.org/nightexcessive/modemscraper
1111

12+
.. image:: https://coveralls.io/repos/github/nightexcessive/modemscraper/badge.svg?branch=develop
13+
:target: https://coveralls.io/github/nightexcessive/modemscraper?branch=develop
14+
15+
1216
.. image:: https://readthedocs.org/projects/modemscraper/badge/?version=latest
1317
:target: https://modemscraper.readthedocs.io/en/latest/?badge=latest
1418
:alt: Documentation Status

modemscraper/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
__author__ = """Michael Johnson"""
66
__email__ = 'michael@johnson.computer'
7-
__version__ = '0.1.0'
7+
__version__ = '0.2.0'

modemscraper/parser.py

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
The parser module parses raw units from the modem's pages and converts them
5+
into machine-usable values.
6+
"""
7+
import pint
8+
9+
10+
_unit_registry = None # scope the default unit registry
11+
12+
13+
def parse(to_parse):
14+
"""
15+
parse parses unit values from Surfboard pages into a tuple.
16+
17+
Currently, parse supports:
18+
19+
* plain integers
20+
* frequencies expressed in Hz
21+
* power levels expressed in dB
22+
* power levels expressed in dBmV
23+
* symbol rates expressed in Sym/sec
24+
25+
Args:
26+
to_parse (TYPE): Description
27+
28+
Returns:
29+
tuple: A tuple containing ()
30+
31+
Raises:
32+
TypeError: if the value given is not a string.
33+
ValueError: if the value given is not known to the parser.
34+
"""
35+
36+
if not isinstance(to_parse, str):
37+
raise TypeError("input must be a string")
38+
39+
parsed = None
40+
41+
try:
42+
parsed = _unit_registry(to_parse)
43+
except pint.errors.UndefinedUnitError as err:
44+
raise ValueError(err)
45+
46+
if isinstance(parsed, int):
47+
return (parsed, 'integer')
48+
49+
if format(parsed.units) != "hertz":
50+
# we check that the unit isn't hertz because our spec calls for hertz
51+
# being returned as such
52+
parsed.ito_base_units() # convert to base units in place
53+
54+
return (parsed.magnitude, '%s' % parsed.units)
55+
56+
57+
def _get_unit_registry():
58+
# create an empty registry
59+
_unit_registry = pint.UnitRegistry(filename=None)
60+
61+
# units from Pint's own defaults
62+
_unit_registry.define("second = [time] = s = sec")
63+
_unit_registry.define("[frequency] = 1 / [time]")
64+
_unit_registry.define("hertz = 1 / second = Hz")
65+
66+
# our own units
67+
_unit_registry.define("symbol = [] = sym")
68+
_unit_registry.define("decibel = [] = dB")
69+
_unit_registry.define("dBmV = []")
70+
71+
# our prefixes
72+
_unit_registry.define("mega- = 1000000 = M-")
73+
74+
return _unit_registry
75+
76+
77+
_unit_registry = _get_unit_registry() # setup our default unit registry

requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
beautifulsoup4==4.6.0
2+
Pint==0.8.1
3+
requests==2.18.1

requirements_dev.txt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
pip==8.1.2
1+
pip==9.0.1
22
bumpversion==0.5.3
33
wheel==0.29.0
44
watchdog==0.8.3
5-
flake8==2.6.0
6-
tox==2.3.1
7-
coverage==4.1
8-
Sphinx==1.4.8
9-
cryptography==1.7
10-
PyYAML==3.11
11-
pytest==2.9.2
5+
flake8==3.3.0
6+
tox==2.7.0
7+
coverage==4.4.1
8+
Sphinx==1.6.2
9+
cryptography==1.9
10+
PyYAML==3.12
11+
pytest==3.1.2
1212
pytest-runner==2.11.1
13+
pytest-cov==2.5.1
14+
httmock==1.2.6

setup.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.1.0
2+
current_version = 0.2.0
33
commit = True
44
tag = True
55

@@ -19,4 +19,4 @@ exclude = docs
1919

2020
[aliases]
2121
test = pytest
22-
# Define setup.py command aliases here
22+

setup.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
history = history_file.read()
1313

1414
requirements = [
15-
# TODO: put package requirements here
15+
'beautifulsoup4',
16+
'Pint',
17+
'requests'
1618
]
1719

1820
setup_requirements = [
@@ -23,12 +25,13 @@
2325

2426
test_requirements = [
2527
'pytest',
26-
# TODO: put package test requirements here
28+
'pytest-cov',
29+
'httmock'
2730
]
2831

2932
setup(
3033
name='modemscraper',
31-
version='0.1.0',
34+
version='0.2.0',
3235
description="Modem scraper retrieves important information from Surfboard-like modem status pages.",
3336
long_description=readme + '\n\n' + history,
3437
author="Michael Johnson",

tests/__init__.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
11
# -*- coding: utf-8 -*-
22

33
"""Unit test package for modemscraper."""
4+
5+
import httmock
6+
import os.path
7+
8+
9+
# Mock all of the modem's pages that we use
10+
@httmock.urlmatch(netloc='192.168.100.1', path='/indexData.html')
11+
def index_page(url, request):
12+
return open(os.path.join(os.path.dirname(__file__), 'example_pages/indexData.html')).read()
13+
14+
15+
@httmock.urlmatch(netloc='192.168.100.1', path='/cmLogsData.html')
16+
def logs_page(url, request):
17+
return open(os.path.join(os.path.dirname(__file__), 'example_pages/cmLogsData.html')).read()
18+
19+
20+
@httmock.urlmatch(netloc='192.168.100.1', path='/cmSignalData.html')
21+
def signals_page(url, request):
22+
return open(os.path.join(os.path.dirname(__file__), 'example_pages/cmSignalData.html')).read()

0 commit comments

Comments
 (0)