diff options
author | Éric Araujo <merwok@netwok.org> | 2011-06-10 21:26:31 (GMT) |
---|---|---|
committer | Éric Araujo <merwok@netwok.org> | 2011-06-10 21:26:31 (GMT) |
commit | 1c1d9a50262b491f755950aa2b3da20c64855581 (patch) | |
tree | dd5b91d049f618d17216212ba33e802f3d21b7a8 /Lib/packaging/util.py | |
parent | df55334d52ba297e8bba4fd267fde68f48256e1c (diff) | |
download | cpython-1c1d9a50262b491f755950aa2b3da20c64855581.zip cpython-1c1d9a50262b491f755950aa2b3da20c64855581.tar.gz cpython-1c1d9a50262b491f755950aa2b3da20c64855581.tar.bz2 |
Move useful function to packaging.util.
Original patch by Erik Bray as part of #11595, changed by me to improve
readability.
Diffstat (limited to 'Lib/packaging/util.py')
-rw-r--r-- | Lib/packaging/util.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/Lib/packaging/util.py b/Lib/packaging/util.py index 812dbe3..dddfb3f 100644 --- a/Lib/packaging/util.py +++ b/Lib/packaging/util.py @@ -250,6 +250,14 @@ def split_quoted(s): return words +def split_multiline(value): + """Split a multiline string into a list, excluding blank lines.""" + + return [element for element in + (line.strip() for line in value.split('\n')) + if element] + + def execute(func, args, msg=None, verbose=0, dry_run=False): """Perform some action that affects the outside world. @@ -542,18 +550,15 @@ def write_file(filename, contents): def _is_package(path): - if not os.path.isdir(path): - return False - return os.path.isfile(os.path.join(path, '__init__.py')) + return os.path.isdir(path) and os.path.isfile( + os.path.join(path, '__init__.py')) # Code taken from the pip project def _is_archive_file(name): archives = ('.zip', '.tar.gz', '.tar.bz2', '.tgz', '.tar') ext = splitext(name)[1].lower() - if ext in archives: - return True - return False + return ext in archives def _under(path, root): |