Пример #1
0
 def __extractExternalChannelGrammarsFromDefinitions(self):
     """Extracts grammars from definition.
     generated channel must be connected to outside elements"""
     inputtypedict = {}
     outputtypedict = {}
     for definition in self.__GTDefinitionlist:
         for gtcondef in definition.inputConnectionDefinitions:
             if gtcondef.externalgtname == "Main":
                 if gtcondef.internalchannelname in inputtypedict:
                     from pydsl.Exceptions import NameOverlap
                     raise NameOverlap
                 #FIXME: Is better to avoid loading the instance to obtain grammar name
                 from pydsl.Memory.Storage.Loader import load_transformer
                 gtinstance = load_transformer(definition.type)
                 inputtypedict[gtcondef.externalchannelname] = gtinstance.inputdefinition[gtcondef.internalchannelname]
                 self.__inputGTDict[gtcondef.externalchannelname] = (gtcondef.basename, gtcondef.internalchannelname) #Prepares self.__inputGTDict
         for gtcondef in definition.outputConnectionDefinitions:
             if gtcondef.externalgtname == "Main":
                 if gtcondef.internalchannelname in outputtypedict:
                     from pydsl.Exceptions import NameOverlap
                     raise NameOverlap
                 from pydsl.Memory.Storage.Loader import load_transformer
                 gtinstance = load_transformer(definition.type)
                 ocd = gtinstance.outputchanneldic
                 outputtypedict[gtcondef.externalchannelname] = gtinstance.outputdefinition[gtcondef.internalchannelname]
                 self.__outputGTDict[gtcondef.externalchannelname] = (gtcondef.basename, gtcondef.internalchannelname) #Prepares self.__outputGTDict
     return (inputtypedict, outputtypedict)
Пример #2
0
 def _initHostT(self, namedic):
     """Inits aux GTs. if a requested aux GT isn't connected, This function will create it"""
     from pydsl.Memory.Storage.Loader import load_transformer
     for title, gttype in namedic.items():
         print(self._server)
         self._hostT[title] = load_transformer(gttype, eventmanager = self._server, ecuid = title) 
         LOG.debug("loaded " + str(title) + "auxT")
Пример #3
0
 def readTR(self, gtname):
     from pydsl.Memory.Storage.Loader import load_transformer
     self.__mainfunc = load_transformer(gtname) 
Пример #4
0
            from pydsl.Guess import guess
            inputformat = guess(inputfile, [ftdl])
            if len(inputformat) == 0:
                print("Input format not found")
                sys.exit(-1)
            elif len(inputformat) > 1:
                print("Several input formats found, please use -i argument")
                sys.exit(-1)
            inputformat = inputformat.pop()

        LOG.warning("Inputformat:" + inputformat)
        from pydsl.Memory.Storage.Directory.Function import TransformerDirStorage 
        from pydsl.Search.Searcher import MemorySearcher
        from pydsl.Search.Indexer import Indexer
        searcher = MemorySearcher([Indexer(TransformerDirStorage())])
        print(searcher.search("output="+destformat+"&&input="+inputformat))
        searchresult = searcher.search("output="+destformat+"&&input="+inputformat)
        if not searchresult:
            print("No conversion available from "+ inputformat + " to " + destformat)
            sys.exit(-1)
        firstresult = searchresult.pop()
        from pydsl.Memory.Storage.Loader import load_transformer
        finstance = load_transformer(firstresult["identifier"])
        result = finstance({"inputfile":inputfile,"outputfile":ARGS.outputfile})
        sys.exit(0)
        #sys.exit(int(str(result["output"])))
    else:
        print(TUSAGE)
        sys.exit(0)
    sys.exit(0)