Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
willemarcel committed Apr 28, 2015
0 parents commit 376cc3f
Show file tree
Hide file tree
Showing 11 changed files with 839 additions and 0 deletions.
57 changes: 57 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml

# Translations
*.mo
*.pot

# Django stuff:
*.log

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# OS X
.DS_Store
675 changes: 675 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
osmdetective
============

Python package to investigate suspicious OSM changesets


License
=======

GPLv3
3 changes: 3 additions & 0 deletions osmdetective/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# osmdetective

has_legs = False
22 changes: 22 additions & 0 deletions osmdetective/chdownload.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import requests

import xml.etree.ElementTree as ET


class ChangesetDownload(object):
"""Class to Download OSM Changesets"""

def __init__(self, start, end):

self.url = 'https://api.openstreetmap.org/api/0.6/changesets/?' + \
'bbox=-73.9830625,-33.8689056,0.0,5.2842873&' + \
'time=%s,%s&closed=true' % (start, end)
self.download = requests.get(self.url)
self.xml = ET.fromstring(self.download.content)
self.changesets = [changeset.get('uid') for changeset in self.xml.getchildren()]

def get_changeset(self, changeset):
url = 'http://www.openstreetmap.org/api/0.6/changeset/%s/download' % changeset
return ET.fromstring(requests.get(url).content)


Empty file.
13 changes: 13 additions & 0 deletions osmdetective/scripts/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Skeleton of a CLI

import click

import osmdetective


@click.command('osmdetective')
@click.argument('count', type=int, metavar='N')
def cli(count):
"""Echo a value `N` number of times"""
for i in range(count):
click.echo(osmdetective.has_legs)
5 changes: 5 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[egg_info]
tag_build = dev

[upload]
dry-run = 1
34 changes: 34 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from codecs import open as codecs_open
from setuptools import setup, find_packages


# Get the long description from the relevant file
with codecs_open('README.rst', encoding='utf-8') as f:
long_description = f.read()


setup(name='osmdetective',
version='0.0.1',
description="Python package to investigate suspicious OSM changesets",
long_description=long_description,
classifiers=[],
keywords=['openstreetmap', 'osm', 'QA'],
author="Wille Marcel",
author_email='wille@wille.blog.br',
url='https://github.com/OSMBrasil/osmdetective',
license='GPLv3+',
packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
include_package_data=True,
zip_safe=False,
install_requires=[
'click',
'requests'
],
extras_require={
'test': ['pytest'],
},
entry_points="""
[console_scripts]
osmdetective=osmdetective.scripts.cli:cli
"""
)
10 changes: 10 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from click.testing import CliRunner

from osmdetective.scripts.cli import cli


def test_cli_count():
runner = CliRunner()
result = runner.invoke(cli, ['3'])
assert result.exit_code == 0
assert result.output == "False\nFalse\nFalse\n"
10 changes: 10 additions & 0 deletions tests/test_mod.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from osmdetective.chdownload import ChangesetDownload


def test_download():
d = ChangesetDownload('20150427T000000', '20150427T000400')
assert d.url == 'https://api.openstreetmap.org/api/0.6/changesets/' + \
'?bbox=-73.9830625,-33.8689056,0.0,5.2842873&' + \
'time=20150427T000000,20150427T000400&closed=true'
assert d.download.status_code == 200
assert len(d.changesets) == 26

0 comments on commit 376cc3f

Please sign in to comment.