James Palmer avatar James Palmer committed bc03c2a

pep8 fixes

Comments (0)

Files changed (19)

 # Build the project's HTML documentation
 docs:
 	cd docs && make html
+
+pep8:
+	pep8 .

ignite/__init__.py

 else:
     for p in __path__:
         modulefinder.AddPackagePath(__name__, p)
-

ignite/bool_optparse.py

 """
 
 import optparse
+
 try:
     _ = optparse._
 except AttributeError:
     from gettext import gettext as _
 
+
 class BoolOptionParser(optparse.OptionParser):
 
     def _process_long_opt(self, rargs, values):
                 # Don't process
                 return
             else:
-                self.error(_('%s option takes a boolean value only (true/false)') % opt)
+                self.error(_('%s option takes a boolean value only ' +
+                             '(true/false)') % opt)
 
         else:
             value = None

ignite/checkperms.py

 """
 import os
 
+
 def read_perm_spec(spec):
     """
     Reads a spec like 'rw-r--r--' into a octal number suitable for
         if read == 'r':
             mask = mask | 4
         elif read != '-':
-            raise ValueError, (
+            raise ValueError(
                 "Character %r unexpected (should be '-' or 'r')"
                 % read)
         if write == 'w':
             mask = mask | 2
         elif write != '-':
-            raise ValueError, (
+            raise ValueError(
                 "Character %r unexpected (should be '-' or 'w')"
                 % write)
         if exe == 'x':
             mask = mask | 1
         elif exe not in ('s', '-'):
-            raise ValueError, (
+            raise ValueError(
                 "Character %r unexpected (should be '-', 'x', or 's')"
                 % exe)
         if exe == 's' and i == 2:
-            raise ValueError, (
+            raise ValueError(
                 "The 'other' executable setting cannot be suid/sgid ('s')")
-        mask = mask << ((2-i)*3)
+        mask = mask << ((2 - i) * 3)
         if exe == 's':
             mask = mask | set_bit
         total_mask = total_mask | mask
 exe_mask = 0111
 full_mask = 07777
 
+
 def mode_diff(filename, mode, **kw):
     """
     Returns the differences calculated using ``calc_mode_diff``
     cur_mode = os.stat(filename).st_mode
     return calc_mode_diff(cur_mode, mode, **kw)
 
+
 def calc_mode_diff(cur_mode, mode, keep_exe=True,
                    not_set='not set: ',
                    set='set: '):
             diffs.append(set + desc)
     return diffs
 
+
 def calc_set_mode(cur_mode, mode, keep_exe=True):
     """
     Calculates the new mode given the current node ``cur_mode`` and
     new_mode = keep_parts | mode
     return new_mode
 
+
 def set_mode(filename, mode, **kw):
     """
     Sets the mode on ``filename`` using ``calc_set_mode``
     new_mode = calc_set_mode(cur_mode, mode, **kw)
     os.chmod(filename, new_mode)
 
+
 def calc_ownership_spec(spec):
     """
     Calculates what a string spec means, returning (uid, username,
             group = grp.getgrgid(gid).gr_name
     return (uid, user, gid, group)
 
+
 def ownership_diff(filename, spec):
     """
     Return a list of differences between the ownership of ``filename``
                      (grp.getgrgid(st.st_gid).gr_name, group))
     return diffs
 
+
 def set_ownership(filename, spec):
     """
     Set the ownership of ``filename`` given the spec.
         gid = st.st_gid
     os.chmod(filename, uid, gid)
 
+
 class PermissionSpec(object):
     """
     Represents a set of specifications for permissions.
         paths = self.paths.items()
         paths.sort(lambda a, b: -cmp(len(a[0]), len(b[0])))
 
+
 class _Rule(object):
     class __metaclass__(type):
         def __new__(meta, class_name, bases, d):
             return cls
 
     inherit = False
+
     def noexists(self):
         return ['Path %s does not exist' % path]
 
+
 class _NoModify(_Rule):
 
     name = 'nomodify'
     def fix(self, path):
         pass
 
+
 class _NoExist(_Rule):
 
     name = 'noexist'
         # @@: Should delete?
         pass
 
+
 class _SymLink(_Rule):
 
     name = 'symlink'
             # @@: This should correct the symlink or something:
             print 'Not symlinking %s' % path
 
+
 class _Permission(_Rule):
 
     name = '*'
     def fix(self, path):
         set_mode(path, self.perm_spec)
 
+
 class _Strategy(object):
 
     def __init__(self, spec):
         self.spec = spec
 
+
 class _Check(_Strategy):
 
     def noexists(self, path, checker):
     def check(self, path, checker):
         checker.check(path)
 
