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


Python Files.getFileName方法代碼示例

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


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

示例1: loadGroup

# 需要導入模塊: import Files [as 別名]
# 或者: from Files import getFileName [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: readIPFile

# 需要導入模塊: import Files [as 別名]
# 或者: from Files import getFileName [as 別名]
def readIPFile():
  _ipFile = Files.getFileName("ip_address")
  try:
    with open(_ipFile) as file:
      return file.read().rstrip()
  except FileNotFoundError:
    log.info.debug("No ip file")
開發者ID:civilwargeeky,項目名稱:GroupMeServer3,代碼行數:9,代碼來源:Network.py

示例3: __init__

# 需要導入模塊: import Files [as 別名]
# 或者: from Files import getFileName [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
開發者ID:civilwargeeky,項目名稱:GroupMeServer3,代碼行數:9,代碼來源:MsgSearch.py

示例4: hasIPChanged

# 需要導入模塊: import Files [as 別名]
# 或者: from Files import getFileName [as 別名]
def hasIPChanged():
  global IP_ADDRESS
  
  _ipFile = Files.getFileName("ip_address")

  #Get the last ip we had
  oldIP = IP_ADDRESS
  if not oldIP:
    oldIP = readIPFile() or IP_ADDRESS #(IP_ADDRESS if we cannot read)
  
  #Get our new ip, then save it
  newIP = getIPAddress()
  if oldIP != newIP: #Only need to write if we changed anything
    with open(_ipFile, "w") as file:
      file.write(newIP)
    
  if oldIP == None: return False #This means we haven't checked before, so the ip can't be differentiating
  return oldIP != newIP
開發者ID:civilwargeeky,項目名稱:GroupMeServer3,代碼行數:20,代碼來源:Network.py

示例5: __init__

# 需要導入模塊: import Files [as 別名]
# 或者: from Files import getFileName [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)
開發者ID:civilwargeeky,項目名稱:GroupMeServer3,代碼行數:26,代碼來源:Groups.py

示例6: getFileName

# 需要導入模塊: import Files [as 別名]
# 或者: from Files import getFileName [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"))
開發者ID:civilwargeeky,項目名稱:GroupMeServer3,代碼行數:5,代碼來源:Users.py

示例7: __init__

# 需要導入模塊: import Files [as 別名]
# 或者: from Files import getFileName [as 別名]
 def __init__(self, title, defaultJoke = defaultDefaultJoke):
   super().__init__(title, defaultJoke)
   self.isLoaded = False
   self.fileName = Files.getFileName(self.title.replace(" ",""), prefix = "LOGFACT_")
開發者ID:civilwargeeky,項目名稱:GroupMeServer3,代碼行數:6,代碼來源:Jokes.py

示例8: securityPurge

# 需要導入模塊: import Files [as 別名]
# 或者: from Files import getFileName [as 別名]
import json
import re
import os
from textwrap import dedent
from time import time
from urllib.parse import urlparse, parse_qs, urlencode
from uuid import uuid4

import Events
import Files
import Groups
import Logging as log
import MsgSearch
### CONFIG AREA ###
ID_LIFETIME = datetime.timedelta(days = 3).total_seconds() #We will tell to store cookie forever, but if its older than this we require a new sign-in
ID_FILE     = Files.getFileName("Server_UUIDs")
DEFAULT_DIR = "http"
ADMIN_PASSWORD = "shiboleeth" #I think that's the Canvas page for MST

NEVER_EXPIRES = "; expires=Fri, 31 Dec 9999 23:59:59 GMT" #Concatenate with cookies to make them never expire

### SECURITY MODULE ###
"""The security module handles keeping track of uuids sent to the website in a request of web resources"""
#The _idDict is a dict of uuid : tuple(last page access, [list of group IDs allowed in])
_idDict = None
#This goes through all uuids and checks their last time
def securityPurge():
  global _idDict
  if _idDict == None: securityLoad()
  timeNow = int(time())
  for user in _idDict.copy():
開發者ID:civilwargeeky,項目名稱:GroupMeServer3,代碼行數:33,代碼來源:Website.py


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