コード例 #1
0
 def _arraylist_of(self, xs):
     """
     Converts a python list to a java.util.ArrayList
     """
     a = ArrayList()
     a.addAll(xs)
     return a
コード例 #2
0
 def _arraylist_of(self, xs):
     """
     Converts a python list to a java.util.ArrayList
     """
     a = ArrayList()
     a.addAll( xs )
     return a
コード例 #3
0
 def getChildren(self, analyticFunctionOrdering):
     """ generated source for method getChildren """
     allChildren = ArrayList()
     allChildren.addAll(getSourceConjunctChildren())
     allChildren.addAll(getFunctionAddedChildren(analyticFunctionOrdering))
     # 			print "Number of children being added: " + len(allChildren);
     return allChildren
コード例 #4
0
def javaConcat(list1, list2):
    x = ArrayList()
    x.addAll(list1)
    x.addAll(list2)
    return tuple(x)

    
    
コード例 #5
0
 def test_iter(self):
     jlist = ArrayList()
     jlist.addAll(range(0, 10))
     
     i = iter(jlist)
     
     x = list(i)
     
     self.assert_(x == range(0, 10))
コード例 #6
0
ファイル: LibrarySizes.py プロジェクト: exotichead/ibmcnx2
def getLibraryList(libType):
    # iterate through all the result pages to return ALL found libraries
    pagecount = 1
    allLibs = ArrayList()
    libList = flsBrowse(libType, pagecount, maxpagingresults)
    while(not libList.isEmpty()):
        allLibs.addAll(libList)
        pagecount = pagecount + 1
        libList = flsBrowse(libType, pagecount, maxpagingresults)
    return allLibs
コード例 #7
0
def getLibraryList(libType):
    # iterate through all the result pages to return ALL found libraries
    pagecount = 1
    allLibs = ArrayList()
    libList = flsBrowse(libType, pagecount, maxpagingresults)
    while (not libList.isEmpty()):
        allLibs.addAll(libList)
        pagecount = pagecount + 1
        libList = flsBrowse(libType, pagecount, maxpagingresults)
    return allLibs
コード例 #8
0
ファイル: PropNetAnnotater.py プロジェクト: hobson/ggpy
 def getAugmentedDescription(self):
     """ generated source for method getAugmentedDescription """
     rval = ArrayList()
     for gdl in description:
         if isinstance(gdl, (GdlRelation, )):
             if rel.__name__.__str__() == "base":
                 notBase = False
         if notBase:
             rval.add(gdl)
     rval.addAll(self.getAnnotations())
     return rval
コード例 #9
0
ファイル: remesh.py プロジェクト: stefanovaleri/jCAE
def afront_insert(liaison, nodes_reader, size, point_metric):
    """ Return the list of mutable nodes which have been inserted """
    if point_metric:
        remesh = VertexInsertion(liaison, point_metric)
    else:
        remesh = VertexInsertion(liaison, size)
    inserted_vertices = ArrayList()
    for g_id in xrange(1, liaison.mesh.getNumberOfGroups() + 1):
        vs = nodes_reader.next()
        remesh.insertNodes(vs, g_id)
        inserted_vertices.addAll(remesh.mutableInserted)
    return inserted_vertices
コード例 #10
0
ファイル: remesh.py プロジェクト: bgarrels/jCAE
def afront_insert(liaison, nodes_reader, size, point_metric):
    """ Return the list of mutable nodes which have been inserted """
    if point_metric:
        remesh = VertexInsertion(liaison, point_metric)
    else:
        remesh = VertexInsertion(liaison, size)
    inserted_vertices = ArrayList()
    for g_id in xrange(1, liaison.mesh.getNumberOfGroups()+1):
        vs = nodes_reader.next()
        remesh.insertNodes(vs, g_id)
        inserted_vertices.addAll(remesh.mutableInserted)
    return inserted_vertices
コード例 #11
0
ファイル: PropNetFlattener.py プロジェクト: hobson/ggpy
 def getConstantAndVariableList(self, term):
     """ generated source for method getConstantAndVariableList """
     rval = ArrayList()
     if isinstance(term, (GdlConstant, )):
         rval.add(term)
         return rval
     elif isinstance(term, (GdlVariable, )):
         rval.add(term)
         return rval
     func = term
     for t in func.getBody():
         rval.addAll(self.getConstantAndVariableList(t))
     return rval
