Commit e15f2620 authored by Victor Poughon's avatar Victor Poughon
Browse files

DOC: sort examples by tag and fix data handling

parent 70da6c02
......@@ -33,7 +33,7 @@ blacklist = [
"LAIAndPROSAILToSensorResponse" # does not run, wrong arguments
def run_example(otb_root, otb_data, name, dry_run):
def run_example(otb_root, name, dry_run):
Run an example by name
Assumes the current working directory is an OTB build
......@@ -71,6 +71,7 @@ def run_example(otb_root, otb_data, name, dry_run):
print("$ " + binary + " " + " ".join(example_args))
if not dry_run:
otb_data = join(otb_root, "Data")
# Make sure Output dir exists
os.makedirs(join(otb_data, "Output"), exist_ok=True)
......@@ -81,19 +82,18 @@ def run_example(otb_root, otb_data, name, dry_run):
def main():
parser = argparse.ArgumentParser(usage="Run one or all OTB cxx examples")
parser.add_argument("otb_root", help="Path to otb repository")
parser.add_argument("otb_data", help="Path to otb-data repository")
parser.add_argument("--name", type=str, help="Run only one example with then given name")
parser.add_argument("-n", "--dry-run", action='store_true', help="Dry run, only print commands")
parser.add_argument("-k", "--keep-going", action='store_true', help="Keep going after failing examples")
args = parser.parse_args()
run_example(args.otb_root, args.otb_data,, dry_run=args.dry_run)
run_example(args.otb_root,, dry_run=args.dry_run)
list_of_examples =[os.path.splitext(os.path.basename(f))[0] for f in glob.glob(join(args.otb_root, "Examples/*/*.cxx"))]
for name in list_of_examples:
run_example(args.otb_root, args.otb_data, name, dry_run=args.dry_run)
run_example(args.otb_root, name, dry_run=args.dry_run)
except Exception as e:
if args.keep_going:
print("Warning:", e)
......@@ -44,7 +44,7 @@ def generate_examples_index(rst_dir, list_of_examples):
index_f = open(join(rst_dir, "Examples.rst"), "w")
index_f.write(RstPageHeading("C++ Examples", 3, ref="cpp-examples"))
for tag, examples_filenames in tag_files.items():
for tag, examples_filenames in sorted(tag_files.items()):
tag_filename = join("Examples", tag + ".rst")
index_f.write("\t" + tag_filename + "\n")
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