本文整理汇总了Python中pyramid.compat.NativeIO.filename方法的典型用法代码示例。如果您正苦于以下问题:Python NativeIO.filename方法的具体用法?Python NativeIO.filename怎么用?Python NativeIO.filename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid.compat.NativeIO
的用法示例。
在下文中一共展示了NativeIO.filename方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: extract
# 需要导入模块: from pyramid.compat import NativeIO [as 别名]
# 或者: from pyramid.compat.NativeIO import filename [as 别名]
def extract(self):
value = self.params.get(self.name, null)
if hasattr(value, 'file'):
value.file.seek(0)
return {
'fp': value.file,
'filename': value.filename,
'mimetype': value.type,
'size': value.length}
elif value:
fp = NativeIO(value)
fp.filename = self.params.get('%s-filename'%self.name, '')
return {
'fp': fp,
'filename': self.params.get('%s-filename'%self.name, ''),
'mimetype': self.params.get('%s-mimetype'%self.name, ''),
'size': len(value)}
return null
示例2: extract
# 需要导入模块: from pyramid.compat import NativeIO [as 别名]
# 或者: from pyramid.compat.NativeIO import filename [as 别名]
def extract(self):
value = self.params.get(self.name, null)
if hasattr(value, "file"):
value.file.seek(0)
return {"fp": value.file, "filename": value.filename, "mimetype": value.type, "size": value.length}
elif value:
if not PY3 and isinstance(value, text_type):
value = value.encode("latin1")
fp = NativeIO(value)
fp.filename = self.params.get("%s-filename" % self.name, "")
return {
"fp": fp,
"filename": self.params.get("%s-filename" % self.name, ""),
"mimetype": self.params.get("%s-mimetype" % self.name, ""),
"size": len(value),
}
return null
示例3: extract
# 需要导入模块: from pyramid.compat import NativeIO [as 别名]
# 或者: from pyramid.compat.NativeIO import filename [as 别名]
def extract(self, default=null):
value = self.params.get(self.name, default)
if hasattr(value, 'file'):
return {
'fp': value.file,
'filename': value.filename,
'mimetype': value.type,
'size': value.length}
elif value:
if not PY3 and isinstance(value, text_type):
value = value.encode('latin1')
fp = NativeIO(value)
fp.filename = self.params.get('%s-filename'%self.name, '')
return {
'fp': fp,
'filename': self.params.get('%s-filename'%self.name, ''),
'mimetype': self.params.get('%s-mimetype'%self.name, ''),
'size': len(value)}
return default