From e88c60e461d8ea07bf720203e26c26cd3561b779 Mon Sep 17 00:00:00 2001 From: Jan-Philipp Litza Date: Tue, 6 May 2014 11:26:47 +0200 Subject: [PATCH] Make genconfig.py compatible to Python 3 --- genconfig.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/genconfig.py b/genconfig.py index b9d4e99..f3275b2 100755 --- a/genconfig.py +++ b/genconfig.py @@ -92,7 +92,7 @@ def create_config(srcdir, fmtclass, exclude=None, filters=[]): domains = [] servers = [] - with file(fpath) as f: + with open(fpath) as f: formatter.add_comment("\n%s\n" % fname) for line in f: if COMMENT_CHAR in line: @@ -142,10 +142,19 @@ if __name__ == "__main__": "v6": lambda option, value: option != "server" or try_inet_pton(AF_INET6, value), } parser = OptionParser() - parser.add_option("-f", "--format", dest="fmt", help="Create config in format FMT. Possible values: %s. Default: dnsmasq" % ", ".join(formatters.keys()), metavar="FMT", choices=formatters.keys(), default="dnsmasq") - parser.add_option("-s", "--sourcedir", dest="src", help="Use files in DIR as input files. Default: data/", metavar="DIR", default="data") - parser.add_option("-x", "--exclude", dest="exclude", help="Exclude the comma-separated list of FILES in the sourcedir from the generation", metavar="FILES", default="") - parser.add_option("--filter", dest="filter", help="Only include certain servers. Possible choices: %s" % ", ".join(filters.keys()), choices=filters.keys()) + parser.add_option("-f", "--format", dest="fmt", + help="Create config in format FMT. Possible values: %s. Default: dnsmasq" % ", ".join(formatters.keys()), metavar="FMT", + choices=list(formatters.keys()), + default="dnsmasq") + parser.add_option("-s", "--sourcedir", dest="src", + help="Use files in DIR as input files. Default: data/", metavar="DIR", + default="data") + parser.add_option("-x", "--exclude", dest="exclude", + help="Exclude the comma-separated list of FILES in the sourcedir from the generation", metavar="FILES", + default="") + parser.add_option("--filter", dest="filter", + help="Only include certain servers. Possible choices: %s" % ", ".join(filters.keys()), + choices=list(filters.keys())) (options, args) = parser.parse_args()