Support files as source for dn2osdbk
The current version only uses directory as source for tranformation. This patch allows to work on a single source file. This is intended to be used to generated the HOT reference data. Change-Id: I574c099c26718e0ca509a492e857c96e7bdc0e15
This commit is contained in:
parent
9b2d94a992
commit
0180dbe580
|
@ -5,6 +5,7 @@ Release notes
|
||||||
----
|
----
|
||||||
|
|
||||||
* ``openstack-doc-test``: Don't always build the HOT guide
|
* ``openstack-doc-test``: Don't always build the HOT guide
|
||||||
|
* ``openstack-dn2osdbk``: Allow single files as source
|
||||||
|
|
||||||
0.17
|
0.17
|
||||||
----
|
----
|
||||||
|
|
|
@ -209,16 +209,23 @@ class ChapterTransformer(BaseFolderTransformer):
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(description="Generate docbook from "
|
parser = argparse.ArgumentParser(description="Generate docbook from "
|
||||||
"DocUtils Native XML format")
|
"DocUtils Native XML format")
|
||||||
parser.add_argument('source', help='Source directory.')
|
parser.add_argument('source', help='Source file or directory.')
|
||||||
parser.add_argument('output', help='Output file.')
|
parser.add_argument('output', help='Output file or directory.')
|
||||||
parser.add_argument('--toplevel', help='Toplevel flag.',
|
parser.add_argument('--toplevel', help='Toplevel flag.',
|
||||||
choices=['book', 'chapter'],
|
choices=['book', 'chapter'],
|
||||||
default='chapter')
|
default='chapter')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
cls = globals()[TRANSFORMERS[args.toplevel]]
|
if os.path.isdir(args.source):
|
||||||
transformer = cls(args.source, args.output)
|
cls = globals()[TRANSFORMERS[args.toplevel]]
|
||||||
sys.exit(transformer.transform())
|
transformer = cls(args.source, args.output)
|
||||||
|
sys.exit(transformer.transform())
|
||||||
|
else:
|
||||||
|
transformer = XMLFileTransformer(args.source, args.toplevel)
|
||||||
|
xml = transformer.transform()
|
||||||
|
with open(args.output, 'w') as fd:
|
||||||
|
fd.write(xml)
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Reference in New Issue