• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.rl_isfile函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中reportlab.lib.utils.rl_isfile函数的典型用法代码示例。如果您正苦于以下问题:Python rl_isfile函数的具体用法?Python rl_isfile怎么用?Python rl_isfile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了rl_isfile函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: findT1File

 def findT1File(self, ext='.pfb'):
     possible_exts = (ext.lower(), ext.upper())
     if hasattr(self,'pfbFileName'):
         r_basename = os.path.splitext(self.pfbFileName)[0]
         for e in possible_exts:
             if rl_isfile(r_basename + e):
                 return r_basename + e
     try:
         r = _fontdata.findT1File(self.name)
     except:
         afm = bruteForceSearchForAFM(self.name)
         if afm:
             if ext.lower() == '.pfb':
                 for e in possible_exts:
                     pfb = os.path.splitext(afm)[0] + e
                     if rl_isfile(pfb):
                         r = pfb
                     else:
                         r = None
             elif ext.lower() == '.afm':
                 r = afm
         else:
             r = None
     if r is None:
         warnOnce("Can't find %s for face '%s'" % (ext, self.name))
     return r
开发者ID:Aeium,项目名称:dotStudio,代码行数:26,代码来源:pdfmetrics.py


示例2: test2

 def test2(self):
     "try under a well known directory NOT on the path"
     from reportlab.lib.testutils import testsFolder
     D = os.path.join(testsFolder,'..','tools','pythonpoint')
     fn = os.path.join(D,'stdparser.py')
     if rl_isfile(fn) or rl_isfile(fn+'c') or rl_isfile(fn+'o'):
         m1 = recursiveImport('stdparser', baseDir=D)
开发者ID:sengupta,项目名称:scilab_cloud,代码行数:7,代码来源:test_lib_utils.py


示例3: getTypeFace

def getTypeFace(faceName):
    """Lazily construct known typefaces if not found"""
    try:
        return _typefaces[faceName]
    except KeyError:
        # not found, construct it if known
        if faceName in standardFonts:
            face = TypeFace(faceName)
            (face.familyName, face.bold, face.italic) = _fontdata.standardFontAttributes[faceName]
            registerTypeFace(face)
##            print 'auto-constructing type face %s with family=%s, bold=%d, italic=%d' % (
##                face.name, face.familyName, face.bold, face.italic)
            return face
        else:
            #try a brute force search
            afm = bruteForceSearchForAFM(faceName)
            if afm:
                for e in ('.pfb', '.PFB'):
                    pfb = os.path.splitext(afm)[0] + e
                    if rl_isfile(pfb): break
                assert rl_isfile(pfb), 'file %s not found!' % pfb
                face = EmbeddedType1Face(afm, pfb)
                registerTypeFace(face)
                return face
            else:
                raise
开发者ID:Aeium,项目名称:dotStudio,代码行数:26,代码来源:pdfmetrics.py


示例4: test2

    def test2(self):
        "try under a well known directory NOT on the path"
        from reportlab.lib.testutils import testsFolder

        D = os.path.join(testsFolder, "..", "tools", "pythonpoint")
        fn = os.path.join(D, "stdparser.py")
        if rl_isfile(fn) or rl_isfile(fn + "c") or rl_isfile(fn + "o"):
            m1 = recursiveImport("stdparser", baseDir=D)
开发者ID:JeffBerger,项目名称:solcorporation,代码行数:8,代码来源:test_lib_utils.py


示例5: bruteForceSearchForFile

def bruteForceSearchForFile(fn,searchPath=None):
    if searchPath is None: from reportlab.rl_config import T1SearchPath as searchPath
    if rl_isfile(fn): return fn
    bfn = os.path.basename(fn)
    for dirname in searchPath:
        if not rl_isdir(dirname): continue
        tfn = os.path.join(dirname,bfn)
        if rl_isfile(tfn): return tfn
    return fn
开发者ID:Aeium,项目名称:dotStudio,代码行数:9,代码来源:pdfmetrics.py


示例6: _processPackageDir

