Example #1
0
 def test_destinsrc_nt(self):
     """ Verify that Z:/a/b/c/d is under Z:/a/b/C """
     src = r"Z:/a/b/C"
     dst = r"Z:/a/b/c/d"
     if os.sep == '\\':
         assert fileutils.destinsrc(src, dst) is True
     else:
         assert fileutils.destinsrc(src, dst) is False
Example #2
0
 def get_policy_root_dir(self):
     """ Return the policy.root.dir or root.dir if not set or not under root.dir."""
     if not self._config.has_key("policy.root.dir"):
         return os.path.normpath(self._config['root.dir'])
     else:
         if fileutils.destinsrc(self._config['root.dir'], self._config['policy.root.dir']):
             return os.path.normpath(self._config['policy.root.dir'])
         else:
             return os.path.normpath(self._config['root.dir'])
Example #3
0
 def add_exclude_lst(self, filename):
     """ Adding excludes from exclude list. """
     if not os.path.exists(filename):
         raise Exception("Could not find '%s'." % filename)
     root_dir = os.path.normpath(self._config['root.dir'])
     flh = codecs.open(filename, 'r', 'utf-8')
     for line in flh:
         path = os.path.normpath(line.strip())
         if os.path.splitdrive(root_dir)[0] != "":
             path = os.path.join(os.path.splitdrive(root_dir)[0], path)
         if fileutils.destinsrc(root_dir, path):
             pathrel = pathaddition.relative.abs2rel(path, root_dir)
             logger.debug("pathrel: %s" % (pathrel))
             self.add_exclude(pathrel)
         else:
             logger.warning("path '%s' is not under '%s', ignoring." % (path, root_dir))
     flh.close()
Example #4
0
 def test_destinsrc2_nt(self):
     """ Verify that Z:/a/b/c/d is not under Z:/a/b/CC """
     if os.sep == '\\':
         src = r"Z:/a/b/CC"
         dst = r"Z:/a/b/c/d"
         assert fileutils.destinsrc(src, dst) is False
Example #5
0
 def test_destinsrc2(self):
     """ Verify that Z:/a/b/c/d is not under Z:/a/b/cc """
     src = r"Z:/a/b/cc"
     dst = r"Z:/a/b/c/d"
     assert fileutils.destinsrc(src, dst) is False