+
 class _Fixer(_Strategy):
 
     def noexists(self, path, checker):
     def check(self, path, checker):
         checker.fix(path)
 
+
 if __name__ == '__main__':
     import doctest
     doctest.testmod()
-

ignite/command.py

     # precedence.
     message = property(_get_message, _set_message)
 
+
 class NoDefault(object):
     pass
 
 
 python_version = sys.version.splitlines()[0].strip()
 
-parser = optparse.OptionParser(add_help_option=False,
-                               version='%s from %s (python %s)'
-                               % (dist, dist.location, python_version),
-                               usage='%prog [ignite_options] COMMAND [command_options]')
+parser = optparse.OptionParser(
+    add_help_option=False,
+    version='%s from %s (python %s)'
+    % (dist, dist.location, python_version),
+    usage='%prog [ignite_options] COMMAND [command_options]')
 
 parser.add_option(
     '--plugin',
     action='append',
     dest='plugins',
-    help="Add a plugin to the list of commands (plugins are Egg specs; will also require() the Egg)")
+    help="Add a plugin to the list of commands (plugins are Egg specs; " + \
+        "will also require() the Egg)")
 parser.add_option(
     '-h', '--help',
     action='store_true',
 
 system_plugins = []
 
+
 def run(args=None):
     if (not args and
         len(sys.argv) >= 2
         command = commands[command_name].load()
     invoke(command, command_name, options, args[1:])
 
+
 def parse_exe_file(config):
     import shlex
     p = ConfigParser.RawConfigParser()
     args = [command_name, config] + options
     return args
 
+
 def get_commands():
     plugins = system_plugins[:]
     egg_info_dir = pluginlib.find_egg_info_dir(os.getcwd())
     commands.update(pluginlib.load_global_commands())
     return commands
 
+
 def invoke(command, command_name, options, args):
     try:
         runner = command(command_name)
     min_args_error = 'You must provide at least %(min_args)s arguments'
     required_args = None
     # If this command takes a configuration file, set this to 1 or -1
-    # Then if invoked through #! the config file will be put into the positional
-    # arguments -- at the beginning with 1, at the end with -1
+    # Then if invoked through #! the config file will be put into the
+    # positional arguments -- at the beginning with 1, at the end with -1
     takes_config_file = None
 
     # Grouped in help messages by this:
 
     def parse_args(self, args):
         if self.usage:
-            usage = ' '+self.usage
+            usage = ' ' + self.usage
         else:
             usage = ''
         self.parser.usage = "%%prog [options]%s\n%s" % (
         if len(s) >= length:
             return s
         if dir == 'left':
-            return s + ' '*(length-len(s))
+            return s + ' ' * (length - len(s))
         else:
-            return ' '*(length-len(s)) + s
+            return ' ' * (length - len(s)) + s
 
     def standard_parser(cls, verbose=True,
                         interactive=False,
             parser.add_option('-f', '--overwrite',
                               dest="overwrite",
                               action="store_true",
-                              help="Overwrite files (warnings will be emitted for non-matching files otherwise)")
+                              help="Overwrite files (warnings will be " + \
+                                  "emitted for non-matching files otherwise)")
         return parser
 
     standard_parser = classmethod(standard_parser)
                 f = open(filename, 'wb')
                 f.write(content)
                 f.close()
-            if svn_add and os.path.exists(os.path.join(os.path.dirname(filename), '.svn')):
+            if svn_add and os.path.exists(os.path.join(
+                    os.path.dirname(filename), '.svn')):
                 self.svn_command('add', filename,
                                  warn_returncode=True)
             return
             if self.interactive:
                 while 1:
                     s = raw_input(
-                        'Overwrite file with new content? [y/N] ').strip().lower()
+                        'Overwrite file with new content? [y/N]').lower()
                     if not s:
                         s = 'n'
                     if s.startswith('y'):
             if regex.search(lines[i]):
                 # Found it!
                 if (lines[i:] and len(lines[i:]) > 1 and
-                    ''.join(lines[i+1:]).strip().startswith(text.strip())):
+                    ''.join(lines[(i + 1):]).strip().startswith(text.strip())):
                     # Already have it!
-                    print 'Warning: line already found in %s (not inserting' % filename
-                    print '  %s' % lines[i]
+                    print 'Warning: line already found in %s (not ' % filename
+                    print 'inserting %s' % lines[i]
                     return
 
                 if indent:
                     text = text.lstrip()
                     match = re.search(r'^[ \t]*', lines[i])
                     text = match.group(0) + text
-                lines[i+1:i+1] = [text]
+                lines[(i + 1):(i + 1)] = [text]
                 break
         else:
             errstr = (
                 "Marker '-*- %s -*-' not found in %s"
                 % (marker_name, filename))
-            if 1 or self.simulate: # @@: being permissive right now
+            if 1 or self.simulate:  # @@: being permissive right now
                 print 'Warning: %s' % errstr
             else:
                 raise ValueError(errstr)
             f.close()
             if (not already_existed
                 and svn_add
-                and os.path.exists(os.path.join(os.path.dirname(filename), '.svn'))):
+                and os.path.exists(os.path.join(
+                        os.path.dirname(filename), '.svn'))):
                 self.svn_command('add', filename)
 
     def parse_vars(self, args):
         if initial is None:
             initial = indent
         lines = text.splitlines()