def _processPackageDir(p,dn,P,allowCompiled=True):
	if _ofile: print('searching package', p, 'dn=',dn, file=_ofile)
	from reportlab.lib.utils import rl_glob, rl_isfile, rl_isdir, isCompactDistro
	if isCompactDistro():
		ext = '.pyc'
		init = '__init__'+ext
		FN = [normpath(x) for x in rl_glob(path_join(dn,'*'))]
		D = []
		dn = normpath(dn)
		for x in FN:
			x = path_dirname(x)
			if x not in D and rl_isdir(x) and path_dirname(x)==dn and rl_isfile(path_join(x,init)): D.append(x)
		F = [x for x in FN if x.endswith(ext) and path_dirname(x)==dn and not path_basename(x).startswith('__init__.')]
	else:
		ext = '.py'
		init = '__init__'+ext
		FN = [path_join(dn,x) for x in os.listdir(dn)]
		D = [x for x in FN if path_isdir(x) and isPyFile(path_join(x,init))]
		F = [x for x in FN if (x.endswith(ext) or (allowCompiled and (x.endswith(ext+'c') or x.endswith(ext+'o')))) and not path_basename(x).startswith('__init__.')]
	for f in F:
		mn = path_splitext(path_basename(f))[0]
		if p: mn = p+'.'+mn
		if mn not in P:
			if _ofile: print('appending 1',mn, file=_ofile)
			P.append(mn)
	for f in D:
		mn = p+('.'+path_basename(f))
		if mn not in P:
			if _ofile: print('appending 2',mn, file=_ofile)
			P.append(mn)
开发者ID:AndyKovv,项目名称:hostel,代码行数:30,代码来源:mutils.py


示例7: _searchT1Dirs

def _searchT1Dirs(n, rl_isfile=rl_isfile, T1SearchPath=T1SearchPath):
    assert T1SearchPath != [], "No Type-1 font search path"
    for d in T1SearchPath:
        f = os.path.join(d, n)
        if rl_isfile(f):
            return f
    return None
开发者ID:wolf29,项目名称:EG-notifications,代码行数:7,代码来源:_fontdata.py


示例8: eoCB

 def eoCB(s,targets=targets,dtdDirs=dtdDirs):
     from reportlab.lib.utils import open_and_read, rl_isfile
     bn = os.path.basename(s)
     if bn in targets:
         for d in dtdDirs:
             fn = os.path.join(d,bn)
             if rl_isfile(fn): return fn, open_and_read(fn,'t')
     return s
开发者ID:AndyKovv,项目名称:hostel,代码行数:8,代码来源:xmlutils.py


示例9: validate

def validate(rawdata):
    global _pyRXP_Parser
    if not _pyRXP_Parser:
        try:
            import pyRXP
        except ImportError:
            return
        from reportlab.lib.utils import open_and_read, rl_isfile
        dtd = 'pythonpoint.dtd'
        if not rl_isfile(dtd):
            dtd = os.path.join(toolsDir(),'pythonpoint','pythonpoint.dtd')
            if not rl_isfile(dtd): return
        def eocb(URI,dtdText=open_and_read(dtd),dtd=dtd):
            if os.path.basename(URI)=='pythonpoint.dtd': return dtd,dtdText
            return URI
        _pyRXP_Parser = pyRXP.Parser(eoCB=eocb)
    return _pyRXP_Parser.parse(rawdata)
开发者ID:nickpack,项目名称:reportlab,代码行数:17,代码来源:pythonpoint.py


示例10: test

    def test(self):
        import reportlab.test
        from reportlab.lib.utils import rl_isfile
        imageFileName = os.path.dirname(reportlab.test.__file__) + os.sep + 'pythonpowered.gif'
        assert rl_isfile(imageFileName), "%s not found!" % imageFileName

        ir = ImageReader(imageFileName)
        assert ir.getSize() == (110,44)
        pixels = ir.getRGBData()
        assert md5.md5(pixels).hexdigest() == '02e000bf3ffcefe9fc9660c95d7e27cf'
开发者ID:eaudeweb,项目名称:naaya,代码行数:10,代码来源:test_images.py


