def _create_xul_app(self, path, id, **kwargs):

        # Dict with all values that are injected in the file templates
        # All values can be overriden via kwargs
        D = dict(vendor='None',
                 name='flexx_ui_app',
                 version='1.0',
                 buildid='1',
                 id='some.app@flexx.io',
                 windowid='xx',
                 title='XUL app runtime',
                 url='http://example.com',
                 windowfeatures='', )
        D.update(kwargs)

        # Create values that need to be unique
        D['windowid'] = 'W' + id
        D['name'] = 'app_' + id
        D['id'] = 'app_' + id + '@flexx.io'

        # Fill in arguments in file contents
        manifest_link = 'manifest chrome/chrome.manifest'
        manifest = 'content {name} content/'.format(**D)
        application_ini = APPLICATION_INI.format(**D)
        main_xul = MAIN_XUL.format(**D)
        main_js = MAIN_JS  # No format (also problematic due to braces)
        prefs_js = PREFS_JS.format(**D)

        # Clear
        if op.isdir(path):
            shutil.rmtree(path)

        # Create directory structure
        for subdir in ('',
                       'chrome', 'chrome/content',
                       'chrome/icons', 'chrome/icons/default',
                       'defaults', 'defaults/preferences',
                       ):
            os.mkdir(op.join(path, subdir))

        # Create files
        for fname, text in [('chrome.manifest', manifest_link),
                            ('chrome/chrome.manifest', manifest),
                            ('application.ini', application_ini),
                            ('defaults/preferences/prefs.js', prefs_js),
                            ('chrome/content/main.js', main_js),
                            ('chrome/content/main.xul', main_xul),
                            ]:
            with open(op.join(path, fname), 'wb') as f:
                f.write(text.encode())

        # Icon - use Icon class to write a png (Unix) and an ico (Windows)
        # The launch function ensures that there always is an icon
        if kwargs.get('icon'):
            icon = kwargs.get('icon')
            icon_name = op.join(path, 'chrome/icons/default/' + D['windowid'])
            icon.write(icon_name + '.ico')
            icon.write(icon_name + '.png')
Create the files that determine the XUL app to launch.
dataset/ETHPy150Open zoofIO/flexx/flexx/webruntime/xul.py/XulRuntime._create_xul_app