-        first = (' '*initial) + lines[0]
-        rest = [(' '*indent)+l for l in lines[1:]]
-        return '\n'.join([first]+rest)
+        first = (' ' * initial) + lines[0]
+        rest = [(' ' * indent) + l for l in lines[1:]]
+        return '\n'.join([first] + rest)
 
 
 class NotFoundCommand(Command):
                                 command.load().summary)
         return 2
 
+
 def popdefault(dict, name, default=None):
     if name not in dict:
         return default

ignite/copydir.py

     subprocess = None
 import inspect
 
+
 class SkipTemplate(Exception):
     """
     Raised to indicate that the template should not be copied over.
     Raise this exception during the substitution of your template
     """
 
+
 def copy_dir(source, dest, vars, verbosity, simulate, indent=0,
              use_cheetah=False, sub_vars=True, interactive=False,
              svn_add=True, overwrite=True, template_renderer=None):
     else:
         names = os.listdir(source)
     names.sort()
-    pad = ' '*(indent*2)
+    pad = ' ' * (indent * 2)
     if not os.path.exists(dest):
         if verbosity >= 1:
             print '%sCreating %s/' % (pad, dest)
             if verbosity:
                 print '%sRecursing into %s' % (pad, os.path.basename(full))
             copy_dir((source[0], full), dest_full, vars, verbosity, simulate,
-                     indent=indent+1, use_cheetah=use_cheetah,
+                     indent=indent + 1, use_cheetah=use_cheetah,
                      sub_vars=sub_vars, interactive=interactive,
                      svn_add=svn_add, template_renderer=template_renderer)
             continue
             if verbosity:
                 print '%sRecursing into %s' % (pad, os.path.basename(full))
             copy_dir(full, dest_full, vars, verbosity, simulate,
-                     indent=indent+1, use_cheetah=use_cheetah,
+                     indent=indent + 1, use_cheetah=use_cheetah,
                      sub_vars=sub_vars, interactive=interactive,
                      svn_add=svn_add, template_renderer=template_renderer)
             continue
             f.close()
         if sub_file:
             try:
-                content = substitute_content(content, vars, filename=full,
-                                             use_cheetah=use_cheetah,
-                                             template_renderer=template_renderer)
+                content = substitute_content(
+                    content, vars, filename=full,
+                    use_cheetah=use_cheetah,
+                    template_renderer=template_renderer)
             except SkipTemplate:
                 continue
             if content is None:
             f.close()
             if old_content == content:
                 if verbosity:
-                    print '%s%s already exists (same content)' % (pad, dest_full)
+                    print '%s%s already exists (same content)' % \
+                        (pad, dest_full)
                 continue
             if interactive:
                 if not query_interactive(
         if verbosity and use_pkg_resources:
             print '%sCopying %s to %s' % (pad, full, dest_full)
         elif verbosity:
-            print '%sCopying %s to %s' % (pad, os.path.basename(full), dest_full)
+            print '%sCopying %s to %s' % (
+                pad, os.path.basename(full), dest_full)
         if not simulate:
             f = open(dest_full, 'wb')
             f.write(content)
             f.close()
         if svn_add and not already_exists:
-            if not os.path.exists(os.path.join(os.path.dirname(os.path.abspath(dest_full)), '.svn')):
+            if not os.path.exists(os.path.join(os.path.dirname(
+                        os.path.abspath(dest_full)), '.svn')):
                 if verbosity > 1:
                     print '%s.svn/ does not exist; cannot add file' % pad
             else:
         elif svn_add and already_exists and verbosity > 1:
             print '%sFile already exists (not doing svn add)' % pad
 
+
 def should_skip_file(name):
     """
     Checks if a file should be skipped based on its name.
 # Overridden on user's request:
 all_answer = None
 
+
 def query_interactive(src_fn, dest_fn, src_content, dest_content,
                       simulate):
     global all_answer
     removed = len([l for l in u_diff if l.startswith('-')
                    and not l.startswith('---')])
     if added > removed:
-        msg = '; %i lines added' % (added-removed)
+        msg = '; %i lines added' % (added - removed)
     elif removed > added:
-        msg = '; %i lines removed' % (removed-added)
+        msg = '; %i lines removed' % (removed - added)
     else:
         msg = ''
     print 'Replace %i bytes with %i bytes (%i/%i lines changed%s)' % (
   Type "all Y/N/B" to use Y/N/B for answer to all future questions
 """
 
+
 def svn_makedirs(dir, svn_add, verbosity, pad):
     parent = os.path.dirname(os.path.abspath(dir))
     if not os.path.exists(parent):
         print 'Script output:'
         print stdout
 
+
 def substitute_filename(fn, vars):
     for var, value in vars.items():
         fn = fn.replace('+%s+' % var, str(value))
     return fn
 
+
 def substitute_content(content, vars, filename='<string>',
                        use_cheetah=False, template_renderer=None):
     global Cheetah
                                      searchList=[vars])
     return careful_sub(tmpl, vars, filename)
 
