conf: print is a function in Python 3

This commit is contained in:
Tobias Brunner
2014-05-13 11:14:43 +02:00
parent 60633a995f
commit 5ee4984da5
+13 -13
View File
@@ -230,32 +230,32 @@ class ConfFormatter:
if len(opt.desc): if len(opt.desc):
self.__wrapper.initial_indent = '{0}# '.format(self.__indent * indent) self.__wrapper.initial_indent = '{0}# '.format(self.__indent * indent)
self.__wrapper.subsequent_indent = self.__wrapper.initial_indent self.__wrapper.subsequent_indent = self.__wrapper.initial_indent
print format(self.__wrapper.fill(self.__tags.replace(opt.desc[0]))) print(self.__wrapper.fill(self.__tags.replace(opt.desc[0])))
def __print_option(self, opt, indent, commented): def __print_option(self, opt, indent, commented):
"""Print a single option with description and default value""" """Print a single option with description and default value"""
comment = "# " if commented or opt.commented else "" comment = "# " if commented or opt.commented else ""
self.__print_description(opt, indent) self.__print_description(opt, indent)
if opt.default: if opt.default:
print '{0}{1}{2} = {3}'.format(self.__indent * indent, comment, opt.name, opt.default) print('{0}{1}{2} = {3}'.format(self.__indent * indent, comment, opt.name, opt.default))
else: else:
print '{0}{1}{2} ='.format(self.__indent * indent, comment, opt.name) print('{0}{1}{2} ='.format(self.__indent * indent, comment, opt.name))
print print('')
def __print_section(self, section, indent, commented): def __print_section(self, section, indent, commented):
"""Print a section with all options""" """Print a section with all options"""
commented = commented or section.commented commented = commented or section.commented
comment = "# " if commented else "" comment = "# " if commented else ""
self.__print_description(section, indent) self.__print_description(section, indent)
print '{0}{1}{2} {{'.format(self.__indent * indent, comment, section.name) print('{0}{1}{2} {{'.format(self.__indent * indent, comment, section.name))
print print('')
for o in sorted(section.options, key=attrgetter('section')): for o in sorted(section.options, key=attrgetter('section')):
if o.section: if o.section:
self.__print_section(o, indent + 1, commented) self.__print_section(o, indent + 1, commented)
else: else:
self.__print_option(o, indent + 1, commented) self.__print_option(o, indent + 1, commented)
print '{0}{1}}}'.format(self.__indent * indent, comment) print('{0}{1}}}'.format(self.__indent * indent, comment))
print print('')
def format(self, options): def format(self, options):
"""Print a list of options""" """Print a list of options"""
@@ -286,14 +286,14 @@ class ManFormatter:
if option.section and not len(option.desc): if option.section and not len(option.desc):
return return
if option.section: if option.section:
print '.TP\n.B {0}\n.br'.format(option.fullname) print('.TP\n.B {0}\n.br'.format(option.fullname))
else: else:
print '.TP' print('.TP')
default = option.default if option.default else '' default = option.default if option.default else ''
print '.BR {0} " [{1}]"'.format(option.fullname, default) print('.BR {0} " [{1}]"'.format(option.fullname, default))
for para in option.desc if len(option.desc) < 2 else option.desc[1:]: for para in option.desc if len(option.desc) < 2 else option.desc[1:]:
print self.__groffize(self.__wrapper.fill(para)) print(self.__groffize(self.__wrapper.fill(para)))
print '' print('')
def format(self, options): def format(self, options):
"""Print a list of options""" """Print a list of options"""