Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #25633

RE: shutil ignore fails on passing a tuple?

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ramit.prasad@jpmorgan.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'attribute': 0.05; 'completeness': 0.07; 'constructor': 0.07; 'received:155': 0.09; 'subject:ignore': 0.09; 'tuple': 0.09; 'ignore': 0.13; 'passing': 0.15; "'replace'": 0.16; '46,': 0.16; '49,': 0.16; 'disclaimers': 0.16; 'disclaimers,': 0.16; 'from:addr:jpmorgan.com': 0.16; 'received:155.180': 0.16; 'received:159.53': 0.16; 'received:159.53.110': 0.16; 'received:bankone.net': 0.16; 'received:exchad.jpmchase.net': 0.16; 'received:jpmchase.com': 0.16; 'received:jpmchase.net': 0.16; 'received:svr.bankone.net': 0.16; 'securities,': 0.16; 'subject:fails': 0.16; 'url:disclosures': 0.16; 'url:jpmorgan': 0.16; 'skip:i 40': 0.17; 'skip:+ 20': 0.18; '>>>': 0.18; 'to:name:python-list@python.org': 0.20; '"",': 0.22; 'work.': 0.23; 'received:169.254': 0.24; 'header:In-Reply-To:1': 0.25; 'skip:" 20': 0.26; '(most': 0.27; 'accuracy': 0.27; 'this?': 0.28; 'convert': 0.29; 'received:169': 0.29; 'skip:_ 10': 0.29; "skip:' 10": 0.30; 'file': 0.32; "skip:' 20": 0.32; 'skip:s 30': 0.33; 'traceback': 0.33; 'to:addr:python- list': 0.33; 'fail': 0.35; 'filter': 0.35; 'subject:?': 0.35; 'there': 0.35; 'but': 0.36; 'should': 0.36; 'charset:us-ascii': 0.36; 'skip:p 20': 0.36; 'does': 0.37; 'why': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'skip:o 20': 0.38; 'to:addr:python.org': 0.39; 'skip:" 10': 0.40; 'think': 0.40; 'solve': 0.62; 'information,': 0.63; 'url:email': 0.63; 'legal': 0.65; 'subject': 0.66; 'purchase': 0.67; 'sale': 0.76; '138,': 0.84; 'received:169.254.8': 0.84
X-DKIM OpenDKIM Filter v2.1.3 sj1.jpmchase.com q6JGr7Qq008456
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpmorgan.com; s=smtpout; t=1342716787; bh=vUtpJUzW702LYopkDxJq22/9SZKum6Iu7o5Ae1yzJUg=; h=From:To:Subject:Date:Message-ID:References:In-Reply-To: Content-Transfer-Encoding:MIME-Version:Content-Type; b=Vt5o5BAeSvV9PfkU11dxg0+ZfqUrvBdhDHINwmmrfPFnMHN7Ybrb5QKc7DvJX86sJ 8NHXyQjda4WXoaOjZfjVtG8iNXn4isJW+fSe9IsS5vlBxIigFbHe/stJ48c7+m+2Uf 3ZyQefUhmty/YnpzWfgNgPnuSwf+MvlsRDDCIy2c=
From "Prasad, Ramit" <ramit.prasad@jpmorgan.com>
To "python-list@python.org" <python-list@python.org>
Subject RE: shutil ignore fails on passing a tuple?
Thread-Topic shutil ignore fails on passing a tuple?
Thread-Index AQHNZc32XlR15Lpjuki83oCb8oZtkZcw0d/A
Date Thu, 19 Jul 2012 16:52:54 +0000
References <50083935$0$6851$e4fe514c@news2.news.xs4all.nl>
In-Reply-To <50083935$0$6851$e4fe514c@news2.news.xs4all.nl>
Accept-Language en-US
Content-Language en-US
X-MS-Has-Attach
X-MS-TNEF-Correlator
x-originating-ip [10.67.79.47]
Content-Transfer-Encoding quoted-printable
MIME-Version 1.0
X-DLP-FWD Yes
Content-Type text/plain; charset="us-ascii"
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2306.1342716795.4697.python-list@python.org> (permalink)
Lines 26
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1342716795 news.xs4all.nl 6964 [2001:888:2000:d::a6]:58548
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:25633

Show key headers only | View raw


> >>> ipatterns
> ('*.txt', '*.hdf', '*.pdf', '*.png')
> >>> igf = shutil.ignore_patterns(ipatterns)
> >>> ignorethis = igf(ddftopdir,os.listdir(ddftopdir))
> 
> Traceback (most recent call last):
>   File "<pyshell#60>", line 1, in <module>
>     ignorethis = igf(ddftopdir,os.listdir(ddftopdir))
>   File "C:\Python27\lib\shutil.py", line 138, in _ignore_patterns
>     ignored_names.extend(fnmatch.filter(names, pattern))
>   File "C:\Python27\lib\fnmatch.py", line 49, in filter
>     pat=os.path.normcase(pat)
>   File "C:\Python27\lib\ntpath.py", line 46, in normcase
>     return s.replace("/", "\\").lower()
> AttributeError: 'tuple' object has no attribute 'replace'
> 
> >>> igg = shutil.ignore_patterns('*.txt', '*.hdf', '*.pdf', '*.png')
> >>> ignorethat = igg(ddftopdir, os.listdir(ddftopdir))
> >>> ignorethat
> set(['Chi2.png', 'DTSdata.hdf', 'TST.hdf', 'BullNoseDiffs.png',
> 'DTSall.hdf', 'Symmetry.pdf'])
> >>>
> ++++++++++++++++++++++++++++
> Why does it fail on passing in a tuple of ignore strings? I thought the ,
> (comma) is pretty much the tuple constructor (if that is the right word).
> 
> How can I solve this? Is there a way to convert a tuple of strings in a form
> that will be accepted?
>

Untested, but I think it should work.
igf = shutil.ignore_patterns(*ipatterns)

Ramit

This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

shutil ignore fails on passing a tuple? "Alex van der Spek" <zdoor@xs4all.nl> - 2012-07-19 18:43 +0200
  RE: shutil ignore fails on passing a tuple? "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-07-19 16:52 +0000
  Re: shutil ignore fails on passing a tuple? Joel Goldstick <joel.goldstick@gmail.com> - 2012-07-19 12:55 -0400
  Re: shutil ignore fails on passing a tuple? Dave Angel <d@davea.name> - 2012-07-19 15:20 -0400

csiph-web