Re: urllib unqoute providing string mismatch between string found using os.walk (Python3)

2019-12-22 Thread Ben Hearn
On Saturday, 21 December 2019 21:46:43 UTC, Ben Hearn wrote: > Hello all, > > I am having a bit of trouble with a string mismatch operation in my tool I am > writing. > > I am comparing a database collection or url quoted paths to the paths on the > users drive. > > These 2 paths look identic

Re: urllib unqoute providing string mismatch between string found using os.walk (Python3)

2019-12-21 Thread Richard Damon
On 12/21/19 8:25 PM, MRAB wrote: > On 2019-12-22 00:22, Michael Torrie wrote: >> On 12/21/19 2:46 PM, Ben Hearn wrote: >>> These 2 paths look identical, one from the drive & the other from an >>> xml url: >>> a = '/Users/macbookpro/Music/tracks_new/_NS_2018/J.Staaf - >>> ¡Móchate! _PromoMix_.wav'

Re: urllib unqoute providing string mismatch between string found using os.walk (Python3)

2019-12-21 Thread MRAB
On 2019-12-22 00:22, Michael Torrie wrote: On 12/21/19 2:46 PM, Ben Hearn wrote: These 2 paths look identical, one from the drive & the other from an xml url: a = '/Users/macbookpro/Music/tracks_new/_NS_2018/J.Staaf - ¡Móchate! _PromoMix_.wav'

Re: urllib unqoute providing string mismatch between string found using os.walk (Python3)

2019-12-21 Thread Chris Angelico
On Sun, Dec 22, 2019 at 11:33 AM Michael Torrie wrote: > > On 12/21/19 2:46 PM, Ben Hearn wrote: > > These 2 paths look identical, one from the drive & the other from an xml > > url: > > a = '/Users/macbookpro/Music/tracks_new/_NS_2018/J.Staaf - ¡Móchate! > > _PromoMix_.wav' >

Re: urllib unqoute providing string mismatch between string found using os.walk (Python3)

2019-12-21 Thread Michael Torrie
On 12/21/19 2:46 PM, Ben Hearn wrote: > These 2 paths look identical, one from the drive & the other from an xml url: > a = '/Users/macbookpro/Music/tracks_new/_NS_2018/J.Staaf - ¡Móchate! > _PromoMix_.wav' ^^ > b = '/Users/macbookpro

Re: urllib unqoute providing string mismatch between string found using os.walk (Python3)

2019-12-21 Thread Dan Sommers
On 12/21/19 4:46 PM, Ben Hearn wrote: import difflib print('\n'.join(difflib.ndiff([a], [b]))) - /Users/macbookpro/Music/tracks_new/_NS_2018/J.Staaf - ¡Móchate! _PromoMix_.wav ? ^^ + /Users/ma

Re: urllib unqoute providing string mismatch between string found using os.walk (Python3)

2019-12-21 Thread Pieter van Oostrum
Ben Hearn writes: > Hello all, > > I am having a bit of trouble with a string mismatch operation in my tool I am > writing. > > I am comparing a database collection or url quoted paths to the paths on the > users drive. > > These 2 paths look identical, one from the drive & the other from an xm

urllib unqoute providing string mismatch between string found using os.walk (Python3)

2019-12-21 Thread Ben Hearn
Hello all, I am having a bit of trouble with a string mismatch operation in my tool I am writing. I am comparing a database collection or url quoted paths to the paths on the users drive. These 2 paths look identical, one from the drive & the other from an xml url: a = '/Users/macbookpro/Music

Re: os.walk the apostrophe and unicode

2017-06-25 Thread Rod Person
act using Python 3.5. I may be lacking in unicode skills > > but I do have the sense enough to know the version of Python I am > > invoking. So I included this screenshot of that so the version of > > Python and the files list returned by os.walk > > > > http://rodperson.c

Re: os.walk the apostrophe and unicode

2017-06-25 Thread Peter Otten
7;ähnlich', 'löblich'] For file names Python resorts to surrogates whenever a byte does not translate into a character in the advertised encoding. > I am in fact using Python 3.5. I may be lacking in unicode skills but I > do have the sense enough to know the version of Python I a

Re: os.walk the apostrophe and unicode

2017-06-25 Thread Michael Torrie
n I am invoking. > So I included this screenshot of that so the version of Python and the > files list returned by os.walk > > http://rodperson.com/graphics/uc/files.png If I create a file that has the U+2019 character in it on my Linux machine (BtrFS), and do os.walk on it, I see the cha