+
 def careful_sub(cheetah_template, vars, filename):
     """
     Substitutes the template with the variables, using the
             call_vars[arg] = vars[arg]
     return sub_catcher(filename, vars, body, **call_vars)
 
+
 def sub_catcher(filename, vars, func, *args, **kw):
     """
     Run a substitution, returning the value.  If an error occurs, show
                 print '%s = %r' % (name, value)
         raise
 
+
 def html_quote(s):
     if s is None:
         return ''
     return cgi.escape(str(s), 1)
 
+
 def url_quote(s):
     if s is None:
         return ''
     return urllib.quote(str(s))
 
+
 def test(conf, true_cond, false_cond=None):
     if conf:
         return true_cond
     else:
         return false_cond
 
+
 def skip_template(condition=True, *args):
     """
     Raise SkipTemplate, which causes copydir to skip the template
     if condition:
         raise SkipTemplate(*args)
 
+
 def _add_except(exc, info):
     if not hasattr(exc, 'args') or exc.args is None:
         return
     'skip_template': skip_template,
     }
 
+
 class TypeMapper(dict):
 
     def __getitem__(self, item):
         else:
             return str(value)
 
+
 def eval_with_catch(expr, vars):
     try:
         return eval(expr, vars)
         _add_except(e, 'in expression %r' % expr)
         raise
 
+
 class LaxTemplate(string.Template):
     # This change of pattern allows for anything in braces, but
     # only identifiers outside of braces:

ignite/create_distro.py

 except NameError:
     from sets import Set as set
 
+
 class CreateDistroCommand(Command):
 
     usage = 'PACKAGE_NAME [VAR=VALUE VAR2=VALUE2 ...]'
                       dest='output_dir',
                       metavar='DIR',
                       default='.',
-                      help="Write put the directory into DIR (default current directory)")
+                      help="Write put the directory into DIR " +
+                           "(default current directory)")
     parser.add_option('--svn-repository',
                       dest='svn_repository',
                       metavar='REPOS',
-                      help="Create package at given repository location (this will create the standard trunk/ tags/ branches/ hierarchy)")
+                      help="Create package at given repository " +
+                           "location (this will create the standard " +
+                           "trunk/ tags/ branches/ hierarchy)")
     parser.add_option('--list-templates',
                       dest='list_templates',
                       action='store_true',
     parser.add_option('--list-variables',
                       dest="list_variables",
                       action="store_true",
-                      help="List all variables expected by the given template (does not create a package)")
+                      help="List all variables expected by the given " +
+                           "template (does not create a package)")
     parser.add_option('--inspect-files',
                       dest='inspect_files',
                       action='store_true',
-                      help="Show where the files in the given (already created) directory came from (useful when using multiple templates)")
+                      help="Show where the files in the given (already " +
+                           "created) directory came from (useful when " +
+                           "using multiple templates)")
     parser.add_option('--config',
                       action='store',
                       dest='config',
             return self.list_variables(templates)
         if self.verbose:
             print 'Selected and implied templates:'
-            max_tmpl_name = max([len(tmpl_name) for tmpl_name, tmpl in templates])
+            max_tmpl_name = max([len(tmpl_name) for tmpl_name, tmpl
+                                 in templates])
             for tmpl_name, tmpl in templates:
                 print '  %s%s  %s' % (
-                    tmpl_name, ' '*(max_tmpl_name-len(tmpl_name)),
+                    tmpl_name, ' ' * (max_tmpl_name - len(tmpl_name)),
                     tmpl.summary)
             print
         if not self.args:
             for key, value in self.read_vars(self.options.config).items():
                 vars.setdefault(key, value)
 
-        if self.verbose: # @@: > 1?
+        if self.verbose:  # @@: > 1?
             self.display_vars(vars)
 
         if self.options.inspect_files:
 
             self.run_command(sys.executable, 'setup.py', 'egg_info',
                              cwd=output_dir,
-                             # This shouldn't be necessary, but a bug in setuptools 0.6c3 is causing a (not entirely fatal) problem that I don't want to fix right now:
+                             # This shouldn't be necessary, but a bug in
+                             # setuptools 0.6c3 is causing a (not entirely
+                             # fatal) problem that I don't want to fix
+                             # right now:
                              expect_returncode=True)
             found_setup_py = True
         elif self.verbose > 1:
     def setup_svn_repository(self, output_dir, dist_name):
         # @@: Use subprocess
         svn_repos = self.options.svn_repository
-        svn_repos_path = os.path.join(svn_repos, dist_name).replace('\\','/')
+        svn_repos_path = os.path.join(svn_repos, dist_name).replace('\\', '/')
         svn_command = 'svn'
         if sys.platform == 'win32':
             svn_command += '.exe'
-        # @@: The previous method of formatting this string using \ doesn't work on Windows
+        # @@: The previous method of formatting this string using \
+        # doesn't work on Windows
         cmd = '%(svn_command)s mkdir %(svn_repos_path)s' + \
             ' %(svn_repos_path)s/trunk %(svn_repos_path)s/tags' + \
             ' %(svn_repos_path)s/branches -m "New project %(dist_name)s"'
         cmd = cmd % {
             'svn_repos_path': svn_repos_path,
             'dist_name': dist_name,
-            'svn_command':svn_command,
+            'svn_command': svn_command,
         }
         if self.verbose:
             print "Running:"
             print cmd
         if not self.simulate:
             os.system(cmd)
-        svn_repos_path_trunk = os.path.join(svn_repos_path,'trunk').replace('\\','/')
-        cmd = svn_command+' co "%s" "%s"' % (svn_repos_path_trunk, output_dir)
+        svn_repos_path_trunk = os.path.join(svn_repos_path,
+                                            'trunk').replace('\\', '/')
+        cmd = svn_command + ' co "%s" "%s"' % (svn_repos_path_trunk,
+                                               output_dir)
         if self.verbose:
             print "Running %s" % cmd
         if not self.simulate:
         max_var = max([len(n) for n, v in vars])
         for name, value in vars:
             print '  %s:%s  %s' % (
-                name, ' '*(max_var-len(name)), value)
+                name, ' ' * (max_var - len(name)), value)
 
     def list_templates(self):
         templates = []
             # @@: Wrap description
             print '  %s:%s  %s' % (
                 template.name,
-                ' '*(max_name-len(template.name)),
+                ' ' * (max_name - len(template.name)),
                 template.summary)
 
     def inspect_files(self, output_dir, templates, vars):
     _ignore_dirs = ['CVS', '_darcs', '.svn']
 
     def _show_files(self, output_dir, file_sources, join='', indent=0):
-        pad = ' '*(2*indent)
+        pad = ' ' * (2 * indent)
         full_dir = os.path.join(output_dir, join)
         names = os.listdir(full_dir)
         dirs = [n for n in names
             self._show_files(
                 output_dir, file_sources,
                 join=os.path.join(join, dir),
-                indent=indent+1)
+                indent=indent + 1)
 
     def _show_leftovers(self, output_dir, file_sources):
         if not file_sources:
     def _show_template_vars(self, tmpl_name, tmpl, message=None):
         title = '%s (from %s)' % (tmpl.name, tmpl_name)
         print title
-        print '-'*len(title)
+        print '-' * len(title)
         if message is not None:
             print '  %s' % message
             print

ignite/entrypoints.py

 import inspect
 import types
 
+
 class EntryPointCommand(Command):
 
     usage = "ENTRY_POINT"
     parser.add_option('--regex',
                       dest='use_regex',
                       action='store_true',
-                      help="Make pattern match as regular expression, not just a wildcard pattern")
+                      help="Make pattern match as regular expression, " +
+                      "not just a wildcard pattern")
 
     def command(self):
         if self.options.list_entry_points:
                 continue
             if len(dists) > 1:
                 print '%s (+ %i older versions)' % (
-                    dist, len(dists)-1)
+                    dist, len(dists) - 1)
             else:
                 print '%s' % dist
             entries.sort(lambda a, b: cmp(a.name, b.name))
                 para = '\n'.join(textwrap.wrap(para, width))
             new_paras.append(para)
         text = '\n\n'.join(new_paras)
-        lines = [' '*indent + line
+        lines = [' ' * indent + line
                  for line in text.splitlines()]
         return '\n'.join(lines)
 
     def _ep_description(self, ep, pad_name=None):
         name = ep.name
         if pad_name is not None:
-            name = name + ' '*(pad_name-len(name))
+            name = name + ' ' * (pad_name - len(name))
         dest = ep.module_name
         if ep.attrs:
             dest = dest + ':' + '.'.join(ep.attrs)
         return eps
 
     def get_group_description(self, group):
-        for entry in pkg_resources.iter_entry_points('ignite.entry_point_description'):
+        for entry in pkg_resources.iter_entry_points(
+            'ignite.entry_point_description'):
             if entry.name == group:
                 ep = entry.load()
                 if hasattr(ep, 'description'):
 
     def _safe_get_entry_point_description(self, ep, group):
         ep.dist.activate()
-        meta_group = 'ignite.description.'+group
+        meta_group = 'ignite.description.' + group
         meta = ep.dist.get_entry_info(meta_group, ep.name)
         if not meta:
             generic = list(pkg_resources.iter_entry_points(
             desc = meta.load()
         return desc
 
+
 class EntryPointDescription(object):
 
     def __init__(self, group):
     # Should define:
     # * description
 
+
 class SuperGeneric(object):
 
     def __init__(self, doc_object):
             else:
                 self.description = sig
 
+
 def dedent(s):
     if s is None:
         return s
     s = s.strip('\n').strip('\r')
     return textwrap.dedent(s)
 
+
 def super_generic(obj):
     desc = SuperGeneric(obj)
     if not desc.description:
         return None
     return desc
 
+
 class ErrorDescription(object):
 
     def __init__(self, exc, tb):
         self.exc = exc
         self.tb = '\n'.join(tb)
         self.description = 'Error loading: %s' % exc
-
     This is an entry point that describes other entry points.
     """
 
