Changeset 113 in tracdarcs for tracdarcs/changesparser.py


Ignore:
Timestamp:
04/22/08 18:49:04 (5 years ago)
Author:
lele@…
Hash name:
20080422164904-97f81-98f144e10998149b782bc2243fea87e0b3c7a0b6
Message:

Clean dirty chars in "darcs changes --xml-output"

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tracdarcs/changesparser.py

    r108 r113  
    105105 
    106106    handler = SAXHandler() 
    107     parseString(changes, handler) 
     107 
     108    def fixup_badchars(s, map): 
     109        if not map: 
     110            return s 
     111 
     112        ret = [map.get(c, c) for c in s] 
     113        return "".join(ret) 
     114 
     115    replace_badchars = { 
     116        '\xc1': 'Á', '\xc9': 'É', '\xcd': 'Í', 
     117        '\xd3': 'Ó', '\xd6': 'Ö', '\xd5': 'Ő', 
     118        '\xda': 'Ú', '\xdc': 'Ü', '\xdb': 'Ű', 
     119        '\xe1': 'á', '\xe9': 'é', '\xed': 'í', 
     120        '\xf3': 'ó', '\xf6': 'ö', '\xf5': 'ő', 
     121        '\xfa': 'ú', '\xfc': 'ü', '\xfb': 'ű', 
     122        '\xf1': 'ñ', '\xdf': 'ß', '\xe5': 'å', 
     123        } 
     124 
     125    cleaned = fixup_badchars(changes, replace_badchars) 
     126    parseString(cleaned, handler) 
    108127    return handler.patches 
Note: See TracChangeset for help on using the changeset viewer.