Changeset 1489

Show
Ignore:
Timestamp:
10/13/09 13:11:07 (6 weeks ago)
Author:
Alexandre Rossi <alexandre.rossi@…>
Hashname:
20091013111107-85ee7-b139ccfa17bfd6abfd2d9121e58848e5d8b4a83b
Message:

[xml] fix bad char from tags in xml failure

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • deejayd/xmlobject.py

    r1310 r1489  
    2626class DeejaydXMLObject(object): 
    2727 
     28    def __is_xml_char(self, char): 
     29        # FIXME: This function should probably be more complicated than this. 
     30        return char not in '\x19' 
     31 
    2832    def _to_xml_string(self, s): 
     33        xml_string = '' 
    2934        if isinstance(s, int) or isinstance(s, float) or isinstance(s, long): 
    30             return "%d" % (s,) 
     35            xml_string = "%d" % (s,) 
    3136        elif isinstance(s, str): 
    32             return "%s" % (s.decode('utf-8')) 
     37            xml_string = "%s" % (s.decode('utf-8')) 
    3338        elif isinstance(s, unicode): 
    3439            rs = s.encode("utf-8") 
    35             return "%s" % (rs.decode('utf-8')) 
     40            xml_string = "%s" % (rs.decode('utf-8')) 
    3641        else: 
    3742            raise TypeError 
     43 
     44        filtered_xml_string = [] 
     45        for string_char in xml_string: 
     46            if self.__is_xml_char(string_char): 
     47                filtered_xml_string.append(string_char) 
     48        return ''.join(filtered_xml_string) 
    3849 
    3950    def _indent(self,elem, level=0):