Re: os.walk the apostrophe and unicode

2017-06-25 Thread Rod Person
oking. So I included this screenshot of that so the version of Python and the files list returned by os.walk http://rodperson.com/graphics/uc/files.png So the fact that it shows as a string and not bytes in the debugger was throwing me for a loop, in my log section I was trying to determine if it w

Re: os.walk the apostrophe and unicode

2017-06-25 Thread alister
On Sun, 25 Jun 2017 02:23:15 -0700, wxjmfauth wrote: > Le samedi 24 juin 2017 21:10:47 UTC+2, alister a écrit : >> On Sat, 24 Jun 2017 14:57:21 -0400, Rod Person wrote: >> >> > \xe2\x80\x99, >> >> because the file name has been created using "Right single quote" >> instead of apostrophe, the gly

Re: os.walk the apostrophe and unicode

2017-06-25 Thread Peter Otten
Steve D'Aprano wrote: > On Sun, 25 Jun 2017 04:57 pm, Peter Otten wrote: >> if everything worked correctly? Though I don't understand why the OP >> doesn't see >> >> '06 - Toddâ\x80\x99s Song (Post-Spiderland Song in Progress).flac' >> >> which is the repr() that I get. > > That's mojibake and

Re: os.walk the apostrophe and unicode

2017-06-25 Thread Steve D'Aprano
On Sun, 25 Jun 2017 04:57 pm, Peter Otten wrote: > Steve D'Aprano wrote: > >> On Sun, 25 Jun 2017 07:17 am, Peter Otten wrote: >> >>> Then I'd fix the name manually... >> >> The file name isn't broken. >> >> >> What's broken is parts of the OP's code which assumes that non-ASCII file >> names

Re: os.walk the apostrophe and unicode

2017-06-25 Thread Peter Otten
Steve D'Aprano wrote: > On Sun, 25 Jun 2017 07:17 am, Peter Otten wrote: > >> Then I'd fix the name manually... > > The file name isn't broken. > > > What's broken is parts of the OP's code which assumes that non-ASCII file > names are broken... Hm, the OP says '06 - Todd\xe2\x80\x99s Song (

Re: os.walk the apostrophe and unicode

2017-06-24 Thread Steve D'Aprano
On Sun, 25 Jun 2017 07:17 am, Peter Otten wrote: > Then I'd fix the name manually... The file name isn't broken. What's broken is parts of the OP's code which assumes that non-ASCII file names are broken... -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure e

Re: os.walk the apostrophe and unicode

2017-06-24 Thread Peter Otten
p3 and flac files, everything is working great until >> > the follow file is found >> > >> > '06 - Todd's Song (Post-Spiderland Song in Progress).flac' >> > >> > for some reason that I can't understand os.walk() returns this file

Re: os.walk the apostrophe and unicode

2017-06-24 Thread MRAB
great until > the follow file is found > > '06 - Todd's Song (Post-Spiderland Song in Progress).flac' > > for some reason that I can't understand os.walk() returns this file > name as > > '06 - Todd\xe2\x80\x99s Song (Post-Spiderland Song in >

Re: os.walk the apostrophe and unicode

2017-06-24 Thread Andre Müller
Can os.fsencode and os.fsdecode help? I've seen it somewhere. I've never used it. To fix encodings, sometimes I use the module ftfy Greetings Andre -- https://mail.python.org/mailman/listinfo/python-list

Re: os.walk the apostrophe and unicode

2017-06-24 Thread Rod Person
til > > the follow file is found > > > > '06 - Todd's Song (Post-Spiderland Song in Progress).flac' > > > > for some reason that I can't understand os.walk() returns this file > > name as > > > > '06 - Todd\xe2\x80\x99s Song (Post-Spide

Re: os.walk the apostrophe and unicode

2017-06-24 Thread Rod Person
> > the follow file is found > > > > '06 - Todd's Song (Post-Spiderland Song in Progress).flac' > > > > for some reason that I can't understand os.walk() returns this file > > name as > > > > '06 - Todd\xe2\x80\x99s Song (

Re: os.walk the apostrophe and unicode

2017-06-24 Thread Peter Otten
c' > > for some reason that I can't understand os.walk() returns this file > name as > > '06 - Todd\xe2\x80\x99s Song (Post-Spiderland Song in Progress).flac' > > which then causes more hell than a little bit for me. I'm not > understand why apostrophe(&#x

Re: os.walk the apostrophe and unicode

2017-06-24 Thread Michael Torrie
ong in Progress).flac' > > for some reason that I can't understand os.walk() returns this file > name as > > '06 - Todd\xe2\x80\x99s Song (Post-Spiderland Song in Progress).flac' That's basically a UTF-8 string there: $ python3 >>> a= b'06 -

