当前位置: 首页>>代码示例>>Python>>正文


Python Collections.singleton方法代码示例

本文整理汇总了Python中java.util.Collections.singleton方法的典型用法代码示例。如果您正苦于以下问题:Python Collections.singleton方法的具体用法?Python Collections.singleton怎么用?Python Collections.singleton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Collections的用法示例。


在下文中一共展示了Collections.singleton方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: exportAll

# 需要导入模块: from java.util import Collections [as 别名]
# 或者: from java.util.Collections import singleton [as 别名]
def exportAll(exportConfigFile, generalConfigFile):
    try:
        print "Loading export config from :", exportConfigFile
        exportConfigProp = loadProps(exportConfigFile,generalConfigFile)
        adminUrl = exportConfigProp.get("adminUrl")
        user = exportConfigProp.get("user")
        passwd = exportConfigProp.get("password")

        jarFileName = exportConfigProp.get("jarFileName")
        customFile = exportConfigProp.get("customizationFile")

        passphrase = exportConfigProp.get("passphrase")
        project = exportConfigProp.get("project")

        connectToServer(user, passwd, adminUrl)
        print 'connected'

        ALSBConfigurationMBean = findService("ALSBConfiguration", "com.bea.wli.sb.management.configuration.ALSBConfigurationMBean")
        print "ALSBConfiguration MBean found"

        print project
        if project == None :
            ref = Ref.DOMAIN
            collection = Collections.singleton(ref)
            if passphrase == None :
                print "Export the config"
                theBytes = ALSBConfigurationMBean.export(collection, true, None)
            else :
                print "Export and encrypt the config"
                theBytes = ALSBConfigurationMBean.export(collection, true, passphrase)
        else :
            ref = Ref.makeProjectRef(project);
            print "Export the project", project
            collection = Collections.singleton(ref)
            theBytes = ALSBConfigurationMBean.exportProjects(collection, passphrase)
        print 'fileName',jarFileName
        aFile = File(jarFileName)
        print 'file',aFile
        out = FileOutputStream(aFile)
        out.write(theBytes)
        out.close()
        print "ALSB Configuration file: "+ jarFileName + " has been exported"

        if customFile != None:
            print collection
            query = EnvValueQuery(None, Collections.singleton(EnvValueTypes.WORK_MANAGER), collection, false, None, false)
            customEnv = FindAndReplaceCustomization('Set the right Work Manager', query, 'Production System Work Manager')
            print 'EnvValueCustomization created'
            customList = ArrayList()
            customList.add(customEnv)
            print customList
            aFile = File(customFile)
            out = FileOutputStream(aFile)
            Customization.toXML(customList, out)
            out.close()

#        print "ALSB Dummy Customization file: "+ customFile + " has been created"
    except:
        raise
开发者ID:robertoporfiro,项目名称:guavatools,代码行数:61,代码来源:export.py

示例2: makeNextAssignmentValid

# 需要导入模块: from java.util import Collections [as 别名]
# 或者: from java.util.Collections import singleton [as 别名]
 def makeNextAssignmentValid(self):
     """ generated source for method makeNextAssignmentValid """
     if self.nextAssignment == None:
         return
     # Something new that can pop up with functional constants...
     i = 0
     while i < len(self.nextAssignment):
         if self.nextAssignment.get(i) == None:
             # Some function doesn't agree with the answer here
             # So what do we increment?
             incrementIndex(self.plan.getIndicesToChangeWhenNull().get(i))
             if self.nextAssignment == None:
                 return
             i = -1
         i += 1
     # Find all the unsatisfied distincts
     # Find the pair with the earliest var. that needs to be changed
     varsToChange = ArrayList()
     d = 0
     while d < self.plan.getDistincts().size():
         # The assignments must use the assignments implied by nextAssignment
         if term1 == term2:
             # need to change one of these
             varsToChange.add(self.plan.getVarsToChangePerDistinct().get(d))
         d += 1
     if not varsToChange.isEmpty():
         # We want just the one, as it is a full restriction on its
         # own behalf
         changeOneInNext(Collections.singleton(varToChange))
开发者ID:hobson,项目名称:ggpy,代码行数:31,代码来源:AssignmentIteratorImpl.py

示例3: exportAll

