Esempio n. 1
0
    def setup_quoting(self):
        """
        Set QuotedRPath versions of important RPaths if chars_to_quote is set.

        Return True if quoting needed to be done, False else.
        """
        # FIXME the problem is that the chars_to_quote can come from the command
        # line but can also be a value coming from the repository itself,
        # set globally by the fs_abilities.xxx_set_globals functions.
        if not Globals.chars_to_quote:
            return False

        if Globals.get_api_version() < 201:  # compat200
            FilenameMapping.set_init_quote_vals()
            self.base_dir = FilenameMapping.get_quotedrpath(self.base_dir)
            self.data_dir = FilenameMapping.get_quotedrpath(self.data_dir)
            self.incs_dir = FilenameMapping.get_quotedrpath(self.incs_dir)
        else:
            self.base_dir = map_filenames.get_quotedrpath(self.base_dir)
            self.data_dir = map_filenames.get_quotedrpath(self.data_dir)
            self.incs_dir = map_filenames.get_quotedrpath(self.incs_dir)

        Globals.set_all('rbdir', self.data_dir)  # compat200

        return True
Esempio n. 2
0
 def testBasicQuote(self):
     """Test basic quoting and unquoting"""
     filenames = [
         b"hello", b"HeLLo", b"EUOeu/EUOeu", b":", b"::::EU", b"/:/:"
     ]
     for filename in filenames:
         quoted = FilenameMapping.quote(filename)
         assert FilenameMapping.unquote(quoted) == filename, filename
Esempio n. 3
0
    def set_chars_to_quote(self, rbdir):
        """Set chars_to_quote setting for backup session

        Unlike most other options, the chars_to_quote setting also
        depends on the current settings in the rdiff-backup-data
        directory, not just the current fs features.

        """
        ctq = self._compare_ctq_file(rbdir, self._get_ctq_from_fsas())

        Globals.set_all('chars_to_quote', ctq)
        if Globals.chars_to_quote:
            FilenameMapping.set_init_quote_vals()
Esempio n. 4
0
	def getinc_paths(self, basename, directory, quoted = 0):
		"""Return increment.______.dir paths"""
		if quoted:
			FilenameMapping.set_init_quote_vals()
			dirrp = FilenameMapping.QuotedRPath(Globals.local_connection,
												  directory)
		else: dirrp = rpath.RPath(Globals.local_connection, directory)
		incbasenames = [filename for filename in robust.listrp(dirrp)
						if filename.startswith(basename)]
		incbasenames.sort()
		incrps = map(dirrp.append, incbasenames)
		return map(lambda x: x.path,
				   filter(lambda incrp: incrp.isincfile(), incrps))
Esempio n. 5
0
 def testQuotedRPaths(self):
     """Test transmission of quoted rpaths"""
     qrp = FilenameMapping.QuotedRPath(self.conn, regfilename)
     assert self.conn.reval("lambda qrp: qrp.data", qrp) == qrp.data
     assert qrp.isreg(), qrp
     qrp_class_str = self.conn.reval("lambda qrp: str(qrp.__class__)", qrp)
     assert qrp_class_str.find("QuotedRPath") > -1, qrp_class_str
 def testQuotedSepBase(self):
     """Test get_quoted_sep_base function"""
     path = "/usr/local/mirror_metadata" ".1969-12-31;08421;05833;05820-07;05800.data.gz"
     qrp = FilenameMapping.get_quoted_sep_base(path)
     assert qrp.base == "/usr/local", qrp.base
     assert len(qrp.index) == 1, qrp.index
     assert qrp.index[0] == "mirror_metadata.1969-12-31T21:33:20-07:00.data.gz"
Esempio n. 7
0
 def getinc_paths(self, basename, directory, quoted=0):
     """Return increment.______.dir paths"""
     if quoted:
         FilenameMapping.set_init_quote_vals()
         dirrp = FilenameMapping.QuotedRPath(Globals.local_connection,
                                             directory)
     else:
         dirrp = rpath.RPath(Globals.local_connection, directory)
     incbasenames = [
         filename for filename in robust.listrp(dirrp)
         if filename.startswith(basename)
     ]
     incbasenames.sort()
     incrps = map(dirrp.append, incbasenames)
     return map(lambda x: x.path,
                filter(lambda incrp: incrp.isincfile(), incrps))
Esempio n. 8
0
 def testQuotedRPaths(self):
     """Test transmission of quoted rpaths"""
     qrp = FilenameMapping.QuotedRPath(self.conn, regfilename)
     self.assertEqual(self.conn.reval("lambda qrp: qrp.data", qrp),
                      qrp.data)
     self.assertTrue(qrp.isreg())
     qrp_class_str = self.conn.reval("lambda qrp: str(qrp.__class__)", qrp)
     self.assertGreater(qrp_class_str.find("QuotedRPath"), -1)
Esempio n. 9
0
 def testQuotedSepBase(self):
     """Test get_quoted_sep_base function"""
     path = (b"/usr/local/mirror_metadata"
             b".1969-12-31;08421;05833;05820-07;05800.data.gz")
     qrp = FilenameMapping.get_quoted_sep_base(path)
     assert qrp.base == b"/usr/local", qrp.base
     assert len(qrp.index) == 1, qrp.index
     assert (qrp.index[0] ==
             b"mirror_metadata.1969-12-31T21:33:20-07:00.data.gz")
Esempio n. 10
0
 def testQuotedRPath(self):
     """Test the QuotedRPath class"""
     path = (b"/usr/local/mirror_metadata"
             b".1969-12-31;08421;05833;05820-07;05800.data.gz")
     qrp = FilenameMapping.get_quotedrpath(
         rpath.RPath(Globals.local_connection, path), 1)
     assert qrp.base == b"/usr/local", qrp.base
     assert len(qrp.index) == 1, qrp.index
     assert (qrp.index[0] == b"mirror_metadata.1969-12-31T21:33:20-07:00.data.gz")
Esempio n. 11
0
    def getinc_paths(self, basename, directory, quoted=0):
        """Returns a sorted list of files which starts with basename
        within a given directory."""

        if quoted:
            FilenameMapping.set_init_quote_vals()
            dirrp = FilenameMapping.QuotedRPath(Globals.local_connection,
                                                directory)
        else:
            dirrp = rpath.RPath(Globals.local_connection, directory)
        incbasenames = [
            filename for filename in robust.listrp(dirrp)
            if filename.startswith(basename)
        ]
        incbasenames.sort()
        incrps = list(map(dirrp.append, incbasenames))
        return [
            x.path for x in [incrp for incrp in incrps if incrp.isincfile()]
        ]
 def setUp(self):
     """Just initialize quoting"""
     Globals.chars_to_quote = "A-Z"
     FilenameMapping.set_init_quote_vals()
 def testBasicQuote(self):
     """Test basic quoting and unquoting"""
     filenames = ["hello", "HeLLo", "EUOeu/EUOeu", ":", "::::EU", "/:/:"]
     for filename in filenames:
         quoted = FilenameMapping.quote(filename)
         assert FilenameMapping.unquote(quoted) == filename, filename
Esempio n. 14
0
 def setUp(self):
     """Just initialize quoting"""
     Globals.chars_to_quote = b'A-Z'
     FilenameMapping.set_init_quote_vals()