Re: os.walk the apostrophe and unicode

2017-06-24 Thread MRAB
reason that I can't understand os.walk() returns this file name as '06 - Todd\xe2\x80\x99s Song (Post-Spiderland Song in Progress).flac' which then causes more hell than a little bit for me. I'm not understand why apostrophe(') becomes \xe2\x80\x99, or what I can do about it

Re: os.walk the apostrophe and unicode

2017-06-24 Thread John Ladasky
ng (Post-Spiderland Song in Progress).flac' > > for some reason that I can't understand os.walk() returns this file > name as > > '06 - Todd\xe2\x80\x99s Song (Post-Spiderland Song in Progress).flac' > > which then causes more hell than a little bit for m

Re: os.walk the apostrophe and unicode

2017-06-24 Thread alister
On Sat, 24 Jun 2017 14:57:21 -0400, Rod Person wrote: > \xe2\x80\x99, because the file name has been created using "Right single quote" instead of apostrophe, the glyphs look identical in many fonts. -- "If you understand what you're doing, you're not learning anything." --

os.walk the apostrophe and unicode

2017-06-24 Thread Rod Person
Hi, I'm working on a program that will walk a file system and clean the id3 tags of mp3 and flac files, everything is working great until the follow file is found '06 - Todd's Song (Post-Spiderland Song in Progress).flac' for some reason that I can't understand os.walk

Re: python 3.4, os.walk does not walk into cdroms

2015-12-18 Thread Nobody
On Thu, 17 Dec 2015 14:03:25 +0100, Siegfried Kaiser wrote: > I have a problem with os.walk - it does not walk into a mounted cdrom, I > do not see the cdrom in the walk at all. > What can I do to walk into cdrom? 1. Are you sure that the directory tree contains the actual mount p

Re: python 3.4, os.walk does not walk into cdroms

2015-12-17 Thread Mark Lawrence
On 17/12/2015 13:03, Siegfried Kaiser wrote: Hello all, I have a problem with os.walk - it does not walk into a mounted cdrom, I do not see the cdrom in the walk at all. What can I do to walk into cdrom? Thanks, Siegfried Please give us. 1) Your OS. 2) Your code. 3) How you

python 3.4, os.walk does not walk into cdroms

2015-12-17 Thread Siegfried Kaiser
Hello all, I have a problem with os.walk - it does not walk into a mounted cdrom, I do not see the cdrom in the walk at all. What can I do to walk into cdrom? Thanks, Siegfried -- Siegfried Kaiser -- https://mail.python.org/mailman/listinfo/python-list

problem while using os.walk with utf-8 characters

2015-05-12 Thread Thierry GAYET
Hi, I'm using the os.walk function for parsing files from an external mass-storage such as usbkey. When i try the following code, i have an error: from __future__ import unicode_literals import sys reload(sys) sys.setdefaultencoding('utf_8') for dirname, dirnames, filen

Re: os.walk/list

2011-03-21 Thread Peter Otten
gest() == > md5.new(f2.read()).digest() > if truth == 0: > print "file copy error" > > that would probably work for the single file copy functions. but would > still breakdown during the for ...os.walk(), again because "fname" is > a list there

Re: os.walk/list

2011-03-20 Thread ecu_jon
truth == 0: print "file copy error" that would probably work for the single file copy functions. but would still breakdown during the for ...os.walk(), again because "fname" is a list there, and the crypto functions work 1 file at a time. even changing crypto functions

Re: os.walk/list

2011-03-20 Thread Peter Otten
.digest() == > md5.new(f2.read()).digest() > if truth == 0: > print "file copy error" > > this worked swimmingly. i moved on to my backupall function, something > like > for (path, dirs, files) in os.walk(source): > #os.walk drills down thru a

Re: os.walk/list

