Created
June 10, 2020 20:56
-
-
Save pdxjohnny/36b755d3cdda981ae82477e7ad24b0ae to your computer and use it in GitHub Desktop.
DFFML display model config as yaml-ish for `dffml model list`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/dffml/util/cli/cmds.py b/dffml/util/cli/cmds.py | |
index 26227b49..0ccb2c25 100644 | |
--- a/dffml/util/cli/cmds.py | |
+++ b/dffml/util/cli/cmds.py | |
@@ -1,3 +1,4 @@ | |
+import json | |
import inspect | |
from typing import List | |
@@ -9,6 +10,7 @@ from ...base import config, field | |
from .cmd import CMD | |
from ...util.config.fields import FIELD_SOURCES | |
+from ...util.data import export_dict, traverse_get | |
class ListEntrypoint(CMD): | |
@@ -25,6 +27,34 @@ class ListEntrypoint(CMD): | |
print(cls.__doc__.rstrip()) | |
else: | |
print("%s" % (cls.__qualname__)) | |
+ print( | |
+ "\n".join( | |
+ filter( | |
+ lambda x: x.strip(), | |
+ json.dumps( | |
+ export_dict( | |
+ **traverse_get( | |
+ cls.args({}), | |
+ *cls.ENTRY_POINT_NAME, | |
+ "config", | |
+ cls.ENTRY_POINT_ORIG_LABEL, | |
+ "config", | |
+ ) | |
+ ), | |
+ sort_keys=True, | |
+ indent=2, | |
+ ) | |
+ .replace("{", "") | |
+ .replace("}", "") | |
+ .replace("]", "") | |
+ .replace("[", "") | |
+ .replace('"', "") | |
+ .replace(",", "") | |
+ .replace("plugin: null", "") | |
+ .split("\n"), | |
+ ) | |
+ ) | |
+ ) | |
print() | |
async def run(self): |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment