コード例 #1
0
ファイル: SQS.py プロジェクト: xyicheng/kombu
 def entity_name(self, name, table=CHARS_REPLACE_TABLE):
     """Format AMQP queue name into a legal SQS queue name."""
     if name.endswith('.fifo'):
         partial = name.rstrip('.fifo')
         partial = text_t(safe_str(partial)).translate(table)
         return partial + '.fifo'
     else:
         return text_t(safe_str(name)).translate(table)
コード例 #2
0
ファイル: SQS.py プロジェクト: AlerzDev/Brazo-Proyecto-Final
 def entity_name(self, name, table=CHARS_REPLACE_TABLE):
     """Format AMQP queue name into a legal SQS queue name."""
     if name.endswith('.fifo'):
         partial = name.rstrip('.fifo')
         partial = text_t(safe_str(partial)).translate(table)
         return partial + '.fifo'
     else:
         return text_t(safe_str(name)).translate(table)
コード例 #3
0
 def default(
     self,
     o,
     dates=(datetime.datetime, datetime.date),
     times=(datetime.time, ),
     textual=(decimal.Decimal, uuid.UUID, DjangoPromise),
     isinstance=isinstance,
     datetime=datetime.datetime,
     text_t=text_t,
 ):
     reducer = getattr(o, "__json__", None)
     if reducer is not None:
         return reducer()
     else:
         if isinstance(o, dates):
             if not isinstance(o, datetime):
                 o = datetime(o.year, o.month, o.day, 0, 0, 0, 0)
             r = o.isoformat()
             if r.endswith("+00:00"):
                 r = r[:-6] + "Z"
             return r
         elif isinstance(o, times):
             return o.isoformat()
         elif isinstance(o, textual):
             return text_t(o)
         return super(JSONEncoder, self).default(o)
コード例 #4
0
ファイル: json.py プロジェクト: CrazyLionHeart/kombu
def loads(s, _loads=json.loads, decode_bytes=IS_PY3):
    # None of the json implementations supports decoding from
    # a buffer/memoryview, or even reading from a stream
    #    (load is just loads(fp.read()))
    # but this is Python, we love copying strings, preferably many times
    # over.  Note that pickle does support buffer/memoryview
    # </rant>
    if isinstance(s, memoryview):
        s = s.tobytes().decode('utf-8')
    elif isinstance(s, bytearray):
        s = s.decode('utf-8')
    elif decode_bytes and isinstance(s, bytes_t):
        s = s.decode('utf-8')
    elif isinstance(s, buffer_t):
        s = text_t(s)  # ... awwwwwww :(
    return _loads(s)
コード例 #5
0
ファイル: json.py プロジェクト: zmullett/kombu
def loads(s, _loads=json.loads, decode_bytes=IS_PY3):
    # None of the json implementations supports decoding from
    # a buffer/memoryview, or even reading from a stream
    #    (load is just loads(fp.read()))
    # but this is Python, we love copying strings, preferably many times
    # over.  Note that pickle does support buffer/memoryview
    # </rant>
    if isinstance(s, memoryview):
        s = s.tobytes().decode('utf-8')
    elif isinstance(s, bytearray):
        s = s.decode('utf-8')
    elif decode_bytes and isinstance(s, bytes_t):
        s = s.decode('utf-8')
    elif isinstance(s, buffer_t):
        s = text_t(s)  # ... awwwwwww :(
    return _loads(s)
コード例 #6
0
def loads(s, _loads=json.loads, decode_bytes=PY3):
    """Deserialize json from string."""
    # None of the json implementations supports decoding from
    # a buffer/memoryview, or even reading from a stream
    #    (load is just loads(fp.read()))
    # but this is Python, we love copying strings, preferably many times
    # over.  Note that pickle does support buffer/memoryview
    # </rant>
    if isinstance(s, memoryview):
        s = s.tobytes().decode("utf-8")
    elif isinstance(s, bytearray):
        s = s.decode("utf-8")
    elif decode_bytes and isinstance(s, bytes_t):
        s = s.decode("utf-8")
    elif isinstance(s, buffer_t):
        s = text_t(s)  # ... awwwwwww :(

    try:
        return _loads(s)
    except _DecodeError:
        # catch "Unpaired high surrogate" error
        return stdjson.loads(s)
