本文整理汇总了Python中pyasm.biz.File.get_by_code方法的典型用法代码示例。如果您正苦于以下问题:Python File.get_by_code方法的具体用法?Python File.get_by_code怎么用?Python File.get_by_code使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.biz.File
的用法示例。
在下文中一共展示了File.get_by_code方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_file_obj
# 需要导入模块: from pyasm.biz import File [as 别名]
# 或者: from pyasm.biz.File import get_by_code [as 别名]
def _get_file_obj(my, snapshot, type='main'):
if type:
xpath = "snapshot/file[@type='%s']" %type
else:
xpath = "snapshot/file[@type]"
xml = snapshot.get_xml_value('snapshot')
node = xml.get_node(xpath)
file = None
if node is not None:
file_code = Xml.get_attribute(node, "file_code")
file = File.get_by_code(file_code)
return file
示例2: _init_file_object
# 需要导入模块: from pyasm.biz import File [as 别名]
# 或者: from pyasm.biz.File import get_by_code [as 别名]
def _init_file_object(my):
'''initialize the file object. Some fields are still empty before checkin postprocess'''
# if set externally already, skip and return
if my._file_object:
return
file_type = my.get_file_type()
if file_type and my.snapshot:
# get the file_object
file_code = my.snapshot.get_file_code_by_type(file_type)
from pyasm.biz import File
my._file_object = File.get_by_code(file_code)
示例3: _test_inplace_checkin
# 需要导入模块: from pyasm.biz import File [as 别名]
# 或者: from pyasm.biz.File import get_by_code [as 别名]
def _test_inplace_checkin(self):
# create a new test.txt file
tmp_dir = Environment.get_tmp_dir()
dir = "%s/temp" % tmp_dir
if not os.path.exists(dir):
os.makedirs(dir)
file_path = "%s/test_inplace.txt" % dir
if os.path.exists(file_path):
os.unlink(file_path)
file = open(file_path, 'w')
file.write("whatever")
file.close()
# inplace checkin: tell tactic that this is the correct path
mode = "inplace"
base_dir = tmp_dir
context = "inplace"
checkin = FileCheckin(self.person, file_path, context=context, mode=mode)
checkin.execute()
snapshot = checkin.get_snapshot()
file_code = snapshot.get_file_code_by_type("main")
file_object = File.get_by_code(file_code)
relative_dir = file_object.get_value("relative_dir")
# The relative dir is empty if the file is outside the repository
self.assertEquals("", relative_dir)
lib_dir = snapshot.get_lib_dir(file_type="main")
file_name = snapshot.get_file_name_by_type("main")
lib_path = "%s/%s" % (lib_dir, file_name)
self.assertEquals( True, os.path.exists(lib_path) )
self.assertEquals( file_path, lib_path)
# check in a file alredy in the repository
asset_dir = Config.get_value("checkin", "asset_base_dir", sub_key="default")
file_path2 = "%s/unittest/text.txt" % asset_dir
file = open(file_path2, 'w')
file.write("whatever")
file.close()
checkin = FileCheckin(self.person, file_path2, context=context, mode=mode)
checkin.execute()
snapshot = checkin.get_snapshot()
file_code = snapshot.get_file_code_by_type("main")
file_object = File.get_by_code(file_code)
# check that the relative dir is as expected
relative_dir = file_object.get_value("relative_dir")
self.assertEquals( relative_dir, "unittest" )
# check that the path returned correctly
lib_path = snapshot.get_path_by_type("main")
self.assertEquals( file_path2, lib_path )
if os.path.exists(file_path):
os.unlink(file_path)
if os.path.exists(file_path2):
os.unlink(file_path2)
示例4: init
# 需要导入模块: from pyasm.biz import File [as 别名]
# 或者: from pyasm.biz.File import get_by_code [as 别名]
def init(my):
WebContainer.register_cmd("pyasm.widget.AnnotateCbk")
sobject = my.get_current_sobject()
if not sobject:
if not my.__dict__.has_key("search_type"):
web = WebContainer.get_web()
my.search_type = web.get_form_value("search_type")
my.search_id = web.get_form_value("search_id")
if not my.search_type:
my.add("No search type")
return
search = Search(my.search_type)
search.add_id_filter(my.search_id)
sobject = search.get_sobject()
snapshot = Snapshot.get_latest_by_sobject(sobject)
# TODO:
# this is a bit klunky
snapshot_xml = snapshot.get_xml_value("snapshot")
file_code = snapshot_xml.get_value("snapshot/file[@type='web']/@file_code")
file = File.get_by_code(file_code)
web_dir = snapshot.get_web_dir()
path = "%s/%s" % (web_dir, file.get_full_file_name() )
# add the annotate js object
script = HtmlElement.script("annotate = new Annotate()")
my.add(script)
# add the image
my.add("<h3>Image Annotations</h3>")
width = 600
img = HtmlElement.img(path)
img.add_style("position: absolute")
img.set_id("annotate_image")
img.add_style("left: 0px")
img.add_style("top: 0px")
img.add_style("opacity: 1.0")
img.add_style("z-index: 1")
img.add_style("width", width)
img.add_event("onmouseup", "annotate.add_new(event)")
my.add(img)
# test
version = snapshot.get_value("version")
if version != 1:
last_version = version - 1
snapshot = Snapshot.get_by_version( \
my.search_type, my.search_id, version=last_version )
snapshot_xml = snapshot.get_xml_value("snapshot")
file_code = snapshot_xml.get_value("snapshot/file[@type='web']/@file_code")
file = File.get_by_code(file_code)
web_dir = snapshot.get_web_dir()
path = "%s/%s" % (web_dir, file.get_full_file_name() )
img = HtmlElement.img(path)
img.set_id("annotate_image_alt")
img.add_style("position: absolute")
img.add_style("left: 0px")
img.add_style("top: 0px")
img.add_style("opacity: 1.0")
img.add_style("z-index: 0")
img.add_style("width", width)
img.add_event("onmouseup", "annotate.add_new(event)")
my.add(img)
#script = HtmlElement.script("align_element('%s','%s')" % \
# ("annotate_image", "annotate_image_alt") )
#my.add(script)
div = DivWdg()
div.add_style("position: absolute")
div.add_style("left: 620")
div.add_style("top: 300")
my.add(div)
button = IconButtonWdg("Switch", IconWdg.REFRESH, True)
button.add_event("onclick", "annotate.switch_alt()")
div.add(button)
button = IconButtonWdg("Opacity", IconWdg.LOAD, True)
button.add_event("onclick", "annotate.set_opacity()")
div.add(button)
#.........这里部分代码省略.........