+
 class CreateTemplateDescription(object):
     description = """
     Entry point for creating the file layout for a new project
     from a template.
     """
 
+
 class IgniteCommandDescription(object):
     description = """
     Entry point that adds a command to the ``ignite`` script
     to a project that has specifically enabled the command.
     """
 
+
 class GlobalIgniteCommandDescription(object):
     description = """
     Entry point that adds a command to the ``ignite`` script
     globally.
     """
 
+
 class AppInstallDescription(object):
     description = """
     This defines a runner that can install the application given a
 ## Not in Ignite per se, but we'll document
 ## them...
 
+
 class ConsoleScriptsDescription(object):
     description = """
     When a package is installed, any entry point listed here will be
     turned into a command-line script.
     """
 
+
 class DistutilsCommandsDescription(object):
     description = """
     This will add a new command when running
     package uses setuptools.
     """
 
+
 class SetupKeywordsDescription(object):
     description = """
     This adds a new keyword to setup.py's setup() function, and a
     validator to validate the value.
     """
 
+
 class EggInfoWriters(object):
     description = """
     This adds a new writer that creates files in the PkgName.egg-info/

ignite/filemaker.py

 except ImportError:
     subprocess = None
 
+
 class FileOp(object):
     """
     Enhance the ease of file copying/processing from a package into a target
         self.source_dir = source_dir
         self.use_pkg_resources = isinstance(source_dir, tuple)
 
-    def copy_file(self, template, dest, filename=None, add_py=True, package=True,
-                  template_renderer=None):
+    def copy_file(self, template, dest, filename=None, add_py=True,
+                  package=True, template_renderer=None):
         """
         Copy a file from the source location to somewhere in the
         destination.
             # exists.
             return
         if not os.path.exists(dir):
