<s> """<STR_LIT>""" <EOL> import os <EOL> import jinja2 <EOL> TEMPLATE_DIR = os . path . join ( os . path . dirname ( __file__ ) , '<STR_LIT>' ) <EOL> _DEFAULT_UI_TEMPLATES = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> _PYTHON_ZAPP_YAML = '<STR_LIT>' <EOL> _PYTHON_ZAPP_WITH_UI_YAML = '<STR_LIT>' <EOL> _PYTHON_TOX_INI_TEMPLATE = """<STR_LIT>""" <EOL> _DEFAULT_TEMPLATE = '<STR_LIT>' <EOL> def template ( location , template , with_ui ) : <EOL> return _TEMPLATES . get ( template , _DEFAULT_TEMPLATE ) ( <EOL> location , with_ui = with_ui <EOL> ) <EOL> def render_zapp_yaml ( name , template_name = _PYTHON_ZAPP_YAML ) : <EOL> """<STR_LIT>""" <EOL> loader = jinja2 . PackageLoader ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> env = jinja2 . Environment ( loader = loader ) <EOL> tmpl = env . get_template ( template_name ) <EOL> return tmpl . render ( name = name ) <EOL> def _create_basic_proj_files ( location , with_ui = False ) : <EOL> """<STR_LIT>""" <EOL> if with_ui : <EOL> zapp_template = _PYTHON_ZAPP_WITH_UI_YAML <EOL> else : <EOL> zapp_template = _PYTHON_ZAPP_YAML <EOL> name = os . path . basename ( os . path . abspath ( location ) ) <EOL> yield ( '<STR_LIT:file>' , os . path . join ( location , '<STR_LIT>' ) , <EOL> render_zapp_yaml ( name , template_name = zapp_template ) ) <EOL> if with_ui : <EOL> for template in _DEFAULT_UI_TEMPLATES : <EOL> src_path = os . path . join ( TEMPLATE_DIR , template ) <EOL> dest_path = os . path . join ( location , template ) <EOL> with open ( src_path ) as fp : <EOL> yield ( '<STR_LIT:file>' , dest_path , fp . read ( ) ) <EOL> def python_template ( location , with_ui = False ) : <EOL> for triple in _create_basic_proj_files ( location , with_ui = with_ui ) : <EOL> yield triple <EOL> dot_zapp_dir = os . path . join ( location , '<STR_LIT>' ) <EOL> yield ( '<STR_LIT>' , dot_zapp_dir , None ) <EOL> tox_ini_path = os . path . join ( dot_zapp_dir , '<STR_LIT>' ) <EOL> yield ( '<STR_LIT:file>' , tox_ini_path , _PYTHON_TOX_INI_TEMPLATE ) <EOL> _TEMPLATES = { <EOL> '<STR_LIT>' : python_template , <EOL> } </s>
