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


Python Unpickler.load方法代码示例

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


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

示例1: load_brain

# 需要导入模块: from pickle import Unpickler [as 别名]
# 或者: from pickle.Unpickler import load [as 别名]
    def load_brain(self):
        """
        Load the actor and critic's configurations from the corresponding files.
        :return: True if configuration loaded, False otherwise
        """

        try:
            # Open the file
            with open("Config/actor.cfg", "rb") as cfg_file:
                # Instantiate an Unpickler
                unpickle = Unpickler(cfg_file)
                # Load the object
                self._actor = unpickle.load()

            # Repeat the operation for the actor
            with open("Config/critic.cfg", "rb") as cfg_file:
                unpickle = Unpickler(cfg_file)
                self._critic = unpickle.load()

            # Return True because everything up to this point went well
            return True

        except IOError as error:
            # Display a message detailing the error
            print("No prevously recorded actor and/or critic configuration")
            # Return False to warn that something bad happened, leaving the actor and critic in an unknown state
            return False
开发者ID:davinellulinvega,项目名称:RoomLearningMapping,代码行数:29,代码来源:Sphero.py

示例2: __init__

# 需要导入模块: from pickle import Unpickler [as 别名]
# 或者: from pickle.Unpickler import load [as 别名]
 def __init__(self, outFile, saveFile):
     computerName=platform.node().capitalize()
     userName=getpass.getuser().capitalize()
     self.outFile=outFile
     self.saveFile=saveFile
     self._kinds={"kind":kind, "adjective":adjective,"entity":entity,"name":name,"thing":thing,"person":person,
                  "computer":computer,"user":user,"infinitive":infinitive,"pronoun":pronoun,
                  "male":male,"female":female,"place":place,"location":location,"number":number,
                  "time":time}
     try:
         infile = open(saveFile,'rb')
         unpickle = Unpickler(infile)
         kinds=unpickle.load()
         self._loadKinds(kinds, "entity")
         self._loadKinds(kinds, "adjective")
         #globalsBak=globals().copy() #backup globals
         globals().update(self._kinds)   #inject dynamic classes into globals
         self._entities,self._antecedents,self._names,self._adjectives=unpickle.load()
         #globals().clear()   #clear globals
         #globals().update(globalsBak)    #restore backup
         infile.close
     except: # IOError:
         self._entities={computerName:computer(computerName,self,True),userName:user(userName,self,True),"Vibranium":thing("Vibranium",self)}
         self._antecedents={"I":self._entities[userName],"you":self._entities[computerName]}
         self._names={}
         self._adjectives={}
         for key,value in self._entities.items():
             if value in self._names:
                 self._names[value].add(key)
             else:
                 self._names[value]={key}
     self._temp={}   #stores 'a/an' objects, possessives, prepositional phrases, and numbers
开发者ID:alebahn,项目名称:Understander,代码行数:34,代码来源:understanding.py

示例3: doUnPickling

# 需要导入模块: from pickle import Unpickler [as 别名]
# 或者: from pickle.Unpickler import load [as 别名]
def doUnPickling(option,pickleFile):
    varRootHash = {}
    from pickle import Unpickler
    if not os.path.isfile(pickleFile):
        print "DEBUG:[doUnPickling] PickleFile does not exist."
        if option == "TERM_CTFMAP":
            print "****ERROR Unpickling****"; exit(1)
        doPickling(option,pickleFile)
    f = open(pickleFile,"r")
    if option == "STEM_TEXT":
        up = Unpickler(f)
        varRootHash = up.load()
        f.close()
#        print "DEBUG:[doUnPickling] Unpickled "+option+": "#,unpkldData
        return varRootHash  
    elif option == "TERM_CTFMAP" :
        print "DEBUG:[doUnpickling] UnPickling Term CTF..."
        up = Unpickler(f)
        termCtfHash = up.load()
        f.close()
        return termCtfHash
    elif option == "STOPLIST" :
        print "DEBUG:[doUnpickling] UnPickling stoplist..."
        up = Unpickler(f)
        stoplst = up.load()
        f.close()
        return stoplst
    elif option == "CATALOG" :
        print "DEBUG:[doUnpickling] UnPickling Catalog.."
        up = Unpickler(f)
        termSeekHash = up.load()
        f.close()
        return termSeekHash
