From cf6a2c4efea3b95296b73014ce0a6833f1f2b107 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20O=C5=BCarowski?= <piotr@debian.org>
Date: Mon, 19 Jul 2010 21:38:00 +0200
Subject: [PATCH] split('\n') communicate()'s stdout

---
 debpython/pydist.py | 7 ++++---
 pyclean             | 3 +--
 pycompile           | 7 +++----
 3 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/debpython/pydist.py b/debpython/pydist.py
index 6bb8a2e..e1fcdd0 100644
--- a/debpython/pydist.py
+++ b/debpython/pydist.py
@@ -118,8 +118,7 @@ def guess_dependency(req, version=None):
                  'or your upstream author to fix requires.txt')
         return set()  # should we sys.exit(1) here?
     req_dict = req_dict.groupdict()
-    name = req_dict['name'].lower()
-    details = data.get(name)
+    details = data.get(req_dict['name'].lower())
     if details:
         for item in details:
             if version not in item.get('versions', version):
@@ -157,7 +156,9 @@ def guess_dependency(req, version=None):
         exit(8)
 
     result = set()
-    for line in stdout:
+    for line in stdout.split('\n'):
+        if not line.strip():
+            continue
         result.add(line.split(':')[0])
     if len(result) > 1:
         log.error('more than one package name found for %s dist', name)
diff --git a/pyclean b/pyclean
index c13fcb1..f211262 100755
--- a/pyclean
+++ b/pyclean
@@ -91,8 +91,7 @@ def get_package_files(package_name):
     if process.returncode != 0:
         log.error('cannot get content of %s', package_name)
         sys.exit(2)
-    for line in stdout:
-        line = line.strip('\n')
+    for line in stdout.split('\n'):
         if line.endswith('.py'):
             yield line
 
diff --git a/pycompile b/pycompile
index ba618cf..976aa28 100755
--- a/pycompile
+++ b/pycompile
@@ -26,8 +26,8 @@ from __future__ import with_statement
 import logging
 import optparse
 import sys
-from os import environ, listdir, mkdir, walk
-from os.path import abspath, dirname, exists, isdir, isfile, join
+from os import environ, listdir, walk
+from os.path import abspath, exists, isdir, isfile, join
 from subprocess import PIPE, Popen
 sys.path.insert(1, '/usr/share/python/')
 from debpython.version import SUPPORTED, debsorted, vrepr, \
@@ -74,8 +74,7 @@ def get_package_files(package_name):
     if process.returncode != 0:
         log.error('cannot get content of %s', package_name)
         exit(2)
-    for line in stdout:
-        line = line.strip('\n')
+    for line in stdout.split('\n'):
         if line.endswith('.py'):
             yield line
 
-- 
GitLab