Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ls shell-like wildcards #302

Closed
wants to merge 15 commits into from
Closed

ls shell-like wildcards #302

wants to merge 15 commits into from

Conversation

jsuchan-reef
Copy link

@jsuchan-reef jsuchan-reef commented Aug 11, 2023

Since the task is quite big, I split it into multiple PRs per command.

Changes ls

  • Allow *, **, ? ,[] ,{} globs/patterns in b2 ls, globbing should work similarly to bash globs. Allow escaping special symbols with backslash \.

@jsuchan-reef jsuchan-reef marked this pull request as draft August 11, 2023 17:30
@jsuchan-reef jsuchan-reef changed the title B2-13: ls shell-like wildcards B2-13: shell-like wildcards Aug 11, 2023
@jsuchan-reef jsuchan-reef force-pushed the yed/B2-13 branch 2 times, most recently from 122a880 to 4de6ac7 Compare August 11, 2023 17:58
@jsuchan-reef jsuchan-reef changed the title B2-13: shell-like wildcards B2-13: ls, rm shell-like wildcards Aug 14, 2023
@jsuchan-reef jsuchan-reef marked this pull request as ready for review August 15, 2023 07:18
@jsuchan-reef jsuchan-reef changed the title B2-13: ls, rm shell-like wildcards B2-13: ls shell-like wildcards Aug 15, 2023
@jsuchan-reef jsuchan-reef changed the title B2-13: ls shell-like wildcards ls shell-like wildcards Aug 15, 2023
b2sdk/utils/wildcards.py Outdated Show resolved Hide resolved
b2sdk/utils/wildcards.py Outdated Show resolved Hide resolved
b2sdk/utils/wildcards.py Outdated Show resolved Hide resolved
b2sdk/utils/wildcards.py Outdated Show resolved Hide resolved
b2sdk/utils/wildcards.py Outdated Show resolved Hide resolved
| wcglob.NEGATE # support [!] for negation
)
wildcard_matcher = partial(
lambda file_name: wcglob.globmatch(file_name, match_pattern, flags=wc_flags, limit=100)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This limit (lowered from 1000 to 100) is hardcoded and undocumented. I'm afraid it will bite someone in the ass one day. Can we set it to a value that won't ever trigger (with the limitation of file name / object length) or expose it so that the user can increase it if they have a weird use case? Otherwise sooner or later someone will hit it, report a bug and we'll have to figure out a way to fix it then. Why did you decide to set it to a 100?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This limit (lowered from 1000 to 100) is hardcoded and undocumented

using wcmatch can be considered an implementation detail, in which case even the limit 1000 is undocumented/hardcoded.

Why did you decide to set it to a 100?

the docs had a warning there "Massive Expansion Risk" which made me think what would be a common use-case this feature might be covering - either expanding a-z, or expanding 0-99. I went with the latter one.
I dont have strong opinion about this, so I'll revert it to 1000, which sounds loose enough.

requirements.txt Outdated Show resolved Hide resolved
jsuchan-reef and others added 5 commits August 15, 2023 15:55
Co-authored-by: Paweł Polewicz <p.polewicz@gmail.com>
Co-authored-by: Paweł Polewicz <p.polewicz@gmail.com>
Co-authored-by: Paweł Polewicz <p.polewicz@gmail.com>
Co-authored-by: Paweł Polewicz <p.polewicz@gmail.com>
@mjurbanski-reef
Copy link

superseeded by other ls&rm PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants