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


Python Common.relative_path方法代码示例

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


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

示例1: _test_symlink

# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import relative_path [as 别名]
    def _test_symlink(my):
        if os.name == 'nt':
            return

        # create a new test.txt file
        file_path = "./symlink.txt"
        file = open(file_path, 'w')
        file.write("symlink test")
        file.close()

        checkin = FileCheckin(my.person, file_path, context="sym_test", checkin_type='auto')
        checkin.execute()

        snap = Snapshot.get_versionless(my.person.get_search_type(), my.person.get_id(), "sym_test", mode='latest', create=False)
        my.assertEquals(True, isinstance(snap, Snapshot))
        if snap:
            lib_path =snap.get_lib_path_by_type('main')
            my.assertEquals(True, os.path.exists(lib_path)) 
            rel_path = os.readlink(lib_path)
            lib_dir = os.path.dirname(lib_path)

            # this is essentially handle_link() in FileUndo class
            wd = os.getcwd()
            os.chdir(lib_dir)
            real_path = os.path.join(lib_dir, os.path.abspath(rel_path))
            # lib_path points to real_path

            expected_rel_path  = Common.relative_path(lib_path, real_path)
            my.assertEquals(True, os.path.exists(real_path))
            my.assertEquals(expected_rel_path, rel_path)
            os.chdir(wd)
开发者ID:blezek,项目名称:TACTIC,代码行数:33,代码来源:checkin_test.py

示例2: _test_symlink

# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import relative_path [as 别名]
    def _test_symlink(self):
        if os.name == 'nt':
            return

        # create a new test.txt file
        file_path = "./symlink.txt"
        file = open(file_path, 'w')
        file.write("symlink test")
        file.close()

        file_path2 = "./symlink_append.txt"
        file = open(file_path2, 'w')
        file.write("append test")
        file.close()


        checkin = FileCheckin(self.person, file_path, context="sym_test", checkin_type='auto')
        checkin.execute()
        snap = checkin.get_snapshot()
        versionless_snap = Snapshot.get_versionless(self.person.get_search_type(), self.person.get_id(), "sym_test", mode='latest', create=False)
        self.assertEquals(True, isinstance(versionless_snap, Snapshot))

        main_lib_path = snap.get_lib_path_by_type('main')
        self.assertEquals(main_lib_path.endswith('/sym_test/.versions/symlink_sym_test_v001.txt'), True)
        if versionless_snap:
            lib_path =versionless_snap.get_lib_path_by_type('main')
            self.assertEquals(True, os.path.exists(lib_path)) 
            rel_path = os.readlink(lib_path)
            lib_dir = os.path.dirname(lib_path)

            # this is essentially handle_link() in FileUndo class
            wd = os.getcwd()
            os.chdir(lib_dir)
            real_path = os.path.join(lib_dir, os.path.abspath(rel_path))
            # lib_path points to real_path

            expected_rel_path  = Common.relative_path(lib_path, real_path)
            self.assertEquals(True, os.path.exists(real_path))
            self.assertEquals(expected_rel_path, rel_path)
            os.chdir(wd)

        # if not inplace or preallocate mode, keep_file_name should be False
        checkin = FileAppendCheckin(snap.get_code(), [file_path2], file_types=['add'], keep_file_name=False, checkin_type='auto')
        checkin.execute()
        snap = checkin.get_snapshot()
        main_lib_path = snap.get_lib_path_by_type('add')
        self.assertEquals(snap.get_value('is_current'), True)
        self.assertEquals(snap.get_value('is_latest'), True)
        self.assertEquals(main_lib_path.endswith('/sym_test/.versions/symlink_append_sym_test_v001.txt'), True)
        versionless_snap = Snapshot.get_versionless(self.person.get_search_type(), self.person.get_id(), "sym_test", mode='latest', create=False)
        if versionless_snap:
            lib_path = versionless_snap.get_lib_path_by_type('add')
            self.assertEquals(lib_path.endswith('/sym_test/symlink_append_sym_test.txt'), True)
            self.assertEquals(os.path.exists(lib_path), True)
开发者ID:mincau,项目名称:TACTIC,代码行数:56,代码来源:checkin_test.py


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