Simple URL builder
pip install buildurl
You can also install the latest version of the code directly from GitHub:
pip install git+git://github.com/MicaelJarniac/BuildURL
For more examples, see the full documentation.
from buildurl import BuildURL
# Use the `/` operator to add a string as a path to the end of the URL, like so:
url = BuildURL("https://pypi.org")
url /= "project"
url /= "buildurl"
print(url.get) # https://pypi.org/project/buildurl
# Or, using a list:
url = BuildURL("https://pypi.org")
url /= ["project", "buildurl"]
print(url.get) # https://pypi.org/project/buildurl
# Use the `+` operator to add a dict as a query:
url = BuildURL("https://example.com")
url += {"testing": "true"}
url += {"fruit": "apple"}
print(url.get) # https://example.com?testing=true&fruit=apple
# Those operations can also be done without modifying the original URL:
url = BuildURL("https://python.org")
print(url.get) # https://python.org
print((url / "doc").get) # https://python.org/doc
print(url.get) # https://python.org
# To get the final URL as a string:
url = BuildURL("https://example.com")
url.get
str(url)
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
More details can be found in CONTRIBUTING.
Micael Jarniac 💻 📖 💡 🤔 🚧 📦 📆 |