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

All Samples(4)  |  Call(2)  |  Derive(0)  |  Import(2)
attempt to convert a filename to utf8

            def fileName2FSEnc(fn):
        '''attempt to convert a filename to utf8'''
        from reportlab.rl_config import fsEncodings
        if isUnicode(fn):
            return asBytes(fn)
        else:
            for enc in fsEncodings:
                try:
                    return fn.decode(enc).encode('utf8')
                except:
                    pass
        raise ValueError('cannot convert %r to utf8 for file path name' % fn)
        


src/r/e/reportlab-3.1.8/tests/test_platypus_general.py   reportlab(Download)
from reportlab.lib import colors
from reportlab.rl_config import defaultPageSize
from reportlab.lib.utils import haveImages, _RL_DIR, rl_isfile, open_for_read, fileName2FSEnc
import unittest
from reportlab.lib.testutils import testsFolder
else:
    _GIF = None
if _GIF: _GIFFSEnc=fileName2FSEnc(_GIF)
 
_JPG = os.path.join(testsFolder,'..','docs','images','lj8100.jpg')

src/r/e/reportlab-3.1.8/tests/test_pdfgen_general.py   reportlab(Download)
from reportlab.lib.units import inch, cm
from reportlab.lib import colors
from reportlab.lib.utils import haveImages, fileName2FSEnc
 
#################################################################
    c.drawString(inch+3, 2*inch+6, 'Hyperlink with custom border style')
 
    xpdf = fileName2FSEnc(outputfile('test_hello.pdf').replace('\\','/'))
    link = 'Hard link to %s, with red border' % xpdf
    r1 = (inch, 1.5*inch, inch+2*3+c.stringWidth(link,c._fontname, c._fontsize), 1.75*inch) # this is x1,y1,x2,y2