本文整理汇总了Python中file.File.name方法的典型用法代码示例。如果您正苦于以下问题:Python File.name方法的具体用法?Python File.name怎么用?Python File.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类file.File
的用法示例。
在下文中一共展示了File.name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_file
# 需要导入模块: from file import File [as 别名]
# 或者: from file.File import name [as 别名]
def create_file(self, filePath, fileName):
file = File()
file.name = fileName
file.relPath = os.path.normpath(os.path.relpath(filePath, self.root))
file.originalPath = os.path.normpath(os.path.join(filePath, fileName))
t = os.path.getmtime(file.originalPath)
file.mTime = datetime.datetime.fromtimestamp(t)
t = os.path.getctime(file.originalPath)
file.cTime = datetime.datetime.fromtimestamp(t)
file.size = os.path.getsize(file.originalPath)
_, fileExtension = os.path.splitext(file.originalPath)
file.type = File.type_from_extension(fileExtension)
if file.type == fileConstants.TYPE_OTHER or file.type == fileConstants.TYPE_UNKNOWN:
return None
self.update_exif_metadata(file)
file.file_type = fileConstants.TYPE_FILESYSTEM
return file
示例2: add_file
# 需要导入模块: from file import File [as 别名]
# 或者: from file.File import name [as 别名]
def add_file(upload, file_name):
my_user = get_my_user()
current_directory_object = get_current_directory_object()
file_id = my_user.key.id() + get_path(file_name, current_directory_object)
file_key = ndb.Key(File, file_id)
if exists(file_key, current_directory_object.files):
file_object = File(id=file_id)
file_object.name = file_name
file_object.blob = upload.key()
file_object.put()
current_directory_object.files.append(file_key)
current_directory_object.put()
else:
# Delete uploaded file from the blobstore
blobstore.delete(upload.key())
logging.debug("A file with this name already exists in this directory!")
示例3: fetch_album_images
# 需要导入模块: from file import File [as 别名]
# 或者: from file.File import name [as 别名]
def fetch_album_images(self, album):
with self.max_threads_lock:
album_last_updated_string = self.get_json_key(album, ['ImagesLastUpdated'])
album_uri = self.get_json_key(album, ['Uris', 'AlbumImages', 'Uri'])
# Check cache for album!images results, if not, request from network.
cached_album_images = None
with self.cache_lock:
try:
_, cached_album_images_json = self.check_cache(album_uri, album_last_updated_string)
if cached_album_images_json is not None:
cached_album_images = json.loads(cached_album_images_json)
except Exception as e:
print 'Exception checking cache for album: ' + album_uri + ' :: ' + e.message
if cached_album_images is None:
if album_uri is None:
print 'Could not find album images Uri for album: ' + self.get_json_key(album, ['Name'])
return
cached_album_images_response = self.session.get(API_ORIGIN + album_uri, params = {'count':'1000000', '_expand' : 'ImageMetadata', '_expandmethod' : 'inline'}, headers={'Accept': 'application/json'})
cached_album_images = {}
try:
cached_album_images = cached_album_images_response.json()
with self.cache_lock:
self.put_cache(album_uri, album_last_updated_string, album, cached_album_images_response.text)
except Exception as e:
print 'Exception getting album :: ' + album_uri + ' :: ' + e.message + ' :: (%d)' % cached_album_images_response.status_code
print 'Full response:' + cached_album_images_response.text
images_array = self.get_json_key(cached_album_images, ['Response', 'AlbumImage'])
if images_array is None:
print 'Could not get images array for album: ' + self.get_json_key(album, ['Name']) + 'uri:' + album_uri
images_array = []
for image in images_array:
file = File()
file.name = self.get_json_key(image, ['FileName'])
is_video = self.get_json_key(image, ['IsVideo'])
if is_video == True:
#print 'Video: ' + file.name
continue
file.relativePath = os.path.normpath(self.get_json_key(album, ['UrlPath']))
file.originalPath = os.path.normpath(os.path.join(file.relativePath, file.name))
file.source = self.get_json_key(image, ['ArchivedUri'])
file.thumbnail = self.get_json_key(image, ['ThumbnailUrl'])
file.weburi = self.get_json_key(image, ['WebUri'])
file.uri = self.get_json_key(image, ['Uri'])
file.size = self.get_json_key(image, ['ArchivedSize'])
file.md5 = self.get_json_key(image, ['ArchivedMD5'])
_, file_extension = os.path.splitext(file.name)
file.type = File.type_from_extension(file_extension)
if file.type == fileConstants.TYPE_OTHER or file.type == fileConstants.TYPE_UNKNOWN:
pass
metadata = self.get_json_key(image, ['Uris', 'ImageMetadata', 'ImageMetadata'])
file.exif_width = self.get_json_key(image, ['OriginalWidth'])
file.exif_height = self.get_json_key(image, ['OriginalHeight'])
file.file_type = fileConstants.TYPE_SMUGMUG
if metadata is not None:
file.metadata = metadata
file.exif_aperture = self.get_json_key(metadata, ['Aperture'])
file.exif_date = self.get_json_key(metadata, ['DateTime']) or self.get_json_key(metadata, ['DateTimeCreated']) or self.get_json_key(metadata, ['DateTimeOriginal'])
file.exif_date_parsed = file.convert_time_string(file.exif_date)
file.exif_iso = self.get_json_key(metadata, ['ISO'])
# fl is a string, strip 'mm', convert to a double
try:
file.exif_focal_length = float(self.get_json_key(metadata, ['FocalLength']).replace('mm', ''))
except:
pass
file.exif_exposure = self.get_json_key(metadata, ['Exposure'])
file.exif_camera = self.get_json_key(metadata, ['Camera']) or self.get_json_key(metadata, ['Model'])
with self.output_lock:
self.add_file_to_hash(file, self.images)
self.increment_threadcount()