def create_xml_file(project_name, module, file_name, template): directory = get_module_directory(module) file_path = "{}/layouts/{}.xml".format(directory, file_name) with open(file_path, 'w+') as java_file: template_output = Template(template).render(lower_project_name=lowercase_first_letter(project_name), upper_project_name=uppercase_first_letter(project_name), lower_module_name=lowercase_first_letter(module.name), upper_module_name=uppercase_first_letter(module.name)) java_file.write(template_output)
def create_view_controllers(module): directory = "{}/ViewControllers".format(module_directory(module)) for view in module.views: file_path = "{}/{}{}ViewController.swift".format( directory, uppercase_first_letter(module.name), uppercase_first_letter(view)) with open(file_path, 'w+') as view_controller_file: template = Template(ios_templates.view_controller_template) view_controller_file.write( template.render(upper_name=uppercase_first_letter(module.name), upper_view=uppercase_first_letter(view)))
def create_android_fragments(project_name, module): for view in module.views: directory = get_module_directory(module) file_path = "{}/{}Fragment.java".format(directory, view) with open(file_path, 'w+') as java_file: template_output = Template(android_templates.fragment).render( lower_project_name=lowercase_first_letter(project_name), lower_module_name=lowercase_first_letter(module.name), upper_module_name=uppercase_first_letter(module.name), upper_fragment_name=uppercase_first_letter(view)) java_file.write(template_output) create_xml_file(project_name=project_name, module=module, file_name="fragment_{}".format(lowercase_first_letter(view)), template=android_templates.fragment_xml)
def create_ios_module_file(module, file_name, template): directory = module_directory(module) file_path = "{}/{}.swift".format(directory, file_name) with open(file_path, 'w+') as swift_file: template_output = Template(template).render( upper_name=uppercase_first_letter(module.name), lower_name=lowercase_first_letter(module.name), upper_views=uppercase_views(module.views)) swift_file.write(template_output)
def create_android_activity(project_name, module): create_java_file(project_name=project_name, module=module, file_name="{}Activity".format(uppercase_first_letter(module.name)), template=android_templates.activity) create_xml_file(project_name=project_name, module=module, file_name="activity_{}".format(lowercase_first_letter(module.name)), template=android_templates.fragment_xml) create_xml_file(project_name=project_name, module=module, file_name="{}_activity_update_for_android_manifest".format(lowercase_first_letter(module.name)), template=android_templates.update_android_manifest_xml)
def create_android_interactor(project_name, module): create_java_file(project_name=project_name, module=module, file_name="{}Interactor".format(uppercase_first_letter(module.name)), template=android_templates.interactor)
def create_android_presenter(project_name, module): create_java_file(project_name=project_name, module=module, file_name="{}Presenter".format(uppercase_first_letter(module.name)), template=android_templates.presenter)
def create_android_component(project_name, module): create_java_file(project_name=project_name, module=module, file_name="{}Component".format(uppercase_first_letter(module.name)), template=android_templates.component)
def create_wireframe(module): create_ios_module_file( module, "{}Wireframe".format(uppercase_first_letter(module.name)), ios_templates.wireframe)
def create_ios_interactor(module): create_ios_module_file( module, "{}Interactor".format(uppercase_first_letter(module.name)), ios_templates.interactor)
def create_ios_presenter(module): create_ios_module_file( module, "{}Presenter".format(uppercase_first_letter(module.name)), ios_templates.presenter)