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


Python File.find_files_from_data方法代码示例

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


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

示例1: test_single_change

# 需要导入模块: from pynimbusauthz.objects import File [as 别名]
# 或者: from pynimbusauthz.objects.File import find_files_from_data [as 别名]
    def test_single_change(self): 
        name = "/file/name"
        old_base = "/OLD"
        new_base = "/NEW"
        data = "/etc/group"

        key = old_base + data
        file1 = File.create_file(self.db, name, self.user1, key, pynimbusauthz.object_type_s3)
        self.db.commit()

        rc = pynimbusauthz.rebase.main([old_base, new_base])
        self.assertEqual(rc, 0, "rc should be 0, is %d" % (rc))

        f2a = File.find_files_from_data(self.db, key)
        f2a = list(f2a)
        self.assertEqual(len(f2a), 0, "should be no values with key %s len is %d" % (old_base, len(f2a)))
        key = new_base + data
        f2a = File.find_files_from_data(self.db, key)
        f2a = list(f2a)
        self.assertNotEqual(len(f2a), 0, "length should be greater than 0 is %d" % (len(f2a)))

        found = False
        for f2 in f2a:
            tst_key = f2.get_data_key()
            if tst_key == key:
                found = True
        self.assertTrue(found, "key not found")
开发者ID:Annatara,项目名称:nimbus,代码行数:29,代码来源:test_rebase.py

示例2: test_find_by_key

# 需要导入模块: from pynimbusauthz.objects import File [as 别名]
# 或者: from pynimbusauthz.objects.File import find_files_from_data [as 别名]
    def test_find_by_key(self):
        user1 = User(self.db)
        name = "/file/name"
        key = "/old/path/base"
        f = File.create_file(self.db, name, user1, key, pynimbusauthz.object_type_s3)
        self.db.commit()

        f2a = File.find_files_from_data(self.db, key)

        found = False
        for f2 in f2a:
            tst_key = f2.get_data_key()
            if tst_key == key:
                found = True
        self.assertTrue(found, "key not found")
开发者ID:ketancmaheshwari,项目名称:nimbus,代码行数:17,代码来源:file_test.py

示例3: test_many_change

# 需要导入模块: from pynimbusauthz.objects import File [as 别名]
# 或者: from pynimbusauthz.objects.File import find_files_from_data [as 别名]
    def test_many_change(self):
        name = "/file/name"
        old_base = "/OLD"
        new_base = "/NEW"
        count = 10

        for i in range(0, count): 
            keyname = str(uuid.uuid1())
            oldkey = old_base + "/" + keyname
            File.create_file(self.db, name+oldkey, self.user1, oldkey, pynimbusauthz.object_type_s3)
        self.db.commit()

        rc = pynimbusauthz.rebase.main([old_base, new_base])
        self.assertEqual(rc, 0, "rc should be 0, is %d" % (rc))

        f2a = File.find_files_from_data(self.db, new_base + "%")
        f2a = list(f2a)
        self.assertEqual(len(f2a), count, "length of the new items should be %d is %s" % (count, len(f2a)))
开发者ID:Annatara,项目名称:nimbus,代码行数:20,代码来源:test_rebase.py

示例4: main

# 需要导入模块: from pynimbusauthz.objects import File [as 别名]
# 或者: from pynimbusauthz.objects.File import find_files_from_data [as 别名]
def main(argv=sys.argv[1:]):
    
    try:
        con_str = pynimbusauthz.get_db_connection_string()
        db_obj = DB(con_str=con_str)

        (opts,args) = setup_options(argv)

        old_path = args[0]
        new_path = args[1]

        pattern = old_path + "%"

        files = list(File.find_files_from_data(db_obj, pattern))
        for f in files:
            old_key = f.get_data_key()
            new_key = old_key.replace(old_path, new_path, 1)
            f.set_data_key(new_key)
        db_obj.commit()
        print "done - %d files rebased" % len(files)

    except AuthzException, ae:
        print ae
        return ae.get_rc()
开发者ID:Annatara,项目名称:nimbus,代码行数:26,代码来源:rebase.py


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