當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。