當前位置: 首頁>>代碼示例>>Python>>正文


Python FileObjectFactory.create方法代碼示例

本文整理匯總了Python中pmaker.models.FileObjectFactory.create方法的典型用法代碼示例。如果您正苦於以下問題:Python FileObjectFactory.create方法的具體用法?Python FileObjectFactory.create怎麽用?Python FileObjectFactory.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pmaker.models.FileObjectFactory的用法示例。


在下文中一共展示了FileObjectFactory.create方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_02_list__multi_generated_file

# 需要導入模塊: from pmaker.models import FileObjectFactory [as 別名]
# 或者: from pmaker.models.FileObjectFactory import create [as 別名]
    def test_02_list__multi_generated_file(self):
        listfile = os.path.join(self.workdir, "file.list")
        listfile2 = os.path.join(self.workdir, "file2.list")
        config = init_config(listfile)

        line = "%s/file*.list\n" % self.workdir
        open(listfile, "w").write(line)
        open(listfile2, "w").write(line)

        collector = FilelistCollector(listfile, config)
        fos = collector.list(listfile)
        fos_ref = [Factory.create(listfile), Factory.create(listfile2)]

        self.assertEquals(sorted(fos), sorted(fos_ref))
開發者ID:ssato,項目名稱:packagemaker,代碼行數:16,代碼來源:FilelistCollectors.py

示例2: test_copy__exists

# 需要導入模塊: from pmaker.models import FileObjectFactory [as 別名]
# 或者: from pmaker.models.FileObjectFactory import create [as 別名]
    def test_copy__exists(self):
        fo = Factory.create(self.testfile1)
        dest = self.testfile1 + ".2"

        FileOps.copy(fo, dest)

        self.assertFalse(FileOps.copy(fo, dest))
開發者ID:masatake,項目名稱:packagemaker,代碼行數:9,代碼來源:FileObjectOperations.py

示例3: test_update

# 需要導入模塊: from pmaker.models import FileObjectFactory [as 別名]
# 或者: from pmaker.models.FileObjectFactory import create [as 別名]
    def test_update(self):
        modifier = RpmAttributeModifier()

        f = F.create("/bin/bash")
        new_f = modifier.update(f)

        self.assertTrue(getattr(new_f, "rpm_attr", False))
開發者ID:ssato,項目名稱:packagemaker,代碼行數:9,代碼來源:RpmModifiers.py

示例4: test_pred__not_exist

# 需要導入模塊: from pmaker.models import FileObjectFactory [as 別名]
# 或者: from pmaker.models.FileObjectFactory import create [as 別名]
    def test_pred__not_exist(self):
        filter = NotExistFilter()
        path = "/bin/sh"

        assert os.path.exists(path)

        fo = Factory.create(path)
        self.assertFalse(filter.pred(fo))
開發者ID:masatake,項目名稱:packagemaker,代碼行數:10,代碼來源:Filters.py

示例5: test_copy_impl_and_remove

# 需要導入模塊: from pmaker.models import FileObjectFactory [as 別名]
# 或者: from pmaker.models.FileObjectFactory import create [as 別名]
    def test_copy_impl_and_remove(self):
        fo = Factory.create(self.testfile1)
        dest = self.testfile1 + ".2"

        FileOps.copy_impl(fo, dest)
        self.assertTrue(os.path.exists(dest))

        FileOps.remove(dest)
        self.assertFalse(os.path.exists(dest))
開發者ID:masatake,項目名稱:packagemaker,代碼行數:11,代碼來源:FileObjectOperations.py

示例6: test__create_wo_attrs

# 需要導入模塊: from pmaker.models import FileObjectFactory [as 別名]
# 或者: from pmaker.models.FileObjectFactory import create [as 別名]
    def test__create_wo_attrs(self):
        fo = Factory.create(self.path)

        self.assertTrue(isinstance(fo, FO.DirObject))
        self.assertEquals(fo.mode, fo.defaults.mode)
        self.assertEquals(fo.uid, fo.defaults.uid)
        self.assertEquals(fo.gid, fo.defaults.gid)
        self.assertEquals(fo.checksum, fo.defaults.checksum)
        self.assertEquals(fo.path, self.path)
