コード例 #1
0
    def _fields(self):
        for fnode in self.root.findall("Field[@context='%s']" %
                                       self.node.attrib["id"]):
            access_type = Access.access_type(fnode)

            if access_type == Access.PRIVATE:
                continue

            if access_type == Access.PROTECTED and not self.allows_subclassing(
            ):
                continue

            name = fnode.attrib["name"]

            # union
            if not name:
                continue

            if self.blacklist.field(self.full_name, name):
                full_name = self.full_name + "::" + name
                Session.ignored_fields.add(full_name)
                continue

            t = Types.get_type_by_id(fnode.attrib["type"], self.root)
            f = Argument.Argument(t, name)
            self.fields.append(f)

            if access_type == Access.PROTECTED:
                self.protected_nonvirtual_members.add(
                    "using %s::%s;" % (self.full_name, f.raw_name))
コード例 #2
0
def _test_fundamental():
    tk = TupleAndKeywords()
    tk.add_parameter(
        Argument.Argument(Types.Type(("int", ), 1, "FundamentalType"), "foo",
                          10))
    tk.add_parameter(
        Argument.Argument(Types.Type(("long int", ), 2, "FundamentalType"),
                          "bar", 20))
    tk.add_parameter(
        Argument.Argument(Types.Type(("int", ), 3, "FundamentalType"), "mit",
                          30))

    print(tk.get_fmt_specifier())
    print(tk.get_keywords())
    print(tk.build_parser_idecl())
    print(tk.build_function_signature_parameter_list())
コード例 #3
0
ファイル: Method.py プロジェクト: g-soulie/uf-yuml
	def fromUML(self,umlString):
		if umlString[0] == "+":
			self.visi = "public"
		if umlString[0] == "-":
			self.visi = "private"
		umlString = umlString.lstrip("+ ").lstrip("- ")
		umlString = umlString.split(":")
		if len(umlString) > 1:
			self.rtype = umlString[1].lstrip(" ")
		umlString = umlString[0]
		umlString = umlString.split("(")
		self.name = umlString[0]
		if len(umlString) > 1:
			arguments = umlString[1].split(")")[0].split(",")
			if len(arguments[0])>0:
				for uml_argument in arguments:
					argument = Argument()
					argument.fromUML(uml_argument.lstrip(" "))
					self.args.append(argument)
コード例 #4
0
ファイル: Method.py プロジェクト: g-soulie/uf-yuml
 def fromUML(self, umlString):
     if umlString[0] == "+":
         self.visi = "public"
     if umlString[0] == "-":
         self.visi = "private"
     umlString = umlString.lstrip("+ ").lstrip("- ")
     umlString = umlString.split(":")
     if len(umlString) > 1:
         self.rtype = umlString[1].lstrip(" ")
     umlString = umlString[0]
     umlString = umlString.split("(")
     self.name = umlString[0]
     if len(umlString) > 1:
         arguments = umlString[1].split(")")[0].split(",")
         if len(arguments[0]) > 0:
             for uml_argument in arguments:
                 argument = Argument()
                 argument.fromUML(uml_argument.lstrip(" "))
                 self.args.append(argument)
コード例 #5
0
	def initializeDB(self, metadata, engine):

		taskInfos = TaskInfo.dbDesign(metadata)
		inputFiles = InputFile.dbDesign(metadata)
		outputFiles = OutputFile.dbDesign(metadata)
		arguments = Argument.dbDesign(metadata)
		gridTasks = GridTask.dbDesign(metadata)
		hosts = Host.dbDesign(metadata)
		taskGroups = TaskGroup.dbDesign(metadata)

		metadata.create_all(engine)
コード例 #6
0
    def _constructor(self, ctor):
        logging.debug(ctor.attrib["demangled"])

        tk = TupleAndKeywords.TupleAndKeywords()
        for argn in ctor.findall("Argument"):
            arg = Argument.Argument()
            arg.parse_xml(self.root, argn)
            tk.add_parameter(arg)

            self.fptrs.try_add(arg.type)

        self.ctors.append(tk)
