[issue9584] Allow curly brace expansion
Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com: -- nosy: +Arfrever versions: +Python 3.5 -Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Changes by Julian Berman julian+python@grayvines.com: -- nosy: +Julian ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Changes by Janus Troelsen ysang...@gmail.com: -- nosy: +ysangkok ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Changes by Serhiy Storchaka storch...@gmail.com: -- stage: patch review - ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Changes by Tim Golden m...@timgolden.me.uk: Removed file: http://bugs.python.org/file27894/0003-reworked-issue9584.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Tim Golden added the comment: Given that this isn't going to go ahead in its current form, and will need wider discussion on python-dev, I'm unassigning myself and I've removed the flawed version of the patch which I'd posted. -- assignee: tim.golden - ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
R. David Murray added the comment: Given the backward compatibility concerns, and the fact that brace expansion and wildcard expansion are conceptually separate operations, perhaps what we should have a is a glob.expand_braces (or some such name) function? (Note: I haven't looked at whether or not this would actually work as an API, I'm just throwing out an idea.) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Serhiy Storchaka added the comment: Given the backward compatibility concerns, and the fact that brace expansion and wildcard expansion are conceptually separate operations, perhaps what we should have a is a glob.expand_braces (or some such name) function? In this case it may be appropriate to place this function into shutil or string module. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Roundup Robot added the comment: New changeset dafca4714298 by Tim Golden in branch 'default': issue9584: Add {} list expansion to glob. Original patch by Mathieu Bridon http://hg.python.org/cpython/rev/dafca4714298 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Serhiy Storchaka added the comment: glob.glob('*.ac') ['configure.ac'] glob.glob('*.sub') ['config.sub'] glob.glob('*.{sub,ac}') ['config.sub'] And since these changes are backward incompatible (and moreover, now it is impossible to glob for paths that contain braces), I would prefer a keyword to switch this option (off by default) or a separate function. See man glob [1] for flag GLOB_BRACE. [1] http://linux.die.net/man/3/glob -- nosy: +serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Mathieu Bridon added the comment: glob.glob('*.{sub,ac}') ['config.sub'] I'm surprised this broke, this is one of the behaviour I thought I had implemented in my original patch. :-/ (and moreover, now it is impossible to glob for paths that contain braces) I am absolutely sure this was working in my original submission, I had even added unit tests for it: +# test some edge cases where braces must not be expanded +eq(self.glob('c{}d'), [self.norm('c{}d')]) +eq(self.glob('c{d{e,f}g'), map(self.norm, ['c{deg', 'c{dfg'])) +eq(self.glob('c{d,e}{f}g'), map(self.norm, ['cd{f}g', 'ce{f}g'])) +eq(self.glob('c{d,e}f}g'), map(self.norm, ['cdf}g', 'cef}g'])) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Tim Golden added the comment: Must have been something I did. I'll revert the commit and re-test. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Roundup Robot added the comment: New changeset ec897bb38708 by Tim Golden in branch 'default': Reversed changes from issue9584 http://hg.python.org/cpython/rev/ec897bb38708 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Serhiy Storchaka added the comment: I am absolutely sure this was working in my original submission, I had even added unit tests for it: It can't be working in any implementation. os.makedirs('a{b,c}d/e') os.listdir('a{b,c}d') ['e'] glob.glob('a{b,c}d/*') [] Was ['a{b,c}d/e'] in 3.3. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Tim Golden added the comment: Well even in the original [working] version, the scope of this change was limited to glob.glob. os.listdir doesn't currently support any form of expansion (at least not on Windows) and nor does os.makedirs. I don't see any problem in restricting this change -- and any future extensions -- to glob.glob whose purpose is precisely to return one or more files matching a, possibly wildcard, pattern. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Serhiy Storchaka added the comment: I'm talking about glob.glob(), not about os.listdir(). Bakward incompatible features should be off by default. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Tim Golden added the comment: Sorry, I misunderstood the point you were making with the os.listdir/makedirs examples. Fair point about backwards compatibility. This may make this change untenable as no-one will want a series of use_feature_xxx flags, one for each change we introduce to glob.glob. Unless we throw in every known expansion / matching right now and have a single use-extended-features flag. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Serhiy Storchaka added the comment: This may make this change untenable as no-one will want a series of use_feature_xxx flags, one for each change we introduce to glob.glob. Unless we throw in every known expansion / matching right now and have a single use-extended-features flag. This is another question. glob.glob(pattern, glob.GLOB_XXX | glob.GLOB_YYY) looks not much shorter than glob.glob(pattern, use_xxx=True, use_yyy=True). And not all features can be configured by only one bit. See os.access() and os.utime() as examples for many options. I hope that before 3.4 feature freeze we can change the interface, if needed. I also believe that this feature may not be regarded as mature without any sort of escaping (which also should be off by default for compatibility). And we need glob.escape() function for escaping arbitrary path. Since it is quite a complicated function, we need more examples in the documentation, which show different corner cases, nesting and interaction with wildcards. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Tim Golden added the comment: I've got a patch for this which applies cleanly to the 3.4 tip. I still need to sort out the Windows issues (which I don't think will be difficult; it looks like a test issue, not a code issue) -- assignee: - tim.golden ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Mathieu Bridon added the comment: I have to apologize for not following up on this patch. At first I had no time to go on pushing for it, and then (after a change of job), I completely forgot about it. :( I guess rebasing the patch on the latest tip is not that useful if you already have done it Tim, and I don't have access to a Windows box to figure out the issue in the tests. At this point is there anything else I can do to help getting it integrated? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Tim Golden added the comment: I'm planning to refactor the tests and the code very slightly. When I've got a reworked patch I'll ping it back to you to ensure it matches your intent. IIUC you're implementing comma-separated lists {abc,def} and nested braces {a{b,c}d,efg} but not ranges {a..z}. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Mathieu Bridon added the comment: IIUC you're implementing comma-separated lists {abc,def} and nested braces {a{b,c}d,efg} but not ranges {a..z}. Exactly. Although that's just because at the time I sent the patch, I didn't know about ranges in shells. So I just implemented the part of curly brace expansion that I knew of and felt would be useful. If ranges are an expected feature from shells, then it would probably be a worthwhile addition. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Tim Golden added the comment: Attached is a refactored version of Mathieu's patch which, when applied to tip, passes all tests. -- Added file: http://bugs.python.org/file27894/0003-reworked-issue9584.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Tim Golden added the comment: Something went wrong with that patch; it doesn't include all the changes to test_glob. I'll upload a newer patch later. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Tim Golden added the comment: Scratch that last comment: the patch does apply. I've tested it against Windows Ubuntu. If no one comes in with any objections I'll commit it within the next day. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Changes by A.M. Kuchling li...@amk.ca: -- versions: +Python 3.4 -Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
A.M. Kuchling added the comment: Help is still needed to debug the failing test_glob.py on Windows. I just tried this patch against 3.4trunk. The first hunk of the glob.py patch doesn't apply because 'for name in glob1(None, basename): yield name' was changed to 'yield from glob1(None, basename)'. The tests still pass w/ Ezio's suggested change to use (',' in sub). -- nosy: +akuchling ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Tim Golden m...@timgolden.me.uk added the comment: I've just rebuilt on Windows against tip. test_glob is failing: test test_glob failed -- Traceback (most recent call last): File c:\work-in-progress\python\cpython-9584\lib\test\test_glob.py, line 135, in test_glob_curly_braces os.path.join('a', 'bcd', 'efg')])) File c:\work-in-progress\python\cpython-9584\lib\test\test_glob.py, line 53, in assertSequencesEqual_noorder self.assertEqual(set(l1), set(l2)) AssertionError: Items in the first set but not the second: '@test_2788_tmp_dir\\a/bcd\\efg' '@test_2788_tmp_dir\\a/bcd\\EF' Items in the second set but not the first: '@test_2788_tmp_dir\\a\\bcd\\EF' '@test_2788_tmp_dir\\a\\bcd\\efg' -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Ezio Melotti ezio.melo...@gmail.com added the comment: +if sub.find(',') != -1: Please use the 'in' operator here. -- nosy: +ezio.melotti ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Mathieu Bridon boche...@fedoraproject.org added the comment: Is anybody still reading this? :-/ Could somebody commit the patch, reject it, or tell me what else I need to do? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Eric Smith e...@trueblade.com added the comment: Yes, we recently switched to Mercurial. See http://docs.python.org/devguide/faq.html You shouldn't need to change your patches just because of the switch from svn. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Mathieu Bridon boche...@fedoraproject.org added the comment: I removed the unused import (mostly as a simple test of mercurial, it's my first commit there). Does it mean that Python development is not being done in SVN, as the documentations state it? My patches have all been based on the SVN py3k branch, please tell me if I must base them on something else instead. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Eric Smith e...@trueblade.com added the comment: I removed the unused import (mostly as a simple test of mercurial, it's my first commit there). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Mathieu Bridon boche...@fedoraproject.org added the comment: So, now that Python 3.2 was released, here is a patch rebased on top of the py3k branch. -- Added file: http://bugs.python.org/file21001/0001-Curly-brace-expansion-in-glob.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Changes by Mathieu Bridon boche...@fedoraproject.org: Removed file: http://bugs.python.org/file20129/0001-Curly-brace-expansion-in-glob.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Mathieu Bridon boche...@fedoraproject.org added the comment: The sys module is imported in glob but never used. It's not related to this feature request but I saw it when implementing the patch, so here is a second patch removing the import. -- Added file: http://bugs.python.org/file21002/0002-Remove-unused-import.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Changes by Mathieu Bridon boche...@fedoraproject.org: Removed file: http://bugs.python.org/file19451/0001-Curly-brace-expansion-in-glob.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Mathieu Bridon boche...@fedoraproject.org added the comment: Same patch, but rebased to the current trunk so it still applies. -- Added file: http://bugs.python.org/file20128/0001-Curly-brace-expansion-in-glob.patch.old ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Mathieu Bridon boche...@fedoraproject.org added the comment: This is the right patch, sorry for all the mail spam. :-/ -- Added file: http://bugs.python.org/file20129/0001-Curly-brace-expansion-in-glob.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
R. David Murray rdmur...@bitdance.com added the comment: Thanks for the research and the updated patch. Unfortunately as a feature request this is going to have to wait for 3.3 since we missed the pre-beta window. -- versions: +Python 3.3 -Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Mathieu Bridon boche...@fedoraproject.org added the comment: Thanks for the research and the updated patch. Unfortunately as a feature request this is going to have to wait for 3.3 since we missed the pre-beta window. Ok. This is my first patch to Python, so I'm not sure what I should do to get this in. Is keeping the patch in sync with the trunk enough? Is there something else, like some more formal process to follow? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
R. David Murray rdmur...@bitdance.com added the comment: Nope, you've got it. After the final release of Python 3.2, please post to the issue to remind us about it, and someone will commit the patch. (For future Python releases we expect that the delays in our ability to commit feature patches will be much shorter, but this is the way it works right now.) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Éric Araujo mer...@netwok.org added the comment: Latest patch looks good. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Mathieu Bridon boche...@fedoraproject.org added the comment: I finally found the time to follow up on this issue, sorry for the absence of response. The thread on Python-Ideas didn't really lead to a consensus (nor did it generate a lot of discussion). Some wanted to see this in fnmatch, others in glob and others in shutils. Most thought glob was the appropriate place though, and this is also my opinion. From the Python documentation, fnmatch is a « Unix filename pattern matching » while glob is a « Unix style pathname pattern expansion ». This makes it clear to me that curly expansion has its place in glob, that would then use fnmatch to match the resulting list of expanded paths. Here is a patch against the py3k branch. The patch contains both the implementation, unit tests, and some changes to the documentation. Note that could I only run the unit tests on Linux (Fedora 14 x86_64) which is the only system I have at hand. -- title: Allow curly braces in fnmatch - Allow curly brace expansion Added file: http://bugs.python.org/file19451/0001-Curly-brace-expansion-in-glob.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9584] Allow curly brace expansion
Changes by Mathieu Bridon boche...@fedoraproject.org: Removed file: http://bugs.python.org/file18497/curly-fnmatch.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com