(self, v)
Format as python literal
Format as python literal
Format as python literal
def _fmt_python(self, v):
        "Format as python literal"
        if v is None:
            return "None"
        elif isinstance(v, self._basestring):
            return repr(v)
        elif isinstance(v, self._binary_type):
            if sys.version_info < (3, 0):
                res = ["buffer(\""]
                for i in v:
                    if ord(i) in self._printable:
                        res.append(i)
                    else:
                        res.append("\\x%02X" % (ord(i), ))
                res.append("\")")
                return "".join(res)
            else:
                res = ['b"']
                for i in v:
                    if i in self._printable:
                        res.append(chr(i))
                    else:
                        res.append("\\x%02X" % (i, ))
                res.append('"')
                return "".join(res)
        else:
            return "%s" % (v, )
def _fmt_python ( self , v ) : if v is None : return "None" elif isinstance ( v , self . _basestring ) : return repr ( v ) elif isinstance ( v , self . _binary_type ) : if sys . version_info < ( 3 , 0 ) : res = [ "buffer(\"" ] for i in v : if ord ( i ) in self . _printable : res . append ( i ) else : res . append ( "\\x%02X" % ( ord ( i ) , ) ) res . append ( "\")" ) return "" . join ( res ) else : res = [ 'b"' ] for i in v : if i in self . _printable : res . append ( chr ( i ) ) else : res . append ( "\\x%02X" % ( i , ) ) res . append ( '"' ) return "" . join ( res ) else : return "%s" % ( v , )