File: stdlib_uuid.py

package info (click to toggle)
py-postgresql 1.2.1%2Bgit20180803.ef7b9a9-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,620 kB
  • sloc: python: 18,317; ansic: 2,024; sql: 282; sh: 26; makefile: 22
file content (14 lines) | stat: -rw-r--r-- 286 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import uuid
from ...types import UUIDOID

def uuid_pack(x, UUID = uuid.UUID, bytes = bytes):
	if isinstance(x, UUID):
		return bytes(x.bytes)
	return bytes(UUID(x).bytes)

def uuid_unpack(x, UUID = uuid.UUID):
	return UUID(bytes=x)

oid_to_io = {
	UUIDOID : (uuid_pack, uuid_unpack),
}