2011-03-19 Thread Dan Stromberg
t provide quite as strong assurance that way, but it does get rid of the need to save what files were processed. You could also do a second os.walk, but of course, that's subject to issues when one of the trees has been changed by something other than your copying program. Finally... Why not

os.walk/list

2011-03-19 Thread ecu_jon
"file copy error" this worked swimmingly. i moved on to my backupall function, something like for (path, dirs, files) in os.walk(source): #os.walk drills down thru all the folders of source for fname in dirs: currentdir = destination+leftover try:

Re: Removing hidden directory in os.walk()

2011-02-25 Thread Chris Rebert
On Fri, Feb 25, 2011 at 9:40 AM, Gaëtan Podevijn wrote: > Hello, > I would like that os.walk() does not walk through hidden directories. I know > that with topdow = true, I can modify the subdirectory list in place, but > how should I remove every hidden directory from this p

Removing hidden directory in os.walk()

2011-02-25 Thread Gaëtan Podevijn
Hello, I would like that os.walk() does not walk through hidden directories. I know that with topdow = true, I can modify the subdirectory list in place, but how should I remove every hidden directory from this place in list ? Thank you, Gaëtan -- http://mail.python.org/mailman/listinfo/python

Re: Path / Listing and os.walk problem.

2010-08-26 Thread Alban Nona
_VDM_AMB_V001.0003.exr >> > >> > True is, there is like 1000 Files is the directory (C:\log\renderfiles\) >> > >> > What Iam looking to is to extract the first part of the filenames as a >> > list, but I dont want the script to extract it 1000times, I mean

Re: Path / Listing and os.walk problem.

2010-08-26 Thread Alban Nona
, but I dont want the script to extract it 1000times, I mean I dont > > need it to extract HPO7_SEQ004_031_VDM_AMB 150 times, because there is > 150 > > Frames. (not sure if its clear tought) > > > > so far, I would like the list to look lik: > > > > ["HPO7_

Re: Path / Listing and os.walk problem.

2010-08-26 Thread Peter Otten
clear tought) > > so far, I would like the list to look lik: > > ["HPO7_SEQ004_031_VDM_DIF", "HPO7_SEQ004_031_VDM_AMB", etc...] > > > I start to think about that, to try to use a > > for (path, dirs, files) in os.walk(path): > list.append(files) > > > b

Path / Listing and os.walk problem.

2010-08-25 Thread Alban Nona
] I start to think about that, to try to use a for (path, dirs, files) in os.walk(path): list.append(files) but this kind of thing will just append the whole 1000 files, thing that I dont want, and more complicated I dont want the thing after "AMB" or "DIF" in the name file

Use of cmp() (was Re: Limitation of os.walk)

2010-05-12 Thread Aahz
[nitpicking one specific point] In article , Steven D'Aprano wrote: > >On the other hand a cmp function is specific to sorting, and nothing >but sorting. Not quite. cmp() is useful any time you have an expensive comparison operation and you need to take three different codepaths depending on t

Re: Limitation of os.walk

2010-05-12 Thread Steven D'Aprano
On Wed, 12 May 2010 19:04:47 +, kj wrote: > In Terry Reedy > writes: > >>On 5/11/2010 3:49 PM, kj wrote: >>> PS: I never understood why os.walk does not support hooks for key >>> events during such a tree traversal. > >>Either 1) it is inten

Re: Limitation of os.walk

2010-05-12 Thread Terry Reedy
On 5/12/2010 2:52 PM, kj wrote: In Tim Chase writes: 05/11/2010 09:07 PM, Terry Reedy wrote: If os.walk were rewritten, it should be as an iterator (generator). Directory entry and exit functions could still be added as params. It *is* an iterator/generator. However, I suspect you mean

Re: Limitation of os.walk

2010-05-12 Thread Patrick Maupin
On May 12, 2:04 pm, kj wrote: > It seems that a similar "simplicity argument" was invoked > to strip the cmp option from sort in Python 3.  G.  Simplicity > is great, but when the drive for it starts causing useful functionality > to be thrown out, then it is going too far.  Yes, I know that i

Re: Limitation of os.walk

2010-05-12 Thread kj
In Terry Reedy writes: >On 5/11/2010 3:49 PM, kj wrote: >> PS: I never understood why os.walk does not support hooks for key >> events during such a tree traversal. >Either 1) it is intentionally simple, with the expectation that people >would write there own code for

