Re: [Tutor] Newbie & Unittest ...

2010-05-07 Thread Damon Timm
;' import unittest from mlc import filetypes TAG_VALUES = ( ('title', 'Christmas Waltz'), ('artist', 'Damon Timm'), ('album', 'Homemade'), ('albumartist', 'Damon Timm'), ('compilation', False

Re: [Tutor] Newbie & Unittest ...

2010-05-06 Thread Damon Timm
ial output... I'm going to have to look into why that is. I need a way to make each function unique ... On Thu, May 6, 2010 at 2:04 PM, Damon Timm wrote: > class TestFileTags(unittest.TestCase): >    pass > > for test_name, file, key, value in list_of_tes

Re: [Tutor] Newbie & Unittest ...

2010-05-06 Thread Damon Timm
, test_func) I'm not sure if it is the *best* or *right* way to do it, but it does the trick! Damon On Thu, May 6, 2010 at 1:53 PM, Damon Timm wrote: > Hi Lie - > > Thanks for that idea -- I tried it but am getting an error.  I read a > little about the __dict__ feature but couldn&#

Re: [Tutor] Newbie & Unittest ...

2010-05-06 Thread Damon Timm
import unittest from mlc.filetypes import * TAG_VALUES = ( ('title', 'Christmas Waltz'), ('artist', 'Damon Timm'), ('album', 'Homemade'), ) FILES = ( FLACFile('data/lossless/01 - Christmas Waltz.flac'), MP3F

Re: [Tutor] Newbie & Unittest ...

2010-05-06 Thread Damon Timm
t;     vinc...@vincentdavis.net >> >>   my blog <http://vincentdavis.net> | >>   LinkedIn <http://www.linkedin.com/in/vincentdavis> >> On Wed, May 5, 2010 at 6:37 PM, Damon Timm wrote: >> Hi - am trying to write some unit tests for my little python project

[Tutor] Newbie & Unittest ...

2010-05-05 Thread Damon Timm
re are the *correct* key, value pairs I am testing against TAG_VALUES = ( ('title', 'Christmas Waltz'), ('artist', 'Damon Timm'), ('album', 'Homemade'), ) # list of different file types that I want to test my tag grabbing capabil

Re: [Tutor] How to map different keys together ?

2010-04-18 Thread Damon Timm
Thanks again for your input. Comments below with working (yea!) code. On Sun, Apr 18, 2010 at 3:23 PM, ALAN GAULD wrote: > Does what I've shown make sense? Alan - I think I got my mind around it -- I had never used lambda functions before, so this is new territory to me. Thanks for the example

Re: [Tutor] How to map different keys together ?

2010-04-18 Thread Damon Timm
;bob the builder'] # woo hoo! it works! >>> mp4_tags['title'] = [u'I can change the title!'] >>> mp4_tags['title'] [u'I can change the title!'] # changing the titles works too >>> mp4_tags['discnumber'] [(1, 1)] # TOD

[Tutor] How to map different keys together ?

2010-04-17 Thread Damon Timm
Hello - I am writing a script that converts an entire music library into a single desired output format. The source music library has a variety of music filetypes (flac, mp3, m4a, ogg, etc) and I am attempting to use mutagen (a music file tagging module, http://code.google.com/p/mutagen/) in order

Re: [Tutor] Script Feedback

2010-03-30 Thread Damon Timm
Hello Denis & Steven - Thanks for your replies. I have taken another stab at things to try and bring it a little further up to snuff ... some more comments/thoughts follow ... On Tue, Mar 30, 2010 at 12:57 PM, Steven D'Aprano wrote: > I usually create a function "print_" or "pr", something like

[Tutor] Script Feedback

2010-03-30 Thread Damon Timm
As a self-taught Python user I am still looking for insight on the most pythonic and programmatically-friendly way of accomplishing a given task. In this case, I have written a script that will perform a “clean bzip2″ of a directory (or directories). Mac OS X (via AFP and netatalk, in my case) tend

Re: [Tutor] Initialize Class Variables by Dictionary ...

2009-08-29 Thread Damon Timm
>> t.test3 'etc' Thanks! On Sat, Aug 29, 2009 at 4:59 PM, Mac Ryan wrote: > On Sat, 2009-08-29 at 16:31 -0400, Damon Timm wrote: >> Hi again - thanks for your help with my question early today (and last >> night).  Tried searching google for this next ques

[Tutor] Initialize Class Variables by Dictionary ...

2009-08-29 Thread Damon Timm
Hi again - thanks for your help with my question early today (and last night). Tried searching google for this next question but can't get an answer ... here is what I would like to do (but it is not working) ... >>>dict = {'test1': 'value1', 'test2': 'value2', 'test3': 'value3'} >>> class Test()

Re: [Tutor] Store Class in Tuple Before Defining it ...

2009-08-29 Thread Damon Timm
Hi Everyone - thanks for your responses. Answered my direct questions: [1] can't be done at the top and [2] would have to move the tuple somewhere else as well as gave me some new ideas about completely rethinking the design ... I love keeping the RE definitions with the child classes ... makes

Re: [Tutor] Store Class in Tuple Before Defining it ...

2009-08-28 Thread Damon Timm
can't reference a class that hasn't been defined! I know this is a rush-job question, but I am hoping someone seems my quandary and maybe has a way around it. I am learning python as we speak! Thanks! And sorry for the double post. Damon On Fri, Aug 28, 2009 at 5:10 PM, Damon Timm wrote:

[Tutor] Store Class in Tuple Before Defining it ...

2009-08-28 Thread Damon Timm
Hi - I would like to have a tuple that holds information, as such: VIDEO_TYPES = ( (SyncYoutube, re.compile(r'([^(]|^)http://www\.youtube\.com/watch\?\S*v=(?P[A-Za-z0-9_-]+)\S*'),), ) ___ Tutor maillist - Tutor@python.org http://mail.python.org/m

Re: [Tutor] fnmatch -or glob question

2009-07-04 Thread Damon Timm
;> glob_text = file_base + "*" + file_ext >>> for f in os.listdir(working_dir): ... if fnmatch.fnmatch(f, glob_text): ... print f ... DSC_0065.400x400.jpg DSC_0065.jpg DSC_0065.300.jpg >>> os.chdir(working_dir) >>> glob.glob(glob_text) ['DSC_0065.

[Tutor] fnmatch -or glob question

2009-07-03 Thread Damon Timm
Hi - I am trying to find a group of thumbnail files for deletion -- the files all have similar naming structure (though the details vary). When the main file is deleted, I want all the little ones to go too. For example, here is a directory listing: DSC_0063.100.jpg DSC_0063.100x150.jpg DSC_0063

Re: [Tutor] General Feedback, Script Structure

2009-02-15 Thread Damon Timm
Kent and Alan - thanks! I moved things around a bit and I think it "looks" better: http://python.pastebin.com/m64e4565d On Sun, Feb 15, 2009 at 2:25 PM, Kent Johnson wrote: > Exactly. dict.get() does a key lookup with a default for missing keys, > then the result is used as a string format. See

Re: [Tutor] General Feedback, Script Structure

2009-02-15 Thread Damon Timm
Hi Kent - thanks for taking a look! Follow-up below: On Sun, Feb 15, 2009 at 12:20 PM, Kent Johnson wrote: > - put the main code in a main() function rather than splitting it > across the file. That's a good idea - I will do that. Is it proper to create a def main() or just under: if __name__

[Tutor] General Feedback, Script Structure

2009-02-15 Thread Damon Timm
Hi - Am still new to python -- was writing a script that is used by mdadm (linux software raid utility) when there was a raid "event" ... the script then sends an email (using another python script caled "gmailme") to me with the information from the event and attaches the details of the raid devi

Re: [Tutor] Sys.stdin Question

2009-01-14 Thread Damon Timm
;, default=default_recipient) parser.add_option("-m", "--message", action="store", type="string", dest="message") (options, args) = parser.parse_args() sendMail(options.recipient, options.subject, options.text, args) $ sendmail.py

Re: [Tutor] Sys.stdin Question

2009-01-13 Thread Damon Timm
On Tue, Jan 13, 2009 at 8:28 PM, Alan Gauld wrote: > The way other Unix style programs deal with this is to write the code > to read from a general file and if you want to use stdin provide an > argument of '-': That's a good idea, actually -- I hadn't thought of that. Although I use that "-" a

[Tutor] Sys.stdin Question

2009-01-13 Thread Damon Timm
Hi - am writing a script to send myself email messages from the command line ... I want to have the option be able to input the message body via a pipe so I can easily shoot emails to myself (like from: ls, cat, df, du, mount, etc) ... what i want to be able to do is: $ ls -la | myscript.py and i

Re: [Tutor] Can subprocess run functions ?

2009-01-07 Thread Damon Timm
On Wed, Jan 7, 2009 at 7:36 PM, wesley chun wrote: > this has been a highly-desired feature for quite awhile. > > starting in 2.6, you can use the new multiprocessing module > (originally called pyprocessing): > http://docs.python.org/library/multiprocessing.html > > there is a backport to 2.4 and

[Tutor] Can subprocess run functions ?

2009-01-07 Thread Damon Timm
Hi everyone - I was playing with subprocess (with some success, I might add) to implement threading in my script (audio conversion). My goal is to be able to spawn off threads to make use of my multiprocessor system (and speed up encoding). With your help, I was successful. Anyhow, subprocess is

Re: [Tutor] SMTP Module Help

2009-01-07 Thread Damon Timm
On 1/6/09, Marco Petersen wrote: > I'm using Python 2.5.4. I wanted to try out the SMTP module. I tried to send > an email through my Gmail account but it keeps saying that the connection > was refused. I used this example to get emailing from python through gmail smtp to work: http://codecommen

Re: [Tutor] Better way - fnmatch with list ? CORRECTION

2009-01-03 Thread Damon Timm
On Sat, Jan 3, 2009 at 4:35 PM, Mark Tolonen wrote: > fnmatch already takes into account systems with case-sensitive filenames: > help(fnmatch.fnmatch) > > Help on function fnmatch in module fnmatch: > > fnmatch(name, pat) > Test whether FILENAME matches PATTERN. > > Patterns are Unix she

Re: [Tutor] Better way - fnmatch with list ? CORRECTION

2009-01-03 Thread Damon Timm
On Fri, Jan 2, 2009 at 7:16 PM, Jervis Whitley wrote: > for fn in files: > base, ext = os.path.splitext(fn) > if ext.lower() in ['.flac', '.mp3', '.mp4']: > > takes into account systems with case sensitive filenames. Thanks! Will throw that in there. I'm getting it ... bit by little bit. >

Re: [Tutor] Better way - fnmatch with list ?

2009-01-02 Thread Damon Timm
On Fri, Jan 2, 2009 at 6:44 PM, bob gailer wrote: > Since file is a built-in function it is a good idea to not use it as a > variable name. Oooh! I did not know that ... thanks ... went through and changed them all. > for fn in files: > base, ext = os.path.splitext(fn) > if ext in ['*.flac'

[Tutor] Better way - fnmatch with list ?

2009-01-02 Thread Damon Timm
Hi - am learning Pythong and loving it! Anyhow, what I have works, but I wondered if there was a "better" (more python-y) way. Here is what I am doing with fnmatch ... am thinking there has to be a one-line way to do this with a lambda or list comprehension ... but my mind can't get around it ..

Re: [Tutor] MP3Info class usage

2008-12-10 Thread Damon Timm
On 12/10/08, Todd Zullinger <[EMAIL PROTECTED]> wrote: > I'd recommend eyeD3¹ and/or mutagen² for tag reading. Both are pretty > easy to use. I would second eyeD3 -- I use the command line version and it is pretty versatile. D > > ¹ http://eyed3.nicfit.net/ > ² http://code.google.com/p/quodlibe

Re: [Tutor] list.index() question

2008-12-08 Thread Damon Timm
.path.splitext: > > files = os.listdir('.') > extensions = [os.path.splitext(f)[1] for f in files] > if '.flac' in extensions: > print 'FLAC files found!' And then to look at fnmatch! Thanks for the direction -- on my way ... On 12/8/08 7:55 PM, Ken

[Tutor] list.index() question

2008-12-08 Thread Damon Timm
Hi again! (Now that everyone was so helpful the first time you'll never get rid of me!) I had a question about using the index() function on a list -- as I walk the directory path, I want to see if a directory contains any files ending in a certain type ... if it does, I wanna do some stuff ... i

Re: [Tutor] Newbie Wondering About Threads

2008-12-07 Thread Damon Timm
On Sun, Dec 7, 2008 at 9:35 PM, Kent Johnson <[EMAIL PROTECTED]> wrote: > There is no need to include both the flac file name and the mp3 file > name if the roots match. You can use os.path functions to split the > extension or the quick-and-dirty way: > mp3file = flacfile.rsplit('.', 1)[0] + '.mp

Re: [Tutor] Newbie Wondering About Threads

2008-12-07 Thread Damon Timm
On Sun, Dec 7, 2008 at 10:47 AM, Kent Johnson <[EMAIL PROTECTED]> wrote: > A function as mentioned above would help. For the threaded solution > the function could just start the child process and wait for it to > finish, it doesn't have to return anything. Each thread will block on > its associate

Re: [Tutor] Newbie Wondering About Threads

2008-12-07 Thread Damon Timm
On Sun, Dec 7, 2008 at 12:33 AM, Martin Walsh <[EMAIL PROTECTED]> wrote: > I'm not certain this completely explains the poor performance, if at > all, but the communicate method of Popen objects will wait until EOF is > reached and the process ends. So IIUC, in your example the process 'p' > runs t

Re: [Tutor] Newbie Wondering About Threads

2008-12-06 Thread Damon Timm
On Sat, Dec 6, 2008 at 6:25 PM, Python Nutter <[EMAIL PROTECTED]> wrote: > I'm on my phone so excuse the simple reply. > From what I skimmed you are wrapping shell commands which is what I do > all the time. Some hints. 1) look into popen or subprocess in place of > execute for more flexibility. I

[Tutor] Newbie Wondering About Threads

2008-12-06 Thread Damon Timm
Hi Everyone - I am a complete and utter Python newbie (as of today, honestly) -- am interested in expanding my programming horizons beyond bash scripting and thought Python would be a nice match for me. To start, I thought I may try re-writing some of my bash scripts in Python as a learning tool f