A new function and a planned change that will break some code.

Tomorrow (or later...) I plan to make a backward-incompatible
change: actually plots and biographies are the only two information
returned in the 'NOTE::TEXT' format (where NOTE is the author's name).
I think it's time to move these to the usual 'TEXT::NOTE'.

[new function]
Following a hint by Turgut, I've introduced the new makeTextNote function
in the helpers module; it can be used to pretty-print strings returned in
the 'TEXT::NOTE' format (there are a lot of them).
It returns a function, customized with a format string.
Portions of the text can be conditionally excluded, if one of the
values ('text' or 'note') is absent.

The returned function can be used as applyToValues argument of the
makeObject2Txt function.

Example of usage:
    from imdb.helpers import makeTextNote

    # Create a fuction with simple replacements.
    plainRepl = makeTextNote(u'TXT: %(text)s NOTE: %(note)s')

    # Create a function with a conditional replacement.
    conditionalRepl = makeTextNote(u'TXT: %(text)s<if note> NOTE: %(note)s</if 
note>')


    t1 = u'119 min'
    t2 = u'120 min::(Italy)'

    print plainRepl(t1)
    print conditionalRepl(t1) # notice the difference.
    print plainRepl(t2)
    print conditionalRepl(t2)



Happy holidays!
-- 
Davide Alberani <davide.alber...@gmail.com> [PGP KeyID: 0x465BFD47]
http://erlug.linux.it/~da/

------------------------------------------------------------------------------
_______________________________________________
Imdbpy-devel mailing list
Imdbpy-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/imdbpy-devel

Reply via email to