-            self.ensure_dir(os.path.dirname(dir), svn_add=svn_add, package=package)
+            self.ensure_dir(os.path.dirname(dir), svn_add=svn_add,
+                            package=package)
             if self.verbose:
                 print 'Creating %s' % self.shorten(dir)
             if not self.simulate:
                 f.close()
                 print 'Creating %s' % self.shorten(initfile)
                 if (svn_add and
-                    os.path.exists(os.path.join(os.path.dirname(dir), '.svn'))):
+                    os.path.exists(os.path.join(os.path.dirname(dir),
+                                                '.svn'))):
                     self.svn_command('add', initfile)
         else:
             if self.verbose > 1:
         the user what to do if a file exists with different content.
         """
         global difflib
-        self.ensure_dir(os.path.dirname(filename), svn_add=svn_add, package=package)
+        self.ensure_dir(os.path.dirname(filename), svn_add=svn_add,
+                        package=package)
         if not os.path.exists(filename):
             if self.verbose:
                 print 'Creating %s' % filename
                 f = open(filename, 'wb')
                 f.write(content)
                 f.close()
-            if svn_add and os.path.exists(os.path.join(os.path.dirname(filename), '.svn')):
+            if (svn_add and
+                os.path.exists(os.path.join(os.path.dirname(filename),
+                                            '.svn'))):
                 self.svn_command('add', filename)
             return
         f = open(filename, 'rb')
             if self.interactive:
                 while 1:
                     s = raw_input(
-                        'Overwrite file with new content? [y/N] ').strip().lower()
+                        'Overwrite file with new content? [y/N]').lower()
                     if not s:
                         s = 'n'
                     if s.startswith('y'):
                 print stdout
         return stdout
 
+
 def popdefault(dict, name, default=None):
     if name not in dict:
         return default
         v = dict[name]
         del dict[name]
         return v
-
 from command import Command
 import pluginlib
 
+
 class GrepCommand(Command):
 
     summary = 'Search project for symbol'
         if not filename.endswith('.py'):
             self.search_text(filename)
             return
-        pyc = filename[:-2]+'pyc'
+        pyc = filename[:-2] + 'pyc'
         if not os.path.exists(pyc):
             py_compile.compile(filename)
         if not os.path.exists(pyc):
         if parts:
             parts = ':' + parts
         return self.module_name(filename) + parts
-
 from command import Command, get_commands
 from command import parser as base_parser
 
+
 class HelpCommand(Command):
 
     summary = "Display help"
                 #if command.description:
                 #    print self.indent_block(command.description, 4)
             print
-

ignite/pluginlib.py

 import os
 import pkg_resources
 
+
 def add_plugin(egg_info_dir, plugin_name):
     """
     Add the plugin to the given distribution (or spec), in
         f.write('\n')
     f.close()
 
