def create_infomodel_homepage(root, repo_cluster, standard): """Creates the homepage of an information model and copies to correct location e.g. https://register.geostandaarden.nl/brt/top10nl/index.html """ artifacts = get_artifacts(root, build_path, sources_path, standard) html = webpages.create_standard_webpage(standard, artifacts, assets_path) # copy homepage to register/standard exists if part of cluster if repo_cluster == "": if root.exists(ospath.join(build_path, register_path, standard['id'])) == False: root.makedir(ospath.join(build_path, register_path, standard['id'])) # write standard HTML page to register/standard/index.html with codecs.open(ospath.join(root.getsyspath('.'), build_path, register_path, standard['id'], 'index.html'), 'w', encoding='utf8') as f: f.write(html) else: # check whether register/cluster/exists if root.exists(ospath.join(build_path, register_path, repo_cluster)) == False: root.makedir(ospath.join(build_path, register_path, repo_cluster)) # check whether register/cluster/standard exists if root.exists(ospath.join(build_path, register_path, repo_cluster, standard['id'])) == False: root.makedir(ospath.join(build_path, register_path, repo_cluster, standard['id'])) # write standard HTML page to register/cluster/standard/index.html with codecs.open(ospath.join(build_path, register_path, repo_cluster, standard['id'], 'index.html'), 'w', encoding='utf8') as f: f.write(html) # copy web assets # root.copydir(ospath.join(assets_path, 'web', 'assets'), ospath.join(build_path, register_path, 'r'), overwrite=True) call('cp -r %s %s' % (ospath.join(assets_path, 'web', 'assets'), ospath.join(root.getsyspath('.'), build_path, register_path, 'r')), shell=True)
def build_folders(standard, root, repo_cluster): """Transforms a repo's folder structure to that of the register Copies infomodel/artifact/assets to artifact/infomodel/assets """ artifacts = get_artifacts(root, build_path, sources_path, standard) for artifact in artifacts: # check whether artifact folder exists in destination_temp if (root.exists(ospath.join(build_path, register_path, artifact))) == False: root.makedir(ospath.join(build_path, register_path, artifact), recursive=True) # copy standard folders from source to destination_temp in desired structure root.copydir(ospath.join(build_path, sources_path, standard['id'], artifact), ospath.join(build_path, register_path, artifact, standard['id']))
def create_infomodel_homepage(root, sources_path, assets_path, build_path, destination_temp, repo_cluster, standard): """Creates the homepage of an information model and copies to correct location e.g. http://register.geostandaarden.nl/brt/top10nl/index.html """ artifacts = get_artifacts(root, build_path, sources_path, standard) html = webpages.create_standard_webpage(standard, artifacts, assets_path) # copy homepage to register/standard exists if part of cluster if repo_cluster == "": if root.exists(ospath.join(build_path, destination_temp, standard["id"])) == False: root.makedir(ospath.join(build_path, destination_temp, standard["id"])) # write standard HTML page to register/standard/index.html with codecs.open( ospath.join(root.getsyspath("."), build_path, destination_temp, standard["id"], "index.html"), "w", encoding="utf8", ) as f: f.write(html) else: # check whether register/cluster/exists if root.exists(ospath.join(build_path, destination_temp, repo_cluster)) == False: root.makedir(ospath.join(build_path, destination_temp, repo_cluster)) # check whether register/cluster/standard exists if root.exists(ospath.join(build_path, destination_temp, repo_cluster, standard["id"])) == False: root.makedir(ospath.join(build_path, destination_temp, repo_cluster, standard["id"])) # write standard HTML page to register/cluster/standard/index.html with codecs.open( ospath.join(build_path, destination_temp, repo_cluster, standard["id"], "index.html"), "w", encoding="utf8" ) as f: f.write(html) # copy web assets # root.copydir(ospath.join(assets_path, 'web', 'assets'), ospath.join(build_path, destination_temp, 'r'), overwrite=True) call( "cp -r %s %s" % ( ospath.join(assets_path, "web", "assets"), ospath.join(root.getsyspath("."), build_path, destination_temp, "r"), ), shell=True, )