def create_table(name, author, ToolConf): xml = getInstallXmlFromRoot() tree = xmlParser.parse(xml) root = tree.getroot() comp_name = root.find('name').text comp_ver = root.find('version').text admin_dir = root.find('administration/files').get('folder') vars_dict = dict(name=name.lower(), \ name_cap=name.capitalize(), \ component_name=comp_name.lower(), \ component_name_cap=comp_name.capitalize(), \ component_name_upper=comp_name.upper(), \ version=comp_ver, \ author_name=author.name, \ author_email=author.email, \ author_url=author.url, \ author_license=author.license, \ author_copyright=author.copyright) src_dir = os.path.abspath(os.path.join(ToolConf['mvc'],'table')) dst_dir = os.path.abspath(os.path.join(os.curdir,admin_dir,'tables')) for t_file in os.listdir(src_dir): file_path = os.path.abspath(os.path.join(src_dir,t_file)) do_rewrite = check_do_rewrite(os.path.join(dst_dir, utils.remake_string(t_file, vars_dict))) if not do_rewrite: sys.exit() try: shutil.copy(file_path, dst_dir) except Exception as e: print(e) utils.remake_dir(dst_dir, vars_dict)
def create_component(name, author, description, ToolConf): vars_dict = dict(creation_date=datetime.date.today(), \ component_name=name.lower(), \ component_name_cap=name.capitalize(), \ component_name_upper=name.upper(), \ author_name=author.name, \ author_email=author.email, \ author_url=author.url, \ author_license=author.license, \ author_copyright=author.copyright, \ component_desc=description) src_dir = os.path.join(ToolConf['templates'],'component') dst_dir = os.path.abspath(os.path.join(os.curdir,'com_'+name)) try: shutil.copytree(src_dir, dst_dir) except Exception as e: print(e) os.chdir(dst_dir) utils.remake_dir(os.curdir, vars_dict)