Exemplo n.º 1
0
    def test_to_string(self):
        layer = to_unicode('ŽĆČĐŠ')
        text = to_unicode('На крај села жута ћирилична кућа')

        self.assertEqual(to_string(layer),
                         r'\U+017d\U+0106\U+010c\U+0110\U+0160')
        self.assertEqual(
            to_string(text),
            r'\U+041d\U+0430 \U+043a\U+0440\U+0430\U+0458 \U+0441\U+0435\U+043b\U+0430 \U+0436\U+0443\U+0442\U+0430 \U+045b\U+0438\U+0440\U+0438\U+043b\U+0438\U+0447\U+043d\U+0430 \U+043a\U+0443\U+045b\U+0430'
        )
Exemplo n.º 2
0
 def cast(self, value, code):
     """ Convert value depending on group code """
     typestr = self.group_code_type(code)
     if typestr == 'string':
         return to_string(value)
     elif typestr == 'bool':
         return 1 if int(value) else 0
     elif typestr == 'float':
         return float(value)
     elif typestr == 'int':
         return int(value)
     raise ValueError("Unknown format '%s'" % to_string(code))
Exemplo n.º 3
0
 def cast(self, value, code):
     """ Convert value depending on group code """
     typestr = self.group_code_type(code)
     if typestr == 'string':
         return to_string(value)
     elif typestr == 'bool':
         return 1 if int(value) else 0
     elif typestr == 'float':
         return float(value)
     elif typestr == 'int':
         return int(value)
     raise ValueError("Unknown format '%s'" % to_string(code))
Exemplo n.º 4
0
 def __init__(self, value, group_code=2):
     super(DXFName, self).__init__(to_string(value), group_code)
Exemplo n.º 5
0
 def __init__(self, value, group_code=1):
     super(DXFString, self).__init__(to_string(value), group_code)
Exemplo n.º 6
0
 def __dxf__(self):
     """ Returns a valid DXF String. Last char has to be '\n'. """
     return "%3d\n%s\n" % (self._group_code, to_string(self._value))
Exemplo n.º 7
0
 def __init__(self, value, group_code=2):
     super(DXFName, self).__init__(to_string(value), group_code)
Exemplo n.º 8
0
 def __init__(self, value, group_code=1):
     super(DXFString, self).__init__(to_string(value), group_code)
Exemplo n.º 9
0
 def __dxf__(self):
     """ Returns a valid DXF String. Last char has to be '\n'. """
     return "%3d\n%s\n" % (self._group_code, to_string(self._value))
Exemplo n.º 10
0
    def test_to_string(self):
        layer = to_unicode('ŽĆČĐŠ')
        text = to_unicode('На крај села жута ћирилична кућа')

        self.assertEqual(to_string(layer), r'\U+017d\U+0106\U+010c\U+0110\U+0160')
        self.assertEqual(to_string(text), r'\U+041d\U+0430 \U+043a\U+0440\U+0430\U+0458 \U+0441\U+0435\U+043b\U+0430 \U+0436\U+0443\U+0442\U+0430 \U+045b\U+0438\U+0440\U+0438\U+043b\U+0438\U+0447\U+043d\U+0430 \U+043a\U+0443\U+045b\U+0430')
Exemplo n.º 11
0
 def __dxf__(self):
     return "%3d\n%s\n" % (self._group_code, to_string(self._value))