コード例 #7
0
ファイル: json.py プロジェクト: 2216288075/meiduo_project
def loads(s, _loads=json.loads, decode_bytes=PY3):
    """Deserialize json from string."""
    # None of the json implementations supports decoding from
    # a buffer/memoryview, or even reading from a stream
    #    (load is just loads(fp.read()))
    # but this is Python, we love copying strings, preferably many times
    # over.  Note that pickle does support buffer/memoryview
    # </rant>
    if isinstance(s, memoryview):
        s = s.tobytes().decode('utf-8')
    elif isinstance(s, bytearray):
        s = s.decode('utf-8')
    elif decode_bytes and isinstance(s, bytes_t):
        s = s.decode('utf-8')
    elif isinstance(s, buffer_t):
        s = text_t(s)  # ... awwwwwww :(

    try:
        return _loads(s)
    except _DecodeError:
        # catch "Unpaired high surrogate" error
        return stdjson.loads(s)
コード例 #8
0
ファイル: json.py プロジェクト: Erve1879/kombu
 def default(self, o,
             dates=(datetime.datetime, datetime.date),
             times=(datetime.time,),
             textual=(decimal.Decimal, uuid.UUID, DjangoPromise),
             isinstance=isinstance,
             datetime=datetime.datetime,
             text_t=text_t):
     reducer = getattr(o, '__json__', None)
     if reducer is not None:
         return reducer()
     else:
         if isinstance(o, dates):
             if not isinstance(o, datetime):
                 o = datetime(o.year, o.month, o.day, 0, 0, 0, 0)
             r = o.isoformat()
             if r.endswith("+00:00"):
                 r = r[:-6] + "Z"
             return r
         elif isinstance(o, times):
             return o.isoformat()
         elif isinstance(o, textual):
             return text_t(o)
         return super(JSONEncoder, self).default(o)
コード例 #9
0
ファイル: json.py プロジェクト: muralikg/kombu
def loads(s, _loads=json.loads, decode_bytes=IS_PY3):
    # None of the json implementations supports decoding from
    # a buffer/memoryview, or even reading from a stream
    #    (load is just loads(fp.read()))
    # but this is Python, we love copying strings, preferably many times
    # over.  Note that pickle does support buffer/memoryview
    # </rant>
    if isinstance(s, memoryview):
        s = s.tobytes().decode('utf-8')
    elif isinstance(s, bytearray):
        s = s.decode('utf-8')
    elif decode_bytes and isinstance(s, bytes_t):
        s = s.decode('utf-8')
    elif isinstance(s, buffer_t):
        s = text_t(s)  # ... awwwwwww :(

    if json.__name__ == 'simplejson':
        try:
            return _loads(s)
        # catch simplejson.decoder.JSONDecodeError: Unpaired high surrogate
        except json.decoder.JSONDecodeError:
            return stdjson.loads(s)
    else:
        return _loads(s)
コード例 #10
0
ファイル: json.py プロジェクト: daevaorn/kombu
def loads(s, _loads=json.loads, decode_bytes=IS_PY3):
    # None of the json implementations supports decoding from
    # a buffer/memoryview, or even reading from a stream
    #    (load is just loads(fp.read()))
    # but this is Python, we love copying strings, preferably many times
    # over.  Note that pickle does support buffer/memoryview
    # </rant>
    if isinstance(s, memoryview):
        s = s.tobytes().decode('utf-8')
    elif isinstance(s, bytearray):
        s = s.decode('utf-8')
    elif decode_bytes and isinstance(s, bytes_t):
        s = s.decode('utf-8')
    elif isinstance(s, buffer_t):
        s = text_t(s)  # ... awwwwwww :(

    if json.__name__ == 'simplejson':
        try:
            return _loads(s)
        # catch simplejson.decoder.JSONDecodeError: Unpaired high surrogate
        except json.decoder.JSONDecodeError:
            return stdjson.loads(s)
    else:
        return _loads(s)
コード例 #11
0
ファイル: test_models.py プロジェクト: fcurella/thorn
 def test_str(self, subscriber):
     assert text_t(subscriber)
コード例 #12
0
 def test_postencode(self):
     m = Message(self.channel, text_t('FOO'), postencode='ccyzz')
     with self.assertRaises(LookupError):
         m._reraise_error()
     m.ack()