コード例 #12
0
 def flatten(self):
     """ generated source for method flatten """
     self.description = DeORer.run(self.description)
     if noAnnotations():
         GamerLogger.log("StateMachine", "Could not find 'base' annotations. Attempting to generate them...")
         self.description = PropNetAnnotater(self.description).getAugmentedDescription()
         GamerLogger.log("StateMachine", "Annotations generated.")
     self.templates = recordTemplates(self.description)
     self.instantiations = initializeInstantiations(self.description)
     flatDescription = ArrayList()
     for constant in templates.keySet():
         flatDescription.addAll(getInstantiations(constant))
     return flatDescription
コード例 #13
0
 def initializeInstantiations(self, description):
     """ generated source for method initializeInstantiations """
     trues = ArrayList()
     for gdl in description:
         if isinstance(gdl, (GdlSentence, )):
             if sentence.__name__.getValue() == "base":
                 if sentence.arity() == 1:
                     trues.add(GdlPool.getRule(GdlPool.getRelation(GdlPool.getConstant("true"), [None]*)))
                 else:
                     self.expandTrue(sentence, 1, LinkedList(), results)
                     trues.addAll(results)
     instantiations = HashMap()
     instantiations.put(GdlPool.getConstant("true"), trues)
     return instantiations
コード例 #14
0
    def getExtraParametersForStep(self, configurationAttributes, step):
        basicmultiauth_result = self.basicmultiauthconfExternalAuthenticator.getExtraParametersForStep(configurationAttributes, step)
        duo_result = self.duoExternalAuthenticator.getExtraParametersForStep(configurationAttributes, step)
        
        if basicmultiauth_result == None:
            return duo_result

        if duo_result == None:
            return basicmultiauth_result
        
        result_list = ArrayList()
        result_list.addAll(basicmultiauth_result)
        result_list.addAll(duo_result)

        return result_list
コード例 #15
0
ファイル: molio.py プロジェクト: onemoonsci/nmrfxstructure
def readSequenceString(polymerName, sequence, seqReader=None):
    ''' Creates a polymer from the sequence provided with the name of polymerName
        The sequence input can either be a chain of characters but will only work
        if the desired polymer is RNA. If creating a polymer for a protein,
        sequence must be a list using the 3 letter code.
    '''
    seqAList = ArrayList()
    seqAList.addAll(sequence)
    if (seqReader == None):
        seqReader = Sequence()
    seqReader.newPolymer()
    seqReader.read(polymerName, seqAList, "")
    updateAtomArray()
    mol = Molecule.getActive()
    return mol
コード例 #16
0
    def getExtraParametersForStep(self, configurationAttributes, step):
        cas2_result = self.cas2ExternalAuthenticator.getExtraParametersForStep(configurationAttributes, step)
        duo_result = self.duoExternalAuthenticator.getExtraParametersForStep(configurationAttributes, step)
        
        if cas2_result == None:
            return duo_result

        if duo_result == None:
            return cas2_result
        
        result_list = ArrayList()
        result_list.addAll(cas2_result)
        result_list.addAll(duo_result)

        return result_list
コード例 #17
0
    def getExtraParametersForStep(self, configurationAttributes, step):
        print "Casa. getExtraParametersForStep %s" % str(step)

        if step > 1:
            list = ArrayList()
            acr = CdiUtil.bean(Identity).getWorkingParameter("ACR")

            if acr in self.authenticators:
                module = self.authenticators[acr]
                params = module.getExtraParametersForStep(module.configAttrs, step)
                if params != None:
                    list.addAll(params)

            list.addAll(Arrays.asList("ACR", "methods", "trustedDevicesInfo"))
            print "extras are %s" % list
            return list

        return None
コード例 #18
0
    def getExtraParametersForStep(self, configurationAttributes, step):
        print "Casa. getExtraParametersForStep %s" % str(step)

        if step > 1:
            list = ArrayList()
            acr = CdiUtil.bean(Identity).getWorkingParameter("ACR")

            if acr in self.authenticators:
                module = self.authenticators[acr]
                params = module.getExtraParametersForStep(module.configAttrs, step)
                if params != None:
                    list.addAll(params)

            list.addAll(Arrays.asList("ACR", "methods", "trustedDevicesInfo"))
            print "extras are %s" % list
            return list

        return None
