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


Python File.set_value方法代码示例

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


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

示例1: _test_naming_util

# 需要导入模块: from file import File [as 别名]
# 或者: from file.File import set_value [as 别名]
    def _test_naming_util(my):
       
        #my.clear_naming()
        naming_util = NamingUtil()
        # these should evaluate to be the same
        file_naming_expr1 = ['{$PROJECT}__{context[0]}__hi_{$BASEFILE}.{$EXT}','{project.code}__{context[0]}__hi_{basefile}.{ext}']
        dir_naming_expr2 = ['{$PROJECT}/{context[1]}/somedir/{@GET(.name_first)}','{project.code}/{snapshot.context[1]}/somedir/{sobject.name_first}']

        process= 'light'
        context = 'light/special'
        type = 'ma'
        version = 2

        virtual_snapshot = Snapshot.create_new()
        virtual_snapshot_xml = '<snapshot process=\'%s\'><file type=\'%s\'/></snapshot>' % (process, type)
        virtual_snapshot.set_value("snapshot", virtual_snapshot_xml)
        virtual_snapshot.set_value("process", process)
        virtual_snapshot.set_value("context", context)
        virtual_snapshot.set_value("snapshot_type", 'file')

        virtual_snapshot.set_sobject(my.person)
        virtual_snapshot.set_value("version", version)

        file_name = "abc.txt"
        file_obj = File(File.SEARCH_TYPE)
        file_obj.set_value("file_name", file_name)
        
        for naming_expr in file_naming_expr1:
            file_name = naming_util.naming_to_file(naming_expr, my.person, virtual_snapshot, file=file_obj, file_type="main")
            my.assertEquals(file_name,'unittest__light__hi_abc.txt')

        for naming_expr in dir_naming_expr2:
            dir_name = naming_util.naming_to_dir(naming_expr, my.person, virtual_snapshot, file=file_obj, file_type="main")
            my.assertEquals(dir_name,'unittest/special/somedir/Philip')
开发者ID:0-T-0,项目名称:TACTIC,代码行数:36,代码来源:naming_test.py

示例2: _test_dir_naming

# 需要导入模块: from file import File [as 别名]
# 或者: from file.File import set_value [as 别名]
    def _test_dir_naming(my):

        # change to the test dir naming class
        my.sobj.set_value('dir_naming_cls', 'pyasm.biz.naming_test.TestDirNaming')
        my.sobj.commit()

        # 1. try a different search_type unittest/person
        version = 9
        code = 'phil2'
        process = 'model'
        type = 'main'
        context = 'modeling'

        asset = SearchType.create( 'unittest/person' )
        asset.set_value("code",code)
        asset.set_value("name_first", "Philip")
        asset.commit()

        # change a different input file name
        file_obj = File(File.SEARCH_TYPE)
        # due to new restriction of set_sobject_value().. we can't use it any more
        #file_obj.set_sobject_value(asset)
        sk = SearchKey.get_by_sobject(asset, use_id =True)
        st = SearchKey.extract_search_type(sk)
        sid = SearchKey.extract_id(sk)
        file_obj.set_value('search_type', st)
        file_obj.set_value('search_id', sid)
        file_obj.set_value('file_name','some_maya_model.mb') 
        file_obj.set_value('type', type)
        file_obj.set_value('base_type', 'file')
        file_obj.commit()

        virtual_snapshot = Snapshot.create_new()
        virtual_snapshot_xml = '<snapshot process=\'%s\'><file type=\'%s\' file_code=\'%s\'/></snapshot>' % (process, type, file_obj.get_code())
        virtual_snapshot.set_value("snapshot", virtual_snapshot_xml)
        virtual_snapshot.set_value("context", context)

        virtual_snapshot.set_sobject(asset)
        virtual_snapshot.set_value("version", version)
        
       
        

        Project.set_project('unittest')
        dir_naming = Project.get_dir_naming()
        dir_naming.set_sobject(asset)
        dir_naming.set_snapshot(virtual_snapshot)
        dir_naming.set_file_object(file_obj)
        dir_name = dir_naming.get_dir()
        expected_dir_name = '/assets/phil2/mb.main/v009'
        expected_dir_name2 = '/phil2/mb.main/v009'
        my.assertEquals(expected_dir_name, dir_name)
        
        lib_paths = virtual_snapshot.get_all_lib_paths()
        sand_paths = virtual_snapshot.get_all_lib_paths(mode='sandbox')
        client_paths = virtual_snapshot.get_all_lib_paths(mode='client_repo')
       
        base_dir = Config.get_value("checkin", "asset_base_dir", sub_key='default')
        sand_base_dir = dir_naming.get_base_dir(protocol='sandbox')
        client_base_dir = dir_naming.get_base_dir(protocol='client_repo')
       

        my.assertEquals(lib_paths[0].startswith('%s%s'%(base_dir, expected_dir_name2)), True)
        my.assertEquals(sand_paths[0].startswith('%s%s'%(sand_base_dir[0], expected_dir_name2)), True)
        my.assertEquals(client_paths[0].startswith('%s%s'%(client_base_dir[0], expected_dir_name2)), True)

        # 2  get_preallocated_path
        # set version 1 here since it's the first snapshot for this sobject. 
        # without a virtual file_object, the file_name is empty, and so the dir ma.maya is now .maya
        my.assertEquals("phil/.maya/v001", my.get_preallocated_dir()) 
        
        # switch back to regular file naming
        my.sobj.set_value('file_naming_cls', 'pyasm.biz.naming_test.TestFileNaming')
        my.sobj.commit()

        my.assertEquals("phil/ma.maya/v001", my.get_preallocated_dir()) 
