示例#1
0
    def list_verbose(self):
        """list available templates and their help text
        """
        textwrapper = TextWrapper(
            initial_indent="   ", subsequent_indent="   ")
        cats = list_sorted_templates(scope=self.allowed_packages)
        if cats:
            for title, items in cats.items():
                print "\n"+ title
                print "-" * len(title)
                # Hard-coded for now, since 'add' is the only one
                if title == 'Local Commands':
                    print '\nadd: Allows the addition of further templates'\
                          ' from the following list'
                    print '     to an existing package\n'
                    print '\nLocal Templates'
                    print '-----------------'
                for temp in items:
                    print "\n%s: %s\n" % (temp['name'], temp['summary'])
                    if temp['help']:
                        wrap_help_paras(textwrapper, temp['help'])
            print
        else:
            print self.texts['not_here_warning']

        return 0
示例#2
0
    def _list_printable_templates(self):
        """
        Printable list of all templates, sorted into categories.
        """
        s = StringIO()
        cats = list_sorted_templates(scope=self.allowed_packages)
        if cats:
            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
                # Hard-coded for now, since 'add' is the only one
                if title == 'Local Commands':
                    print >>s, "|  add: Allows the addition of further"\
                          " templates from the following list"
                    print >>s, "        to an existing package\n"
                for entry in items:
                    print >>s, "|  %s:%s %s\n" % (
                         entry['name'],
                        ' '*(max_name-len(entry['name'])),
                        entry['summary']),
        else:
            print >>s, self.texts['not_here_warning']

        s.seek(0)
        return s.read()
示例#3
0
    def test_generate_dotfile(self):
        """Verify that the help features of the script function correctly"""
        cats = list_sorted_templates()
        templates = sum(cats.values(), [])
        tempnames = [t['name'] for t in templates]

        # --make-config-file produces a config file with headings for each
        # template
        output = run('--make-config-file')
        for theading in ['[' + name + ']' for name in tempnames]:
            self.assertTrue(theading in output,
                            '%s does not appear in .templer' % theading)
示例#4
0
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
示例#5
0
    def generate_dotfile(self):
        """generate a dotfile to hold default values
        """

        cats = list_sorted_templates(scope=self.allowed_packages)
        print self.texts['dotfile_header'] % {'script_name': self.name}
        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)
        return 0
示例#6
0
 def test_list_verbose(self):
     output = run('--list')
     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.assertTrue(cat in output, '%s not in --list output' % cat)
     for tname in tempnames:
         self.assertTrue(tname in output, '%s not in --list output' % tname)
     for summary in tempsums:
         self.assertTrue(summary in output,
                         '%s not in --list output' % summary)
示例#7
0
 def _list_printable_templates(self):
     """
     Printable list of all templates, sorted into 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()
示例#8
0
    def generate_dotfile(self):
        """generate a dotfile to hold default values

        method must exit by raising error or calling sys.exit
        """

        cats = list_sorted_templates()
        print self.texts["dotfile_header"] % {"script_name": self.name}
        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)
        sys.exit(0)
示例#9
0
    def generate_dotfile(self):
        """generate a dotfile to hold default values

        method must exit by raising error or calling sys.exit
        """

        cats = list_sorted_templates()
        print self.texts['dotfile_header'] % {'script_name': self.name}
        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)
        sys.exit(0)
示例#10
0
    def list_verbose(self):
        """list available templates and their help text

        method must exit by raising error or calling sys.exit
        """
        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
        sys.exit(0)
示例#11
0
 def _list_printable_templates(self):
     """
     Printable list of all templates, sorted into 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()
示例#12
0
    def test_generate_dotfile(self):
        """Verify that the help features of the script function correctly"""
        oldargv = sys.argv

        cats = list_sorted_templates()
        catnames = cats.keys()
        templates = sum(cats.values(), [])
        tempnames = [t["name"] for t in templates]

        # --make-config-file produces a config file with headings for each
        # template
        sys.argv = ["templer", "--make-config-file"]
        output = run()
        for theading in ["[" + name + "]" for name in tempnames]:
            self.assertTrue(theading in output, "%s does not appear in .templer" % theading)

        sys.argv = oldargv
示例#13
0
    def test_generate_dotfile(self):
        """Verify that the help features of the script function correctly"""
        oldargv = sys.argv

        cats = list_sorted_templates()
        catnames = cats.keys()
        templates = sum(cats.values(), [])
        tempnames = [t['name'] for t in templates]

        # --make-config-file produces a config file with headings for each
        # template
        sys.argv = ['templer', '--make-config-file']
        output = run()
        for theading in ['[' + name + ']' for name in tempnames]:
            self.assertTrue(theading in output,
                            '%s does not appear in .templer' % theading)

        sys.argv = oldargv
示例#14
0
    def list_verbose(self):
        """list available templates and their help text

        method must exit by raising error or calling sys.exit
        """
        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
        sys.exit(0)
示例#15
0
    def test_list_verbose(self):
        oldargv = sys.argv

        sys.argv = ["templer", "--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.assertTrue(cat in output, "%s not in --list output" % cat)
        for tname in tempnames:
            self.assertTrue(tname in output, "%s not in --list output" % tname)
        for summary in tempsums:
            self.assertTrue(summary in output, "%s not in --list output" % summary)

        sys.argv = oldargv
示例#16
0
    def test_list_verbose(self):
        oldargv = sys.argv

        sys.argv = ['templer', '--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.assertTrue(cat in output, '%s not in --list output' % cat)
        for tname in tempnames:
            self.assertTrue(tname in output, '%s not in --list output' % tname)
        for summary in tempsums:
            self.assertTrue(summary in output,
                            '%s not in --list output' % summary)

        sys.argv = oldargv
示例#17
0
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)
示例#18
0
    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 = ['templer', '--help']
        output = run()
        self.assertTrue(DESCRIPTION in output,
                        '--help produces incorrect output: %s' % output)

        # --list produces a verbose list of all templates by category
        sys.argv = ['templer', '--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.assertTrue(cat in output, '%s not in --list output' % cat)
        for tname in tempnames:
            self.assertTrue(tname in output, '%s not in --list output' % tname)
        for summary in tempsums:
            self.assertTrue(summary in output,
                            '%s not in --list output' % summary)

        # --make-config-file produces a config file with headings for each
        # template
        sys.argv = ['templer', '--make-config-file']
        output = run()
        for theading in ['[' + name + ']' for name in tempnames]:
            self.assertTrue(theading in output,
                            '%s does not appear in .templer' % theading)

        # --version should output a version number.  make sure it finds
        # something
        sys.argv = ['templer', '--version']
        output = run()
        self.assertFalse('unable' in output)

        sys.argv = oldargv
示例#19
0
    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.assertTrue(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.assertTrue(cat in output, '%s not in --list output' % cat)
        for tname in tempnames:
            self.assertTrue(tname in output, '%s not in --list output' % tname)
        for summary in tempsums:
            self.assertTrue(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.assertTrue(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.assertFalse('unable' in output)

        sys.argv = oldargv