Beispiel #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
Beispiel #2
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")