示例#1
0
class TestCase006(unittest.TestCase):
    def setUp(self):
        self.factory=ParserFactory()
        self.factory.addParser(CPPParser())
        self.factory.addParser(PythonParser())

    def test_path(self):
        parser=self.factory.getParser(ParserType.Cpp)
        parser.locateSubFolders('../data/c++')
        parser.buildContent()
示例#2
0
class TestCase005(unittest.TestCase):
    def setUp(self):
        self.factory=ParserFactory()
        self.factory.addParser(CPPParser())
        self.factory.addParser(PythonParser())

    def test_path(self):
        self.factory.parse(ParserType.Python,'../data/python','../bin/pythonexamples')
        self.assertNotEqual(self.factory.getParser(ParserType.Python).getSrcFolderSize(),0)

        self.factory.parse(ParserType.Cpp,'../data/c++','../bin/cppexamples')
        self.assertNotEqual(self.factory.getParser(ParserType.Cpp).getSrcFolderSize(),0)
示例#3
0
    def construct(node):
        fl = FieldLocator()
        fl.identifyFields(node)
        temp = fl.getFieldNode().getEducationIndex()

        for parserType in ResumeProcessor.__parserList:
            parser = ParserFactory.createParser(parserType, node.getContent())
            parser.parse(node, fl.getFieldNode())
示例#4
0
    def construct(node):
        fl = FieldLocator()
        fl.identifyFields(node)
        temp = fl.getFieldNode().getEducationIndex()

        for parserType in ResumeProcessor.__parserList:
            parser = ParserFactory.createParser(parserType, node.getContent())
            parser.parse(node, fl.getFieldNode())
示例#5
0
class TestCase001(unittest.TestCase):
    def setUp(self):
        self.factory=ParserFactory()
        self.factory.addParser(CPPParser())
        self.factory.addParser(PythonParser())

    def test_loadparser(self):
        self.assertEqual(self.factory.getParser(ParserType.Cpp).getType(),ParserType.Cpp)
        self.assertEqual(self.factory.getParser(ParserType.Python).getType(),ParserType.Python)
        self.assertEqual(self.factory.getParser(ParserType.Arduino),None)
示例#6
0
文件: terse.py 项目: talipovm/Terse
def terse_file(fl, i=None):
    log.debug('Opening ' + str(fl))

    if fl[0] == 'file':
        if not IO.all_readable(fl[1:]):
            log.debug('Cannot open ' + str(fl))
            return None  # to the next file
        Parser = ParserFactory.interface_by_file_extension(
            fl, registered_file_extensions)
    else:
        Parser = ParserFactory.interface_by_command_line(fl)

    # from this moment, f is an object of a specific class according to the file type
    Parser.file = fl[1]
    if i is not None:
        Parser.settings.counter = i

    try:
        Parser.parse()
        Parser.postprocess()
        b1, b2 = Parser.webdata()
        # print(fl[1],i,Parser.settings.web_path('-xxx'))
    except:
        log.error('Parsing %s failed!' % (str(fl)))
        if fl[0] == 'file':
            # Save failed calculations to use them to improve terse
            FailFolder = settings.OutputFolder + '/failed'
            if IO.prepare_folder(FailFolder):
                shutil.copy(fl[1], FailFolder)
        if settings.debug:
            raise  # terse will crash but give some feedback
        else:
            return None  # silently skip_n problematic file

    if settings.usage:
        Parser.usage()

    return (b1, b2)
示例#7
0
文件: terse.py 项目: talipovm/terse
def terse_file(fl,i=None):
    log.debug('Opening ' + str(fl))

    if fl[0] == 'file':
        if not IO.all_readable(fl[1:]):
            log.debug('Cannot open ' + str(fl))
            return None # to the next file
        Parser = ParserFactory.interface_by_file_extension(fl, registered_file_extensions)
    else:
        Parser = ParserFactory.interface_by_command_line(fl)

    # from this moment, f is an object of a specific class according to the file type
    Parser.file = fl[1]
    if i is not None:
        Parser.settings.counter = i

    try:
        Parser.parse()
        Parser.postprocess()
        b1, b2 = Parser.webdata()
        # print(fl[1],i,Parser.settings.web_path('-xxx'))
    except:
        log.error('Parsing %s failed!' % (str(fl)))
        if fl[0] == 'file':
        # Save failed calculations to use them to improve terse
            FailFolder = settings.OutputFolder + '/failed'
            if IO.prepare_folder(FailFolder):
                shutil.copy(fl[1],FailFolder)
        if settings.debug:
            raise  # terse will crash but give some feedback
        else:
            return None  # silently skip_n problematic file

    if settings.usage:
        Parser.usage()

    return (b1,b2)
示例#8
0
class TestCase002(unittest.TestCase):
    def setUp(self):
        self.factory=ParserFactory()
        self.factory.addParser(CPPParser())
        self.factory.addParser(PythonParser())

    def test_detect(self):
        self.assertEqual(self.factory.detectType('../data/python/libs/zip.py'),ParserType.Python)
        self.assertEqual(self.factory.detectType('../data/c++/qt/mvc/mvc.cpp'),ParserType.Cpp)
        self.assertEqual(self.factory.detectType('../data/c++/qt/mvc/mvc.build'),None)
示例#9
0
 def setUp(self):
     self.factory=ParserFactory()
     self.factory.addParser(CPPParser())
     self.factory.addParser(PythonParser())
示例#10
0
class TestCase004(unittest.TestCase):
    def setUp(self):
        self.factory=ParserFactory()
        self.factory.addParser(CPPParser())
        self.factory.addParser(PythonParser())

    def test_path(self):
        self.factory.parse(ParserType.Python,'../data/python','../bin/pythonexamples')
        self.factory.parse(ParserType.Cpp,'../data/c++','../bin/cppexamples')
        self.assertEqual(self.factory.getParser(ParserType.Python).getInputPath(),'../data/python')
        self.assertEqual(self.factory.getParser(ParserType.Python).getOutputPath(),'../bin/pythonexamples')
        self.assertEqual(self.factory.getParser(ParserType.Cpp).getInputPath(),'../data/c++')
        self.assertEqual(self.factory.getParser(ParserType.Cpp).getOutputPath(),'../bin/cppexamples')
示例#11
0
#! /usr/bin/env python3

import sys,os
sys.path.append(os.path.abspath('../src/parsers'))
from ParserFactory import ParserFactory
from Parser import ParserType
from CPPParser import CPPParser
from PythonParser import PythonParser

if __name__ == '__main__':
	factory=ParserFactory()
	factory.addParser(CPPParser())
	factory.addParser(PythonParser())

	parser=factory.getParser(ParserType.Cpp)
	parser.locateSubFolders('../data/c++')
	parser.buildContent()


示例#12
0
#! /usr/bin/env python3
from subprocess import call
import sys,os
sys.path.append(os.path.abspath('../src/parsers'))
from ParserFactory import ParserFactory
from Parser import ParserType
from CPPParser import CPPParser
from PythonParser import PythonParser

if __name__ == '__main__':
	factory=ParserFactory()
	factory.addParser(CPPParser())
	factory.addParser(PythonParser())
	factory.parse(ParserType.Python,'../data/python','./pythonexamples')
	factory.parse(ParserType.Cpp,'../data/c++','./cppexamples')
	call(['rm footer.html'],shell=True)
 def create_parser_marker(question_type, attempt, question):
     parser = ParserFactory.create_parser(question_type, attempt)
     marker = MarkerFactory.create_marker(question_type, question, parser)
     return (parser, marker)