本文整理汇总了Python中pyasm.search.Search.column_exists方法的典型用法代码示例。如果您正苦于以下问题:Python Search.column_exists方法的具体用法?Python Search.column_exists怎么用?Python Search.column_exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.search.Search
的用法示例。
在下文中一共展示了Search.column_exists方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import column_exists [as 别名]
def execute(my):
filenames = my.kwargs.get("filenames")
upload_dir = Environment.get_upload_dir()
base_dir = upload_dir
search_type = my.kwargs.get("search_type")
key = my.kwargs.get("key")
relative_dir = my.kwargs.get("relative_dir")
if not relative_dir:
project_code = Project.get_project_code()
search_type_obj = SearchType.get(search_type)
table = search_type_obj.get_table()
relative_dir = "%s/%s" % (project_code, table)
server = TacticServerStub.get()
parent_key = my.kwargs.get("parent_key")
category = my.kwargs.get("category")
keywords = my.kwargs.get("keywords")
extra_data = my.kwargs.get("extra_data")
if extra_data:
extra_data = jsonloads(extra_data)
else:
extra_data = {}
# TODO: use this to generate a category
category_script_path = my.kwargs.get("category_script_path")
"""
ie:
from pyasm.checkin import ExifMetadataParser
parser = ExifMetadataParser(path=file_path)
tags = parser.get_metadata()
date = tags.get("EXIF DateTimeOriginal")
return date.split(" ")[0]
"""
if not SearchType.column_exists(search_type, "name"):
raise TacticException('The Ingestion puts the file name into the name column which is the minimal requirement. Please first create a "name" column for this sType.')
for count, filename in enumerate(filenames):
# first see if this sobjects still exists
search = Search(search_type)
search.add_filter("name", filename)
if relative_dir and search.column_exists("relative_dir"):
search.add_filter("relative_dir", relative_dir)
sobject = search.get_sobject()
# else create a new one
if not sobject:
sobject = SearchType.create(search_type)
sobject.set_value("name", filename)
if relative_dir and sobject.column_exists("relative_dir"):
sobject.set_value("relative_dir", relative_dir)
# extract metadata
file_path = "%s/%s" % (base_dir, File.get_filesystem_name(filename))
# TEST: convert on upload
try:
convert = my.kwargs.get("convert")
if convert:
message_key = "IngestConvert001"
cmd = ConvertCbk(**convert)
cmd.execute()
except Exception, e:
print "WARNING: ", e
if not os.path.exists(file_path):
raise Exception("Path [%s] does not exist" % file_path)
# get the metadata from this image
if SearchType.column_exists(search_type, "relative_dir"):
if category and category not in ['none', None]:
from pyasm.checkin import ExifMetadataParser
parser = ExifMetadataParser(path=file_path)
tags = parser.get_metadata()
date = tags.get("EXIF DateTimeOriginal")
if not date:
date_str = "No-Date"
else:
date_str = str(date)
# this can't be parsed correctly by dateutils
parts = date_str.split(" ")
date_str = parts[0].replace(":", "-")
#.........这里部分代码省略.........
示例2: get_display
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import column_exists [as 别名]
def get_display(self):
search_type = self.kwargs.get("search_type")
search = Search(search_type)
if not search.column_exists("_is_collection"):
return self.top
search.add_filter("_is_collection", True)
collections = search.get_sobjects()
dialog = DivWdg()
self.set_as_panel(dialog)
dialog.add_class('spt_col_dialog_top')
title_div = DivWdg()
title_div.add_style('margin: 10px')
title_div.add(HtmlElement.b("Add selected items to collection(s)"))
dialog.add(title_div)
add_div = DivWdg()
dialog.add(add_div)
icon = IconWdg(name="Add new collection", icon="BS_PLUS")
icon.add_style("opacity: 0.6")
icon.add_style("padding-right: 3px")
add_div.add(icon)
add_div.add("Create new Collection")
add_div.add_style("text-align: center")
add_div.add_style("background-color: #EEEEEE")
add_div.add_style("padding: 5px")
add_div.add_style("height: 20px")
add_div.add_class("hand")
insert_view = "edit_collection"
add_div.add_behavior( {
'type': 'listen',
'event_name': 'refresh_col_dialog',
'cbjs_action': '''
var dialog_content = bvr.src_el.getParent('.spt_col_dialog_top');
spt.panel.refresh(dialog_content);
'''})
add_div.add_behavior( {
'type': 'click_up',
'insert_view': insert_view,
'event_name': 'refresh_col_dialog',
'cbjs_action': '''
var top = bvr.src_el.getParent(".spt_table_top");
var table = top.getElement(".spt_table");
var search_type = top.getAttribute("spt_search_type");
// Hide the dialog when popup loads.
var dialog_top = bvr.src_el.getParent(".spt_dialog_top");
dialog_top.style.visibility = "hidden";
kwargs = {
search_type: search_type,
mode: "insert",
view: bvr.insert_view,
save_event: bvr.event_name,
show_header: false,
'num_columns': 2,
default: {
_is_collection: true
}
};
spt.panel.load_popup("Create New Collection", "tactic.ui.panel.EditWdg", kwargs);
'''
} )
content_div = DivWdg()
dialog.add(content_div)
content_div.add_style("width: 270px")
content_div.add_style("padding: 5px")
content_div.add_style("padding-bottom: 0px")
custom_cbk = {}
custom_cbk['enter'] = '''
var top = bvr.src_el.getParent(".spt_dialog");
var input = top.getElement(".spt_main_search");
var search_value = input.value.toLowerCase();
var collections = top.getElements(".spt_collection_div");
var num_result = 0;
var no_results_el = top.getElement(".spt_no_results");
for (i = 0; i < collections.length; i++) {
// Access the Collection title (without number count)
var collection_title = collections[i].getElement(".spt_collection_checkbox").getAttribute("collection_name").toLowerCase();
if (collection_title.indexOf(search_value) != '-1') {
collections[i].style.display = "block";
num_result += 1;
}
else {
collections[i].style.display = "none";
}
#.........这里部分代码省略.........
示例3: get_display
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import column_exists [as 别名]
def get_display(my):
search_type = my.kwargs.get("search_type")
search = Search(search_type)
if not search.column_exists("_is_collection"):
return my.top
search.add_filter("_is_collection", True)
collections = search.get_sobjects()
top = my.top
top.add_class("spt_dialog")
button = IconButtonWdg(title='Add to Collection', icon="BS_TH_LARGE", show_arrow=True)
top.add(button)
detail_wdg = DivWdg()
top.add(detail_wdg)
dialog = DialogWdg()
top.add(dialog)
dialog.set_as_activator(button, offset={'x':-25,'y': 0})
dialog.add_title("Collections")
dialog.add("<div style='margin: 10px'><b>Add selected items to a collection</b></div>")
add_div = DivWdg()
dialog.add(add_div)
icon = IconWdg(name="Add new collection", icon="BS_PLUS")
icon.add_style("opacity: 0.6")
icon.add_style("padding-right: 3px")
add_div.add(icon)
add_div.add("Create new Collection")
add_div.add_style("text-align: center")
add_div.add_style("background-color: #EEEEEE")
add_div.add_style("padding: 5px")
add_div.add_style("height: 20px")
add_div.add_class("hand")
insert_view = "edit_collection"
add_div.add_behavior( {
'type': 'click_up',
'insert_view': insert_view,
'cbjs_action': '''
var top = bvr.src_el.getParent(".spt_table_top");
var table = top.getElement(".spt_table");
var search_type = top.getAttribute("spt_search_type");
// Hide the dialog when popup loads.
var dialog_top = bvr.src_el.getParent(".spt_dialog_top");
dialog_top.style.visibility = "hidden";
kwargs = {
search_type: search_type,
mode: "insert",
view: bvr.insert_view,
save_event: bvr.event_name,
show_header: false,
'num_columns': 2,
default: {
_is_collection: true
}
};
spt.panel.load_popup("Add New Collection", "tactic.ui.panel.EditWdg", kwargs);
'''
} )
content_div = DivWdg()
dialog.add(content_div)
content_div.add_style("width: 270px")
content_div.add_style("padding: 5px")
content_div.add_style("padding-bottom: 0px")
custom_cbk = {}
custom_cbk['enter'] = '''
var top = bvr.src_el.getParent(".spt_dialog");
var input = top.getElement(".spt_main_search");
var search_value = input.value.toLowerCase();
var collections = top.getElements(".spt_collection_div");
var num_result = 0;
for (i = 0; i < collections.length; i++) {
// Access the Collection title (without number count)
var collection_title = collections[i].attributes[0].value.toLowerCase();
if (collection_title.indexOf(search_value) != '-1') {
collections[i].style.display = "block";
num_result += 1;
}
else {
collections[i].style.display = "none";
}
}
// if no search results, display all
if (num_result == 0) {
for (i = 0; i < collections.length; i++) {
collections[i].style.display = "block";
}
#.........这里部分代码省略.........
示例4: execute
# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import column_exists [as 别名]
def execute(my):
filenames = my.kwargs.get("filenames")
upload_dir = Environment.get_upload_dir()
base_dir = upload_dir
update_mode = my.kwargs.get("update_mode")
search_type = my.kwargs.get("search_type")
key = my.kwargs.get("key")
relative_dir = my.kwargs.get("relative_dir")
if not relative_dir:
project_code = Project.get_project_code()
search_type_obj = SearchType.get(search_type)
table = search_type_obj.get_table()
relative_dir = "%s/%s" % (project_code, table)
server = TacticServerStub.get()
parent_key = my.kwargs.get("parent_key")
category = my.kwargs.get("category")
keywords = my.kwargs.get("keywords")
update_data = my.kwargs.get("update_data")
extra_data = my.kwargs.get("extra_data")
if extra_data:
extra_data = jsonloads(extra_data)
else:
extra_data = {}
# TODO: use this to generate a category
category_script_path = my.kwargs.get("category_script_path")
"""
ie:
from pyasm.checkin import ExifMetadataParser
parser = ExifMetadataParser(path=file_path)
tags = parser.get_metadata()
date = tags.get("EXIF DateTimeOriginal")
return date.split(" ")[0]
"""
if not SearchType.column_exists(search_type, "name"):
raise TacticException('The Ingestion puts the file name into the name column which is the minimal requirement. Please first create a "name" column for this sType.')
input_prefix = update_data.get('input_prefix')
non_seq_filenames = []
# For sequence mode, take all filenames, and regenerate the filenames based on the function "find_sequences"
if update_mode == "sequence":
non_seq_filenames_dict, seq_digit_length = my.find_sequences(filenames)
# non_seq_filenames is a list of filenames that are stored in the None key,
# which are the filenames that are not part of a sequence, or does not contain
# a sequence pattern.
non_seq_filenames = non_seq_filenames_dict[None]
# delete the None key from list so filenames can be used in the latter for loop
del non_seq_filenames_dict[None]
filenames = non_seq_filenames_dict.keys()
if filenames == []:
raise TacticException('No sequences are found in files. Please follow the pattern of [filename] + [digits] + [file extension (optional)]. Examples: [abc_1001.png, abc_1002.png] [abc.1001.mp3, abc.1002.mp3] [abc_100_1001.png, abc_100_1002.png]')
for count, filename in enumerate(filenames):
# Check if files should be updated.
# If so, attempt to find one to update.
# If more than one is found, do not update.
if update_mode in ["true", "True"]:
# first see if this sobjects still exists
search = Search(search_type)
search.add_filter("name", filename)
if relative_dir and search.column_exists("relative_dir"):
search.add_filter("relative_dir", relative_dir)
sobjects = search.get_sobjects()
if len(sobjects) > 1:
sobject = None
elif len(sobjects) == 1:
sobject = sobjects[0]
else:
sobject = None
elif update_mode == "sequence":
if not FileGroup.is_sequence(filename):
raise TacticException('Please modify sequence naming to have at least three digits.')
search = Search(search_type)
search.add_filter("name", filename)
if relative_dir and search.column_exists("relative_dir"):
search.add_filter("relative_dir", relative_dir)
sobjects = search.get_sobjects()
if sobjects:
sobject = sobjects[0]
else:
sobject = None
else:
sobject = None
# Create a new file
if not sobject:
sobject = SearchType.create(search_type)
#.........这里部分代码省略.........