コード例 #1
0
ファイル: parser.py プロジェクト: masatake/packagemaker
    def test_04_parse_line_of_filelist(self):
        line = "/etc/resolv.conf"
        (paths, attrs) = P.parse_line_of_filelist(line + " \n")

        self.assertEquals(paths[0], line)
        self.assertEquals(attrs, {})

        line2 = line + ",install_path=/var/lib/network/resolv.conf,uid=0,gid=0"
        (paths, attrs) = P.parse_line_of_filelist(line2 + " \n")

        self.assertEquals(paths[0], line)
        self.assertEquals(
            attrs.install_path, "/var/lib/network/resolv.conf"
        )
        self.assertEquals(attrs.uid, 0)
        self.assertEquals(attrs.gid, 0)
コード例 #2
0
    def _parse(self, line):
        """Parse the line and returns FileObjects list generator.
        """
        # remove extra white spaces at the top and the end.
        line = line.rstrip().strip()

        if not line or line.startswith("#"):
            return []
        else:
            try:
                (paths, attrs) = P.parse_line_of_filelist(line)
            except ValueError:
                print "line=" + line
                raise

            return [Factory.create(p, self.use_rpmdb, **attrs) for p in paths]