Ejemplo n.º 1
0
def setSourceProcessingFlags(config):
    # set outputFormat explicitly if format or output file are supplied by user.
    # otherwise, outputFormat is set to inputFormat during parsing
    if config.outputFormat == None:
        if config.outputFile:
            ext = os.path.splitext(config.outputFile)[1]
            config.outputFormat = Ffile.get_format(ext)
            setOutputFormat(config.outputFormat)
    elif (config.outputFormat <> 'fixed') and (config.outputFormat <> 'free'):
        opt.error(
            "outputFormat option must be specified with either 'fixed' or 'free' as an argument"
        )
    else:
        setOutputFormat(config.outputFormat)
    if config.outputLineLength:
        setOutputLineLength(config.outputLineLength)
    if config.inputLineLength:
        setInputLineLength(config.inputLineLength)
    # set symtab type defaults
    Symtab.setTypeDefaults((fs.RealStmt, []), (fs.IntegerStmt, []))
    # parse info units
    if config.infoUnitFile:
        from PyFort.fortUnit import fortUnitIterator
        for aUnit in fortUnitIterator(config.infoUnitFile, config.inputFormat):
            # need to parse this so the type information is available, but do not modify or print units
            pass
    # set verbosity
    DebugManager.setVerbose(config.isVerbose)
    DebugManager.setQuiet(config.noWarnings)
    DebugManager.setCheck(config.check)
Ejemplo n.º 2
0
import tempfile
from Setup import *
from unittest import *
from PyUtil.errors import UserError
from PyUtil.symtab import Symtab
from PyFort.fortUnit import fortUnitIterator
from PyFort.fortStmts import RealStmt, IntegerStmt
from PyFort.flow import setOutputFormat
from Canon.canon import UnitCanonicalizer, CanonError
from PyUtil.debugManager import DebugManager
from PyFort.flow import setOutputFormat
'''
Unit tests for canonicalizer

'''
DebugManager.setQuiet(True)

Symtab.setTypeDefaults((RealStmt, []), (IntegerStmt, []))


def compareFiles(assertFunc,
                 originalFileName,
                 RefFileName,
                 format,
                 hoistStrings=False):
    try:
        (fd, testFileName) = tempfile.mkstemp()
        testFile = open(testFileName, 'w')
        setOutputFormat(format)
        UnitCanonicalizer.setHoistStringsFlag(hoistStrings)
        for aUnit in fortUnitIterator(fname_t(originalFileName), format):