Search is not available for this dataset
identifier
stringlengths 1
155
| parameters
stringlengths 2
6.09k
| docstring
stringlengths 11
63.4k
| docstring_summary
stringlengths 0
63.4k
| function
stringlengths 29
99.8k
| function_tokens
sequence | start_point
sequence | end_point
sequence | language
stringclasses 1
value | docstring_language
stringlengths 2
7
| docstring_language_predictions
stringlengths 18
23
| is_langid_reliable
stringclasses 2
values |
---|---|---|---|---|---|---|---|---|---|---|---|
xclOpen | (deviceIndex, logFileName, level) |
xclOpen(): Open a device and obtain its handle
:param deviceIndex: (unsigned int) Slot number of device 0 for first device, 1 for the second device...
:param logFileName: (const char pointer) Log file to use for optional logging
:param level: (int) Severity level of messages to log
:return: device handle
|
xclOpen(): Open a device and obtain its handle | def xclOpen(deviceIndex, logFileName, level):
"""
xclOpen(): Open a device and obtain its handle
:param deviceIndex: (unsigned int) Slot number of device 0 for first device, 1 for the second device...
:param logFileName: (const char pointer) Log file to use for optional logging
:param level: (int) Severity level of messages to log
:return: device handle
"""
libc.xclOpen.restype = ctypes.POINTER(xclDeviceHandle)
libc.xclOpen.argtypes = [ctypes.c_uint, ctypes.c_char_p, ctypes.c_int]
return libc.xclOpen(deviceIndex, logFileName, level) | [
"def",
"xclOpen",
"(",
"deviceIndex",
",",
"logFileName",
",",
"level",
")",
":",
"libc",
".",
"xclOpen",
".",
"restype",
"=",
"ctypes",
".",
"POINTER",
"(",
"xclDeviceHandle",
")",
"libc",
".",
"xclOpen",
".",
"argtypes",
"=",
"[",
"ctypes",
".",
"c_uint",
",",
"ctypes",
".",
"c_char_p",
",",
"ctypes",
".",
"c_int",
"]",
"return",
"libc",
".",
"xclOpen",
"(",
"deviceIndex",
",",
"logFileName",
",",
"level",
")"
] | [
170,
0
] | [
181,
56
] | python | en | ['en', 'error', 'th'] | False |
xclClose | (handle) |
xclClose(): Close an opened device
:param handle: (xclDeviceHandle) device handle
:return: None
|
xclClose(): Close an opened device | def xclClose(handle):
"""
xclClose(): Close an opened device
:param handle: (xclDeviceHandle) device handle
:return: None
"""
libc.xclClose.restype = None
libc.xclClose.argtype = xclDeviceHandle
libc.xclClose(handle) | [
"def",
"xclClose",
"(",
"handle",
")",
":",
"libc",
".",
"xclClose",
".",
"restype",
"=",
"None",
"libc",
".",
"xclClose",
".",
"argtype",
"=",
"xclDeviceHandle",
"libc",
".",
"xclClose",
"(",
"handle",
")"
] | [
183,
0
] | [
192,
25
] | python | en | ['en', 'error', 'th'] | False |
xclResetDevice | (handle, kind) |
xclResetDevice() - Reset a device or its CL
:param handle: Device handle
:param kind: Reset kind
:return: 0 on success or appropriate error number
|
xclResetDevice() - Reset a device or its CL
:param handle: Device handle
:param kind: Reset kind
:return: 0 on success or appropriate error number
| def xclResetDevice(handle, kind):
"""
xclResetDevice() - Reset a device or its CL
:param handle: Device handle
:param kind: Reset kind
:return: 0 on success or appropriate error number
"""
libc.xclResetDevice.restype = ctypes.c_int
libc.xclResetDevice.argtypes = [xclDeviceHandle, ctypes.c_int]
libc.xclResetDevice(handle, kind) | [
"def",
"xclResetDevice",
"(",
"handle",
",",
"kind",
")",
":",
"libc",
".",
"xclResetDevice",
".",
"restype",
"=",
"ctypes",
".",
"c_int",
"libc",
".",
"xclResetDevice",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"c_int",
"]",
"libc",
".",
"xclResetDevice",
"(",
"handle",
",",
"kind",
")"
] | [
194,
0
] | [
203,
37
] | python | en | ['en', 'error', 'th'] | False |
xclGetDeviceInfo2 | (handle, info) |
xclGetDeviceInfo2() - Obtain various bits of information from the device
:param handle: (xclDeviceHandle) device handle
:param info: (xclDeviceInfo pointer) Information record
:return: 0 on success or appropriate error number
|
xclGetDeviceInfo2() - Obtain various bits of information from the device | def xclGetDeviceInfo2 (handle, info):
"""
xclGetDeviceInfo2() - Obtain various bits of information from the device
:param handle: (xclDeviceHandle) device handle
:param info: (xclDeviceInfo pointer) Information record
:return: 0 on success or appropriate error number
"""
libc.xclGetDeviceInfo2.restype = ctypes.c_int
libc.xclGetDeviceInfo2.argtypes = [xclDeviceHandle, ctypes.POINTER(xclDeviceInfo2)]
return libc.xclGetDeviceInfo2(handle, info) | [
"def",
"xclGetDeviceInfo2",
"(",
"handle",
",",
"info",
")",
":",
"libc",
".",
"xclGetDeviceInfo2",
".",
"restype",
"=",
"ctypes",
".",
"c_int",
"libc",
".",
"xclGetDeviceInfo2",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"POINTER",
"(",
"xclDeviceInfo2",
")",
"]",
"return",
"libc",
".",
"xclGetDeviceInfo2",
"(",
"handle",
",",
"info",
")"
] | [
205,
0
] | [
216,
47
] | python | en | ['en', 'error', 'th'] | False |
xclGetUsageInfo | (handle, info) |
xclGetUsageInfo() - Obtain usage information from the device
:param handle: Device handle
:param info: Information record
:return: 0 on success or appropriate error number
|
xclGetUsageInfo() - Obtain usage information from the device
:param handle: Device handle
:param info: Information record
:return: 0 on success or appropriate error number
| def xclGetUsageInfo (handle, info):
"""
xclGetUsageInfo() - Obtain usage information from the device
:param handle: Device handle
:param info: Information record
:return: 0 on success or appropriate error number
"""
libc.xclGetUsageInfo.restype = ctypes.c_int
libc.xclGetUsageInfo.argtypes = [xclDeviceHandle, ctypes.POINTER(xclDeviceInfo2)]
return libc.xclGetUsageInfo(handle, info) | [
"def",
"xclGetUsageInfo",
"(",
"handle",
",",
"info",
")",
":",
"libc",
".",
"xclGetUsageInfo",
".",
"restype",
"=",
"ctypes",
".",
"c_int",
"libc",
".",
"xclGetUsageInfo",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"POINTER",
"(",
"xclDeviceInfo2",
")",
"]",
"return",
"libc",
".",
"xclGetUsageInfo",
"(",
"handle",
",",
"info",
")"
] | [
218,
0
] | [
227,
45
] | python | en | ['en', 'error', 'th'] | False |
xclGetErrorStatus | (handle, info) |
xclGetErrorStatus() - Obtain error information from the device
:param handle: Device handle
:param info: Information record
:return: 0 on success or appropriate error number
|
xclGetErrorStatus() - Obtain error information from the device
:param handle: Device handle
:param info: Information record
:return: 0 on success or appropriate error number
| def xclGetErrorStatus(handle, info):
"""
xclGetErrorStatus() - Obtain error information from the device
:param handle: Device handle
:param info: Information record
:return: 0 on success or appropriate error number
"""
libc.xclGetErrorStatus.restype = ctypes.c_int
libc.xclGetErrorStatus.argtypes = [xclDeviceHandle, ctypes.POINTER(xclDeviceInfo2)]
return libc.xclGetErrorStatus(handle, info) | [
"def",
"xclGetErrorStatus",
"(",
"handle",
",",
"info",
")",
":",
"libc",
".",
"xclGetErrorStatus",
".",
"restype",
"=",
"ctypes",
".",
"c_int",
"libc",
".",
"xclGetErrorStatus",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"POINTER",
"(",
"xclDeviceInfo2",
")",
"]",
"return",
"libc",
".",
"xclGetErrorStatus",
"(",
"handle",
",",
"info",
")"
] | [
229,
0
] | [
238,
47
] | python | en | ['en', 'error', 'th'] | False |
xclLoadXclBin | (handle, buf) |
Download FPGA image (xclbin) to the device
:param handle: (xclDeviceHandle) device handle
:param buf: (void pointer) Pointer to device image (xclbin) in memory
:return: 0 on success or appropriate error number
Download FPGA image (AXLF) to the device. The PR bitstream is encapsulated inside
xclbin as a section. xclbin may also contains other sections which are suitably
handled by the driver
|
Download FPGA image (xclbin) to the device | def xclLoadXclBin(handle, buf):
"""
Download FPGA image (xclbin) to the device
:param handle: (xclDeviceHandle) device handle
:param buf: (void pointer) Pointer to device image (xclbin) in memory
:return: 0 on success or appropriate error number
Download FPGA image (AXLF) to the device. The PR bitstream is encapsulated inside
xclbin as a section. xclbin may also contains other sections which are suitably
handled by the driver
"""
libc.xclLoadXclBin.restype = ctypes.c_int
libc.xclLoadXclBin.argtypes = [xclDeviceHandle, ctypes.c_void_p]
return libc.xclLoadXclBin(handle, buf) | [
"def",
"xclLoadXclBin",
"(",
"handle",
",",
"buf",
")",
":",
"libc",
".",
"xclLoadXclBin",
".",
"restype",
"=",
"ctypes",
".",
"c_int",
"libc",
".",
"xclLoadXclBin",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"c_void_p",
"]",
"return",
"libc",
".",
"xclLoadXclBin",
"(",
"handle",
",",
"buf",
")"
] | [
240,
0
] | [
254,
42
] | python | en | ['en', 'error', 'th'] | False |
xclGetSectionInfo | (handle, info, size, kind, index) |
xclGetSectionInfo() - Get Information from sysfs about the downloaded xclbin sections
:param handle: Device handle
:param info: Pointer to preallocated memory which will store the return value.
:param size: Pointer to preallocated memory which will store the return size.
:param kind: axlf_section_kind for which info is being queried
:param index: The (sub)section index for the "kind" type.
:return: 0 on success or appropriate error number
|
xclGetSectionInfo() - Get Information from sysfs about the downloaded xclbin sections
:param handle: Device handle
:param info: Pointer to preallocated memory which will store the return value.
:param size: Pointer to preallocated memory which will store the return size.
:param kind: axlf_section_kind for which info is being queried
:param index: The (sub)section index for the "kind" type.
:return: 0 on success or appropriate error number
| def xclGetSectionInfo(handle, info, size, kind, index):
"""
xclGetSectionInfo() - Get Information from sysfs about the downloaded xclbin sections
:param handle: Device handle
:param info: Pointer to preallocated memory which will store the return value.
:param size: Pointer to preallocated memory which will store the return size.
:param kind: axlf_section_kind for which info is being queried
:param index: The (sub)section index for the "kind" type.
:return: 0 on success or appropriate error number
"""
libc.xclGetSectionInfo.restype = ctypes.c_int
libc.xclGetSectionInfo.argtypes = [xclDeviceHandle, ctypes.POINTER(xclDeviceInfo2),
ctypes.POINTER(ctypes.sizeof(xclDeviceInfo2)),
ctypes.c_int, ctypes.c_int]
return libc.xclGetSectionInfo(handle, info, size, kind, index) | [
"def",
"xclGetSectionInfo",
"(",
"handle",
",",
"info",
",",
"size",
",",
"kind",
",",
"index",
")",
":",
"libc",
".",
"xclGetSectionInfo",
".",
"restype",
"=",
"ctypes",
".",
"c_int",
"libc",
".",
"xclGetSectionInfo",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"POINTER",
"(",
"xclDeviceInfo2",
")",
",",
"ctypes",
".",
"POINTER",
"(",
"ctypes",
".",
"sizeof",
"(",
"xclDeviceInfo2",
")",
")",
",",
"ctypes",
".",
"c_int",
",",
"ctypes",
".",
"c_int",
"]",
"return",
"libc",
".",
"xclGetSectionInfo",
"(",
"handle",
",",
"info",
",",
"size",
",",
"kind",
",",
"index",
")"
] | [
256,
0
] | [
270,
66
] | python | en | ['en', 'error', 'th'] | False |
xclReClock2 | (handle, region, targetFreqMHz) |
xclReClock2() - Configure PR region frequencies
:param handle: Device handle
:param region: PR region (always 0)
:param targetFreqMHz: Array of target frequencies in order for the Clock Wizards driving the PR region
:return: 0 on success or appropriate error number
|
xclReClock2() - Configure PR region frequencies
:param handle: Device handle
:param region: PR region (always 0)
:param targetFreqMHz: Array of target frequencies in order for the Clock Wizards driving the PR region
:return: 0 on success or appropriate error number
| def xclReClock2(handle, region, targetFreqMHz):
"""
xclReClock2() - Configure PR region frequencies
:param handle: Device handle
:param region: PR region (always 0)
:param targetFreqMHz: Array of target frequencies in order for the Clock Wizards driving the PR region
:return: 0 on success or appropriate error number
"""
libc.xclReClock2.restype = ctypes.c_int
libc.xclReClock2.argtypes = [xclDeviceHandle, ctypes.c_uint, ctypes.c_uint]
return libc.xclReClock2(handle, region, targetFreqMHz) | [
"def",
"xclReClock2",
"(",
"handle",
",",
"region",
",",
"targetFreqMHz",
")",
":",
"libc",
".",
"xclReClock2",
".",
"restype",
"=",
"ctypes",
".",
"c_int",
"libc",
".",
"xclReClock2",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"c_uint",
",",
"ctypes",
".",
"c_uint",
"]",
"return",
"libc",
".",
"xclReClock2",
"(",
"handle",
",",
"region",
",",
"targetFreqMHz",
")"
] | [
272,
0
] | [
282,
58
] | python | en | ['en', 'error', 'th'] | False |
xclLockDevice | (handle) |
Get exclusive ownership of the device
:param handle: (xclDeviceHandle) device handle
:return: 0 on success or appropriate error number
The lock is necessary before performing buffer migration, register access or bitstream downloads
|
Get exclusive ownership of the device | def xclLockDevice(handle):
"""
Get exclusive ownership of the device
:param handle: (xclDeviceHandle) device handle
:return: 0 on success or appropriate error number
The lock is necessary before performing buffer migration, register access or bitstream downloads
"""
libc.xclLockDevice.restype = ctypes.c_int
libc.xclLockDevice.argtype = xclDeviceHandle
return libc.xclLockDevice(handle) | [
"def",
"xclLockDevice",
"(",
"handle",
")",
":",
"libc",
".",
"xclLockDevice",
".",
"restype",
"=",
"ctypes",
".",
"c_int",
"libc",
".",
"xclLockDevice",
".",
"argtype",
"=",
"xclDeviceHandle",
"return",
"libc",
".",
"xclLockDevice",
"(",
"handle",
")"
] | [
284,
0
] | [
295,
37
] | python | en | ['en', 'error', 'th'] | False |
xclUnlockDevice | (handle) |
xclUnlockDevice() - Release exclusive ownership of the device
:param handle: (xclDeviceHandle) device handle
:return: 0 on success or appropriate error number
|
xclUnlockDevice() - Release exclusive ownership of the device | def xclUnlockDevice(handle):
"""
xclUnlockDevice() - Release exclusive ownership of the device
:param handle: (xclDeviceHandle) device handle
:return: 0 on success or appropriate error number
"""
libc.xclUnlockDevice.restype = ctypes.c_int
libc.xclUnlockDevice.argtype = xclDeviceHandle
return libc.xclUnlockDevice(handle) | [
"def",
"xclUnlockDevice",
"(",
"handle",
")",
":",
"libc",
".",
"xclUnlockDevice",
".",
"restype",
"=",
"ctypes",
".",
"c_int",
"libc",
".",
"xclUnlockDevice",
".",
"argtype",
"=",
"xclDeviceHandle",
"return",
"libc",
".",
"xclUnlockDevice",
"(",
"handle",
")"
] | [
297,
0
] | [
306,
39
] | python | en | ['en', 'error', 'th'] | False |
xclOpenContext | (handle, xclbinId, ipIndex, shared) |
xclOpenContext() - Create shared/exclusive context on compute units
:param handle: Device handle
:param xclbinId: UUID of the xclbin image running on the device
:param ipIndex: IP/CU index in the IP LAYOUT array
:param shared: Shared access or exclusive access
:return: 0 on success or appropriate error number
The context is necessary before submitting execution jobs using xclExecBuf(). Contexts may be
exclusive or shared. Allocation of exclusive contexts on a compute unit would succeed
only if another client has not already setup up a context on that compute unit. Shared
contexts can be concurrently allocated by many processes on the same compute units.
|
xclOpenContext() - Create shared/exclusive context on compute units
:param handle: Device handle
:param xclbinId: UUID of the xclbin image running on the device
:param ipIndex: IP/CU index in the IP LAYOUT array
:param shared: Shared access or exclusive access
:return: 0 on success or appropriate error number | def xclOpenContext(handle, xclbinId, ipIndex, shared):
"""
xclOpenContext() - Create shared/exclusive context on compute units
:param handle: Device handle
:param xclbinId: UUID of the xclbin image running on the device
:param ipIndex: IP/CU index in the IP LAYOUT array
:param shared: Shared access or exclusive access
:return: 0 on success or appropriate error number
The context is necessary before submitting execution jobs using xclExecBuf(). Contexts may be
exclusive or shared. Allocation of exclusive contexts on a compute unit would succeed
only if another client has not already setup up a context on that compute unit. Shared
contexts can be concurrently allocated by many processes on the same compute units.
"""
libc.xclOpenContext.restype = ctypes.c_int
libc.xclOpenContext.argtypes = [xclDeviceHandle, ctypes.c_char_p, ctypes.c_uint, ctypes.c_bool]
return libc.xclOpenContext(handle, xclbinId.bytes, ipIndex, shared) | [
"def",
"xclOpenContext",
"(",
"handle",
",",
"xclbinId",
",",
"ipIndex",
",",
"shared",
")",
":",
"libc",
".",
"xclOpenContext",
".",
"restype",
"=",
"ctypes",
".",
"c_int",
"libc",
".",
"xclOpenContext",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"c_char_p",
",",
"ctypes",
".",
"c_uint",
",",
"ctypes",
".",
"c_bool",
"]",
"return",
"libc",
".",
"xclOpenContext",
"(",
"handle",
",",
"xclbinId",
".",
"bytes",
",",
"ipIndex",
",",
"shared",
")"
] | [
308,
0
] | [
324,
71
] | python | en | ['en', 'error', 'th'] | False |
xclCloseContext | (handle, xclbinId, ipIndex) |
xclCloseContext() - Close previously opened context
:param handle: Device handle
:param xclbinId: UUID of the xclbin image running on the device
:param ipIndex: IP/CU index in the IP LAYOUT array
:return: 0 on success or appropriate error number
Close a previously allocated shared/exclusive context for a compute unit.
|
xclCloseContext() - Close previously opened context
:param handle: Device handle
:param xclbinId: UUID of the xclbin image running on the device
:param ipIndex: IP/CU index in the IP LAYOUT array
:return: 0 on success or appropriate error number | def xclCloseContext(handle, xclbinId, ipIndex):
"""
xclCloseContext() - Close previously opened context
:param handle: Device handle
:param xclbinId: UUID of the xclbin image running on the device
:param ipIndex: IP/CU index in the IP LAYOUT array
:return: 0 on success or appropriate error number
Close a previously allocated shared/exclusive context for a compute unit.
"""
libc.xclCloseContext.restype = ctypes.c_int
libc.xclCloseContext.argtypes = [xclDeviceHandle, ctypes.c_char_p, ctypes.c_uint]
return libc.xclCloseContext(handle, xclbinId.bytes, ipIndex) | [
"def",
"xclCloseContext",
"(",
"handle",
",",
"xclbinId",
",",
"ipIndex",
")",
":",
"libc",
".",
"xclCloseContext",
".",
"restype",
"=",
"ctypes",
".",
"c_int",
"libc",
".",
"xclCloseContext",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"c_char_p",
",",
"ctypes",
".",
"c_uint",
"]",
"return",
"libc",
".",
"xclCloseContext",
"(",
"handle",
",",
"xclbinId",
".",
"bytes",
",",
"ipIndex",
")"
] | [
326,
0
] | [
338,
64
] | python | en | ['en', 'error', 'th'] | False |
xclUpgradeFirmware | (handle, fileName) |
Update the device BPI PROM with new image
:param handle: Device handle
:param fileName:
:return: 0 on success or appropriate error number
|
Update the device BPI PROM with new image
:param handle: Device handle
:param fileName:
:return: 0 on success or appropriate error number
| def xclUpgradeFirmware(handle, fileName):
"""
Update the device BPI PROM with new image
:param handle: Device handle
:param fileName:
:return: 0 on success or appropriate error number
"""
libc.xclUpgradeFirmware.restype = ctypes.c_int
libc.xclUpgradeFirmware.argtypes = [xclDeviceHandle, ctypes.c_void_p]
return libc.xclUpgradeFirmware(handle, fileName) | [
"def",
"xclUpgradeFirmware",
"(",
"handle",
",",
"fileName",
")",
":",
"libc",
".",
"xclUpgradeFirmware",
".",
"restype",
"=",
"ctypes",
".",
"c_int",
"libc",
".",
"xclUpgradeFirmware",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"c_void_p",
"]",
"return",
"libc",
".",
"xclUpgradeFirmware",
"(",
"handle",
",",
"fileName",
")"
] | [
340,
0
] | [
349,
52
] | python | en | ['en', 'error', 'th'] | False |
xclUpgradeFirmware2 | (handle, file1, file2) |
Update the device BPI PROM with new image with clearing bitstream
:param handle: Device handle
:param fileName:
:return: 0 on success or appropriate error number
|
Update the device BPI PROM with new image with clearing bitstream
:param handle: Device handle
:param fileName:
:return: 0 on success or appropriate error number
| def xclUpgradeFirmware2(handle, file1, file2):
"""
Update the device BPI PROM with new image with clearing bitstream
:param handle: Device handle
:param fileName:
:return: 0 on success or appropriate error number
"""
libc.xclUpgradeFirmware2.restype = ctypes.c_int
libc.xclUpgradeFirmware2.argtypes = [xclDeviceHandle, ctypes.c_void_p, ctypes.c_void_p]
return libc.xclUpgradeFirmware2(handle, file1, file2) | [
"def",
"xclUpgradeFirmware2",
"(",
"handle",
",",
"file1",
",",
"file2",
")",
":",
"libc",
".",
"xclUpgradeFirmware2",
".",
"restype",
"=",
"ctypes",
".",
"c_int",
"libc",
".",
"xclUpgradeFirmware2",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"c_void_p",
",",
"ctypes",
".",
"c_void_p",
"]",
"return",
"libc",
".",
"xclUpgradeFirmware2",
"(",
"handle",
",",
"file1",
",",
"file2",
")"
] | [
351,
0
] | [
360,
57
] | python | en | ['en', 'error', 'th'] | False |
xclUpgradeFirmwareXSpi | (handle, fileName, index) |
Update the device SPI PROM with new image
:param handle:
:param fileName:
:param index:
:return:
|
Update the device SPI PROM with new image
:param handle:
:param fileName:
:param index:
:return:
| def xclUpgradeFirmwareXSpi (handle, fileName, index):
"""
Update the device SPI PROM with new image
:param handle:
:param fileName:
:param index:
:return:
"""
libc.xclUpgradeFirmwareXSpi.restype = ctypes.c_int
libc.xclUpgradeFirmwareXSpi.argtypes = [xclDeviceHandle, ctypes.c_void_p, ctypes.c_int]
return libc.xclUpgradeFirmwareXSpi(handle, fileName, index) | [
"def",
"xclUpgradeFirmwareXSpi",
"(",
"handle",
",",
"fileName",
",",
"index",
")",
":",
"libc",
".",
"xclUpgradeFirmwareXSpi",
".",
"restype",
"=",
"ctypes",
".",
"c_int",
"libc",
".",
"xclUpgradeFirmwareXSpi",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"c_void_p",
",",
"ctypes",
".",
"c_int",
"]",
"return",
"libc",
".",
"xclUpgradeFirmwareXSpi",
"(",
"handle",
",",
"fileName",
",",
"index",
")"
] | [
362,
0
] | [
372,
63
] | python | en | ['en', 'error', 'th'] | False |
xclBootFPGA | (handle) |
Boot the FPGA from PROM
:param handle: Device handle
:return: 0 on success or appropriate error number
|
Boot the FPGA from PROM
:param handle: Device handle
:return: 0 on success or appropriate error number
| def xclBootFPGA(handle):
"""
Boot the FPGA from PROM
:param handle: Device handle
:return: 0 on success or appropriate error number
"""
libc.xclBootFPGA.restype = ctypes.c_int
libc.xclBootFPGA.argtype = xclDeviceHandle
return libc.xclBootFPGA(handle) | [
"def",
"xclBootFPGA",
"(",
"handle",
")",
":",
"libc",
".",
"xclBootFPGA",
".",
"restype",
"=",
"ctypes",
".",
"c_int",
"libc",
".",
"xclBootFPGA",
".",
"argtype",
"=",
"xclDeviceHandle",
"return",
"libc",
".",
"xclBootFPGA",
"(",
"handle",
")"
] | [
374,
0
] | [
382,
35
] | python | en | ['en', 'error', 'th'] | False |
xclRemoveAndScanFPGA | () |
Write to /sys/bus/pci/devices/<deviceHandle>/remove and initiate a pci rescan by
writing to /sys/bus/pci/rescan.
:return:
|
Write to /sys/bus/pci/devices/<deviceHandle>/remove and initiate a pci rescan by
writing to /sys/bus/pci/rescan.
:return:
| def xclRemoveAndScanFPGA():
"""
Write to /sys/bus/pci/devices/<deviceHandle>/remove and initiate a pci rescan by
writing to /sys/bus/pci/rescan.
:return:
"""
libc.xclRemoveAndScanFPGA.restype = ctypes.c_int
return libc.xclRemoveAndScanFPGA() | [
"def",
"xclRemoveAndScanFPGA",
"(",
")",
":",
"libc",
".",
"xclRemoveAndScanFPGA",
".",
"restype",
"=",
"ctypes",
".",
"c_int",
"return",
"libc",
".",
"xclRemoveAndScanFPGA",
"(",
")"
] | [
384,
0
] | [
391,
38
] | python | en | ['en', 'error', 'th'] | False |
xclLogMsg | (handle, level, tag, format, *args) |
Send message to log file as per settings in ini file.
:param handle: (xclDeviceHandle) device handle
:param level: (xrtLogMsgLevel) Severity level of the msg
:param tag: (const char*) Tag supplied by the client, like "OCL", "XMA", etc.
:param format: (const char *) Format of Msg string to write to log file
:param ...: All other arguments as per the format
:return: 0 on success or appropriate error number
|
Send message to log file as per settings in ini file. | def xclLogMsg(handle, level, tag, format, *args):
"""
Send message to log file as per settings in ini file.
:param handle: (xclDeviceHandle) device handle
:param level: (xrtLogMsgLevel) Severity level of the msg
:param tag: (const char*) Tag supplied by the client, like "OCL", "XMA", etc.
:param format: (const char *) Format of Msg string to write to log file
:param ...: All other arguments as per the format
:return: 0 on success or appropriate error number
"""
libc.xclAllocBO.restype = ctypes.c_int
libc.xclAllocBO.argtypes = [xclDeviceHandle, ctypes.c_int, ctypes.c_void_p, ctypes.c_void_p]
return libc.xclLogMsg(handle, level, tag, format, *args) | [
"def",
"xclLogMsg",
"(",
"handle",
",",
"level",
",",
"tag",
",",
"format",
",",
"*",
"args",
")",
":",
"libc",
".",
"xclAllocBO",
".",
"restype",
"=",
"ctypes",
".",
"c_int",
"libc",
".",
"xclAllocBO",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"c_int",
",",
"ctypes",
".",
"c_void_p",
",",
"ctypes",
".",
"c_void_p",
"]",
"return",
"libc",
".",
"xclLogMsg",
"(",
"handle",
",",
"level",
",",
"tag",
",",
"format",
",",
"*",
"args",
")"
] | [
393,
0
] | [
406,
60
] | python | en | ['en', 'error', 'th'] | False |
xclAllocBO | (handle, size, unused, flags) |
Allocate a BO of requested size with appropriate flags
:param handle: (xclDeviceHandle) device handle
:param size: (size_t) Size of buffer
:param unused: (int) unused parameter present for legacy reasons
:param flags: (unsigned int) Specify bank information, etc
:return: BO handle
|
Allocate a BO of requested size with appropriate flags | def xclAllocBO(handle, size, unused, flags):
"""
Allocate a BO of requested size with appropriate flags
:param handle: (xclDeviceHandle) device handle
:param size: (size_t) Size of buffer
:param unused: (int) unused parameter present for legacy reasons
:param flags: (unsigned int) Specify bank information, etc
:return: BO handle
"""
libc.xclAllocBO.restype = ctypes.c_uint
libc.xclAllocBO.argtypes = [xclDeviceHandle, ctypes.c_size_t, ctypes.c_int, ctypes.c_uint]
return libc.xclAllocBO(handle, size, unused, flags) | [
"def",
"xclAllocBO",
"(",
"handle",
",",
"size",
",",
"unused",
",",
"flags",
")",
":",
"libc",
".",
"xclAllocBO",
".",
"restype",
"=",
"ctypes",
".",
"c_uint",
"libc",
".",
"xclAllocBO",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"c_size_t",
",",
"ctypes",
".",
"c_int",
",",
"ctypes",
".",
"c_uint",
"]",
"return",
"libc",
".",
"xclAllocBO",
"(",
"handle",
",",
"size",
",",
"unused",
",",
"flags",
")"
] | [
409,
0
] | [
421,
55
] | python | en | ['en', 'error', 'th'] | False |
xclAllocUserPtrBO | (handle, userptr, size, flags) |
Allocate a BO using userptr provided by the user
:param handle: Device handle
:param userptr: Pointer to 4K aligned user memory
:param size: Size of buffer
:param flags: Specify bank information, etc
:return: BO handle
|
Allocate a BO using userptr provided by the user
:param handle: Device handle
:param userptr: Pointer to 4K aligned user memory
:param size: Size of buffer
:param flags: Specify bank information, etc
:return: BO handle
| def xclAllocUserPtrBO(handle, userptr, size, flags):
"""
Allocate a BO using userptr provided by the user
:param handle: Device handle
:param userptr: Pointer to 4K aligned user memory
:param size: Size of buffer
:param flags: Specify bank information, etc
:return: BO handle
"""
libc.xclAllocUserPtrBO.restype = ctypes.c_uint
libc.xclAllocUserPtrBO.argtypes = [xclDeviceHandle, ctypes.c_void_p, ctypes.c_size_t, ctypes.c_uint]
return libc.xclAllocUserPtrBO(handle, userptr, size, flags) | [
"def",
"xclAllocUserPtrBO",
"(",
"handle",
",",
"userptr",
",",
"size",
",",
"flags",
")",
":",
"libc",
".",
"xclAllocUserPtrBO",
".",
"restype",
"=",
"ctypes",
".",
"c_uint",
"libc",
".",
"xclAllocUserPtrBO",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"c_void_p",
",",
"ctypes",
".",
"c_size_t",
",",
"ctypes",
".",
"c_uint",
"]",
"return",
"libc",
".",
"xclAllocUserPtrBO",
"(",
"handle",
",",
"userptr",
",",
"size",
",",
"flags",
")"
] | [
423,
0
] | [
434,
63
] | python | en | ['en', 'error', 'th'] | False |
xclFreeBO | (handle, boHandle) |
Free a previously allocated BO
:param handle: device handle
:param boHandle: BO handle
|
Free a previously allocated BO | def xclFreeBO(handle, boHandle):
"""
Free a previously allocated BO
:param handle: device handle
:param boHandle: BO handle
"""
libc.xclFreeBO.restype = None
libc.xclFreeBO.argtypes = [xclDeviceHandle, ctypes.c_uint]
libc.xclFreeBO(handle, boHandle) | [
"def",
"xclFreeBO",
"(",
"handle",
",",
"boHandle",
")",
":",
"libc",
".",
"xclFreeBO",
".",
"restype",
"=",
"None",
"libc",
".",
"xclFreeBO",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"c_uint",
"]",
"libc",
".",
"xclFreeBO",
"(",
"handle",
",",
"boHandle",
")"
] | [
436,
0
] | [
445,
36
] | python | en | ['en', 'error', 'th'] | False |
xclWriteBO | (handle, boHandle, src, size, seek) |
Copy-in user data to host backing storage of BO
:param handle: Device handle
:param boHandle: BO handle
:param src: Source data pointer
:param size: Size of data to copy
:param seek: Offset within the BO
:return: 0 on success or appropriate error number
|
Copy-in user data to host backing storage of BO
:param handle: Device handle
:param boHandle: BO handle
:param src: Source data pointer
:param size: Size of data to copy
:param seek: Offset within the BO
:return: 0 on success or appropriate error number
| def xclWriteBO(handle, boHandle, src, size, seek):
"""
Copy-in user data to host backing storage of BO
:param handle: Device handle
:param boHandle: BO handle
:param src: Source data pointer
:param size: Size of data to copy
:param seek: Offset within the BO
:return: 0 on success or appropriate error number
"""
libc.xclWriteBO.restype = ctypes.c_int
libc.xclWriteBO.argtypes = [xclDeviceHandle, ctypes.c_uint, ctypes.c_void_p, ctypes.c_size_t, ctypes.c_size_t]
return libc.xclWriteBO(handle, boHandle, src, size, seek) | [
"def",
"xclWriteBO",
"(",
"handle",
",",
"boHandle",
",",
"src",
",",
"size",
",",
"seek",
")",
":",
"libc",
".",
"xclWriteBO",
".",
"restype",
"=",
"ctypes",
".",
"c_int",
"libc",
".",
"xclWriteBO",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"c_uint",
",",
"ctypes",
".",
"c_void_p",
",",
"ctypes",
".",
"c_size_t",
",",
"ctypes",
".",
"c_size_t",
"]",
"return",
"libc",
".",
"xclWriteBO",
"(",
"handle",
",",
"boHandle",
",",
"src",
",",
"size",
",",
"seek",
")"
] | [
447,
0
] | [
459,
61
] | python | en | ['en', 'error', 'th'] | False |
xclReadBO | (handle, boHandle, dst, size, skip) |
Copy-out user data from host backing storage of BO
:param handle: Device handle
:param boHandle: BO handle
:param dst: Destination data pointer
:param size: Size of data to copy
:param skip: Offset within the BO
:return: 0 on success or appropriate error number
|
Copy-out user data from host backing storage of BO
:param handle: Device handle
:param boHandle: BO handle
:param dst: Destination data pointer
:param size: Size of data to copy
:param skip: Offset within the BO
:return: 0 on success or appropriate error number
| def xclReadBO(handle, boHandle, dst, size, skip):
"""
Copy-out user data from host backing storage of BO
:param handle: Device handle
:param boHandle: BO handle
:param dst: Destination data pointer
:param size: Size of data to copy
:param skip: Offset within the BO
:return: 0 on success or appropriate error number
"""
libc.xclReadBO.restype = ctypes.c_int
libc.xclReadBO.argtypes = [xclDeviceHandle, ctypes.c_uint, ctypes.c_void_p, ctypes.c_size_t, ctypes.c_size_t]
return libc.xclReadBO(handle, boHandle, dst, size, skip) | [
"def",
"xclReadBO",
"(",
"handle",
",",
"boHandle",
",",
"dst",
",",
"size",
",",
"skip",
")",
":",
"libc",
".",
"xclReadBO",
".",
"restype",
"=",
"ctypes",
".",
"c_int",
"libc",
".",
"xclReadBO",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"c_uint",
",",
"ctypes",
".",
"c_void_p",
",",
"ctypes",
".",
"c_size_t",
",",
"ctypes",
".",
"c_size_t",
"]",
"return",
"libc",
".",
"xclReadBO",
"(",
"handle",
",",
"boHandle",
",",
"dst",
",",
"size",
",",
"skip",
")"
] | [
461,
0
] | [
473,
60
] | python | en | ['en', 'error', 'th'] | False |
xclMapBO | (handle, boHandle, write, buf_type='char', buf_size=1) |
Memory map BO into user's address space
:param handle: (xclDeviceHandle) device handle
:param boHandle: (unsigned int) BO handle
:param write: (boolean) READ only or READ/WRITE mapping
:param buf_type: type of memory mapped buffer
:param buf_size: size of buffer
:return: (pointer) Memory mapped buffer
Map the contents of the buffer object into host memory
To unmap the buffer call POSIX unmap() on mapped void pointer returned from xclMapBO
Return type void pointer doesn't get correctly binded in ctypes
To map the buffer, explicitly specify the type and size of data
|
Memory map BO into user's address space | def xclMapBO(handle, boHandle, write, buf_type='char', buf_size=1):
"""
Memory map BO into user's address space
:param handle: (xclDeviceHandle) device handle
:param boHandle: (unsigned int) BO handle
:param write: (boolean) READ only or READ/WRITE mapping
:param buf_type: type of memory mapped buffer
:param buf_size: size of buffer
:return: (pointer) Memory mapped buffer
Map the contents of the buffer object into host memory
To unmap the buffer call POSIX unmap() on mapped void pointer returned from xclMapBO
Return type void pointer doesn't get correctly binded in ctypes
To map the buffer, explicitly specify the type and size of data
"""
if buf_type == 'char':
prop = xclBOProperties()
xclGetBOProperties(handle, boHandle, prop)
libc.xclMapBO.restype = ctypes.POINTER(ctypes.c_char * prop.size)
elif buf_size == 1 and buf_type == 'int':
libc.xclMapBO.restype = ctypes.POINTER(ctypes.c_int)
elif buf_type == 'int':
libc.xclMapBO.restype = ctypes.POINTER(ctypes.c_int * buf_size)
else:
print("ERROR: This data type is not supported ")
libc.xclMapBO.argtypes = [xclDeviceHandle, ctypes.c_uint, ctypes.c_bool]
ptr = libc.xclMapBO(handle, boHandle, write)
return ptr | [
"def",
"xclMapBO",
"(",
"handle",
",",
"boHandle",
",",
"write",
",",
"buf_type",
"=",
"'char'",
",",
"buf_size",
"=",
"1",
")",
":",
"if",
"buf_type",
"==",
"'char'",
":",
"prop",
"=",
"xclBOProperties",
"(",
")",
"xclGetBOProperties",
"(",
"handle",
",",
"boHandle",
",",
"prop",
")",
"libc",
".",
"xclMapBO",
".",
"restype",
"=",
"ctypes",
".",
"POINTER",
"(",
"ctypes",
".",
"c_char",
"*",
"prop",
".",
"size",
")",
"elif",
"buf_size",
"==",
"1",
"and",
"buf_type",
"==",
"'int'",
":",
"libc",
".",
"xclMapBO",
".",
"restype",
"=",
"ctypes",
".",
"POINTER",
"(",
"ctypes",
".",
"c_int",
")",
"elif",
"buf_type",
"==",
"'int'",
":",
"libc",
".",
"xclMapBO",
".",
"restype",
"=",
"ctypes",
".",
"POINTER",
"(",
"ctypes",
".",
"c_int",
"*",
"buf_size",
")",
"else",
":",
"print",
"(",
"\"ERROR: This data type is not supported \"",
")",
"libc",
".",
"xclMapBO",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"c_uint",
",",
"ctypes",
".",
"c_bool",
"]",
"ptr",
"=",
"libc",
".",
"xclMapBO",
"(",
"handle",
",",
"boHandle",
",",
"write",
")",
"return",
"ptr"
] | [
475,
0
] | [
507,
14
] | python | en | ['en', 'error', 'th'] | False |
xclSyncBO | (handle, boHandle, direction, size, offset) |
Synchronize buffer contents in requested direction
:param handle: (xclDeviceHandle) device handle
:param boHandle: (unsigned int) BO handle
:param direction: (xclBOSyncDirection) To device or from device
:param size: (size_t) Size of data to synchronize
:param offset: (size_t) Offset within the BO
:return: 0 on success or standard errno
|
Synchronize buffer contents in requested direction | def xclSyncBO(handle, boHandle, direction, size, offset):
"""
Synchronize buffer contents in requested direction
:param handle: (xclDeviceHandle) device handle
:param boHandle: (unsigned int) BO handle
:param direction: (xclBOSyncDirection) To device or from device
:param size: (size_t) Size of data to synchronize
:param offset: (size_t) Offset within the BO
:return: 0 on success or standard errno
"""
libc.xclSyncBO.restype = ctypes.c_uint
libc.xclSyncBO.argtypes = [xclDeviceHandle, ctypes.c_uint, ctypes.c_int, ctypes.c_size_t, ctypes.c_size_t]
return libc.xclSyncBO(handle, boHandle, direction, size, offset) | [
"def",
"xclSyncBO",
"(",
"handle",
",",
"boHandle",
",",
"direction",
",",
"size",
",",
"offset",
")",
":",
"libc",
".",
"xclSyncBO",
".",
"restype",
"=",
"ctypes",
".",
"c_uint",
"libc",
".",
"xclSyncBO",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"c_uint",
",",
"ctypes",
".",
"c_int",
",",
"ctypes",
".",
"c_size_t",
",",
"ctypes",
".",
"c_size_t",
"]",
"return",
"libc",
".",
"xclSyncBO",
"(",
"handle",
",",
"boHandle",
",",
"direction",
",",
"size",
",",
"offset",
")"
] | [
509,
0
] | [
522,
68
] | python | en | ['en', 'error', 'th'] | False |
xclCopyBO | (handle, dstBoHandle, srcBoHandle, size, dst_offset, src_offset) |
Copy device buffer contents to another buffer
:param handle: Device handle
:param dstBoHandle: Destination BO handle
:param srcBoHandle: Source BO handle
:param size: Size of data to synchronize
:param dst_offset: dst Offset within the BO
:param src_offset: src Offset within the BO
:return: 0 on success or standard errno
|
Copy device buffer contents to another buffer
:param handle: Device handle
:param dstBoHandle: Destination BO handle
:param srcBoHandle: Source BO handle
:param size: Size of data to synchronize
:param dst_offset: dst Offset within the BO
:param src_offset: src Offset within the BO
:return: 0 on success or standard errno
| def xclCopyBO(handle, dstBoHandle, srcBoHandle, size, dst_offset, src_offset):
"""
Copy device buffer contents to another buffer
:param handle: Device handle
:param dstBoHandle: Destination BO handle
:param srcBoHandle: Source BO handle
:param size: Size of data to synchronize
:param dst_offset: dst Offset within the BO
:param src_offset: src Offset within the BO
:return: 0 on success or standard errno
"""
libc.xclCopyBO.restype = ctypes.c_int
libc.xclCopyBO.argtypes = [xclDeviceHandle, ctypes.c_uint, ctypes.c_uint, ctypes.c_size_t, ctypes.c_size_t,
ctypes.c_uint]
libc.xclCopyBO(handle, dstBoHandle, srcBoHandle, size, dst_offset, src_offset) | [
"def",
"xclCopyBO",
"(",
"handle",
",",
"dstBoHandle",
",",
"srcBoHandle",
",",
"size",
",",
"dst_offset",
",",
"src_offset",
")",
":",
"libc",
".",
"xclCopyBO",
".",
"restype",
"=",
"ctypes",
".",
"c_int",
"libc",
".",
"xclCopyBO",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"c_uint",
",",
"ctypes",
".",
"c_uint",
",",
"ctypes",
".",
"c_size_t",
",",
"ctypes",
".",
"c_size_t",
",",
"ctypes",
".",
"c_uint",
"]",
"libc",
".",
"xclCopyBO",
"(",
"handle",
",",
"dstBoHandle",
",",
"srcBoHandle",
",",
"size",
",",
"dst_offset",
",",
"src_offset",
")"
] | [
524,
0
] | [
538,
82
] | python | en | ['en', 'error', 'th'] | False |
xclExportBO | (handle, boHandle) |
Obtain DMA-BUF file descriptor for a BO
:param handle: Device handle
:param boHandle: BO handle which needs to be exported
:return: File handle to the BO or standard errno
|
Obtain DMA-BUF file descriptor for a BO
:param handle: Device handle
:param boHandle: BO handle which needs to be exported
:return: File handle to the BO or standard errno
| def xclExportBO(handle, boHandle):
"""
Obtain DMA-BUF file descriptor for a BO
:param handle: Device handle
:param boHandle: BO handle which needs to be exported
:return: File handle to the BO or standard errno
"""
libc.xclExportBO.restype = ctypes.c_int
libc.xclExportBO.argtypes = [xclDeviceHandle, ctypes.c_uint]
return libc.xclExportBO(handle, boHandle) | [
"def",
"xclExportBO",
"(",
"handle",
",",
"boHandle",
")",
":",
"libc",
".",
"xclExportBO",
".",
"restype",
"=",
"ctypes",
".",
"c_int",
"libc",
".",
"xclExportBO",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"c_uint",
"]",
"return",
"libc",
".",
"xclExportBO",
"(",
"handle",
",",
"boHandle",
")"
] | [
540,
0
] | [
549,
45
] | python | en | ['en', 'error', 'th'] | False |
xclImportBO | (handle, fd, flags) |
Obtain BO handle for a BO represented by DMA-BUF file descriptor
:param handle: Device handle
:param fd: File handle to foreign BO owned by another device which needs to be imported
:param flags: Unused
:return: BO handle of the imported BO
Import a BO exported by another device.
This operation is backed by Linux DMA-BUF framework
|
Obtain BO handle for a BO represented by DMA-BUF file descriptor
:param handle: Device handle
:param fd: File handle to foreign BO owned by another device which needs to be imported
:param flags: Unused
:return: BO handle of the imported BO | def xclImportBO(handle, fd, flags):
"""
Obtain BO handle for a BO represented by DMA-BUF file descriptor
:param handle: Device handle
:param fd: File handle to foreign BO owned by another device which needs to be imported
:param flags: Unused
:return: BO handle of the imported BO
Import a BO exported by another device.
This operation is backed by Linux DMA-BUF framework
"""
libc.xclImportBO.restype = ctypes.c_int
libc.xclImportBO.argtypes = [xclDeviceHandle, ctypes.c_int, ctypes.c_uint]
libc.xclImportBO(handle, fd, flags) | [
"def",
"xclImportBO",
"(",
"handle",
",",
"fd",
",",
"flags",
")",
":",
"libc",
".",
"xclImportBO",
".",
"restype",
"=",
"ctypes",
".",
"c_int",
"libc",
".",
"xclImportBO",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"c_int",
",",
"ctypes",
".",
"c_uint",
"]",
"libc",
".",
"xclImportBO",
"(",
"handle",
",",
"fd",
",",
"flags",
")"
] | [
551,
0
] | [
564,
39
] | python | en | ['en', 'error', 'th'] | False |
xclGetBOProperties | (handle, boHandle, properties) |
Obtain xclBOProperties struct for a BO
:param handle: (xclDeviceHandle) device handle
:param boHandle: (unsigned int) BO handle
:param properties: BO properties struct pointer
:return: 0 on success
|
Obtain xclBOProperties struct for a BO | def xclGetBOProperties(handle, boHandle, properties):
"""
Obtain xclBOProperties struct for a BO
:param handle: (xclDeviceHandle) device handle
:param boHandle: (unsigned int) BO handle
:param properties: BO properties struct pointer
:return: 0 on success
"""
libc.xclGetBOProperties.restype = ctypes.c_int
libc.xclGetBOProperties.argtypes = [xclDeviceHandle, ctypes.c_uint, ctypes.POINTER(xclBOProperties)]
return libc.xclGetBOProperties(handle, boHandle, properties) | [
"def",
"xclGetBOProperties",
"(",
"handle",
",",
"boHandle",
",",
"properties",
")",
":",
"libc",
".",
"xclGetBOProperties",
".",
"restype",
"=",
"ctypes",
".",
"c_int",
"libc",
".",
"xclGetBOProperties",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"c_uint",
",",
"ctypes",
".",
"POINTER",
"(",
"xclBOProperties",
")",
"]",
"return",
"libc",
".",
"xclGetBOProperties",
"(",
"handle",
",",
"boHandle",
",",
"properties",
")"
] | [
566,
0
] | [
577,
64
] | python | en | ['en', 'error', 'th'] | False |
xclGetDeviceAddr | (handle, boHandle) |
Get the physical address on the device
This API is deprecated and will be removed in future release.
New clients should use xclGetBOProperties() instead.
:param handle: (xclDeviceHandle) device handle
:param boHandle: (unsigned int) BO handle
:return: uint64_t address of the BO on success
|
Get the physical address on the device | def xclGetDeviceAddr(handle, boHandle):
"""
Get the physical address on the device
This API is deprecated and will be removed in future release.
New clients should use xclGetBOProperties() instead.
:param handle: (xclDeviceHandle) device handle
:param boHandle: (unsigned int) BO handle
:return: uint64_t address of the BO on success
"""
libc.xclGetBOProperties.restype = ctypes.c_uint64
libc.xclGetBOProperties.argtypes = [xclDeviceHandle, ctypes.c_uint]
return libc.xclGetBOProperties(handle, boHandle) | [
"def",
"xclGetDeviceAddr",
"(",
"handle",
",",
"boHandle",
")",
":",
"libc",
".",
"xclGetBOProperties",
".",
"restype",
"=",
"ctypes",
".",
"c_uint64",
"libc",
".",
"xclGetBOProperties",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"c_uint",
"]",
"return",
"libc",
".",
"xclGetBOProperties",
"(",
"handle",
",",
"boHandle",
")"
] | [
579,
0
] | [
592,
52
] | python | en | ['en', 'error', 'th'] | False |
xclUnmgdPread | (handle, flags, buf, size, offeset) |
Perform unmanaged device memory read operation
:param handle: Device handle
:param flags: Unused
:param buf: Destination data pointer
:param size: Size of data to copy
:param offeset: Absolute offset inside device
:return: size of bytes read or appropriate error number
This API may be used to perform DMA operation from absolute location specified. Users
may use this if they want to perform their own device memory management -- not using the buffer
object (BO) framework defined before.
|
Perform unmanaged device memory read operation
:param handle: Device handle
:param flags: Unused
:param buf: Destination data pointer
:param size: Size of data to copy
:param offeset: Absolute offset inside device
:return: size of bytes read or appropriate error number | def xclUnmgdPread(handle, flags, buf, size, offeset):
"""
Perform unmanaged device memory read operation
:param handle: Device handle
:param flags: Unused
:param buf: Destination data pointer
:param size: Size of data to copy
:param offeset: Absolute offset inside device
:return: size of bytes read or appropriate error number
This API may be used to perform DMA operation from absolute location specified. Users
may use this if they want to perform their own device memory management -- not using the buffer
object (BO) framework defined before.
"""
libc.xclUnmgdPread.restype = ctypes.c_size_t
libc.xclUnmgdPread.argtypes = [xclDeviceHandle, ctypes.c_uint, ctypes.c_void_p, ctypes.c_size_t, ctypes.c_uint64]
return libc.xclUnmgdPread(handle, flags, buf, size, offeset) | [
"def",
"xclUnmgdPread",
"(",
"handle",
",",
"flags",
",",
"buf",
",",
"size",
",",
"offeset",
")",
":",
"libc",
".",
"xclUnmgdPread",
".",
"restype",
"=",
"ctypes",
".",
"c_size_t",
"libc",
".",
"xclUnmgdPread",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"c_uint",
",",
"ctypes",
".",
"c_void_p",
",",
"ctypes",
".",
"c_size_t",
",",
"ctypes",
".",
"c_uint64",
"]",
"return",
"libc",
".",
"xclUnmgdPread",
"(",
"handle",
",",
"flags",
",",
"buf",
",",
"size",
",",
"offeset",
")"
] | [
594,
0
] | [
610,
64
] | python | en | ['en', 'error', 'th'] | False |
xclUnmgdPwrite | (handle, flags, buf, size, offset) |
Perform unmanaged device memory write operation
:param handle: Device handle
:param flags: Unused
:param buf: Destination data pointer
:param size: Size of data to copy
:param offeset: Absolute offset inside device
:return: size of bytes read or appropriate error number
This API may be used to perform DMA operation from absolute location specified. Users
may use this if they want to perform their own device memory management -- not using the buffer
object (BO) framework defined before.
|
Perform unmanaged device memory write operation
:param handle: Device handle
:param flags: Unused
:param buf: Destination data pointer
:param size: Size of data to copy
:param offeset: Absolute offset inside device
:return: size of bytes read or appropriate error number | def xclUnmgdPwrite(handle, flags, buf, size, offset):
"""
Perform unmanaged device memory write operation
:param handle: Device handle
:param flags: Unused
:param buf: Destination data pointer
:param size: Size of data to copy
:param offeset: Absolute offset inside device
:return: size of bytes read or appropriate error number
This API may be used to perform DMA operation from absolute location specified. Users
may use this if they want to perform their own device memory management -- not using the buffer
object (BO) framework defined before.
"""
libc.xclUnmgdPwrite.restype = ctypes.c_size_t
libc.xclUnmgdPwrite.argtypes = [xclDeviceHandle, ctypes.c_uint, ctypes.c_void_p, ctypes.c_size_t, ctypes.c_uint64]
return libc.xclUnmgdPwrite(handle, flags, buf, size, offset) | [
"def",
"xclUnmgdPwrite",
"(",
"handle",
",",
"flags",
",",
"buf",
",",
"size",
",",
"offset",
")",
":",
"libc",
".",
"xclUnmgdPwrite",
".",
"restype",
"=",
"ctypes",
".",
"c_size_t",
"libc",
".",
"xclUnmgdPwrite",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"c_uint",
",",
"ctypes",
".",
"c_void_p",
",",
"ctypes",
".",
"c_size_t",
",",
"ctypes",
".",
"c_uint64",
"]",
"return",
"libc",
".",
"xclUnmgdPwrite",
"(",
"handle",
",",
"flags",
",",
"buf",
",",
"size",
",",
"offset",
")"
] | [
612,
0
] | [
628,
64
] | python | en | ['en', 'error', 'th'] | False |
xclWrite | (handle, space, offset, hostBuf, size) |
Perform register write operation
:param handle: Device handle
:param space: Address space
:param offset: Offset in the address space
:param hostBuf: Source data pointer
:param size: Size of data to copy
:return: size of bytes written or appropriate error number
This API may be used to write to device registers exposed on PCIe BAR. Offset is relative to the
the address space. A device may have many address spaces.
This API will be deprecated in future. Please use this API only for IP bringup/debugging. For
execution management please use XRT Compute Unit Execution Management APIs defined below
|
Perform register write operation
:param handle: Device handle
:param space: Address space
:param offset: Offset in the address space
:param hostBuf: Source data pointer
:param size: Size of data to copy
:return: size of bytes written or appropriate error number | def xclWrite(handle, space, offset, hostBuf, size):
"""
Perform register write operation
:param handle: Device handle
:param space: Address space
:param offset: Offset in the address space
:param hostBuf: Source data pointer
:param size: Size of data to copy
:return: size of bytes written or appropriate error number
This API may be used to write to device registers exposed on PCIe BAR. Offset is relative to the
the address space. A device may have many address spaces.
This API will be deprecated in future. Please use this API only for IP bringup/debugging. For
execution management please use XRT Compute Unit Execution Management APIs defined below
"""
libc.xclWrite.restype = ctypes.c_size_t
libc.xclWrite.argtypes = [xclDeviceHandle, ctypes.c_int, ctypes.c_uint64, ctypes.c_void_p, ctypes.c_size_t]
return libc.xclWrite(handle, space, offset, hostBuf, size) | [
"def",
"xclWrite",
"(",
"handle",
",",
"space",
",",
"offset",
",",
"hostBuf",
",",
"size",
")",
":",
"libc",
".",
"xclWrite",
".",
"restype",
"=",
"ctypes",
".",
"c_size_t",
"libc",
".",
"xclWrite",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"c_int",
",",
"ctypes",
".",
"c_uint64",
",",
"ctypes",
".",
"c_void_p",
",",
"ctypes",
".",
"c_size_t",
"]",
"return",
"libc",
".",
"xclWrite",
"(",
"handle",
",",
"space",
",",
"offset",
",",
"hostBuf",
",",
"size",
")"
] | [
630,
0
] | [
647,
62
] | python | en | ['en', 'error', 'th'] | False |
xclRead | (handle, space, offset, hostBuf, size) |
Perform register write operation
:param handle: Device handle
:param space: Address space
:param offset: Offset in the address space
:param hostBuf: Destination data pointer
:param size: Size of data to copy
:return: size of bytes written or appropriate error number
This API may be used to write to device registers exposed on PCIe BAR. Offset is relative to the
the address space. A device may have many address spaces.
This API will be deprecated in future. Please use this API only for IP bringup/debugging. For
execution management please use XRT Compute Unit Execution Management APIs defined below
|
Perform register write operation
:param handle: Device handle
:param space: Address space
:param offset: Offset in the address space
:param hostBuf: Destination data pointer
:param size: Size of data to copy
:return: size of bytes written or appropriate error number | def xclRead(handle, space, offset, hostBuf, size):
"""
Perform register write operation
:param handle: Device handle
:param space: Address space
:param offset: Offset in the address space
:param hostBuf: Destination data pointer
:param size: Size of data to copy
:return: size of bytes written or appropriate error number
This API may be used to write to device registers exposed on PCIe BAR. Offset is relative to the
the address space. A device may have many address spaces.
This API will be deprecated in future. Please use this API only for IP bringup/debugging. For
execution management please use XRT Compute Unit Execution Management APIs defined below
"""
libc.xclRead.restype = ctypes.c_size_t
libc.xclRead.argtypes = [xclDeviceHandle, ctypes.c_int, ctypes.c_uint64, ctypes.c_void_p, ctypes.c_size_t]
return libc.xclRead(handle, space, offset, hostBuf, size) | [
"def",
"xclRead",
"(",
"handle",
",",
"space",
",",
"offset",
",",
"hostBuf",
",",
"size",
")",
":",
"libc",
".",
"xclRead",
".",
"restype",
"=",
"ctypes",
".",
"c_size_t",
"libc",
".",
"xclRead",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"c_int",
",",
"ctypes",
".",
"c_uint64",
",",
"ctypes",
".",
"c_void_p",
",",
"ctypes",
".",
"c_size_t",
"]",
"return",
"libc",
".",
"xclRead",
"(",
"handle",
",",
"space",
",",
"offset",
",",
"hostBuf",
",",
"size",
")"
] | [
649,
0
] | [
666,
61
] | python | en | ['en', 'error', 'th'] | False |
xclExecBuf | (handle, cmdBO) |
xclExecBuf() - Submit an execution request to the embedded (or software) scheduler
:param handle: Device handle
:param cmdBO: BO handle containing command packet
:return: 0 or standard error number
Submit an exec buffer for execution. The exec buffer layout is defined by struct ert_packet
which is defined in file *ert.h*. The BO should been allocated with DRM_XOCL_BO_EXECBUF flag.
|
xclExecBuf() - Submit an execution request to the embedded (or software) scheduler
:param handle: Device handle
:param cmdBO: BO handle containing command packet
:return: 0 or standard error number | def xclExecBuf(handle, cmdBO):
"""
xclExecBuf() - Submit an execution request to the embedded (or software) scheduler
:param handle: Device handle
:param cmdBO: BO handle containing command packet
:return: 0 or standard error number
Submit an exec buffer for execution. The exec buffer layout is defined by struct ert_packet
which is defined in file *ert.h*. The BO should been allocated with DRM_XOCL_BO_EXECBUF flag.
"""
libc.xclExecBuf.restype = ctypes.c_int
libc.xclExecBuf.argtypes = [xclDeviceHandle, ctypes.c_uint]
return libc.xclExecBuf(handle, cmdBO) | [
"def",
"xclExecBuf",
"(",
"handle",
",",
"cmdBO",
")",
":",
"libc",
".",
"xclExecBuf",
".",
"restype",
"=",
"ctypes",
".",
"c_int",
"libc",
".",
"xclExecBuf",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"c_uint",
"]",
"return",
"libc",
".",
"xclExecBuf",
"(",
"handle",
",",
"cmdBO",
")"
] | [
668,
0
] | [
680,
41
] | python | en | ['en', 'error', 'th'] | False |
xclExecBufWithWaitList | (handle, cmdBO, num_bo_in_wait_list, bo_wait_list) |
Submit an execution request to the embedded (or software) scheduler
:param handle: Device handle
:param cmdBO:BO handle containing command packet
:param num_bo_in_wait_list: Number of BO handles in wait list
:param bo_wait_list: BO handles that must complete execution before cmdBO is started
:return:0 or standard error number
Submit an exec buffer for execution. The BO handles in the wait
list must complete execution before cmdBO is started. The BO
handles in the wait list must have beeen submitted prior to this
call to xclExecBufWithWaitList.
|
Submit an execution request to the embedded (or software) scheduler
:param handle: Device handle
:param cmdBO:BO handle containing command packet
:param num_bo_in_wait_list: Number of BO handles in wait list
:param bo_wait_list: BO handles that must complete execution before cmdBO is started
:return:0 or standard error number | def xclExecBufWithWaitList(handle, cmdBO, num_bo_in_wait_list, bo_wait_list):
"""
Submit an execution request to the embedded (or software) scheduler
:param handle: Device handle
:param cmdBO:BO handle containing command packet
:param num_bo_in_wait_list: Number of BO handles in wait list
:param bo_wait_list: BO handles that must complete execution before cmdBO is started
:return:0 or standard error number
Submit an exec buffer for execution. The BO handles in the wait
list must complete execution before cmdBO is started. The BO
handles in the wait list must have beeen submitted prior to this
call to xclExecBufWithWaitList.
"""
libc.xclExecBufWithWaitList.restype = ctypes.c_int
libc.xclExecBufWithWaitList.argtypes = [xclDeviceHandle, ctypes.c_uint, ctypes.c_size_t, ctypes.POINTER(ctypes.c_uint)]
return libc.xclExecBufWithWaitList(handle, cmdBO, num_bo_in_wait_list, bo_wait_list) | [
"def",
"xclExecBufWithWaitList",
"(",
"handle",
",",
"cmdBO",
",",
"num_bo_in_wait_list",
",",
"bo_wait_list",
")",
":",
"libc",
".",
"xclExecBufWithWaitList",
".",
"restype",
"=",
"ctypes",
".",
"c_int",
"libc",
".",
"xclExecBufWithWaitList",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"c_uint",
",",
"ctypes",
".",
"c_size_t",
",",
"ctypes",
".",
"POINTER",
"(",
"ctypes",
".",
"c_uint",
")",
"]",
"return",
"libc",
".",
"xclExecBufWithWaitList",
"(",
"handle",
",",
"cmdBO",
",",
"num_bo_in_wait_list",
",",
"bo_wait_list",
")"
] | [
682,
0
] | [
698,
88
] | python | en | ['en', 'error', 'th'] | False |
xclExecWait | (handle, timeoutMilliSec) |
xclExecWait() - Wait for one or more execution events on the device
:param handle: Device handle
:param timeoutMilliSec: How long to wait for
:return: Same code as poll system call
Wait for notification from the hardware. The function essentially calls "poll" system
call on the driver file handle. The return value has same semantics as poll system call.
If return value is > 0 caller should check the status of submitted exec buffers
|
xclExecWait() - Wait for one or more execution events on the device
:param handle: Device handle
:param timeoutMilliSec: How long to wait for
:return: Same code as poll system call | def xclExecWait(handle, timeoutMilliSec):
"""
xclExecWait() - Wait for one or more execution events on the device
:param handle: Device handle
:param timeoutMilliSec: How long to wait for
:return: Same code as poll system call
Wait for notification from the hardware. The function essentially calls "poll" system
call on the driver file handle. The return value has same semantics as poll system call.
If return value is > 0 caller should check the status of submitted exec buffers
"""
libc.xclExecWait.restype = ctypes.c_int
libc.xclExecWait.argtypes = [xclDeviceHandle, ctypes.c_int]
return libc.xclExecWait(handle, timeoutMilliSec) | [
"def",
"xclExecWait",
"(",
"handle",
",",
"timeoutMilliSec",
")",
":",
"libc",
".",
"xclExecWait",
".",
"restype",
"=",
"ctypes",
".",
"c_int",
"libc",
".",
"xclExecWait",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"c_int",
"]",
"return",
"libc",
".",
"xclExecWait",
"(",
"handle",
",",
"timeoutMilliSec",
")"
] | [
700,
0
] | [
713,
52
] | python | en | ['en', 'error', 'th'] | False |
xclRegisterInterruptNotify | (handle, userInterrupt, fd) |
register *eventfdfile handle for a MSIX interrupt
:param handle: Device handle
:param userInterrupt: MSIX interrupt number
:param fd: Eventfd handle
:return: 0 on success or standard errno
Support for non managed interrupts (interrupts from custom IPs). fd should be obtained from
eventfd system call. Caller should use standard poll/read eventfd framework in order to wait for
interrupts. The handles are automatically unregistered on process exit.
|
register *eventfdfile handle for a MSIX interrupt
:param handle: Device handle
:param userInterrupt: MSIX interrupt number
:param fd: Eventfd handle
:return: 0 on success or standard errno | def xclRegisterInterruptNotify(handle, userInterrupt, fd):
"""
register *eventfdfile handle for a MSIX interrupt
:param handle: Device handle
:param userInterrupt: MSIX interrupt number
:param fd: Eventfd handle
:return: 0 on success or standard errno
Support for non managed interrupts (interrupts from custom IPs). fd should be obtained from
eventfd system call. Caller should use standard poll/read eventfd framework in order to wait for
interrupts. The handles are automatically unregistered on process exit.
"""
libc.xclRegisterInterruptNotify.restype = ctypes.c_int
libc.xclRegisterInterruptNotify.argtypes = [xclDeviceHandle, ctypes.c_uint, ctypes.c_int]
return libc.xclRegisterInterruptNotify(handle, userInterrupt, fd) | [
"def",
"xclRegisterInterruptNotify",
"(",
"handle",
",",
"userInterrupt",
",",
"fd",
")",
":",
"libc",
".",
"xclRegisterInterruptNotify",
".",
"restype",
"=",
"ctypes",
".",
"c_int",
"libc",
".",
"xclRegisterInterruptNotify",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"c_uint",
",",
"ctypes",
".",
"c_int",
"]",
"return",
"libc",
".",
"xclRegisterInterruptNotify",
"(",
"handle",
",",
"userInterrupt",
",",
"fd",
")"
] | [
715,
0
] | [
729,
69
] | python | en | ['en', 'error', 'th'] | False |
xclCreateWriteQueue | (handle, q_ctx, q_hdl) |
Create Write Queue
:param handle:Device handle
:param q_ctx:Queue Context
:param q_hdl:Queue handle
:return:
This is used to create queue based on information provided in Queue context. Queue handle is generated if creation
successes.
This feature will be enabled in a future release.
|
Create Write Queue
:param handle:Device handle
:param q_ctx:Queue Context
:param q_hdl:Queue handle
:return: | def xclCreateWriteQueue(handle, q_ctx, q_hdl):
"""
Create Write Queue
:param handle:Device handle
:param q_ctx:Queue Context
:param q_hdl:Queue handle
:return:
This is used to create queue based on information provided in Queue context. Queue handle is generated if creation
successes.
This feature will be enabled in a future release.
"""
libc.xclCreateWriteQueue.restype = ctypes.c_int
libc.xclCreateWriteQueue.argtypes = [xclDeviceHandle, ctypes.POINTER(xclQueueContext), ctypes.c_uint64]
return libc.xclCreateWriteQueue(handle, q_ctx, q_hdl) | [
"def",
"xclCreateWriteQueue",
"(",
"handle",
",",
"q_ctx",
",",
"q_hdl",
")",
":",
"libc",
".",
"xclCreateWriteQueue",
".",
"restype",
"=",
"ctypes",
".",
"c_int",
"libc",
".",
"xclCreateWriteQueue",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"POINTER",
"(",
"xclQueueContext",
")",
",",
"ctypes",
".",
"c_uint64",
"]",
"return",
"libc",
".",
"xclCreateWriteQueue",
"(",
"handle",
",",
"q_ctx",
",",
"q_hdl",
")"
] | [
746,
0
] | [
760,
57
] | python | en | ['en', 'error', 'th'] | False |
xclCreateReadQueue | (handle, q_ctx, q_hdl) |
Create Read Queue
:param handle:Device handle
:param q_ctx:Queue Context
:param q_hdl:Queue handle
:return:
This is used to create queue based on information provided in Queue context. Queue handle is generated if creation
successes.
This feature will be enabled in a future release.
|
Create Read Queue
:param handle:Device handle
:param q_ctx:Queue Context
:param q_hdl:Queue handle
:return: | def xclCreateReadQueue(handle, q_ctx, q_hdl):
"""
Create Read Queue
:param handle:Device handle
:param q_ctx:Queue Context
:param q_hdl:Queue handle
:return:
This is used to create queue based on information provided in Queue context. Queue handle is generated if creation
successes.
This feature will be enabled in a future release.
"""
libc.xclCreateReadQueue.restype = ctypes.c_int
libc.xclCreateReadQueue.argtypes = [xclDeviceHandle, ctypes.POINTER(xclQueueContext), ctypes.c_uint64]
return libc.xclCreateReadQueue(handle, q_ctx, q_hdl) | [
"def",
"xclCreateReadQueue",
"(",
"handle",
",",
"q_ctx",
",",
"q_hdl",
")",
":",
"libc",
".",
"xclCreateReadQueue",
".",
"restype",
"=",
"ctypes",
".",
"c_int",
"libc",
".",
"xclCreateReadQueue",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"POINTER",
"(",
"xclQueueContext",
")",
",",
"ctypes",
".",
"c_uint64",
"]",
"return",
"libc",
".",
"xclCreateReadQueue",
"(",
"handle",
",",
"q_ctx",
",",
"q_hdl",
")"
] | [
762,
0
] | [
776,
56
] | python | en | ['en', 'error', 'th'] | False |
xclAllocQDMABuf | (handle, size, buf_hdl) |
Allocate DMA buffer
:param handle: Device handle
:param size: Buffer handle
:param buf_hdl: Buffer size
:return: buffer pointer
These functions allocate and free DMA buffers which is used for queue read and write.
This feature will be enabled in a future release.
|
Allocate DMA buffer
:param handle: Device handle
:param size: Buffer handle
:param buf_hdl: Buffer size
:return: buffer pointer | def xclAllocQDMABuf(handle, size, buf_hdl):
"""
Allocate DMA buffer
:param handle: Device handle
:param size: Buffer handle
:param buf_hdl: Buffer size
:return: buffer pointer
These functions allocate and free DMA buffers which is used for queue read and write.
This feature will be enabled in a future release.
"""
libc.xclAllocQDMABuf.restypes = ctypes.c_void_p
libc.xclAllocQDMABuf.argtypes = [xclDeviceHandle, ctypes.c_size_t, ctypes.c_uint64]
return libc.xclAllocQDMABuf(handle, size, buf_hdl) | [
"def",
"xclAllocQDMABuf",
"(",
"handle",
",",
"size",
",",
"buf_hdl",
")",
":",
"libc",
".",
"xclAllocQDMABuf",
".",
"restypes",
"=",
"ctypes",
".",
"c_void_p",
"libc",
".",
"xclAllocQDMABuf",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"c_size_t",
",",
"ctypes",
".",
"c_uint64",
"]",
"return",
"libc",
".",
"xclAllocQDMABuf",
"(",
"handle",
",",
"size",
",",
"buf_hdl",
")"
] | [
779,
0
] | [
792,
54
] | python | en | ['en', 'error', 'th'] | False |
xclFreeQDMABuf | (handle, buf_hdl) |
Allocate DMA buffer
:param handle: Device handle
:param size: Buffer handle
:param buf_hdl: Buffer size
:return: buffer pointer
These functions allocate and free DMA buffers which is used for queue read and write.
This feature will be enabled in a future release.
|
Allocate DMA buffer
:param handle: Device handle
:param size: Buffer handle
:param buf_hdl: Buffer size
:return: buffer pointer | def xclFreeQDMABuf(handle, buf_hdl):
"""
Allocate DMA buffer
:param handle: Device handle
:param size: Buffer handle
:param buf_hdl: Buffer size
:return: buffer pointer
These functions allocate and free DMA buffers which is used for queue read and write.
This feature will be enabled in a future release.
"""
libc.xclFreeQDMABuf.restypes = ctypes.c_int
libc.xclFreeQDMABuf.argtypes = [xclDeviceHandle, ctypes.c_uint64]
return libc.xclFreeQDMABuf(handle, buf_hdl) | [
"def",
"xclFreeQDMABuf",
"(",
"handle",
",",
"buf_hdl",
")",
":",
"libc",
".",
"xclFreeQDMABuf",
".",
"restypes",
"=",
"ctypes",
".",
"c_int",
"libc",
".",
"xclFreeQDMABuf",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"c_uint64",
"]",
"return",
"libc",
".",
"xclFreeQDMABuf",
"(",
"handle",
",",
"buf_hdl",
")"
] | [
794,
0
] | [
807,
47
] | python | en | ['en', 'error', 'th'] | False |
xclDestroyQueue | (handle, q_hdl) |
Destroy Queue
:param handle: Device handle
:param q_hdl: Queue handle
This function destroy Queue and release all resources. It returns -EBUSY if Queue is in running state.
This feature will be enabled in a future release.
|
Destroy Queue
:param handle: Device handle
:param q_hdl: Queue handle | def xclDestroyQueue(handle, q_hdl):
"""
Destroy Queue
:param handle: Device handle
:param q_hdl: Queue handle
This function destroy Queue and release all resources. It returns -EBUSY if Queue is in running state.
This feature will be enabled in a future release.
"""
libc.xclDestroyQueue.restypes = ctypes.c_int
libc.xclDestroyQueue.argtypes = [xclDeviceHandle, ctypes.c_uint64]
return libc.xclDestroyQueue(handle, q_hdl) | [
"def",
"xclDestroyQueue",
"(",
"handle",
",",
"q_hdl",
")",
":",
"libc",
".",
"xclDestroyQueue",
".",
"restypes",
"=",
"ctypes",
".",
"c_int",
"libc",
".",
"xclDestroyQueue",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"c_uint64",
"]",
"return",
"libc",
".",
"xclDestroyQueue",
"(",
"handle",
",",
"q_hdl",
")"
] | [
809,
0
] | [
820,
46
] | python | en | ['en', 'error', 'th'] | False |
xclModifyQueue | (handle, q_hdl) |
Modify Queue
:param handle: Device handle
:param q_hdl: Queue handle
This function modifies Queue context on the fly. Modifying rid implies
to program hardware traffic manager to connect Queue to the kernel pipe.
|
Modify Queue
:param handle: Device handle
:param q_hdl: Queue handle | def xclModifyQueue(handle, q_hdl):
"""
Modify Queue
:param handle: Device handle
:param q_hdl: Queue handle
This function modifies Queue context on the fly. Modifying rid implies
to program hardware traffic manager to connect Queue to the kernel pipe.
"""
libc.xclModifyQueue.restypes = ctypes.c_int
libc.xclModifyQueue.argtypes = [xclDeviceHandle, ctypes.c_uint64]
return libc.xclModifyQueue(handle, q_hdl) | [
"def",
"xclModifyQueue",
"(",
"handle",
",",
"q_hdl",
")",
":",
"libc",
".",
"xclModifyQueue",
".",
"restypes",
"=",
"ctypes",
".",
"c_int",
"libc",
".",
"xclModifyQueue",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"c_uint64",
"]",
"return",
"libc",
".",
"xclModifyQueue",
"(",
"handle",
",",
"q_hdl",
")"
] | [
822,
0
] | [
833,
45
] | python | en | ['en', 'error', 'th'] | False |
xclStartQueue | (handle, q_hdl) |
set Queue to running state
:param handle: Device handle
:param q_hdl: Queue handle
This function set xclStartQueue to running state. xclStartQueue starts to process Read and Write requests.
|
set Queue to running state
:param handle: Device handle
:param q_hdl: Queue handle | def xclStartQueue(handle, q_hdl):
"""
set Queue to running state
:param handle: Device handle
:param q_hdl: Queue handle
This function set xclStartQueue to running state. xclStartQueue starts to process Read and Write requests.
"""
libc.xclStartQueue.restypes = ctypes.c_int
libc.xclStartQueue.argtypes = [xclDeviceHandle, ctypes.c_uint64]
return libc.xclStartQueue(handle, q_hdl) | [
"def",
"xclStartQueue",
"(",
"handle",
",",
"q_hdl",
")",
":",
"libc",
".",
"xclStartQueue",
".",
"restypes",
"=",
"ctypes",
".",
"c_int",
"libc",
".",
"xclStartQueue",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"c_uint64",
"]",
"return",
"libc",
".",
"xclStartQueue",
"(",
"handle",
",",
"q_hdl",
")"
] | [
835,
0
] | [
845,
44
] | python | en | ['en', 'error', 'th'] | False |
xclStopQueue | (handle, q_hdl) |
set Queue to init state
:param handle: Device handle
:param q_hdl: Queue handle
This function set Queue to init state. all pending read and write requests will be flushed.
wr_complete and rd_complete will be called with error wbe for flushed requests.
|
set Queue to init state
:param handle: Device handle
:param q_hdl: Queue handle | def xclStopQueue(handle, q_hdl):
"""
set Queue to init state
:param handle: Device handle
:param q_hdl: Queue handle
This function set Queue to init state. all pending read and write requests will be flushed.
wr_complete and rd_complete will be called with error wbe for flushed requests.
"""
libc.xclStopQueue.restypes = ctypes.c_int
libc.xclStopQueue.argtypes = [xclDeviceHandle, ctypes.c_uint64]
return libc.xclStopQueue(handle, q_hdl) | [
"def",
"xclStopQueue",
"(",
"handle",
",",
"q_hdl",
")",
":",
"libc",
".",
"xclStopQueue",
".",
"restypes",
"=",
"ctypes",
".",
"c_int",
"libc",
".",
"xclStopQueue",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"c_uint64",
"]",
"return",
"libc",
".",
"xclStopQueue",
"(",
"handle",
",",
"q_hdl",
")"
] | [
847,
0
] | [
858,
43
] | python | en | ['en', 'error', 'th'] | False |
xclWriteQueue | (handle, q_hdl, wr_req) |
write data to queue
:param handle: Device handle
:param q_hdl: Queue handle
:param wr_req: write request
:return:
This function moves data from host memory. Based on the Queue type, data is written as stream or packet.
Return: number of bytes been written or error code.
stream Queue:
There is not any Flag been added to mark the end of buffer.
The bytes been written should equal to bytes been requested unless error happens.
Packet Queue:
There is Flag been added for end of buffer. Thus kernel may recognize that a packet is receviced.
This function supports blocking and non-blocking write
blocking:
return only when the entire buf has been written, or error.
non-blocking:
return 0 immediatly.
EOT:
end of transmit signal will be added at last
silent: (only used with non-blocking);
No event generated after write completes
|
write data to queue
:param handle: Device handle
:param q_hdl: Queue handle
:param wr_req: write request
:return: | def xclWriteQueue(handle, q_hdl, wr_req):
"""
write data to queue
:param handle: Device handle
:param q_hdl: Queue handle
:param wr_req: write request
:return:
This function moves data from host memory. Based on the Queue type, data is written as stream or packet.
Return: number of bytes been written or error code.
stream Queue:
There is not any Flag been added to mark the end of buffer.
The bytes been written should equal to bytes been requested unless error happens.
Packet Queue:
There is Flag been added for end of buffer. Thus kernel may recognize that a packet is receviced.
This function supports blocking and non-blocking write
blocking:
return only when the entire buf has been written, or error.
non-blocking:
return 0 immediatly.
EOT:
end of transmit signal will be added at last
silent: (only used with non-blocking);
No event generated after write completes
"""
libc.xclWriteQueue.restype = ctypes.c_ssize_t
libc.xclWriteQueue.argtypes = [xclDeviceHandle, ctypes.POINTER(xclQueueRequest)]
return libc.xclWriteQueue(handle, q_hdl, wr_req) | [
"def",
"xclWriteQueue",
"(",
"handle",
",",
"q_hdl",
",",
"wr_req",
")",
":",
"libc",
".",
"xclWriteQueue",
".",
"restype",
"=",
"ctypes",
".",
"c_ssize_t",
"libc",
".",
"xclWriteQueue",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"POINTER",
"(",
"xclQueueRequest",
")",
"]",
"return",
"libc",
".",
"xclWriteQueue",
"(",
"handle",
",",
"q_hdl",
",",
"wr_req",
")"
] | [
903,
0
] | [
930,
52
] | python | en | ['en', 'error', 'th'] | False |
xclReadQueue | (handle, q_hdl, wr_req) |
write data to queue
:param handle: Device handle
:param q_hdl: Queue handle
:param wr_req: write request
:return:
This function moves data to host memory. Based on the Queue type, data is read as stream or packet.
Return: number of bytes been read or error code.
stream Queue:
read until all the requested bytes is read or error happens.
blocking:
return only when the requested bytes are read (stream) or the entire packet is read (packet)
non-blocking:
return 0 immidiately.
|
write data to queue
:param handle: Device handle
:param q_hdl: Queue handle
:param wr_req: write request
:return: | def xclReadQueue(handle, q_hdl, wr_req):
"""
write data to queue
:param handle: Device handle
:param q_hdl: Queue handle
:param wr_req: write request
:return:
This function moves data to host memory. Based on the Queue type, data is read as stream or packet.
Return: number of bytes been read or error code.
stream Queue:
read until all the requested bytes is read or error happens.
blocking:
return only when the requested bytes are read (stream) or the entire packet is read (packet)
non-blocking:
return 0 immidiately.
"""
libc.xclReadQueue.restype = ctypes.c_ssize_t
libc.xclReadQueue.argtypes = [xclDeviceHandle, ctypes.POINTER(xclQueueRequest)]
return libc.xclReadQueue(handle, q_hdl, wr_req) | [
"def",
"xclReadQueue",
"(",
"handle",
",",
"q_hdl",
",",
"wr_req",
")",
":",
"libc",
".",
"xclReadQueue",
".",
"restype",
"=",
"ctypes",
".",
"c_ssize_t",
"libc",
".",
"xclReadQueue",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"POINTER",
"(",
"xclQueueRequest",
")",
"]",
"return",
"libc",
".",
"xclReadQueue",
"(",
"handle",
",",
"q_hdl",
",",
"wr_req",
")"
] | [
932,
0
] | [
951,
51
] | python | en | ['en', 'error', 'th'] | False |
xclPollCompletion | (handle, min_compl, max_compl, comps, actual_compl, timeout) |
for non-blocking read/write, check if there is any request been completed
:param handle: device handle
:param min_compl: unblock only when receiving min_compl completions
:param max_compl: Max number of completion with one poll
:param comps:
:param actual_compl:
:param timeout: timeout
:return:
|
for non-blocking read/write, check if there is any request been completed
:param handle: device handle
:param min_compl: unblock only when receiving min_compl completions
:param max_compl: Max number of completion with one poll
:param comps:
:param actual_compl:
:param timeout: timeout
:return:
| def xclPollCompletion(handle, min_compl, max_compl, comps, actual_compl, timeout):
"""
for non-blocking read/write, check if there is any request been completed
:param handle: device handle
:param min_compl: unblock only when receiving min_compl completions
:param max_compl: Max number of completion with one poll
:param comps:
:param actual_compl:
:param timeout: timeout
:return:
"""
libc.xclPollCompletion.restype = ctypes.c_int
libc.xclPollCompletion.argtypes = [xclDeviceHandle, ctypes.c_int, ctypes.c_int, ctypes.POINTER(xclReqCompletion),
ctypes.POINTER(ctypes.c_int), ctypes.c_int]
return libc.xclPollCompletion(handle, min_compl, max_compl, comps, actual_compl, timeout) | [
"def",
"xclPollCompletion",
"(",
"handle",
",",
"min_compl",
",",
"max_compl",
",",
"comps",
",",
"actual_compl",
",",
"timeout",
")",
":",
"libc",
".",
"xclPollCompletion",
".",
"restype",
"=",
"ctypes",
".",
"c_int",
"libc",
".",
"xclPollCompletion",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"c_int",
",",
"ctypes",
".",
"c_int",
",",
"ctypes",
".",
"POINTER",
"(",
"xclReqCompletion",
")",
",",
"ctypes",
".",
"POINTER",
"(",
"ctypes",
".",
"c_int",
")",
",",
"ctypes",
".",
"c_int",
"]",
"return",
"libc",
".",
"xclPollCompletion",
"(",
"handle",
",",
"min_compl",
",",
"max_compl",
",",
"comps",
",",
"actual_compl",
",",
"timeout",
")"
] | [
953,
0
] | [
967,
93
] | python | en | ['en', 'error', 'th'] | False |
xclRegRead | (handle, cu_index, offset, datap) |
Read register in register space of a CU
:param handle: Device handle
:param cu_index: CU index
:param offset: Offset in the register space
:param datap: Pointer to where result will be saved
:return: 0 or appropriate error number
|
Read register in register space of a CU
:param handle: Device handle
:param cu_index: CU index
:param offset: Offset in the register space
:param datap: Pointer to where result will be saved
:return: 0 or appropriate error number
| def xclRegRead(handle, cu_index, offset, datap):
"""
Read register in register space of a CU
:param handle: Device handle
:param cu_index: CU index
:param offset: Offset in the register space
:param datap: Pointer to where result will be saved
:return: 0 or appropriate error number
"""
libc.xclRegRead.restype = ctypes.c_int
libc.xclRegRead.argtypes = [xclDeviceHandle, ctypes.uint32_t, ctypes.uint32_t, ctypes.POINTER(ctypes.c_uint32_t)]
return libc.xclRegRead(handle, cu_index, offset, datap) | [
"def",
"xclRegRead",
"(",
"handle",
",",
"cu_index",
",",
"offset",
",",
"datap",
")",
":",
"libc",
".",
"xclRegRead",
".",
"restype",
"=",
"ctypes",
".",
"c_int",
"libc",
".",
"xclRegRead",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"uint32_t",
",",
"ctypes",
".",
"uint32_t",
",",
"ctypes",
".",
"POINTER",
"(",
"ctypes",
".",
"c_uint32_t",
")",
"]",
"return",
"libc",
".",
"xclRegRead",
"(",
"handle",
",",
"cu_index",
",",
"offset",
",",
"datap",
")"
] | [
969,
0
] | [
980,
59
] | python | en | ['en', 'error', 'th'] | False |
xclRgWrite | (handle, cu_index, offset, data) |
Write register in register space of a CU
:param handle: Device handle
:param cu_index: CU index
:param offset: Offset in the register space
:param data: Pointer to where result will be saved
:return: 0 or appropriate error number
|
Write register in register space of a CU
:param handle: Device handle
:param cu_index: CU index
:param offset: Offset in the register space
:param data: Pointer to where result will be saved
:return: 0 or appropriate error number
| def xclRgWrite(handle, cu_index, offset, data):
"""
Write register in register space of a CU
:param handle: Device handle
:param cu_index: CU index
:param offset: Offset in the register space
:param data: Pointer to where result will be saved
:return: 0 or appropriate error number
"""
libc.xclRegRead.restype = ctypes.c_int
libc.xclRegRead.argtypes = [xclDeviceHandle, ctypes.uint32_t, ctypes.uint32_t, ctypes.c_uint32_t]
return libc.xclRegRead(handle, cu_index, offset, data) | [
"def",
"xclRgWrite",
"(",
"handle",
",",
"cu_index",
",",
"offset",
",",
"data",
")",
":",
"libc",
".",
"xclRegRead",
".",
"restype",
"=",
"ctypes",
".",
"c_int",
"libc",
".",
"xclRegRead",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"uint32_t",
",",
"ctypes",
".",
"uint32_t",
",",
"ctypes",
".",
"c_uint32_t",
"]",
"return",
"libc",
".",
"xclRegRead",
"(",
"handle",
",",
"cu_index",
",",
"offset",
",",
"data",
")"
] | [
982,
0
] | [
993,
58
] | python | en | ['en', 'error', 'th'] | False |
xclDebugReadIPStatus | (handle, type, debugResults) |
:param handle:
:param type:
:param debugResults:
:return:
| def xclDebugReadIPStatus(handle, type, debugResults):
"""
:param handle:
:param type:
:param debugResults:
:return:
"""
libc.xclDebugReadIPStatus.restype = ctypes.c_size_t
libc.xclDebugReadIPStatus.argtypes = [xclDeviceHandle, ctypes.c_int, ctypes.c_void_p]
return libc.xclDebugReadIPStatus(handle, type, debugResults) | [
"def",
"xclDebugReadIPStatus",
"(",
"handle",
",",
"type",
",",
"debugResults",
")",
":",
"libc",
".",
"xclDebugReadIPStatus",
".",
"restype",
"=",
"ctypes",
".",
"c_size_t",
"libc",
".",
"xclDebugReadIPStatus",
".",
"argtypes",
"=",
"[",
"xclDeviceHandle",
",",
"ctypes",
".",
"c_int",
",",
"ctypes",
".",
"c_void_p",
"]",
"return",
"libc",
".",
"xclDebugReadIPStatus",
"(",
"handle",
",",
"type",
",",
"debugResults",
")"
] | [
995,
0
] | [
1005,
64
] | python | en | ['en', 'error', 'th'] | False |
|
Hashes.__init__ | (self, hashes=None) |
:param hashes: A dict of algorithm names pointing to lists of allowed
hex digests
|
:param hashes: A dict of algorithm names pointing to lists of allowed
hex digests
| def __init__(self, hashes=None):
# type: (Dict[str, List[str]]) -> None
"""
:param hashes: A dict of algorithm names pointing to lists of allowed
hex digests
"""
allowed = {}
if hashes is not None:
for alg, keys in hashes.items():
# Make sure values are always sorted (to ease equality checks)
allowed[alg] = sorted(keys)
self._allowed = allowed | [
"def",
"__init__",
"(",
"self",
",",
"hashes",
"=",
"None",
")",
":",
"# type: (Dict[str, List[str]]) -> None",
"allowed",
"=",
"{",
"}",
"if",
"hashes",
"is",
"not",
"None",
":",
"for",
"alg",
",",
"keys",
"in",
"hashes",
".",
"items",
"(",
")",
":",
"# Make sure values are always sorted (to ease equality checks)",
"allowed",
"[",
"alg",
"]",
"=",
"sorted",
"(",
"keys",
")",
"self",
".",
"_allowed",
"=",
"allowed"
] | [
30,
4
] | [
41,
31
] | python | en | ['en', 'error', 'th'] | False |
Hashes.is_hash_allowed | (
self,
hash_name, # type: str
hex_digest, # type: str
) | Return whether the given hex digest is allowed. | Return whether the given hex digest is allowed. | def is_hash_allowed(
self,
hash_name, # type: str
hex_digest, # type: str
):
# type: (...) -> bool
"""Return whether the given hex digest is allowed."""
return hex_digest in self._allowed.get(hash_name, []) | [
"def",
"is_hash_allowed",
"(",
"self",
",",
"hash_name",
",",
"# type: str",
"hex_digest",
",",
"# type: str",
")",
":",
"# type: (...) -> bool",
"return",
"hex_digest",
"in",
"self",
".",
"_allowed",
".",
"get",
"(",
"hash_name",
",",
"[",
"]",
")"
] | [
68,
4
] | [
75,
61
] | python | en | ['en', 'en', 'en'] | True |
Hashes.check_against_chunks | (self, chunks) | Check good hashes against ones built from iterable of chunks of
data.
Raise HashMismatch if none match.
| Check good hashes against ones built from iterable of chunks of
data. | def check_against_chunks(self, chunks):
# type: (Iterator[bytes]) -> None
"""Check good hashes against ones built from iterable of chunks of
data.
Raise HashMismatch if none match.
"""
gots = {}
for hash_name in self._allowed.keys():
try:
gots[hash_name] = hashlib.new(hash_name)
except (ValueError, TypeError):
raise InstallationError(f"Unknown hash name: {hash_name}")
for chunk in chunks:
for hash in gots.values():
hash.update(chunk)
for hash_name, got in gots.items():
if got.hexdigest() in self._allowed[hash_name]:
return
self._raise(gots) | [
"def",
"check_against_chunks",
"(",
"self",
",",
"chunks",
")",
":",
"# type: (Iterator[bytes]) -> None",
"gots",
"=",
"{",
"}",
"for",
"hash_name",
"in",
"self",
".",
"_allowed",
".",
"keys",
"(",
")",
":",
"try",
":",
"gots",
"[",
"hash_name",
"]",
"=",
"hashlib",
".",
"new",
"(",
"hash_name",
")",
"except",
"(",
"ValueError",
",",
"TypeError",
")",
":",
"raise",
"InstallationError",
"(",
"f\"Unknown hash name: {hash_name}\"",
")",
"for",
"chunk",
"in",
"chunks",
":",
"for",
"hash",
"in",
"gots",
".",
"values",
"(",
")",
":",
"hash",
".",
"update",
"(",
"chunk",
")",
"for",
"hash_name",
",",
"got",
"in",
"gots",
".",
"items",
"(",
")",
":",
"if",
"got",
".",
"hexdigest",
"(",
")",
"in",
"self",
".",
"_allowed",
"[",
"hash_name",
"]",
":",
"return",
"self",
".",
"_raise",
"(",
"gots",
")"
] | [
77,
4
] | [
99,
25
] | python | en | ['en', 'en', 'en'] | True |
Hashes.check_against_file | (self, file) | Check good hashes against a file-like object
Raise HashMismatch if none match.
| Check good hashes against a file-like object | def check_against_file(self, file):
# type: (BinaryIO) -> None
"""Check good hashes against a file-like object
Raise HashMismatch if none match.
"""
return self.check_against_chunks(read_chunks(file)) | [
"def",
"check_against_file",
"(",
"self",
",",
"file",
")",
":",
"# type: (BinaryIO) -> None",
"return",
"self",
".",
"check_against_chunks",
"(",
"read_chunks",
"(",
"file",
")",
")"
] | [
105,
4
] | [
112,
59
] | python | en | ['en', 'en', 'en'] | True |
Hashes.__nonzero__ | (self) | Return whether I know any known-good hashes. | Return whether I know any known-good hashes. | def __nonzero__(self):
# type: () -> bool
"""Return whether I know any known-good hashes."""
return bool(self._allowed) | [
"def",
"__nonzero__",
"(",
"self",
")",
":",
"# type: () -> bool",
"return",
"bool",
"(",
"self",
".",
"_allowed",
")"
] | [
119,
4
] | [
122,
34
] | python | en | ['en', 'en', 'en'] | True |
MissingHashes.__init__ | (self) | Don't offer the ``hashes`` kwarg. | Don't offer the ``hashes`` kwarg. | def __init__(self):
# type: () -> None
"""Don't offer the ``hashes`` kwarg."""
# Pass our favorite hash in to generate a "gotten hash". With the
# empty list, it will never match, so an error will always raise.
super().__init__(hashes={FAVORITE_HASH: []}) | [
"def",
"__init__",
"(",
"self",
")",
":",
"# type: () -> None",
"# Pass our favorite hash in to generate a \"gotten hash\". With the",
"# empty list, it will never match, so an error will always raise.",
"super",
"(",
")",
".",
"__init__",
"(",
"hashes",
"=",
"{",
"FAVORITE_HASH",
":",
"[",
"]",
"}",
")"
] | [
155,
4
] | [
160,
52
] | python | en | ['en', 'en', 'sw'] | True |
log_response | (message, *args, response=None, request=None, logger=request_logger, level=None, exc_info=None) |
Log errors based on HttpResponse status.
Log 5xx responses as errors and 4xx responses as warnings (unless a level
is given as a keyword argument). The HttpResponse status_code and the
request are passed to the logger's extra parameter.
|
Log errors based on HttpResponse status. | def log_response(message, *args, response=None, request=None, logger=request_logger, level=None, exc_info=None):
"""
Log errors based on HttpResponse status.
Log 5xx responses as errors and 4xx responses as warnings (unless a level
is given as a keyword argument). The HttpResponse status_code and the
request are passed to the logger's extra parameter.
"""
# Check if the response has already been logged. Multiple requests to log
# the same response can be received in some cases, e.g., when the
# response is the result of an exception and is logged at the time the
# exception is caught so that the exc_info can be recorded.
if getattr(response, '_has_been_logged', False):
return
if level is None:
if response.status_code >= 500:
level = 'error'
elif response.status_code >= 400:
level = 'warning'
else:
level = 'info'
getattr(logger, level)(
message, *args,
extra={
'status_code': response.status_code,
'request': request,
},
exc_info=exc_info,
)
response._has_been_logged = True | [
"def",
"log_response",
"(",
"message",
",",
"*",
"args",
",",
"response",
"=",
"None",
",",
"request",
"=",
"None",
",",
"logger",
"=",
"request_logger",
",",
"level",
"=",
"None",
",",
"exc_info",
"=",
"None",
")",
":",
"# Check if the response has already been logged. Multiple requests to log",
"# the same response can be received in some cases, e.g., when the",
"# response is the result of an exception and is logged at the time the",
"# exception is caught so that the exc_info can be recorded.",
"if",
"getattr",
"(",
"response",
",",
"'_has_been_logged'",
",",
"False",
")",
":",
"return",
"if",
"level",
"is",
"None",
":",
"if",
"response",
".",
"status_code",
">=",
"500",
":",
"level",
"=",
"'error'",
"elif",
"response",
".",
"status_code",
">=",
"400",
":",
"level",
"=",
"'warning'",
"else",
":",
"level",
"=",
"'info'",
"getattr",
"(",
"logger",
",",
"level",
")",
"(",
"message",
",",
"*",
"args",
",",
"extra",
"=",
"{",
"'status_code'",
":",
"response",
".",
"status_code",
",",
"'request'",
":",
"request",
",",
"}",
",",
"exc_info",
"=",
"exc_info",
",",
")",
"response",
".",
"_has_been_logged",
"=",
"True"
] | [
200,
0
] | [
231,
36
] | python | en | ['en', 'error', 'th'] | False |
AdminEmailHandler.format_subject | (self, subject) |
Escape CR and LF characters.
|
Escape CR and LF characters.
| def format_subject(self, subject):
"""
Escape CR and LF characters.
"""
return subject.replace('\n', '\\n').replace('\r', '\\r') | [
"def",
"format_subject",
"(",
"self",
",",
"subject",
")",
":",
"return",
"subject",
".",
"replace",
"(",
"'\\n'",
",",
"'\\\\n'",
")",
".",
"replace",
"(",
"'\\r'",
",",
"'\\\\r'",
")"
] | [
129,
4
] | [
133,
64
] | python | en | ['en', 'error', 'th'] | False |
ContentBased.__init__ | (self, train_file=None, test_file=None, output_file=None, similarity_file=None, similarity_sep='\t',
rank_length=10, as_binary=True, sep='\t', output_sep='\t') |
Content Based Recommender for Item Recommendation
Usage::
>> ContentBased(train, test, similarity_file=similarity_file).compute()
:param train_file: File which contains the train set. This file needs to have at least 3 columns
(user item feedback_value).
:type train_file: str
:param test_file: File which contains the test set. This file needs to have at least 3 columns
(user item feedback_value).
:type test_file: str, default None
:param output_file: File with dir to write the final predictions
:type output_file: str, default None
:param similarity_file: File which contains the similarity set. This file needs to have at least 3 columns
(item item similarity).
:type similarity_file: str, default None
:param rank_length: Size of the rank that must be generated by the predictions of the recommender algorithm
:type rank_length: int, default 10
:param similarity_sep: Delimiter for similarity or metadata file
:type similarity_sep: str, default '\t'
:param sep: Delimiter for input files file
:type sep: str, default '\t'
:param output_sep: Delimiter for output file
:type output_sep: str, default '\t'
|
Content Based Recommender for Item Recommendation | def __init__(self, train_file=None, test_file=None, output_file=None, similarity_file=None, similarity_sep='\t',
rank_length=10, as_binary=True, sep='\t', output_sep='\t'):
"""
Content Based Recommender for Item Recommendation
Usage::
>> ContentBased(train, test, similarity_file=similarity_file).compute()
:param train_file: File which contains the train set. This file needs to have at least 3 columns
(user item feedback_value).
:type train_file: str
:param test_file: File which contains the test set. This file needs to have at least 3 columns
(user item feedback_value).
:type test_file: str, default None
:param output_file: File with dir to write the final predictions
:type output_file: str, default None
:param similarity_file: File which contains the similarity set. This file needs to have at least 3 columns
(item item similarity).
:type similarity_file: str, default None
:param rank_length: Size of the rank that must be generated by the predictions of the recommender algorithm
:type rank_length: int, default 10
:param similarity_sep: Delimiter for similarity or metadata file
:type similarity_sep: str, default '\t'
:param sep: Delimiter for input files file
:type sep: str, default '\t'
:param output_sep: Delimiter for output file
:type output_sep: str, default '\t'
"""
super(ContentBased, self).__init__(train_file=train_file, test_file=test_file, output_file=output_file,
as_binary=as_binary, rank_length=rank_length, sep=sep, output_sep=output_sep)
self.recommender_name = 'Content Based Algorithm'
self.similarity_file = similarity_file
self.similarity_sep = similarity_sep
self.si_matrix = None
self.similar_items = None
self.users_profile = None | [
"def",
"__init__",
"(",
"self",
",",
"train_file",
"=",
"None",
",",
"test_file",
"=",
"None",
",",
"output_file",
"=",
"None",
",",
"similarity_file",
"=",
"None",
",",
"similarity_sep",
"=",
"'\\t'",
",",
"rank_length",
"=",
"10",
",",
"as_binary",
"=",
"True",
",",
"sep",
"=",
"'\\t'",
",",
"output_sep",
"=",
"'\\t'",
")",
":",
"super",
"(",
"ContentBased",
",",
"self",
")",
".",
"__init__",
"(",
"train_file",
"=",
"train_file",
",",
"test_file",
"=",
"test_file",
",",
"output_file",
"=",
"output_file",
",",
"as_binary",
"=",
"as_binary",
",",
"rank_length",
"=",
"rank_length",
",",
"sep",
"=",
"sep",
",",
"output_sep",
"=",
"output_sep",
")",
"self",
".",
"recommender_name",
"=",
"'Content Based Algorithm'",
"self",
".",
"similarity_file",
"=",
"similarity_file",
"self",
".",
"similarity_sep",
"=",
"similarity_sep",
"self",
".",
"si_matrix",
"=",
"None",
"self",
".",
"similar_items",
"=",
"None",
"self",
".",
"users_profile",
"=",
"None"
] | [
23,
4
] | [
72,
33
] | python | en | ['en', 'error', 'th'] | False |
ContentBased.init_model | (self) |
Method to initialize the model. Create and read a similarity matrix
|
Method to initialize the model. Create and read a similarity matrix | def init_model(self):
"""
Method to initialize the model. Create and read a similarity matrix
"""
if self.similarity_file is not None:
similarity = ReadFile(self.similarity_file, sep=self.similarity_sep, as_binary=False
).read_metadata_or_similarity()
self.si_matrix = np.zeros((len(self.items), len(self.items)))
# Fill similarity matrix
for i in similarity['col_1']:
for i_j in similarity['dict'][i]:
self.si_matrix[self.item_to_item_id[i], self.item_to_item_id[int(i_j)]] = similarity['dict'][i][i_j]
# Remove NaNs
self.si_matrix[np.isnan(self.si_matrix)] = 0.0
else:
raise ValueError("This algorithm needs a similarity matrix file!") | [
"def",
"init_model",
"(",
"self",
")",
":",
"if",
"self",
".",
"similarity_file",
"is",
"not",
"None",
":",
"similarity",
"=",
"ReadFile",
"(",
"self",
".",
"similarity_file",
",",
"sep",
"=",
"self",
".",
"similarity_sep",
",",
"as_binary",
"=",
"False",
")",
".",
"read_metadata_or_similarity",
"(",
")",
"self",
".",
"si_matrix",
"=",
"np",
".",
"zeros",
"(",
"(",
"len",
"(",
"self",
".",
"items",
")",
",",
"len",
"(",
"self",
".",
"items",
")",
")",
")",
"# Fill similarity matrix",
"for",
"i",
"in",
"similarity",
"[",
"'col_1'",
"]",
":",
"for",
"i_j",
"in",
"similarity",
"[",
"'dict'",
"]",
"[",
"i",
"]",
":",
"self",
".",
"si_matrix",
"[",
"self",
".",
"item_to_item_id",
"[",
"i",
"]",
",",
"self",
".",
"item_to_item_id",
"[",
"int",
"(",
"i_j",
")",
"]",
"]",
"=",
"similarity",
"[",
"'dict'",
"]",
"[",
"i",
"]",
"[",
"i_j",
"]",
"# Remove NaNs",
"self",
".",
"si_matrix",
"[",
"np",
".",
"isnan",
"(",
"self",
".",
"si_matrix",
")",
"]",
"=",
"0.0",
"else",
":",
"raise",
"ValueError",
"(",
"\"This algorithm needs a similarity matrix file!\"",
")"
] | [
74,
4
] | [
94,
78
] | python | en | ['en', 'error', 'th'] | False |
ContentBased.compute | (self, verbose=True, metrics=None, verbose_evaluation=True, as_table=False, table_sep='\t', n_ranks=None) |
Extends compute method from BaseItemRecommendation. Method to run recommender algorithm
:param verbose: Print recommender and database information
:type verbose: bool, default True
:param metrics: List of evaluation metrics
:type metrics: list, default None
:param verbose_evaluation: Print the evaluation results
:type verbose_evaluation: bool, default True
:param as_table: Print the evaluation results as table
:type as_table: bool, default False
:param table_sep: Delimiter for print results (only work with verbose=True and as_table=True)
:type table_sep: str, default '\t'
:param n_ranks: List of positions to evaluate the ranking
:type n_ranks: list, None
|
Extends compute method from BaseItemRecommendation. Method to run recommender algorithm | def compute(self, verbose=True, metrics=None, verbose_evaluation=True, as_table=False, table_sep='\t', n_ranks=None):
"""
Extends compute method from BaseItemRecommendation. Method to run recommender algorithm
:param verbose: Print recommender and database information
:type verbose: bool, default True
:param metrics: List of evaluation metrics
:type metrics: list, default None
:param verbose_evaluation: Print the evaluation results
:type verbose_evaluation: bool, default True
:param as_table: Print the evaluation results as table
:type as_table: bool, default False
:param table_sep: Delimiter for print results (only work with verbose=True and as_table=True)
:type table_sep: str, default '\t'
:param n_ranks: List of positions to evaluate the ranking
:type n_ranks: list, None
"""
super(ContentBased, self).compute(verbose=verbose)
if verbose:
print("training_time:: %4f sec" % timed(self.init_model))
if self.extra_info_header is not None:
print(self.extra_info_header)
self.create_user_profile()
print("prediction_time:: %4f sec" % timed(self.predict))
print('\n')
else:
self.init_model()
self.create_user_profile()
self.predict()
self.write_ranking()
if self.test_file is not None:
self.evaluate(metrics, verbose_evaluation, as_table=as_table, table_sep=table_sep, n_ranks=n_ranks) | [
"def",
"compute",
"(",
"self",
",",
"verbose",
"=",
"True",
",",
"metrics",
"=",
"None",
",",
"verbose_evaluation",
"=",
"True",
",",
"as_table",
"=",
"False",
",",
"table_sep",
"=",
"'\\t'",
",",
"n_ranks",
"=",
"None",
")",
":",
"super",
"(",
"ContentBased",
",",
"self",
")",
".",
"compute",
"(",
"verbose",
"=",
"verbose",
")",
"if",
"verbose",
":",
"print",
"(",
"\"training_time:: %4f sec\"",
"%",
"timed",
"(",
"self",
".",
"init_model",
")",
")",
"if",
"self",
".",
"extra_info_header",
"is",
"not",
"None",
":",
"print",
"(",
"self",
".",
"extra_info_header",
")",
"self",
".",
"create_user_profile",
"(",
")",
"print",
"(",
"\"prediction_time:: %4f sec\"",
"%",
"timed",
"(",
"self",
".",
"predict",
")",
")",
"print",
"(",
"'\\n'",
")",
"else",
":",
"self",
".",
"init_model",
"(",
")",
"self",
".",
"create_user_profile",
"(",
")",
"self",
".",
"predict",
"(",
")",
"self",
".",
"write_ranking",
"(",
")",
"if",
"self",
".",
"test_file",
"is",
"not",
"None",
":",
"self",
".",
"evaluate",
"(",
"metrics",
",",
"verbose_evaluation",
",",
"as_table",
"=",
"as_table",
",",
"table_sep",
"=",
"table_sep",
",",
"n_ranks",
"=",
"n_ranks",
")"
] | [
119,
4
] | [
161,
111
] | python | en | ['en', 'error', 'th'] | False |
gcd | (p, q) | Returns the greatest common divisor of p and q
>>> gcd(48, 180)
12
| Returns the greatest common divisor of p and q | def gcd(p, q):
"""Returns the greatest common divisor of p and q
>>> gcd(48, 180)
12
"""
while q != 0:
(p, q) = (q, p % q)
return p | [
"def",
"gcd",
"(",
"p",
",",
"q",
")",
":",
"while",
"q",
"!=",
"0",
":",
"(",
"p",
",",
"q",
")",
"=",
"(",
"q",
",",
"p",
"%",
"q",
")",
"return",
"p"
] | [
29,
0
] | [
38,
12
] | python | en | ['en', 'en', 'en'] | True |
get_primality_testing_rounds | (number) | Returns minimum number of rounds for Miller-Rabing primality testing,
based on number bitsize.
According to NIST FIPS 186-4, Appendix C, Table C.3, minimum number of
rounds of M-R testing, using an error probability of 2 ** (-100), for
different p, q bitsizes are:
* p, q bitsize: 512; rounds: 7
* p, q bitsize: 1024; rounds: 4
* p, q bitsize: 1536; rounds: 3
See: http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf
| Returns minimum number of rounds for Miller-Rabing primality testing,
based on number bitsize. | def get_primality_testing_rounds(number):
"""Returns minimum number of rounds for Miller-Rabing primality testing,
based on number bitsize.
According to NIST FIPS 186-4, Appendix C, Table C.3, minimum number of
rounds of M-R testing, using an error probability of 2 ** (-100), for
different p, q bitsizes are:
* p, q bitsize: 512; rounds: 7
* p, q bitsize: 1024; rounds: 4
* p, q bitsize: 1536; rounds: 3
See: http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf
"""
# Calculate number bitsize.
bitsize = rsa.common.bit_size(number)
# Set number of rounds.
if bitsize >= 1536:
return 3
if bitsize >= 1024:
return 4
if bitsize >= 512:
return 7
# For smaller bitsizes, set arbitrary number of rounds.
return 10 | [
"def",
"get_primality_testing_rounds",
"(",
"number",
")",
":",
"# Calculate number bitsize.",
"bitsize",
"=",
"rsa",
".",
"common",
".",
"bit_size",
"(",
"number",
")",
"# Set number of rounds.",
"if",
"bitsize",
">=",
"1536",
":",
"return",
"3",
"if",
"bitsize",
">=",
"1024",
":",
"return",
"4",
"if",
"bitsize",
">=",
"512",
":",
"return",
"7",
"# For smaller bitsizes, set arbitrary number of rounds.",
"return",
"10"
] | [
41,
0
] | [
64,
13
] | python | en | ['en', 'en', 'en'] | True |
miller_rabin_primality_testing | (n, k) | Calculates whether n is composite (which is always correct) or prime
(which theoretically is incorrect with error probability 4**-k), by
applying Miller-Rabin primality testing.
For reference and implementation example, see:
https://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test
:param n: Integer to be tested for primality.
:type n: int
:param k: Number of rounds (witnesses) of Miller-Rabin testing.
:type k: int
:return: False if the number is composite, True if it's probably prime.
:rtype: bool
| Calculates whether n is composite (which is always correct) or prime
(which theoretically is incorrect with error probability 4**-k), by
applying Miller-Rabin primality testing. | def miller_rabin_primality_testing(n, k):
"""Calculates whether n is composite (which is always correct) or prime
(which theoretically is incorrect with error probability 4**-k), by
applying Miller-Rabin primality testing.
For reference and implementation example, see:
https://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test
:param n: Integer to be tested for primality.
:type n: int
:param k: Number of rounds (witnesses) of Miller-Rabin testing.
:type k: int
:return: False if the number is composite, True if it's probably prime.
:rtype: bool
"""
# prevent potential infinite loop when d = 0
if n < 2:
return False
# Decompose (n - 1) to write it as (2 ** r) * d
# While d is even, divide it by 2 and increase the exponent.
d = n - 1
r = 0
while not (d & 1):
r += 1
d >>= 1
# Test k witnesses.
for _ in range(k):
# Generate random integer a, where 2 <= a <= (n - 2)
a = rsa.randnum.randint(n - 3) + 1
x = pow(a, d, n)
if x == 1 or x == n - 1:
continue
for _ in range(r - 1):
x = pow(x, 2, n)
if x == 1:
# n is composite.
return False
if x == n - 1:
# Exit inner loop and continue with next witness.
break
else:
# If loop doesn't break, n is composite.
return False
return True | [
"def",
"miller_rabin_primality_testing",
"(",
"n",
",",
"k",
")",
":",
"# prevent potential infinite loop when d = 0",
"if",
"n",
"<",
"2",
":",
"return",
"False",
"# Decompose (n - 1) to write it as (2 ** r) * d",
"# While d is even, divide it by 2 and increase the exponent.",
"d",
"=",
"n",
"-",
"1",
"r",
"=",
"0",
"while",
"not",
"(",
"d",
"&",
"1",
")",
":",
"r",
"+=",
"1",
"d",
">>=",
"1",
"# Test k witnesses.",
"for",
"_",
"in",
"range",
"(",
"k",
")",
":",
"# Generate random integer a, where 2 <= a <= (n - 2)",
"a",
"=",
"rsa",
".",
"randnum",
".",
"randint",
"(",
"n",
"-",
"3",
")",
"+",
"1",
"x",
"=",
"pow",
"(",
"a",
",",
"d",
",",
"n",
")",
"if",
"x",
"==",
"1",
"or",
"x",
"==",
"n",
"-",
"1",
":",
"continue",
"for",
"_",
"in",
"range",
"(",
"r",
"-",
"1",
")",
":",
"x",
"=",
"pow",
"(",
"x",
",",
"2",
",",
"n",
")",
"if",
"x",
"==",
"1",
":",
"# n is composite.",
"return",
"False",
"if",
"x",
"==",
"n",
"-",
"1",
":",
"# Exit inner loop and continue with next witness.",
"break",
"else",
":",
"# If loop doesn't break, n is composite.",
"return",
"False",
"return",
"True"
] | [
67,
0
] | [
117,
15
] | python | en | ['en', 'en', 'en'] | True |
is_prime | (number) | Returns True if the number is prime, and False otherwise.
>>> is_prime(2)
True
>>> is_prime(42)
False
>>> is_prime(41)
True
| Returns True if the number is prime, and False otherwise. | def is_prime(number):
"""Returns True if the number is prime, and False otherwise.
>>> is_prime(2)
True
>>> is_prime(42)
False
>>> is_prime(41)
True
"""
# Check for small numbers.
if number < 10:
return number in {2, 3, 5, 7}
# Check for even numbers.
if not (number & 1):
return False
# Calculate minimum number of rounds.
k = get_primality_testing_rounds(number)
# Run primality testing with (minimum + 1) rounds.
return miller_rabin_primality_testing(number, k + 1) | [
"def",
"is_prime",
"(",
"number",
")",
":",
"# Check for small numbers.",
"if",
"number",
"<",
"10",
":",
"return",
"number",
"in",
"{",
"2",
",",
"3",
",",
"5",
",",
"7",
"}",
"# Check for even numbers.",
"if",
"not",
"(",
"number",
"&",
"1",
")",
":",
"return",
"False",
"# Calculate minimum number of rounds.",
"k",
"=",
"get_primality_testing_rounds",
"(",
"number",
")",
"# Run primality testing with (minimum + 1) rounds.",
"return",
"miller_rabin_primality_testing",
"(",
"number",
",",
"k",
"+",
"1",
")"
] | [
120,
0
] | [
143,
56
] | python | en | ['en', 'en', 'en'] | True |
getprime | (nbits) | Returns a prime number that can be stored in 'nbits' bits.
>>> p = getprime(128)
>>> is_prime(p-1)
False
>>> is_prime(p)
True
>>> is_prime(p+1)
False
>>> from rsa import common
>>> common.bit_size(p) == 128
True
| Returns a prime number that can be stored in 'nbits' bits. | def getprime(nbits):
"""Returns a prime number that can be stored in 'nbits' bits.
>>> p = getprime(128)
>>> is_prime(p-1)
False
>>> is_prime(p)
True
>>> is_prime(p+1)
False
>>> from rsa import common
>>> common.bit_size(p) == 128
True
"""
assert nbits > 3 # the loop wil hang on too small numbers
while True:
integer = rsa.randnum.read_random_odd_int(nbits)
# Test for primeness
if is_prime(integer):
return integer | [
"def",
"getprime",
"(",
"nbits",
")",
":",
"assert",
"nbits",
">",
"3",
"# the loop wil hang on too small numbers",
"while",
"True",
":",
"integer",
"=",
"rsa",
".",
"randnum",
".",
"read_random_odd_int",
"(",
"nbits",
")",
"# Test for primeness",
"if",
"is_prime",
"(",
"integer",
")",
":",
"return",
"integer"
] | [
146,
0
] | [
169,
26
] | python | en | ['en', 'en', 'en'] | True |
are_relatively_prime | (a, b) | Returns True if a and b are relatively prime, and False if they
are not.
>>> are_relatively_prime(2, 3)
True
>>> are_relatively_prime(2, 4)
False
| Returns True if a and b are relatively prime, and False if they
are not. | def are_relatively_prime(a, b):
"""Returns True if a and b are relatively prime, and False if they
are not.
>>> are_relatively_prime(2, 3)
True
>>> are_relatively_prime(2, 4)
False
"""
d = gcd(a, b)
return d == 1 | [
"def",
"are_relatively_prime",
"(",
"a",
",",
"b",
")",
":",
"d",
"=",
"gcd",
"(",
"a",
",",
"b",
")",
"return",
"d",
"==",
"1"
] | [
174,
0
] | [
185,
17
] | python | en | ['en', 'en', 'en'] | True |
AdminSite.check | (self, app_configs) |
Run the system checks on all ModelAdmins, except if they aren't
customized at all.
|
Run the system checks on all ModelAdmins, except if they aren't
customized at all.
| def check(self, app_configs):
"""
Run the system checks on all ModelAdmins, except if they aren't
customized at all.
"""
if app_configs is None:
app_configs = apps.get_app_configs()
app_configs = set(app_configs) # Speed up lookups below
errors = []
modeladmins = (o for o in self._registry.values() if o.__class__ is not ModelAdmin)
for modeladmin in modeladmins:
if modeladmin.model._meta.app_config in app_configs:
errors.extend(modeladmin.check())
return errors | [
"def",
"check",
"(",
"self",
",",
"app_configs",
")",
":",
"if",
"app_configs",
"is",
"None",
":",
"app_configs",
"=",
"apps",
".",
"get_app_configs",
"(",
")",
"app_configs",
"=",
"set",
"(",
"app_configs",
")",
"# Speed up lookups below",
"errors",
"=",
"[",
"]",
"modeladmins",
"=",
"(",
"o",
"for",
"o",
"in",
"self",
".",
"_registry",
".",
"values",
"(",
")",
"if",
"o",
".",
"__class__",
"is",
"not",
"ModelAdmin",
")",
"for",
"modeladmin",
"in",
"modeladmins",
":",
"if",
"modeladmin",
".",
"model",
".",
"_meta",
".",
"app_config",
"in",
"app_configs",
":",
"errors",
".",
"extend",
"(",
"modeladmin",
".",
"check",
"(",
")",
")",
"return",
"errors"
] | [
78,
4
] | [
92,
21
] | python | en | ['en', 'error', 'th'] | False |
AdminSite.register | (self, model_or_iterable, admin_class=None, **options) |
Register the given model(s) with the given admin class.
The model(s) should be Model classes, not instances.
If an admin class isn't given, use ModelAdmin (the default admin
options). If keyword arguments are given -- e.g., list_display --
apply them as options to the admin class.
If a model is already registered, raise AlreadyRegistered.
If a model is abstract, raise ImproperlyConfigured.
|
Register the given model(s) with the given admin class. | def register(self, model_or_iterable, admin_class=None, **options):
"""
Register the given model(s) with the given admin class.
The model(s) should be Model classes, not instances.
If an admin class isn't given, use ModelAdmin (the default admin
options). If keyword arguments are given -- e.g., list_display --
apply them as options to the admin class.
If a model is already registered, raise AlreadyRegistered.
If a model is abstract, raise ImproperlyConfigured.
"""
admin_class = admin_class or ModelAdmin
if isinstance(model_or_iterable, ModelBase):
model_or_iterable = [model_or_iterable]
for model in model_or_iterable:
if model._meta.abstract:
raise ImproperlyConfigured(
'The model %s is abstract, so it cannot be registered with admin.' % model.__name__
)
if model in self._registry:
registered_admin = str(self._registry[model])
msg = 'The model %s is already registered ' % model.__name__
if registered_admin.endswith('.ModelAdmin'):
# Most likely registered without a ModelAdmin subclass.
msg += 'in app %r.' % re.sub(r'\.ModelAdmin$', '', registered_admin)
else:
msg += 'with %r.' % registered_admin
raise AlreadyRegistered(msg)
# Ignore the registration if the model has been
# swapped out.
if not model._meta.swapped:
# If we got **options then dynamically construct a subclass of
# admin_class with those **options.
if options:
# For reasons I don't quite understand, without a __module__
# the created class appears to "live" in the wrong place,
# which causes issues later on.
options['__module__'] = __name__
admin_class = type("%sAdmin" % model.__name__, (admin_class,), options)
# Instantiate the admin class to save in the registry
self._registry[model] = admin_class(model, self) | [
"def",
"register",
"(",
"self",
",",
"model_or_iterable",
",",
"admin_class",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"admin_class",
"=",
"admin_class",
"or",
"ModelAdmin",
"if",
"isinstance",
"(",
"model_or_iterable",
",",
"ModelBase",
")",
":",
"model_or_iterable",
"=",
"[",
"model_or_iterable",
"]",
"for",
"model",
"in",
"model_or_iterable",
":",
"if",
"model",
".",
"_meta",
".",
"abstract",
":",
"raise",
"ImproperlyConfigured",
"(",
"'The model %s is abstract, so it cannot be registered with admin.'",
"%",
"model",
".",
"__name__",
")",
"if",
"model",
"in",
"self",
".",
"_registry",
":",
"registered_admin",
"=",
"str",
"(",
"self",
".",
"_registry",
"[",
"model",
"]",
")",
"msg",
"=",
"'The model %s is already registered '",
"%",
"model",
".",
"__name__",
"if",
"registered_admin",
".",
"endswith",
"(",
"'.ModelAdmin'",
")",
":",
"# Most likely registered without a ModelAdmin subclass.",
"msg",
"+=",
"'in app %r.'",
"%",
"re",
".",
"sub",
"(",
"r'\\.ModelAdmin$'",
",",
"''",
",",
"registered_admin",
")",
"else",
":",
"msg",
"+=",
"'with %r.'",
"%",
"registered_admin",
"raise",
"AlreadyRegistered",
"(",
"msg",
")",
"# Ignore the registration if the model has been",
"# swapped out.",
"if",
"not",
"model",
".",
"_meta",
".",
"swapped",
":",
"# If we got **options then dynamically construct a subclass of",
"# admin_class with those **options.",
"if",
"options",
":",
"# For reasons I don't quite understand, without a __module__",
"# the created class appears to \"live\" in the wrong place,",
"# which causes issues later on.",
"options",
"[",
"'__module__'",
"]",
"=",
"__name__",
"admin_class",
"=",
"type",
"(",
"\"%sAdmin\"",
"%",
"model",
".",
"__name__",
",",
"(",
"admin_class",
",",
")",
",",
"options",
")",
"# Instantiate the admin class to save in the registry",
"self",
".",
"_registry",
"[",
"model",
"]",
"=",
"admin_class",
"(",
"model",
",",
"self",
")"
] | [
94,
4
] | [
140,
64
] | python | en | ['en', 'error', 'th'] | False |
AdminSite.unregister | (self, model_or_iterable) |
Unregister the given model(s).
If a model isn't already registered, raise NotRegistered.
|
Unregister the given model(s). | def unregister(self, model_or_iterable):
"""
Unregister the given model(s).
If a model isn't already registered, raise NotRegistered.
"""
if isinstance(model_or_iterable, ModelBase):
model_or_iterable = [model_or_iterable]
for model in model_or_iterable:
if model not in self._registry:
raise NotRegistered('The model %s is not registered' % model.__name__)
del self._registry[model] | [
"def",
"unregister",
"(",
"self",
",",
"model_or_iterable",
")",
":",
"if",
"isinstance",
"(",
"model_or_iterable",
",",
"ModelBase",
")",
":",
"model_or_iterable",
"=",
"[",
"model_or_iterable",
"]",
"for",
"model",
"in",
"model_or_iterable",
":",
"if",
"model",
"not",
"in",
"self",
".",
"_registry",
":",
"raise",
"NotRegistered",
"(",
"'The model %s is not registered'",
"%",
"model",
".",
"__name__",
")",
"del",
"self",
".",
"_registry",
"[",
"model",
"]"
] | [
142,
4
] | [
153,
37
] | python | en | ['en', 'error', 'th'] | False |
AdminSite.is_registered | (self, model) |
Check if a model class is registered with this `AdminSite`.
|
Check if a model class is registered with this `AdminSite`.
| def is_registered(self, model):
"""
Check if a model class is registered with this `AdminSite`.
"""
return model in self._registry | [
"def",
"is_registered",
"(",
"self",
",",
"model",
")",
":",
"return",
"model",
"in",
"self",
".",
"_registry"
] | [
155,
4
] | [
159,
38
] | python | en | ['en', 'error', 'th'] | False |
AdminSite.add_action | (self, action, name=None) |
Register an action to be available globally.
|
Register an action to be available globally.
| def add_action(self, action, name=None):
"""
Register an action to be available globally.
"""
name = name or action.__name__
self._actions[name] = action
self._global_actions[name] = action | [
"def",
"add_action",
"(",
"self",
",",
"action",
",",
"name",
"=",
"None",
")",
":",
"name",
"=",
"name",
"or",
"action",
".",
"__name__",
"self",
".",
"_actions",
"[",
"name",
"]",
"=",
"action",
"self",
".",
"_global_actions",
"[",
"name",
"]",
"=",
"action"
] | [
161,
4
] | [
167,
43
] | python | en | ['en', 'error', 'th'] | False |
AdminSite.disable_action | (self, name) |
Disable a globally-registered action. Raise KeyError for invalid names.
|
Disable a globally-registered action. Raise KeyError for invalid names.
| def disable_action(self, name):
"""
Disable a globally-registered action. Raise KeyError for invalid names.
"""
del self._actions[name] | [
"def",
"disable_action",
"(",
"self",
",",
"name",
")",
":",
"del",
"self",
".",
"_actions",
"[",
"name",
"]"
] | [
169,
4
] | [
173,
31
] | python | en | ['en', 'error', 'th'] | False |
AdminSite.get_action | (self, name) |
Explicitly get a registered global action whether it's enabled or
not. Raise KeyError for invalid names.
|
Explicitly get a registered global action whether it's enabled or
not. Raise KeyError for invalid names.
| def get_action(self, name):
"""
Explicitly get a registered global action whether it's enabled or
not. Raise KeyError for invalid names.
"""
return self._global_actions[name] | [
"def",
"get_action",
"(",
"self",
",",
"name",
")",
":",
"return",
"self",
".",
"_global_actions",
"[",
"name",
"]"
] | [
175,
4
] | [
180,
41
] | python | en | ['en', 'error', 'th'] | False |
AdminSite.actions | (self) |
Get all the enabled actions as an iterable of (name, func).
|
Get all the enabled actions as an iterable of (name, func).
| def actions(self):
"""
Get all the enabled actions as an iterable of (name, func).
"""
return self._actions.items() | [
"def",
"actions",
"(",
"self",
")",
":",
"return",
"self",
".",
"_actions",
".",
"items",
"(",
")"
] | [
183,
4
] | [
187,
36
] | python | en | ['en', 'error', 'th'] | False |
AdminSite.has_permission | (self, request) |
Return True if the given HttpRequest has permission to view
*at least one* page in the admin site.
|
Return True if the given HttpRequest has permission to view
*at least one* page in the admin site.
| def has_permission(self, request):
"""
Return True if the given HttpRequest has permission to view
*at least one* page in the admin site.
"""
return request.user.is_active and request.user.is_staff | [
"def",
"has_permission",
"(",
"self",
",",
"request",
")",
":",
"return",
"request",
".",
"user",
".",
"is_active",
"and",
"request",
".",
"user",
".",
"is_staff"
] | [
189,
4
] | [
194,
63
] | python | en | ['en', 'error', 'th'] | False |
AdminSite.admin_view | (self, view, cacheable=False) |
Decorator to create an admin view attached to this ``AdminSite``. This
wraps the view and provides permission checking by calling
``self.has_permission``.
You'll want to use this from within ``AdminSite.get_urls()``:
class MyAdminSite(AdminSite):
def get_urls(self):
from django.urls import path
urls = super().get_urls()
urls += [
path('my_view/', self.admin_view(some_view))
]
return urls
By default, admin_views are marked non-cacheable using the
``never_cache`` decorator. If the view can be safely cached, set
cacheable=True.
|
Decorator to create an admin view attached to this ``AdminSite``. This
wraps the view and provides permission checking by calling
``self.has_permission``. | def admin_view(self, view, cacheable=False):
"""
Decorator to create an admin view attached to this ``AdminSite``. This
wraps the view and provides permission checking by calling
``self.has_permission``.
You'll want to use this from within ``AdminSite.get_urls()``:
class MyAdminSite(AdminSite):
def get_urls(self):
from django.urls import path
urls = super().get_urls()
urls += [
path('my_view/', self.admin_view(some_view))
]
return urls
By default, admin_views are marked non-cacheable using the
``never_cache`` decorator. If the view can be safely cached, set
cacheable=True.
"""
def inner(request, *args, **kwargs):
if not self.has_permission(request):
if request.path == reverse('admin:logout', current_app=self.name):
index_path = reverse('admin:index', current_app=self.name)
return HttpResponseRedirect(index_path)
# Inner import to prevent django.contrib.admin (app) from
# importing django.contrib.auth.models.User (unrelated model).
from django.contrib.auth.views import redirect_to_login
return redirect_to_login(
request.get_full_path(),
reverse('admin:login', current_app=self.name)
)
return view(request, *args, **kwargs)
if not cacheable:
inner = never_cache(inner)
# We add csrf_protect here so this function can be used as a utility
# function for any view, without having to repeat 'csrf_protect'.
if not getattr(view, 'csrf_exempt', False):
inner = csrf_protect(inner)
return update_wrapper(inner, view) | [
"def",
"admin_view",
"(",
"self",
",",
"view",
",",
"cacheable",
"=",
"False",
")",
":",
"def",
"inner",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"has_permission",
"(",
"request",
")",
":",
"if",
"request",
".",
"path",
"==",
"reverse",
"(",
"'admin:logout'",
",",
"current_app",
"=",
"self",
".",
"name",
")",
":",
"index_path",
"=",
"reverse",
"(",
"'admin:index'",
",",
"current_app",
"=",
"self",
".",
"name",
")",
"return",
"HttpResponseRedirect",
"(",
"index_path",
")",
"# Inner import to prevent django.contrib.admin (app) from",
"# importing django.contrib.auth.models.User (unrelated model).",
"from",
"django",
".",
"contrib",
".",
"auth",
".",
"views",
"import",
"redirect_to_login",
"return",
"redirect_to_login",
"(",
"request",
".",
"get_full_path",
"(",
")",
",",
"reverse",
"(",
"'admin:login'",
",",
"current_app",
"=",
"self",
".",
"name",
")",
")",
"return",
"view",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"if",
"not",
"cacheable",
":",
"inner",
"=",
"never_cache",
"(",
"inner",
")",
"# We add csrf_protect here so this function can be used as a utility",
"# function for any view, without having to repeat 'csrf_protect'.",
"if",
"not",
"getattr",
"(",
"view",
",",
"'csrf_exempt'",
",",
"False",
")",
":",
"inner",
"=",
"csrf_protect",
"(",
"inner",
")",
"return",
"update_wrapper",
"(",
"inner",
",",
"view",
")"
] | [
196,
4
] | [
238,
42
] | python | en | ['en', 'error', 'th'] | False |
AdminSite.each_context | (self, request) |
Return a dictionary of variables to put in the template context for
*every* page in the admin site.
For sites running on a subpath, use the SCRIPT_NAME value if site_url
hasn't been customized.
|
Return a dictionary of variables to put in the template context for
*every* page in the admin site. | def each_context(self, request):
"""
Return a dictionary of variables to put in the template context for
*every* page in the admin site.
For sites running on a subpath, use the SCRIPT_NAME value if site_url
hasn't been customized.
"""
script_name = request.META['SCRIPT_NAME']
site_url = script_name if self.site_url == '/' and script_name else self.site_url
return {
'site_title': self.site_title,
'site_header': self.site_header,
'site_url': site_url,
'has_permission': self.has_permission(request),
'available_apps': self.get_app_list(request),
'is_popup': False,
'is_nav_sidebar_enabled': self.enable_nav_sidebar,
} | [
"def",
"each_context",
"(",
"self",
",",
"request",
")",
":",
"script_name",
"=",
"request",
".",
"META",
"[",
"'SCRIPT_NAME'",
"]",
"site_url",
"=",
"script_name",
"if",
"self",
".",
"site_url",
"==",
"'/'",
"and",
"script_name",
"else",
"self",
".",
"site_url",
"return",
"{",
"'site_title'",
":",
"self",
".",
"site_title",
",",
"'site_header'",
":",
"self",
".",
"site_header",
",",
"'site_url'",
":",
"site_url",
",",
"'has_permission'",
":",
"self",
".",
"has_permission",
"(",
"request",
")",
",",
"'available_apps'",
":",
"self",
".",
"get_app_list",
"(",
"request",
")",
",",
"'is_popup'",
":",
"False",
",",
"'is_nav_sidebar_enabled'",
":",
"self",
".",
"enable_nav_sidebar",
",",
"}"
] | [
300,
4
] | [
318,
9
] | python | en | ['en', 'error', 'th'] | False |
AdminSite.password_change | (self, request, extra_context=None) |
Handle the "change password" task -- both form display and validation.
|
Handle the "change password" task -- both form display and validation.
| def password_change(self, request, extra_context=None):
"""
Handle the "change password" task -- both form display and validation.
"""
from django.contrib.admin.forms import AdminPasswordChangeForm
from django.contrib.auth.views import PasswordChangeView
url = reverse('admin:password_change_done', current_app=self.name)
defaults = {
'form_class': AdminPasswordChangeForm,
'success_url': url,
'extra_context': {**self.each_context(request), **(extra_context or {})},
}
if self.password_change_template is not None:
defaults['template_name'] = self.password_change_template
request.current_app = self.name
return PasswordChangeView.as_view(**defaults)(request) | [
"def",
"password_change",
"(",
"self",
",",
"request",
",",
"extra_context",
"=",
"None",
")",
":",
"from",
"django",
".",
"contrib",
".",
"admin",
".",
"forms",
"import",
"AdminPasswordChangeForm",
"from",
"django",
".",
"contrib",
".",
"auth",
".",
"views",
"import",
"PasswordChangeView",
"url",
"=",
"reverse",
"(",
"'admin:password_change_done'",
",",
"current_app",
"=",
"self",
".",
"name",
")",
"defaults",
"=",
"{",
"'form_class'",
":",
"AdminPasswordChangeForm",
",",
"'success_url'",
":",
"url",
",",
"'extra_context'",
":",
"{",
"*",
"*",
"self",
".",
"each_context",
"(",
"request",
")",
",",
"*",
"*",
"(",
"extra_context",
"or",
"{",
"}",
")",
"}",
",",
"}",
"if",
"self",
".",
"password_change_template",
"is",
"not",
"None",
":",
"defaults",
"[",
"'template_name'",
"]",
"=",
"self",
".",
"password_change_template",
"request",
".",
"current_app",
"=",
"self",
".",
"name",
"return",
"PasswordChangeView",
".",
"as_view",
"(",
"*",
"*",
"defaults",
")",
"(",
"request",
")"
] | [
320,
4
] | [
335,
62
] | python | en | ['en', 'error', 'th'] | False |
AdminSite.password_change_done | (self, request, extra_context=None) |
Display the "success" page after a password change.
|
Display the "success" page after a password change.
| def password_change_done(self, request, extra_context=None):
"""
Display the "success" page after a password change.
"""
from django.contrib.auth.views import PasswordChangeDoneView
defaults = {
'extra_context': {**self.each_context(request), **(extra_context or {})},
}
if self.password_change_done_template is not None:
defaults['template_name'] = self.password_change_done_template
request.current_app = self.name
return PasswordChangeDoneView.as_view(**defaults)(request) | [
"def",
"password_change_done",
"(",
"self",
",",
"request",
",",
"extra_context",
"=",
"None",
")",
":",
"from",
"django",
".",
"contrib",
".",
"auth",
".",
"views",
"import",
"PasswordChangeDoneView",
"defaults",
"=",
"{",
"'extra_context'",
":",
"{",
"*",
"*",
"self",
".",
"each_context",
"(",
"request",
")",
",",
"*",
"*",
"(",
"extra_context",
"or",
"{",
"}",
")",
"}",
",",
"}",
"if",
"self",
".",
"password_change_done_template",
"is",
"not",
"None",
":",
"defaults",
"[",
"'template_name'",
"]",
"=",
"self",
".",
"password_change_done_template",
"request",
".",
"current_app",
"=",
"self",
".",
"name",
"return",
"PasswordChangeDoneView",
".",
"as_view",
"(",
"*",
"*",
"defaults",
")",
"(",
"request",
")"
] | [
337,
4
] | [
348,
66
] | python | en | ['en', 'error', 'th'] | False |
AdminSite.i18n_javascript | (self, request, extra_context=None) |
Display the i18n JavaScript that the Django admin requires.
`extra_context` is unused but present for consistency with the other
admin views.
|
Display the i18n JavaScript that the Django admin requires. | def i18n_javascript(self, request, extra_context=None):
"""
Display the i18n JavaScript that the Django admin requires.
`extra_context` is unused but present for consistency with the other
admin views.
"""
return JavaScriptCatalog.as_view(packages=['django.contrib.admin'])(request) | [
"def",
"i18n_javascript",
"(",
"self",
",",
"request",
",",
"extra_context",
"=",
"None",
")",
":",
"return",
"JavaScriptCatalog",
".",
"as_view",
"(",
"packages",
"=",
"[",
"'django.contrib.admin'",
"]",
")",
"(",
"request",
")"
] | [
350,
4
] | [
357,
84
] | python | en | ['en', 'error', 'th'] | False |
AdminSite.logout | (self, request, extra_context=None) |
Log out the user for the given HttpRequest.
This should *not* assume the user is already logged in.
|
Log out the user for the given HttpRequest. | def logout(self, request, extra_context=None):
"""
Log out the user for the given HttpRequest.
This should *not* assume the user is already logged in.
"""
from django.contrib.auth.views import LogoutView
defaults = {
'extra_context': {
**self.each_context(request),
# Since the user isn't logged out at this point, the value of
# has_permission must be overridden.
'has_permission': False,
**(extra_context or {})
},
}
if self.logout_template is not None:
defaults['template_name'] = self.logout_template
request.current_app = self.name
return LogoutView.as_view(**defaults)(request) | [
"def",
"logout",
"(",
"self",
",",
"request",
",",
"extra_context",
"=",
"None",
")",
":",
"from",
"django",
".",
"contrib",
".",
"auth",
".",
"views",
"import",
"LogoutView",
"defaults",
"=",
"{",
"'extra_context'",
":",
"{",
"*",
"*",
"self",
".",
"each_context",
"(",
"request",
")",
",",
"# Since the user isn't logged out at this point, the value of",
"# has_permission must be overridden.",
"'has_permission'",
":",
"False",
",",
"*",
"*",
"(",
"extra_context",
"or",
"{",
"}",
")",
"}",
",",
"}",
"if",
"self",
".",
"logout_template",
"is",
"not",
"None",
":",
"defaults",
"[",
"'template_name'",
"]",
"=",
"self",
".",
"logout_template",
"request",
".",
"current_app",
"=",
"self",
".",
"name",
"return",
"LogoutView",
".",
"as_view",
"(",
"*",
"*",
"defaults",
")",
"(",
"request",
")"
] | [
360,
4
] | [
379,
54
] | python | en | ['en', 'error', 'th'] | False |
AdminSite.login | (self, request, extra_context=None) |
Display the login form for the given HttpRequest.
|
Display the login form for the given HttpRequest.
| def login(self, request, extra_context=None):
"""
Display the login form for the given HttpRequest.
"""
if request.method == 'GET' and self.has_permission(request):
# Already logged-in, redirect to admin index
index_path = reverse('admin:index', current_app=self.name)
return HttpResponseRedirect(index_path)
# Since this module gets imported in the application's root package,
# it cannot import models from other applications at the module level,
# and django.contrib.admin.forms eventually imports User.
from django.contrib.admin.forms import AdminAuthenticationForm
from django.contrib.auth.views import LoginView
context = {
**self.each_context(request),
'title': _('Log in'),
'app_path': request.get_full_path(),
'username': request.user.get_username(),
}
if (REDIRECT_FIELD_NAME not in request.GET and
REDIRECT_FIELD_NAME not in request.POST):
context[REDIRECT_FIELD_NAME] = reverse('admin:index', current_app=self.name)
context.update(extra_context or {})
defaults = {
'extra_context': context,
'authentication_form': self.login_form or AdminAuthenticationForm,
'template_name': self.login_template or 'admin/login.html',
}
request.current_app = self.name
return LoginView.as_view(**defaults)(request) | [
"def",
"login",
"(",
"self",
",",
"request",
",",
"extra_context",
"=",
"None",
")",
":",
"if",
"request",
".",
"method",
"==",
"'GET'",
"and",
"self",
".",
"has_permission",
"(",
"request",
")",
":",
"# Already logged-in, redirect to admin index",
"index_path",
"=",
"reverse",
"(",
"'admin:index'",
",",
"current_app",
"=",
"self",
".",
"name",
")",
"return",
"HttpResponseRedirect",
"(",
"index_path",
")",
"# Since this module gets imported in the application's root package,",
"# it cannot import models from other applications at the module level,",
"# and django.contrib.admin.forms eventually imports User.",
"from",
"django",
".",
"contrib",
".",
"admin",
".",
"forms",
"import",
"AdminAuthenticationForm",
"from",
"django",
".",
"contrib",
".",
"auth",
".",
"views",
"import",
"LoginView",
"context",
"=",
"{",
"*",
"*",
"self",
".",
"each_context",
"(",
"request",
")",
",",
"'title'",
":",
"_",
"(",
"'Log in'",
")",
",",
"'app_path'",
":",
"request",
".",
"get_full_path",
"(",
")",
",",
"'username'",
":",
"request",
".",
"user",
".",
"get_username",
"(",
")",
",",
"}",
"if",
"(",
"REDIRECT_FIELD_NAME",
"not",
"in",
"request",
".",
"GET",
"and",
"REDIRECT_FIELD_NAME",
"not",
"in",
"request",
".",
"POST",
")",
":",
"context",
"[",
"REDIRECT_FIELD_NAME",
"]",
"=",
"reverse",
"(",
"'admin:index'",
",",
"current_app",
"=",
"self",
".",
"name",
")",
"context",
".",
"update",
"(",
"extra_context",
"or",
"{",
"}",
")",
"defaults",
"=",
"{",
"'extra_context'",
":",
"context",
",",
"'authentication_form'",
":",
"self",
".",
"login_form",
"or",
"AdminAuthenticationForm",
",",
"'template_name'",
":",
"self",
".",
"login_template",
"or",
"'admin/login.html'",
",",
"}",
"request",
".",
"current_app",
"=",
"self",
".",
"name",
"return",
"LoginView",
".",
"as_view",
"(",
"*",
"*",
"defaults",
")",
"(",
"request",
")"
] | [
382,
4
] | [
413,
53
] | python | en | ['en', 'error', 'th'] | False |
AdminSite._build_app_dict | (self, request, label=None) |
Build the app dictionary. The optional `label` parameter filters models
of a specific app.
|
Build the app dictionary. The optional `label` parameter filters models
of a specific app.
| def _build_app_dict(self, request, label=None):
"""
Build the app dictionary. The optional `label` parameter filters models
of a specific app.
"""
app_dict = {}
if label:
models = {
m: m_a for m, m_a in self._registry.items()
if m._meta.app_label == label
}
else:
models = self._registry
for model, model_admin in models.items():
app_label = model._meta.app_label
has_module_perms = model_admin.has_module_permission(request)
if not has_module_perms:
continue
perms = model_admin.get_model_perms(request)
# Check whether user has any perm for this module.
# If so, add the module to the model_list.
if True not in perms.values():
continue
info = (app_label, model._meta.model_name)
model_dict = {
'name': capfirst(model._meta.verbose_name_plural),
'object_name': model._meta.object_name,
'perms': perms,
'admin_url': None,
'add_url': None,
}
if perms.get('change') or perms.get('view'):
model_dict['view_only'] = not perms.get('change')
try:
model_dict['admin_url'] = reverse('admin:%s_%s_changelist' % info, current_app=self.name)
except NoReverseMatch:
pass
if perms.get('add'):
try:
model_dict['add_url'] = reverse('admin:%s_%s_add' % info, current_app=self.name)
except NoReverseMatch:
pass
if app_label in app_dict:
app_dict[app_label]['models'].append(model_dict)
else:
app_dict[app_label] = {
'name': apps.get_app_config(app_label).verbose_name,
'app_label': app_label,
'app_url': reverse(
'admin:app_list',
kwargs={'app_label': app_label},
current_app=self.name,
),
'has_module_perms': has_module_perms,
'models': [model_dict],
}
if label:
return app_dict.get(label)
return app_dict | [
"def",
"_build_app_dict",
"(",
"self",
",",
"request",
",",
"label",
"=",
"None",
")",
":",
"app_dict",
"=",
"{",
"}",
"if",
"label",
":",
"models",
"=",
"{",
"m",
":",
"m_a",
"for",
"m",
",",
"m_a",
"in",
"self",
".",
"_registry",
".",
"items",
"(",
")",
"if",
"m",
".",
"_meta",
".",
"app_label",
"==",
"label",
"}",
"else",
":",
"models",
"=",
"self",
".",
"_registry",
"for",
"model",
",",
"model_admin",
"in",
"models",
".",
"items",
"(",
")",
":",
"app_label",
"=",
"model",
".",
"_meta",
".",
"app_label",
"has_module_perms",
"=",
"model_admin",
".",
"has_module_permission",
"(",
"request",
")",
"if",
"not",
"has_module_perms",
":",
"continue",
"perms",
"=",
"model_admin",
".",
"get_model_perms",
"(",
"request",
")",
"# Check whether user has any perm for this module.",
"# If so, add the module to the model_list.",
"if",
"True",
"not",
"in",
"perms",
".",
"values",
"(",
")",
":",
"continue",
"info",
"=",
"(",
"app_label",
",",
"model",
".",
"_meta",
".",
"model_name",
")",
"model_dict",
"=",
"{",
"'name'",
":",
"capfirst",
"(",
"model",
".",
"_meta",
".",
"verbose_name_plural",
")",
",",
"'object_name'",
":",
"model",
".",
"_meta",
".",
"object_name",
",",
"'perms'",
":",
"perms",
",",
"'admin_url'",
":",
"None",
",",
"'add_url'",
":",
"None",
",",
"}",
"if",
"perms",
".",
"get",
"(",
"'change'",
")",
"or",
"perms",
".",
"get",
"(",
"'view'",
")",
":",
"model_dict",
"[",
"'view_only'",
"]",
"=",
"not",
"perms",
".",
"get",
"(",
"'change'",
")",
"try",
":",
"model_dict",
"[",
"'admin_url'",
"]",
"=",
"reverse",
"(",
"'admin:%s_%s_changelist'",
"%",
"info",
",",
"current_app",
"=",
"self",
".",
"name",
")",
"except",
"NoReverseMatch",
":",
"pass",
"if",
"perms",
".",
"get",
"(",
"'add'",
")",
":",
"try",
":",
"model_dict",
"[",
"'add_url'",
"]",
"=",
"reverse",
"(",
"'admin:%s_%s_add'",
"%",
"info",
",",
"current_app",
"=",
"self",
".",
"name",
")",
"except",
"NoReverseMatch",
":",
"pass",
"if",
"app_label",
"in",
"app_dict",
":",
"app_dict",
"[",
"app_label",
"]",
"[",
"'models'",
"]",
".",
"append",
"(",
"model_dict",
")",
"else",
":",
"app_dict",
"[",
"app_label",
"]",
"=",
"{",
"'name'",
":",
"apps",
".",
"get_app_config",
"(",
"app_label",
")",
".",
"verbose_name",
",",
"'app_label'",
":",
"app_label",
",",
"'app_url'",
":",
"reverse",
"(",
"'admin:app_list'",
",",
"kwargs",
"=",
"{",
"'app_label'",
":",
"app_label",
"}",
",",
"current_app",
"=",
"self",
".",
"name",
",",
")",
",",
"'has_module_perms'",
":",
"has_module_perms",
",",
"'models'",
":",
"[",
"model_dict",
"]",
",",
"}",
"if",
"label",
":",
"return",
"app_dict",
".",
"get",
"(",
"label",
")",
"return",
"app_dict"
] | [
431,
4
] | [
497,
23
] | python | en | ['en', 'error', 'th'] | False |
AdminSite.get_app_list | (self, request) |
Return a sorted list of all the installed apps that have been
registered in this site.
|
Return a sorted list of all the installed apps that have been
registered in this site.
| def get_app_list(self, request):
"""
Return a sorted list of all the installed apps that have been
registered in this site.
"""
app_dict = self._build_app_dict(request)
# Sort the apps alphabetically.
app_list = sorted(app_dict.values(), key=lambda x: x['name'].lower())
# Sort the models alphabetically within each app.
for app in app_list:
app['models'].sort(key=lambda x: x['name'])
return app_list | [
"def",
"get_app_list",
"(",
"self",
",",
"request",
")",
":",
"app_dict",
"=",
"self",
".",
"_build_app_dict",
"(",
"request",
")",
"# Sort the apps alphabetically.",
"app_list",
"=",
"sorted",
"(",
"app_dict",
".",
"values",
"(",
")",
",",
"key",
"=",
"lambda",
"x",
":",
"x",
"[",
"'name'",
"]",
".",
"lower",
"(",
")",
")",
"# Sort the models alphabetically within each app.",
"for",
"app",
"in",
"app_list",
":",
"app",
"[",
"'models'",
"]",
".",
"sort",
"(",
"key",
"=",
"lambda",
"x",
":",
"x",
"[",
"'name'",
"]",
")",
"return",
"app_list"
] | [
499,
4
] | [
513,
23
] | python | en | ['en', 'error', 'th'] | False |
AdminSite.index | (self, request, extra_context=None) |
Display the main admin index page, which lists all of the installed
apps that have been registered in this site.
|
Display the main admin index page, which lists all of the installed
apps that have been registered in this site.
| def index(self, request, extra_context=None):
"""
Display the main admin index page, which lists all of the installed
apps that have been registered in this site.
"""
app_list = self.get_app_list(request)
context = {
**self.each_context(request),
'title': self.index_title,
'subtitle': None,
'app_list': app_list,
**(extra_context or {}),
}
request.current_app = self.name
return TemplateResponse(request, self.index_template or 'admin/index.html', context) | [
"def",
"index",
"(",
"self",
",",
"request",
",",
"extra_context",
"=",
"None",
")",
":",
"app_list",
"=",
"self",
".",
"get_app_list",
"(",
"request",
")",
"context",
"=",
"{",
"*",
"*",
"self",
".",
"each_context",
"(",
"request",
")",
",",
"'title'",
":",
"self",
".",
"index_title",
",",
"'subtitle'",
":",
"None",
",",
"'app_list'",
":",
"app_list",
",",
"*",
"*",
"(",
"extra_context",
"or",
"{",
"}",
")",
",",
"}",
"request",
".",
"current_app",
"=",
"self",
".",
"name",
"return",
"TemplateResponse",
"(",
"request",
",",
"self",
".",
"index_template",
"or",
"'admin/index.html'",
",",
"context",
")"
] | [
516,
4
] | [
533,
92
] | python | en | ['en', 'error', 'th'] | False |
_simple_domain_name_validator | (value) |
Validate that the given value contains no whitespaces to prevent common
typos.
|
Validate that the given value contains no whitespaces to prevent common
typos.
| def _simple_domain_name_validator(value):
"""
Validate that the given value contains no whitespaces to prevent common
typos.
"""
checks = ((s in value) for s in string.whitespace)
if any(checks):
raise ValidationError(
_("The domain name cannot contain any spaces or tabs."),
code='invalid',
) | [
"def",
"_simple_domain_name_validator",
"(",
"value",
")",
":",
"checks",
"=",
"(",
"(",
"s",
"in",
"value",
")",
"for",
"s",
"in",
"string",
".",
"whitespace",
")",
"if",
"any",
"(",
"checks",
")",
":",
"raise",
"ValidationError",
"(",
"_",
"(",
"\"The domain name cannot contain any spaces or tabs.\"",
")",
",",
"code",
"=",
"'invalid'",
",",
")"
] | [
11,
0
] | [
21,
9
] | python | en | ['en', 'error', 'th'] | False |
clear_site_cache | (sender, **kwargs) |
Clear the cache (if primed) each time a site is saved or deleted.
|
Clear the cache (if primed) each time a site is saved or deleted.
| def clear_site_cache(sender, **kwargs):
"""
Clear the cache (if primed) each time a site is saved or deleted.
"""
instance = kwargs['instance']
using = kwargs['using']
try:
del SITE_CACHE[instance.pk]
except KeyError:
pass
try:
del SITE_CACHE[Site.objects.using(using).get(pk=instance.pk).domain]
except (KeyError, Site.DoesNotExist):
pass | [
"def",
"clear_site_cache",
"(",
"sender",
",",
"*",
"*",
"kwargs",
")",
":",
"instance",
"=",
"kwargs",
"[",
"'instance'",
"]",
"using",
"=",
"kwargs",
"[",
"'using'",
"]",
"try",
":",
"del",
"SITE_CACHE",
"[",
"instance",
".",
"pk",
"]",
"except",
"KeyError",
":",
"pass",
"try",
":",
"del",
"SITE_CACHE",
"[",
"Site",
".",
"objects",
".",
"using",
"(",
"using",
")",
".",
"get",
"(",
"pk",
"=",
"instance",
".",
"pk",
")",
".",
"domain",
"]",
"except",
"(",
"KeyError",
",",
"Site",
".",
"DoesNotExist",
")",
":",
"pass"
] | [
102,
0
] | [
115,
12
] | python | en | ['en', 'error', 'th'] | False |
SiteManager.get_current | (self, request=None) |
Return the current Site based on the SITE_ID in the project's settings.
If SITE_ID isn't defined, return the site with domain matching
request.get_host(). The ``Site`` object is cached the first time it's
retrieved from the database.
|
Return the current Site based on the SITE_ID in the project's settings.
If SITE_ID isn't defined, return the site with domain matching
request.get_host(). The ``Site`` object is cached the first time it's
retrieved from the database.
| def get_current(self, request=None):
"""
Return the current Site based on the SITE_ID in the project's settings.
If SITE_ID isn't defined, return the site with domain matching
request.get_host(). The ``Site`` object is cached the first time it's
retrieved from the database.
"""
from django.conf import settings
if getattr(settings, 'SITE_ID', ''):
site_id = settings.SITE_ID
return self._get_site_by_id(site_id)
elif request:
return self._get_site_by_request(request)
raise ImproperlyConfigured(
"You're using the Django \"sites framework\" without having "
"set the SITE_ID setting. Create a site in your database and "
"set the SITE_ID setting or pass a request to "
"Site.objects.get_current() to fix this error."
) | [
"def",
"get_current",
"(",
"self",
",",
"request",
"=",
"None",
")",
":",
"from",
"django",
".",
"conf",
"import",
"settings",
"if",
"getattr",
"(",
"settings",
",",
"'SITE_ID'",
",",
"''",
")",
":",
"site_id",
"=",
"settings",
".",
"SITE_ID",
"return",
"self",
".",
"_get_site_by_id",
"(",
"site_id",
")",
"elif",
"request",
":",
"return",
"self",
".",
"_get_site_by_request",
"(",
"request",
")",
"raise",
"ImproperlyConfigured",
"(",
"\"You're using the Django \\\"sites framework\\\" without having \"",
"\"set the SITE_ID setting. Create a site in your database and \"",
"\"set the SITE_ID setting or pass a request to \"",
"\"Site.objects.get_current() to fix this error.\"",
")"
] | [
47,
4
] | [
66,
9
] | python | en | ['en', 'error', 'th'] | False |
SiteManager.clear_cache | (self) | Clear the ``Site`` object cache. | Clear the ``Site`` object cache. | def clear_cache(self):
"""Clear the ``Site`` object cache."""
global SITE_CACHE
SITE_CACHE = {} | [
"def",
"clear_cache",
"(",
"self",
")",
":",
"global",
"SITE_CACHE",
"SITE_CACHE",
"=",
"{",
"}"
] | [
68,
4
] | [
71,
23
] | python | en | ['en', 'en', 'en'] | True |
_hash_of_file | (path: str, algorithm: str) | Return the hash digest of a file. | Return the hash digest of a file. | def _hash_of_file(path: str, algorithm: str) -> str:
"""Return the hash digest of a file."""
with open(path, 'rb') as archive:
hash = hashlib.new(algorithm)
for chunk in read_chunks(archive):
hash.update(chunk)
return hash.hexdigest() | [
"def",
"_hash_of_file",
"(",
"path",
":",
"str",
",",
"algorithm",
":",
"str",
")",
"->",
"str",
":",
"with",
"open",
"(",
"path",
",",
"'rb'",
")",
"as",
"archive",
":",
"hash",
"=",
"hashlib",
".",
"new",
"(",
"algorithm",
")",
"for",
"chunk",
"in",
"read_chunks",
"(",
"archive",
")",
":",
"hash",
".",
"update",
"(",
"chunk",
")",
"return",
"hash",
".",
"hexdigest",
"(",
")"
] | [
48,
0
] | [
54,
27
] | python | en | ['en', 'en', 'en'] | True |
Storage.open | (self, name, mode='rb') | Retrieve the specified file from storage. | Retrieve the specified file from storage. | def open(self, name, mode='rb'):
"""Retrieve the specified file from storage."""
return self._open(name, mode) | [
"def",
"open",
"(",
"self",
",",
"name",
",",
"mode",
"=",
"'rb'",
")",
":",
"return",
"self",
".",
"_open",
"(",
"name",
",",
"mode",
")"
] | [
35,
4
] | [
37,
37
] | python | en | ['en', 'en', 'en'] | True |
Storage.save | (self, name, content, max_length=None) |
Save new content to the file specified by name. The content should be
a proper File object or any Python file-like object, ready to be read
from the beginning.
|
Save new content to the file specified by name. The content should be
a proper File object or any Python file-like object, ready to be read
from the beginning.
| def save(self, name, content, max_length=None):
"""
Save new content to the file specified by name. The content should be
a proper File object or any Python file-like object, ready to be read
from the beginning.
"""
# Get the proper name for the file, as it will actually be saved.
if name is None:
name = content.name
if not hasattr(content, 'chunks'):
content = File(content, name)
name = self.get_available_name(name, max_length=max_length)
return self._save(name, content) | [
"def",
"save",
"(",
"self",
",",
"name",
",",
"content",
",",
"max_length",
"=",
"None",
")",
":",
"# Get the proper name for the file, as it will actually be saved.",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"content",
".",
"name",
"if",
"not",
"hasattr",
"(",
"content",
",",
"'chunks'",
")",
":",
"content",
"=",
"File",
"(",
"content",
",",
"name",
")",
"name",
"=",
"self",
".",
"get_available_name",
"(",
"name",
",",
"max_length",
"=",
"max_length",
")",
"return",
"self",
".",
"_save",
"(",
"name",
",",
"content",
")"
] | [
39,
4
] | [
53,
40
] | python | en | ['en', 'error', 'th'] | False |
Storage.get_valid_name | (self, name) |
Return a filename, based on the provided filename, that's suitable for
use in the target storage system.
|
Return a filename, based on the provided filename, that's suitable for
use in the target storage system.
| def get_valid_name(self, name):
"""
Return a filename, based on the provided filename, that's suitable for
use in the target storage system.
"""
return get_valid_filename(name) | [
"def",
"get_valid_name",
"(",
"self",
",",
"name",
")",
":",
"return",
"get_valid_filename",
"(",
"name",
")"
] | [
57,
4
] | [
62,
39
] | python | en | ['en', 'error', 'th'] | False |
Storage.get_alternative_name | (self, file_root, file_ext) |
Return an alternative filename, by adding an underscore and a random 7
character alphanumeric string (before the file extension, if one
exists) to the filename.
|
Return an alternative filename, by adding an underscore and a random 7
character alphanumeric string (before the file extension, if one
exists) to the filename.
| def get_alternative_name(self, file_root, file_ext):
"""
Return an alternative filename, by adding an underscore and a random 7
character alphanumeric string (before the file extension, if one
exists) to the filename.
"""
return '%s_%s%s' % (file_root, get_random_string(7), file_ext) | [
"def",
"get_alternative_name",
"(",
"self",
",",
"file_root",
",",
"file_ext",
")",
":",
"return",
"'%s_%s%s'",
"%",
"(",
"file_root",
",",
"get_random_string",
"(",
"7",
")",
",",
"file_ext",
")"
] | [
64,
4
] | [
70,
70
] | python | en | ['en', 'error', 'th'] | False |
Storage.get_available_name | (self, name, max_length=None) |
Return a filename that's free on the target storage system and
available for new content to be written to.
|
Return a filename that's free on the target storage system and
available for new content to be written to.
| def get_available_name(self, name, max_length=None):
"""
Return a filename that's free on the target storage system and
available for new content to be written to.
"""
dir_name, file_name = os.path.split(name)
if '..' in pathlib.PurePath(dir_name).parts:
raise SuspiciousFileOperation("Detected path traversal attempt in '%s'" % dir_name)
validate_file_name(file_name)
file_root, file_ext = os.path.splitext(file_name)
# If the filename already exists, generate an alternative filename
# until it doesn't exist.
# Truncate original name if required, so the new filename does not
# exceed the max_length.
while self.exists(name) or (max_length and len(name) > max_length):
# file_ext includes the dot.
name = os.path.join(dir_name, self.get_alternative_name(file_root, file_ext))
if max_length is None:
continue
# Truncate file_root if max_length exceeded.
truncation = len(name) - max_length
if truncation > 0:
file_root = file_root[:-truncation]
# Entire file_root was truncated in attempt to find an available filename.
if not file_root:
raise SuspiciousFileOperation(
'Storage can not find an available filename for "%s". '
'Please make sure that the corresponding file field '
'allows sufficient "max_length".' % name
)
name = os.path.join(dir_name, self.get_alternative_name(file_root, file_ext))
return name | [
"def",
"get_available_name",
"(",
"self",
",",
"name",
",",
"max_length",
"=",
"None",
")",
":",
"dir_name",
",",
"file_name",
"=",
"os",
".",
"path",
".",
"split",
"(",
"name",
")",
"if",
"'..'",
"in",
"pathlib",
".",
"PurePath",
"(",
"dir_name",
")",
".",
"parts",
":",
"raise",
"SuspiciousFileOperation",
"(",
"\"Detected path traversal attempt in '%s'\"",
"%",
"dir_name",
")",
"validate_file_name",
"(",
"file_name",
")",
"file_root",
",",
"file_ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"file_name",
")",
"# If the filename already exists, generate an alternative filename",
"# until it doesn't exist.",
"# Truncate original name if required, so the new filename does not",
"# exceed the max_length.",
"while",
"self",
".",
"exists",
"(",
"name",
")",
"or",
"(",
"max_length",
"and",
"len",
"(",
"name",
")",
">",
"max_length",
")",
":",
"# file_ext includes the dot.",
"name",
"=",
"os",
".",
"path",
".",
"join",
"(",
"dir_name",
",",
"self",
".",
"get_alternative_name",
"(",
"file_root",
",",
"file_ext",
")",
")",
"if",
"max_length",
"is",
"None",
":",
"continue",
"# Truncate file_root if max_length exceeded.",
"truncation",
"=",
"len",
"(",
"name",
")",
"-",
"max_length",
"if",
"truncation",
">",
"0",
":",
"file_root",
"=",
"file_root",
"[",
":",
"-",
"truncation",
"]",
"# Entire file_root was truncated in attempt to find an available filename.",
"if",
"not",
"file_root",
":",
"raise",
"SuspiciousFileOperation",
"(",
"'Storage can not find an available filename for \"%s\". '",
"'Please make sure that the corresponding file field '",
"'allows sufficient \"max_length\".'",
"%",
"name",
")",
"name",
"=",
"os",
".",
"path",
".",
"join",
"(",
"dir_name",
",",
"self",
".",
"get_alternative_name",
"(",
"file_root",
",",
"file_ext",
")",
")",
"return",
"name"
] | [
72,
4
] | [
103,
19
] | python | en | ['en', 'error', 'th'] | False |
Storage.generate_filename | (self, filename) |
Validate the filename by calling get_valid_name() and return a filename
to be passed to the save() method.
|
Validate the filename by calling get_valid_name() and return a filename
to be passed to the save() method.
| def generate_filename(self, filename):
"""
Validate the filename by calling get_valid_name() and return a filename
to be passed to the save() method.
"""
# `filename` may include a path as returned by FileField.upload_to.
dirname, filename = os.path.split(filename)
if '..' in pathlib.PurePath(dirname).parts:
raise SuspiciousFileOperation("Detected path traversal attempt in '%s'" % dirname)
return os.path.normpath(os.path.join(dirname, self.get_valid_name(filename))) | [
"def",
"generate_filename",
"(",
"self",
",",
"filename",
")",
":",
"# `filename` may include a path as returned by FileField.upload_to.",
"dirname",
",",
"filename",
"=",
"os",
".",
"path",
".",
"split",
"(",
"filename",
")",
"if",
"'..'",
"in",
"pathlib",
".",
"PurePath",
"(",
"dirname",
")",
".",
"parts",
":",
"raise",
"SuspiciousFileOperation",
"(",
"\"Detected path traversal attempt in '%s'\"",
"%",
"dirname",
")",
"return",
"os",
".",
"path",
".",
"normpath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"dirname",
",",
"self",
".",
"get_valid_name",
"(",
"filename",
")",
")",
")"
] | [
105,
4
] | [
114,
85
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.