开发者ID:ede-n,项目名称:Information-Retrieval,代码行数:35,代码来源:Index_corpus.py

示例4: load

# 需要导入模块: from pickle import Unpickler [as 别名]
# 或者: from pickle.Unpickler import load [as 别名]
def load(fn):
    aunpickler = Unpickler(open(fn,'r'));
    dis_list = aunpickler.load()
    data4hz = aunpickler.load()
    exp_list = aunpickler.load()
    pairs = []
    for hzkey in data4hz:
        p = FreqPair()
        p.ex = hzkey[0]
        p.em = hzkey[1]
        p.flu = data4hz[hzkey]
        pairs.append(p)
    return (dis_list,pairs,exp_list)
开发者ID:vrepina,项目名称:linre,代码行数:15,代码来源:freq_pairs.py

示例5: fromFile

# 需要导入模块: from pickle import Unpickler [as 别名]
# 或者: from pickle.Unpickler import load [as 别名]
def fromFile(worldDir):
    '''Load a world object from a campaign bundle'''
    pickleFileName = os.path.join(worldDir, 'data.pickle')
    pickle = Unpickler(open(pickleFileName, 'rb'))
    fileVersion = pickle.load()
    if fileVersion != openfrontier.PICKLE_VERSION:
        raise TypeError(
                "Data version mismatch: expected {0}; got {1}.".format(
                    openfrontier.PICKLE_VERSION, fileVersion))
    world = pickle.load()
    if not isinstance(world, OFWorld):
        raise TypeError(
                "Expected OFWorld; got {0}".format(type(world).__name__))
    return world
开发者ID:bfrobin446,项目名称:openfrontier,代码行数:16,代码来源:ofworld.py

示例6: recover_snapshot

# 需要导入模块: from pickle import Unpickler [as 别名]
# 或者: from pickle.Unpickler import load [as 别名]
 def recover_snapshot(self):
     file = open(path.join(self.basedir,fu.last_snapshot_file(self.basedir)),"rb")
     if not file:
         return None
     logger.debug("Recovering snapshot from: " + file.name)
     unpickler = Unpickler(file)
     return unpickler.load()
开发者ID:felipecruz,项目名称:coopy,代码行数:9,代码来源:snapshot.py

示例7: loads

# 需要导入模块: from pickle import Unpickler [as 别名]
# 或者: from pickle.Unpickler import load [as 别名]
 def loads(self, s):
     up = Unpickler(BytesIO(s))
     up.persistent_load = self._get_object
     try:
         return up.load()
     except KeyError as e:
         raise UnpicklingError("Could not find Node class for %s" % e)
开发者ID:pkuyken,项目名称:RDFTranslator,代码行数:9,代码来源:store.py

示例8: testDeepCopyCanInvalidate

# 需要导入模块: from pickle import Unpickler [as 别名]
# 或者: from pickle.Unpickler import load [as 别名]
    def testDeepCopyCanInvalidate(self):
        """
        Tests regression for invalidation problems related to missing
        readers and writers values in cloned objects (see
        http://mail.zope.org/pipermail/zodb-dev/2008-August/012054.html)
        """
        import ZODB.MappingStorage
        database = DB(ZODB.blob.BlobStorage(
            'blobs', ZODB.MappingStorage.MappingStorage()))
        connection = database.open()
        root = connection.root()
        transaction.begin()
        root['blob'] = Blob()
        transaction.commit()

        stream = StringIO()
        p = Pickler(stream, 1)
        p.dump(root['blob'])
        u = Unpickler(stream)
        stream.seek(0)
        clone = u.load()
        clone._p_invalidate()

        # it should also be possible to open the cloned blob
        # (even though it won't contain the original data)
        clone.open()

        # tearDown
        database.close()
开发者ID:grodniewicz,项目名称:oship,代码行数:31,代码来源:testblob.py

示例9: Environment

# 需要导入模块: from pickle import Unpickler [as 别名]
# 或者: from pickle.Unpickler import load [as 别名]
class Environment(object):

    handle = None
    loader = None
    writer = None
    data = None


    def __init__(self):
    
        self.handle = open("environment.pickle", 'w+')
        self.loader = Unpickler(self.handle)
        self.writer = Pickler(self.handle)

        try:
            self.data = self.loader.load()
        except EOFError:
            print "WARNING: Empty environment, creating environment file."
            self.data = {}
            self.write(self.data)


    def write(self, data):

        self.writer.dump(data)