コード例 #13
0
ファイル: test_base.py プロジェクト: appannie/kombu
 def test_postencode(self):
     m = Message(text_t('FOO'), channel=self.channel, postencode='ccyzz')
     with pytest.raises(LookupError):
         m._reraise_error()
     m.ack()
コード例 #14
0
ファイル: test_base.py プロジェクト: P79N6A/hue-from-scratch
 def test_postencode(self):
     m = Message(text_t('FOO'), channel=self.channel, postencode='ccyzz')
     with pytest.raises(LookupError):
         m._reraise_error()
     m.ack()
コード例 #15
0
 def test_str(self):
     self.assertTrue(text_t(self.subscriber))
コード例 #16
0
ファイル: test_json.py プロジェクト: Erve1879/kombu
 def test_Decimal(self):
     d = Decimal('3314132.13363235235324234123213213214134')
     assert loads(dumps({'d': d})), {'d': text_t(d)}
コード例 #17
0
ファイル: test_base.py プロジェクト: NarrativeTeam/kombu
 def test_postencode(self):
     with self.assertRaises(LookupError):
         Message(self.channel, text_t('FOO'), postencode='ccyzz')
コード例 #18
0
 def test_Decimal(self):
     d = Decimal('3314132.13363235235324234123213213214134')
     self.assertDictEqual(loads(dumps({'d': d})), {
         'd': text_t(d),
     })
コード例 #19
0
ファイル: test_base.py プロジェクト: CrazyLionHeart/kombu
 def test_postencode(self):
     m = Message(self.channel, text_t('FOO'), postencode='ccyzz')
     with self.assertRaises(LookupError):
         m._reraise_error()
     m.ack()
コード例 #20
0
ファイル: test_json.py プロジェクト: Erve1879/kombu
 def test_UUID(self):
     id = uuid4()
     assert loads(dumps({'u': id})), {'u': text_t(id)}
コード例 #21
0
 def test_UUID(self):
     id = uuid4()
     self.assertDictEqual(loads(dumps({'u': id})), {
         'u': text_t(id),
     })
コード例 #22
0
ファイル: test_json.py プロジェクト: Scalr/kombu
 def test_Decimal(self):
     d = Decimal('3314132.13363235235324234123213213214134')
     assert loads(dumps({'d': d})), {'d': text_t(d)}
コード例 #23
0
ファイル: SLMQ.py プロジェクト: 18636800170/videoWebsie
 def entity_name(self, name, table=CHARS_REPLACE_TABLE):
     """Format AMQP queue name into a valid SLQS queue name."""
     return text_t(safe_str(name)).translate(table)
コード例 #24
0
ファイル: test_json.py プロジェクト: Sonicbids/kombu
 def test_Decimal(self):
     d = Decimal('3314132.13363235235324234123213213214134')
     self.assertDictEqual(loads(dumps({'d': d})), {
         'd': text_t(d),
     })
コード例 #25
0
ファイル: test_json.py プロジェクト: Scalr/kombu
 def test_UUID(self):
     id = uuid4()
     assert loads(dumps({'u': id})), {'u': text_t(id)}
コード例 #26
0
ファイル: test_json.py プロジェクト: Sonicbids/kombu
 def test_UUID(self):
     id = uuid4()
     self.assertDictEqual(loads(dumps({'u': id})), {
         'u': text_t(id),
     })
コード例 #27
0
ファイル: test_base.py プロジェクト: NarrativeTeam/kombu
 def test_postencode(self):
     with self.assertRaises(LookupError):
         Message(self.channel, text_t('FOO'), postencode='ccyzz')
コード例 #28
0
ファイル: test_models.py プロジェクト: viyat-test-1/thorn
 def test_str(self, subscriber):
     assert text_t(subscriber)
コード例 #29
0
ファイル: SLMQ.py プロジェクト: lokifist/kombu
 def entity_name(self, name, table=CHARS_REPLACE_TABLE):
     """Format AMQP queue name into a valid SLQS queue name."""
     return text_t(safe_str(name)).translate(table)
コード例 #30
0
ファイル: test_base.py プロジェクト: xujun10110/kombu
 def test_postencode(self):
     with self.assertRaises(LookupError):
         Message(self.channel, text_t("FOO"), postencode="ccyzz")