def build_folders(source, destination_temp, standards, root): print "Building register..." source_fs = OSFS(source) # iterate over all standards in source directory for standard in standards: print "Processing %s ... " % standard['id'] standard_fs = source_fs.opendir(standard['id']) # list all sub standards of a standard artifacts = standard_fs.listdir(dirs_only=True) if '.git' in artifacts: artifacts.remove(".git") for artifact in artifacts: # check whether artifact folder exists in destination_temp if root.exists('%s/%s' % (destination_temp, artifact)) == False: root.makedir('%s/%s' % (destination_temp, artifact)) # copy standard folders from source to destination_temp in desired structure root.copydir('%s/%s/%s' % (source, standard['id'], artifact), '%s/%s/%s' % (destination_temp, artifact, standard['id'])) # create standard HTML page html = create_standard_webpage(standard, artifacts) # check whether standard folder exists in register root if root.exists('%s/%s' % (destination_temp, standard['id'])) == False: root.makedir('%s/%s' % (destination_temp, standard['id'])) # write standard HTML page to register/standard/index.html with codecs.open('%s/%s/index.html' % (destination_temp, standard['id']), 'w', encoding='utf8') as f: f.write(html)
def build_folders(source, destination_temp, standard, root): """Transform the repos' folder structure to that of the register and build HTML pages for each standard. """ source_fs = OSFS(source) print "Processing %s ... " % standard['id'] standard_fs = source_fs.opendir(standard['id']) # list all artifacts of a standard artifacts = standard_fs.listdir(dirs_only=True) if '.git' in artifacts: artifacts.remove(".git") for artifact in artifacts: # check whether artifact folder exists in destination_temp if root.exists('%s/%s' % (destination_temp, artifact)) == False: root.makedir('%s/%s' % (destination_temp, artifact)) # copy standard folders from source to destination_temp in desired structure root.copydir('%s/%s/%s' % (source, standard['id'], artifact), '%s/%s/%s' % (destination_temp, artifact, standard['id'])) html = create_standard_webpage(standard, artifacts) # check whether register/standard exists if root.exists('%s/%s' % (destination_temp, standard['id'])) == False: root.makedir('%s/%s' % (destination_temp, standard['id'])) # write standard HTML page to register/standard/index.html with codecs.open('%s/%s/index.html' % (destination_temp, standard['id']), 'w', encoding='utf8') as f: f.write(html) # copy web assets root.copydir('web/assets', '%s/r' % destination_temp, overwrite=True)
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, )