Re: Limitation of os.walk

2010-05-12 Thread kj
In Tim Chase writes: > 05/11/2010 09:07 PM, Terry Reedy wrote: >> If os.walk were rewritten, it should be as an iterator (generator). >> Directory entry and exit functions could still be added as params. >It *is* an iterator/generator. However, I suspect you mean that &g

Re: Limitation of os.walk

2010-05-11 Thread Tim Chase
05/11/2010 09:07 PM, Terry Reedy wrote: PS: I never understood why os.walk does not support hooks for key events during such a tree traversal. Either 1) it is intentionally simple, with the expectation that people would write there own code for more complicated uses or 2) no one has submitted

Re: Limitation of os.walk

2010-05-11 Thread Terry Reedy
On 5/11/2010 3:49 PM, kj wrote: I want implement a function that walks through a directory tree and performs an analsysis of all the subdirectories found. The task has two essential requirements that, AFAICT, make it impossible to use os.walk for this: 1. I need to be able to prune certain

Re: Limitation of os.walk

2010-05-11 Thread kj
In Tim Chase writes: >That said, the core source for os.walk() is a whole 23 >lines of code, it's easy enough to just clone it and add what you >need... Thanks, that was a good idea. ~K -- http://mail.python.org/mailman/listinfo/python-list

Re: Limitation of os.walk

2010-05-11 Thread Tim Chase
On 05/11/2010 02:49 PM, kj wrote: I want implement a function that walks through a directory tree and performs an analsysis of all the subdirectories found. The task has two essential requirements that, AFAICT, make it impossible to use os.walk for this: 1. I need to be able to prune certain

Limitation of os.walk

2010-05-11 Thread kj
I want implement a function that walks through a directory tree and performs an analsysis of all the subdirectories found. The task has two essential requirements that, AFAICT, make it impossible to use os.walk for this: 1. I need to be able to prune certain directories from being visited. 2

Re: os.walk restart

2010-03-31 Thread Piet van Oostrum
check whether a directory is in that list and skip the program run for these. Something like this (symbolically): lastrun = map(string.strip, logfile.readlines()) newlog = ... open logfile in append mode ... for root, dirs, files in os.walk(basedir): if root not in lastrun: run pr

Re: os.walk restart

2010-03-18 Thread Tim Chase
Steve Howell wrote: If that's the case, then you might be able to get away with just leaving some kind of breadcrumbs whenever you've successfully processed a directory or a file, Unless you're indexing a read-only device (whether hardware read-only like a CD, or permission-wise read-only like

Re: os.walk restart

2010-03-17 Thread Steven D'Aprano
On Wed, 17 Mar 2010 20:08:48 -0700, alex23 wrote: > Steven D'Aprano wrote: >> # Untested >> last_visited = open("last_visited.txt", 'r').read() >> for root, dirs, files in os.walk(last_visited or basedir): >>      open("last_visited.txt&qu

Re: os.walk restart

2010-03-17 Thread Steve Howell
On Mar 17, 3:04 pm, Keir Vaughan-taylor wrote: > I am traversing a large set of directories using > > for root, dirs, files in os.walk(basedir): >     run program > > Being a huge directory set the traversal is taking days to do a > traversal. > Sometimes it is the case

Re: os.walk restart

2010-03-17 Thread MRAB
Keir Vaughan-taylor wrote: I am traversing a large set of directories using for root, dirs, files in os.walk(basedir): run program Being a huge directory set the traversal is taking days to do a traversal. Sometimes it is the case there is a crash because of a programming error. As each

Re: os.walk restart

2010-03-17 Thread alex23
Steven D'Aprano wrote: > # Untested > last_visited = open("last_visited.txt", 'r').read() > for root, dirs, files in os.walk(last_visited or basedir): >      open("last_visited.txt", 'w').write(root) >      run program Wouldn't

Re: os.walk restart

2010-03-17 Thread Gabriel Genellina
En Wed, 17 Mar 2010 19:04:14 -0300, Keir Vaughan-taylor escribió: I am traversing a large set of directories using for root, dirs, files in os.walk(basedir): run program Being a huge directory set the traversal is taking days to do a traversal. Sometimes it is the case there is a crash

Re: os.walk restart