# 需要导入模块: from java.util import Collections [as 别名]
# 或者: from java.util.Collections import singleton [as 别名]
def exportAll():
    try:

        ALSBConfigurationMBean = findService("ALSBConfiguration", "com.bea.wli.sb.management.configuration.ALSBConfigurationMBean")
        print "ALSBConfiguration MBean found"

        print project
        if project == "None" :
            ref = Ref.DOMAIN
            collection = Collections.singleton(ref)
            if passphrase == None :
                print "Export the config"
                theBytes = ALSBConfigurationMBean.export(collection, true, None)
            else :
                print "Export and encrypt the config"
                theBytes = ALSBConfigurationMBean.export(collection, true, passphrase)
        else :
            ref = Ref.makeProjectRef(project);
            print "Export the project", project
            collection = Collections.singleton(ref)
            theBytes = ALSBConfigurationMBean.exportProjects(collection, passphrase)

        aFile = File(exportJar)
        out = FileOutputStream(aFile)
        out.write(theBytes)
        out.close()
        print "ALSB Configuration file: "+ exportJar + " has been exported"

        if customFile != "None":
            print collection
            query = EnvValueQuery(None, Collections.singleton(EnvValueTypes.WORK_MANAGER), collection, false, None, false)
            customEnv = FindAndReplaceCustomization('Set the right Work Manager', query, 'Production System Work Manager')
            print 'EnvValueCustomization created'
            customList = ArrayList()
            customList.add(customEnv)
            print customList
            aFile = File(customFile)
            out = FileOutputStream(aFile)
            Customization.toXML(customList, out)
            out.close()

        print "ALSB Dummy Customization file: "+ customFile + " has been created"
    except:
        raise
开发者ID:jurandirjuks,项目名称:osbutils,代码行数:46,代码来源:export.py

示例4: exportAll

# 需要导入模块: from java.util import Collections [as 别名]
# 或者: from java.util.Collections import singleton [as 别名]
def exportAll():
    try:

        ALSBConfigurationMBean = findService("ALSBConfiguration", "com.bea.wli.sb.management.configuration.ALSBConfigurationMBean")
        print "ALSBConfiguration MBean found"

        print project
        if project == "None" :
            ref = Ref.DOMAIN
            collection = Collections.singleton(ref)
            if passphrase == None :
                print "Export the config"
                theBytes = ALSBConfigurationMBean.export(collection, true, None)
            else :
                print "Export and encrypt the config"
                theBytes = ALSBConfigurationMBean.export(collection, true, passphrase)
        else :
            ref = Ref.makeProjectRef(project);
            print "Export the project", project
            collection = Collections.singleton(ref)
            theBytes = ALSBConfigurationMBean.exportProjects(collection, passphrase)

        aFile = File(exportJar)
        out = FileOutputStream(aFile)
        out.write(theBytes)
        out.close()
        print "ALSB Configuration file: "+ exportJar + " has been exported"

        if customFile != "None":
            print collection
# see com.bea.wli.sb.util.EnvValueTypes in sb-kernel-api.jar for the values

#EnvValueQuery evquery =
#     new EnvValueQuery(
#         null,        // search across all resource types
#         Collections.singleton(EnvValueTypes.URI_ENV_VALUE_TYPE), // search only the URIs
#         null,        // search across all projects and folders.
#         true,        // only search across resources that are
#                      // actually modified/imported in this session
#         "localhost", // the string we want to replace
#         false        // not a complete match of URI. any URI
#                      // that has "localhost" as substring will match
#         );

            refTypes = HashSet()
            refTypes.add(EnvValueTypes.SERVICE_URI_TABLE)
            refTypes.add(EnvValueTypes.SERVICE_URI)
            query = EnvValueQuery(Collections.singleton(Refs.BUSINESS_SERVICE_TYPE), refTypes, collection, false, "search string", false)
#           query = EnvValueQuery(None, Collections.singleton(EnvValueTypes.SERVICE_URI_TABLE), collection, false, "search string", false)
            customEnv = FindAndReplaceCustomization('new endpoint url', query, 'replace string')