コード例 #7
0
ファイル: MethodJar.py プロジェクト: vanxining/pbpp
    def __init__(self, root, node, free_function):
        self.name = node.attrib["name"]
        self.raw_sig = node.attrib["demangled"]

        self.free_function = free_function
        if not free_function:
            self.access = Access.access_type(node)
            self.virtual = node.attrib.get("virtual") == "1"
            self.final = node.attrib.get("final") == "1"
            self.pure_virtual = node.attrib.get("pure_virtual") == "1"
            self.static = node.attrib.get("static") == "1"

        self.args = TupleAndKeywords.TupleAndKeywords()
        for arg_node in node.findall("Argument"):
            self.args.add_parameter(Argument.from_xml(root, arg_node))

        self.returns = Types.get_type_by_id(node.attrib["returns"], root)
コード例 #8
0
    def __init__(self, root, node, free_function):
        self.name = node.attrib["name"]
        self.raw_sig = node.attrib["demangled"]

        self.free_function = free_function
        if not free_function:
            self.access = Access.access_type(node)
            self.virtual = node.attrib.get("virtual") == "1"
            self.final = node.attrib.get("final") == "1"
            self.pure_virtual = node.attrib.get("pure_virtual") == "1"
            self.static = node.attrib.get("static") == "1"

        self.args = TupleAndKeywords.TupleAndKeywords()
        for arg_node in node.findall("Argument"):
            self.args.add_parameter(Argument.from_xml(root, arg_node))

        self.returns = Types.get_type_by_id(node.attrib["returns"], root)
コード例 #9
0
ファイル: Cli.py プロジェクト: wenli1999/automation
def main():
    arg_dict = Argument.parseArgument('CLI unit test')
    cliTool = CliTool(arg_dict)

    cliTool.open()
    cliTool.sendCommand("vlan show")
    cliTool.close()

    cliTool.open()
    cliTool.sendCommand("port show")
    cliTool.close()

    cliTool.open()
    device = Device.Device(arg_dict)
    device.rebootAndReLogin(cliTool, 'reboot now')
    cliTool.sendCommand('int show')
    cliTool.close()
コード例 #10
0
ファイル: Snmp.py プロジェクト: wenli1999/automation
def main():
    snmpTool = SnmpTool(Argument.parseArgument('SNMP unit test'))

    # getBulk
    result = snmpTool.snmpBulkWalk('1.3.6.1.4.1.6141.2.60.2.1.1.1.1.2')
    for key, value in result.items():
        LOG.debug('%s = %s', key, value)

    # get
    result = snmpTool.snmpGet('1.3.6.1.2.1.1.1.0', '1.3.6.1.2.1.1.5.0', '1.3.6.1.4.1.6141.2.60.12.1.11.1.0',
                              '1.3.6.1.4.1.6141.2.60.2.1.1.1.1.2.1')
    for key, value in result.items():
        LOG.debug('%s = %s', key, value)

    # Get list
    oid_list = ['1.3.6.1.2.1.1.1.0', '1.3.6.1.2.1.1.5.0', '1.3.6.1.4.1.6141.2.60.12.1.11.1.0',
                '1.3.6.1.4.1.6141.2.60.2.1.1.1.1.2.1']
    result = snmpTool.snmpGetList(oid_list)
    for key, value in result.items():
        LOG.debug('%s = %s', key, value)
コード例 #11
0
 def __parse_argument(self, element):
     argument = Argument.Argument()
     if element.tag[0:3] != "arg":
         print("Argument element tag must start with arg", file=sys.stderr)
         exit(31)
     if not element.tag[3:].isdigit():
         print("Argument element tag must end with digit", file=sys.stderr)
         exit(31)
     argument.set_order(int(element.tag[3:]))
     for key, value in element.items():
         if key == "type":
             argument.set_type(value)
         else:
             print("Argument element must have correct attributes",
                   file=sys.stderr)
             exit(31)
     if not argument.get_type():
         print("Argument element must have type attribute", file=sys.stderr)
         exit(31)
     argument.set_value(element.text)
     return argument
