{"id":16546707,"url":"https://github.com/sbrugman/pathlad","last_synced_at":"2026-06-05T12:31:17.938Z","repository":{"id":65424234,"uuid":"260015204","full_name":"sbrugman/pathlad","owner":"sbrugman","description":"Your friendly Python Path Converter","archived":false,"fork":false,"pushed_at":"2020-04-29T23:36:06.000Z","size":10,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-14T13:52:35.612Z","etag":null,"topics":["code","formatter","formatting","legacy-code","linter","pathlib","python","technical-debt"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sbrugman.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-29T18:52:41.000Z","updated_at":"2023-02-08T18:01:34.000Z","dependencies_parsed_at":"2023-01-23T01:25:10.472Z","dependency_job_id":null,"html_url":"https://github.com/sbrugman/pathlad","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbrugman%2Fpathlad","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbrugman%2Fpathlad/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbrugman%2Fpathlad/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbrugman%2Fpathlad/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sbrugman","download_url":"https://codeload.github.com/sbrugman/pathlad/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241827078,"owners_count":20026599,"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":["code","formatter","formatting","legacy-code","linter","pathlib","python","technical-debt"],"created_at":"2024-10-11T19:11:25.462Z","updated_at":"2026-06-05T12:31:17.931Z","avatar_url":"https://github.com/sbrugman.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pathlad\n_Your friendly Python Path Converter_\n\nPython 3.4 introduced [Pathlib](https://docs.python.org/3/library/pathlib.html), a clean object-oriented cross-platform way of handling paths. If the examples in the docs do not convince you yet, please read these blog posts by Trey Hunner:  [Why you should be using Pathlib](https://treyhunner.com/2018/12/why-you-should-be-using-pathlib/) and [No really, pathlib is great](https://treyhunner.com/2019/01/no-really-pathlib-is-great/).\nDon't let your codebases be another one full with unnecessary path logic.\n\n## What it does\n\n1. Parses your Python code and automatically fix prehistoric file manipulations.\n\n2. Helps you kickstart with refactoring you legacy code paths. Don't expect it to do all the work for you (yet). The best part: even if it makes a mistake, you know already where to look.\n\n3. Profit.\n\n## Example\nBefore:\n```python\nimport os\n\nos.path.isdir(os.path.join(__file__, \"../test\"))\n```\n\nAfter:\n\n```python\nfrom pathlib import Path\n\n(Path(__file__) / \"..\" / \"test\").is_dir()\n```\n\nYou can find more examples in the [examples](examples/input/) directory.\n\n## Installation\n\nInstallation via pip:\n\n`pip install pathlad`\n\n## Usage\n\nCommand line interface:\n\n`pathlad [dirname]`\n\n## API Coverage\n\n- [X] [Pathlib's equivalences](https://docs.python.org/3.8/library/pathlib.html#correspondence-to-tools-in-the-os-module)\n- [X] `os.makedirs`\n- [X] `os.path.normpath`\n- [X] `os.path.realpath`\n- [X] `open`\n- [X] `os.path.getsize`\n- [X] `os.listdir`\n- [X] Nested calls\n- [ ] `glob.glob`\n- [ ] `Path.write_*`\n- [ ] `from os import method`\n\n## Advanced Usage options\n\n**Warning:** pathlad is under active development, the API might change without notice.\n\npathlad is built on top of [2to3](https://docs.python.org/3/library/2to3.html) (just like [black](https://github.com/psf/black)). For now, the options are identical.\n\n```bash\nUsage: pathlad [options] file|dir ...\n\nOptions:\n  -h, --help            show this help message and exit\n  -j PROCESSES, --processes=PROCESSES\n                        Run 2to3 concurrently\n  -x NOFIX, --nofix=NOFIX\n                        Prevent a transformation from being run\n  -v, --verbose         More verbose logging\n  --no-diffs            Don't show diffs of the refactoring\n  -w, --write           Write back modified files\n  -n, --nobackups       Don't write backups for modified files\n  -o OUTPUT_DIR, --output-dir=OUTPUT_DIR\n                        Put output files in this directory instead of\n                        overwriting the input files.  Requires -n.\n  -W, --write-unchanged-files\n                        Also write files even if no changes were required\n                        (useful with --output-dir); implies -w.\n  --add-suffix=ADD_SUFFIX\n                        Append this string to all output filenames. Requires\n                        -n if non-empty.  ex: --add-suffix='3' will generate\n                        .py3 files.\n```\n\n## Tips\n\n- `pathlad` doesn't care about formatting. For the best results, run [`isort`](https://github.com/timothycrosley/isort) and [`black`](https://github.com/psf/black/) afterwards.\n\n- `pathlib` is generally slower than `os.path`, especially when creating lots of `Path` objects. In most cases however, such as dataset creation scripts and tests, this doesn't weigh up to the value of readable, maintainable code.\n\n## Contributing\n\n\u003e However, being a programmer - I'm too lazy to spend 8 hours mindlessly performing a function, but not too lazy to spend 16 hours automating it. \n\n~ Timothy Crosley\n\nPull-requests are welcome.\n\nHelpful contributions include:\n- Extending API coverage for `os`, `glob`, `shutils`\n- More robust fixing w.r.t. spacing, optional arguments etc. \n- A method validation only (for example, a `--check-only` flag)\n- A pre-commit hook\n- Typing of some kind\n- Basically any feature you see in `black` or `isort` etc. \n- Remove unused `os`, `glob` imports (`flake8 --select F401`, `autoflake --in-place --imports=os,glob,pathlib`) \n\n## Resources\n\n- http://python3porting.com/2to3.html\n- http://python3porting.com/fixers.html\n- https://lucumr.pocoo.org/2010/2/11/porting-to-python-3-a-guide/\n- https://docs.python.org/3/library/pathlib.html#correspondence-to-tools-in-the-os-module\n- https://github.com/python/cpython/tree/3.8/Lib/lib2to3/fixes\n- https://stackoverflow.com/questions/24508357/how-to-launch-own-2to3-fixer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbrugman%2Fpathlad","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsbrugman%2Fpathlad","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbrugman%2Fpathlad/lists"}