Skip to content

Commit 843780b

Browse files
bbaylesanonrig
authored andcommitted
Import bbayles/what-url
1 parent d3bfe96 commit 843780b

File tree

21 files changed

+22762
-0
lines changed

21 files changed

+22762
-0
lines changed

.github/workflows/build_test.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Build and test
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build_test:
7+
strategy:
8+
matrix:
9+
os: ["ubuntu-20.04", "macos-latest"]
10+
python: ["3.8", "3.9", "3.10", "3.11"]
11+
12+
runs-on: ${{ matrix.os }}
13+
14+
steps:
15+
- uses: actions/checkout@v3
16+
- name: Set up Python ${{ matrix.python }}
17+
uses: actions/setup-python@v4
18+
with:
19+
python-version: ${{ matrix.python }}
20+
- name: Install dependencies
21+
run: |
22+
make requirements
23+
- name: Static analysis
24+
if: "matrix.python == '3.8'"
25+
run: |
26+
make check
27+
- name: Build packages
28+
run: |
29+
make package
30+
- name: Repair wheels
31+
if: "matrix.os == 'ubuntu-20.04'"
32+
run: |
33+
pip install -U auditwheel patchelf
34+
auditwheel repair --plat manylinux_2_31_x86_64 --wheel-dir dist dist/what_url-*linux*.whl
35+
- name: Run tests
36+
run: |
37+
pip install -e .
38+
make coverage
39+
- name: Build docs with sphinx
40+
if: "matrix.python == '3.8' && matrix.os == 'ubuntu-20.04'"
41+
run: |
42+
make docs
43+
- name: Upload packages
44+
uses: actions/upload-artifact@v3
45+
with:
46+
name: what-url-packages
47+
path: dist/*

.gitignore

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
*.o
9+
10+
# Distribution / packaging
11+
.Python
12+
build/
13+
develop-eggs/
14+
dist/
15+
downloads/
16+
eggs/
17+
.eggs/
18+
lib/
19+
lib64/
20+
parts/
21+
sdist/
22+
var/
23+
wheels/
24+
share/python-wheels/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
MANIFEST
29+
30+
# PyInstaller
31+
# Usually these files are written by a python script from a template
32+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33+
*.manifest
34+
*.spec
35+
36+
# Installer logs
37+
pip-log.txt
38+
pip-delete-this-directory.txt
39+
40+
# Unit test / coverage reports
41+
htmlcov/
42+
.tox/
43+
.nox/
44+
.coverage
45+
.coverage.*
46+
.cache
47+
nosetests.xml
48+
coverage.xml
49+
*.cover
50+
*.py,cover
51+
.hypothesis/
52+
.pytest_cache/
53+
cover/
54+
55+
# Translations
56+
*.mo
57+
*.pot
58+
59+
# Django stuff:
60+
*.log
61+
local_settings.py
62+
db.sqlite3
63+
db.sqlite3-journal
64+
65+
# Flask stuff:
66+
instance/
67+
.webassets-cache
68+
69+
# Scrapy stuff:
70+
.scrapy
71+
72+
# Sphinx documentation
73+
docs/_build/
74+
75+
# PyBuilder
76+
.pybuilder/
77+
target/
78+
79+
# Jupyter Notebook
80+
.ipynb_checkpoints
81+
82+
# IPython
83+
profile_default/
84+
ipython_config.py
85+
86+
# pyenv
87+
# For a library or package, you might want to ignore these files since the code is
88+
# intended to run in multiple environments; otherwise, check them in:
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/
134+
135+
# pytype static type analyzer
136+
.pytype/
137+
138+
# Cython debug symbols
139+
cython_debug/
140+
141+
# MacOS stuff
142+
.DS_Store

Makefile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
.PHONY: requirements
2+
requirements:
3+
python3 -m pip install -r requirements/development.txt
4+
5+
.PHONY: check
6+
check:
7+
black --check .
8+
ruff .
9+
10+
.PHONY: format
11+
format:
12+
black .
13+
14+
.PHONY: coverage
15+
coverage:
16+
coverage run -m unittest
17+
coverage report --show-missing --fail-under 99
18+
19+
.PHONY: test
20+
test:
21+
python -m unittest -v ${tests}
22+
23+
.PHONY: docs
24+
docs:
25+
sphinx-build -W -b html docs docs/_build/html
26+
27+
.PHONY: clean
28+
clean:
29+
rm -rf _build/
30+
rm -rf _dist/
31+
rm -rf what_url.egg-info/
32+
rm -f what_url/_ada_wrapper.abi3.so
33+
rm -f what_url/ada.o
34+
35+
.PHONY: package
36+
package:
37+
c++ -c "what_url/ada.cpp" -fPIC -std="c++17" -O2 -o "what_url/ada.o"
38+
python -m build --no-isolation
39+
twine check dist/*

README.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
what-url
2+
========
3+
4+
This is ``what_url``, a Python library for parsing and joining URLs.
5+
6+
Examples
7+
--------
8+
9+
.. code-block:: python
10+
11+
>>> import what_url
12+
>>> what_url.check_url('https://example.org')
13+
True
14+
>>> what_url.join_url(
15+
'https://example.org/dir/child.txt', '../parent.txt'
16+
)
17+
'https://example.org/parent.txt'
18+
>>> what_url.normalize_url('https://example.org/dir/../parent.txt')
19+
'https://example.org/parent.txt'
20+
>>> what_url.parse_url('https://user:pass@example.org:80/api?q=1#2')
21+
{
22+
'href': 'https://user:pass@example.org:80/api?q=1#2',
23+
'username': 'user',
24+
'password': 'pass',
25+
'protocol': 'https:',
26+
'host': 'example.org:80',
27+
'port': '80',
28+
'hostname': 'example.org',
29+
'pathname': '/api',
30+
'search': '?q=1',
31+
'hash': '#2'
32+
}

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/conf.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import os
2+
import shutil
3+
import sys
4+
5+
# Put the project package on the path
6+
parent_dir = os.path.abspath('..')
7+
sys.path.insert(0, parent_dir)
8+
9+
# Copy README.rst so it can be included in index.rst
10+
build_dir = '_build'
11+
os.makedirs(build_dir, exist_ok=True)
12+
13+
readme_src = os.path.join(parent_dir, 'README.rst')
14+
readme_dst = os.path.join(build_dir, 'README.pprst')
15+
shutil.copyfile(readme_src, readme_dst)
16+
17+
project = 'bbayles/what-url'
18+
copyright = '2023, Bo Bayles'
19+
author = 'Bo Bayles'
20+
21+
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode']
22+
autodoc_member_order = 'bysource'
23+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']

docs/index.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.. include:: ./_build/README.pprst
2+
3+
API Documentation
4+
=================
5+
6+
.. automodule:: what_url
7+
:members:
8+
9+
10+
Indices and tables
11+
==================
12+
13+
* :ref:`genindex`
14+
* :ref:`modindex`
15+
* :ref:`search`

docs/make.bat

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=.
11+
set BUILDDIR=_build
12+
13+
%SPHINXBUILD% >NUL 2>NUL
14+
if errorlevel 9009 (
15+
echo.
16+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17+
echo.installed, then set the SPHINXBUILD environment variable to point
18+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
19+
echo.may add the Sphinx directory to PATH.
20+
echo.
21+
echo.If you don't have Sphinx installed, grab it from
22+
echo.https://www.sphinx-doc.org/
23+
exit /b 1
24+
)
25+
26+
if "%1" == "" goto help
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

pyproject.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[build-system]
2+
requires = ["cffi", "setuptools", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[tool.black]
6+
line-length = 88
7+
target-version = ['py38']
8+
skip-string-normalization = true
9+
10+
[tool.ruff]
11+
select = ["E", "F"]
12+
line-length = 88
13+
target-version = "py38"
14+
exclude = [
15+
".git",
16+
".ruff_cache",
17+
]

requirements/base.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# What we want
2+
cffi==1.15.1
3+
4+
# What we need
5+
pycparser==2.21

0 commit comments

Comments
 (0)