[install-guide/f21-branch] Make sure that the tail of the element is not lost
by pbokoc
commit 37166d00d72f959978f37a045c9b741ff3af606a
Author: Martin Kolman <mkolman(a)redhat.com>
Date: Thu Nov 6 19:29:08 2014 +0100
Make sure that the tail of the element is not lost
Signed-off-by: Martin Kolman <mkolman(a)redhat.com>
prepare_anaconda_help_content.py | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
---
diff --git a/prepare_anaconda_help_content.py b/prepare_anaconda_help_content.py
old mode 100755
new mode 100644
index 0609912..91ea7e6
--- a/prepare_anaconda_help_content.py
+++ b/prepare_anaconda_help_content.py
@@ -131,6 +131,7 @@ for path, tree in xml_files.items():
new_element = ET.Element("ulink")
new_element.attrib["url"] = filename
new_element.text = title
+ new_element.tail = xref.tail
# replace the old link element with the new one
xref.getparent().replace(xref, new_element)
else:
@@ -141,7 +142,11 @@ for path, tree in xml_files.items():
# lxml doesn't seem to be able to replace an element with a string,
# so we will just clear the element and replace it with the templates
# in a later sed pas :P
+ tail = xref.tail
+ # clear() removes the tail, which is in this case pretty much unrelated
+ # to the element, so we need to make sure to save & restore it
xref.clear()
+ xref.tail = tail
outside_links += 1
rewritten_links += 1
else:
9 years, 7 months
[install-guide/f21-branch] Add a script for generating anaconda help content
by pbokoc
commit dd22ed3565303d2f6c1e3873fe9a1888897b1d6f
Author: Martin Kolman <mkolman(a)redhat.com>
Date: Thu Nov 6 18:42:03 2014 +0100
Add a script for generating anaconda help content
After the script is run Anaconda help content will be stored in
the anaconda_help_content folder.
Signed-off-by: Martin Kolman <mkolman(a)redhat.com>
prepare_anaconda_help_content.py | 173 ++++++++++++++++++++++++++++++++++++++
1 files changed, 173 insertions(+), 0 deletions(-)
---
diff --git a/prepare_anaconda_help_content.py b/prepare_anaconda_help_content.py
new file mode 100755
index 0000000..0609912
--- /dev/null
+++ b/prepare_anaconda_help_content.py
@@ -0,0 +1,173 @@
+#!/usr/bin/python
+#
+# Process the Installation Guide to a format suitable for use as built-in-help in Anaconda
+import os
+import shutil
+import glob
+import subprocess
+# we are using lxml as unlike in the Python built-in ElementTree elements
+# in the lxml tree know their parents - this is handy when removing the figure tags
+from lxml import etree as ET
+
+INPUT_FOLDER = "en-US"
+OUTPUT_FOLDER = "anaconda_help_content/en-US"
+
+# list of the XML help content & supporting files Anaconda currently cares about
+ANACONDA_HELP_FILES = [
+ "DateTimeSpoke.xml",
+ "KeyboardSpoke.xml",
+ "SourceSpoke.xml",
+ "FilterSpoke.xml",
+ "PasswordSpoke.xml",
+ "StorageSpoke.xml",
+ "WelcomeSpoke.xml",
+ "SummaryHub.xml",
+ "Installation_Guide.xml",
+ "Installation_Guide.ent",
+ "LangSupportSpoke.xml",
+ "CustomSpoke.xml",
+ "NetworkSpoke.xml",
+ "SoftwareSpoke.xml",
+ "UserSpoke.xml"
+]
+
+def run_xmllint():
+ for path in glob.glob(os.path.join(OUTPUT_FOLDER, "*.xml")):
+ try:
+ temp_file_path = "%s.temp" % path
+ # xmllint outputs to stdout, so we catch the output to a temporary
+ # file and then overwrite the original with the temporary file once
+ # xmllint is done
+ temp_file = open(temp_file_path, "w")
+ subprocess.check_call(["xmllint", "--noent", path], stdout=temp_file)
+ temp_file.close()
+ shutil.move(temp_file_path, path)
+ except subprocess.CalledProcessError:
+ print("WARNING: running xmllint on %s failed" % path)
+
+# does the input folder exist ?
+if not os.path.isdir(INPUT_FOLDER):
+ print("ERROR: input folder does not exists")
+ exit(1)
+
+# make sure that the output folder is empty
+if os.path.exists(OUTPUT_FOLDER):
+ # if it already exists, delete it
+ shutil.rmtree(OUTPUT_FOLDER)
+os.makedirs(OUTPUT_FOLDER)
+
+print("copying relevant help content files")
+for file_name in ANACONDA_HELP_FILES:
+ origin = os.path.join(INPUT_FOLDER, file_name)
+ destination = os.path.join(OUTPUT_FOLDER, file_name)
+ if not os.path.isfile(origin):
+ print("WARNING: required file %s is missing" % origin)
+ shutil.copy(origin, destination)
+
+print("removing non breakable spaces")
+for path in glob.glob(os.path.join(OUTPUT_FOLDER, "*.xml")):
+ os.system("sed 's/ / /g' -i %s %s" % (path, path))
+
+# run xmllint to resolve entities
+print("running xmllint to resolve entities")
+run_xmllint()
+
+print("loading all XML files")
+
+xml_files = {}
+known_ids = {}
+
+for path in glob.glob(os.path.join(OUTPUT_FOLDER, "*.xml")):
+ print("loading: %s" % path)
+ try:
+ tree = ET.parse(path)
+ root = tree.getroot()
+ # find all elements that have an id attribute
+ for element in root.iter():
+ id = element.attrib.get("id")
+ # the element has an id attribute
+ if id:
+ title = element.find('title')
+ if hasattr(title, "text"):
+ # store the tile text and filename under the id
+ filename = os.path.split(path)[1]
+ known_ids[id] = (filename, title.text)
+ else:
+ # some title elements might not have any text property
+ print("WARNING: id %s in %s has no title text" % (id, path))
+
+ xml_files[path] = tree
+ except ET.ParseError as err:
+ print("WARNING: parsing failed:\n%s" % err)
+
+print("%d XML files loaded" % len(xml_files))
+print("%d ids found" % len(known_ids))
+
+# remove pictures/figures
+removed_figures = 0
+removed_remarks = 0
+rewritten_links = 0
+outside_links = 0
+print("removing figure & remark tags, rewriting links")
+for path, tree in xml_files.items():
+ root = tree.getroot()
+
+ for figure in root.findall('.//figure'):
+ parent = figure.getparent()
+ parent.remove(figure)
+ removed_figures += 1
+
+ for remark in root.findall('.//remark'):
+ parent = remark.getparent()
+ parent.remove(remark)
+ removed_remarks += 1
+
+ # rewrite all links to a format digestible by Yelp
+ for xref in root.findall('.//xref'):
+ link_target = xref.attrib.get('linkend')
+ if link_target:
+ if link_target in known_ids:
+ filename, title = known_ids[link_target]
+ new_element = ET.Element("ulink")
+ new_element.attrib["url"] = filename
+ new_element.text = title
+ # replace the old link element with the new one
+ xref.getparent().replace(xref, new_element)
+ else:
+ # this link points outside of the help files currently
+ # used by Anaconda, so replace it with "find it somewhere else"
+ # template
+ print("INFO: outside link, id: %s in %s" % (link_target, path))
+ # lxml doesn't seem to be able to replace an element with a string,
+ # so we will just clear the element and replace it with the templates
+ # in a later sed pas :P
+ xref.clear()
+ outside_links += 1
+ rewritten_links += 1
+ else:
+ print("WARNING: %s has a xref link with missing linkend" % path)
+
+print("%d figures and %d remarks have been removed" % (removed_figures, removed_remarks))
+print("%d links have been rewritten, %d were outside links" % (rewritten_links, outside_links))
+
+# write the modified XMLs to disk
+print("saving modified XMLs to storage")
+for path, tree in xml_files.items():
+ tree.write(path)
+
+# replate the oustide links here with sed as lxml is not able to do that for us
+print("removing obsolete <xref/> tags")
+template = "the full <citetitle>\&PRODUCT\; Installation Guide<\/citetitle>, available at \&IGURL\;"
+for path in glob.glob(os.path.join(OUTPUT_FOLDER, "*.xml")):
+ os.system("sed 's/<xref\/>/%s/g' -i %s %s" % (template, path, path))
+
+# resolve any newly added entities
+print("running xmllint to resolve any newly added entities")
+run_xmllint()
+
+# remove the entity file, it is no longer needed
+print("removing the entity file")
+os.remove(os.path.join(OUTPUT_FOLDER, "Installation_Guide.ent"))
+
+print("done!")
+exit(0)
9 years, 7 months
[install-guide] (3 commits) ...Better BZURL entity def
by pbokoc
Summary of changes:
f3e172e... Adding an xref to the Welcome Spoke (*)
3b00e1a... Updating gitignore (*)
856b161... Better BZURL entity def (*)
(*) This commit already existed in another branch; no separate mail sent
9 years, 7 months
[install-guide/f21-branch] Updating gitignore
by pbokoc
commit 3b00e1afc3a552f56ee3546779fea2946b1fc8ae
Author: Petr Bokoc <pbokoc(a)redhat.com>
Date: Thu Nov 6 18:38:05 2014 +0100
Updating gitignore
.gitignore | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index a9acd77..786675c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,5 @@
-en-US/images/storagedevices/.directory
publish/**/*
tmp/**/*
-en-US/.directory
en-US/*.xml~
en-US/*.xml#
en-US/*.ent~
@@ -9,3 +7,4 @@ en-US/*.ent~
pot/*.pot~
*.cfg~
*.swp
+anaconda_help_content/
9 years, 7 months
[install-guide/f21-branch] Adding an xref to the Welcome Spoke
by pbokoc
commit f3e172e1e4ff4da6151477c7cef59aaf6469fa0b
Author: Petr Bokoc <pbokoc(a)redhat.com>
Date: Thu Nov 6 18:37:09 2014 +0100
Adding an xref to the Welcome Spoke
en-US/WelcomeSpoke.xml | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/en-US/WelcomeSpoke.xml b/en-US/WelcomeSpoke.xml
index 97388bb..363435f 100644
--- a/en-US/WelcomeSpoke.xml
+++ b/en-US/WelcomeSpoke.xml
@@ -21,7 +21,7 @@
One language is pre-selected by default on top of the list. If network access is configured at this point (for example, if you booted from a network server instead of local media), the pre-selected language will be determined based on automatic location detection using the GeoIP module. Alternatively, if you used the <option>inst.lang=</option> option on the boot command line or in your PXE server configuration, this language will be selected by default, but you will still be able to change it.
</para>
<para>
- After you select your language and locale, click <guilabel>Continue</guilabel> to confirm your selection and proceed to the main installation menu.
+ After you select your language and locale, click <guilabel>Continue</guilabel> to confirm your selection and proceed to <xref linkend="sect-installation-gui-installation-summary" />.
</para>
<note>
<para>
9 years, 7 months
[install-guide/f21-branch] (4 commits) ...Adding IGURL to entity defs
by pbokoc
Summary of changes:
1bba0bf... Small adjustments in Language Support (*)
732e032... Cleaning up references to comps.xml in Kickstart %packages (*)
5076b43... Adding Software Spoke (*)
83a7786... Adding IGURL to entity defs (*)
(*) This commit already existed in another branch; no separate mail sent
9 years, 7 months