当前位置: 首页>>代码示例>>Python>>正文


Python utils.open_and_read函数代码示例

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


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

示例1: run

def run(pagesize=None, verbose=0, outDir=None):
    import os
    from reportlab.tools.docco.rl_doc_utils import setStory, getStory, RLDocTemplate, defaultPageSize
    from reportlab.tools.docco import rl_doc_utils
    from reportlab.lib.utils import open_and_read, _RL_DIR
    if not outDir: outDir = os.path.join(_RL_DIR,'docs')
    destfn = os.path.join(outDir,'userguide.pdf')
    doc = RLDocTemplate(destfn,pagesize = pagesize or defaultPageSize)

    #this builds the story
    setStory()
    G = {}
    exec 'from reportlab.tools.docco.rl_doc_utils import *' in G, G
    for f in (
        'ch1_intro',
        'ch2_graphics',
        'ch2a_fonts',
        'ch3_pdffeatures',
        'ch4_platypus_concepts',
        'ch5_paragraphs',
        'ch6_tables',
        'ch7_custom',
        'ch9_future',
        'app_demos',
        ):
        exec open_and_read(f+'.py',mode='t') in G, G
    del G

    story = getStory()
    if verbose: print 'Built story contains %d flowables...' % len(story)
    doc.build(story)
    if verbose: print 'Saved "%s"' % destfn
开发者ID:alexissmirnov,项目名称:donomo,代码行数:32,代码来源:genuserguide.py

示例2: run

def run(pagesize=None, verbose=1, outDir=None):
    import os
    from reportlab.tools.docco.rl_doc_utils import setStory, getStory, RLDocTemplate, defaultPageSize
    from reportlab.tools.docco import rl_doc_utils
    from reportlab.lib.utils import open_and_read, _RL_DIR
    if not outDir: outDir = os.path.join(_RL_DIR,'docs')
    destfn = os.path.join(outDir,'graphguide.pdf')
    doc = RLDocTemplate(destfn,pagesize = pagesize or defaultPageSize)

    #this builds the story
    setStory()
    G = {}
    exec 'from reportlab.tools.docco.rl_doc_utils import *' in G, G
    doc = RLDocTemplate(destfn,pagesize = pagesize or defaultPageSize)
    for f in (
        'ch1_intro',
        'ch2_concepts',
        'ch3_shapes',
        'ch4_widgets',
        'ch5_charts',
        ):
        exec open_and_read(f+'.py',mode='t') in G, G
    del G

    story = getStory()
    if verbose: print 'Built story contains %d flowables...' % len(story)
    doc.build(story)
    if verbose: print 'Saved "%s"' % destfn
开发者ID:eaudeweb,项目名称:naaya,代码行数:28,代码来源:gengraphguide.py

示例3: run

def run(pagesize=None, verbose=0, outDir=None):
    import sys,os
    from reportlab.lib.utils import open_and_read
    cwd = os.getcwd()
    docsDir=os.path.dirname(os.path.dirname(sys.argv[0]) or cwd)
    topDir=os.path.dirname(docsDir)
    if not outDir: outDir=docsDir
    G = {}
    sys.path.insert(0,topDir)
    from reportlab.pdfbase.pdfmetrics import registerFontFamily
    from reportlab.pdfbase import pdfmetrics
    from reportlab.pdfbase.ttfonts import TTFont
    pdfmetrics.registerFont(TTFont('Vera', 'Vera.ttf'))
    pdfmetrics.registerFont(TTFont('VeraBd', 'VeraBd.ttf'))
    pdfmetrics.registerFont(TTFont('VeraIt', 'VeraIt.ttf'))
    pdfmetrics.registerFont(TTFont('VeraBI', 'VeraBI.ttf'))
    registerFontFamily('Vera',normal='Vera',bold='VeraBd',italic='VeraIt',boldItalic='VeraBI')
    from tools.docco.rl_doc_utils import setStory, getStory, RLDocTemplate, defaultPageSize, H1, H2, H3, H4
    from tools.docco import rl_doc_utils
    exec 'from tools.docco.rl_doc_utils import *' in G, G
    destfn = os.path.join(outDir,'reportlab-userguide.pdf')
    doc = RLDocTemplate(destfn,pagesize = pagesize or defaultPageSize)


    #this builds the story
    setStory()

    for f in (
        'ch1_intro',
        'ch2_graphics',
        'ch2a_fonts',
        'ch3_pdffeatures',
        'ch4_platypus_concepts',
        'ch5_paragraphs',
        'ch6_tables',
        'ch7_custom',
        'graph_intro',
        'graph_concepts',
        'graph_charts',
        'graph_shapes',
        'graph_widgets',
        'app_demos',
        ):
        exec open_and_read(f+'.py',mode='t') in G, G
    del G

    story = getStory()
    if verbose: print 'Built story contains %d flowables...' % len(story)
    doc.multiBuild(story)
    if verbose: print 'Saved "%s"' % destfn
