WIP lookup commands
This commit is contained in:
parent
38796bf1f2
commit
e534212cf1
16
odoo-rpc.py
16
odoo-rpc.py
|
@ -9,9 +9,12 @@ import os
|
|||
import sys
|
||||
import json
|
||||
import odoorpc # pip install odoorpc
|
||||
#from typing import Iterable # > py38
|
||||
from collections import Iterable # < py38
|
||||
|
||||
from renderers import render, tsv
|
||||
|
||||
|
||||
def eprint(*args, **kwargs):
|
||||
print(*args, file=sys.stderr, **kwargs)
|
||||
|
||||
|
@ -50,6 +53,17 @@ eprint( MODEL_IGNORE )
|
|||
|
||||
|
||||
|
||||
|
||||
def flatten(items):
|
||||
"""Yield items from any nested iterable; see Reference."""
|
||||
for x in items:
|
||||
if isinstance(x, Iterable) and not isinstance(x, (str, bytes)):
|
||||
for sub_x in flatten(x):
|
||||
yield sub_x
|
||||
else:
|
||||
yield x
|
||||
|
||||
|
||||
def jlog( obj ):
|
||||
print( json.dumps(obj, indent=4) ) #"\t") )
|
||||
|
||||
|
@ -338,7 +352,7 @@ def flatten_stack( data ):
|
|||
if type(data[key]) in [list,dict]:
|
||||
flat += flatten_stack(data[key])
|
||||
|
||||
return flat
|
||||
return list(flatten(flat))
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue