aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/sanity/005examples/extract_vhdl.py
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/sanity/005examples/extract_vhdl.py')
-rw-r--r--testsuite/sanity/005examples/extract_vhdl.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/testsuite/sanity/005examples/extract_vhdl.py b/testsuite/sanity/005examples/extract_vhdl.py
new file mode 100644
index 000000000..fa2243caa
--- /dev/null
+++ b/testsuite/sanity/005examples/extract_vhdl.py
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+import sys
+
+def extract(out):
+ # Skip until the first line
+ while (1):
+ l = sys.stdin.readline()
+ if l == '':
+ return False
+ if l == '.. code-block:: VHDL\n':
+ break
+
+ # Write example
+ while (1):
+ l = sys.stdin.readline()
+ if l[0] == '\n':
+ out.write(l)
+ elif len(l) >= 2 and l[:2] == ' ':
+ out.write(l[2:])
+ else:
+ break
+
+ return True
+
+for f in sys.argv[1:]:
+ print("Extracting {}...".format(f))
+ with open(f, "w") as out:
+ if not extract(out):
+ sys.exit(1)
+sys.exit(0)