开发者ID:jbacou,项目名称:myReportLab_installPackage,代码行数:50,代码来源:genuserguide.py

示例4: checkFileForTabs

 def checkFileForTabs(self, filename):
     txt = open_and_read(filename, "r")
     chunks = string.split(txt, "\t")
     tabCount = len(chunks) - 1
     if tabCount:
         # raise Exception, "File %s contains %d tab characters!" % (filename, tabCount)
         self.output.write("file %s contains %d tab characters!\n" % (filename, tabCount))
开发者ID:eaudeweb,项目名称:naaya,代码行数:7,代码来源:test_source_chars.py

示例5: 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

示例6: _rel_open_and_read

def _rel_open_and_read(fn):
    from reportlab.lib.utils import open_and_read
    from reportlab.lib.testutils import testsFolder
    cwd = os.getcwd()
    os.chdir(testsFolder)
    try:
        return open_and_read(fn)
    finally:
        os.chdir(cwd)
开发者ID:sengupta,项目名称:scilab_cloud,代码行数:9,代码来源:test_lib_utils.py

示例7: run

def run(pagesize=None, verbose=0, outDir=None):
    import sys, os
    from reportlab.lib.utils import open_and_read

    cwd = os.getcwd()
    docsDir = os.path.dirname(os.path.dirname(sys.argv[0]) or cwd)
    topDir = os.path.dirname(docsDir)
    if not outDir:
        outDir = docsDir
    G = {}
    sys.path.insert(0, topDir)
    from reportlab.pdfbase.pdfmetrics import registerFontFamily
    from reportlab.pdfbase import pdfmetrics
    from reportlab.pdfbase.ttfonts import TTFont

    pdfmetrics.registerFont(TTFont("Vera", "Vera.ttf"))
    pdfmetrics.registerFont(TTFont("VeraBd", "VeraBd.ttf"))
    pdfmetrics.registerFont(TTFont("VeraIt", "VeraIt.ttf"))
    pdfmetrics.registerFont(TTFont("VeraBI", "VeraBI.ttf"))
    registerFontFamily("Vera", normal="Vera", bold="VeraBd", italic="VeraIt", boldItalic="VeraBI")
    from tools.docco.rl_doc_utils import setStory, getStory, RLDocTemplate, defaultPageSize, H1, H2, H3, H4
    from tools.docco import rl_doc_utils

    exec("from tools.docco.rl_doc_utils import *", G, G)
    destfn = os.path.join(outDir, "reportlab-userguide.pdf")
    doc = RLDocTemplate(destfn, pagesize=pagesize or defaultPageSize)

    # this builds the story
    setStory()

    for f in (
        "ch1_intro",
        "ch2_graphics",
        "ch2a_fonts",
        "ch3_pdffeatures",
        "ch4_platypus_concepts",
        "ch5_paragraphs",
        "ch6_tables",
        "ch7_custom",
        "graph_intro",
        "graph_concepts",
        "graph_charts",
        "graph_shapes",
        "graph_widgets",
        "app_demos",
    ):
        exec(open_and_read(f + ".py", mode="t"), G, G)
    del G

    story = getStory()
    if verbose:
        print("Built story contains %d flowables..." % len(story))
    doc.multiBuild(story)
    if verbose:
        print('Saved "%s"' % destfn)
开发者ID:wolf29,项目名称:EG-notifications,代码行数:55,代码来源:genuserguide.py

示例8: xml2rad

def xml2rad(xml, validating=1, eoCB=None):
    '''convert xml to radxml form'''
    if validating:
        from reportlab.lib.utils import isCompactDistro, open_and_read
        if not eoCB and isCompactDistro():
            eoCB = lambda x, open_and_read=open_and_read: (x, open_and_read(x))
        import pyRXPU
        rad = pyRXPU.Parser().parse(xml,eoCB=eoCB)
    else:
        from reportlab.lib import rparsexml
        rad = rparsexml.parsexml0(xml)[0][2][0]
    return rad
开发者ID:AndyKovv,项目名称:hostel,代码行数:12,代码来源:xmlutils.py

示例9: testAscii

    def testAscii(self):
        "Test if Python files are pure ASCII ones."
        from reportlab.lib.testutils import RL_HOME
        allPyFiles = GlobDirectoryWalker(RL_HOME, '*.py')

        for path in allPyFiles:
            fileContent = open_and_read(path,'r')
            nonAscii = u''.join(list(set([c for c in fileContent if ord(c)>127])))

            truncPath = path[path.find('reportlab'):]
            args = (truncPath, repr(map(ord, nonAscii)))
            msg = "File %s contains characters: %s." % args
            assert len(nonAscii) == 0, msg
