Check and Fix Outdated URLs
Project description
urlfix: Check and Fix Outdated URLs
urlfix
aims to find all outdated URLs in a given file and fix them.
Supported file formats
urlfix
fixes URLs given a file of the following types:
- MarkDown (.md)
- Plain Text files (.txt)
Installation
The simplest way to install the latest release is as follows:
pip install urlfix
To install the development version:
Open the Terminal/CMD/Git bash/shell and enter
pip install git+https://github.com/Nelson-Gon/urlfix.git
# or for the less stable dev version
pip install git+https://github.com/Nelson-Gon/urlfix.git@dev
Otherwise:
# clone the repo
git clone git@github.com:Nelson-Gon/urlfix.git
cd urlfix
python3 setup.py install
Sample usage
from urlfix import urlfix
Create an object of class URLFix
urlfix_object = URLFix("testurls.txt", output_file="replacement.txt", input_format="txt")
Replacing URLs
After creating our object, we can replace outdated URLs as follows:
urlfix_object.replace_urls(verbose=1)
The above uses default arguments and will not replace a file inplace. This is a safety mechanism to ensure one does not damage their files.
Since we set verbose
to True
, we get the following output:
urlfix_object.replace_urls()
https://cran.r-project.org/package=manymodelr replaced with https://cran.r-project.org/web/packages/manymodelr/index.html in replacement.txt
https://tidyverse.org/lifecycle/#maturing replaced with https://lifecycle.r-lib.org/articles/stages.html in replacement.txt
2 URLs have changed
2
To replace silently, simply set verbose to False
(which is the default).
urlfix_object.replace_urls()
2 URLs have changed
2
Inplace Replacement
If you are confident enough, you can set inplace
to True
in replace_urls
to replace links inplace.
urlfix_object.replace_urls(inplace=True)
To report any issues, suggestions or improvement, please do so at issues.
If you would like to cite this work, please use:
Nelson Gonzabato (2021) urlfix: Check and Fix Outdated URLs https://github.com/Nelson-Gon/urlfix
Thank you very much.
“Before software can be reusable it first has to be usable.” – Ralph Johnson
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.