Skip to content

Support case in-sensitive globbing #10

Open

Description

@guettli

It would be very nice if your library does support case in-sensitive globbing

Activity

  1. ankostis commented on Apr 20, 2017

    @ankostis
    Contributor

    It seems it does support both case in/sensitive matching, depending on the OS (see glob2.fnmatch.fnmatchcase().

    The problem is that it is not configurable.
    @miracle2k am I correct?

  2. ankostis commented on Apr 20, 2017

    @ankostis
    Contributor

    Actually in Windows, it converts all matches to lower-cases, which is unexpected, and would break if user-code then runs in POSIX. Should I open a separate bug for that?

  3. ankostis commented on Apr 20, 2017

    @ankostis
    Contributor

    @miracle2k is there a reason why not to use re.IGNORECASE in fnmatch() to implement chase-sensitiviness?
    That would allow to avoid os.path.normcase() (but not slash replacement), and preserve the case of the captured matches.

    Explanation why preserving the case of the matches is important

    Assume a Makefile-like tool written in python (e.g. doit).
    Scripts of such tools would rely on names formed out of glob-captured names, but these would be different depending on which OS the script has run. So the scripts are not be portable.

  4. guettli commented on Apr 20, 2017

    @guettli
    Author

    @ankostis I don't know. My use case for this issue is gone. You can create a new and close this one if you want to.

  5. miracle2k commented on Apr 25, 2017

    @miracle2k
    Owner

    I believe that the behaviour of this library with regards to case should be the same as the regular Python one. By default this should remain so.

    I am open to adding a flag for this.

    You may also be able to implement this outside of the library via a custom globber subclass.

    I am closing this since it's not actionable for me (I won't implement it myself), but a pull request is welcome.

  6. ankostis commented on Apr 25, 2017

    @ankostis
    Contributor

    I believe that the behaviour of this library with regards to case should be the same as the regular Python one.

    Returning the matched-parts of filenames is a functionality that is not present on python's 's glob and fnamtch modules, so maybe you can decide this independently.

    Anyhow, I will provide a PR with a flag for this issue, because I'm really bitten by this one.
    Thanks for your feedback.

  7. added a commit that references this issue on Apr 26, 2017
  8. ankostis commented on Apr 26, 2017

    @ankostis
    Contributor

    I noticed that all tests fail on Windows - and the reason is that the matches are not preserved, and
    that test-cases assume that os.sep char is always '/' .
    Is my observation correct?

  9. added 2 commits that reference this issue on Apr 26, 2017
  10. miracle2k commented on May 7, 2017

    @miracle2k
    Owner

    Re-opening to investigate behaviour change.

  11. ankostis commented on May 7, 2017

    @ankostis
    Contributor

    All tests was failing in Windows before the change.
    There should not be any behavior change - if it happens, it's a mistake.

  12. guettli commented on Sep 23, 2019

    @guettli
    Author

    What is the current state concerning "case in-sensitive globbing"?

  13. ankostis commented on Sep 23, 2019

    @ankostis
    Contributor

    Described in #19 (comment).

  14. gergelyk commented on Dec 29, 2023

    @gergelyk

    Oh, this is a bit misleading in the current implementation (0.7). Under Ubuntu:

    Python 3.11.6 (main, Dec 28 2023, 19:53:52) [GCC 9.4.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import glob2
    >>> glob2.glob('*.jpg', case_sensitive=True)
    ['bar.JPG', 'foo.jpg']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions