def main():
    if len(sys.argv) == 2 and sys.argv[1] == 'inputs':
        print(in_file)
        return
    if len(sys.argv) == 2 and sys.argv[1] == 'outputs':
        print(out_file)
        return

    with open(in_file) as fin:
        layout = json.loads(fin.read())

    # Read the layouts from the json file and determine alignment of widgets (as they can refer to
    # other widgets.
    overlay_widgets = {}
    for widget_properties in layout['widgets']:
        widget = OverlayWidget(widget_properties)
        overlay_widgets[widget.name] = widget
        set_alignment_flags(widget, overlay_widgets)

    # Go over the widgets again and generate initialization code.  Note that we need to iterate over
    # the widgets in order, so we can't use the overlay_widgets dictionary for iteration.
    init_widgets = []
    for widget_properties in layout['widgets']:
        init_widgets.append(generate_widget_init(overlay_widgets[widget_properties['name']]))

    with open(out_file, 'w') as outfile:
        outfile.write(
            template_out_file.format(
                script_name=__file__,
                copyright_year=date.today().year,
                input_file_name=in_file,
                out_file_name=out_file,
                init_widgets='\n'.join(init_widgets)))
        outfile.close()