Skip to content

Commit

Permalink
Merge aede9e3 into df17f53
Browse files Browse the repository at this point in the history
  • Loading branch information
Beakerboy committed Apr 18, 2024
2 parents df17f53 + aede9e3 commit df31f14
Show file tree
Hide file tree
Showing 15 changed files with 241 additions and 101 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python package

on:
push:
branches: [ "master" ]
pull_request:

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[tests]
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude antlr
- name: Test with pytest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pytest --cov=src
coveralls --service=github
flake8:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[tests]
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --show-source --statistics --exclude antlr
- name: Static Test with Mypy
run: |
mypy src/
29 changes: 0 additions & 29 deletions .github/workflows/test.yml

This file was deleted.

6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ pip install geojson2osm
```

## Usage
### Command Line
```python
python -m geojson2osm your_geojson_file.geojson output.osm
```

### Library
```python
import json
from geojson2osm import geojson2osm
Expand All @@ -25,4 +30,3 @@ osm_xml = geojson2osm(geojson_data)
# Save the OSM XML data to a file
with open('output.osm', 'w') as output_file:
output_file.write(osm_xml)

1 change: 0 additions & 1 deletion geojson2osm/__init__.py

This file was deleted.

38 changes: 38 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "geojson2osm"
version = "0.0.2"
authors = [
{ name="Kshitijraj Sharma", email="skshitizraj@gmail.com" },
]
description = "A Python package to convert GeoJSON data to OSM XML format."
readme = "README.md"
requires-python = ">=3.8"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]

[project.optional-dependencies]
tests = [
'mypy',
'pytest',
'pytest-cov',
'pytest-mock',
'coveralls',
'pep8-naming',
'flake8-annotations'
]
[project.urls]
"Homepage" = "https://github.com/kshitijrajsharma/geojson2osm"
"Bug Tracker" = "https://github.com/kshitijrajsharma/geojson2osm/issues"

[tool.pytest.ini_options]
pythonpath = "src:tests"
testpaths = [
"tests",
]
28 changes: 0 additions & 28 deletions setup.py

This file was deleted.

1 change: 1 addition & 0 deletions src/geojson2osm/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .geojson2osm import geojson2osm # noqa
21 changes: 21 additions & 0 deletions src/geojson2osm/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import json
import sys
from geojson2osm import geojson2osm as g2o


def main() -> None:
# Load your GeoJSON data
input = sys.argv[1]
geojson_data = json.load(open(input))

# Convert the GeoJSON data to OSM XML format
osm_xml = g2o(geojson_data)

# Save the OSM XML data to a file
output = sys.argv[2]
with open(output, 'w') as output_file:
output_file.write(osm_xml)


if __name__ == '__main__':
main()

0 comments on commit df31f14

Please sign in to comment.