Ejemplo n.º 1
0
    def process_archive(self, filename, log=False):
        f = zipfile.ZipFile(filename)

        prefix = os.path.basename(filename).rsplit('.', 1)[0]

        with progressbar(f.namelist(), prefix=prefix, enabled=log) as bar:
            for member in bar:
                if member.endswith('/'):
                    continue
                with tempfile.NamedTemporaryFile() as df:
                    with f.open(member) as sf:
                        shutil.copyfileobj(sf, df)
                        iter = self.process_file(df.name)
                        if iter is not None:
                            for tup in iter:
                                yield (chop_symbol_path(member),) + tup
Ejemplo n.º 2
0
    def process_archive(self, filename, log=False):
        f = zipfile.ZipFile(filename)

        prefix = os.path.basename(filename).rsplit('.', 1)[0]

        with progressbar(f.namelist(), prefix=prefix, enabled=log) as bar:
            for member in bar:
                if member.endswith('/'):
                    continue
                with tempfile.NamedTemporaryFile() as df:
                    with f.open(member) as sf:
                        shutil.copyfileobj(sf, df)
                        iter = self.process_file(df.name)
                        if iter is not None:
                            for tup in iter:
                                yield (chop_symbol_path(member),) + tup
Ejemplo n.º 3
0
    def process_directory(self, base, log):
        base = os.path.normpath(os.path.abspath(base))

        paths = []
        for dirpath, dirnames, filenames in os.walk(base):
            for filename in filenames:
                path = os.path.join(base, dirpath, filename)
                paths.append(path)

        with progressbar(paths, prefix=os.path.basename(base),
                         enabled=log) as bar:
            for path in bar:
                local_path = path[len(base) + 1:]
                iter = self.process_file(path)
                if iter is not None:
                    for tup in iter:
                        yield (chop_symbol_path(local_path),) + tup
Ejemplo n.º 4
0
    def process_directory(self, base, log):
        base = os.path.normpath(os.path.abspath(base))

        paths = []
        for dirpath, dirnames, filenames in os.walk(base):
            for filename in filenames:
                path = os.path.join(base, dirpath, filename)
                paths.append(path)

        with progressbar(paths, prefix=os.path.basename(base),
                         enabled=log) as bar:
            for path in bar:
                local_path = path[len(base) + 1:]
                iter = self.process_file(path)
                if iter is not None:
                    for tup in iter:
                        yield (chop_symbol_path(local_path),) + tup