-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a small python script that combines a xml-skeleton and the plai…
…n-xml-django-template (with handling < and > replacement)
- Loading branch information
1 parent
ddfee18
commit 79820eb
Showing
3 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{% load view_tags %} | ||
{% get_set 'project/dataset' as datasets %} | ||
|
||
<head> | ||
{% get_value 'project/title' as title %} | ||
<title>{{ title.value }}</title> | ||
<h1>{% render_value 'project/title' %}</h1> | ||
|
||
<div class="alert alert-info" role="alert"> | ||
<p><b>Hinweis</b></p> | ||
<i><p>Im Folgenden haben wir die von Ihnen eingegebenen Informationen über das | ||
Projekt noch einmal zusammengefasst.</p> | ||
<p>Bitte beachten Sie, dass diese Ansicht nochmals überprüft und bei Bedarf | ||
überarbeitet werden sollte.</p></i> | ||
</div> | ||
|
||
<hr noshade color=rgb(0, 157, 129) width=100% size=20> | ||
</head> | ||
|
||
|
||
<body> | ||
<h1>Umgang mit Forschungsdaten</h1> | ||
<h2>Datenbeschreibung</h2> | ||
|
||
{% comment "question" %} | ||
<h3>Auf welche Weise entstehen in Ihrem Projekt neue Daten?</h3> | ||
{% endcomment %} | ||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<rdmo xmlns:dc="http://purl.org/dc/elements/1.1/" created="2024-03-12T15:06:45.930126+01:00" | ||
version="2.0.0"> | ||
<view dc:uri="https://rdmorganiser.github.io/terms/views/templaterenderer"> | ||
<uri_prefix>https://rdmorganiser.github.io/terms</uri_prefix> | ||
<uri_path>templaterenderer</uri_path> | ||
<dc:comment>Entwurf für den DFG-Checkliste-Katalog der RDMO-AG. **Nicht** kompatibel mit dem | ||
DFG-Checkliste-Katalog von Fodako.</dc:comment> | ||
<order>0</order> | ||
<title lang="en">templaterenderer-view</title> | ||
<help lang="en">templaterenderer-view</help> | ||
<title lang="de">templaterenderer-view</title> | ||
<help lang="de">templaterenderer-view</help> | ||
<title lang="fr">templaterenderer-view</title> | ||
<help lang="fr">templaterenderer-view</help> | ||
<title lang="it">templaterenderer-view</title> | ||
<help lang="it">templaterenderer-view</help> | ||
<title lang="es">templaterenderer-view</title> | ||
<help lang="es">templaterenderer-view</help> | ||
<catalogs/> | ||
<template> | ||
</template> | ||
</view> | ||
</rdmo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import glob | ||
import os | ||
|
||
import xml.etree.ElementTree as ET | ||
|
||
files = list(zip( | ||
glob.glob(os.path.join(os.path.dirname(__file__), 'templaterenderer-djangotemplates', '*.django')), | ||
glob.glob(os.path.join(os.path.dirname(__file__), 'templaterenderer-djangotemplates', '*.xmlskeleton')) | ||
)) | ||
for template, headerfile in files: | ||
print('# Working on file pair:') | ||
print(' ' + os.path.abspath(template)) | ||
print(' ' + os.path.abspath(headerfile)) | ||
with open(template, 'r', encoding='utf-8') as open_template: | ||
escaped_template = open_template.read().replace('<','<').replace('>','>') | ||
with open(headerfile, 'r', encoding='utf-8') as open_header: | ||
header_content = open_header.read() | ||
try: | ||
header_start=header_content.rsplit('<template>',1)[0] | ||
header_end=header_content.rsplit('</template>',1)[1] | ||
except IndexError: | ||
print('# The files do not hold a template-section. We try the next one.\n') | ||
continue | ||
outfile_path = os.path.join(os.getcwd(), 'rdmorganiser/views', os.path.basename(template).rsplit('.',1)[0] + '.xml') | ||
with open( | ||
outfile_path, | ||
'w', | ||
encoding='utf-8' | ||
) as xmloutput: | ||
xmloutput.write( | ||
header_start + '<template>\n' + escaped_template + '\n </template>' + header_end | ||
) | ||
print('# Template-file written: {}\n'.format(outfile_path)) |