示例11: _loadGlyphs

    def _loadGlyphs(self, pfbFileName):
        """Loads in binary glyph data, and finds the four length
        measurements needed for the font descriptor"""
        assert rl_isfile(pfbFileName), 'file %s not found' % pfbFileName
        d = open_and_read(pfbFileName, 'b')
        s1, l1 = _pfbCheck(0,d,PFB_ASCII,pfbFileName)
        s2, l2 = _pfbCheck(l1,d,PFB_BINARY,pfbFileName)
        s3, l3 = _pfbCheck(l2,d,PFB_ASCII,pfbFileName)
        _pfbCheck(l3,d,PFB_EOF,pfbFileName)
        self._binaryData = d[s1:l1]+d[s2:l2]+d[s3:l3]

        self._length = len(self._binaryData)
        self._length1 = l1-s1
        self._length2 = l2-s2
        self._length3 = l3-s3
开发者ID:eaudeweb,项目名称:naaya,代码行数:15,代码来源:pdfmetrics.py


示例12: TTFOpenFile

def TTFOpenFile(fn):
    '''Opens a TTF file possibly after searching TTFSearchPath
    returns (filename,file)
    '''
    from reportlab.lib.utils import rl_isfile, open_for_read
    try:
        f = open_for_read(fn,'rb')
        return fn, f
    except IOError:
        import os
        if not os.path.isabs(fn):
            for D in rl_config.TTFSearchPath:
                tfn = os.path.join(D,fn)
                if rl_isfile(tfn):
                    f = open_for_read(tfn,'rb')
                    return tfn, f
        raise TTFError('Can\'t open file "%s"' % fn)
开发者ID:Dongminator,项目名称:CV-Management-tool,代码行数:17,代码来源:ttfonts.py


示例13: rl_isfile

from reportlab.test import unittest
from reportlab.test.utils import makeSuiteForClasses, outputfile

from reportlab.pdfgen import canvas
from reportlab import platypus
from reportlab.platypus import BaseDocTemplate, PageTemplate, Flowable, FrameBreak
from reportlab.platypus import Paragraph, Preformatted
from reportlab.lib.units import inch, cm
from reportlab.lib.styles import PropertySet, getSampleStyleSheet, ParagraphStyle
from reportlab.lib import colors
from reportlab.rl_config import defaultPageSize
from reportlab.lib.utils import haveImages, _RL_DIR, rl_isfile, open_for_read
if haveImages:
    _GIF = os.path.join(_RL_DIR,'test','pythonpowered.gif')
    if not rl_isfile(_GIF): _GIF = None
else:
    _GIF = None
_JPG = os.path.join(_RL_DIR,'docs','images','lj8100.jpg')
if not rl_isfile(_JPG): _JPG = None

def getFurl(fn):
    furl = fn.replace(os.sep,'/')
    if sys.platform=='win32' and furl[1]==':': furl = furl[0]+'|'+furl[2:]
    if furl[0]!='/': furl = '/'+furl
    return 'file://'+furl

PAGE_HEIGHT = defaultPageSize[1]

#################################################################
#
开发者ID:roytest001,项目名称:PythonCode,代码行数:30,代码来源:test_platypus_general.py


示例14: test2

 def test2(self):
     "try under a well known directory NOT on the path"
     D = os.path.join(os.path.dirname(reportlab.__file__), "tools", "pythonpoint")
     fn = os.path.join(D, "stdparser.py")
     if rl_isfile(fn) or rl_isfile(fn + "c") or rl_isfile(fn + "o"):
         m1 = recursiveImport("stdparser", baseDir=D)
开发者ID:eaudeweb,项目名称:naaya,代码行数:6,代码来源:test_lib_utils.py


示例15: makeDocument


#.........这里部分代码省略.........
    c.drawText(t)

    #now reset canvas to get rid of the clipping mask
    c.restoreState()

    c.showPage()


