本文整理汇总了Python中common.Common.safe_file_name方法的典型用法代码示例。如果您正苦于以下问题:Python Common.safe_file_name方法的具体用法?Python Common.safe_file_name怎么用?Python Common.safe_file_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common.Common
的用法示例。
在下文中一共展示了Common.safe_file_name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_file_name
# 需要导入模块: from common import Common [as 别名]
# 或者: from common.Common import safe_file_name [as 别名]
def _get_file_name(self, file):
mime_type = file['mimeType']
title = file['title']
version = ""
drivetype = ""
ext = ""
if self.is_duplicate(file):
version = ' (' + file['version'] + ')'
if ('application/vnd.google-apps' in mime_type) and (mime_type != "application/vnd.google-apps.folder"):
if 'exportLinks' in file:
export_link = self._get_download_url(file)
ext = '.' + export_link[export_link.index('exportFormat=') + 13:]
drivetype = mime_type[mime_type.rindex('.'):]
if '.' in title:
extension = title[title.rindex('.'):]
base = title[:title.rindex('.')]
filename = "{base}{extension}{drivetype}{ext}".format(base=base, extension=extension, drivetype=drivetype, ext=ext)
else:
filename = "{title}{drivetype}{ext}".format(title=title,drivetype=drivetype, ext=ext)
if '.' in filename:
extension = filename[filename.rindex('.'):]
base = filename[:filename.rindex('.')]
filename = "{base}{version}{extension}".format(base=base, version=version, extension=extension)
else:
filename = "{title}{version}".format(title=title, version=version)
return Common.safe_file_name(filename)
示例2: _redirect_messages_to_save
# 需要导入模块: from common import Common [as 别名]
# 或者: from common.Common import safe_file_name [as 别名]
def _redirect_messages_to_save(self, data, slip):
data = data.read().decode()
json_data = json.loads(data)
if "messages" in json_data:
for message in json_data["messages"]:
download_uri = self.get_message_uri(message)
_filetitle = message["id"] + ".txt"
filetitle = Common.safe_file_name(_filetitle)
self.file_size_bytes += int(message["sizeEstimate"])
if filetitle != filetitle:
self.project.log("exception", "Normalized '{}' to '{}'".format(_filetitle, filetitle),"warning", True)
self.content_downloader.put(Downloader.DownloadSlip(download_uri, message, filetitle, "snippet"))
示例3: _get_file_name
# 需要导入模块: from common import Common [as 别名]
# 或者: from common.Common import safe_file_name [as 别名]
def _get_file_name(self, file):
fname = os.path.basename(file['path'])
return Common.safe_file_name(fname)