コード例 #12
0
    def _process_global_constants(self):
        xpath = ".//Variable[@file='%s'][@context='%s']" % (
            self.current_file_id(), self.id
        )

        for var_node in self.root.findall(xpath):
            if "artificial" in var_node.attrib:
                if var_node.attrib["artificial"] == '1':
                    continue

            var = Argument.from_xml(self.root, var_node)
            var.name = var_node.attrib["demangled"]  # Full name

            full_decl = {
                "TYPE": var.type.decl(),
                "FULL_NAME": var.name
            }

            if self.blacklist.global_constants(full_decl):
                continue

            self.global_constants[var.name] = var
            self.modified = True
コード例 #13
0
    def _process_global_constants(self):
        xpath = ".//Variable[@file='%s'][@context='%s']" % (
            self.current_file_id(), self.id
        )

        for var_node in self.root.findall(xpath):
            if "artificial" in var_node.attrib:
                if var_node.attrib["artificial"] == '1':
                    continue

            var = Argument.from_xml(self.root, var_node)
            var.name = var_node.attrib["demangled"]  # Full name

            full_decl = {
                "TYPE": var.type.decl(),
                "FULL_NAME": var.name
            }

            if self.blacklist.global_constants(full_decl):
                continue

            self.global_constants[var.name] = var
            self.modified = True
コード例 #14
0
def _test():
    import CodeBlock
    import Converters
    import HeaderJar

    header_jar = HeaderJar.HeaderJar()
    Session.begin(header_jar)

    Converters.add(Converters.WcsConv())

    tk = TupleAndKeywords()
    tk.add_parameter(
        Argument.Argument(Types.Type((
            "int",
            "*",
        ), 1, "FundamentalType"), "foo"))
    tk.add_parameter(
        Argument.Argument(Types.Type((
            "double",
            "&",
        ), 2, "FundamentalType"), "bar"))
    tk.add_parameter(
        Argument.Argument(
            Types.Type((
                "long unsigned int",
                "&",
                "const",
            ), 3, "FundamentalType"), "xyz"))
    tk.add_parameter(
        Argument.Argument(Types.Type((
            "X",
            "const",
            "&",
        ), 4, "Class"), "x"))
    tk.add_parameter(
        Argument.Argument(Types.Type((
            "Y",
            "*",
        ), 5, "Class"), "y"))
    tk.add_parameter(Argument.Argument(Types.Type(("Z", ), 6, "Class"), "z"))
    tk.add_parameter(
        Argument.Argument(Types.Type(("bool", ), 7, "FundamentalType"), "b"))
    tk.add_parameter(
        Argument.Argument(
            Types.Type((
                "wchar_t",
                "const",
                "*",
            ), 8, "PointerType"), "str"))

    print(tk.get_fmt_specifier())
    print(tk.get_keywords())
    print(tk.build_function_signature_parameter_list())

    from Module import PythonNamer
    namer = PythonNamer()

    print(tk.build_parser_idecl(namer=namer))
    _print_empty_line()

    block = CodeBlock.CodeBlock()
    tk.write_args_parsing_code(block, namer, True, "return nullptr;", "<TEST>")

    print(block.flush())
    _print_empty_line()
    _print_empty_line()

    tk = TupleAndKeywords()
    tk.add_parameter(
        Argument.Argument(Types.Type((
            "int",
            "*",
        ), 1, "FundamentalType"), "foo", "nullptr"))
    tk.add_parameter(
        Argument.Argument(Types.Type((
            "double",
            "&",
        ), 2, "FundamentalType"), "bar", "PI"))
    tk.add_parameter(
        Argument.Argument(
            Types.Type((
                "long unsigned int",
                "&",
                "const",
            ), 3, "FundamentalType"), "xyz", "MAXINT"))
    tk.add_parameter(
        Argument.Argument(Types.Type((
            "X",
            "const",
            "&",
        ), 4, "Class"), "x", "_x"))
    tk.add_parameter(
        Argument.Argument(Types.Type((
            "Y",
            "*",
        ), 5, "Class"), "y", "_py"))
    tk.add_parameter(
        Argument.Argument(Types.Type(("Z", ), 6, "Class"), "z", "Z(1990)"))
    tk.add_parameter(
        Argument.Argument(Types.Type(("bool", ), 7, "FundamentalType"), "b",
                          "true"))
    tk.add_parameter(
        Argument.Argument(
            Types.Type((
                "wchar_t",
                "const",
                "*",
            ), 8, "PointerType"), "str", 'L"Hello world!"'))
    tk.write_args_parsing_code(block, namer, True, "return nullptr;", "<TEST>")

    print(block.flush())

    integer = Types.Type(("int", ), 99, "FundamentalType")
    Converters.add(Converters.ListConv(integer))

    tk = TupleAndKeywords()
    tk.add_parameter(
        Argument.Argument(
            Types.Type((
                "std::vector<int>",
                "const",
                "&",
            ), 0, "Class"), "vi", "_vi"))
    tk.write_args_parsing_code(block, namer, True, "return nullptr;", "<TEST>")

    print(block.flush())

    K = Types.Type((
        "wchar_t",
        "const",
        "*",
    ), 111, "PointerType")
    V = Types.Type((
        "wxColour",
        "*",
    ), 112, "PointerType")
    Converters.add(Converters.DictConv(K, V))

    tk = TupleAndKeywords()
    tk.add_parameter(
        Argument.Argument(
            Types.Type((
                "std::map<wchar_t const *, wxColour *>",
                "&",
            ), 0, "Class"), "m"))
    tk.write_args_parsing_code(block, namer, True, "return nullptr;", "<TEST>")

    print(block.flush())