#########################################################################
#
#  Page 7 - images
#
#########################################################################
    framePage(c, "Images")
    c.setFont('Times-Roman', 12)
    t = c.beginText(inch, 10 * inch)
    if not haveImages:
        c.drawString(inch, 11*inch,
                     "Python Imaging Library not found! Below you see rectangles instead of images.")

    t.textLines("""PDFgen uses the Python Imaging Library to process a very wide variety of image formats.
        This page shows image capabilities.  If I've done things right, the bitmap should have
        its bottom left corner aligned with the crosshairs.
        There are two methods for drawing images.  The recommended use is to call drawImage.
        This produces the smallest PDFs and the fastest generation times as each image's binary data is
        only embedded once in the file.  Also you can use advanced features like transparency masks.
        You can also use drawInlineImage, which puts images in the page stream directly.
        This is slightly faster for Acrobat to render or for very small images, but wastes
        space if you use images more than once.""")

    c.drawText(t)

    gif = os.path.join(_RL_DIR,'test','pythonpowered.gif')
    if haveImages and rl_isfile(gif):
        c.drawInlineImage(gif,2*inch, 7*inch)
    else:
        c.rect(2*inch, 7*inch, 110, 44)

    c.line(1.5*inch, 7*inch, 4*inch, 7*inch)
    c.line(2*inch, 6.5*inch, 2*inch, 8*inch)
    c.drawString(4.5 * inch, 7.25*inch, 'inline image drawn at natural size')

    if haveImages and rl_isfile(gif):
        c.drawInlineImage(gif,2*inch, 5*inch, inch, inch)
    else:
        c.rect(2*inch, 5*inch, inch, inch)

    c.line(1.5*inch, 5*inch, 4*inch, 5*inch)
    c.line(2*inch, 4.5*inch, 2*inch, 6*inch)
    c.drawString(4.5 * inch, 5.25*inch, 'inline image distorted to fit box')

    c.drawString(1.5 * inch, 4*inch, 'Image XObjects can be defined once in the file and drawn many times.')
    c.drawString(1.5 * inch, 3.75*inch, 'This results in faster generation and much smaller files.')

    for i in range(5):
        if haveImages:
            (w, h) = c.drawImage(gif, (1.5 + i)*inch, 3*inch)
        else:
            c.rect((1.5 + i)*inch, 3*inch, 110, 44)

    myMask = [254,255,222,223,0,1]
    c.drawString(1.5 * inch, 2.5*inch, "The optional 'mask' parameter lets you define transparent colors. We used a color picker")
    c.drawString(1.5 * inch, 2.3*inch, "to determine that the yellow in the image above is RGB=(225,223,0).  We then define a mask")
    c.drawString(1.5 * inch, 2.1*inch, "spanning these RGB values:  %s.  The background vanishes!!" % myMask)
    c.drawString(2.5*inch, 1.2*inch, 'This would normally be obscured')
    if haveImages:
开发者ID:eaudeweb,项目名称:naaya,代码行数:67,代码来源:test_pdfgen_pycanvas.py