开发者ID:0-T-0,项目名称:TACTIC,代码行数:78,代码来源:naming_test.py

示例3: _test_file_naming

# 需要导入模块: from file import File [as 别名]
# 或者: from file.File import set_value [as 别名]
    def _test_file_naming(my):
        process = 'model'
        type = 'main'
        context = 'modeling'
        version = 10
        file_name = 'testing_image.jpg'
        code = name = 'vehicle001'
        asset_library = 'vehicle'

        asset = SearchType.create( Asset.SEARCH_TYPE )
        asset.set_value("code",code)
        asset.set_value("name",name)
        asset.set_value("asset_library",asset_library)
        asset.set_value("asset_type","asset")

        virtual_snapshot = Snapshot.create_new()
        virtual_snapshot_xml = '<snapshot process=\'%s\'><file type=\'%s\'/></snapshot>' % (process, type)
        virtual_snapshot.set_value("snapshot", virtual_snapshot_xml)
        virtual_snapshot.set_value("context", context)
        virtual_snapshot.set_value("version", version)

        virtual_snapshot.set_sobject(asset)


        file_obj = File(File.SEARCH_TYPE)
        file_obj.set_value("file_name", file_name)
        

        file_naming = Project.get_file_naming()

        file_naming.set_sobject(asset)
        file_naming.set_snapshot(virtual_snapshot)
        file_naming.set_file_object(file_obj)

        expected_file_name = 'vehicle001_%s_v%0.3d.jpg' %(context,version)
        file_name = file_naming.get_file_name()
        my.assertEquals(expected_file_name, file_name)


        # try a default directory name

        file_obj.set_value("file_name", "test_dir")
        file_obj.set_value("base_type", "directory")
        file_naming.set_file_object(file_obj)
        
        # this should adopt the original dir name in the prefix
        expected_file_name = 'test_dir_%s_v%0.3d' %(context,version)
        file_name = file_naming.get_default()
        my.assertEquals(expected_file_name, file_name)

        #2 try a different search_type unittest/person
        version = 9
        
        
        file_obj.set_value("base_type", "file")
        # change a different input file name
        file_obj.set_value('file_name','some_maya_model.ma') 
        
        # use a real snapshot
        virtual_snapshot.set_sobject(my.person)
        virtual_snapshot.set_value("version", version)
        
        # change to the test file naming class
        my.sobj.set_value('file_naming_cls', 'pyasm.biz.naming_test.TestFileNaming')
        my.sobj.commit()
        Project.set_project('unittest')
        file_naming = Project.get_file_naming()
        file_naming.set_sobject(my.person)
        file_naming.set_snapshot(virtual_snapshot)
        file_naming.set_file_object(file_obj)
        file_name = file_naming.get_file_name()

        expected_file_name = 'phil_main_v009.ma'
        my.assertEquals(expected_file_name, file_name)

        # get_preallocated_path
        type = 'ma'
        #file_obj.set_value('type', type)
        #file_naming.set_file_object(file_obj)

        preallocated = my.snapshot.get_preallocated_path(file_type='maya', file_name='what.ma',ext='ma')
        preallocated_file_name = os.path.basename(preallocated)
        my.assertEquals("phil_main_v001.ma", preallocated_file_name)

        preallocated = my.snapshot.get_preallocated_path(file_type='houdini', file_name='what.otl',ext='otl')
        preallocated_file_name = os.path.basename(preallocated)
        my.assertEquals("phil_main_v001.otl", preallocated_file_name)

        preallocated = my.snapshot.get_preallocated_path(file_type='houdini', file_name='what_is.otl', ext='hipnc')
        preallocated_file_name = os.path.basename(preallocated)
        my.assertEquals("phil_main_v001.hipnc", preallocated_file_name)


        # try an empty file naming
        # change to the test file naming class
        my.sobj.set_value('file_naming_cls', 'pyasm.biz.naming_test.TestFileNaming2')
        my.sobj.commit()

        Project.set_project('unittest')
        file_naming = Project.get_file_naming()
#.........这里部分代码省略.........
开发者ID:0-T-0,项目名称:TACTIC,代码行数:103,代码来源:naming_test.py


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