Skip to content

Commit aa10e27

Browse files
committed
Create sitemap generator python package
1 parent 24f2c67 commit aa10e27

15 files changed

Lines changed: 3138 additions & 0 deletions

File tree

.dockerignore

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
sitemap/
2+
docker-compose.yml
3+
Dockerfile
4+
5+
# Byte-compiled / optimized / DLL files
6+
__pycache__/
7+
*.py[cod]
8+
*$py.class
9+
10+
# C extensions
11+
*.so
12+
13+
# Distribution / packaging
14+
.Python
15+
build/
16+
develop-eggs/
17+
dist/
18+
downloads/
19+
eggs/
20+
.eggs/
21+
lib/
22+
lib64/
23+
parts/
24+
sdist/
25+
var/
26+
wheels/
27+
pip-wheel-metadata/
28+
share/python-wheels/
29+
*.egg-info/
30+
.installed.cfg
31+
*.egg
32+
MANIFEST
33+
34+
# PyInstaller
35+
# Usually these files are written by a python script from a template
36+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
37+
*.manifest
38+
*.spec
39+
40+
# Installer logs
41+
pip-log.txt
42+
pip-delete-this-directory.txt
43+
44+
# Unit test / coverage reports
45+
htmlcov/
46+
.tox/
47+
.nox/
48+
.coverage
49+
.coverage.*
50+
.cache
51+
nosetests.xml
52+
coverage.xml
53+
*.cover
54+
*.py,cover
55+
.hypothesis/
56+
.pytest_cache/
57+
58+
# Translations
59+
*.mo
60+
*.pot
61+
62+
# Django stuff:
63+
*.log
64+
local_settings.py
65+
db.sqlite3
66+
db.sqlite3-journal
67+
68+
# Flask stuff:
69+
instance/
70+
.webassets-cache
71+
72+
# Scrapy stuff:
73+
.scrapy
74+
75+
# Sphinx documentation
76+
docs/_build/
77+
78+
# PyBuilder
79+
target/
80+
81+
# Jupyter Notebook
82+
.ipynb_checkpoints
83+
84+
# IPython
85+
profile_default/
86+
ipython_config.py
87+
88+
# pyenv
89+
.python-version
90+
91+
# pipenv
92+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
94+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
95+
# install all needed dependencies.
96+
#Pipfile.lock
97+
98+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
99+
__pypackages__/
100+
101+
# Celery stuff
102+
celerybeat-schedule
103+
celerybeat.pid
104+
105+
# SageMath parsed files
106+
*.sage.py
107+
108+
# Environments
109+
.env
110+
.venv
111+
env/
112+
venv/
113+
ENV/
114+
env.bak/
115+
venv.bak/
116+
117+
# Spyder project settings
118+
.spyderproject
119+
.spyproject
120+
121+
# Rope project settings
122+
.ropeproject
123+
124+
# mkdocs documentation
125+
/site
126+
127+
# mypy
128+
.mypy_cache/
129+
.dmypy.json
130+
dmypy.json
131+
132+
# Pyre type checker
133+
.pyre/

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ celerybeat.pid
102102
*.sage.py
103103

104104
# Environments
105+
.DS_Store
105106
.env
106107
.venv
107108
env/
@@ -127,3 +128,6 @@ dmypy.json
127128

