def add_directory(self, path, ignore=None):
        """Add ``*.py`` files under the directory ``path`` to the archive.
        """
        for root, dirs, files in os.walk(path):
            arc_prefix = os.path.relpath(root, os.path.dirname(path))
            # py3 remove pyc cache dirs.
            if '__pycache__' in dirs:
                dirs.remove('__pycache__')
            for f in files:
                dest_path = os.path.join(arc_prefix, f)

                # ignore specific files
                if ignore and ignore(dest_path):
                    continue

                if f.endswith('.pyc') or f.endswith('.c'):
                    continue
                f_path = os.path.join(root, f)

                self.add_file(f_path, dest_path)
def add_directory ( self , path , ignore = None ) : for root , dirs , files in os . walk ( path ) : arc_prefix = os . path . relpath ( root , os . path . dirname ( path ) ) if '__pycache__' in dirs : dirs . remove ( '__pycache__' ) for f in files : dest_path = os . path . join ( arc_prefix , f ) if ignore and ignore ( dest_path ) : continue if f . endswith ( '.pyc' ) or f . endswith ( '.c' ) : continue f_path = os . path . join ( root , f ) self . add_file ( f_path , dest_path )
Add ``*.py`` files under the directory ``path`` to the archive.