generate.py
def main():
    """Parse command line arguments and process actions."""
    # Parse the command line arguments
    parser = argparse.ArgumentParser(
        description='Generates HTML, LaTeX, and Markdown resumes from data in '
        'YAML files.')
    parser.add_argument(
        'yamls', metavar='YAML_FILE', nargs='+',
        help='the YAML files that contain the resume details, in order of '
             'increasing precedence')
    parser.add_argument(
        '-p', '--preview', action='store_true',
        help='prints generated resumes to stdout instead of writing to file')
    parser.add_argument('-b', '--publications', metavar='YAML_FILE',
                        help='YAML file with publications info')
    group = parser.add_mutually_exclusive_group()
    group.add_argument('-t', '--html', action='store_true',
                       help='only generate HTML resume')
    group.add_argument('-l', '--latex', action='store_true',
                       help='only generate LaTeX resume')
    group.add_argument('-m', '--markdown', action='store_true',
                       help='only generate Markdown resume')
    group.add_argument('-x', '--text', action='store_true',
                       help='only generate text resume')
    args = parser.parse_args()

    yaml_data = {}
    for yaml_file in args.yamls:
        with open(yaml_file) as f:
            yaml_data.update(yaml.load(f))

    # Sub into the publications section as its items, if they don't exist
    if args.publications:
        with open(args.publications) as f:
            pubs = yaml.load(f)

        for s in yaml_data['sections']:
            if 'type' in s and s['type'] == 'publications' and 'items' not in s:
                s['items'] = pubs
                break

    # Remove the publications section if it exists and has no items
    yaml_data['sections'] = [
        s for s in yaml_data['sections']
        if 'type' not in s or s['type'] != 'publications' or 'items' in s]

    if args.html or args.latex or args.markdown or args.text:
        if args.html:
            process_resume(HTML_CONTEXT, yaml_data, args.preview)
        elif args.latex:
            process_resume(LATEX_CONTEXT, yaml_data, args.preview)
        elif args.markdown:
            process_resume(MARKDOWN_CONTEXT, yaml_data, args.preview)
        elif args.text:
            process_resume(TEXT_CONTEXT, yaml_data, args.preview)
    else:
        process_resume(HTML_CONTEXT, yaml_data, args.preview)
        process_resume(LATEX_CONTEXT, yaml_data, args.preview)
        process_resume(MARKDOWN_CONTEXT, yaml_data, args.preview)
        process_resume(TEXT_CONTEXT, yaml_data, args.preview)
Parse command line arguments and process actions.
Parse command line arguments and process actions.
Parse command line arguments and process actions .
def main():
    parser = argparse.ArgumentParser(
        description='Generates HTML, LaTeX, and Markdown resumes from data in '
        'YAML files.')
    parser.add_argument(
        'yamls', metavar='YAML_FILE', nargs='+',
        help='the YAML files that contain the resume details, in order of '
             'increasing precedence')
    parser.add_argument(
        '-p', '--preview', action='store_true',
        help='prints generated resumes to stdout instead of writing to file')
    parser.add_argument('-b', '--publications', metavar='YAML_FILE',
                        help='YAML file with publications info')
    group = parser.add_mutually_exclusive_group()
    group.add_argument('-t', '--html', action='store_true',
                       help='only generate HTML resume')
    group.add_argument('-l', '--latex', action='store_true',
                       help='only generate LaTeX resume')
    group.add_argument('-m', '--markdown', action='store_true',
                       help='only generate Markdown resume')
    group.add_argument('-x', '--text', action='store_true',
                       help='only generate text resume')
    args = parser.parse_args()
    yaml_data = {}
    for yaml_file in args.yamls:
        with open(yaml_file) as f:
            yaml_data.update(yaml.load(f))
    if args.publications:
        with open(args.publications) as f:
            pubs = yaml.load(f)
        for s in yaml_data['sections']:
            if 'type' in s and s['type'] == 'publications' and 'items' not in s:
                s['items'] = pubs
                break
    yaml_data['sections'] = [
        s for s in yaml_data['sections']
        if 'type' not in s or s['type'] != 'publications' or 'items' in s]
    if args.html or args.latex or args.markdown or args.text:
        if args.html:
            process_resume(HTML_CONTEXT, yaml_data, args.preview)
        elif args.latex:
            process_resume(LATEX_CONTEXT, yaml_data, args.preview)
        elif args.markdown:
            process_resume(MARKDOWN_CONTEXT, yaml_data, args.preview)
        elif args.text:
            process_resume(TEXT_CONTEXT, yaml_data, args.preview)
    else:
        process_resume(HTML_CONTEXT, yaml_data, args.preview)
        process_resume(LATEX_CONTEXT, yaml_data, args.preview)
        process_resume(MARKDOWN_CONTEXT, yaml_data, args.preview)
        process_resume(TEXT_CONTEXT, yaml_data, args.preview)
def main ( ) : parser = argparse . ArgumentParser ( description = 'Generates HTML, LaTeX, and Markdown resumes from data in ' 'YAML files.' ) parser . add_argument ( 'yamls' , metavar = 'YAML_FILE' , nargs = '+' , help = 'the YAML files that contain the resume details, in order of ' 'increasing precedence' ) parser . add_argument ( '-p' , '--preview' , action = 'store_true' , help = 'prints generated resumes to stdout instead of writing to file' ) parser . add_argument ( '-b' , '--publications' , metavar = 'YAML_FILE' , help = 'YAML file with publications info' ) group = parser . add_mutually_exclusive_group ( ) group . add_argument ( '-t' , '--html' , action = 'store_true' , help = 'only generate HTML resume' ) group . add_argument ( '-l' , '--latex' , action = 'store_true' , help = 'only generate LaTeX resume' ) group . add_argument ( '-m' , '--markdown' , action = 'store_true' , help = 'only generate Markdown resume' ) group . add_argument ( '-x' , '--text' , action = 'store_true' , help = 'only generate text resume' ) args = parser . parse_args ( ) yaml_data = { } for yaml_file in args . yamls : with open ( yaml_file ) as f : yaml_data . update ( yaml . load ( f ) ) if args . publications : with open ( args . publications ) as f : pubs = yaml . load ( f ) for s in yaml_data [ 'sections' ] : if 'type' in s and s [ 'type' ] == 'publications' and 'items' not in s : s [ 'items' ] = pubs break yaml_data [ 'sections' ] = [ s for s in yaml_data [ 'sections' ] if 'type' not in s or s [ 'type' ] != 'publications' or 'items' in s ] if args . html or args . latex or args . markdown or args . text : if args . html : process_resume ( HTML_CONTEXT , yaml_data , args . preview ) elif args . latex : process_resume ( LATEX_CONTEXT , yaml_data , args . preview ) elif args . markdown : process_resume ( MARKDOWN_CONTEXT , yaml_data , args . preview ) elif args . text : process_resume ( TEXT_CONTEXT , yaml_data , args . preview ) else : process_resume ( HTML_CONTEXT , yaml_data , args . preview ) process_resume ( LATEX_CONTEXT , yaml_data , args . preview ) process_resume ( MARKDOWN_CONTEXT , yaml_data , args . preview ) process_resume ( TEXT_CONTEXT , yaml_data , args . preview )
Parse command line arguments and process actions.
Parse command line arguments and process actions .
"""Parse command line arguments and process actions.""" # Parse the command line arguments # Sub into the publications section as its items, if they don't exist # Remove the publications section if it exists and has no items