開發者ID:ssato,項目名稱:packagemaker,代碼行數:11,代碼來源:FileObjectFactory.py

示例7: test_pred__unsupported__fileobjects

# 需要導入模塊: from pmaker.models import FileObjectFactory [as 別名]
# 或者: from pmaker.models.FileObjectFactory import create [as 別名]
    def test_pred__unsupported__fileobjects(self):
        username = pwd.getpwuid(os.getuid()).pw_name
        paths = ["/dev/null", "/dev/zero"] + glob.glob("/tmp/orbit-%s/linc-*" % username)[:3]  # device files  # socket

        paths = [p for p in paths if os.path.exists(p)]

        for p in paths:
            fo = Factory.create(p)
            self.assertTrue(self.filter.pred(fo))
開發者ID:masatake,項目名稱:packagemaker,代碼行數:11,代碼來源:Filters.py

示例8: test_pred__permitted_to_read

# 需要導入模塊: from pmaker.models import FileObjectFactory [as 別名]
# 或者: from pmaker.models.FileObjectFactory import create [as 別名]
    def test_pred__permitted_to_read(self):
        filter = ReadAccessFilter()
        pred = lambda f: os.path.exists(f) and os.access(f, os.R_OK)

        path = random.choice([p for p in ("/etc/hosts", "/etc/resolv.conf",
                                          "/etc/sysctl.conf")
                              if pred(p)])

        fo = Factory.create(path)
        self.assertFalse(filter.pred(fo))
開發者ID:ssato,項目名稱:packagemaker,代碼行數:12,代碼來源:Filters.py

示例9: test__create_w_filetype_symlink

# 需要導入模塊: from pmaker.models import FileObjectFactory [as 別名]
# 或者: from pmaker.models.FileObjectFactory import create [as 別名]
    def test__create_w_filetype_symlink(self):
        filetype = FO.typestr_to_type("symlink")
        fo = Factory.create(self.path, filetype=filetype)

        self.assertTrue(isinstance(fo, FO.SymlinkObject))
        self.assertEquals(fo.type(), G.TYPE_SYMLINK)
        self.assertEquals(fo.path, self.path)
        self.assertEquals(fo.mode, fo.defaults.mode)
        self.assertEquals(fo.uid, fo.defaults.uid)
        self.assertEquals(fo.gid, fo.defaults.gid)
        self.assertEquals(fo.checksum, fo.defaults.checksum)
開發者ID:ssato,項目名稱:packagemaker,代碼行數:13,代碼來源:FileObjectFactory.py

示例10: test__create_w_content

# 需要導入模塊: from pmaker.models import FileObjectFactory [as 別名]
# 或者: from pmaker.models.FileObjectFactory import create [as 別名]
    def test__create_w_content(self):
        content = "Hello, world\n"
        fo = Factory.create(self.path, content=content)

        self.assertTrue(isinstance(fo, FO.FileObject))
        self.assertEquals(fo.path, self.path)
        self.assertEquals(fo.mode, fo.defaults.mode)
        self.assertEquals(fo.uid, fo.defaults.uid)
        self.assertEquals(fo.gid, fo.defaults.gid)
        self.assertEquals(fo.checksum, fo.defaults.checksum)
        self.assertEquals(fo.content, content)
開發者ID:ssato,項目名稱:packagemaker,代碼行數:13,代碼來源:FileObjectFactory.py

示例11: test__create_w_src

