[Python-checkins] commit of r41617 - in sandbox/trunk/setuptools: setuptools.txt setuptools/archive_util.py

Guido van Rossum guido at python.org
Fri Dec 9 05:53:44 CET 2005


Why so many blank lines?
On 12/5/05, phillip.eby <python-checkins at python.org> wrote:
> Author: phillip.eby
> Date: Tue Dec 6 04:12:48 2005
> New Revision: 41617
>> Modified:
> sandbox/trunk/setuptools/setuptools.txt
> sandbox/trunk/setuptools/setuptools/archive_util.py
> Log:
> Added an ``unpack_directory()`` driver to ``setuptools.archive_util``, so
> that you can process a directory tree through a processing filter as if
> it were a zipfile or tarfile.
>>> Modified: sandbox/trunk/setuptools/setuptools.txt
> ==============================================================================
> --- sandbox/trunk/setuptools/setuptools.txt (original)
> +++ sandbox/trunk/setuptools/setuptools.txt Tue Dec 6 04:12:48 2005
> @@ -2177,6 +2177,10 @@
> * Made all commands that use ``easy_install`` respect its configuration
> options, as this was causing some problems with ``setup.py install``.
>> + * Added an ``unpack_directory()`` driver to ``setuptools.archive_util``, so
> + that you can process a directory tree through a processing filter as if it
> + were a zipfile or tarfile.
> +
> 0.6a8
> * Fixed some problems building extensions when Pyrex was installed, especially
> with Python 2.4 and/or packages using SWIG.
>> Modified: sandbox/trunk/setuptools/setuptools/archive_util.py
> ==============================================================================
> --- sandbox/trunk/setuptools/setuptools/archive_util.py (original)
> +++ sandbox/trunk/setuptools/setuptools/archive_util.py Tue Dec 6 04:12:48 2005
> @@ -3,10 +3,10 @@
>> __all__ = [
> "unpack_archive", "unpack_zipfile", "unpack_tarfile", "default_filter",
> - "UnrecognizedFormat", "extraction_drivers"
> + "UnrecognizedFormat", "extraction_drivers", "unpack_directory",
> ]
>> -import zipfile, tarfile, os
> +import zipfile, tarfile, os, shutil
> from pkg_resources import ensure_directory
> from distutils.errors import DistutilsError
>> @@ -80,6 +80,47 @@
>>>> +def unpack_directory(filename, extract_dir, progress_filter=default_filter):
> + """"Unpack" a directory, using the same interface as for archives
> +
> + Raises ``UnrecognizedFormat`` if `filename` is not a directory
> + """
> + if not os.path.isdir(filename):
> + raise UnrecognizedFormat("%s is not a directory" % (filename,))
> +
> + paths = {filename:('',extract_dir)}
> + for base, dirs, files in os.walk(filename):
> + src,dst = paths[base]
> + for d in dirs:
> + paths[os.path.join(base,d)] = src+d+'/', os.path.join(dst,d)
> + for f in files:
> + name = src+f
> + target = os.path.join(dst,f)
> + target = progress_filter(src+f, target)
> + if not target:
> + continue # skip non-files
> + ensure_directory(target)
> + shutil.copyfile(os.path.join(base,f), target)
> +
> +
> +
> +
> +
> +
> +
> +
> +
> +
> +
> +
> +
> +
> +
> +
> +
> +
> +
> +
> def unpack_zipfile(filename, extract_dir, progress_filter=default_filter):
> """Unpack zip `filename` to `extract_dir`
>> @@ -156,7 +197,7 @@
>>>> -extraction_drivers = unpack_zipfile, unpack_tarfile
> +extraction_drivers = unpack_directory, unpack_zipfile, unpack_tarfile
>>>> _______________________________________________
> Python-checkins mailing list
> Python-checkins at python.org
> http://mail.python.org/mailman/listinfo/python-checkins
>
--
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /