Closed Bug 1591498 Opened 4 months ago Closed 3 months ago

[python3] Solve glob_to_regex for both py2 and py3

Categories

(Webtools :: Pontoon, task)

task
Not set

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: Pike, Assigned: jotes)

References

Details

Attachments

(1 file)

The code in pontoon.base.utils.glob_to_regex is affected by the py3 move pretty badly.

$ python -c 'import fnmatch;print(fnmatch.translate("*"))'
.*\Z(?ms)
$ python3 -c 'import fnmatch;print(fnmatch.translate("*"))'
(?s:.*)\Z

I wonder if it's easier to drop fnmatch.translate and just implement wildcards from scratch?

https://github.com/mozilla/pontoon/blob/b826d82e8b835cbe20aa8839a0bdc5b899e1ab44/pontoon/base/utils.py#L670-L682

IIRC jotes had been asking about this?

Flags: needinfo?(poke)

I've asked about it on IRC a few days ago. Tags module uses glob_to_regex in some places, it makes easier to resource files.
We've decided to implement something simpler that doesn't need external dependencies.

Flags: needinfo?(poke)

Maybe some or most of the code in https://github.com/Pike/compare-locales/blob/80d52e763dc1e6a2af54473cb0307e62fd179a9f/compare_locales/paths/matcher.py#L184-L459 can help. Basically does the same thing, take some glob syntax, convert it into a sane regex.

Assignee: nobody → poke
Status: NEW → ASSIGNED
Status: ASSIGNED → RESOLVED
Closed: 3 months ago
Resolution: --- → FIXED

Searching of resources doesn't work.

Note that we've landed 2 followup patches, which made "Linked" and "Not Linked" resources show up again:
https://bugzilla.mozilla.org/show_bug.cgi?id=1595569
https://bugzilla.mozilla.org/show_bug.cgi?id=1597650

Status: RESOLVED → REOPENED
Resolution: FIXED → ---

:mathjazz
I can try to fix this if it's not urgent (I'll need a few hours).

Thanks, let's sync on IRC.

Okay, I'm closing this one because We decided to remove the support for glob patterns in search queries. The fix will be implemented in the follow-up bug.

Status: REOPENED → RESOLVED
Closed: 3 months ago3 months ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.