[issue1738] filecmp.dircmp does exact match only
Nikolaus Rath added the comment: I don't think that we can just introduce path normalization in phase0. Even though I agree that this would be the proper way to do it when reimplementing from scratch, it breaks backward compatibility. There also is a small mistake in that the *match* attribute should also be used for subdirectories in the `phase4` method. Other than that, this patch looks good to me. I fixed the above issues, rebased on current hg tip, and added some missing markup in the documentation. After inspecting the code, it seems that there is no difference between directory entries being hidden by the *hide* parameter, and being ignored* by the *ignore* parameter, so I also updated the documentation make this less confusing. I could not reproduce the test failure reported by Mark, but this is most likely because I could not find out on what base revision to apply his patch. I think this is ready for commit. -- nosy: +nikratio Added file: http://bugs.python.org/file3/issue1738.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1738 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1738] filecmp.dircmp does exact match only
Changes by Mark Lawrence breamore...@yahoo.co.uk: -- nosy: -BreamoreBoy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1738 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1738] filecmp.dircmp does exact match only
Mark Lawrence breamore...@yahoo.co.uk added the comment: Patch worked fine with 2.7. I reworked it for SVN trunk but got this failure. FAILED (failures=1) Traceback (most recent call last): File test_filecmp.py, line 179, in module test_main() File test_filecmp.py, line 176, in test_main support.run_unittest(FileCompareTestCase, DirCompareTestCase) File c:\py3k\lib\test\support.py, line 1128, in run_unittest _run_suite(suite) File c:\py3k\lib\test\support.py, line , in _run_suite raise TestFailed(err) test.support.TestFailed: Traceback (most recent call last): File test_filecmp.py, line 158, in test_dircmp_fnmatch self.assertEqual(d.left_list, ['file']) AssertionError: Lists differ: ['dir-ignore', 'file', 'file.t... != ['file'] First differing element 0: dir-ignore file First list contains 2 additional elements. First extra element 1: file - ['dir-ignore', 'file', 'file.tmp'] + ['file'] I've attached a py3k patch as a different pair of eyes is more likely to spot a problem. -- nosy: +BreamoreBoy Added file: http://bugs.python.org/file18930/issue1738py3k.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1738 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1738] filecmp.dircmp does exact match only
Changes by Alexander Belopolsky belopol...@users.sourceforge.net: -- assignee: belopolsky - ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1738 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1738] filecmp.dircmp does exact match only
Changes by Terry J. Reedy tjre...@udel.edu: -- versions: +Python 2.7, Python 3.1, Python 3.2 -Python 2.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1738 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1738] filecmp.dircmp does exact match only
Changes by Terry J. Reedy tjre...@udel.edu: -- versions: -Python 2.6, Python 2.7, Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1738 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1738] filecmp.dircmp does exact match only
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: The patch does not apply to py3k branch. -- assignee: - belopolsky stage: - needs patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1738 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1738] filecmp.dircmp does exact match only
Michael Amrhein [EMAIL PROTECTED] added the comment: Here's a 2nd revised patch, which * adds a keyword 'match' to the constructor of class 'dircmp' * defaults 'match' to str.__eq__ * modifies method 'phase0': apply os.name.normcase to each name in ignore and hide * modifies the docs accordingly, incl. an example for using pattern matching * modifies the test case for the default matching * adds a test case for using pattern matching (fnmatch.fnmatch) Added file: http://bugs.python.org/file10078/add_match_func.patch __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1738 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1738] filecmp.dircmp does exact match only
Michael Amrhein [EMAIL PROTECTED] added the comment: There is one small issue I would like to discuss: While the comparison of directory and file names in phase1 is case-insensitive on case-insensitive systems (os.path.normcase applied to each name), the filtering of ignore and hide in phase0 isn't. I can't imagine a good reason for this and would like to change it by also applying os.name.normcase to each name in ignore and hide. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1738 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1738] filecmp.dircmp does exact match only
Michael Amrhein [EMAIL PROTECTED] added the comment: Alexander Belopolsky [EMAIL PROTECTED] added the comment: ... '*' is a perfectly legal filename character on most filesystems Oops! Never thought of putting a '*' into a file name. Obviously, I should have tried before ... Ok, then I agree that, for not breaking existing code, the match function should default to string comparison. I'll provide a second revised patch in the next days. And, I'll chain ignore and hide, as you proposed. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1738 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1738] filecmp.dircmp does exact match only
Michael Amrhein [EMAIL PROTECTED] added the comment: I've implemented an enhanced version of this feature by adding a keyword 'match' to the constructor of class 'dircmp'. It defaults to function 'fnmatch' imported from module 'fnmatch'. This allows to exclude directories and/or files by using patterns like '*.tmp'. By giving a different function it's also possible to use more elaborated patterns, for example, based on regular expressions. Attached patch includes updates of documentation and test cases. -- nosy: +mamrhein versions: +Python 2.6 Added file: http://bugs.python.org/file10005/wildcard.patch __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1738 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1738] filecmp.dircmp does exact match only
Alexander Belopolsky [EMAIL PROTECTED] added the comment: +1 on adding the match argument. Can you comment on how one would implement the old behavior? I would guess match=lambda x,y: x in y, which is not that bad, but maybe that should be the default and those who need pattern matching should use match=fnmatch. On the patch itself, please don't change default arguments from None to lists or function. There is a subtle difference between the two forms. For example, in your code if someone overrides filecmp.fnmatch before calling dircmp, old fnmatch will still be used. If you do match=None in finction declaration and match is None check in the function body, then the new overridden value will be used in the above scenario. -- nosy: +belopolsky __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1738 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1738] filecmp.dircmp does exact match only
Michael Amrhein [EMAIL PROTECTED] added the comment: Ok, I've set default arguments (back) to None. Revised patch attached. Defaulting the match function to fnmatch doesn't change the behavior in the normal case, i.e. when regular file / directory names are used, like in the default value of ignore. It behaves different in two cases: a) A string given in ignore contains wildcard character(s): In this case this parameter would have no effect in the previous implementation, because the string would not match any file / directory name exactly. In the changed implementation all files / directories matching the pattern would be ignored. If the wildcard(s) were included by intent, this is what probably was intended; if they were included by mistake, both version do not behave as intended. b) File system is case-insensitive: In this case the changed implementation will ignore files / directories which the previous version did not ignore because of a case mismatch. But, on such a file system this is what one would normally expect, I think. So, in both cases, I feel the changed behavior is acceptable. Or did I miss something? Added file: http://bugs.python.org/file10008/add_match_func.patch __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1738 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1738] filecmp.dircmp does exact match only
Alexander Belopolsky [EMAIL PROTECTED] added the comment: As you are working on this, please consider changing self.hide+self.ignore in phase0 to chain(self.hide, self.ignore) where chain should be imported from itertools. There is no need to create the combined list (twice!) and not accepting arbitrary iterables for hide and ignore seems to be against the zen of python. __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1738 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1738] filecmp.dircmp does exact match only
Sean Reifschneider [EMAIL PROTECTED] added the comment: Please also include at least documentation changes, since this changes the behavior of the module. This would be in the file: Doc/library/filecmp.rst Also. If possible a test would be great. The file for this would be: ./Lib/test/test_filecmp.py -- keywords: +patch nosy: +jafo priority: - normal __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1738 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1738] filecmp.dircmp does exact match only
Virgil Dupras added the comment: The documentation doesn't say anything about dircmp being supposed to support pattern matching. This ticket is a feature request rather than a bug. -- components: +Library (Lib) -None nosy: +vdupras type: behavior - feature request __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1738 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1738] filecmp.dircmp does exact match only
Changes by Georg Brandl: Removed file: http://bugs.python.org/file9067/filecmp.py.patch __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1738 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1738] filecmp.dircmp does exact match only
New submission from Oliver Nelson: dircmp's ignore and hide list only take exact files to ignore, not unix filename pattern's. This means you can't hide/ignore *.bak or something similar. Changing the _filter function adds this: def newfilter(flist, skip): for pattern in skip: flist = list(ifilterfalse(fnmatch.filter(flist, pattern).__contains__, flist)) return flist __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1738 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1738] filecmp.dircmp does exact match only
Changes by Oliver Nelson: -- components: None nosy: flxkid severity: normal status: open title: filecmp.dircmp does exact match only type: behavior versions: Python 2.5 __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1738 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1738] filecmp.dircmp does exact match only
Guido van Rossum added the comment: I'm sorry, but can you rephrase that in the form of a patch? I can't quite figure out what you're trying to say, except that it sounds like it's scratching an itch of yours. -- nosy: +gvanrossum __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1738 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1738] filecmp.dircmp does exact match only
Oliver Nelson added the comment: Patch attached (sorry, this is my first bug report on an os project). dircmp has a list of files to ignore and hide. These lists right now are compared to the left and right lists using __contains__ to filter out the ignore/hide lists. This patch adds the ability to pass file patterns in addition to filenames so that you can filter classes of files such as *.bak or temp*.* Added file: http://bugs.python.org/file9067/filecmp.py.patch __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1738 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1738] filecmp.dircmp does exact match only
Oliver Nelson added the comment: sorry...jacked up the patch file...new one attached Added file: http://bugs.python.org/file9068/filecmp.py.patch __ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1738 __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com