コード例 #19
0
ファイル: PropNetAnnotater.py プロジェクト: hobson/ggpy
 def getAnnotations(self):
     """ generated source for method getAnnotations """
     # Find universe and initial domains
     for gdl in description:
         processGdl(gdl, None)
         processDomain(gdl)
     # Compute the actual domains of everything
     updateDomains()
     # printDomains();
     # printDomainRefs();
     # Compute function corresponding to universal set for insertion in baseprops
     body = ArrayList()
     body.addAll(self.universe)
     self.universalDom = GdlPool.getFunction(GdlPool.getConstant("thing"), body)
     # Find next/init things and use them to instantiate base props
     for gdl in description:
         findAndInstantiateBaseProps(gdl)
     self.baseRelations = mergeBaseRelations(self.baseRelations)
     # Return the results
     rval = ArrayList()
     rval.addAll(self.baseRelations)
     return rval
コード例 #20
0
ファイル: Mfa.py プロジェクト: sign-in-canada/MFA
    def getExtraParametersForStep(self, configurationAttributes, step):
        print "MFA. getExtraParametersForStep called for step '%s'" % step

        # Inject dependencies
        identity = CdiUtil.bean(Identity)
        flow = identity.getWorkingParameter("flow")
        authenticatorType = identity.getWorkingParameter("authenticatorType")

        # General Parameters
        parameters = ArrayList(Arrays.asList("userId", "flow", "authenticatorType",
                                             "nextStep", "rpShortName.en", "rpShortName.fr", "rpContent"))
        
        # Registration Parameters
        if (flow == "Register"):
            parameters.add("recoveryCode")
            if (authenticatorType == "TOTP" and step == 3):
                parameters.addAll(Arrays.asList("totpEnrollmentRequest", "totpSecretKey", "qrLabel", "qrOptions"))
            if (authenticatorType == "FIDO" and step == 2):
                parameters.add("fido_u2f_registration_request")

        if (flow == "Authenticate" and authenticatorType == "FIDO" and step == 2):
                parameters.add("fido_u2f_authentication_request")

        return parameters
コード例 #21
0
ファイル: casa.py プロジェクト: ediboko1980/casa
    def getExtraParametersForStep(self, configurationAttributes, step):
        print "Casa. getExtraParametersForStep %s" % str(step)
        list = ArrayList()

        if step > 1:
            acr = CdiUtil.bean(Identity).getWorkingParameter("ACR")

            if acr in self.authenticators:
                module = self.authenticators[acr]
                params = module.getExtraParametersForStep(module.configAttrs, step)
                if params != None:
                    list.addAll(params)

            list.addAll(Arrays.asList("ACR", "methods", "trustedDevicesInfo"))
        else:
            list.add("externalProviders")

        list.addAll(Arrays.asList("casa_contextPath", "casa_prefix", "casa_faviconUrl", "casa_extraCss", "casa_logoUrl"))
        print "extras are %s" % list
        return list
コード例 #22
0
 def test_len(self):
     jlist = ArrayList()
     jlist.addAll(range(0, 10))
     
     self.assert_(len(jlist) == 10)
