Update of /cvsroot/freevo/freevo/src/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31857
Modified Files: __init__.py fxdparser.py mediainfo.py misc.py Log Message: unicode fixes Index: __init__.py =================================================================== RCS file: /cvsroot/freevo/freevo/src/util/__init__.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** __init__.py 27 Feb 2004 20:15:03 -0000 1.14 --- __init__.py 28 Feb 2004 21:04:17 -0000 1.15 *************** *** 11,14 **** --- 11,17 ---- # ----------------------------------------------------------------------- # $Log$ + # Revision 1.15 2004/02/28 21:04:17 dischi + # unicode fixes + # # Revision 1.14 2004/02/27 20:15:03 dischi # more unicode fixes *************** *** 80,83 **** --- 83,89 ---- print 'tried encoding %s and %s' % (encoding, config.LOCALE) print e + elif string.__class__ != unicode: + return unicode(str(string), config.LOCALE) + return string Index: fxdparser.py =================================================================== RCS file: /cvsroot/freevo/freevo/src/util/fxdparser.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** fxdparser.py 16 Jan 2004 16:23:07 -0000 1.13 --- fxdparser.py 28 Feb 2004 21:04:17 -0000 1.14 *************** *** 10,13 **** --- 10,16 ---- # ----------------------------------------------------------------------- # $Log$ + # Revision 1.14 2004/02/28 21:04:17 dischi + # unicode fixes + # # Revision 1.13 2004/01/16 16:23:07 dischi # made a ugly unicode fix...I will never understand python character encoding *************** *** 86,89 **** --- 89,93 ---- + class XMLnode: """ *************** *** 153,167 **** if vfs.isfile(filename): vfs.unlink(filename) ! f = vfs.codecs_open(filename, 'w', encoding='utf-8') ! f.write('<?xml version="1.0" ?>\n') ! try: ! self._dump_recurse(f, self.tree) ! except UnicodeDecodeError: ! # sigh, some strange encoding errors again, make it slower ! # but it should work now ! f.close() ! f = vfs.codecs_open(filename, 'w', encoding='utf-8') ! f.write('<?xml version="1.0" ?>\n') ! self._dump_recurse(f, self.tree, encoding_problem=True) f.write('\n') --- 157,163 ---- if vfs.isfile(filename): vfs.unlink(filename) ! f = vfs.codecs_open(filename, 'wb', encoding='utf-8') ! f.write('<?xml version="1.0" encoding="utf-8" ?>\n') ! self._dump_recurse(f, self.tree) f.write('\n') *************** *** 174,179 **** util.save_pickle(self.tree, vfs.getoverlay(filename + '.raw')) ! ! def _dump_recurse(self, f, elem, depth=0, encoding_problem=False): """ Help function to dump all elements --- 170,176 ---- util.save_pickle(self.tree, vfs.getoverlay(filename + '.raw')) ! ! ! def _dump_recurse(self, f, elem, depth=0): """ Help function to dump all elements *************** *** 183,187 **** f.write('<' + elem.name) for (ns, name), value in elem.attrs.items(): ! f.write(' %s="%s"' % (name, value)) if elem.children or elem.first_cdata: if elem.first_cdata == None: --- 180,184 ---- f.write('<' + elem.name) for (ns, name), value in elem.attrs.items(): ! f.write(u' ' + Unicode(name) + u'="' + Unicode(value) + '"') if elem.children or elem.first_cdata: if elem.first_cdata == None: *************** *** 190,204 **** f.write(' ') else: ! data = elem.first_cdata.replace('&', '&') ! if encoding_problem: ! unidata = unicode() ! for c in data: ! unidata += unichr(ord(c)) ! data = unidata ! f.write('>' + data) for child in elem.children: ! self._dump_recurse(f, child, depth=depth+1, ! encoding_problem=encoding_problem) if child.following_cdata == None: if child == elem.children[-1]: --- 187,195 ---- f.write(' ') else: ! data = Unicode(elem.first_cdata).replace(u'&', u'&') ! f.write(u'>' + data) for child in elem.children: ! self._dump_recurse(f, child, depth=depth+1) if child.following_cdata == None: if child == elem.children[-1]: *************** *** 328,332 **** for child in node.children: if child.name == name: ! return util.format_text(child.textof().encode(config.LOCALE)) return '' --- 319,323 ---- for child in node.children: if child.name == name: ! return util.format_text(child.textof()) return '' *************** *** 341,345 **** if node: try: ! r = node.attrs[('',name)].encode(config.LOCALE) except KeyError: pass --- 332,336 ---- if node: try: ! r = node.attrs[('',name)] except KeyError: pass *************** *** 372,376 **** rerurn the text of the node """ ! return util.format_text(node.textof().encode(config.LOCALE)) --- 363,367 ---- rerurn the text of the node """ ! return util.format_text(node.textof()) *************** *** 394,398 **** for node in nodes: for child in node.children: ! txt = child.textof().encode(config.LOCALE) if not txt: continue --- 385,389 ---- for node in nodes: for child in node.children: ! txt = child.textof() if not txt: continue Index: mediainfo.py =================================================================== RCS file: /cvsroot/freevo/freevo/src/util/mediainfo.py,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** mediainfo.py 27 Feb 2004 20:42:05 -0000 1.34 --- mediainfo.py 28 Feb 2004 21:04:17 -0000 1.35 *************** *** 11,14 **** --- 11,17 ---- # ----------------------------------------------------------------------- # $Log$ + # Revision 1.35 2004/02/28 21:04:17 dischi + # unicode fixes + # # Revision 1.34 2004/02/27 20:42:05 dischi # save disc file info *************** *** 346,358 **** info[variable] = video[variable] - if info.has_key('tracks') and info['tracks'] and not info.has_key('length'): - info['length'] = 0 - for track in info['tracks']: - if track.has_key('length') and track['length']: - info['length'] += track['length'] - if info['tracks'][0].has_key('length') and info['tracks'][0]['length'] and \ - info['tracks'][0]['length'] * len(info['tracks']) == info['length']: - # badly masted dvd - info['length'] = info['tracks'][0]['length'] return info return {} --- 349,352 ---- Index: misc.py =================================================================== RCS file: /cvsroot/freevo/freevo/src/util/misc.py,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** misc.py 27 Feb 2004 20:08:42 -0000 1.33 --- misc.py 28 Feb 2004 21:04:17 -0000 1.34 *************** *** 11,14 **** --- 11,17 ---- # ----------------------------------------------------------------------- # $Log$ + # Revision 1.34 2004/02/28 21:04:17 dischi + # unicode fixes + # # Revision 1.33 2004/02/27 20:08:42 dischi # add function to check for identical string beginnings *************** *** 268,275 **** def format_text(text): ! while len(text) and text[0] in (' ', '\t', '\n'): text = text[1:] ! text = re.sub('\n[\t *]', ' ', text) ! while len(text) and text[-1] in (' ', '\t', '\n'): text = text[:-1] return text --- 271,278 ---- def format_text(text): ! while len(text) and text[0] in (u' ', u'\t', u'\n'): text = text[1:] ! text = re.sub(u'\n[\t *]', u' ', text) ! while len(text) and text[-1] in (u' ', u'\t', u'\n'): text = text[:-1] return text ------------------------------------------------------- SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now! http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click _______________________________________________ Freevo-cvslog mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/freevo-cvslog