def _tabulate(result, **kwargs): version_map = [] version_base = [ ('atom', 'meta/versions/atom'), ('firmware', 'meta/versions/sensor'), ] version_option = kwargs.pop('versions', 'none') if version_option == 'fw': version_map = version_base elif version_option == 'all': def _map_script_versions(json): versions = dpath.values(json, 'meta/versions/sensor-script/*/version') return '\n'.join([v for v in versions if not v.startswith('ffffffff')]) version_map = version_base + [ ('libary', 'meta/versions/sensor-library'), ('config', 'meta/versions/sensor-config'), ('script', _map_script_versions) ] def _map_card(json): key = unicode(dpath.get(json, 'meta/card/id')) return card_type(key, key) tabulate(result, [ ('id', shorten_json_id), ('mac', 'meta/mac'), ('type', _map_card), ('seen', 'meta/last-seen'), ] + version_map + [ ('name', 'attributes/name'), ])
def _tabulate(result): def _map_user_count(json): return len(dpath.get(json, 'relationships/user/data')) util.tabulate(result, [ ('id', 'id'), ('name', 'attributes/name'), ('users', _map_user_count) ])
def _tabulate(result): def _map_sensor_count(json): return len(dpath.get(json, 'relationships/sensor/data')) util.tabulate(result, [ ('id', util.shorten_json_id), ('sensors', _map_sensor_count), ('name', 'attributes/name') ])
def _tabulate(result): util.tabulate(result, [ ('id', util.shorten_json_id), ('state', 'attributes/state'), ('name', 'attributes/name'), ('files', util.map_script_filenames), ('error', 'attributes/error/error') ])
def _tabulate_users(result): util.tabulate(result, [ ('id', 'id') ])
def tabulate(result, **kwargs): if not result: click.echo('No data') return util.tabulate(result, _mapping_for(**kwargs))
def _tabulate(result): util.tabulate(result, [ ('id', 'id'), ('name', 'attributes/name') ])