bin/preprocess.py
def main():
    '''
    Main driver for regenerating _config.yml for web site.
    This program also creates _includes/recent_blog_posts.html.
    '''

    # Get the standard stuff.
    options, args = parse_args()

    # Load other information.
    config = load_info(options.config_dir, STANDARD_YML)

    # Insert standing values into configuration.
    config.update({
        'month_names'     : MONTHS,
        'months'          : sorted(MONTHS.keys()),
        'site'            : options.site,
        'timestamp'       : time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime()),
        'today'           : options.today
    })

    # Load cached dashboard info.  Do this early to avoid wasting time
    # on everything else if it's not available.
    config['dashboard'] = load_cached_info(os.curdir, DASHBOARD_CACHE, 'dashboard cache')

    # Fetch information from AMY.
    config['badges'] = fetch_info(options.amy_url, BADGES_URL)
    config['airports'] = fetch_info(options.amy_url, AIRPORTS_URL)
    config['workshops'] = fetch_info(options.amy_url, WORKSHOPS_URL)

    # Lower-case and coalesce national flags.
    for a in config['airports']:
        a['country'] = a['country'].lower()
    for w in config['workshops']:
        w['country'] = w['country'].lower()
    config['flags'] = {
        'workshops': sorted({w['country'] for w in config['workshops'] if w['country']}),
        'airports': sorted({a['country'] for a in config['airports'] if a['country']})
    }

    # Select workshops that will be displayed on the home page (soonest first).
    workshops_upcoming = [w for w in config['workshops'] if w['start'] >= config['today']]
    workshops_upcoming.reverse()
    config['workshops_upcoming'] = workshops_upcoming
    config['workshops_upcoming_short'] = workshops_upcoming[ :config['upcoming_length'] ]

    # Load people and projects.
    config['people'] = list(map(lambda x: os.path.relpath(x, '_includes'),
                                sorted(glob.glob('_includes/people/*.html'))))
    config['projects'] = list(map(lambda x: os.path.relpath(x, '_includes'),
                                  sorted(glob.glob('_includes/projects/*.html'))))

    # Get information from blog entries.
    config['blog'] = harvest_blog(config)

    # Sanity checks on blog posts.
    check_blog_sanity(config['blog'])

    # Select those that'll be displayed on the home page, the index page, etc.
    config['blog_recent'] = config['blog'][ -config['recent_length']: ]
    config['blog_recent'].reverse()

    # Create _includes/recent_blog_posts.html for inclusion in blog index page.
    # This is done programmatically because we want snippets to be rendered properly.
    for post in config['blog_recent']:
        post['excerpt'] = get_blog_excerpt(post['path'])
    write_recent_blog_posts(config['blog_recent'])

    # Organize all posts by year and month.
    blog_lookup, blog_count = organize_blog_entries(config['blog'])
    config['blog_lookup'] = blog_lookup
    config['blog_count'] = blog_count
    config['blog_years'] = sorted(blog_lookup.keys())
    config['blog_years'].reverse()

    # Construct list of favorite blog posts.
    config['blog_favorites'] = [p for p in config['blog'] if p['favorite']]
    config['blog_favorites'].reverse()

    # Save.
    with open(CONFIG_YML, 'w') as writer:
        yaml.dump(config, writer, encoding='utf-8', allow_unicode=True)

    Main driver for regenerating _config.yml for web site.
    This program also creates _includes/recent_blog_posts.html.
    
Main driver for regenerating _config.yml for web site.
This program also creates _includes/recent_blog_posts.html.
Main driver for regenerating _config . yml for web site . This program also creates _includes / recent_blog_posts . html .
def main():
    options, args = parse_args()
    config = load_info(options.config_dir, STANDARD_YML)
    config.update({
        'month_names'     : MONTHS,
        'months'          : sorted(MONTHS.keys()),
        'site'            : options.site,
        'timestamp'       : time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime()),
        'today'           : options.today
    })
    config['dashboard'] = load_cached_info(os.curdir, DASHBOARD_CACHE, 'dashboard cache')
    config['badges'] = fetch_info(options.amy_url, BADGES_URL)
    config['airports'] = fetch_info(options.amy_url, AIRPORTS_URL)
    config['workshops'] = fetch_info(options.amy_url, WORKSHOPS_URL)
    for a in config['airports']:
        a['country'] = a['country'].lower()
    for w in config['workshops']:
        w['country'] = w['country'].lower()
    config['flags'] = {
        'workshops': sorted({w['country'] for w in config['workshops'] if w['country']}),
        'airports': sorted({a['country'] for a in config['airports'] if a['country']})
    }
    workshops_upcoming = [w for w in config['workshops'] if w['start'] >= config['today']]
    workshops_upcoming.reverse()
    config['workshops_upcoming'] = workshops_upcoming
    config['workshops_upcoming_short'] = workshops_upcoming[ :config['upcoming_length'] ]
    config['people'] = list(map(lambda x: os.path.relpath(x, '_includes'),
                                sorted(glob.glob('_includes/people/*.html'))))
    config['projects'] = list(map(lambda x: os.path.relpath(x, '_includes'),
                                  sorted(glob.glob('_includes/projects/*.html'))))
    config['blog'] = harvest_blog(config)
    check_blog_sanity(config['blog'])
    config['blog_recent'] = config['blog'][ -config['recent_length']: ]
    config['blog_recent'].reverse()
    for post in config['blog_recent']:
        post['excerpt'] = get_blog_excerpt(post['path'])
    write_recent_blog_posts(config['blog_recent'])
    blog_lookup, blog_count = organize_blog_entries(config['blog'])
    config['blog_lookup'] = blog_lookup
    config['blog_count'] = blog_count
    config['blog_years'] = sorted(blog_lookup.keys())
    config['blog_years'].reverse()
    config['blog_favorites'] = [p for p in config['blog'] if p['favorite']]
    config['blog_favorites'].reverse()
    with open(CONFIG_YML, 'w') as writer:
        yaml.dump(config, writer, encoding='utf-8', allow_unicode=True)
