<s> import argparse <EOL> import os <EOL> import sys <EOL> import jinja2 <EOL> from jinja2 import Template <EOL> import editors <EOL> PROJECT_PATH = os . path . join ( os . path . abspath ( os . path . dirname ( __file__ ) ) ) <EOL> TEMPLATE_PATH = os . path . join ( PROJECT_PATH , '<STR_LIT>' ) <EOL> JINJA_ENVIRONMENT = jinja2 . Environment ( <EOL> loader = jinja2 . FileSystemLoader ( TEMPLATE_PATH ) , <EOL> extensions = [ '<STR_LIT>' ] , <EOL> autoescape = True ) <EOL> def generate ( editor , selected_langs ) : <EOL> assert selected_langs , "<STR_LIT>" <EOL> ctx = { "<STR_LIT>" : { } , "<STR_LIT>" : { } , "<STR_LIT>" : editor } <EOL> for l in selected_langs : <EOL> for ext in [ "<STR_LIT>" , "<STR_LIT>" ] : <EOL> with open ( "<STR_LIT>" . format ( l , ext ) ) as f : <EOL> ctx [ ext ] [ l ] = f . read ( ) <EOL> template = None <EOL> with open ( "<STR_LIT>" ) as f : <EOL> template = Template ( f . read ( ) . decode ( '<STR_LIT:utf-8>' ) ) <EOL> if not template : <EOL> template = Template ( "<STR_LIT>" ) <EOL> ctx [ '<STR_LIT>' ] = "<STR_LIT:U+002C>" . join ( selected_langs ) <EOL> def sh_exist ( lang ) : <EOL> return os . path . isfile ( "<STR_LIT>" . format ( lang ) ) <EOL> ctx [ '<STR_LIT>' ] = sh_exist <EOL> print template . render ( ** ctx ) . encode ( '<STR_LIT:utf-8>' ) <EOL> def main ( ) : <EOL> parser = argparse . ArgumentParser ( description = "<STR_LIT>" ) <EOL> parser . add_argument ( "<STR_LIT>" , type = str , <EOL> choices = editors . EDITORS . keys ( ) , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( "<STR_LIT>" , "<STR_LIT>" , type = str , required = True , <EOL> help = "<STR_LIT>" ) <EOL> args = parser . parse_args ( ) <EOL> editor = editors . get_editor ( args . editor ) <EOL> langs = args . langs . split ( '<STR_LIT:U+002C>' ) <EOL> generate ( editor , langs ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
