Commits

Alex Grönholm committed 88d9427

PEP 8 fixes; removed a useless statement

Comments (0)

Files changed (1)

scripttest/__init__.py

 import shlex
 import subprocess
 import re
+
 from scripttest.backwardscompat import uc
 
+__all__ = ['TestFileEnvironment']
+
 console_encoding = sys.stdout.encoding
 
 if sys.platform == 'win32':
     def clean_environ(e):
         ret = dict(
-            ((str(k),str(v)) for k,v in e.items()) )
+            ((str(k), str(v)) for k, v in e.items()))
         return ret
 else:
-    def clean_environ(e): 
+    def clean_environ(e):
         return e
 
+
 # From pathutils by Michael Foord: http://www.voidspace.org.uk/python/pathutils.html
 def onerror(func, path, exc_info):
     """
     else:
         raise
 
-__all__ = ['TestFileEnvironment']
-
 if sys.platform == 'win32':
     def full_executable_path(invoked, environ):
 
         if os.path.splitext(invoked)[1]:
             return invoked
-        
+
         explicit_dir = os.path.dirname(invoked)
 
         if explicit_dir:
-            path = [ explicit_dir ]
+            path = [explicit_dir]
         else:
             path = environ.get('PATH').split(os.path.pathsep)
 
 
         for dir in path:
             for ext in extensions:
-                full_path = os.path.join(dir, invoked+ext)
-                if os.path.exists( full_path ):
+                full_path = os.path.join(dir, invoked + ext)
+                if os.path.exists(full_path):
                     return full_path
 
-        return invoked # Not found; invoking it will likely fail
+        return invoked  # Not found; invoking it will likely fail
 
     class Popen(subprocess.Popen):
         def __init__(
             self, args, bufsize=0, executable=None,
             stdin=None, stdout=None, stderr=None,
-            preexec_fn=None, close_fds=False, shell=False, 
-            cwd=None, env=None, 
+            preexec_fn=None, close_fds=False, shell=False,
+            cwd=None, env=None,
             *args_, **kw):
 
             if executable is None and not shell:
                 executable = full_executable_path(args[0], env or os.environ)
 
-            super(Popen,self).__init__(
-                args, bufsize, executable, stdin, stdout, stderr, 
+            super(Popen, self).__init__(
+                args, bufsize, executable, stdin, stdout, stderr,
                 preexec_fn, close_fds, shell, cwd, env, *args_, **kw)
-        
+
 else:
     from subprocess import Popen
 
         self.split_cmd = split_cmd
 
     def _guess_base_path(self, stack_level):
-        frame = sys._getframe(stack_level+1)
+        frame = sys._getframe(stack_level + 1)
         file = frame.f_globals.get('__file__')
         if not file:
             raise TypeError(
             else:
                 script, args = script.split(None, 1)
                 args = shlex.split(args)
-        
-        environ=clean_environ(self.environ)
+
         all = [script] + args
-
         files_before = self._find_files()
 
         if debug:
             proc = subprocess.Popen(all,
                                     cwd=cwd,
-                                    shell=(sys.platform=='win32'), # see http://bugs.python.org/issue8557
+                                    shell=(sys.platform == 'win32'),  # see http://bugs.python.org/issue8557
                                     env=clean_environ(self.environ))
         else:
-            proc = subprocess.Popen(all, stdin=subprocess.PIPE, 
-                                    stderr=subprocess.PIPE, 
+            proc = subprocess.Popen(all, stdin=subprocess.PIPE,
+                                    stderr=subprocess.PIPE,
                                     stdout=subprocess.PIPE,
                                     cwd=cwd,
-                                    shell=(sys.platform=='win32'), # see http://bugs.python.org/issue8557
+                                    shell=(sys.platform == 'win32'),  # see http://bugs.python.org/issue8557
                                     env=clean_environ(self.environ))
 
         if debug:
-            stdout,stderr = proc.communicate()
+            stdout, stderr = proc.communicate()
         else:
             stdout, stderr = proc.communicate(stdin)
         stdout = uc(stdout, console_encoding)
             'Temporary files left over: %s'
             % ', '.join(sorted(names)))
 
+
 class ProcResult(object):
 
     """
                     s.append(t)
         return '\n'.join(s)
 
+
 class FoundFile(object):
 
     """
             self.__class__.__name__,
             self.base_path, self.path)
 
+
 class FoundDir(object):
 
     """
             self.__class__.__name__,
             self.base_path, self.path)
 
+
 def _popget(d, key, default=None):
     """
     Pop the key if found (else return default)
         return d.pop(key)
     return default
 
+
 def _space_prefix(pref, full, sep=None, indent=None, include_sep=True):
     """
     Anything shared by pref and full will be replaced with spaces