Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F3937443
raw.txt
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
douardda
Jul 2 2020, 12:31 PM
2020-07-02 12:31:45 (UTC+2)
Size
1 KB
Subscribers
None
raw.txt
View Options
def escape(data, toplevel=True):
if data is None:
return ""
if isinstance(data, bytes):
return "\\x%s" % binascii.hexlify(data).decode("ascii")
elif isinstance(data, str):
return '"%s"' % data.replace('"', '""')
elif isinstance(data, datetime.datetime):
# We escape twice to make sure the string generated by
# isoformat gets escaped
return escape(data.isoformat())
elif isinstance(data, dict):
return escape(json.dumps(data))
elif isinstance(data, (list, tuple)):
ret = "{%s}" % ",".join(escape(d, toplevel=False) for d in data)
if toplevel:
ret = '"%s"' % ret.replace("\\", "\\\\")
return ret
elif isinstance(data, psycopg2.extras.Range):
# We escape twice here too, so that we make sure
# everything gets passed to copy properly
return escape(
"%s%s,%s%s"
% (
"[" if data.lower_inc else "(",
"-infinity" if data.lower_inf else escape(data.lower),
"infinity" if data.upper_inf else escape(data.upper),
"]" if data.upper_inc else ")",
)
)
elif isinstance(data, enum.IntEnum):
return escape(int(data))
else:
# We don't escape here to make sure we pass literals properly
return str(data)
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
982117
Attached To
P710 (An Untitled Masterwork)
Event Timeline
Log In to Comment