Add convenience methods to PlatformDirsAPI that allow iterating over both user and site dirs/paths.#258
Conversation
- `iter_config_dirs()` - `iter_config_paths()` - `iter_data_dirs()` - `iter_data_paths()` - `iter_cache_dirs()` - `iter_cache_paths()` - `iter_runtime_dirs()` - `iter_runtime_paths()` Signed-off-by: Spaceship Operations <spaceshipoperations@gmail.com>
for more information, see https://pre-commit.ci
Making it easier for applications to find their configuration files To be honest the only important method to me is
The methods are simple; it takes literally a couple minutes to write them and submit a PR, so it's easier to show them first and discuss them afterwards than to discuss them before. Of course, you are free to accept or reject them. Also, I can rename the methods if you don't like their name, or do any other modifications.
I added an entry in
Sure, I can write them if you say you will accept the PR. |
Signed-off-by: Spaceship Operations <spaceshipoperations@gmail.com>
|
Also, the initial implementation I submitted is rudimentary. If you are okay with the idea, I will also override the Unix variants of Ideally Would it be more suitable to keep the Unix override to a second PR, so that we're doing one thing at a time? |
|
I'm ok with the idea. |
Signed-off-by: Spaceship Operations <spaceshipoperations@gmail.com>
This rids platform-specific classes of the need to reimplement the former if they override the latter. Signed-off-by: Spaceship Operations <spaceshipoperations@gmail.com>
This involves minor restructuring in the `Unix` class.
A couple private helpers which contain common code for obtaining
a list of config/data dirs were added, and now all of the
`{user,site,iter}_{config,data}_*` methods internally use them.
Consequently the private helper `_with_multi_path` became
unnecessary, and was therefore removed.
Signed-off-by: Spaceship Operations <spaceshipoperations@gmail.com>
Signed-off-by: Spaceship Operations <spaceshipoperations@gmail.com>
Ruff complains about strings with `:yield:` directives not ending in a period. Added ignores for them in `pyproject.toml`. Signed-off-by: Spaceship Operations <spaceshipoperations@gmail.com>
Signed-off-by: Spaceship Operations <spaceshipoperations@gmail.com>
Signed-off-by: Spaceship Operations <spaceshipoperations@gmail.com>
|
Great to know! I implemented the Unix overrides. The commit contains a summary of the change:
Are you okay with this? It does make things easier. I have yet to add tests, but the existing coverage tests are 100% passing, although One of them is due to Ruff not recognizing the The second one is about "useless assignment before return". For the time being, I reformatted the offending lines, though that resulted in a long line due to having to satisfy the pre-commit hook. Would you prefer if I reverted to the old more readable "assignment then return" and silenced Ruff's warnings about it? I also added ignores in |
Signed-off-by: Spaceship Operations <spaceshipoperations@gmail.com>
a802cbb to
1990159
Compare
[](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [platformdirs](https://togithub.com/platformdirs/platformdirs) | `==4.1.0` -> `==4.2.1` | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- > [!WARNING] > Some dependencies could not be looked up. Check the Dependency Dashboard for more information. --- ### Release Notes <details> <summary>platformdirs/platformdirs (platformdirs)</summary> ### [`v4.2.1`](https://togithub.com/platformdirs/platformdirs/releases/tag/4.2.1) [Compare Source](https://togithub.com/platformdirs/platformdirs/compare/4.2.0...4.2.1) <!-- Release notes generated using configuration in .github/release.yml at main --> #### What's Changed - Switch to ruff for formatting and use codespell and docformatter by [@​gaborbernat](https://togithub.com/gaborbernat) in [https://github.com/platformdirs/platformdirs/pull/261](https://togithub.com/platformdirs/platformdirs/pull/261) - Use hatch over tox by [@​gaborbernat](https://togithub.com/gaborbernat) in [https://github.com/platformdirs/platformdirs/pull/262](https://togithub.com/platformdirs/platformdirs/pull/262) - chore: various minor fixes by [@​deronnax](https://togithub.com/deronnax) in [https://github.com/platformdirs/platformdirs/pull/263](https://togithub.com/platformdirs/platformdirs/pull/263) - chore: update dead Microsoft's known folders documentation link by [@​deronnax](https://togithub.com/deronnax) in [https://github.com/platformdirs/platformdirs/pull/267](https://togithub.com/platformdirs/platformdirs/pull/267) - Allow working without ctypes by [@​youknowone](https://togithub.com/youknowone) in [https://github.com/platformdirs/platformdirs/pull/275](https://togithub.com/platformdirs/platformdirs/pull/275) #### New Contributors - [@​deronnax](https://togithub.com/deronnax) made their first contribution in [https://github.com/platformdirs/platformdirs/pull/263](https://togithub.com/platformdirs/platformdirs/pull/263) - [@​youknowone](https://togithub.com/youknowone) made their first contribution in [https://github.com/platformdirs/platformdirs/pull/275](https://togithub.com/platformdirs/platformdirs/pull/275) **Full Changelog**: tox-dev/platformdirs@4.2.0...4.2.1 ### [`v4.2.0`](https://togithub.com/platformdirs/platformdirs/releases/tag/4.2.0) [Compare Source](https://togithub.com/platformdirs/platformdirs/compare/4.1.0...4.2.0) <!-- Release notes generated using configuration in .github/release.yml at main --> #### What's Changed - Fix 2 typos about XDG_DATA_DIR by [@​Freed-Wu](https://togithub.com/Freed-Wu) in [https://github.com/platformdirs/platformdirs/pull/256](https://togithub.com/platformdirs/platformdirs/pull/256) - Add convenience methods to `PlatformDirsAPI` that allow iterating over both user and site dirs/paths. by [@​SpaceshipOperations](https://togithub.com/SpaceshipOperations) in [https://github.com/platformdirs/platformdirs/pull/258](https://togithub.com/platformdirs/platformdirs/pull/258) #### New Contributors - [@​SpaceshipOperations](https://togithub.com/SpaceshipOperations) made their first contribution in [https://github.com/platformdirs/platformdirs/pull/258](https://togithub.com/platformdirs/platformdirs/pull/258) **Full Changelog**: tox-dev/platformdirs@4.1.0...4.2.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/googleapis/sdk-platform-java). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zMDEuNCIsInVwZGF0ZWRJblZlciI6IjM3LjMxMy4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119--> Co-authored-by: Alice <65933803+alicejli@users.noreply.github.com>
[](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [platformdirs](https://togithub.com/platformdirs/platformdirs) | `==4.1.0` -> `==4.2.1` | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- > [!WARNING] > Some dependencies could not be looked up. Check the Dependency Dashboard for more information. --- ### Release Notes <details> <summary>platformdirs/platformdirs (platformdirs)</summary> ### [`v4.2.1`](https://togithub.com/platformdirs/platformdirs/releases/tag/4.2.1) [Compare Source](https://togithub.com/platformdirs/platformdirs/compare/4.2.0...4.2.1) <!-- Release notes generated using configuration in .github/release.yml at main --> #### What's Changed - Switch to ruff for formatting and use codespell and docformatter by [@​gaborbernat](https://togithub.com/gaborbernat) in [https://github.com/platformdirs/platformdirs/pull/261](https://togithub.com/platformdirs/platformdirs/pull/261) - Use hatch over tox by [@​gaborbernat](https://togithub.com/gaborbernat) in [https://github.com/platformdirs/platformdirs/pull/262](https://togithub.com/platformdirs/platformdirs/pull/262) - chore: various minor fixes by [@​deronnax](https://togithub.com/deronnax) in [https://github.com/platformdirs/platformdirs/pull/263](https://togithub.com/platformdirs/platformdirs/pull/263) - chore: update dead Microsoft's known folders documentation link by [@​deronnax](https://togithub.com/deronnax) in [https://github.com/platformdirs/platformdirs/pull/267](https://togithub.com/platformdirs/platformdirs/pull/267) - Allow working without ctypes by [@​youknowone](https://togithub.com/youknowone) in [https://github.com/platformdirs/platformdirs/pull/275](https://togithub.com/platformdirs/platformdirs/pull/275) #### New Contributors - [@​deronnax](https://togithub.com/deronnax) made their first contribution in [https://github.com/platformdirs/platformdirs/pull/263](https://togithub.com/platformdirs/platformdirs/pull/263) - [@​youknowone](https://togithub.com/youknowone) made their first contribution in [https://github.com/platformdirs/platformdirs/pull/275](https://togithub.com/platformdirs/platformdirs/pull/275) **Full Changelog**: tox-dev/platformdirs@4.2.0...4.2.1 ### [`v4.2.0`](https://togithub.com/platformdirs/platformdirs/releases/tag/4.2.0) [Compare Source](https://togithub.com/platformdirs/platformdirs/compare/4.1.0...4.2.0) <!-- Release notes generated using configuration in .github/release.yml at main --> #### What's Changed - Fix 2 typos about XDG_DATA_DIR by [@​Freed-Wu](https://togithub.com/Freed-Wu) in [https://github.com/platformdirs/platformdirs/pull/256](https://togithub.com/platformdirs/platformdirs/pull/256) - Add convenience methods to `PlatformDirsAPI` that allow iterating over both user and site dirs/paths. by [@​SpaceshipOperations](https://togithub.com/SpaceshipOperations) in [https://github.com/platformdirs/platformdirs/pull/258](https://togithub.com/platformdirs/platformdirs/pull/258) #### New Contributors - [@​SpaceshipOperations](https://togithub.com/SpaceshipOperations) made their first contribution in [https://github.com/platformdirs/platformdirs/pull/258](https://togithub.com/platformdirs/platformdirs/pull/258) **Full Changelog**: tox-dev/platformdirs@4.1.0...4.2.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/googleapis/sdk-platform-java). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zMDEuNCIsInVwZGF0ZWRJblZlciI6IjM3LjMxMy4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119--> Co-authored-by: Alice <65933803+alicejli@users.noreply.github.com>


Signed-off-by: Spaceship Operations spaceshipoperations@gmail.com