{"id":15938377,"url":"https://github.com/nelson-gon/urlfix","last_synced_at":"2025-03-25T07:31:06.103Z","repository":{"id":45029778,"uuid":"336733328","full_name":"Nelson-Gon/urlfix","owner":"Nelson-Gon","description":"Check and Fix Outdated URLs","archived":false,"fork":false,"pushed_at":"2022-11-28T08:52:49.000Z","size":175,"stargazers_count":2,"open_issues_count":2,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-08T05:22:06.157Z","etag":null,"topics":["developer-tools","development","development-tools","http-requests","https","markdown","outdated-urls","pip3","pypi","python3","regex","txt","url-parsing","urllib","urlparser","urls","web"],"latest_commit_sha":null,"homepage":"https://urlfix.readthedocs.io/en/latest/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Nelson-Gon.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-07T07:58:46.000Z","updated_at":"2023-09-08T18:18:17.000Z","dependencies_parsed_at":"2023-01-21T17:34:47.322Z","dependency_job_id":null,"html_url":"https://github.com/Nelson-Gon/urlfix","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nelson-Gon%2Furlfix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nelson-Gon%2Furlfix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nelson-Gon%2Furlfix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nelson-Gon%2Furlfix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Nelson-Gon","download_url":"https://codeload.github.com/Nelson-Gon/urlfix/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222047580,"owners_count":16922197,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["developer-tools","development","development-tools","http-requests","https","markdown","outdated-urls","pip3","pypi","python3","regex","txt","url-parsing","urllib","urlparser","urls","web"],"created_at":"2024-10-07T05:22:15.432Z","updated_at":"2024-10-29T12:41:36.639Z","avatar_url":"https://github.com/Nelson-Gon.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# urlfix: Check and Fix Outdated URLs\n\n\n[![PyPI version fury.io](https://badge.fury.io/py/urlfix.svg)](https://pypi.python.org/pypi/urlfix/)\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.4515212.svg)](https://doi.org/10.5281/zenodo.4515212)\n[![Project Status](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active) \n[![Codecov](https://codecov.io/gh/Nelson-Gon/urlfix/branch/master/graph/badge.svg)](https://codecov.io/gh/Nelson-Gon/urlfix?branch=master)\n![Test-Package](https://github.com/Nelson-Gon/urlfix/workflows/Test-Package/badge.svg)\n[![PyPI license](https://img.shields.io/pypi/l/urlfix.svg)](https://pypi.python.org/pypi/urlfix/)\n[![Documentation Status](https://readthedocs.org/projects/urlfix/badge/?version=latest)](https://urlfix.readthedocs.io/en/latest/?badge=latest)\n[![Total Downloads](https://pepy.tech/badge/urlfix)](https://pepy.tech/project/urlfix)\n[![Monthly Downloads](https://pepy.tech/badge/urlfix/month)](https://pepy.tech/project/urlfix)\n[![Weekly Downloads](https://pepy.tech/badge/urlfix/week)](https://pepy.tech/project/urlfix)\n[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://GitHub.com/Nelson-Gon/urlfix/graphs/commit-activity)\n[![GitHub last commit](https://img.shields.io/github/last-commit/Nelson-Gon/urlfix.svg)](https://github.com/Nelson-Gon/urlfix/commits/master)\n[![GitHub issues](https://img.shields.io/github/issues/Nelson-Gon/urlfix.svg)](https://GitHub.com/Nelson-Gon/urlfix/issues/)\n[![GitHub issues-closed](https://img.shields.io/github/issues-closed/Nelson-Gon/urlfix.svg)](https://GitHub.com/Nelson-Gon/urlfix/issues?q=is%3Aissue+is%3Aclosed)\n\n\n\n`urlfix` aims to find all outdated URLs in a given file and fix them. \n\n\n**Features List**\n\n- [x] Commandline and programmer-friendly modes. \n\n- [x] Replace outdated URLs/links in a single file\n\n- [x] Replace outdated URLs/links in a directory\n\n- [x] Replace outdated URLs/links in the same file or in the same files in a directory i.e. inplace.\n\n- [x] Replace outdated links in files in nested directories\n- [x] Replace outdated links in files in sub-nested directories \n\n**Supported file formats**\n\n`urlfix` fixes URLs given a file of the following types:\n\n- [x] MarkDown (.md)\n- [x] Plain Text files (.txt)\n\n- [x] RMarkdown (.rmd)\n\n- [x] ReStructured Text (.rst)\n\n- [ ] PDF (.pdf)\n\n- [ ] Word (.docx)\n\n- [ ] ODF (.odf)\n\n\n\n**Installation**\n\nThe simplest way to install the latest release is as follows:\n\n```shell\npip install urlfix\n\n```\n\nTo install the development version:\n\n\nOpen the Terminal/CMD/Git bash/shell and enter\n\n```shell\n\npip install git+https://github.com/Nelson-Gon/urlfix.git\n\n# or for the less stable dev version\npip install git+https://github.com/Nelson-Gon/urlfix.git@dev\n\n```\n\nOtherwise:\n\n```shell\n# clone the repo\ngit clone git@github.com:Nelson-Gon/urlfix.git\ncd urlfix\npip install -e . \n\n```\n\n\n\n**Sample usage**\n\n**Script Mode**\n\nTo use at the commandline, please use:\n\n```shell\n\npython -m urlfix --mode \"f\" --verbose 1 --inplace 1 --inpath myfile.md\n\n```\n\nIf not replacing within the same file, then:\n\n```shell\n\npython -m urlfix --mode \"f\" --verbose 1 --inplace 0 --inpath myfile.md --output-file myoutputfile.md\n\n```\n\n\n\nTo get help:\n\n```shell\npython -m urlfix -h \n\n#usage: main.py [-h] -m MODE -in INPUT_FILE [-o OUTPUT_FILE] -v {False,false,0,True,true,1} -i {False,false,0,True,true,1}\n#\n#optional arguments:\n#  -h, --help            show this help message and exit\n#  -m MODE, --mode MODE  Mode to use. One of f for file or d for directory\n#  -in INPUT_FILE, --input-file INPUT_FILE\n#                        Input file for which link updates are required.\n#  -o OUTPUT_FILE, --output-file OUTPUT_FILE\n#                        Output file to write to. Optional, only necessary if not replacing inplace\n#  -v {False,false,0,True,true,1}, --verbose {False,false,0,True,true,1}\n#                        String to control verbosity. Defaults to True.\n#  -i {False,false,0,True,true,1}, --inplace {False,false,0,True,true,1}\n#                        Should links be replaced inplace? This should be safe but to be sure, test with an output file first.\n\n\n\n```\n\n**Programmer-Friendly Mode**\n\n```python\n\nfrom urlfix.urlfix import URLFix\nfrom urlfix.dirurlfix import DirURLFix\n\n```\n\n**Create an object of class URLFix**\n\n```python\n\nurlfix_object = URLFix(\"testfiles/testurls.txt\", output_file=\"replacement.txt\")\n\n```\n**Replacing URLs**\n\nAfter creating our object, we can replace outdated URLs as follows:\n\n```python\n\nurlfix_object.replace_urls(verbose=1)\n\n```\nThe above uses default arguments and will not replace a file inplace. This is a safety mechanism to ensure one does not\ndamage their files. \n\nSince we set `verbose` to `True`, we get the following output:\n\n```python\nurlfix_object.replace_urls()\n```\n\nTo replace silently, simply set verbose to `False` (which is the default). \n\n```python\nurlfix_object.replace_urls()\n```\n\nIf there are URLs known to be valid, pass these to the `correct_urls` argument to save some time.\n\n```python \n\nurlfix_object.replace_urls(correct_urls=[urls_here]) # Use a Sequence eg tuple, list, etc\n\n```\n\n\n**Replacing several files in a directory**\n\nTo replace several files in a directory, we can use `DirURLFix` as follows.\n\n* Instantiate an object of class `DirURLFix`\n\n```python\n\nreplace_in_dir = DirURLFix(\"path_to_dir\")\n\n```\n\n* Call `replace_urls`\n\n```python\n\nreplace_in_dir.replace_urls()\n\n```\n\n**Recursively replacing links in nested directories**\n\nTo replace outdated links in several files located in several directories, we set `recursive` to `True`.\nCurrently, replacing links in directories nested within nested directories is not (yet) supported.\n\n```python\n\nrecursive_object = DirURLFix(\"path_to_root_directory\", recursive=True)\n\n```\n\nWe can then proceed as above\n\n```python\n\nrecursive_object.replace_urls() # provide other arguments as you may wish. \n\n```\n---\n\nTo report any issues, suggestions or improvement, please do so at [issues](https://github.com/Nelson-Gon/urlfix/issues). \n\nIf you would like to cite this work, please use:\n\nNelson Gonzabato (2021) urlfix: Check and Fix Outdated URLs https://github.com/Nelson-Gon/urlfix\n\n\n**Thank you very much**. \n\n\n\u003e “Before software can be reusable it first has to be usable.” – Ralph Johnson\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnelson-gon%2Furlfix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnelson-gon%2Furlfix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnelson-gon%2Furlfix/lists"}