2010-03-17 Thread Steven D'Aprano
On Wed, 17 Mar 2010 15:04:14 -0700, Keir Vaughan-taylor wrote: > I am traversing a large set of directories using > > for root, dirs, files in os.walk(basedir): > run program > > Being a huge directory set the traversal is taking days to do a > traversal. > Sometimes

os.walk restart

2010-03-17 Thread Keir Vaughan-taylor
I am traversing a large set of directories using for root, dirs, files in os.walk(basedir): run program Being a huge directory set the traversal is taking days to do a traversal. Sometimes it is the case there is a crash because of a programming error. As each directory is processed the name

Re: How to avoid certain directories when using os.walk?

2009-10-30 Thread Gabriel Genellina
En Fri, 30 Oct 2009 14:50:34 -0300, Sean DiZazzo escribió: On Oct 29, 10:17 pm, Chris Rebert wrote: On Thu, Oct 29, 2009 at 9:53 PM, Peng Yu wrote: > I don't see a way to avoid walking over directories of certain names > with os.walk. For example, I don't want os.walk re

Re: How to avoid certain directories when using os.walk?

2009-10-30 Thread Dave Angel
Sean DiZazzo wrote: On Oct 29, 10:17 pm, Chris Rebert wrote: On Thu, Oct 29, 2009 at 9:53 PM, Peng Yu wrote: I don't see a way to avoid walking over directories of certain names with os.walk. For example, I don't want os.walk return files whose path include '/backup/&#

Re: How to avoid certain directories when using os.walk?

2009-10-30 Thread Sean DiZazzo
On Oct 29, 10:17 pm, Chris Rebert wrote: > On Thu, Oct 29, 2009 at 9:53 PM, Peng Yu wrote: > > I don't see a way to avoid walking over directories of certain names > > with os.walk. For example, I don't want os.walk return files whose > > path include 

Re: How to avoid certain directories when using os.walk?

2009-10-30 Thread Dave Angel
Chris Rebert wrote: On Thu, Oct 29, 2009 at 9:53 PM, Peng Yu wrote: I don't see a way to avoid walking over directories of certain names with os.walk. For example, I don't want os.walk return files whose path include '/backup/'. Is there a way to do so? Otherwise, maybe

Re: How to avoid certain directories when using os.walk?

2009-10-29 Thread Chris Rebert
On Thu, Oct 29, 2009 at 9:53 PM, Peng Yu wrote: > I don't see a way to avoid walking over directories of certain names > with os.walk. For example, I don't want os.walk return files whose > path include '/backup/'. Is there a way to do so? Otherwise, maybe I >

How to avoid certain directories when using os.walk?

2009-10-29 Thread Peng Yu
I don't see a way to avoid walking over directories of certain names with os.walk. For example, I don't want os.walk return files whose path include '/backup/'. Is there a way to do so? Otherwise, maybe I will have to make my own program. Thank you! -- http://mail.python.

Re: postprocessing in os.walk

2009-10-13 Thread Ethan Furman
kj wrote: In Dave Angel writes: [snippetty snip] Why would you need a special hook when the os.walk() generator yields exactly once per directory? So whatever work you do on the list of files you get, you can then put the summary logic immediately after. I think you're missin

Re: postprocessing in os.walk