コード例 #23
0
ファイル: Match.py プロジェクト: hobson/ggpy
class Match(object):
    """ generated source for class Match """
    matchId = str()
    randomToken = str()
    spectatorAuthToken = str()
    playClock = int()
    startClock = int()
    previewClock = int()
    startTime = Date()
    theGame = Game()
    moveHistory = List()
    stateHistory = List()
    errorHistory = List()
    stateTimeHistory = List()
    isCompleted = bool()
    isAborted = bool()
    goalValues = List()
    numRoles = int()
    theCryptographicKeys = EncodedKeyPair()
    thePlayerNamesFromHost = List()
    isPlayerHuman = List()
    theGdlScrambler = NoOpGdlScrambler()

    @overloaded
    def __init__(self, matchId, previewClock, startClock, playClock, theGame):
        """ generated source for method __init__ """
        self.matchId = matchId
        self.previewClock = previewClock
        self.startClock = startClock
        self.playClock = playClock
        self.theGame = theGame
        self.startTime = Date()
        self.randomToken = getRandomString(32)
        self.spectatorAuthToken = getRandomString(12)
        self.isCompleted = False
        self.isAborted = False
        self.numRoles = Role.computeRoles(theGame.getRules()).size()
        self.moveHistory = ArrayList()
        self.stateHistory = ArrayList()
        self.stateTimeHistory = ArrayList()
        self.errorHistory = ArrayList()
        self.goalValues = ArrayList()

    @__init__.register(object, str, Game, str)
    def __init___0(self, theJSON, theGame, authToken):
        """ generated source for method __init___0 """
        theMatchObject = JSONObject(theJSON)
        self.matchId = theMatchObject.getString("matchId")
        self.startClock = theMatchObject.getInt("startClock")
        self.playClock = theMatchObject.getInt("playClock")
        if theGame == None:
            self.theGame = RemoteGameRepository.loadSingleGame(theMatchObject.getString("gameMetaURL"))
            if self.theGame == None:
                raise RuntimeException("Could not find metadata for game referenced in Match object: " + theMatchObject.getString("gameMetaURL"))
        else:
            self.theGame = theGame
        if theMatchObject.has("previewClock"):
            self.previewClock = theMatchObject.getInt("previewClock")
        else:
            self.previewClock = -1
        self.startTime = Date(theMatchObject.getLong("startTime"))
        self.randomToken = theMatchObject.getString("randomToken")
        self.spectatorAuthToken = authToken
        self.isCompleted = theMatchObject.getBoolean("isCompleted")
        if theMatchObject.has("isAborted"):
            self.isAborted = theMatchObject.getBoolean("isAborted")
        else:
            self.isAborted = False
        self.numRoles = Role.computeRoles(self.theGame.getRules()).size()
        self.moveHistory = ArrayList()
        self.stateHistory = ArrayList()
        self.stateTimeHistory = ArrayList()
        self.errorHistory = ArrayList()
        theMoves = theMatchObject.getJSONArray("moves")
        i = 0
        while i < len(theMoves):
            while j < len(moveElements):
                theMove.add(GdlFactory.createTerm(moveElements.getString(j)))
                j += 1
            self.moveHistory.add(theMove)
            i += 1
        theStates = theMatchObject.getJSONArray("states")
        i = 0
        while i < len(theStates):
            while j < len(stateElements):
                theState.add(GdlFactory.create("( true " + stateElements.get(j).__str__() + " )"))
                j += 1
            self.stateHistory.add(theState)
            i += 1
        theStateTimes = theMatchObject.getJSONArray("stateTimes")
        i = 0
        while i < len(theStateTimes):
            self.stateTimeHistory.add(Date(theStateTimes.getLong(i)))
            i += 1
        if theMatchObject.has("errors"):
            while i < len(theErrors):
                while j < len(errorElements):
                    theMoveErrors.add(errorElements.getString(j))
                    j += 1
                self.errorHistory.add(theMoveErrors)
                i += 1
        self.goalValues = ArrayList()
        try:
            while i < len(theGoalValues):
                self.goalValues.add(theGoalValues.getInt(i))
                i += 1
        except JSONException as e:
            pass
        #  TODO: Add a way to recover cryptographic public keys and signatures.
        #  Or, perhaps loading a match into memory for editing should strip those?
        if theMatchObject.has("playerNamesFromHost"):
            self.thePlayerNamesFromHost = ArrayList()
            while i < len(thePlayerNames):
                self.thePlayerNamesFromHost.add(thePlayerNames.getString(i))
                i += 1
        if theMatchObject.has("isPlayerHuman"):
            self.isPlayerHuman = ArrayList()
            while i < len(isPlayerHumanArray):
                self.isPlayerHuman.add(isPlayerHumanArray.getBoolean(i))
                i += 1

    #  Mutators 
    def setCryptographicKeys(self, k):
        """ generated source for method setCryptographicKeys """
        self.theCryptographicKeys = k

    def enableScrambling(self):
        """ generated source for method enableScrambling """
        self.theGdlScrambler = MappingGdlScrambler(Random(self.startTime.getTime()))
        for rule in theGame.getRules():
            self.theGdlScrambler.scramble(rule)

    def setPlayerNamesFromHost(self, thePlayerNames):
        """ generated source for method setPlayerNamesFromHost """
        self.thePlayerNamesFromHost = thePlayerNames

    def getPlayerNamesFromHost(self):
        """ generated source for method getPlayerNamesFromHost """
        return self.thePlayerNamesFromHost

    def setWhichPlayersAreHuman(self, isPlayerHuman):
        """ generated source for method setWhichPlayersAreHuman """
        self.isPlayerHuman = isPlayerHuman

    def appendMoves(self, moves):
        """ generated source for method appendMoves """
        self.moveHistory.add(moves)

    def appendMoves2(self, moves):
        """ generated source for method appendMoves2 """
        #  NOTE: This is appendMoves2 because it Java can't handle two
        #  appendMove methods that both take List objects with different
        #  templatized parameters.
        theMoves = ArrayList()
        for m in moves:
            theMoves.add(m.getContents())
        self.appendMoves(theMoves)

    def appendState(self, state):
        """ generated source for method appendState """
        self.stateHistory.add(state)
        self.stateTimeHistory.add(Date())

    def appendErrors(self, errors):
        """ generated source for method appendErrors """
        self.errorHistory.add(errors)

    def appendNoErrors(self):
        """ generated source for method appendNoErrors """
        theNoErrors = ArrayList()
        i = 0
        while i < self.numRoles:
            theNoErrors.add("")
            i += 1
        self.errorHistory.add(theNoErrors)

    def markCompleted(self, theGoalValues):
        """ generated source for method markCompleted """
        self.isCompleted = True
        if theGoalValues != None:
            self.goalValues.addAll(theGoalValues)

    def markAborted(self):
        """ generated source for method markAborted """
        self.isAborted = True

    #  Complex accessors 
    def toJSON(self):
        """ generated source for method toJSON """
        theJSON = JSONObject()
        try:
            theJSON.put("matchId", self.matchId)
            theJSON.put("randomToken", self.randomToken)
            theJSON.put("startTime", self.startTime.getTime())
            theJSON.put("gameMetaURL", getGameRepositoryURL())
            theJSON.put("isCompleted", self.isCompleted)
            theJSON.put("isAborted", self.isAborted)
            theJSON.put("states", JSONArray(renderArrayAsJSON(renderStateHistory(self.stateHistory), True)))
            theJSON.put("moves", JSONArray(renderArrayAsJSON(renderMoveHistory(self.moveHistory), False)))
            theJSON.put("stateTimes", JSONArray(renderArrayAsJSON(self.stateTimeHistory, False)))
            if len(self.errorHistory) > 0:
                theJSON.put("errors", JSONArray(renderArrayAsJSON(renderErrorHistory(self.errorHistory), False)))
            if len(self.goalValues) > 0:
                theJSON.put("goalValues", self.goalValues)
            theJSON.put("previewClock", self.previewClock)
            theJSON.put("startClock", self.startClock)
            theJSON.put("playClock", self.playClock)
            if self.thePlayerNamesFromHost != None:
                theJSON.put("playerNamesFromHost", self.thePlayerNamesFromHost)
            if self.isPlayerHuman != None:
                theJSON.put("isPlayerHuman", self.isPlayerHuman)
            theJSON.put("scrambled", self.theGdlScrambler.scrambles() if self.theGdlScrambler != None else False)
        except JSONException as e:
            return None
        if self.theCryptographicKeys != None:
            try:
                SignableJSON.signJSON(theJSON, self.theCryptographicKeys.thePublicKey, self.theCryptographicKeys.thePrivateKey)
                if not SignableJSON.isSignedJSON(theJSON):
                    raise Exception("Could not recognize signed match: " + theJSON)
                if not SignableJSON.verifySignedJSON(theJSON):
                    raise Exception("Could not verify signed match: " + theJSON)
            except Exception as e:
                System.err.println(e)
                theJSON.remove("matchHostPK")
                theJSON.remove("matchHostSignature")
        return theJSON.__str__()

    def toXML(self):
        """ generated source for method toXML """
        try:
            theXML.append("<match>")
            for key in JSONObject.getNames(theJSON):
                if isinstance(value, (JSONObject, )):
                    raise RuntimeException("Unexpected embedded JSONObject in match JSON with tag " + key + "; could not convert to XML.")
                elif not (isinstance(value, (JSONArray, ))):
                    theXML.append(renderLeafXML(key, theJSON.get(key)))
                elif key == "states":
                    theXML.append(renderStateHistoryXML(self.stateHistory))
                elif key == "moves":
                    theXML.append(renderMoveHistoryXML(self.moveHistory))
                elif key == "errors":
                    theXML.append(renderErrorHistoryXML(self.errorHistory))
                else:
                    theXML.append(renderArrayXML(key, value))
            theXML.append("</match>")
            return theXML.__str__()
        except JSONException as je:
            return None

    def getMostRecentMoves(self):
        """ generated source for method getMostRecentMoves """
        if len(self.moveHistory) == 0:
            return None
        return self.moveHistory.get(len(self.moveHistory) - 1)

    def getMostRecentState(self):
        """ generated source for method getMostRecentState """
        if len(self.stateHistory) == 0:
            return None
        return self.stateHistory.get(len(self.stateHistory) - 1)

    def getGameRepositoryURL(self):
        """ generated source for method getGameRepositoryURL """
        return getGame().getRepositoryURL()

    def __str__(self):
        """ generated source for method toString """
        return self.toJSON()

    #  Simple accessors 
    def getMatchId(self):
        """ generated source for method getMatchId """
        return self.matchId

    def getRandomToken(self):
        """ generated source for method getRandomToken """
        return self.randomToken

    def getSpectatorAuthToken(self):
        """ generated source for method getSpectatorAuthToken """
        return self.spectatorAuthToken

    def getGame(self):
        """ generated source for method getGame """
        return self.theGame

    def getMoveHistory(self):
        """ generated source for method getMoveHistory """
        return self.moveHistory

    def getStateHistory(self):
        """ generated source for method getStateHistory """
        return self.stateHistory

    def getStateTimeHistory(self):
        """ generated source for method getStateTimeHistory """
        return self.stateTimeHistory

    def getErrorHistory(self):
        """ generated source for method getErrorHistory """
        return self.errorHistory

    def getPreviewClock(self):
        """ generated source for method getPreviewClock """
        return self.previewClock

    def getPlayClock(self):
        """ generated source for method getPlayClock """
        return self.playClock

    def getStartClock(self):
        """ generated source for method getStartClock """
        return self.startClock

    def getStartTime(self):
        """ generated source for method getStartTime """
        return self.startTime

    def isCompleted(self):
        """ generated source for method isCompleted """
        return self.isCompleted

    def isAborted(self):
        """ generated source for method isAborted """
        return self.isAborted

    def getGoalValues(self):
        """ generated source for method getGoalValues """
        return self.goalValues

    def getGdlScrambler(self):
        """ generated source for method getGdlScrambler """
        return self.theGdlScrambler

    #  Static methods 
    @classmethod
    def getRandomString(cls, nLength):
        """ generated source for method getRandomString """
        theGenerator = Random()
        theString = ""
        i = 0
        while i < nLength:
            if nVal < 26:
                theString += str(('a' + nVal))
            elif nVal < 52:
                theString += str(('A' + (nVal - 26)))
            elif nVal < 62:
                theString += str(('0' + (nVal - 52)))
            i += 1
        return theString

    #  JSON rendering methods 
    @classmethod
    def renderArrayAsJSON(cls, theList, useQuotes):
        """ generated source for method renderArrayAsJSON """
        s = "["
        i = 0
        while i < len(theList):
            #  AppEngine-specific, not needed yet: if (o instanceof Text) o = ((Text)o).getValue();
            if isinstance(o, (Date, )):
                o = (o).getTime()
            if useQuotes:
                s += "\""
            s += o.__str__()
            if useQuotes:
                s += "\""
            if i < len(theList) - 1:
                s += ", "
            i += 1
        return s + "]"

    @classmethod
    def renderStateHistory(cls, stateHistory):
        """ generated source for method renderStateHistory """
        renderedStates = ArrayList()
        for aState in stateHistory:
            renderedStates.add(renderStateAsSymbolList(aState))
        return renderedStates

    @classmethod
    def renderMoveHistory(cls, moveHistory):
        """ generated source for method renderMoveHistory """
        renderedMoves = ArrayList()
        for aMove in moveHistory:
            renderedMoves.add(cls.renderArrayAsJSON(aMove, True))
        return renderedMoves

    @classmethod
    def renderErrorHistory(cls, errorHistory):
        """ generated source for method renderErrorHistory """
        renderedErrors = ArrayList()
        for anError in errorHistory:
            renderedErrors.add(cls.renderArrayAsJSON(anError, True))
        return renderedErrors

    @classmethod
    def renderStateAsSymbolList(cls, theState):
        """ generated source for method renderStateAsSymbolList """
        #  Strip out the TRUE proposition, since those are implied for states.
        s = "( "
        for sent in theState:
            s += sentString.substring(6, 2 - len(sentString)).trim() + " "
        return s + ")"

    #  XML Rendering methods -- these are horribly inefficient and are included only for legacy/standards compatibility 
    @classmethod
    def renderLeafXML(cls, tagName, value):
        """ generated source for method renderLeafXML """
        return "<" + tagName + ">" + value.__str__() + "</" + tagName + ">"

    @classmethod
    def renderMoveHistoryXML(cls, moveHistory):
        """ generated source for method renderMoveHistoryXML """
        theXML = StringBuilder()
        theXML.append("<history>")
        for move in moveHistory:
            theXML.append("<move>")
            for action in move:
                theXML.append(cls.renderLeafXML("action", renderGdlToXML(action)))
            theXML.append("</move>")
        theXML.append("</history>")
        return theXML.__str__()

    @classmethod
    def renderErrorHistoryXML(cls, errorHistory):
        """ generated source for method renderErrorHistoryXML """
        theXML = StringBuilder()
        theXML.append("<errorHistory>")
        for errors in errorHistory:
            theXML.append("<errors>")
            for error in errors:
                theXML.append(cls.renderLeafXML("error", error))
            theXML.append("</errors>")
        theXML.append("</errorHistory>")
        return theXML.__str__()

    @classmethod
    def renderStateHistoryXML(cls, stateHistory):
        """ generated source for method renderStateHistoryXML """
        theXML = StringBuilder()
        theXML.append("<herstory>")
        for state in stateHistory:
            theXML.append(renderStateXML(state))
        theXML.append("</herstory>")
        return theXML.__str__()

    @classmethod
    def renderStateXML(cls, state):
        """ generated source for method renderStateXML """
        theXML = StringBuilder()
        theXML.append("<state>")
        for sentence in state:
            theXML.append(renderGdlToXML(sentence))
        theXML.append("</state>")
        return theXML.__str__()

    @classmethod
    def renderArrayXML(cls, tag, arr):
        """ generated source for method renderArrayXML """
        theXML = StringBuilder()
        i = 0
        while i < len(arr):
            theXML.append(cls.renderLeafXML(tag, arr.get(i)))
            i += 1
        return theXML.__str__()

    @classmethod
    def renderGdlToXML(cls, gdl):
        """ generated source for method renderGdlToXML """
        rval = ""
        if isinstance(gdl, (GdlConstant, )):
            return c.getValue()
        elif isinstance(gdl, (GdlFunction, )):
            if f.__name__.__str__() == "true":
                return "<fact>" + cls.renderGdlToXML(f.get(0)) + "</fact>"
            else:
                rval += "<relation>" + f.__name__ + "</relation>"
                while i < f.arity():
                    pass
                    i += 1
                return rval
        elif isinstance(gdl, (GdlRelation, )):
            if relation.__name__.__str__() == "true":
                while i < relation.arity():
                    pass
                    i += 1
                return rval
            else:
                rval += "<relation>" + relation.__name__ + "</relation>"
                while i < relation.arity():
                    pass
                    i += 1
                return rval
        else:
            System.err.println("gdlToXML Error: could not handle " + gdl.__str__())
            return None
