Python binascii.a2b_qp() Examples
The following are 30
code examples of binascii.a2b_qp().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
binascii
, or try the search function
.
Example #1
Source File: test_binascii.py From medicare-demo with Apache License 2.0 | 6 votes |
def test_qp(self): # A test for SF bug 534347 (segfaults without the proper fix) try: binascii.a2b_qp("", **{1:1}) except TypeError: pass else: self.fail("binascii.a2b_qp(**{1:1}) didn't raise TypeError") self.assertEqual(binascii.a2b_qp("= "), "= ") self.assertEqual(binascii.a2b_qp("=="), "=") self.assertEqual(binascii.a2b_qp("=AX"), "=AX") self.assertRaises(TypeError, binascii.b2a_qp, foo="bar") self.assertEqual(binascii.a2b_qp("=00\r\n=00"), "\x00\r\n\x00") self.assertEqual( binascii.b2a_qp("\xff\r\n\xff\n\xff"), "=FF\r\n=FF\r\n=FF" ) self.assertEqual( binascii.b2a_qp("0"*75+"\xff\r\n\xff\r\n\xff"), "0"*75+"=\r\n=FF\r\n=FF\r\n=FF" )
Example #2
Source File: test_binascii.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_qp(self): # A test for SF bug 534347 (segfaults without the proper fix) try: binascii.a2b_qp("", **{1:1}) except TypeError: pass else: self.fail("binascii.a2b_qp(**{1:1}) didn't raise TypeError") self.assertEqual(binascii.a2b_qp("= "), "= ") self.assertEqual(binascii.a2b_qp("=="), "=") self.assertEqual(binascii.a2b_qp("=AX"), "=AX") self.assertRaises(TypeError, binascii.b2a_qp, foo="bar") self.assertEqual(binascii.a2b_qp("=00\r\n=00"), "\x00\r\n\x00") self.assertEqual( binascii.b2a_qp("\xff\r\n\xff\n\xff"), "=FF\r\n=FF\r\n=FF" ) self.assertEqual( binascii.b2a_qp("0"*75+"\xff\r\n\xff\r\n\xff"), "0"*75+"=\r\n=FF\r\n=FF\r\n=FF" ) self.assertEqual(binascii.b2a_qp('\0\n'), '=00\n') self.assertEqual(binascii.b2a_qp('\0\n', quotetabs=True), '=00\n') self.assertEqual(binascii.b2a_qp('foo\tbar\t\n'), 'foo\tbar=09\n') self.assertEqual(binascii.b2a_qp('foo\tbar\t\n', quotetabs=True), 'foo=09bar=09\n') self.assertEqual(binascii.b2a_qp('.'), '=2E') self.assertEqual(binascii.b2a_qp('.\n'), '=2E\n') self.assertEqual(binascii.b2a_qp('a.\n'), 'a.\n')
Example #3
Source File: test_binascii.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_qp(self): binascii.a2b_qp(data=b"", header=False) # Keyword arguments allowed # A test for SF bug 534347 (segfaults without the proper fix) try: binascii.a2b_qp(b"", **{1:1}) except TypeError: pass else: self.fail("binascii.a2b_qp(**{1:1}) didn't raise TypeError") self.assertEqual(binascii.a2b_qp(b"= "), b"= ") self.assertEqual(binascii.a2b_qp(b"=="), b"=") self.assertEqual(binascii.a2b_qp(b"=AX"), b"=AX") self.assertRaises(TypeError, binascii.b2a_qp, foo="bar") self.assertEqual(binascii.a2b_qp(b"=00\r\n=00"), b"\x00\r\n\x00") self.assertEqual( binascii.b2a_qp(b"\xff\r\n\xff\n\xff"), b"=FF\r\n=FF\r\n=FF") self.assertEqual( binascii.b2a_qp(b"0"*75+b"\xff\r\n\xff\r\n\xff"), b"0"*75+b"=\r\n=FF\r\n=FF\r\n=FF") self.assertEqual(binascii.b2a_qp(b'\0\n'), b'=00\n') self.assertEqual(binascii.b2a_qp(b'\0\n', quotetabs=True), b'=00\n') self.assertEqual(binascii.b2a_qp(b'foo\tbar\t\n'), b'foo\tbar=09\n') self.assertEqual(binascii.b2a_qp(b'foo\tbar\t\n', quotetabs=True), b'foo=09bar=09\n') self.assertEqual(binascii.b2a_qp(b'.'), b'=2E') self.assertEqual(binascii.b2a_qp(b'.\n'), b'=2E\n') self.assertEqual(binascii.b2a_qp(b'a.\n'), b'a.\n')
Example #4
Source File: test_binascii.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_not_implemented(self): test_cases = [ lambda: binascii.a2b_qp(None), lambda: binascii.a2b_qp(None, None), lambda: binascii.a2b_hqx(None), lambda: binascii.rledecode_hqx(None), lambda: binascii.rlecode_hqx(None), lambda: binascii.b2a_hqx(None), ] for temp_func in test_cases: self.assertRaises(NotImplementedError, temp_func)
Example #5
Source File: multipart.py From Galaxy_Plugin_Bethesda with MIT License | 5 votes |
def _decode_content_transfer(self, data: bytes) -> bytes: encoding = cast(str, self.headers[CONTENT_TRANSFER_ENCODING]).lower() if encoding == 'base64': return base64.b64decode(data) elif encoding == 'quoted-printable': return binascii.a2b_qp(data) elif encoding in ('binary', '8bit', '7bit'): return data else: raise RuntimeError('unknown content transfer encoding: {}' ''.format(encoding))
Example #6
Source File: test_binascii.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_qp(self): # A test for SF bug 534347 (segfaults without the proper fix) try: binascii.a2b_qp("", **{1:1}) except TypeError: pass else: self.fail("binascii.a2b_qp(**{1:1}) didn't raise TypeError") self.assertEqual(binascii.a2b_qp("= "), "= ") self.assertEqual(binascii.a2b_qp("=="), "=") self.assertEqual(binascii.a2b_qp("=AX"), "=AX") self.assertRaises(TypeError, binascii.b2a_qp, foo="bar") self.assertEqual(binascii.a2b_qp("=00\r\n=00"), "\x00\r\n\x00") self.assertEqual( binascii.b2a_qp("\xff\r\n\xff\n\xff"), "=FF\r\n=FF\r\n=FF" ) self.assertEqual( binascii.b2a_qp("0"*75+"\xff\r\n\xff\r\n\xff"), "0"*75+"=\r\n=FF\r\n=FF\r\n=FF" ) self.assertEqual(binascii.b2a_qp('\0\n'), '=00\n') self.assertEqual(binascii.b2a_qp('\0\n', quotetabs=True), '=00\n') self.assertEqual(binascii.b2a_qp('foo\tbar\t\n'), 'foo\tbar=09\n') self.assertEqual(binascii.b2a_qp('foo\tbar\t\n', quotetabs=True), 'foo=09bar=09\n') self.assertEqual(binascii.b2a_qp('.'), '=2E') self.assertEqual(binascii.b2a_qp('.\n'), '=2E\n') self.assertEqual(binascii.b2a_qp('a.\n'), 'a.\n')
Example #7
Source File: quopri.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def decodestring(s, header=False): if a2b_qp is not None: return a2b_qp(s, header=header) from io import BytesIO infp = BytesIO(s) outfp = BytesIO() decode(infp, outfp, header=header) return outfp.getvalue() # Other helper functions
Example #8
Source File: quopri.py From medicare-demo with Apache License 2.0 | 5 votes |
def decodestring(s, header = 0): if a2b_qp is not None: return a2b_qp(s, header = header) from cStringIO import StringIO infp = StringIO(s) outfp = StringIO() decode(infp, outfp, header = header) return outfp.getvalue() # Other helper functions
Example #9
Source File: test_binascii.py From medicare-demo with Apache License 2.0 | 5 votes |
def test_empty_string(self): # A test for SF bug #1022953. Make sure SystemError is not raised. for n in ['b2a_qp', 'a2b_hex', 'b2a_base64', 'a2b_uu', 'a2b_qp', 'b2a_hex', 'unhexlify', 'hexlify', 'crc32', 'b2a_hqx', 'a2b_hqx', 'a2b_base64', 'rlecode_hqx', 'b2a_uu', 'rledecode_hqx']: f = getattr(binascii, n) f('') binascii.crc_hqx('', 0)
Example #10
Source File: quopri.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def decodestring(s, header = 0): if a2b_qp is not None: return a2b_qp(s, header = header) from cStringIO import StringIO infp = StringIO(s) outfp = StringIO() decode(infp, outfp, header = header) return outfp.getvalue() # Other helper functions
Example #11
Source File: quopri.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def decodestring(s, header = 0): if a2b_qp is not None: return a2b_qp(s, header = header) from cStringIO import StringIO infp = StringIO(s) outfp = StringIO() decode(infp, outfp, header = header) return outfp.getvalue() # Other helper functions
Example #12
Source File: quopri.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def decodestring(s, header = 0): if a2b_qp is not None: return a2b_qp(s, header = header) from cStringIO import StringIO infp = StringIO(s) outfp = StringIO() decode(infp, outfp, header = header) return outfp.getvalue() # Other helper functions
Example #13
Source File: multipart.py From lambda-text-extractor with Apache License 2.0 | 5 votes |
def _decode_content_transfer(self, data): encoding = self.headers[CONTENT_TRANSFER_ENCODING].lower() if encoding == 'base64': return base64.b64decode(data) elif encoding == 'quoted-printable': return binascii.a2b_qp(data) elif encoding in ('binary', '8bit', '7bit'): return data else: raise RuntimeError('unknown content transfer encoding: {}' ''.format(encoding))
Example #14
Source File: multipart.py From lambda-text-extractor with Apache License 2.0 | 5 votes |
def _decode_content_transfer(self, data): encoding = self.headers[CONTENT_TRANSFER_ENCODING].lower() if encoding == 'base64': return base64.b64decode(data) elif encoding == 'quoted-printable': return binascii.a2b_qp(data) elif encoding in ('binary', '8bit', '7bit'): return data else: raise RuntimeError('unknown content transfer encoding: {}' ''.format(encoding))
Example #15
Source File: quopri.py From RevitBatchProcessor with GNU General Public License v3.0 | 5 votes |
def decodestring(s, header = 0): if a2b_qp is not None: return a2b_qp(s, header = header) from cStringIO import StringIO infp = StringIO(s) outfp = StringIO() decode(infp, outfp, header = header) return outfp.getvalue() # Other helper functions
Example #16
Source File: quopri.py From PokemonGo-DesktopMap with MIT License | 5 votes |
def decodestring(s, header = 0): if a2b_qp is not None: return a2b_qp(s, header = header) from cStringIO import StringIO infp = StringIO(s) outfp = StringIO() decode(infp, outfp, header = header) return outfp.getvalue() # Other helper functions
Example #17
Source File: quopri.py From unity-python with MIT License | 5 votes |
def decodestring(s, header = 0): if a2b_qp is not None: return a2b_qp(s, header = header) from cStringIO import StringIO infp = StringIO(s) outfp = StringIO() decode(infp, outfp, header = header) return outfp.getvalue() # Other helper functions
Example #18
Source File: quopri.py From android_universal with MIT License | 5 votes |
def decodestring(s, header=False): if a2b_qp is not None: return a2b_qp(s, header=header) from io import BytesIO infp = BytesIO(s) outfp = BytesIO() decode(infp, outfp, header=header) return outfp.getvalue() # Other helper functions
Example #19
Source File: quopri.py From canape with GNU General Public License v3.0 | 5 votes |
def decodestring(s, header = 0): if a2b_qp is not None: return a2b_qp(s, header = header) from cStringIO import StringIO infp = StringIO(s) outfp = StringIO() decode(infp, outfp, header = header) return outfp.getvalue() # Other helper functions
Example #20
Source File: quopri.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def decodestring(s, header = 0): if a2b_qp is not None: return a2b_qp(s, header = header) from cStringIO import StringIO infp = StringIO(s) outfp = StringIO() decode(infp, outfp, header = header) return outfp.getvalue() # Other helper functions
Example #21
Source File: quopri.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def decodestring(s, header = 0): if a2b_qp is not None: return a2b_qp(s, header = header) from cStringIO import StringIO infp = StringIO(s) outfp = StringIO() decode(infp, outfp, header = header) return outfp.getvalue() # Other helper functions
Example #22
Source File: test_binascii.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_qp(self): # A test for SF bug 534347 (segfaults without the proper fix) try: binascii.a2b_qp("", **{1:1}) except TypeError: pass else: self.fail("binascii.a2b_qp(**{1:1}) didn't raise TypeError") self.assertEqual(binascii.a2b_qp("= "), "= ") self.assertEqual(binascii.a2b_qp("=="), "=") self.assertEqual(binascii.a2b_qp("=AX"), "=AX") self.assertRaises(TypeError, binascii.b2a_qp, foo="bar") self.assertEqual(binascii.a2b_qp("=00\r\n=00"), "\x00\r\n\x00") self.assertEqual( binascii.b2a_qp("\xff\r\n\xff\n\xff"), "=FF\r\n=FF\r\n=FF" ) self.assertEqual( binascii.b2a_qp("0"*75+"\xff\r\n\xff\r\n\xff"), "0"*75+"=\r\n=FF\r\n=FF\r\n=FF" ) self.assertEqual(binascii.b2a_qp('\0\n'), '=00\n') self.assertEqual(binascii.b2a_qp('\0\n', quotetabs=True), '=00\n') self.assertEqual(binascii.b2a_qp('foo\tbar\t\n'), 'foo\tbar=09\n') self.assertEqual(binascii.b2a_qp('foo\tbar\t\n', quotetabs=True), 'foo=09bar=09\n') self.assertEqual(binascii.b2a_qp('.'), '=2E') self.assertEqual(binascii.b2a_qp('.\n'), '=2E\n') self.assertEqual(binascii.b2a_qp('a.\n'), 'a.\n')
Example #23
Source File: quopri.py From pmatic with GNU General Public License v2.0 | 5 votes |
def decodestring(s, header = 0): if a2b_qp is not None: return a2b_qp(s, header = header) from cStringIO import StringIO infp = StringIO(s) outfp = StringIO() decode(infp, outfp, header = header) return outfp.getvalue() # Other helper functions
Example #24
Source File: test_binascii.py From BinderFilter with MIT License | 5 votes |
def test_qp(self): # A test for SF bug 534347 (segfaults without the proper fix) try: binascii.a2b_qp("", **{1:1}) except TypeError: pass else: self.fail("binascii.a2b_qp(**{1:1}) didn't raise TypeError") self.assertEqual(binascii.a2b_qp("= "), "= ") self.assertEqual(binascii.a2b_qp("=="), "=") self.assertEqual(binascii.a2b_qp("=AX"), "=AX") self.assertRaises(TypeError, binascii.b2a_qp, foo="bar") self.assertEqual(binascii.a2b_qp("=00\r\n=00"), "\x00\r\n\x00") self.assertEqual( binascii.b2a_qp("\xff\r\n\xff\n\xff"), "=FF\r\n=FF\r\n=FF" ) self.assertEqual( binascii.b2a_qp("0"*75+"\xff\r\n\xff\r\n\xff"), "0"*75+"=\r\n=FF\r\n=FF\r\n=FF" ) self.assertEqual(binascii.b2a_qp('\0\n'), '=00\n') self.assertEqual(binascii.b2a_qp('\0\n', quotetabs=True), '=00\n') self.assertEqual(binascii.b2a_qp('foo\tbar\t\n'), 'foo\tbar=09\n') self.assertEqual(binascii.b2a_qp('foo\tbar\t\n', quotetabs=True), 'foo=09bar=09\n') self.assertEqual(binascii.b2a_qp('.'), '=2E') self.assertEqual(binascii.b2a_qp('.\n'), '=2E\n') self.assertEqual(binascii.b2a_qp('a.\n'), 'a.\n')
Example #25
Source File: quopri.py From BinderFilter with MIT License | 5 votes |
def decodestring(s, header = 0): if a2b_qp is not None: return a2b_qp(s, header = header) from cStringIO import StringIO infp = StringIO(s) outfp = StringIO() decode(infp, outfp, header = header) return outfp.getvalue() # Other helper functions
Example #26
Source File: quopri.py From Computable with MIT License | 5 votes |
def decodestring(s, header = 0): if a2b_qp is not None: return a2b_qp(s, header = header) from cStringIO import StringIO infp = StringIO(s) outfp = StringIO() decode(infp, outfp, header = header) return outfp.getvalue() # Other helper functions
Example #27
Source File: quopri.py From ironpython3 with Apache License 2.0 | 5 votes |
def decodestring(s, header=False): if a2b_qp is not None: return a2b_qp(s, header=header) from io import BytesIO infp = BytesIO(s) outfp = BytesIO() decode(infp, outfp, header=header) return outfp.getvalue() # Other helper functions
Example #28
Source File: quopri.py From oss-ftp with MIT License | 5 votes |
def decodestring(s, header = 0): if a2b_qp is not None: return a2b_qp(s, header = header) from cStringIO import StringIO infp = StringIO(s) outfp = StringIO() decode(infp, outfp, header = header) return outfp.getvalue() # Other helper functions
Example #29
Source File: test_binascii.py From oss-ftp with MIT License | 5 votes |
def test_qp(self): # A test for SF bug 534347 (segfaults without the proper fix) try: binascii.a2b_qp("", **{1:1}) except TypeError: pass else: self.fail("binascii.a2b_qp(**{1:1}) didn't raise TypeError") self.assertEqual(binascii.a2b_qp("= "), "= ") self.assertEqual(binascii.a2b_qp("=="), "=") self.assertEqual(binascii.a2b_qp("=AX"), "=AX") self.assertRaises(TypeError, binascii.b2a_qp, foo="bar") self.assertEqual(binascii.a2b_qp("=00\r\n=00"), "\x00\r\n\x00") self.assertEqual( binascii.b2a_qp("\xff\r\n\xff\n\xff"), "=FF\r\n=FF\r\n=FF" ) self.assertEqual( binascii.b2a_qp("0"*75+"\xff\r\n\xff\r\n\xff"), "0"*75+"=\r\n=FF\r\n=FF\r\n=FF" ) self.assertEqual(binascii.b2a_qp('\0\n'), '=00\n') self.assertEqual(binascii.b2a_qp('\0\n', quotetabs=True), '=00\n') self.assertEqual(binascii.b2a_qp('foo\tbar\t\n'), 'foo\tbar=09\n') self.assertEqual(binascii.b2a_qp('foo\tbar\t\n', quotetabs=True), 'foo=09bar=09\n') self.assertEqual(binascii.b2a_qp('.'), '=2E') self.assertEqual(binascii.b2a_qp('.\n'), '=2E\n') self.assertEqual(binascii.b2a_qp('a.\n'), 'a.\n')
Example #30
Source File: test_binascii.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_not_implemented(self): test_cases = [ lambda: binascii.a2b_qp(None), lambda: binascii.a2b_qp(None, None), lambda: binascii.a2b_hqx(None), lambda: binascii.rledecode_hqx(None), lambda: binascii.rlecode_hqx(None), lambda: binascii.b2a_hqx(None), ] for temp_func in test_cases: self.assertRaises(NotImplementedError, temp_func)