MCPcopy
hub / github.com/jarun/buku / print_json_safe

Function print_json_safe

buku.py:5146–5173  ·  view source on GitHub ↗

Prints json results and handles IOError Parameters ---------- resultset : list Search results from DB query. single_record : bool If True, indicates only one record. Default is False. field_filter : int Indicates format for displaying bookmarks. Default i

(resultset, single_record=False, field_filter=0)

Source from the content-addressed store, hash-verified

5144
5145
5146def print_json_safe(resultset, single_record=False, field_filter=0):
5147 """Prints json results and handles IOError
5148
5149 Parameters
5150 ----------
5151 resultset : list
5152 Search results from DB query.
5153 single_record : bool
5154 If True, indicates only one record. Default is False.
5155 field_filter : int
5156 Indicates format for displaying bookmarks. Default is 0 ("all fields").
5157
5158 Returns
5159 -------
5160 None
5161 """
5162
5163 try:
5164 print(format_json(resultset, single_record, field_filter))
5165 except IOError:
5166 try:
5167 sys.stdout.close()
5168 except IOError:
5169 pass
5170 try:
5171 sys.stderr.close()
5172 except IOError:
5173 pass
5174
5175
5176def is_int(string):

Callers 2

print_recMethod · 0.85
mainFunction · 0.85

Calls 2

format_jsonFunction · 0.85
closeMethod · 0.80

Tested by

no test coverage detected