Esempio n. 1
0
def errMsg(message, suppress = False, lf = True):
    """print message to stderr, possibly"""
    
    if not suppress:
        if lf:
            sys.stderr.write(message + gv.getVar('strTermChar'))
        else:
            sys.stderr.write(message)
        if gv.getVar('flush'):
            sys.stderr.flush()
Esempio n. 2
0
def pdfSetMetadata(canv = None, mdAuthor = 'CR Hailey', mdSubject = None, 
        mdTitle = None, mdKeywords = None, mdCreator = None, mdHeader = None):
    """ set pdf document metadata"""
    
    global pdfAuthorTxt, pdfSubjectTxt, pdfTitleTxt
    global pdfKeywordsTxt, pdfCreatorTxt, pdfHeaderTxt
    if canv == None:    # set crhPDF defaults
        if mdAuthor:
            pdfAuthorTxt = mdAuthor
        if mdSubject:
            pdfSubjectTxt = mdSubject
        if mdTitle:
            pdfTitleTxt = mdTitle
        if mdKeywords:
            pdfKeywordsTxt = mdKeywords
        if mdCreator:
            pdfCreatorTxt = mdCreator
        if mdHeader:
            pdfHeaderTxt = mdHeader
    else:
#        canv.setDateFormatter(_dateFormat)
        canv.setAuthor(mdAuthor)
        if not mdCreator:
            canv.setCreator(gv.getVar('progName'))
        if mdTitle:
            canv.setTitle(mdTitle)
        if mdKeywords:
            canv.setKeywords(mdKeywords)
        if mdSubject:
            canv.setSubject(mdSubject)
Esempio n. 3
0
def pdfDocTemplate(filename):
    """create document template sized as required"""

    doc = BaseDocTemplate(filename, pagesize = pdfPageSz, 
        leftMargin = pdfMargin, rightMargin = pdfMargin, topMargin = pdfMargin, 
        bottomMargin = pdfMargin, creator = gv.getVar('progName'),
        author = pdfAuthorTxt, subject = pdfSubjectTxt, title = pdfTitleTxt, 
        keywords = pdfKeywordsTxt, pageCompression = 1)
    # normal frame as for SimpleFlowDocument
    frameN = Frame(doc.leftMargin, doc.bottomMargin, doc.width, doc.height, id='normal')
    doc.addPageTemplates([PageTemplate(id = 'all',frames = frameN, onPage = allPages)])
    return doc
Esempio n. 4
0
def statusErrMsg(status, function, message, suppress = False):
    """print status message in standard format to stderr"""
    
    errMsg("{}-{}-{}--{}".format(status, gv.getVar('progName'), function, message), suppress)
Esempio n. 5
0
def getDbg():
    """return current debug mode"""
    
    return gv.getVar('debug')
Esempio n. 6
0
def getProgName():
    """return program name variable value"""
    
    return gv.getVar('progName')
Esempio n. 7
0
if __name__ == '__main__':
    # suppress messages
    msg('msg(1) called', 1)
    errMsg('errMsg(1) called', 1)
    tMsg('tMsg(1) called', 1)
    errTMsg('errTMsg(1) called', 1)
    statusMsg('info', 'test', 'statusMsg(1) called', 1)
    statusErrMsg('info', 'test', 'statusErrMsg(1) called', 1)
    # messages not suppressed
    msg('msg(2) called')
    errMsg('errMsg(2) called')
    tMsg('tMsg(2) called')
    errTMsg('errTMsg(2) called')
    statusMsg('info', 'test', 'statusMsg(2) called')
    statusErrMsg('info', 'test', 'statusErrMsg(2) called')
    # debug not set (debug messages suppressed)
    dbgMsg('dbgMsg(1) called')
    dbgTMsg('dbgTMsg(1) called')
    dbgDMsg('dbgMsg(1) called')
    setDbg(True)
    # debug set (debug messages not suppressed)
    dbgMsg('dbgMsg(2) called')
    dbgTMsg('dbgTMsg(2) called')
    dbgDMsg('dbgDMsg(2) called')
    # play with progName gv
    msg("progName: " + gv.getVar('progName'))
    setProgName('testName')
    msg("progName: " + getProgName())
    setProgName()
    msg("progName: " + getProgName())