コード例 #15
0
import os
import scipy as sp
import Matrice
import MethodeL
import Argument
from scipy import linalg
import matplotlib as mpl
import matplotlib.pyplot as plt
import sys
import getopt
from pylab import *
ion()

## EXECUTION PROBLEME LINEAIRE

methode = Argument.mainEL(sys.argv[1:])

## DONNEES

b_inf = -2
b_sup = 2
N = 50
eps = 1.0e-10
h = (b_sup - b_inf) / (N - 1)
gamma = h

## CALCUL MATRICE

R = Matrice.CalculR(N, b_inf, b_sup)
M = Matrice.CalculM(N, b_inf, b_sup)
A = Matrice.CalculA(N, b_inf, b_sup)
コード例 #16
0
    engine.execute("USE DistributedController") # select new db

    mySessionClass = sessionmaker(bind=engine)
    mySession = mySessionClass()


    metadata = MetaData()

    taskInfos = TaskInfo.dbDesign(metadata)

    inputFiles = InputFile.dbDesign(metadata)

    outputFiles = OutputFile.dbDesign(metadata)

    arguments = Argument.dbDesign(metadata)

    gridTasks = GridTask.dbDesign(metadata)

    taskGroups = TaskGroup.dbDesign(metadata)

    metadata.create_all(engine)


    #create task group
    taskGroup = TaskGroup.TaskGroup(indexFile, postProcessScript)
    mySession.add(taskGroup)
    mySession.commit()

    print("LOADING TASK GROUP: " + indexFile)
    for xmlFile in open(indexFile, 'r'):
コード例 #17
0
ファイル: OpticalFlow.py プロジェクト: kairx772/VisionBot
import sys
sys.path.append("src")
import Argument
import IOutils
import ImageProcessing