开发者ID:phryk,项目名称:crust,代码行数:27,代码来源:daemon.py

示例10: __init__

# 需要导入模块: from pickle import Unpickler [as 别名]
# 或者: from pickle.Unpickler import load [as 别名]
    def __init__(self, partIn, maxThreadsIn=8):
        super(ValgrindAnalyzer, self).__init__()
        self.release = None
        self.plat    = None
        self.part    = partIn
        self.ignoreLibs = ['libm-2.5.so','libpthread-2.5.so', 'cmsRun']
        self.libList = []

        prodFileName = os.environ['CMSSW_RELEASE_BASE']+'/src/ReleaseProducts.list'
        self.rpr = RelProdReader()
        self.rpr.readProducts(prodFileName)

        vgCmdFileName = os.environ['CMSSW_RELEASE_BASE']+'/qaLogs/vgCmds.pkl'
        from pickle import Unpickler
        vgCmdFile = open(vgCmdFileName, 'r')
        vgCmdPklr = Unpickler(vgCmdFile)
        self.vgCmds = vgCmdPklr.load()
        vgCmdFile.close()

        self.toDo = []

        self.threadList = []
        self.maxThreads = maxThreadsIn
        self.threadStatus = {}
        self.threadTiming = {}
开发者ID:cms-sw,项目名称:int-build,代码行数:27,代码来源:redoValgrind.py

示例11: _reader

# 需要导入模块: from pickle import Unpickler [as 别名]
# 或者: from pickle.Unpickler import load [as 别名]
    def _reader(self, data):
        unpickler = Unpickler(StringIO(data))

        while True:
            try:
                self._process(*unpickler.load())
            except EOFError:
                break
开发者ID:A-K,项目名称:naali,代码行数:10,代码来源:bridge.py

示例12: readData

# 需要导入模块: from pickle import Unpickler [as 别名]
# 或者: from pickle.Unpickler import load [as 别名]
 def readData(self):
     import config
     pklFileName = config.siteInfo['qaPath']+'/navigator-summary.pkl'
     pklIn = open(pklFileName,'r')
     from pickle import Unpickler
     upklr = Unpickler(pklIn)
     self.data = upklr.load()
     pklIn.close()
开发者ID:cms-sw,项目名称:cmssdt-web,代码行数:10,代码来源:makeIgNavSummPlots.py

示例13: testPickleUnpickle

# 需要导入模块: from pickle import Unpickler [as 别名]
# 或者: from pickle.Unpickler import load [as 别名]
    def testPickleUnpickle(self):
        s = BytesIO()
        p = Pickler(s)
        p.dump(Allow)
        s.seek(0)
        u = Unpickler(s)
        newAllow = u.load()

        self.assertTrue(newAllow is Allow)
开发者ID:jean,项目名称:zope.securitypolicy,代码行数:11,代码来源:test_settings.py

示例14: loads

# 需要导入模块: from pickle import Unpickler [as 别名]
# 或者: from pickle.Unpickler import load [as 别名]
 def loads(self, string):
     f = StringIO(string)
     unpickler = Unpickler(f)
     unpickler.memo = self._unpicklememo
     res = unpickler.load()
     self._updatepicklememo()
     #print >>debug, "loaded", res
     #print >>debug, "unpicklememo", self._unpicklememo
     return res
开发者ID:enyst,项目名称:plexnet,代码行数:11,代码来源:mypickle.py

示例15: unpickle_outcomes

# 需要导入模块: from pickle import Unpickler [as 别名]
# 或者: from pickle.Unpickler import load [as 别名]
def unpickle_outcomes(fn, desired_iterations):
        fh = open(fn, 'r')
        unp = Unpickler(fh)
        outcomes = unp.load()
        fh.close()
        kept_iterations = outcomes["ITERATIONS"]
        if kept_iterations == desired_iterations:
            return outcomes
        raise IOError
开发者ID:eliwald,项目名称:blackjack,代码行数:11,代码来源:blackjack.py


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