本文整理匯總了Python中Files.join方法的典型用法代碼示例。如果您正苦於以下問題:Python Files.join方法的具體用法?Python Files.join怎麽用?Python Files.join使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Files
的用法示例。
在下文中一共展示了Files.join方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: loadGroup
# 需要導入模塊: import Files [as 別名]
# 或者: from Files import join [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)
示例2: __init__
# 需要導入模塊: import Files [as 別名]
# 或者: from Files import join [as 別名]
def __init__(self, group):
self.group = group #Which Searcher this is
self.fileName = Files.getFileName(Files.join(self.searchesFolder, "Group"+group.groupID))
#Will only be set on load. This is the groupID of the parent group
self.parentID = None #(stored because many groups we save messages for groups that no longer exist on GroupMe)
self._messageList = [] #This contains all known messages in chronological order. Values should all be standard strings
self._hasLoaded = False
示例3: __init__
# 需要導入模塊: import Files [as 別名]
# 或者: from Files import join [as 別名]
def __init__(self, group):
#Users will be "verified" when communicating with the server.
#People who do not exist will not usually be sent in requests for group members
self.hasVerified = False
self.group = group #Group reference
self.dirName = Files.join(Files.getGroupFolder(self.group), "Users")
#Note: position in userList is not static
self.userList = [] #This will be where users are normally stored
self.IDDict = {}
self.aliasList = {}
#Creates folder if it does not exist
Files.createFolder(self.dirName)
示例4: __init__
# 需要導入模塊: import Files [as 別名]
# 或者: from Files import join [as 別名]
def __init__(self, ID = None, groupID = None): #groupID is the GroupMe groupID, not internal (ID is internal)
self.groupID = groupID
self.name = None
self.image = None
self.password = None #This should be in MainGroup, but it doesn't save an attrTable and I have no way of changing it without breaking existing server
#The owner is not necessary, but if there are multiple users with tokens, this will resolve issues
self.owner = None #The owner is a token of the owner user
self.bot = None #This is the group's bot id that it uses to post messages
#These are just save objects to be used by other modules
self.analytics = {}
self.commands = {}
self.markedForDeletion = False #Groups can get deleted. I want to delete the ones that don't exist, just not during initialization
groupRegister(self, ID) #If no ID, will assign an id automatically
self.folderPath = Files.getGroupFolder(self)
self.filePath = Files.getFileName(Files.join(self.folderPath, SAVE_FILE_NAME))
#This UserList should be empty and just a reference to the object
#Users should be loaded in postInit once we have gotten user data from internet
self.users = Users.UserList(self)
self.handler = Network.GroupMeHandler(self)
self.commandBuilder = Commands.CommandBuilder(self)
示例5: getFileName
# 需要導入模塊: import Files [as 別名]
# 或者: from Files import join [as 別名]
def getFileName(self):
if not self.ID: log.error("Attempted to get file name for unloaded or unset user")
return Files.getFileName(Files.join(Files.getGroupFolder(self.group), "Users", self.ID or "DEFAULT_USER"))