|
30 | 30 |
|
31 | 31 | import objdictgen |
32 | 32 | from objdictgen import jsonod |
33 | | -from objdictgen.printing import GetPrintEntry |
| 33 | +from objdictgen.printing import format_node |
34 | 34 | from objdictgen.typing import TDiffEntries, TDiffNodes, TPath |
35 | 35 |
|
36 | 36 | T = TypeVar('T') |
@@ -122,59 +122,6 @@ def _printlines(entries: TDiffEntries): |
122 | 122 | _printlines(diffs[index]) |
123 | 123 |
|
124 | 124 |
|
125 | | -def list_od( |
126 | | - od: "Node", |
127 | | - name: str, |
128 | | - opts: argparse.Namespace) -> Generator[str, None, None]: |
129 | | - """Generator for producing the output for odg list""" |
130 | | - |
131 | | - # Get the indexes to print and determine the order |
132 | | - keys = od.GetAllIndices(sort=opts.sort) |
133 | | - if opts.index: |
134 | | - indexp = [jsonod.str_to_int(i) for i in opts.index] |
135 | | - keys = [k for k in keys if k in indexp] |
136 | | - missing = ", ".join((str(k) for k in indexp if k not in keys)) |
137 | | - if missing: |
138 | | - raise ValueError(f"Unknown index {missing}") |
139 | | - |
140 | | - profiles = [] |
141 | | - if od.DS302: |
142 | | - loaded, equal = jsonod.compare_profile("DS-302", od.DS302) |
143 | | - if equal: |
144 | | - extra = "DS-302 (equal)" |
145 | | - elif loaded: |
146 | | - extra = "DS-302 (not equal)" |
147 | | - else: |
148 | | - extra = "DS-302 (not loaded)" |
149 | | - profiles.append(extra) |
150 | | - |
151 | | - pname = od.ProfileName |
152 | | - if pname and pname != 'None': |
153 | | - loaded, equal = jsonod.compare_profile(pname, od.Profile, od.SpecificMenu) |
154 | | - if equal: |
155 | | - extra = f"{pname} (equal)" |
156 | | - elif loaded: |
157 | | - extra = f"{pname} (not equal)" |
158 | | - else: |
159 | | - extra = f"{pname} (not loaded)" |
160 | | - profiles.append(extra) |
161 | | - |
162 | | - if not opts.compact: |
163 | | - yield f"{Fore.CYAN}File:{Style.RESET_ALL} {name}" |
164 | | - yield f"{Fore.CYAN}Name:{Style.RESET_ALL} {od.Name} [{od.Type.upper()}] {od.Description}" |
165 | | - tp = ", ".join(profiles) or None |
166 | | - yield f"{Fore.CYAN}Profiles:{Style.RESET_ALL} {tp}" |
167 | | - if od.ID: |
168 | | - yield f"{Fore.CYAN}ID:{Style.RESET_ALL} {od.ID}" |
169 | | - yield "" |
170 | | - |
171 | | - # Print the parameters |
172 | | - yield from GetPrintEntry( |
173 | | - od, keys=keys, short=opts.short, compact=opts.compact, unused=opts.unused, |
174 | | - verbose=opts.all, raw=opts.raw |
175 | | - ) |
176 | | - |
177 | | - |
178 | 125 | @debug_wrapper() |
179 | 126 | def main(debugopts: DebugOpts, args: Sequence[str]|None = None): |
180 | 127 | """ Main command dispatcher """ |
@@ -265,6 +212,7 @@ def main(debugopts: DebugOpts, args: Sequence[str]|None = None): |
265 | 212 | subp.add_argument('--raw', action="store_true", help="Show raw parameter values") |
266 | 213 | subp.add_argument('--short', action="store_true", help="Do not list sub-index") |
267 | 214 | subp.add_argument('--unused', action="store_true", help="Include unused profile parameters") |
| 215 | + subp.add_argument('--internal', action="store_true", help="Show internal data") |
268 | 216 | subp.add_argument('-D', '--debug', **opt_debug) # type: ignore[arg-type] |
269 | 217 | subp.add_argument('--no-color', action='store_true', help="Disable colored output") |
270 | 218 |
|
@@ -400,7 +348,7 @@ def main(debugopts: DebugOpts, args: Sequence[str]|None = None): |
400 | 348 | print(Fore.LIGHTBLUE_EX + name + '\n' + "=" * len(name) + Style.RESET_ALL) |
401 | 349 |
|
402 | 350 | od = open_od(name) |
403 | | - for line in list_od(od, name, opts): |
| 351 | + for line in format_node(od, name, index=opts.index, opts=opts): |
404 | 352 | print(line) |
405 | 353 |
|
406 | 354 |
|
|
0 commit comments