userCommand = Argument.CommandParser()
userCommand.parseArguments()
inputVideo = userCommand.getInputVideoInfo()
outputVideo = userCommand.getOutputVideoInfo()
outputText = userCommand.getOutputTextInfo()

port = IOutils.IOport(inputVideo, outputVideo, outputText)
port.createFileInstancesUponRequirement()

preprocessor = ImageProcessing.VideoPreprocessor(inputVideo)
preprocessor.findSideToCrop()
preprocessor.findCropPoints()
scaleRatio = preprocessor.getDisplayTargetRatio()

algo = ImageProcessing.Algorithm()

arrowMaker = ImageProcessing.VideoArtist(scaleRatio)
arrowMaker.findBestFrameMapping((8, 8))

monitor = IOutils.Display()

frame = port.getInputVideoFrame()
croppedFrame = preprocessor.cropFrameIntoSquare(frame)
previousFrame = preprocessor.convertFrameIntoSpecifiedFormat(croppedFrame)
コード例 #18
0
    def __parse_args(self, instruction):
        symb = ["var", "int", "string", "bool"]
        opcode = instruction.get('opcode')
        order = instruction.get('order')
        err_message = "Instruction order = '{0}' ".format(order)
        args_count = len(instruction)

        # <var> <symb>
        if (opcode in ["MOVE", "INT2CHAR", "STRLEN", "TYPE", "NOT"]):
            err_message += "\nInstruction '{0}' expects arguments <var> <symb>".format(
                opcode)
            if (args_count != 2):
                raise InstructException(err_message)
            if (instruction[0].get('type') != 'var'):
                raise InstructException(err_message)
            if (instruction[1].get('type') not in symb):
                raise InstructException(err_message)

        # no arguments
        elif (opcode
              in ["CREATEFRAME", "PUSHFRAME", "POPFRAME", "RETURN", "BREAK"]):
            err_message += "\nInstruction '{0}' expects no arguments".format(
                opcode)
            if (args_count != 0):
                raise InstructException(err_message)
        # <var>
        elif (opcode in ["DEFVAR", "POPS"]):
            err_message += "\nInstruction '{0}' expects argument <var>".format(
                opcode)
            if (args_count != 1):
                raise InstructException(err_message)
            if (instruction[0].get('type') != 'var'):
                raise InstructException(err_message)
        # <label>
        elif (opcode in ["CALL", "LABEL", "JUMP"]):
            err_message += "\nInstruction '{0}' expects argument <label>".format(
                opcode)
            if (args_count != 1):
                raise InstructException(err_message)
            if (instruction[0].get('type') != 'label'):
                raise InstructException(err_message)
        # <symb>
        elif (opcode in ["PUSHS", "WRITE", "DPRINT"]):
            err_message += "\nInstruction '{0}' expects argument <symb>".format(
                opcode)
            if (args_count != 1):
                raise InstructException(err_message)
            if (instruction[0].get('type') not in symb):
                raise InstructException(err_message)
        # <var> <symb1> <symb2>
        elif (opcode in [
                "ADD", "SUB", "MUL", "IDIV", "LT", "GT", "EQ", "AND", "OR",
                "STRI2INT", "CONCAT", "GETCHAR", "SETCHAR"
        ]):
            err_message += ("\nInstruction '{0}' expects arguments "
                            "<var> <symb1> <symb2>".format(opcode))
            if (args_count != 3):
                raise InstructException(err_message)
            if (instruction[0].get('type') != 'var'):
                raise InstructException(err_message)
            if (instruction[1].get('type') not in symb):
                raise InstructException(err_message)
            if (instruction[2].get('type') not in symb):
                raise InstructException(err_message)
        # <var> <type>
        elif (opcode == "READ"):
            err_message += ("\nInstruction '{0}' expects arguments "
                            "<var> <type>".format(opcode))
            if (args_count != 2):
                raise InstructException(err_message)
            if (instruction[0].get('type') != 'var'):
                raise InstructException(err_message)
            if (instruction[1].get('type') != 'type'):
                raise InstructException(err_message)
        # <label> <symb1> <symb2>
        elif (opcode in ["JUMPIFEQ", "JUMPIFNEQ"]):
            err_message += ("\nInstruction '{0}' expects arguments "
                            "<label> <symb1> <symb2>".format(opcode))
            if (args_count != 3):
                raise InstructException(err_message)
            if (instruction[0].get('type') != 'label'):
                raise InstructException(err_message)
            if (instruction[1].get('type') not in symb):
                raise InstructException(err_message)
            if (instruction[2].get('type') not in symb):
                raise InstructException(err_message)
        else:
            err_message += "\nUnknown instruction '{0}'".format(opcode)
            raise InstructException(err_message)

        for arg in instruction:
            self.__arguments.append(Argument.Argument(arg))