#            object = QualifiedEnvValue(Refs.makeBusinessSvcRef(ref,'file'), Refs.BUSINESS_SERVICE_TYPE, "XSDvalidation/file", "aaa")
#            objects = ArrayList()
#            objects.add(object)
#            customEnv2 = EnvValueCustomization('Set the right endpoints', objects)

            print 'EnvValueCustomization created'
            customList = ArrayList()
            customList.add(customEnv)
#            customList.add(customEnv2)

            print customList
            aFile = File(customFile)
            out = FileOutputStream(aFile)
            Customization.toXML(customList, out)
            out.close()

        print "ALSB Dummy Customization file: "+ customFile + " has been created"
    except:
        raise
开发者ID:A3a3e1,项目名称:soa_tools,代码行数:72,代码来源:export.py

示例5: create_0

# 需要导入模块: from java.util import Collections [as 别名]
# 或者: from java.util.Collections import singleton [as 别名]
 def create_0(cls, description, verbose):
     """ generated source for method create_0 """
     print "Building propnet..."
     startTime = System.currentTimeMillis()
     description = GdlCleaner.run(description)
     description = DeORer.run(description)
     description = VariableConstrainer.replaceFunctionValuedVariables(description)
     description = Relationizer.run(description)
     description = CondensationIsolator.run(description)
     if verbose:
         for gdl in description:
             print gdl
     # We want to start with a rule graph and follow the rule graph.
     # Start by finding general information about the game
     model = SentenceDomainModelFactory.createWithCartesianDomains(description)
     # Restrict domains to values that could actually come up in rules.
     # See chinesecheckers4's "count" relation for an example of why this
     # could be useful.
     model = SentenceDomainModelOptimizer.restrictDomainsToUsefulValues(model)
     if verbose:
         print "Setting constants..."
     constantChecker = ConstantCheckerFactory.createWithForwardChaining(model)
     if verbose:
         print "Done setting constants"
     sentenceFormNames = SentenceForms.getNames(model.getSentenceForms())
     usingBase = sentenceFormNames.contains("base")
     usingInput = sentenceFormNames.contains("input")
     # For now, we're going to build this to work on those with a
     # particular restriction on the dependency graph:
     # Recursive loops may only contain one sentence form.
     # This describes most games, but not all legal games.
     dependencyGraph = model.getDependencyGraph()
     if verbose:
         print "Computing topological ordering... ",
         System.out.flush()
     ConcurrencyUtils.checkForInterruption()
     topologicalOrdering = getTopologicalOrdering(model.getSentenceForms(), dependencyGraph, usingBase, usingInput)
     if verbose:
         print "done"
     roles = Role.computeRoles(description)
     components = HashMap()
     negations = HashMap()
     trueComponent = Constant(True)
     falseComponent = Constant(False)
     functionInfoMap = HashMap()
     completedSentenceFormValues = HashMap()
     for form in topologicalOrdering:
         ConcurrencyUtils.checkForInterruption()
         if verbose:
             print "Adding sentence form " + form,
             System.out.flush()
         if constantChecker.isConstantForm(form):
             if verbose:
                 print " (constant)"
             # Only add it if it's important
             if form.__name__ == cls.LEGAL or form.__name__ == cls.GOAL or form.__name__ == cls.INIT:
                 # Add it
                 for trueSentence in constantChecker.getTrueSentences(form):
                     trueProp.addInput(trueComponent)
                     trueComponent.addOutput(trueProp)
                     components.put(trueSentence, trueComponent)
             if verbose:
                 print "Checking whether " + form + " is a functional constant..."
             addConstantsToFunctionInfo(form, constantChecker, functionInfoMap)
             addFormToCompletedValues(form, completedSentenceFormValues, constantChecker)
             continue 
         if verbose:
             print 
         # TODO: Adjust "recursive forms" appropriately
         # Add a temporary sentence form thingy? ...
         addSentenceForm(form, model, components, negations, trueComponent, falseComponent, usingBase, usingInput, Collections.singleton(form), temporaryComponents, temporaryNegations, functionInfoMap, constantChecker, completedSentenceFormValues)
         # TODO: Pass these over groups of multiple sentence forms
         if verbose and not temporaryComponents.isEmpty():
             print "Processing temporary components..."
         processTemporaryComponents(temporaryComponents, temporaryNegations, components, negations, trueComponent, falseComponent)
         addFormToCompletedValues(form, completedSentenceFormValues, components)
         # if(verbose)
         # TODO: Add this, but with the correct total number of components (not just Propositions)
         # print "  "+completedSentenceFormValues.get(form).size() + " components added";
     # Connect "next" to "true"
     if verbose:
         print "Adding transitions..."
     addTransitions(components)
     # Set up "init" proposition
     if verbose:
         print "Setting up 'init' proposition..."
     setUpInit(components, trueComponent, falseComponent)
     # Now we can safely...
     removeUselessBasePropositions(components, negations, trueComponent, falseComponent)
     if verbose:
         print "Creating component set..."
     componentSet = HashSet(components.values())
     # Try saving some memory here...
     components = None
     negations = None
     completeComponentSet(componentSet)
     ConcurrencyUtils.checkForInterruption()
     if verbose:
         print "Initializing propnet object..."
     # Make it look the same as the PropNetFactory results, until we decide