示例16: search

    def search(self):
        started = time.clock()
        if not self._dirs:
            raise ValueError("Font search path is empty!  Please specify search directories using addDirectory or addDirectories")

        if self.useCache:
            cfn = self._getCacheFileName()
            if rl_isfile(cfn):
                try:
                    self.load(cfn)
                    #print "loaded cached file with %d fonts (%s)" % (len(self._fonts), cfn)
                    return
                except:
                    pass  #pickle load failed.  Ho hum, maybe it's an old pickle.  Better rebuild it.

        from stat import ST_MTIME
        for dirName in self._dirs:
            fileNames = rl_listdir(dirName)
            for fileName in fileNames:
                root, ext = os.path.splitext(fileName)
                if ext.lower() in EXTENSIONS:
                    #it's a font
                    f = FontDescriptor()
                    f.fileName = os.path.normpath(os.path.join(dirName, fileName))
                    f.timeModified = rl_getmtime(f.fileName)

                    ext = ext.lower()
                    if ext[0] == '.':
                        ext = ext[1:]
                    f.typeCode = ext  #strip the dot

                    #what to do depends on type.  We only accept .pfb if we
                    #have .afm to go with it, and don't handle .otf now.

                    if ext in ('otf', 'pfa'):
                        self._skippedFiles.append(fileName)

                    elif ext in ('ttf','ttc'):
                        #parsing should check it for us
                        from reportlab.pdfbase.ttfonts import TTFontFile, TTFError
                        try:
                            font = TTFontFile(fileName,validate=self.validate)
                        except TTFError:
                            self._badFiles.append(fileName)
                            continue
                        f.name = font.name
                        f.fullName = font.fullName
                        f.styleName = font.styleName
                        f.familyName = font.familyName
                        f.isBold = (FF_FORCEBOLD == FF_FORCEBOLD & font.flags)
                        f.isItalic = (FF_ITALIC == FF_ITALIC & font.flags)

                    elif ext == 'pfb':

                        # type 1; we need an AFM file or have to skip.
                        if rl_isfile(os.path.join(dirName, root + '.afm')):
                            f.metricsFileName = os.path.normpath(os.path.join(dirName, root + '.afm'))
                        elif rl_isfile(os.path.join(dirName, root + '.AFM')):
                            f.metricsFileName = os.path.normpath(os.path.join(dirName, root + '.AFM'))
                        else:
                            self._skippedFiles.append(fileName)
                            continue
                        from reportlab.pdfbase.pdfmetrics import parseAFMFile

                        (info, glyphs) = parseAFMFile(f.metricsFileName)
                        f.name = info['FontName']
                        f.fullName = info.get('FullName', f.name)
                        f.familyName = info.get('FamilyName', None)
                        f.isItalic = (float(info.get('ItalicAngle', 0)) > 0.0)
                        #if the weight has the word bold, deem it bold
                        f.isBold = ('bold' in info.get('Weight','').lower())

                    self._fonts.append(f)
        if self.useCache:
            self.save(cfn)

        finished = time.clock()
开发者ID:7o9,项目名称:stdm-plugin,代码行数:77,代码来源:fontfinder.py


示例17: test2

 def test2(self):
     "try under a well known directory NOT on the path"
     D = os.path.join(os.path.dirname(reportlab.__file__), 'tools','pythonpoint')
     fn = os.path.join(D,'stdparser.py')
     if rl_isfile(fn) or rl_isfile(fn+'c') or rl_isfile(fn+'o'):
         m1 = recursiveImport('stdparser', baseDir=D)
开发者ID:eaudeweb,项目名称:naaya,代码行数:6,代码来源:test_lib_utils.py


示例18: rl_isfile

import string, copy, sys, os
from reportlab.pdfgen import canvas
from reportlab import platypus
from reportlab.platypus import BaseDocTemplate, PageTemplate, Flowable, FrameBreak
from reportlab.platypus import Paragraph, Preformatted
from reportlab.lib.units import inch, cm
from reportlab.lib.styles import PropertySet, getSampleStyleSheet, ParagraphStyle
from reportlab.lib import colors
from reportlab.rl_config import defaultPageSize
from reportlab.lib.utils import haveImages, _RL_DIR, rl_isfile, open_for_read, fileName2Utf8
import unittest
from reportlab.lib.testutils import testsFolder

if haveImages:
    _GIF = os.path.join(testsFolder, "pythonpowered.gif")
    if not rl_isfile(_GIF):
        _GIF = None
else:
    _GIF = None
if _GIF:
    _GIFUTF8 = fileName2Utf8(_GIF)

_JPG = os.path.join(testsFolder, "..", "docs", "images", "lj8100.jpg")
if not rl_isfile(_JPG):
    _JPG = None


def getFurl(fn):
    furl = fn.replace(os.sep, "/")
    if sys.platform == "win32" and furl[1] == ":":
        furl = furl[0] + "|" + furl[2:]
开发者ID:jameshickey,项目名称:ReportLab,代码行数:31,代码来源:test_platypus_general.py



注:本文中的reportlab.lib.utils.rl_isfile函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.ImageReader类代码示例发布时间:2022-05-26
下一篇:
Python utils.rl_isdir函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap