Re: New appletrailers script and kaa.xmlutils

John Molohan <[email protected]>
Newsgroups gmane.comp.video.freevo.devel
Message-ID <[email protected]>
  On 11/08/2010 8:52, Jason Tackaberry wrote:
> On Wed, 2010-08-11 at 20:28 +0100, John Molohan wrote:
>> With the patch it seems to work perfectly for me.
> Only because with your patch, two wrongs make a right. :)
:)
> Namely:
>
>> file = video.add_child('url mplayer-options="%s"' %mplayeropts, trailer.preview.large)
>> # video.add_child('mplayer_options', mplayeropts)
> The commented out line seems to suggest you realized that
> 'mplayer-options' was something different than 'url' (and indeed it is).
I'd guessed at it.
> What you actually ended up doing was creating a child node with the node
> name 'url mplayer-options="..."'.  kaa.xmlutils behaved correctly by
> including the mplayer-options stuff in the closing tag.
Ah, ok.
> The problem is generally that kaa.xmlutils doesn't provide a way to add
> attributes to an existing node.  It's why I said in my earlier email:
>
> On Wed, 2010-08-11 at 14:12 -0400, Jason Tackaberry wrote:
>> (I've not actually looked this xmlutils API before.  I'm tempted to
>> deprecate __getattr__ in favor of __getitem__ and implement
>> __setitem__.)
Right.
> I'll implement this tonight.
Cool.
> Meanwhile, you can initialize nodes with new attributes by passing
> keyword arguments to add_child.  However, keyword arguments can't
> contain dashes, and add_child() does no translation.
>
> So try this kludge:
>
>          video.add_child('url', trailer.preview.large, **{'mplayer-options': mplayeropts})
That seems to work perfectly, thanks.
>
> Once I make the changes, it will be a bit more sane:
>
>          url = video.add_child('url', trailer.preview.large)
>          url['mplayer-options'] = mplayeropts
Looks good.
>
> Or possibly I could keep __getattr__ and implement __setattr__,
> converting '_' to '-' so that there's symmetry with __getattr__, which
> would keep the same API as now but prevents ever being able to handle
> attributes that actually, truly use underscores (e.g. mplayer_options
> instead of mplayer-options).
>
> What do you think dischi?
>
> Cheers,
> Jason.
Thanks,

John

------------------------------------------------------------------------------
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.