[issue8402] glob returns empty list with [ character in the folder name

2012-10-13 Thread Michele OrrĂ¹

Michele OrrĂ¹ added the comment:

The attached patch adds support for '\\' escaping to fnmatch, and consequently 
to glob.

--
keywords: +patch
nosy: +maker
versions: +Python 3.4 -Python 3.2
Added file: http://bugs.python.org/file27551/issue8402.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8402
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8402] glob returns empty list with [ character in the folder name

2012-10-11 Thread a1abhishek

a1abhishek added the comment:

i m agree with answer number 6. the resolution mentioned is quite easy and very 
effectve

thanks
http://www.packersmoversdirectory.net/

--
nosy: +a1abhishek

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8402
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8402] glob returns empty list with [ character in the folder name

2011-11-11 Thread flacs

flacs 0f1...@gmail.com added the comment:

As a workaround, it is possible to make every glob character a character set of 
one character (wrapping it with [] ). The gotcha here is that you can't just 
use multiple replaces because you would escape the escape brackets.

Here is a function adapted from [1]:

def escape_glob(path):
transdict = {
'[': '[[]',
']': '[]]',
'*': '[*]',
'?': '[?]',
}
rc = re.compile('|'.join(map(re.escape, transdict)))
return rc.sub(lambda m: transdict[m.group(0)], path)

[1] http://www.daniweb.com/software-development/python/code/216636

--
components: +Library (Lib)
nosy: +flacs

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8402
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8402] glob returns empty list with [ character in the folder name

2011-11-11 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
nosy: +ezio.melotti

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8402
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8402] glob returns empty list with [ character in the folder name

2010-09-27 Thread Constantin Veretennicov

Changes by Constantin Veretennicov kveretenni...@gmail.com:


--
nosy: +kveretennicov

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8402
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8402] glob returns empty list with [ character in the folder name

2010-07-09 Thread Eric Smith

Eric Smith e...@trueblade.com added the comment:

The note about no quoting meta-chars is in the docstring for fnmatch.translate, 
not the documentation. I still see it in 3.1. I have a to-do item to add this 
to the actual documentation. I'll add an issue.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8402
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8402] glob returns empty list with [ character in the folder name

2010-07-08 Thread Terry J. Reedy

Terry J. Reedy tjre...@udel.edu added the comment:

The 3.1.2 doc for fnmatch.translate no longer says There is no way to quote 
meta-characters. If that is still true (no quoting method is given that I can 
see), then that removal is something of a regression.

--
nosy: +tjreedy
versions: +Python 3.2 -Python 2.5

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8402
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8402] glob returns empty list with [ character in the folder name

2010-05-26 Thread Dan Gawarecki

Dan Gawarecki dan_gaware...@datacard.com added the comment:

Shouldn't the title be updated to indicate the fnmatch is the true source of 
the behavior (I'm basing this on http://docs.python.org/library/glob.html 
indicating the fnmatch is invoked by glob).  I'm not using glob, but fnmatch in 
my attempt to find filenames that look like Ajax_[version2].txt.  

If nothing else, it would have helped me if the documentation would state 
whether or not the brackets could be escaped.  It doesn't appear from my tests 
(trying Ajax_\[version2\].txt and Ajax_\\[version2\\].txt) that 'escaping' 
is possible, but if the filter pattern gets turned into a regular expression, I 
think escaping *would* be possible.  Is that a reasonable assumption?

I'm running 2.5.1 under Windows, and this is my first ever post to the bugs 
list.

--
nosy: +Aquinas

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8402
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8402] glob returns empty list with [ character in the folder name

2010-05-26 Thread Dan Gawarecki

Dan Gawarecki dan_gaware...@datacard.com added the comment:

Following up...
I saw Eric Smith's 2nd note (2010-04-15 @1:27) about fnmatch.translate 
documentation stating that
   There is no way to quote meta-characters.

When I looked at:
http://docs.python.org/library/fnmatch.html#module-fnmatch

did not see this statement appear anywhere.  Would this absence be because 
someone is working on making this enhancement?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8402
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8402] glob returns empty list with [ character in the folder name

2010-05-26 Thread Eric Smith

Eric Smith e...@trueblade.com added the comment:

I don't think so. That quote came from the docstring for fnmatch.translate.

 help(fnmatch.translate)
Help on function translate in module fnmatch:

translate(pat)
Translate a shell PATTERN to a regular expression.

There is no way to quote meta-characters.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8402
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8402] glob returns empty list with [ character in the folder name

2010-04-14 Thread george hu

New submission from george hu geo...@gmail.com:

Have this problem in python 2.5.4 under windows. 
I'm trying to return a list of files in a directory by using glob. It keeps 
returning a empty list until I tested/adjusted folder name by removing [ 
character from it. Not sure if this is a bug.

glob.glob(c:\abc\afolderwith[test]\*) returns empty list
glob.glob(c:\abc\afolderwithtest]\*) returns files

--
messages: 103160
nosy: george.hu
severity: normal
status: open
title: glob returns empty list with [ character in the folder name
type: behavior
versions: Python 2.5

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8402
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8402] glob returns empty list with [ character in the folder name

2010-04-14 Thread Shashwat Anand

Shashwat Anand anand.shash...@gmail.com added the comment:

When you do :
glob.glob(c:\abc\afolderwith[test]\*) returns empty list
It looks for all files in three directories:
c:\abc\afolderwitht\*
c:\abc\afolderwithe\*
c:\abc\afolderwiths\*

Ofcourse they do not exist so it returns empty list

06:35:05 l0nwlf-MBP:Desktop $ ls -R test
1 2 3
06:35:15 l0nwlf-MBP:Desktop $ ls -R test1
alpha beta  gamma

 glob.glob('/Users/l0nwlf/Desktop/test[123]/*')
['/Users/l0nwlf/Desktop/test1/alpha', '/Users/l0nwlf/Desktop/test1/beta', 
'/Users/l0nwlf/Desktop/test1/gamma']

As you can see, by giving the argument test[123] it looked for test1, test2, 
test3. Since test1 existed, it gave all the files present within it.

--
nosy: +l0nwlf

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8402
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8402] glob returns empty list with [ character in the folder name

2010-04-14 Thread Eric Smith

Eric Smith e...@trueblade.com added the comment:

See the explanation at 
http://docs.python.org/library/fnmatch.html#module-fnmatch , which uses the 
same rules.

--
nosy: +eric.smith
resolution:  - invalid
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8402
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8402] glob returns empty list with [ character in the folder name

2010-04-14 Thread george hu

george hu geo...@gmail.com added the comment:

Ok, what if the name of the directory contains [] characters? What is the 
escape string for that?

--
status: closed - open

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8402
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8402] glob returns empty list with [ character in the folder name

2010-04-14 Thread Eric Smith

Eric Smith e...@trueblade.com added the comment:

The documentation for fnmatch.translate, which is what ultimately gets called, 
says:
   There is no way to quote meta-characters.
Sorry.

If you want to see this changed, you could open a feature request. If you have 
a patch, that would help!

You probably want to research what the Unix shells use for escaping globs.

--
status: open - pending

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8402
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8402] glob returns empty list with [ character in the folder name

2010-04-14 Thread Shashwat Anand

Shashwat Anand anand.shash...@gmail.com added the comment:

glob module does not provide what you want.
As a workaround you can try:

os.listdir(c:\abc\afolderwith[test])

07:02:52 l0nwlf-MBP:Desktop $ ls -R test\[123\]/
1 2 3
 os.listdir('/Users/l0nwlf/Desktop/test[123]')
['1', '2', '3']

Changing type to 'Feature Request'

--
status: pending - open
type: behavior - feature request

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8402
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8402] glob returns empty list with [ character in the folder name

2010-04-14 Thread Shashwat Anand

Changes by Shashwat Anand anand.shash...@gmail.com:


--
title: glob returns empty list with  - glob returns empty list with [ 
character in the folder name

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8402
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8402] glob returns empty list with [ character in the folder name

2010-04-14 Thread R. David Murray

Changes by R. David Murray rdmur...@bitdance.com:


Removed file: http://bugs.python.org/file16925/unnamed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8402
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com