-
Notifications
You must be signed in to change notification settings - Fork 6
Import bbayles/what-url #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
b120c62
Import bbayles/what-url
bbayles 8076e7e
Add concurrency to GHA
bbayles 4c84f39
Update setup.cfg
bbayles 37da13d
Rename from what-url to ada-url
bbayles 2e8072e
Update GHA conditions
bbayles a806b87
Add script to update the Ada single header package
bbayles 096e133
Use for compiling
bbayles c9a2385
Makefile variable for rm
bbayles 07c9a94
Add WHATWG URL class
bbayles 232afc3
Add buil instructions
bbayles 7c8d507
Example for replace_url
bbayles fffac1b
Fix typo in error message
bbayles File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: Build and test | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened, ready_for_review] | ||
paths-ignore: | ||
- '**.rst' | ||
- 'docs/**' | ||
push: | ||
branches: | ||
- main | ||
paths-ignore: | ||
- '**.rst' | ||
- 'docs/**' | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build_test: | ||
strategy: | ||
matrix: | ||
os: ["ubuntu-20.04", "macos-latest"] | ||
python: ["3.8", "3.9", "3.10", "3.11"] | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we install Ruff and test the linter as well in a different workflow? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can split the workflow into different pieces, sure. |
||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python }} | ||
- name: Install dependencies | ||
run: | | ||
make requirements | ||
- name: Static analysis | ||
if: "matrix.python == '3.8'" | ||
run: | | ||
make check | ||
- name: Build packages | ||
run: | | ||
make package | ||
- name: Repair wheels | ||
if: "matrix.os == 'ubuntu-20.04'" | ||
run: | | ||
pip install -U auditwheel patchelf | ||
auditwheel repair --plat manylinux_2_31_x86_64 --wheel-dir dist dist/ada_url-*linux*.whl | ||
- name: Run tests | ||
run: | | ||
pip install -e . | ||
make coverage | ||
- name: Build docs with sphinx | ||
if: "matrix.python == '3.8' && matrix.os == 'ubuntu-20.04'" | ||
run: | | ||
make docs | ||
- name: Upload packages | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ada-url-packages | ||
path: dist/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
*.o | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# 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/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
cover/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
.pybuilder/ | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
# For a library or package, you might want to ignore these files since the code is | ||
# intended to run in multiple environments; otherwise, check them in: | ||
# .python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# pytype static type analyzer | ||
.pytype/ | ||
|
||
# Cython debug symbols | ||
cython_debug/ | ||
|
||
# MacOS stuff | ||
.DS_Store |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
.PHONY: requirements | ||
requirements: | ||
python3 -m pip install -r requirements/development.txt | ||
|
||
.PHONY: check | ||
check: | ||
black --check . | ||
ruff . | ||
|
||
.PHONY: format | ||
format: | ||
black . | ||
|
||
.PHONY: coverage | ||
coverage: | ||
coverage run -m unittest | ||
coverage report --show-missing --fail-under 99 | ||
|
||
.PHONY: test | ||
test: | ||
python -m unittest -v ${tests} | ||
|
||
.PHONY: docs | ||
docs: | ||
sphinx-build -W -b html docs docs/_build/html | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -rf _build/ | ||
rm -rf _dist/ | ||
rm -rf ada_url.egg-info/ | ||
$(RM) ada_url/_ada_wrapper.abi3.so | ||
$(RM) ada_url/ada.o | ||
|
||
.PHONY: package | ||
package: | ||
$(CXX) -c "ada_url/ada.cpp" -fPIC -std="c++17" -O2 -o "ada_url/ada.o" | ||
python -m build --no-isolation | ||
twine check dist/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
ada-url | ||
======== | ||
|
||
This is ``ada_url``, a Python library for parsing and joining URLs. | ||
|
||
bbayles marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Examples | ||
-------- | ||
|
||
This package exposes a ``URL`` class that is intended to match the one described in the | ||
`WHATWG URL spec <https://url.spec.whatwg.org/#url-class>`__. | ||
|
||
.. code-block:: python | ||
|
||
>>> import ada_url | ||
>>> with ada_url.URL('https://example.org/path/../file.txt') as urlobj: | ||
... urlobj.host = 'example.com' | ||
... new_url = urlobj.href | ||
>>> new_url | ||
'https://example.com/file.txt' | ||
|
||
It also provides some higher level functions for parsing and manipulating URLs. | ||
|
||
.. code-block:: python | ||
|
||
>>> import ada_url | ||
>>> ada_url.check_url('https://example.org') | ||
True | ||
>>> ada_url.join_url( | ||
'https://example.org/dir/child.txt', '../parent.txt' | ||
) | ||
'https://example.org/parent.txt' | ||
>>> ada_url.normalize_url('https://example.org/dir/../parent.txt') | ||
'https://example.org/parent.txt' | ||
>>> ada_url.parse_url('https://user:[email protected]:80/api?q=1#2') | ||
{ | ||
'href': 'https://user:[email protected]:80/api?q=1#2', | ||
'username': 'user', | ||
'password': 'pass', | ||
'protocol': 'https:', | ||
'host': 'example.org:80', | ||
'port': '80', | ||
'hostname': 'example.org', | ||
'pathname': '/api', | ||
'search': '?q=1', | ||
'hash': '#2' | ||
} | ||
lemire marked this conversation as resolved.
Show resolved
Hide resolved
|
||
>>> ada_url.replace_url('http://example.org:80', protocol='https:') | ||
'https://example.org/' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from ada_url.ada_adapter import ( | ||
URL, | ||
check_url, | ||
join_url, | ||
normalize_url, | ||
parse_url, | ||
replace_url, | ||
) | ||
|
||
__all__ = [ | ||
'URL', | ||
'check_url', | ||
'join_url', | ||
'normalize_url', | ||
'parse_url', | ||
'replace_url', | ||
] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.