當前位置: 首頁>>代碼示例>>Python>>正文


Python Files.read方法代碼示例

本文整理匯總了Python中Files.read方法的典型用法代碼示例。如果您正苦於以下問題:Python Files.read方法的具體用法?Python Files.read怎麽用?Python Files.read使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Files的用法示例。


在下文中一共展示了Files.read方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: loadGroup

# 需要導入模塊: import Files [as 別名]
# 或者: from Files import read [as 別名]
def loadGroup(folder):
  if type(folder) == int:
    folder = "Group "+str(folder)
  try:
    loadedGroup = _folderCache[folder]
    log.group("Group already loaded, returning group:", loadedGroup)
    return loadedGroup
  except KeyError:
    pass #Just continue loading
  try:
    groupNumber = int(re.search("\d+", folder).group())
    log.group("Loading Group:", groupNumber)
  except AttributeError:
    raise RuntimeError("Group Folder '"+folder+"' does not have a group number")
  try:
    with open(Files.getFileName(Files.join(folder, SAVE_FILE_NAME))) as file:
      groupType = Files.read(file)
      log.group("Group Type:",groupType)
      newGroup = globals()[groupType](groupNumber).load(file) #Load arbitrary class
      _folderCache[folder] = newGroup #Save it to a cache so we cannot load twice
      return newGroup
      #except (KeyError, TypeError, AttributeError) as Error: #I actually think I want this to be a halting error.
      #  log.error("Failed to properly load group file:", Error)
  except FileNotFoundError: #The group was improperly initialized/saved
    log.group.error("Group had no load file. Deleting folder")
    Files.deleteFolder(folder)
開發者ID:civilwargeeky,項目名稱:GroupMeServer3,代碼行數:28,代碼來源:Groups.py

示例2: load

# 需要導入模塊: import Files [as 別名]
# 或者: from Files import read [as 別名]
 def load(self):
   if not self._hasLoaded:
     log.save.low("Loading",self)
     self._hasLoaded = True
     try:
       with open(self.fileName, "r") as file:
         self.parentID = Files.read(file)
         self._messageList = json.load(file)
     except FileNotFoundError:
       log.save.debug("No file found for",self,", not loading")
     except ValueError:
       log.save.error("Invalid JSON Saving on server stop")
開發者ID:civilwargeeky,項目名稱:GroupMeServer3,代碼行數:14,代碼來源:MsgSearch.py

示例3: load

# 需要導入模塊: import Files [as 別名]
# 或者: from Files import read [as 別名]
 def load(self, fileHandle):
   super().load(fileHandle)
   self.collectiveGroup = int(Files.read(fileHandle))
   log.save("Group ID set on subgroup load:", self.collectiveGroup)
開發者ID:civilwargeeky,項目名稱:GroupMeServer3,代碼行數:6,代碼來源:Groups.py

示例4: load

# 需要導入模塊: import Files [as 別名]
# 或者: from Files import read [as 別名]
 def load(self, handle):
   Files.loadAttrTable(self, handle)
   self._tempID = str(Files.read(handle))
   #We should be loaded after the parent has loaded
   self._parentObj = self.group.parent.users.getUserFromID(self._tempID)
   return self
開發者ID:civilwargeeky,項目名稱:GroupMeServer3,代碼行數:8,代碼來源:Users.py


注:本文中的Files.read方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。