[Tutor] Preffered way to search posix filesystem

2005-01-26 Thread Miles Stevenson
I would like to search filesystem structures using globs on Posix systems from 
within Python. I don't see an obvious method to do this with in the standard 
modules. What is the preferred way of doing this? Should I just use the find 
command or is there a good module out there for searching?

Thanks.
-- 
Miles Stevenson
[EMAIL PROTECTED]
PGP FP: 035F 7D40 44A9 28FA 7453 BDF4 329F 889D 767D 2F63


pgpLQhrIGjLES.pgp
Description: PGP signature
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Safely buffering user input

2005-01-27 Thread Miles Stevenson
Newbie question.

I'm trying to practice safe coding techniques. I just want to make sure that a 
user can't supply a massive argument to my script and cause trouble. I'm just 
trying only accept about 256 bytes:

buffer(sys.argv[1], 0, 256)
searchpath = sys.argv[1]

The script runs successfully, but when I give the script much more than 256 
characters, it doesn't seem to chop it off. It still holds the entire long 
string and prints the whole thing back out again when I do a:

print searchpath

I assume the size arguments to buffer() are in bytes? Am I not using this 
correctly? Thanks in advance.

-- 
Miles Stevenson
[EMAIL PROTECTED]
PGP FP: 035F 7D40 44A9 28FA 7453 BDF4 329F 889D 767D 2F63


pgpOtDoQlQse6.pgp
Description: PGP signature
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Preffered way to search posix filesystem

2005-01-28 Thread Miles Stevenson
Thanks for the advice! My problem was that the built-in Python docs in Kdevelop 
weren't up-to-date, and 
I had trouble finding walk() in the docs. Here is the approach that I used 
being a python newbie 
(improvements are welcome):



def getfiles(path):
"""Recursively search a path and generate a lit of OGG files found

Takes a filesystem path as an argument. The path is recursively searched for
OGG files. Returns a list of each file found (in absolute path format) with
the first element of the list set to 'start'"""
filelist = ['start']
for root, dirs, files in os.walk(path):
for name in files:
a = os.path.join(root, name)
if os.path.isfile(a) and fnmatch.fnmatch(a, '*.ogg'):
filelist.append(a)
return filelist



What is interesting is that the latest 2.4 Python docs say that walk() returns 
a Tuple, which is untrue. 
It returns a generator object according to type(). This had me heavily confused 
as to how to use 
what was returned from walk() and it took a good hour of troubleshooting to 
figure it out.

-Miles

On Wednesday 26 January 2005 11:27 pm, you wrote:
> Try the os module.  I think this should probably get you there.
> http://docs.python.org/lib/module-os.html
>
> Miles Stevenson wrote:
> >I would like to search filesystem structures using globs on Posix
>
> systems from
>
> >within Python. I don't see an obvious method to do this with in the
>
> standard
>
> >modules. What is the preferred way of doing this? Should I just use
>
> the find
>
> >command or is there a good module out there for searching?
> >
> >Thanks.
>
> ______
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com

-- 
Miles Stevenson
[EMAIL PROTECTED]
PGP FP: 035F 7D40 44A9 28FA 7453 BDF4 329F 889D 767D 2F63
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Ogg Tag Module recommendations

2005-02-03 Thread Miles Stevenson
Can anyone recommend to me a Python module to work with ID3v2 tags in Ogg 
Vorbis files? I tried using the EyeD3 module, but it only supports mp3 right 
now, and I couldn't get the pyid3tag module to work reliably, or I'm just not 
understanding the documentation.

I just need to retrieve all of the ID3v2 tag info from a collection of ogg 
files, store them in a file, and then insert them back into different ogg 
files. Anyone have a module/library they recommend?

Thanks.
-- 
Miles Stevenson
[EMAIL PROTECTED]
PGP FP: 035F 7D40 44A9 28FA 7453 BDF4 329F 889D 767D 2F63


pgpoSFR82UYnd.pgp
Description: PGP signature
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor