Skip to content

Commit 61d3804

Browse files
committed
src/ layout, functionalize for better testing and reuse
1 parent 7abee9a commit 61d3804

File tree

21 files changed

+189
-188
lines changed

21 files changed

+189
-188
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,26 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v2
14-
- uses: actions/setup-python@v1
14+
- uses: actions/setup-python@v2
1515
with:
1616
python-version: '3.x'
17+
1718
- run: pip install .[tests,lint]
19+
1820
- run: flake8
19-
- run: mypy .
21+
- run: mypy . src
22+
2023
- run: pytest
21-
working-directory: tests
24+
2225

2326
windows:
2427
runs-on: windows-latest
2528
steps:
2629
- uses: actions/checkout@v2
27-
- uses: actions/setup-python@v1
30+
- uses: actions/setup-python@v2
2831
with:
2932
python-version: '3.x'
33+
3034
- run: pip install .[tests]
35+
3136
- run: pytest
32-
working-directory: tests

mypy.ini renamed to .mypy.ini

File renamed without changes.

csv2kml.py

Lines changed: 0 additions & 17 deletions
This file was deleted.

mozloc/base.py

Lines changed: 0 additions & 35 deletions
This file was deleted.

mozloc/config.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ requires = ["setuptools", "wheel"]
33

44
[tool.black]
55
line-length = 132
6+
7+
[tool.pytest.ini_options]
8+
addopts = "-ra -v"

pytest.ini

Lines changed: 0 additions & 2 deletions
This file was deleted.

setup.cfg

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = mozloc
3-
version = 1.0.0
3+
version = 1.1.0
44
author = Michael Hirsch, Ph.D.
55
author_email = scivision@users.noreply.github.com
66
url = https://github.com/scivision/mozilla-location-wifi
@@ -9,13 +9,12 @@ keywords =
99
wifi
1010
geolocation
1111
classifiers =
12-
Development Status :: 4 - Beta
12+
Development Status :: 5 - Production/Stable
1313
Environment :: Console
1414
Intended Audience :: Information Technology
1515
Intended Audience :: System Administrators
1616
Operating System :: POSIX :: Linux
1717
Operating System :: Microsoft :: Windows
18-
Programming Language :: Python :: 3.6
1918
Programming Language :: Python :: 3.7
2019
Programming Language :: Python :: 3.8
2120
Programming Language :: Python :: 3.9
@@ -27,14 +26,16 @@ long_description = file: README.md
2726
long_description_content_type = text/markdown
2827

2928
[options]
30-
python_requires = >= 3.6
29+
python_requires = >= 3.7
3130
packages = find:
32-
scripts =
33-
csv2kml.py
34-
MozLoc.py
3531
install_requires =
3632
pandas
3733
requests
34+
package_dir=
35+
=src
36+
37+
[options.packages.find]
38+
where=src
3839

3940
[options.extras_require]
4041
tests =
@@ -47,4 +48,5 @@ io =
4748

4849
[options.entry_points]
4950
console_scripts =
50-
MozLoc = MozLoc:main
51+
MozLoc = mozloc.__main__:mozilla_location
52+
mozloc_csv2kml = mozloc.__main__:csv2kml
File renamed without changes.

MozLoc.py renamed to src/mozloc/__main__.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
88
Don't abuse the API or you'll get banned (excessive polling rate)
99
"""
10-
from mozloc import log_wifi_loc
10+
from .base import log_wifi_loc
1111
from argparse import ArgumentParser
1212

1313

14-
def main():
14+
def mozilla_location():
1515
"""
1616
output: lat lon [deg] accuracy [m]
1717
"""
@@ -20,10 +20,23 @@ def main():
2020
p.add_argument(
2121
"-T", "--cadence", help="how often to ping [sec]. Some laptops cannot go faster than 30 sec.", default=60, type=float
2222
)
23+
p.add_argument(
24+
"-url",
25+
help="Mozilla location services URL--don't use this default test key",
26+
default="https://location.services.mozilla.com/v1/geolocate?key=test",
27+
)
2328
p = p.parse_args()
2429

25-
log_wifi_loc(p.cadence, p.logfile)
30+
log_wifi_loc(p.cadence, p.url, p.logfile)
31+
2632

33+
def csv2kml():
34+
"""convert logged positions to KML"""
35+
from .utils import csv2kml
36+
37+
p = ArgumentParser()
38+
p.add_argument("logfn", help="csv logfile to read")
39+
p.add_argument("kmlfn", help="kml filename to write")
40+
p = p.parse_args()
2741

28-
if __name__ == "__main__":
29-
main()
42+
csv2kml(p.logfn, p.kmlfn)

0 commit comments

Comments
 (0)