# 需要導入模塊: from pmaker.models import FileObjectFactory [as 別名]
# 或者: from pmaker.models.FileObjectFactory import create [as 別名]
    def test__create_w_src(self):
        src = "/etc/hosts"
        fo = Factory.create(self.path, src=src)

        self.assertTrue(isinstance(fo, FO.FileObject))
        self.assertEquals(fo.path, self.path)
        self.assertEquals(fo.mode, fo.defaults.mode)
        self.assertEquals(fo.uid, fo.defaults.uid)
        self.assertEquals(fo.gid, fo.defaults.gid)
        self.assertEquals(fo.checksum, fo.defaults.checksum)
        self.assertEquals(fo.src, src)
開發者ID:ssato,項目名稱:packagemaker,代碼行數:13,代碼來源:FileObjectFactory.py

示例12: test__create_w_linkto

# 需要導入模塊: from pmaker.models import FileObjectFactory [as 別名]
# 或者: from pmaker.models.FileObjectFactory import create [as 別名]
    def test__create_w_linkto(self):
        linkto = "/etc/hosts"
        fo = Factory.create(self.path, linkto=linkto)

        self.assertTrue(isinstance(fo, FO.SymlinkObject))
        self.assertEquals(fo.path, self.path)
        self.assertEquals(fo.mode, fo.defaults.mode)
        self.assertEquals(fo.uid, fo.defaults.uid)
        self.assertEquals(fo.gid, fo.defaults.gid)
        self.assertEquals(fo.checksum, fo.defaults.checksum)
        self.assertEquals(fo.linkto, linkto)
開發者ID:ssato,項目名稱:packagemaker,代碼行數:13,代碼來源:FileObjectFactory.py

示例13: test__create_w_filetype_dir

# 需要導入模塊: from pmaker.models import FileObjectFactory [as 別名]
# 或者: from pmaker.models.FileObjectFactory import create [as 別名]
    def test__create_w_filetype_dir(self):
        filetype = FO.typestr_to_type("dir")
        fo = Factory.create(self.path, filetype=filetype)

        self.assertTrue(isinstance(fo, FO.DirObject))
        self.assertEquals(fo.type(), G.TYPE_DIR)
        self.assertEquals(fo.path, self.path)
        self.assertEquals(fo.mode, fo.defaults.mode)
        self.assertEquals(fo.uid, fo.defaults.uid)
        self.assertEquals(fo.gid, fo.defaults.gid)
        self.assertEquals(fo.checksum, fo.defaults.checksum)
開發者ID:ssato,項目名稱:packagemaker,代碼行數:13,代碼來源:FileObjectFactory.py

示例14: test_pred__supported__fileobjects

# 需要導入模塊: from pmaker.models import FileObjectFactory [as 別名]
# 或者: from pmaker.models.FileObjectFactory import create [as 別名]
    def test_pred__supported__fileobjects(self):
        paths = [
            "/etc/resolv.conf", "/etc/hosts",  # normal files
            "/etc",  # dirs
            "/etc/rc",  "/etc/init.d", "/etc/grub.conf"  # symlinks
        ]
        paths = [p for p in paths if os.path.exists(p)]

        for p in paths:
            fo = Factory.create(p)
            self.assertFalse(self.filter.pred(fo))
開發者ID:ssato,項目名稱:packagemaker,代碼行數:13,代碼來源:Filters.py

示例15: _parse

# 需要導入模塊: from pmaker.models import FileObjectFactory [as 別名]
# 或者: from pmaker.models.FileObjectFactory import create [as 別名]
    def _parse(self, bobj):
        """
        :param bobj: A Bunch object holds path and attrs (metadata) of files.
        """
        path = bobj.get("path", False)

        if not path or path.startswith("#"):
            return []
        else:
            paths = "*" in path and glob.glob(path) or [path]
            attrs = bobj.get("attrs", dict())

            return [Factory.create(p, self.use_rpmdb, **attrs) for p in paths]
開發者ID:masatake,項目名稱:packagemaker,代碼行數:15,代碼來源:FilelistCollectors.py


注:本文中的pmaker.models.FileObjectFactory.create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。