Add more logging with file prefixes

This makes the handoff between gendoc and batesian clearer in the logs.
pull/977/head
Kegan Dougal 9 years ago
parent 064a2c9172
commit f1adad5fb3

@ -253,13 +253,12 @@ def run_through_template(input):
] ]
if VERBOSE: if VERBOSE:
args.insert(2, "-v") args.insert(2, "-v")
log("EXEC: %s" % " ".join(args))
log(" ==== build.py output ==== ") log(" ==== build.py output ==== ")
log( print subprocess.check_output(
subprocess.check_output( args,
args, stderr=out,
stderr=out, cwd="../templating"
cwd="../templating"
)
) )
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
with open(tmpfile, 'r') as f: with open(tmpfile, 'r') as f:

@ -16,7 +16,7 @@ class Sections(object):
def log(self, text): def log(self, text):
if self.debug: if self.debug:
print text print "batesian:sections: %s" % text
def get_sections(self): def get_sections(self):
render_list = inspect.getmembers(self, predicate=inspect.ismethod) render_list = inspect.getmembers(self, predicate=inspect.ismethod)

@ -22,7 +22,7 @@ class Units(object):
def log(self, text): def log(self, text):
if self.debug: if self.debug:
print text print "batesian:units: %s" % text
def get_units(self, debug=False): def get_units(self, debug=False):
unit_list = inspect.getmembers(self, predicate=inspect.ismethod) unit_list = inspect.getmembers(self, predicate=inspect.ismethod)

@ -52,8 +52,8 @@ def create_from_template(template, sections):
def check_unaccessed(name, store): def check_unaccessed(name, store):
unaccessed_keys = store.get_unaccessed_set() unaccessed_keys = store.get_unaccessed_set()
if len(unaccessed_keys) > 0: if len(unaccessed_keys) > 0:
print "Found %s unused %s keys." % (len(unaccessed_keys), name) log("Found %s unused %s keys." % (len(unaccessed_keys), name))
print unaccessed_keys log(unaccessed_keys)
def main(input_module, file_stream=None, out_dir=None, verbose=False): def main(input_module, file_stream=None, out_dir=None, verbose=False):
if out_dir and not os.path.exists(out_dir): if out_dir and not os.path.exists(out_dir):
@ -121,17 +121,19 @@ def main(input_module, file_stream=None, out_dir=None, verbose=False):
return return
# check the input files and substitute in sections where required # check the input files and substitute in sections where required
print "Parsing input template: %s" % file_stream.name log("Parsing input template: %s" % file_stream.name)
temp = Template(file_stream.read()) temp = Template(file_stream.read())
print "Creating output for: %s" % file_stream.name log("Creating output for: %s" % file_stream.name)
output = create_from_template(temp, sections) output = create_from_template(temp, sections)
with open( with open(
os.path.join(out_dir, os.path.basename(file_stream.name)), "w" os.path.join(out_dir, os.path.basename(file_stream.name)), "w"
) as f: ) as f:
f.write(output) f.write(output)
print "Output file for: %s" % file_stream.name log("Output file for: %s" % file_stream.name)
check_unaccessed("units", units) check_unaccessed("units", units)
def log(line):
print "batesian: %s" % line
if __name__ == '__main__': if __name__ == '__main__':
parser = ArgumentParser( parser = ArgumentParser(
@ -175,7 +177,7 @@ if __name__ == '__main__':
sys.exit(0) sys.exit(0)
if not args.file: if not args.file:
print "No file supplied." log("No file supplied.")
parser.print_help() parser.print_help()
sys.exit(1) sys.exit(1)

Loading…
Cancel
Save