开发者ID:jeffery9,项目名称:reportlab,代码行数:13,代码来源:test_pyfiles.py

示例10: run

def run(pagesize=None, verbose=0, outDir=None):
    import os
    from reportlab.tools.docco.rl_doc_utils import setStory, getStory, RLDocTemplate, defaultPageSize
    from reportlab.tools.docco import rl_doc_utils
    from reportlab.lib.utils import open_and_read, _RL_DIR
    if not outDir: 
        outDir = '../manuals/'#os.path.join(_RL_DIR,'docs')
        if not os.path.isdir(outDir):
            os.mkdir(outDir)
    destfn = os.path.join(outDir,'X4 - Installazione.pdf')
    doc = RLDocTemplate(destfn,pagesize = pagesize or defaultPageSize)
    doc.title = 'X4 Setup'
    doc.subject = 'Manuale di installazione di X4GA'
    doc.author = 'Astra S.r.l.'

    #this builds the story
    setStory()
    G = {}
    exec 'from reportlab.tools.docco.rl_doc_utils import *' in G, G
    for f in (
        'ch1_intro',
        'ch2_dbengine',
        'ch3_workstation',
        #'ch3_pdffeatures',
        #'ch4_platypus_concepts',
        #'ch5_paragraphs',
        #'ch6_tables',
        #'ch7_custom',
        #'ch9_future',
        #'app_demos',
        ):
        exec open_and_read(f+'.py',mode='t') in G, G
    del G

    story = getStory()
    if verbose: print 'Built story contains %d flowables...' % len(story)
    doc.build(story)
    if verbose: print 'Saved "%s"' % destfn
开发者ID:alexsandrino,项目名称:X4GA,代码行数:38,代码来源:genuserguide.py

示例11: checkFileForTrailingSpaces

    def checkFileForTrailingSpaces(self, filename):
        txt = open_and_read(filename, 'r')
        initSize = len(txt)
        badLines = 0
        badChars = 0
        for line in string.split(txt, '\n'):
            stripped = string.rstrip(line)
            spaces = len(line) - len(stripped)  # OK, so they might be trailing tabs, who cares?
            if spaces:
                badLines = badLines + 1
                badChars = badChars + spaces

        if badChars != 0:
            self.output.write("file %s contains %d trailing spaces, or %0.2f%% wastage\n" % (filename, badChars, 100.0*badChars/initSize))
开发者ID:sengupta,项目名称:scilab_cloud,代码行数:14,代码来源:test_source_chars.py

示例12: _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

示例13: testAscii

    def testAscii(self):
        "Test if Python files are pure ASCII ones."
        from reportlab.lib.testutils import RL_HOME
        allPyFiles = GlobDirectoryWalker(RL_HOME, '*.py')

        for path in allPyFiles:
            fileContent = open_and_read(path,'r')
            nonAscii = filter(lambda c: ord(c)>127, fileContent)
            nonAscii = unique(nonAscii)

            truncPath = path[string.find(path, 'reportlab'):]
            args = (truncPath, repr(map(ord, nonAscii)))
            msg = "File %s contains characters: %s." % args
##            if nonAscii:
##                print msg
            assert nonAscii == '', msg
开发者ID:ingob,项目名称:mwlib.ext,代码行数:16,代码来源:test_pyfiles.py

示例14: epsBBox

def epsBBox(fn,bbpat=re.compile(r'^\s*%%boundingbox:\s*(.*)\s*$',re.I|re.M)):
    '''
    read an eps file and attempt to obtain its bounding box

    >>> cleanup()
    >>> x=pdfConvert('zzzdingo.pdf',scale=0.5,device='eps',outfile='zzzdingo.eps')
    >>> assert x and os.path.isfile(os.path.basename(x[0]))
    >>> print epsBBox('zzzdingo.eps')
    [0, 0, 100, 50]
    '''
    text = open_and_read(fn)
    m=bbpat.search(text)
    if not m:
        raise ValueError('Cannot find bounding box in "%s"' % fn)
    bb = m.group(1).strip().split()
    if len(bb)!=4: 
        raise ValueError('Not enough bounding box entries "%s" found in "%s"' % (m.group(0).strip(),fn))
    try:
        return list(map(float,bb))
    except:
        raise ValueError('Bad bounding box entries "%s" found in "%s"' % (m.group(0).strip(),fn))
开发者ID:AndyKovv,项目名称:hostel,代码行数:21,代码来源:pdf2jpeg.py

示例15: open

 def open(self, fileName):
     """Parse and resolve a PDF file as much as possible"""
     from reportlab.lib.utils import open_and_read
     self.rawContent = open_and_read(fileName)
     self._parse()
开发者ID:AndyKovv,项目名称:hostel,代码行数:5,代码来源:pdfexplorer.py


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