+
 def remove_plugin(egg_info_dir, plugin_name):
     """
     Remove the plugin to the given distribution (or spec), in
         f.write('\n')
     f.close()
 
+
 def find_egg_info_dir(dir):
     while 1:
         try:
             return None
         dir = parent
 
+
 def resolve_plugins(plugin_list):
     found = []
     while plugin_list:
                     plugin_list.append(add_plugin)
     return map(get_distro, found)
 
+
 def get_distro(spec):
     return pkg_resources.get_distribution(spec)
 
+
 def load_commands_from_plugins(plugins):
     commands = {}
     for plugin in plugins:
             plugin, group='ignite.ignite_command'))
     return commands
 
+
 def parse_lines(data):
     result = []
     for line in data.splitlines():
             result.append(line)
     return result
 
+
 def load_global_commands():
     commands = {}
     for p in pkg_resources.iter_entry_points('ignite.global_ignite_command'):
         commands[p.name] = p
     return commands
 
+
 def egg_name(dist_name):
     return pkg_resources.to_filename(pkg_resources.safe_name(dist_name))
 
+
 def egg_info_dir(base_dir, dist_name):
     all = []
     for dir_extension in ['.'] + os.listdir(base_dir):
         full = os.path.join(base_dir, dir_extension,
-                            egg_name(dist_name)+'.egg-info')
+                            egg_name(dist_name) + '.egg-info')
         all.append(full)
         if os.path.exists(full):
             return full

ignite/templates.py

 import command
 import jinja2
 
+
 def default_template_renderer(content, vars, filename=None):
     template = jinja2.Template(content)
     return template.render(vars)
 
+
 class Template(object):
 
     # Subclasses must define:
     def template_dir(self):
         assert self._template_dir is not None, (
             "Template %r didn't set _template_dir" % self)
-        if isinstance( self._template_dir, tuple):
+        if isinstance(self._template_dir, tuple):
             return self._template_dir
         else:
             return os.path.join(self.module_dir(), self._template_dir)
             if var.name not in unused_vars:
                 if cmd.interactive:
                     prompt = 'Enter %s' % var.full_description()
-                    response = cmd.challenge(prompt, var.default, var.should_echo)
+                    response = cmd.challenge(prompt, var.default,
+                                             var.should_echo)
                     converted_vars[var.name] = response
                 elif var.default is command.NoDefault:
                     errors.append('Required variable missing: %s'
 
 NoDefault = command.NoDefault
 
+
 class var(object):
 
     def __init__(self, name, description,
         for var in vars:
             if var.description:
                 print '%s%s%s  %s' % (
-                    ' '*indent,
+                    ' ' * indent,
                     var.name,
-                    ' '*(max_name-len(var.name)),
+                    ' ' * (max_name - len(var.name)),
                     var.description)
             else:
                 print '  %s' % var.name
 
     print_vars = classmethod(print_vars)
 
+
 class BasicPackage(Template):
 
     _template_dir = 'ignite-templates/basic_package'
         var('author_email', 'Author email'),
         var('url', 'URL of homepage'),
         var('license_name', 'License name'),
-        var('zip_safe', 'True/False: if the package can be distributed as a .zip file', default=False),
+        var('zip_safe',
+            'True/False: if the package can be distributed as a .zip file',
+            default=False),
         ]
 
     template_renderer = staticmethod(default_template_renderer)
 _skip_variables = ['VFN', 'currentTime', 'self', 'VFFSL', 'dummyTrans',
                    'getmtime', 'trans']
 
+
 def find_args_in_template(template):
     if isinstance(template, (str, unicode)):
         # Treat as filename:
     if not hasattr(template, 'body'):
         # Don't know...
         return None
+
     method = template.body
     args, varargs, varkw, defaults = inspect.getargspec(method)
-    defaults=list(defaults or [])
+    defaults = list(defaults or [])
     vars = []
     while args:
         if len(args) == len(defaults):
                 default=default))
     return vars
 
+
 def find_args_in_dir(dir, verbose=False):
     all_vars = {}
     for fn in os.listdir(dir):
                     "Variable defaults do not match: %s: %r and %r"
                     % (var_name, cur_var.default, var.default))
     return all_vars
-
 from setuptools import setup, find_packages
-import re, os
+import os
+import re
 
 version = '1.7.5'
 
 if os.path.exists(news):
     news = open(news).read()
     parts = re.split(r'([0-9\.]+)\s*\n\r?-+\n\r?', news)
-    for i in range(len(parts)-1):
+    for i in range(len(parts) - 1):
         if parts[i] == version:
-            found_news = parts[i+i]
+            found_news = parts[i + i]
             break
 # if not found_news:
 #     print 'Warning: no news for this version found'
 
-long_description="""\
+long_description = """\
 Create file layouts for packages.  For instance, ``ignite create
   --template=basic_package MyPackage`` will create a `setuptools
   <http://peak.telecommunity.com/DevCenter/setuptools>`_-ready
 
 if found_news:
     title = 'Changes in %s' % version
-    long_description += "\n%s\n%s\n" % (title, '-'*len(title))
+    long_description += "\n%s\n%s\n" % (title, '-' * len(title))
     long_description += found_news
 
 setup(
     name="Ignite",
     version=version,
-    description="A pluggable command-line frontend, including commands to setup package file layouts",
+    description="A pluggable command-line frontend, including commands to " + \
+        "setup package file layouts",
     long_description=long_description,
     classifiers=[
       "Development Status :: 5 - Production/Stable",
     [egg_info.writers]
     ignite_plugins.txt = setuptools.command.egg_info:write_arg
     """,