128129
# Pyre type checker
129130
.pyre/
131+
132+
sitemap/
133+
/namespaces/

Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM python:3.9.13-slim
2+
3+
COPY . /build/
4+
WORKDIR /build
5+
6+
RUN \
7+
# Install dependencies
8+
apt-get update -y \
9+
&& apt-get upgrade -y \
10+
&& apt-get install -y git \
11+
&& git clone -b master https://github.com/internetofwater/geoconnex.us.git /geoconnex.us \
12+
# Install sitemap-generator
13+
&& pip3 install -e . \
14+
# cleanup
15+
&& apt autoremove -y \
16+
&& apt-get -q clean \
17+
&& rm -rf /var/lib/apt/lists/*
18+
19+
ENTRYPOINT [ "sitemap-generator", "run" ]
20+
CMD [ "/build/tests/data/namespaces" ]

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## Sitemap Generator
2+
3+
Generate sitemap from file system

docker-compose.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: '3.6'
2+
3+
services:
4+
sitemap-generator:
5+
container_name: sitemap-generator
6+
build:
7+
context: .
8+
volumes:
9+
- ./sitemap:/sitemap

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
click
2+
GitPython

setup.py

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# =================================================================
2+
#
3+
# Authors: Benjamin Webb <bwebb@lincolninst.edu>
4+
#
5+
# Copyright (c) 2023 Benjamin Webb
6+
#
7+
# Permission is hereby granted, free of charge, to any person
8+
# obtaining a copy of this software and associated documentation
9+
# files (the "Software"), to deal in the Software without
10+
# restriction, including without limitation the rights to use,
11+
# copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
# copies of the Software, and to permit persons to whom the
13+
# Software is furnished to do so, subject to the following
14+
# conditions:
15+
#
16+
# The above copyright notice and this permission notice shall be
17+
# included in all copies or substantial portions of the Software.
18+
#
19+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
21+
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
23+
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24+
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26+
# OTHER DEALINGS IN THE SOFTWARE.
27+
#
28+
# =================================================================
29+
30+
import io
31+
import os
32+
import re
33+
from setuptools import Command, find_packages, setup
34+
35+
36+
class PyTest(Command):
37+
user_options = []
38+
39+
def initialize_options(self):
40+
pass
41+
42+
def finalize_options(self):
43+
pass
44+
45+
def run(self):
46+
import subprocess
47+
errno = subprocess.call(['pytest'])
48+
raise SystemExit(errno)
49+
50+
51+
def read(filename, encoding='utf-8'):
52+
"""read file contents"""
53+
full_path = os.path.join(os.path.dirname(__file__), filename)
54+
with io.open(full_path, encoding=encoding) as fh:
55+
contents = fh.read().strip()
56+
return contents
57+
58+
59+
def get_package_version():
60+
"""get version from top-level package init"""
61+
version_file = read('sitemap_generator/__init__.py')
62+
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
63+
version_file, re.M)
64+
if version_match:
65+
return version_match.group(1)
66+
raise RuntimeError("Unable to find version string.")
67+
68+
69+
KEYWORDS = [
70+
'sitemap',
71+
'cgs',
72+
'internetofwater'
73+
]
74+
75+
DESCRIPTION = ('Sitemap generator provides a python interface to generate'
76+
'sitemap XML files.')
77+
78+
79+
# ensure a fresh MANIFEST file is generated
80+
if (os.path.exists('MANIFEST')):
81+
os.unlink('MANIFEST')
82+
83+
84+
setup(
85+
name='sitemap_generator',
86+
version=get_package_version(),
87+
description=DESCRIPTION.strip(),
88+
long_description=read('README.md'),
89+
long_description_content_type='text/markdown',
90+
license='MIT Software License',
91+
platforms='all',
92+
keywords=' '.join(KEYWORDS),
93+
author='Ben Webb',
94+
author_email='bwebb@lincolninst.edu',
95+
maintainer='Ben Webb',
96+
maintainer_email='bwebb@lincolninst.edu',
97+
url='https://github.com/cgs-earth/sitemap-generator',
98+
install_requires=read('requirements.txt').splitlines(),
99+
packages=find_packages(),
100+
include_package_data=True,
101+
entry_points={
102+
'console_scripts': [
103+
'sitemap-generator=sitemap_generator:cli'
104+
]
105+
},
106+
classifiers=[
107+
'Development Status :: 1 - Beta',
108+
'Environment :: Console',
109+
'Intended Audience :: Developers',
110+
'Intended Audience :: Science/Research',
111+
'License :: OSI Approved :: MIT Software License',
112+
'Operating System :: OS Independent',
113+
'Programming Language :: Python',
114+
'Topic :: Scientific/Engineering :: Atmospheric Science',
115+
'Topic :: Scientific/Engineering :: GIS',
116+
'Topic :: Scientific/Engineering :: Information Analysis'
117+
],
118+
project_urls={
119+
'Homepage': 'https://github.com/cgs-earth/sitemap-generator',
120+
'Source Code': 'https://github.com/cgs-earth/sitemap-generator',
121+
'Issue Tracker': 'https://github.com/cgs-earth/sitemap-generator/issues'
122+
},
123+
cmdclass={'test': PyTest},
124+
test_suite='tests.run_tests'
125+
)

sitemap_generator/__init__.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# =================================================================
2+
#
3+
# Authors: Benjamin Webb <bwebb@lincolninst.edu>
4+
#
5+
# Copyright (c) 2023 Benjamin Webb
6+
#
7+
# Permission is hereby granted, free of charge, to any person
8+
# obtaining a copy of this software and associated documentation
9+
# files (the "Software"), to deal in the Software without
10+
# restriction, including without limitation the rights to use,
11+
# copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
# copies of the Software, and to permit persons to whom the
13+
# Software is furnished to do so, subject to the following
14+
# conditions:
15+
#
16+
# The above copyright notice and this permission notice shall be
17+
# included in all copies or substantial portions of the Software.
18+
#
19+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
21+
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
23+
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24+
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26+
# OTHER DEALINGS IN THE SOFTWARE.
27+
#
28+
# =================================================================
29+
30+
__version__ = '0.1.0'
31+
32+
import click
33+
34+
from sitemap_generator.handler import run
35+
36+
37+
@click.group()
38+
@click.version_option(version=__version__)
39+
def cli():
40+
"""Sitemap Generator"""
41+
pass
42+
43+
44+
cli.add_command(run)

0 commit comments

Comments
 (0)