+ if os.path.isdir(full_fname):
+ continue
+
+ if fname.endswith('.conf'):
+ parse_config(bnf, regs, full_fname)
+
+def parse_all_configs(configs):
+ regs = {}
+
+ # set up the bnf to be used for each file
+ lbrack = Literal("[").suppress()
+ rbrack = Literal("]").suppress()
+ colon = Literal(":").suppress()
+ semi = Literal(";")
+
+ comment = semi + Optional(restOfLine)
+
+ nonrbrack = "".join([c for c in printables if c != "]"]) + " \t"
+ noncolon = "".join([c for c in printables if c != ":"]) + " \t"
+
+ sectionDef = lbrack + Word(nonrbrack) + rbrack
+ keyDef = ~lbrack + Word(noncolon) + colon + restOfLine
+
+ bnf = Dict(ZeroOrMore(Group(sectionDef + ZeroOrMore(Group(keyDef)))))
+ bnf.ignore(comment)
+
+ # bundle into a single var that can be passed to os.path.walk
+ conf_data = (bnf, regs)
+
+ for conf in configs:
+ if not os.path.exists(conf):
+ continue
+ if os.path.isdir(conf):
+ os.path.walk(conf, parse_config_dir, conf_data)
+ else:
+ parse_config(bnf, regs, conf)
+ return regs