本文整理汇总了Python中models.File.select方法的典型用法代码示例。如果您正苦于以下问题:Python File.select方法的具体用法?Python File.select怎么用?Python File.select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.File
的用法示例。
在下文中一共展示了File.select方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse
# 需要导入模块: from models import File [as 别名]
# 或者: from models.File import select [as 别名]
def parse(query):
if query == "":
return File.select()
tokens = tokenize(query)
result = _parse(iter(tokens))
try:
iter(result)
except TypeError:
result = File.select().join(Metadata, peewee.JOIN_LEFT_OUTER).where(result)
return result
示例2: get_entries
# 需要导入模块: from models import File [as 别名]
# 或者: from models.File import select [as 别名]
def get_entries():
"""Gets all file names currently in catalog"""
catalog_files = []
if File.select():
for item in File.select():
catalog_files.append(item.file_name)
else:
return catalog_files
return catalog_files
示例3: view_all_entries
# 需要导入模块: from models import File [as 别名]
# 或者: from models.File import select [as 别名]
def view_all_entries():
"""Gather all entries in the catalog, along with their metadata"""
all_entries = (FileTag
.select(FileTag, File, Tag)
.join(Tag)
.switch(FileTag)
.join(File)
.order_by(File.file_name))
# dictionary houses all files in catalog and each file's associated tags
files_with_tags = {}
for file_tag in all_entries:
f = file_tag.file_id
tag = file_tag.tag_id.tag_name
files_with_tags.setdefault(f.file_name, []).append(tag)
ordered_list = sorted([file_name for file_name in File.select()])
# Creates a list called of tuples called 'entries'
# each tuple containing name of catalog file and metadata
entries = []
for f_name in ordered_list:
f_name.file_name
f_name.description
f_name.date_created
tags = ' | '.join(sorted(files_with_tags.get(f_name.file_name, '')))
entries.append((f_name.file_name, f_name.description, f_name.date_created, tags))
return entries
示例4: UNTAGGED
# 需要导入模块: from models import File [as 别名]
# 或者: from models.File import select [as 别名]
def UNTAGGED():
tagged_files = Metadata.select(Metadata.file).where(Metadata.field != 'import-time')
return set(File.select().where(File.id.not_in(tagged_files)))
示例5: Token
# 需要导入模块: from models import File [as 别名]
# 或者: from models.File import select [as 别名]
def Token(token):
if ':' in token:
field, value = token.split(':', 1)
else:
field, value = 'tag', token
files = File.select().join(Metadata, peewee.JOIN_LEFT_OUTER)
return set(files.where((Metadata.field == field) & (Metadata.value == value)))
示例6: handle_backspace_key
# 需要导入模块: from models import File [as 别名]
# 或者: from models.File import select [as 别名]
def handle_backspace_key(self):
confirmDialog = wx.MessageDialog(self,
"Remove %s Files?" % self.thumbnailGrid.SelectedItemCount,
"Remove Files?",
style=wx.OK | wx.CANCEL)
confirmDialog.SetOKLabel("Delete")
if confirmDialog.ShowModal() == wx.ID_OK:
files = File.select().where(File.md5 << [item.Text for item in self.get_selected_thumbs()])
for file in files:
file.delete_instance(recursive=True)
# Repaint the tag list.
self.update_tags()
self.update_thumbnails()
self.preview = None
示例7: handle_T_key
# 需要导入模块: from models import File [as 别名]
# 或者: from models.File import select [as 别名]
def handle_T_key(self):
# Get the File objects corresponding to the selected thumbnails
files = File.select().where(File.md5 << [item.Text for item in self.get_selected_thumbs()])
# Determine the existing tags for these files.
old_tags = Metadata.filter(Metadata.file << files, Metadata.field.not_in(['import-time']))
old_tags = sorted(list(set(['%s:"%s"' % (t.field, t.value) for t in old_tags])))
dialog = wx.TextEntryDialog(None, "Tags:", "Modifiy Tags", value=", ".join(old_tags))
if dialog.ShowModal() == wx.ID_OK:
# Determine the new tags for these files.
new_tags = dialog.GetValue()
new_tags = [t.strip() for t in new_tags.split(",")]
# Add any new tags that have been added.
for token in set(new_tags) - set(old_tags):
# Determine the actual field and tags
if ':' in token:
field, value = token.split(':', 1)
else:
field, value = 'tag', token
value = value.strip('"')
# Create records for all selected files.
for file in files:
try:
Metadata(file=file, field=field, value=value).save()
except IntegrityError:
pass
# Remove any tags that were removed.
removed_tags = list(set(old_tags) - set(new_tags))
# Add any new tags that have been added.
for token in set(old_tags) - set(new_tags):
# Determine the actual field and tags
if ':' in token:
field, value = token.split(':', 1)
else:
field, value = 'tag', token
# Create records for all selected files.
value = value.strip('"')
Metadata.delete().where(Metadata.file << files,
Metadata.field == field,
Metadata.value == value).execute()
# Repaint the tag list.
self.update_tags()
示例8: folder
# 需要导入模块: from models import File [as 别名]
# 或者: from models.File import select [as 别名]
def folder(folder_name):
try:
f = Folder.get(name=folder_name)
except peewee.DoesNotExist:
return jsonify(message='error'), 404
if request.method == 'POST':
file = request.files['file']
if file:
actual_filename = secure_filename(
folder_name + '_' + file.filename)
if os.path.exists(os.path.join(app.config['UPLOAD_FOLDER'], actual_filename)):
return jsonify(message='error'), 409
file.save(
os.path.join(app.config['UPLOAD_FOLDER'], actual_filename))
f2 = File.create(folder=folder_name,
filename=file.filename,
public_share_url=generate_url(),
private_share_url=generate_url(),
private_share_password=generate_password(),
open_public_share=False,
open_private_share=False)
f2.save()
return jsonify(message='OK'), 201
if request.method == 'GET':
files = File.select().where(File.folder == folder_name)
items = [{
'filename': x.filename,
'public': x.public_share_url,
'private': x.private_share_url,
'password': x.private_share_password,
'openPublic': x.open_public_share,
'openPrivate': x.open_private_share
} for x in files]
return jsonify(message='OK', items=items)
if request.method == 'DELETE':
try:
f.delete_instance()
except peewee.IntegrityError:
return jsonify(message='error'), 409
return jsonify(message='OK')
示例9: __init__
# 需要导入模块: from models import File [as 别名]
# 或者: from models.File import select [as 别名]
def __init__(self, parent):
super(type(self), self).__init__(parent)
self.add_dir = "~/Pictures"
self._preview = None # Track the currently selected image, by md5.
self._filter = "" # Track the current Filter
self.filters = [] # Track previous Filters.
# Only update the preview when we stop changing the list selection
self.list_change_timer = wx.Timer(self)
# Load the Grid
self.thumbnail_index = {}
self.thumbnails = wx.ImageList()
self.thumbnailGrid.SetImageList(self.thumbnails, wx.IMAGE_LIST_NORMAL)
for f in File.select():
self.thumbnail_index[f.md5] = self.thumbnails.Add(f.as_bitmap())
self.update_thumbnails()
self.SetStatusText("Matching Images: %s" % self.thumbnailGrid.ItemCount)
self.update_tags()
示例10: HAS
# 需要导入模块: from models import File [as 别名]
# 或者: from models.File import select [as 别名]
def HAS(_, token):
return set(File.select().join(Metadata, peewee.JOIN_LEFT_OUTER).where(Metadata.field == token))
示例11: NOT
# 需要导入模块: from models import File [as 别名]
# 或者: from models.File import select [as 别名]
def NOT(token):
return set(File.select().where(File.id.not_in([f.id for f in token])))