当前位置: 首页>>代码示例>>Python>>正文


Python FileSystem.basename方法代码示例

本文整理汇总了Python中common_py.system.filesystem.FileSystem.basename方法的典型用法代码示例。如果您正苦于以下问题:Python FileSystem.basename方法的具体用法?Python FileSystem.basename怎么用?Python FileSystem.basename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在common_py.system.filesystem.FileSystem的用法示例。


在下文中一共展示了FileSystem.basename方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: append_coverage_code

# 需要导入模块: from common_py.system.filesystem import FileSystem [as 别名]
# 或者: from common_py.system.filesystem.FileSystem import basename [as 别名]
def append_coverage_code(testfile, coverage):
    if not coverage:
        return

    with open(testfile, 'r') as file_p:
        content = file_p.read()

    with open(testfile, 'w') as file_p:
        file_p.write(JS_COVERAGE_CODE.format(
            folder=JS_COVERAGE_FOLDER, file=fs.basename(testfile)))
        file_p.write(content)
开发者ID:MoonkiHong,项目名称:iotjs,代码行数:13,代码来源:testrunner.py

示例2: generate_module

# 需要导入模块: from common_py.system.filesystem import FileSystem [as 别名]
# 或者: from common_py.system.filesystem.FileSystem import basename [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)
开发者ID:Samsung,项目名称:iotjs,代码行数:69,代码来源:iotjs-generate-module.py


注:本文中的common_py.system.filesystem.FileSystem.basename方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。