コード例 #24
0
ファイル: sapappsutils.py プロジェクト: deezeesms/dd-git
	def getTransactionsInfo(self, transactions):
		mapTransactionToInfo = HashMap()
		mapProgramToTransaction = HashMap()

		if (transactions == None) or (len(transactions) == 0):
			logger.info("getTransactionsInfo: transactions list is empty")
			return mapTransactionToInfo
		
		transactionsRS = self.__client.executeQuery('TSTC', '', 'TCODE', transactions, 'TCODE,PGMNA,DYPNO')#@@CMD_PERMISION sap protocol execution
		while transactionsRS.next():
			transaction = transactionsRS.getString("TCODE")
			program = transactionsRS.getString("PGMNA")
			screen = transactionsRS.getString("DYPNO")
			if logger.isDebugEnabled():
				logger.debug("-------------------------------------------------------")
				logger.debug("getTransactionsInfo: transaction = " + transaction)
				logger.debug("getTransactionsInfo: program = " + program)
				logger.debug("getTransactionsInfo: screen = " + screen)
				logger.debug("-------------------------------------------------------")

			if (program == None) or (len(program) == 0):
				program = "N/A"
				logger.info("getTransactionsInfo: program for transaction [" + str(transaction) + "] is no available - setting to N/A.")

			info = TransactionInfo(transaction,program,screen)
			mapTransactionToInfo.put(transaction,info)
			transForProgram = mapProgramToTransaction.get(program)
			if transForProgram == None:
				transForProgram = ArrayList()
				mapProgramToTransaction.put(program,transForProgram)
			transForProgram.add(transaction)

		if logger.isDebugEnabled():
			logger.debug("getTransactionsInfo: mapProgramToTransaction = " + str(mapProgramToTransaction))

		if len(mapProgramToTransaction) == 0:
			logger.info("getTransactionsInfo: failed to get programs for transactions " + str(transactions))
			return mapProgramToTransaction

		objNames = ArrayList(mapProgramToTransaction.keySet())
		objNames.addAll(mapTransactionToInfo.keySet())
		
		
		programsRS = self.__client.executeQuery('TADIR', "(OBJECT = 'PROG' OR OBJECT = 'TRAN') AND ", 'OBJ_NAME', objNames, 'OBJECT,OBJ_NAME,VERSID,DEVCLASS')#@@CMD_PERMISION sap protocol execution
		
		while programsRS.next():
			objectType = programsRS.getString("OBJECT")
			if objectType == "PROG":
				program = programsRS.getString("OBJ_NAME")
				version = programsRS.getString("VERSID")
				transForProgram = mapProgramToTransaction.get(program)
				if transForProgram != None:
					
					for ti in transForProgram:
						info = mapTransactionToInfo.get(ti)
						if info == None:
							logger.info("program: Failed to find info for transaction [" + str(transaction) + "]")
						else:
							info.version = version
				else:
					logger.info("getTransactionsInfo: failed getting transactions for program [" + str(program) + "]")
			else: # transaction
				devclass = programsRS.getString("DEVCLASS");
				transaction = programsRS.getString("OBJ_NAME")
				info = mapTransactionToInfo.get(transaction)
				if info == None:
					logger.info("transaction: Failed to find info for transaction [" + str(transaction) + "]")
					info = TransactionInfo(transaction,"N/A","")
					mapTransactionToInfo.put(transaction,info)
				info.devclass = devclass

		if logger.isDebugEnabled():
			logger.debug("--------------------------------------------------")
			logger.debug("getTransactionsInfo: returning transaction info " + str(mapTransactionToInfo))
			logger.debug("--------------------------------------------------")

		return mapTransactionToInfo
