def list_verbose(): """List templates verbosely, with full help.""" textwrapper = TextWrapper( initial_indent=" ", subsequent_indent=" ") cats = list_sorted_templates() for title, items in cats.items(): print "\n"+ title print "-" * len(title) for temp in items: print "\n%s: %s\n" % (temp['name'], temp['summary']) if temp['help']: wrap_help_paras(textwrapper, temp['help']) print
def generate_dotzopeskel(): """Make an example .zopeskel file for user.""" cats = list_sorted_templates() print """ # This file can contain preferences for zopeskel. # To do so, uncomment the lines that look like: # variable_name = Default Value [DEFAULT] """ for temp in sum(cats.values(), []): print "\n[%(name)s]\n" % temp tempc = temp['entry'].load() for var in tempc.vars: if hasattr(var, 'pretty_description'): print "# %s" % var.pretty_description() print "# %s = %s\n" % ( var.name, var.default )
def list_printable_templates(): """ Printable list of all templates, sorted into two categories. """ s = StringIO() cats = list_sorted_templates() templates = sum(cats.values(), []) # flatten into single list max_name = max([len(x['name']) for x in templates]) for title, items in cats.items(): print >>s, "\n%s\n" % title for entry in items: print >>s, "| %s:%s %s\n" % ( entry['name'], ' '*(max_name-len(entry['name'])), entry['summary']), s.seek(0) return s.read()
def test_script_features(self): """Verify that the help features of the script function correctly""" oldargv = sys.argv # --help produces the DESCRIPTION string sys.argv = ['zopeskel', '--help'] output = run() self.failUnless(DESCRIPTION in output, '--help produces incorrect output: %s' % output) # --list produces a verbose list of all templates by category sys.argv = ['zopeskel', '--list'] output = run() cats = list_sorted_templates() catnames = cats.keys() templates = sum(cats.values(), []) tempnames = [t['name'] for t in templates] tempsums = [t['summary'] for t in templates] for cat in catnames: self.failUnless(cat in output, '%s not in --list output' % cat) for tname in tempnames: self.failUnless(tname in output, '%s not in --list output' % tname) for summary in tempsums: self.failUnless(summary in output, '%s not in --list output' % summary) # --make-config-file produces a config file with headings for each template sys.argv = ['zopeskel', '--make-config-file'] output = run() for theading in ['[' + name + ']' for name in tempnames]: self.failUnless(theading in output, '%s does not appear in .zopeskel' % theading) # --version should output a version number. make sure it finds something sys.argv = ['zopeskel', '--version'] output = run() self.failIf('unable' in output) sys.argv = oldargv