def main ( ) : options , args = parse_args ( ) config = load_info ( options . config_dir , STANDARD_YML ) config . update ( { 'month_names' : MONTHS , 'months' : sorted ( MONTHS . keys ( ) ) , 'site' : options . site , 'timestamp' : time . strftime ( '%Y-%m-%dT%H:%M:%SZ' , time . gmtime ( ) ) , 'today' : options . today } ) config [ 'dashboard' ] = load_cached_info ( os . curdir , DASHBOARD_CACHE , 'dashboard cache' ) config [ 'badges' ] = fetch_info ( options . amy_url , BADGES_URL ) config [ 'airports' ] = fetch_info ( options . amy_url , AIRPORTS_URL ) config [ 'workshops' ] = fetch_info ( options . amy_url , WORKSHOPS_URL ) for a in config [ 'airports' ] : a [ 'country' ] = a [ 'country' ] . lower ( ) for w in config [ 'workshops' ] : w [ 'country' ] = w [ 'country' ] . lower ( ) config [ 'flags' ] = { 'workshops' : sorted ( { w [ 'country' ] for w in config [ 'workshops' ] if w [ 'country' ] } ) , 'airports' : sorted ( { a [ 'country' ] for a in config [ 'airports' ] if a [ 'country' ] } ) } workshops_upcoming = [ w for w in config [ 'workshops' ] if w [ 'start' ] >= config [ 'today' ] ] workshops_upcoming . reverse ( ) config [ 'workshops_upcoming' ] = workshops_upcoming config [ 'workshops_upcoming_short' ] = workshops_upcoming [ : config [ 'upcoming_length' ] ] config [ 'people' ] = list ( map ( lambda x : os . path . relpath ( x , '_includes' ) , sorted ( glob . glob ( '_includes/people/*.html' ) ) ) ) config [ 'projects' ] = list ( map ( lambda x : os . path . relpath ( x , '_includes' ) , sorted ( glob . glob ( '_includes/projects/*.html' ) ) ) ) config [ 'blog' ] = harvest_blog ( config ) check_blog_sanity ( config [ 'blog' ] ) config [ 'blog_recent' ] = config [ 'blog' ] [ - config [ 'recent_length' ] : ] config [ 'blog_recent' ] . reverse ( ) for post in config [ 'blog_recent' ] : post [ 'excerpt' ] = get_blog_excerpt ( post [ 'path' ] ) write_recent_blog_posts ( config [ 'blog_recent' ] ) blog_lookup , blog_count = organize_blog_entries ( config [ 'blog' ] ) config [ 'blog_lookup' ] = blog_lookup config [ 'blog_count' ] = blog_count config [ 'blog_years' ] = sorted ( blog_lookup . keys ( ) ) config [ 'blog_years' ] . reverse ( ) config [ 'blog_favorites' ] = [ p for p in config [ 'blog' ] if p [ 'favorite' ] ] config [ 'blog_favorites' ] . reverse ( ) with open ( CONFIG_YML , 'w' ) as writer : yaml . dump ( config , writer , encoding = 'utf-8' , allow_unicode = True )
Main driver for regenerating _config.yml for web site.
Main driver for regenerating _config . yml for web site .
'''
    Main driver for regenerating _config.yml for web site.
    This program also creates _includes/recent_blog_posts.html.
    ''' # Get the standard stuff. # Load other information. # Insert standing values into configuration. # Load cached dashboard info.  Do this early to avoid wasting time # on everything else if it's not available. # Fetch information from AMY. # Lower-case and coalesce national flags. # Select workshops that will be displayed on the home page (soonest first). # Load people and projects. # Get information from blog entries. # Sanity checks on blog posts. # Select those that'll be displayed on the home page, the index page, etc. # Create _includes/recent_blog_posts.html for inclusion in blog index page. # This is done programmatically because we want snippets to be rendered properly. # Organize all posts by year and month. # Construct list of favorite blog posts. # Save.