コード例 #25
0
 def addFormToCompletedValues(cls, form, completedSentenceFormValues, constantChecker):
     """ generated source for method addFormToCompletedValues """
     sentences = ArrayList()
     sentences.addAll(constantChecker.getTrueSentences(form))
     completedSentenceFormValues.put(form, sentences)
コード例 #26
0
		w = p2.getW()
		# Not sure these will act as pointers
		l[0] = l[0] / LAYER_SCALE + box.x
		l[1] = l[1] / LAYER_SCALE + box.y
		w[0] = w[0] / LAYER_SCALE + box.x
		w[1] = w[1] / LAYER_SCALE + box.y

# Free memory
project.getLoader().releaseAll()

# Collect current transforms from patches
inf_area = infinite_area()
vector_data = ArrayList()
for layer in layers:
	vector_data.addAll(
			cast_collection(layer.getDisplayables(VectorData, False, True),
			VectorData, True))
vector_data.addAll(
		cast_collection(layerset.getZDisplayables(VectorData, True),
		VectorData, True))

# Propagate before or propagate after
# TO DO

# Apply transforms to patches
progress = 0
for mesh, layer in zip(meshes, layers):
	Utils.log("Applying transforms to patches...")
	IJ.showProgress(0, len(layers))

	mlt = MovingLeastSquaresTransform2()