2009-10-13 Thread Dave Angel
7;ve been meaning to add a few enhancements to it for a while, so I thought that in the process I'd port it to Python, using the os.walk function, but I see that os.walk does not have anything like this File::Find::find's postprocess hook. Is there a good way to simulate it (without having t

Re: postprocessing in os.walk

2009-10-13 Thread Paul Rubin
kj writes: > I think you're missing the point. The hook in question has to be > called *immediately after* all the subtrees that are rooted in > subdirectories contained in the current directory have been visited > by os.walk. > > I'd love to see your "5 lines

Re: postprocessing in os.walk

2009-10-13 Thread Peter Otten
cript. >>> >>> This maintenance script is getting long in the tooth, and I've been >>> meaning to add a few enhancements to it for a while, so I thought >>> that in the process I'd port it to Python, using the os.walk >>> function, but I see

Re: postprocessing in os.walk

2009-10-13 Thread kj
ng long in the tooth, and I've been >> meaning to add a few enhancements to it for a while, so I thought >> that in the process I'd port it to Python, using the os.walk >> function, but I see that os.walk does not have anything like this >> File::Find::find&

Re: postprocessing in os.walk

2009-10-12 Thread Dave Angel
hat in the process I'd port it to Python, using the os.walk function, but I see that os.walk does not have anything like this File::Find::find's postprocess hook. Is there a good way to simulate it (without having to roll my own File::Find::find in Python)? TIA! kynn Why would

postprocessing in os.walk

2009-10-12 Thread kj
in the process I'd port it to Python, using the os.walk function, but I see that os.walk does not have anything like this File::Find::find's postprocess hook. Is there a good way to simulate it (without having to roll my own File::Find::find in Python)? TIA! kynn -- http://mail.python.org/mailman/listinfo/python-list

Re: postprocessing in os.walk

2009-10-11 Thread jordilin
for a while, so I thought > that in the process I'd port it to Python, using the os.walk > function, but I see that os.walk does not have anything like this > File::Find::find's postprocess hook.  Is there a good way to simulate > it (without having to roll my own File::Fin

Re: os.walk()

2009-08-06 Thread Chris Rebert
> On Tue, Aug 4, 2009 at 10:48 PM, Chris Rebert wrote: >> On Tue, Aug 4, 2009 at 7:06 PM, Michael Savarese wrote: >> > Greetings >> > Python newbie here, and thanks to all who have helped me previously. >> > Is there a way of grabbing file attributes while trav

Re: os.walk()

2009-08-04 Thread Chris Rebert
On Tue, Aug 4, 2009 at 7:06 PM, Michael Savarese wrote: > Greetings > Python newbie here, and thanks to all who have helped me previously. > Is there a way of grabbing file attributes while traversing with os.walk()? > It would be advantageous to have date modified and file size al

os.walk()

2009-08-04 Thread Michael Savarese
Greetings Python newbie here, and thanks to all who have helped me previously. Is there a way of grabbing file attributes while traversing with os.walk()? It would be advantageous to have date modified and file size along with the file name. If anyone can point me in the right direction, I&#

Re: os.walk and os.listdir problems python 3.0+

2009-06-27 Thread Gabriel Genellina
En Thu, 25 Jun 2009 11:15:15 -0300, Amos Anderson escribió: Thank you. That works very well when writing to a text file but what is the equivalent when writing the information to stdout using print? See this recent post: http://comments.gmane.org/gmane.comp.python.general/627850 -- Gabri

Re: os.walk and os.listdir problems python 3.0+

2009-06-25 Thread Amos Anderson
codecs.charmap_encode(input,self.errors,encoding_table)[0] >> UnicodeEncodeError: 'charmap' codec can't encode character '\u200b' in >> position >> 30: character maps to >> >> Code is as follows... >> import os >> f = open("

Re: os.walk and os.listdir problems python 3.0+

2009-06-24 Thread Mark Tolonen
harmap' codec can't encode character '\u200b' in position 30: character maps to Code is as follows... import os f = open("dirlist.txt", 'w') for root, dirs, files in os.walk("C:\\Users\\Filter\\"): f.write("root:{0}\n".format(root)

os.walk and os.listdir problems python 3.0+

2009-06-24 Thread Amos Anderson
s follows... import os f = open("dirlist.txt", 'w') for root, dirs, files in os.walk("C:\\Users\\Filter\\"): f.write("root:{0}\n".format(root)) f.write("dirs:\n") for i in dirs: f.write("dir:{0}\n".format(i)) f.w

Re: problem with glob in remote directory or os.walk in remote directory in windos

2009-02-27 Thread Steve Holden
lameck kassana wrote: > At last i did it it was this wrong line file_count += len(files) ---it > supposed to be file_count+=1 > but thanks for help ya python masters .Steven Holden thanks very > very much for your tip about raw string > Lameck: Please note that file_count = 0 for files in

Re: problem with glob in remote directory or os.walk in remote directory in windos

2009-02-27 Thread Steve Holden
lameck kassana wrote: > now it is working but i wonder it brings higher number of count as if it > counts files in wholes computer can you check in my code and correct me > > import glob > import os > file_count=0 > for files in glob.glob(r"\\192.16

Re: problem with glob in remote directory or os.walk in remote directory in windos

2009-02-27 Thread lameck kassana
At last i did it it was this wrong line file_count += len(files) ---it supposed to be file_count+=1 but thanks for help ya python masters .Steven Holden thanks very very much for your tip about raw string On Fri, Feb 27, 2009 at 12:43 PM, Gabriel Genellina wrote: > En Fri, 27 Feb 2009 07:02

Re: problem with glob in remote directory or os.walk in remote directory in windos

2009-02-27 Thread Gabriel Genellina
En Fri, 27 Feb 2009 07:02:57 -0200, lameck kassana escribió: now it is working but i wonder it brings higher number of count as if it counts files in wholes computer can you check in my code and correct me import glob import os file_count=0 fo

Re: problem with glob in remote directory or os.walk in remote directory in windos

2009-02-27 Thread lameck kassana
now it is working but i wonder it brings higher number of count as if it counts files in wholes computer can you check in my code and correct me import glob import os file_count=0 for files in glob.glob(r"\\192.168.0.45\loader\Files\file_log\v20090

Re: problem with glob in remote directory or os.walk in remote directory in windos

2009-02-26 Thread Steve Holden
lameck kassana wrote: > ok my original question is how can count the files of ceratin pattern(eg > *.txt) in remote directory .It seems use of glob.glob() for remote > directory is not working .Example I want to count the files in following > shared folder \\192.168.0.45\files how can > do it by u

Re: problem with glob in remote directory or os.walk in remote directory in windos

2009-02-26 Thread lameck kassana
ok my original question is how can count the files of ceratin pattern(eg *.txt) in remote directory .It seems use of glob.glob() for remote directory is not working .Example I want to count the files in following shared folder \\192.168.0.45\files how can do it by using glob.glob() On Thu, Feb 26

Re: problem with glob in remote directory or os.walk in remote directory in windos

2009-02-26 Thread Steve Holden
lameck kassana wrote: > i am trying to write script which will count files for remote directory > which having certain pattern. > Please refrain from repeating questions. When you posted this a reply had already been made to your original posting. Remember, this isn't a paid help desk ... regard

problem with glob in remote directory or os.walk in remote directory in windos

2009-02-26 Thread lameck kassana
file_string) File.close() ---- the problem the glob.glob() does not work in remotely directory especially in window environment i don't know why?? i also try os.walk() for remote directory it faile

using os.walk to generate objects

2008-12-03 Thread Joe Hrbek
tem, choose/make a simple directory structure to use as your root for os.walk(). Also, you must start from the top most directory level, like /test. /tmp/test as a root will not work (yet). :) I wanted to know if I could use os.walk() to construct an object based off of a directory tree. So, the fo

Re: Exclude Directories from os.walk

2008-10-21 Thread Scott David Daniels
D wrote: Ok, my brain's apparently not working right today.. what I'd like to do is allow the user to specify a directory to exclude (ex- "C:\temp \test") - then, when os.walk gets to "C:\temp\test", it excludes that directory and all its subdirectories (so, "C

Re: Exclude Directories from os.walk

2008-10-21 Thread D
) > continue > > WARNING: untest code > - Show quoted text - > > On Tue, Oct 21, 2008 at 6:13 PM, D <[EMAIL PROTECTED]> wrote: > > Ok, my brain's apparently not working right today.. what I'd like to > > do is allow the user to specify a directory to exc

Re: Exclude Directories from os.walk

2008-10-21 Thread Orestis Markou
t; Ok, my brain's apparently not working right today.. what I'd like to > do is allow the user to specify a directory to exclude (ex- "C:\temp > \test") - then, when os.walk gets to "C:\temp\test", it excludes that > directory and all its subdirectories (so,

Re: Exclude Directories from os.walk

2008-10-21 Thread D
Ok, my brain's apparently not working right today.. what I'd like to do is allow the user to specify a directory to exclude (ex- "C:\temp \test") - then, when os.walk gets to "C:\temp\test", it excludes that directory and all its subdirectories (so, "C:\temp\my

Re: Exclude Directories from os.walk

2008-10-21 Thread Scott David Daniels
D wrote: Hello, How can one exclude a directory (and all its subdirectories) when running os.walk()? Thanks, Doug for base, dirs, files in os.walk('wherever'): if 'RCS' in dirs: dirs.remove('RCS') As described in the os.walk docs. --Scott

Re: Exclude Directories from os.walk

2008-10-21 Thread Tim Golden
D wrote: Hello, How can one exclude a directory (and all its subdirectories) when running os.walk()? Just remove it from the dirnames yielded: import os for dirpath, dirnames, filenames in os.walk ("c:/temp"): print dirpath if "archive" in dirnames: dirnames.remov

  1   2   3   >