Esempio n. 1
0
    def compare(self, other, source=None):
        from .utils.compare import compare_files

        differences = []
        try:
            listing_diff = Difference.from_text(
                '\n'.join(list_files(self.path)),
                '\n'.join(list_files(other.path)),
                self.path,
                other.path,
                source='file list')
            if listing_diff:
                differences.append(listing_diff)
        except RequiredToolNotFound:
            logger.info("Unable to find 'getfacl'.")
        differences.extend(compare_meta(self.name, other.name))
        my_container = DirectoryContainer(self)
        other_container = DirectoryContainer(other)
        my_names = my_container.get_member_names()
        other_names = other_container.get_member_names()
        to_compare = set(my_names).intersection(other_names)
        to_compare = set(filter_excludes(to_compare))
        with Progress(len(to_compare)) as p:
            for name in sorted(to_compare):
                my_file = my_container.get_member(name)
                other_file = other_container.get_member(name)
                inner_difference = compare_files(my_file,
                                                 other_file,
                                                 source=name)
                meta_differences = compare_meta(my_file.name, other_file.name)
                if meta_differences and not inner_difference:
                    inner_difference = Difference(None, my_file.path,
                                                  other_file.path)
                if inner_difference:
                    inner_difference.add_details(meta_differences)
                    differences.append(inner_difference)
                p.step(msg=name)
        if not differences:
            return None
        difference = Difference(None, self.path, other.path, source)
        difference.add_details(differences)
        return difference
Esempio n. 2
0
 def get_filtered_members(self):
     # If your get_member implementation is O(n) then this will be O(n^2)
     # cost. In such cases it is HIGHLY RECOMMENDED to override this as well
     for name in filter_excludes(self.get_member_names()):
         yield name, self.get_member(name)