Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(20)  |  Call(13)  |  Derive(0)  |  Import(7)

            def asBytes(v,enc='utf8'):
        return v if isinstance(v,str) else v.encode(enc)
        


src/r/e/reportlab-3.1.8/src/reportlab/lib/rl_accel.py   reportlab(Download)
 
if _py_funcs:
    from reportlab.lib.utils import isBytes, isUnicode, isSeq, isPy3, rawBytes, asNative, asUnicode, asBytes
    from math import log
    from struct import unpack
 
        r = ''.join(out.__self__)
        return asBytes(r,enc='latin1')
    _py_funcs['asciiBase85Decode'] = asciiBase85Decode
 

src/r/e/reportlab-3.1.8/src/reportlab/lib/pdfencrypt.py   reportlab(Download)
"""helpers for pdf encryption/decryption"""
import sys, os, tempfile
from reportlab.lib.utils import getBytesIO, md5, asBytes, int2Byte, char2int, rawUnicode, rawBytes, isPy3
from reportlab.pdfgen.canvas import Canvas
from reportlab.pdfbase import pdfutils
    #AR force same as iText example
    #Permissions =  -1836   #int(Permissions - 2**31)
    password = asBytes(password) + PadString
    # truncate to 32 bytes
    password = password[:32]
        permissionsString += int2Byte(byte % 256)
 
    hash = md5(asBytes(password))
    hash.update(asBytes(OwnerKey))
    hash.update(asBytes(permissionsString))

src/r/e/reportlab-3.1.8/src/reportlab/graphics/renderPS.py   reportlab(Download)
 
from reportlab.pdfbase.pdfmetrics import getFont, stringWidth, unicode2T1 # for font info
from reportlab.lib.utils import getBytesIO, getStringIO, asBytes, char2int, rawBytes, asNative, isUnicode
from reportlab.lib.rl_accel import fp_str
from reportlab.lib.colors import black
def _escape_and_limit(s):
    s = asBytes(s)
    R = []
    aR = R.append
    n = 0
    def _AsciiHexEncode(self, input):  # also based on piddlePDF
        "Helper function used by images"
        output = getStringIO()
        for char in asBytes(input):
            output.write('%02x' % char2int(char))

src/r/e/reportlab-3.1.8/src/reportlab/graphics/shapes.py   reportlab(Download)
from reportlab.lib import colors
from reportlab.lib.validators import *
from reportlab.lib.utils import isSeq, asBytes
isOpacity = NoneOr(isNumberInRange(0,1))
from reportlab.lib.attrmap import *
            filename = fnroot+'.py'
            if verbose: print(genFmt % ('py',filename))
            open(filename,'wb').write(asBytes(self._renderPy().replace('\n',os.linesep)))
            ext = ext +  '/.py'
 

src/r/e/reportlab-3.1.8/src/reportlab/platypus/paraparser.py   reportlab(Download)
 
from reportlab.lib.abag import ABag
from reportlab.lib.utils import ImageReader, isPy3, annotateException, encode_label, asUnicode, asBytes, uniChr
from reportlab.lib.colors import toColor, white, black, red, Color
from reportlab.lib.fonts import tt2ps, ps2tt

src/r/e/reportlab-3.1.8/tests/test_rl_accel.py   reportlab(Download)
__version__=''' $Id'''
__doc__='''basic tests.'''
from reportlab.lib.testutils import setOutDir,makeSuiteForClasses, printLocation
from reportlab.lib.utils import asBytes
setOutDir(__name__)
                encoded = efunc(plain)
                decoded = dfunc(encoded)
                assert decoded == asBytes(plain,'latin1'), "Round-trip AsciiBase85 failed for %s & %s\nplain=%s\nencoded=%s\ndecoded=%s" % (
                        ascii(efunc),ascii(dfunc), ascii(plain), ascii(encoded), ascii(decoded))
                if not j:

src/r/e/reportlab-3.1.8/tests/test_pdfbase_pdfutils.py   reportlab(Download)
from reportlab.pdfbase.pdfutils import _AsciiHexEncode, _AsciiHexDecode
from reportlab.pdfbase.pdfutils import asciiBase85Encode, asciiBase85Decode
from reportlab.lib.utils import asBytes
 
class PdfEncodingTestCase(unittest.TestCase):
            encoded = asciiBase85Encode(plain)
            decoded = asciiBase85Decode(encoded)
            assert decoded == asBytes(plain,'latin1'), msg
            plain += chr(i)