This instance will be upgraded to Heptapod 0.23.2 on 2021-08-05 at 11:00 UTC+2 (a few minutes of down time)

Commit 47fc549d authored by Anton Shestakov's avatar Anton Shestakov
Browse files

test2rst: minor improvements

branch : stable
parent 5affbb44f135
Pipeline #13238 passed with stage
in 5 minutes and 24 seconds
#!/usr/bin/env python3
import argparse
import os
import re
import sys
ignored_patterns = [
......@@ -14,6 +14,7 @@ ignored_patterns = [
def rstify(orig):
"""Take contents of a .t file and produce reStructuredText"""
newlines = []
code_block_mode = False
......@@ -21,7 +22,7 @@ def rstify(orig):
for line in orig.splitlines():
# Emtpy lines doesn't change output
# Empty lines doesn't change output
if not line:
code_block_mode = False
......@@ -59,17 +60,19 @@ def rstify(orig):
return "\n".join(newlines)
def main(path):
with open(path) as f:
def main():
ap = argparse.ArgumentParser()
ap.add_argument('testfile', help='.t file to transform')
opts = ap.parse_args()
with open(opts.testfile) as f:
content =
rst = rstify(content)
target = os.path.splitext(path)[0] + '.rst'
target = os.path.splitext(opts.testfile)[0] + '.rst'
with open(target, 'w') as f:
if __name__ == '__main__':
if len(sys.argv) != 2:
print('Please supply a path to tests dir as parameter')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment