casadi-reader 0.2.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ """Read CasADi files without installing or loading CasADi."""
2
+
3
+ from .reader import LazyBlob, loads, loads_resource, read_casadi, read_resource, to_json
4
+
5
+ __all__ = ["LazyBlob", "loads", "loads_resource", "read_casadi", "read_resource", "to_json"]
@@ -0,0 +1,25 @@
1
+ import argparse
2
+ from pathlib import Path
3
+ from . import read_casadi, read_resource, to_json
4
+
5
+
6
+ def main():
7
+ parser = argparse.ArgumentParser(description="Inspect CasADi files without CasADi")
8
+ parser.add_argument("input", type=Path)
9
+ parser.add_argument("output", type=Path, nargs="?")
10
+ parser.add_argument("--lazy", action="store_true")
11
+ parser.add_argument("--resource", action="store_true", help="Read a raw Resource stream")
12
+ args = parser.parse_args()
13
+ try:
14
+ read = read_resource if args.resource else read_casadi
15
+ text = to_json(read(args.input, lazy=args.lazy), indent=2) + "\n"
16
+ if args.output:
17
+ args.output.write_text(text)
18
+ else:
19
+ print(text, end="")
20
+ except (OSError, ValueError) as error:
21
+ parser.exit(1, str(error) + "\n")
22
+
23
+
24
+ if __name__ == "__main__":
25
+ main()