コード例 #19
0
ファイル: ConvNL.py プロジェクト: NFred/Stage
import Argument
from scipy import linalg
import matplotlib as mpl
import matplotlib.pyplot as plt
from pylab import *
ion()


b_inf = -2
b_sup = 2
N = 100
eps = 1.0e-09
beta = 10
gamma = 10

pre = Argument.mainC(sys.argv[1:])

nbi1 = np.zeros((4,1),dtype = int)
nbi2 = np.zeros((4,1),dtype = int)
nbi3 = np.zeros((4,1),dtype = int)
h = np.zeros((4,1),dtype = float)
j = 0
for i in [30,50,100,200] :
    h[j] = (b_sup - b_inf)/(i-1)
    Mat = Matrice.CalculDF(i,b_inf,b_sup)
    RN = Matrice.CalculDFR(i,b_inf,b_sup)
    I = np.eye(i,i)
    alpha = 1
    x0 = np.linspace(1,1,i)
    x0 = x0.T
    
コード例 #20
0
import Argument
from scipy import linalg
import matplotlib as mpl
import matplotlib.pyplot as plt
from pylab import *

ion()

b_inf = -2
b_sup = 2
N = 100
eps = 1.0e-09
beta = 10
gamma = 10

pre = Argument.mainC(sys.argv[1:])

nbi1 = np.zeros((4, 1), dtype=int)
nbi2 = np.zeros((4, 1), dtype=int)
nbi3 = np.zeros((4, 1), dtype=int)
h = np.zeros((4, 1), dtype=float)
j = 0
for i in [30, 50, 100, 200]:
    h[j] = (b_sup - b_inf) / (i - 1)
    Mat = Matrice.CalculDF(i, b_inf, b_sup)
    RN = Matrice.CalculDFR(i, b_inf, b_sup)
    I = np.eye(i, i)
    alpha = 1
    x0 = np.linspace(1, 1, i)
    x0 = x0.T
コード例 #21
0
ファイル: ExecL.py プロジェクト: NFred/Stage
import scipy as sp
import Matrice
import MethodeL
import Argument
from scipy import linalg
import matplotlib as mpl
import matplotlib.pyplot as plt
import sys
import getopt
from pylab import *
ion()

## EXECUTION PROBLEME LINEAIRE


methode = Argument.mainEL(sys.argv[1:])


## DONNEES

b_inf = -2
b_sup = 2
N = 50
eps = 1.0e-10
h = (b_sup-b_inf)/(N-1)
gamma = h

## CALCUL MATRICE

R = Matrice.CalculR(N,b_inf,b_sup)
M = Matrice.CalculM(N,b_inf,b_sup)
コード例 #22
0
import sys, getopt
from Argument import *

if __name__ == "__main__":
    handler = ArgumentsHandler(
        Argument("help", "help", "h", False, "provides Help"),
        Argument("test", "test", "t", description="Testing"))
    result = handler.resolve(sys.argv)
    print(result)