Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def format_array(val):
if val is None:
return settings.missingval
if not isinstance(val, list):
return val
return '{' + ','.join(text_type(format_array(e)) for e in val) + '}'
def format_array(val):
if val is None:
return settings.missingval
if not isinstance(val, list):
return val
return "{" + ",".join(text_type(format_array(e)) for e in val) + "}"
column_types = None
if hasattr(cur, "description"):
column_types = []
for d in cur.description:
if (
d[1] in psycopg2.extensions.DECIMAL.values
or d[1] in psycopg2.extensions.FLOAT.values
):
column_types.append(float)
if (
d[1] == psycopg2.extensions.INTEGER.values
or d[1] in psycopg2.extensions.LONGINTEGER.values
):
column_types.append(int)
else:
column_types.append(text_type)
formatted = formatter.format_output(cur, headers, **output_kwargs)
if isinstance(formatted, (text_type)):
formatted = iter(formatted.splitlines())
first_line = next(formatted)
formatted = itertools.chain([first_line], formatted)
if not expanded and max_width and len(first_line) > max_width and headers:
formatted = formatter.format_output(
cur, headers, format_name="vertical", column_types=None, **output_kwargs
)
if isinstance(formatted, (text_type)):
formatted = iter(formatted.splitlines())
output = itertools.chain(output, formatted)
if status: # Only print the status if it's not None.
column_types.append(float)
if d[1] == psycopg2.extensions.INTEGER.values or \
d[1] in psycopg2.extensions.LONGINTEGER.values:
column_types.append(int)
else:
column_types.append(text_type)
formatted = formatter.format_output(cur, headers, **output_kwargs)
if isinstance(formatted, (text_type)):
formatted = iter(formatted.splitlines())
first_line = next(formatted)
formatted = itertools.chain([first_line], formatted)
if (not expanded and max_width and len(first_line) > max_width and headers):
formatted = formatter.format_output(
cur, headers, format_name='vertical', column_types=None, **output_kwargs)
if isinstance(formatted, (text_type)):
formatted = iter(formatted.splitlines())
output = itertools.chain(output, formatted)
if status: # Only print the status if it's not None.
output = itertools.chain(output, [status])
return output
if max_width is not None:
cur = list(cur)
column_types = None
if hasattr(cur, 'description'):
column_types = []
for d in cur.description:
if d[1] in psycopg2.extensions.DECIMAL.values or \
d[1] in psycopg2.extensions.FLOAT.values:
column_types.append(float)
if d[1] == psycopg2.extensions.INTEGER.values or \
d[1] in psycopg2.extensions.LONGINTEGER.values:
column_types.append(int)
else:
column_types.append(text_type)
formatted = formatter.format_output(cur, headers, **output_kwargs)
if isinstance(formatted, (text_type)):
formatted = iter(formatted.splitlines())
first_line = next(formatted)
formatted = itertools.chain([first_line], formatted)
if (not expanded and max_width and len(first_line) > max_width and headers):
formatted = formatter.format_output(
cur, headers, format_name='vertical', column_types=None, **output_kwargs)
if isinstance(formatted, (text_type)):
formatted = iter(formatted.splitlines())
output = itertools.chain(output, formatted)
if status: # Only print the status if it's not None.
output = itertools.chain(output, [status])
return output
for d in cur.description:
if (
d[1] in psycopg2.extensions.DECIMAL.values
or d[1] in psycopg2.extensions.FLOAT.values
):
column_types.append(float)
if (
d[1] == psycopg2.extensions.INTEGER.values
or d[1] in psycopg2.extensions.LONGINTEGER.values
):
column_types.append(int)
else:
column_types.append(text_type)
formatted = formatter.format_output(cur, headers, **output_kwargs)
if isinstance(formatted, (text_type)):
formatted = iter(formatted.splitlines())
first_line = next(formatted)
formatted = itertools.chain([first_line], formatted)
if not expanded and max_width and len(first_line) > max_width and headers:
formatted = formatter.format_output(
cur, headers, format_name="vertical", column_types=None, **output_kwargs
)
if isinstance(formatted, (text_type)):
formatted = iter(formatted.splitlines())
output = itertools.chain(output, formatted)
if status: # Only print the status if it's not None.
output = itertools.chain(output, [status])
return output
if cur:
headers = [case_function(utf8tounicode(x)) for x in headers]
if max_width is not None:
cur = list(cur)
column_types = None
if hasattr(cur, 'description'):
column_types = []
for d in cur.description:
if d[1] in psycopg2.extensions.DECIMAL.values or \
d[1] in psycopg2.extensions.FLOAT.values:
column_types.append(float)
if d[1] == psycopg2.extensions.INTEGER.values or \
d[1] in psycopg2.extensions.LONGINTEGER.values:
column_types.append(int)
else:
column_types.append(text_type)
formatted = formatter.format_output(cur, headers, **output_kwargs)
if isinstance(formatted, (text_type)):
formatted = iter(formatted.splitlines())
first_line = next(formatted)
formatted = itertools.chain([first_line], formatted)
if (not expanded and max_width and len(first_line) > max_width and headers):
formatted = formatter.format_output(
cur, headers, format_name='vertical', column_types=None, **output_kwargs)
if isinstance(formatted, (text_type)):
formatted = iter(formatted.splitlines())
output = itertools.chain(output, formatted)
if status: # Only print the status if it's not None.
output = itertools.chain(output, [status])