本文整理汇总了Python中pyasm.common.Common.get_filesystem_name方法的典型用法代码示例。如果您正苦于以下问题:Python Common.get_filesystem_name方法的具体用法?Python Common.get_filesystem_name怎么用?Python Common.get_filesystem_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.common.Common
的用法示例。
在下文中一共展示了Common.get_filesystem_name方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_search_types
# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import get_filesystem_name [as 别名]
def create_search_types(my):
from tactic.ui.app import SearchTypeCreatorCmd
project_code = my.kwargs.get('project_code')
search_types = my.kwargs.get('project_stype')
if not search_types:
return
for search_type in search_types:
if search_type == "":
continue
search_type = Common.get_filesystem_name(search_type)
if search_type.find("/") != -1:
parts = search_type.split("/")
namespace = parts[0]
table = parts[1]
else:
namespace = project_code
table = search_type
search_type = "%s/%s" % (namespace, search_type)
description = Common.get_display_name(table)
title = description
has_pipeline = True
kwargs = {
'database': project_code,
'namespace': project_code,
'schema': 'public',
'search_type_name': search_type,
'asset_description': description,
'asset_title': title,
'sobject_pipeline': has_pipeline,
}
creator = SearchTypeCreatorCmd(**kwargs)
creator.execute()
示例2: process_file_path
# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import get_filesystem_name [as 别名]
def process_file_path(file_path):
'''makes a file path completely kosher with the file system. Only do it on basename or it would remove the : from C:/'''
return Common.get_filesystem_name(file_path)
示例3: get_display
# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import get_filesystem_name [as 别名]
#.........这里部分代码省略.........
else:
menu_item.add_behavior( {
'project_code': project_code,
'cbjs_action': '''
spt.app_busy.show("Jumping to Project ["+bvr.project_code+"]", "");
document.location = '/tactic/%s/';
''' % project_code
} )
menu.add(menu_item)
search = Search("sthpw/project")
search.add_column("category", distinct=True)
categories = [x.get_value("category") for x in search.get_sobjects() ]
for category in categories:
if category == '':
continue
# FIXME: a little inefficient, but should be ok for now
category_projects = []
for project in projects:
if project.get_value("category") != category:
continue
project_code = project.get_code()
if not security.check_access("project", project_code, "view"):
continue
category_projects.append(project)
if category_projects:
suffix = Common.get_filesystem_name(category)
label = "%s (%s)" % (category, len(category_projects))
menu_item = MenuItem(type='submenu', label=label)
menu_item.set_submenu_tag_suffix(suffix)
menu.add(menu_item)
submenu = Menu(width=200, menu_tag_suffix=suffix)
menus.append(submenu)
for project in category_projects:
add_project_menu(submenu, project)
from pyasm.security import get_security_version
security_version = get_security_version()
for project in projects:
if project.get_value("category") != "":
continue
project_code = project.get_code()
if security_version >= 2:
key = { "code": project_code }
key2 = { "code": "*" }
keys = [key, key2]
default = "deny"
if not security.check_access("project", keys, "allow", default=default):
continue
else:
if not security.check_access("project", project_code, "view", default="allow"):
continue
add_project_menu(menu, project)
示例4: naming_to_file
# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import get_filesystem_name [as 别名]
#.........这里部分代码省略.........
attr, index = attr.split("[")
index = int(index.rstrip("]"))
if attr == "context":
value = snapshot.get_value(attr)
elif attr == "snapshot_type":
value = snapshot.get_value(attr)
elif attr == "version":
value = snapshot.get_value(attr)
if value:
value = version_expr % int(value)
else:
value = "0"*version_padding
elif attr == "revision":
value = snapshot.get_value(attr)
if value:
value = version_expr % int(value)
else:
value = "0"*version_padding
elif attr.startswith("#"):
if not snapshot:
continue
value = snapshot.get_value("version")
expr = "%%0.%sd" % len(attr)
if value:
value = expr % int(value)
else:
value = "0" * len(attr)
elif attr == "basefile":
file_name = file.get_value("file_name")
base_type = file.get_value("base_type")
if base_type =='directory':
value = file_name
else:
base, ext = os.path.splitext(file_name)
value = base
elif attr == "ext":
if not ext:
file_name = file.get_value("file_name")
base_type = file.get_value("base_type")
if base_type =='directory':
value = ''
else:
base, ext = os.path.splitext(file_name)
value = ext.lstrip(".")
else:
# external ext starts with a .
ext = ext.lstrip(".")
value = ext
elif attr in ["login","user"]:
login = Environment.get_login()
value = login.get_value("login")
elif attr == "file_type":
if file_type:
value = file_type
else:
value = 'main'
elif attr.startswith('date'):
# {date,%Y-%m-%d_%H-%M-%S]}
import time
parts = attr.split(",", 1)
if len(parts) == 2:
format = parts[1]
else:
format = "%Y%m%d"
value = time.strftime(format, time.localtime())
else:
value = sobject.get_value(attr)
# tbis applies to context for now
if index != -1:
value = re.split("[/]", value)
if len(value) <= index:
value = '!'
else:
value = value[index]
#if not value:
# raise NamingException("Value for part [%s] is empty" % part)
if isinstance(value, int):
value = str(value)
result = result.replace("{%s}" % part, value)
# don't allow / in filename,
# FIXME: it's not put in get_filesystem_name since it
# is used for directory name also, need to modify that
result = result.replace("/", "_")
# post process result so that it looks good
result = Common.get_filesystem_name(result)
return result