Esempio n. 1
0
    def quote(self):
        """
        A string quoting this object.

        'q'.quote() == "'q'"
        """

        return quoteChar(self._c)
Esempio n. 2
0
    def quote(self):
        """
        A string quoting this object.

        'q'.quote() == "'q'"
        """

        return quoteChar(self._c)
Esempio n. 3
0
def ensureByte(char):
    """
    Like chr(ord(char)), but throws on failure.
    """

    if not u'\x00' <= char <= u'\xff':
        raise userError(u"Unacceptable bytestring character: " +
                quoteChar(char))
    return chr(ord(char))
Esempio n. 4
0
    def recv(self, atom, args):
        if atom is ADD_1:
            other = unwrapInt(args[0])
            return self.withOffset(other)

        if atom is ASINTEGER_0:
            return IntObject(ord(self._c))

        if atom is ASSTRING_0:
            return StrObject(unicode(self._c))

        if atom is GETCATEGORY_0:
            return StrObject(unicode(unicodedb.category(ord(self._c))))

        if atom is MAX_1:
            other = unwrapChar(args[0])
            return self if self._c > other else args[0]

        if atom is MIN_1:
            other = unwrapChar(args[0])
            return self if self._c < other else args[0]

        if atom is NEXT_0:
            return self.withOffset(1)

        if atom is OP__CMP_1:
            return polyCmp(self._c, unwrapChar(args[0]))

        if atom is PREVIOUS_0:
            return self.withOffset(-1)

        if atom is QUOTE_0:
            return StrObject(quoteChar(self._c))

        if atom is SUBTRACT_1:
            other = unwrapInt(args[0])
            return self.withOffset(-other)

        raise Refused(self, atom, args)
Esempio n. 5
0
 def visitCharExpr(self, c, span):
     self.write(quoteChar(c[0]))
Esempio n. 6
0
 def toQuote(self):
     return quoteChar(self._c)
Esempio n. 7
0
 def visitCharExpr(self, c):
     self.write(quoteChar(c[0]))
Esempio n. 8
0
 def testCharNull(self):
     self.assertEqual(quoteChar(u'\x00'), u"'\\x00'")
Esempio n. 9
0
 def pretty(self, out):
     out.write(quoteChar(self._c[0]).encode("utf-8"))
Esempio n. 10
0
 def testCharSingleQuote(self):
     self.assertEqual(quoteChar(u"'"), u"'\\''")
Esempio n. 11
0
 def testChar(self):
     self.assertEqual(quoteChar(u'a'), u"'a'")
Esempio n. 12
0
 def testCharNull(self):
     self.assertEqual(quoteChar(u'\x00'), u"'\\x00'")
Esempio n. 13
0
 def testCharNewline(self):
     self.assertEqual(quoteChar(u'\n'), u"'\\n'")
Esempio n. 14
0
 def testCharSingleQuote(self):
     self.assertEqual(quoteChar(u"'"), u"'\\''")
Esempio n. 15
0
 def testChar(self):
     self.assertEqual(quoteChar(u'a'), u"'a'")
Esempio n. 16
0
 def toQuote(self):
     return quoteChar(self._c)
Esempio n. 17
0
File: nodes.py Progetto: dckc/typhon
 def pretty(self, out):
     out.write(quoteChar(self._c[0]).encode("utf-8"))
Esempio n. 18
0
 def testCharNewline(self):
     self.assertEqual(quoteChar(u'\n'), u"'\\n'")