#.........这里部分代码省略.........
开发者ID:hobson,项目名称:ggpy,代码行数:103,代码来源:OptimizingPropNetFactory.py

示例6: __authorize_with_service_account

# 需要导入模块: from java.util import Collections [as 别名]
# 或者: from java.util.Collections import singleton [as 别名]
 def __authorize_with_service_account(service_account_json):
     credential = GoogleCredential.fromStream(IOUtils.toInputStream(service_account_json, StandardCharsets.UTF_8)).createScoped(Collections.singleton(AndroidPublisherScopes.ANDROIDPUBLISHER))
     return credential
开发者ID:xebialabs-community,项目名称:xld-android-play-plugin,代码行数:5,代码来源:AndroidPublisherHelper.py

示例7: unpublish

# 需要导入模块: from java.util import Collections [as 别名]
# 或者: from java.util.Collections import singleton [as 别名]
def unpublish():
    try:
        # Declare Variables
        sessionMBean = None
        alsbConfigurationMBean = None
        packageHome = sys.argv[4]

        # Connect to Server
        print "Connecting to server: ", sys.argv[3]
        connectToServer()

        # Create unique session name
        print "Creating unique session name"
        sessionName = createSessionName()
        print "Created session name :", sessionName

        # Create and start session
        print "Creating SessionMBean"
        sessionMBean = getSessionMBean(sessionName)
        print "SessionMBean started new session"

        # obtain the ALSBConfigurationMBean instance that operates
        # on the session that has just been created. Notice that
        # the name of the mbean contains the session name.
        print "Create ALSBConfiguration"
        alsbConfigurationMBean = findService(
            String(ALSBConfigurationMBean.NAME + ".").concat(sessionName), ALSBConfigurationMBean.TYPE
        )
        print "ALSBConfiguration MBean found", alsbConfigurationMBean

        # Perform updates or read operations in the session using alsbSession
        # sys.arg[4] is the root of the package
        print "INFO package root is " + packageHome
        psc_list = []

        try:
            file = open(packageHome + "/" + "osbundeployables.properties", "rb")
        except:
            print "ERROR failed to open osbundeployables.properties"
            raise
        for line in file.readlines():
            print "INFO removing " + line.rstrip()
            pscName = line.rstrip()
            if len(pscName) != 0:
                psc_list.append(pscName)
                projectRef = com.bea.wli.config.Ref(
                    com.bea.wli.config.Ref.PROJECT_REF, com.bea.wli.config.Ref.DOMAIN, pscName
                )
                if alsbConfigurationMBean.exists(projectRef):
                    alsbConfigurationMBean.delete(Collections.singleton(projectRef))

        print "INFO This session has removed for the following projects:"
        for psc in psc_list:
            print "\t" + psc

        try:
            sessionMBean.activateSession(sessionName, "Deleted projects" + "\t" + "\n\t".join(psc_list))
        except:
            print "ERROR problem encountered activating the session"
            print "INFO this can happen if one or more of the managed servers are not running"
            raise

    except:
        print "ERROR Unexpected error:", sys.exc_info()[0]
        if sessionMBean != None:
            sessionMBean.discardSession(sessionName)
            file.close()
            raise
开发者ID:nstreet,项目名称:autodeploy,代码行数:70,代码来源:unpublish.py


注:本文中的java.util.Collections.singleton方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。