本文整理汇总了Python中common_py.system.filesystem.FileSystem.isdir方法的典型用法代码示例。如果您正苦于以下问题:Python FileSystem.isdir方法的具体用法?Python FileSystem.isdir怎么用?Python FileSystem.isdir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common_py.system.filesystem.FileSystem
的用法示例。
在下文中一共展示了FileSystem.isdir方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate_module
# 需要导入模块: from common_py.system.filesystem import FileSystem [as 别名]
# 或者: from common_py.system.filesystem.FileSystem import isdir [as 别名]
def generate_module(args):
directory = args.directory
if fs.isdir(directory):
# handle strings end with '/'
if directory[-1] == '/':
directory = directory[:-1]
dirname = fs.basename(directory)
else:
sys.exit('Please give an existing directory.')
if args.out_dir:
output_dir = args.out_dir
else:
output_dir = fs.join(fs.join(path.TOOLS_ROOT, 'module_generator'),
'output')
if not fs.isdir(output_dir):
os.mkdir(output_dir)
output_dir = fs.join(output_dir, dirname + '_module')
if not fs.isdir(output_dir):
os.mkdir(output_dir)
src_dir = fs.join(output_dir, 'src')
if not fs.isdir(src_dir):
os.mkdir(src_dir)
header_file = fs.join(src_dir, dirname + '_js_binding.h')
header_text, api_headers = generate_header(directory)
with open(header_file, 'w') as h:
h.write(header_text)
c_file = generate_c_source(header_file, api_headers, dirname, args)
extension = 'cpp' if args.lang == 'c++' else 'c'
with open(fs.join(src_dir, dirname + '_js_binding.' + extension), 'w') as c:
c.write(c_file)
library = search_for_lib(directory)
if not library:
print ('\033[93mWARNING: Cannot find library file. ' +
'Only the binding layer source has generated.\033[00m')
return
lib_root, lib_name = library
cmake_file = MODULE_CMAKE.format(NAME=dirname, LIBRARY=lib_name[3:-2])
with open(fs.join(output_dir, 'module.cmake'), 'w') as cmake:
cmake.write(cmake_file)
fs.copyfile(fs.join(lib_root, lib_name), fs.join(output_dir, lib_name))
json_file = MODULES_JSON.format(NAME=dirname, CMAKE='module.cmake')
if args.lang == 'c++':
cmake_lists = CMAKE_LISTS.format(NAME=dirname)
with open(fs.join(src_dir, 'CMakeLists.txt'), 'w') as cmake:
cmake.write(cmake_lists)
with open(fs.join(output_dir, 'modules.json'), 'w') as json:
json.write(json_file)