-    install_requires=[
-#      'Paste>=1.3',
-#      'PasteDeploy',
-      ],
+    install_requires=[],
     )

tests/__init__.py

     output_dir = os.path.join(here, 'appsetup', 'output')
     if os.path.exists(output_dir):
         shutil.rmtree(output_dir)
-        
+
 pkg_resources.require('FakePlugin')
-

tests/test_egg_finder.py

 import os
-from paste.script import pluginlib
+from ignite import pluginlib
+
 
 def test_egg_info():
     egg_dir = os.path.join(os.path.dirname(__file__),
     assert found == os.path.join(
         os.path.dirname(os.path.dirname(__file__)),
         'PasteScript.egg-info')
-    
+
+
 def test_resolve_plugins():
     plugins = ['FakePlugin']
     all = pluginlib.resolve_plugins(plugins)
     assert all
     assert len(all) == 2
 
+
 def test_find_commands():
     all = pluginlib.resolve_plugins(['PasteScript', 'FakePlugin'])
     commands = pluginlib.load_commands_from_plugins(all)
     print commands
     assert 'testcom' in commands
-    

tests/test_plugin_adder.py

 
 plugin_file = os.path.join(egg_dir, 'paster_plugins.txt')
 
+
 def plugin_lines():
     if not os.path.exists(plugin_file):
         return []
     f.close()
     return [l.strip() for l in lines if l.strip()]
 
+
 def test_add_remove():
     prev = plugin_lines()
     pluginlib.add_plugin(egg_dir, 'Test')

tests/test_template_introspect.py

 
 tmpl_dir = os.path.join(os.path.dirname(__file__), 'sample_templates')
 
+
 def test_find():
     vars = templates.find_args_in_dir(tmpl_dir, True)
     assert 'a' in vars
     assert 'b' in vars
     assert vars['b'].default == 1
     assert len(vars) == 2
-    
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.