本文整理汇总了Python中pyasm.biz.Project.get_file_naming方法的典型用法代码示例。如果您正苦于以下问题:Python Project.get_file_naming方法的具体用法?Python Project.get_file_naming怎么用?Python Project.get_file_naming使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.biz.Project
的用法示例。
在下文中一共展示了Project.get_file_naming方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_virtual_snapshot_extended
# 需要导入模块: from pyasm.biz import Project [as 别名]
# 或者: from pyasm.biz.Project import get_file_naming [as 别名]
def get_virtual_snapshot_extended(search_key, context, snapshot_type="file", is_revision=False, level_key=None, file_type=['main'], file_name=[''], postfixes=None, subfolders=None, keep_file_name=False, ext=[''], version=None):
'''creates a virtual snapshot and returns a path that this snapshot
would generate through the naming conventions''
@params
snapshot creation:
-----------------
search_key - a unique identifier key representing an sobject
context - the context of the checkin
snapshot_type - [optional] descibes what kind of a snapshot this is.
More information about a snapshot type can be found in the
prod/snapshot_type sobject
level_key - the unique identifier of the level that this
is to be checked into
path creation:
--------------
file_type: the type of file that will be checked in. Some naming
conventions make use of this information to separate directories
for different file types
file_name: the desired file name of the preallocation. This information
may be ignored by the naming convention or it may use this as a
base for the final file name
ext: force the extension of the file name returned
@return
path as determined by the naming conventions
'''
# getting virtual snapshots
import json
from pyasm.biz import Snapshot
from pyasm.biz import Project
from pyasm.search import SearchType
api = server.server
sobjects = api._get_sobjects(search_key)
sobject = sobjects[0]
result_dict = {'versionless': {'paths': [], 'names': []}, 'versioned': {'paths': [], 'names': []}}
# get the level object
if level_key:
levels = api._get_sobjects(level_key)
level = levels[0]
level_type = level.get_search_type()
level_id = level.get_id()
else:
level_type = None
level_id = None
description = "No description"
if len(file_name) > 1:
keep_file_name = True
if len(set(file_type)) != 1:
keep_file_name = False
if not postfixes:
postfixes = []
for fn in range(len(file_name)):
postfixes.append('')
if not subfolders:
subfolders = []
for fn in range(len(file_name)):
subfolders.append('')
def prepare_filename(filenaming, f_l, ex, postfix):
if keep_file_name:
if postfix:
result_file_name = f_l + '_' + postfix + '.' + ex
else:
result_file_name = f_l + '.' + ex
else:
name_ext = filenaming.get_file_name()
if postfix:
result_file_name = name_ext.replace('.' + ex, '_' + postfix + '.' + ex)
else:
result_file_name = name_ext
return result_file_name
def prepare_folder(d, sub):
if sub:
return d + '/' + sub
else:
return d
for i, fl in enumerate(file_name):
if not fl:
fl = sobject.get_code()
if not fl:
fl = sobject.get_name()
if not fl:
fl = "unknown"
file_object = SearchType.create("sthpw/file")
file_object.set_value("file_name", fl)
file_object.set_value("type", file_type[i])
file_naming = Project.get_file_naming()
#.........这里部分代码省略.........