MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / pretty

Function pretty

src/formattedcode/output_csv.py:237–253  ·  view source on GitHub ↗

Return a unicode text pretty representation of data (as YAML or else) if data is a sequence or mapping or the data as-is otherwise

(data)

Source from the content-addressed store, hash-verified

235
236
237def pretty(data):
238 """
239 Return a unicode text pretty representation of data (as YAML or else) if
240 data is a sequence or mapping or the data as-is otherwise
241 """
242 if not data:
243 return None
244 seqtypes = list, tuple
245 maptypes = dict, dict
246 coltypes = seqtypes + maptypes
247 if isinstance(data, seqtypes):
248 if len(data) == 1 and isinstance(data[0], str):
249 return data[0].strip()
250 if isinstance(data, coltypes):
251 return saneyaml.dump(
252 data, indent=2, encoding='utf-8').decode('utf-8').strip()
253 return data
254
255
256def get_package_columns(_columns=set()):

Callers

nothing calls this directly

Calls 2

decodeMethod · 0.45
dumpMethod · 0.45

Tested by

no test coverage detected