本文整理汇总了Python中snapshot.Snapshot.get_by_version方法的典型用法代码示例。如果您正苦于以下问题:Python Snapshot.get_by_version方法的具体用法?Python Snapshot.get_by_version怎么用?Python Snapshot.get_by_version使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类snapshot.Snapshot
的用法示例。
在下文中一共展示了Snapshot.get_by_version方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_default_ending
# 需要导入模块: from snapshot import Snapshot [as 别名]
# 或者: from snapshot.Snapshot import get_by_version [as 别名]
def add_default_ending(my, parts, auto_version=True, is_sequence=True):
context = my.snapshot.get_value("context")
filename = my.file_object.get_full_file_name()
# make sure that the version in the file name does not yet exist
version = my.get_version_from_file_name(filename)
if not auto_version and version:
# if the file version is not the same as the snapshot version
# then check to see if the snapshot already exists
if version != my.snapshot.get_value("version"):
existing_snap = Snapshot.get_by_version(my.snapshot.get_value("search_type"),\
my.snapshot.get_value("search_id"), context, version)
if existing_snap:
raise TacticException('A snapshot with context "%s" and version "%s" already exists.' % (context, version) )
my.snapshot.set_value("version", version)
my.snapshot.commit()
else:
version = my.snapshot.get_value("version")
if version == 0:
version = "CURRENT"
elif version == -1:
version = "LATEST"
else:
if version == "":
version = 1
# pad the version by by the global setting
padding = Config.get_value("checkin", "version_padding")
if not padding:
padding = 3
else:
padding = int(padding)
expr = "v%%0.%sd" % padding
version = expr % version
revision = my.snapshot.get_value("revision", no_exception=True)
if revision:
revision = "r%0.2d" % revision
ext = my.get_ext()
# by default publish is not put into the file name
if context != "publish":
parts.append(context.replace("/", "_"))
# add the server location
#value = ProdSetting.get_value_by_key("naming/add_server")
server = Config.get_value("install", "server")
if server:
parts.append(server)
if my.is_tactic_repo():
parts.append(version)
if revision:
parts.append(revision)
from pyasm.prod.biz import ProdSetting
value = ProdSetting.get_value_by_key("naming/add_initials")
if value == "false":
project = Project.get()
initials = Project.get().get_initials()
parts.append(initials)
filename = "_".join(parts)
if is_sequence:
filename = "%s.####.%s" % (filename, ext)
elif ext: # dir don't need extension
filename = "%s%s" % (filename, ext)
return filename