repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
google/pyu2f
pyu2f/model.py
ClientData.GetJson
def GetJson(self): """Returns JSON version of ClientData compatible with FIDO spec.""" # The U2F Raw Messages specification specifies that the challenge is encoded # with URL safe Base64 without padding encoding specified in RFC 4648. # Python does not natively support a paddingless encoding, so we sim...
python
def GetJson(self): """Returns JSON version of ClientData compatible with FIDO spec.""" # The U2F Raw Messages specification specifies that the challenge is encoded # with URL safe Base64 without padding encoding specified in RFC 4648. # Python does not natively support a paddingless encoding, so we sim...
[ "def", "GetJson", "(", "self", ")", ":", "# The U2F Raw Messages specification specifies that the challenge is encoded", "# with URL safe Base64 without padding encoding specified in RFC 4648.", "# Python does not natively support a paddingless encoding, so we simply", "# remove the padding from t...
Returns JSON version of ClientData compatible with FIDO spec.
[ "Returns", "JSON", "version", "of", "ClientData", "compatible", "with", "FIDO", "spec", "." ]
train
https://github.com/google/pyu2f/blob/8742d798027a21cbde0704aac0e93269bad2c3d0/pyu2f/model.py#L43-L55
google/pyu2f
pyu2f/hid/linux.py
GetValueLength
def GetValueLength(rd, pos): """Get value length for a key in rd. For a key at position pos in the Report Descriptor rd, return the length of the associated value. This supports both short and long format values. Args: rd: Report Descriptor pos: The position of the key in rd. Returns: (key_s...
python
def GetValueLength(rd, pos): """Get value length for a key in rd. For a key at position pos in the Report Descriptor rd, return the length of the associated value. This supports both short and long format values. Args: rd: Report Descriptor pos: The position of the key in rd. Returns: (key_s...
[ "def", "GetValueLength", "(", "rd", ",", "pos", ")", ":", "rd", "=", "bytearray", "(", "rd", ")", "key", "=", "rd", "[", "pos", "]", "if", "key", "==", "LONG_ITEM_ENCODING", ":", "# If the key is tagged as a long item (0xfe), then the format is", "# [key (1 byte)]...
Get value length for a key in rd. For a key at position pos in the Report Descriptor rd, return the length of the associated value. This supports both short and long format values. Args: rd: Report Descriptor pos: The position of the key in rd. Returns: (key_size, data_len) where key_size is t...
[ "Get", "value", "length", "for", "a", "key", "in", "rd", "." ]
train
https://github.com/google/pyu2f/blob/8742d798027a21cbde0704aac0e93269bad2c3d0/pyu2f/hid/linux.py#L35-L72
google/pyu2f
pyu2f/hid/linux.py
ReadLsbBytes
def ReadLsbBytes(rd, offset, value_size): """Reads value_size bytes from rd at offset, least signifcant byte first.""" encoding = None if value_size == 1: encoding = '<B' elif value_size == 2: encoding = '<H' elif value_size == 4: encoding = '<L' else: raise errors.HidError('Invalid value s...
python
def ReadLsbBytes(rd, offset, value_size): """Reads value_size bytes from rd at offset, least signifcant byte first.""" encoding = None if value_size == 1: encoding = '<B' elif value_size == 2: encoding = '<H' elif value_size == 4: encoding = '<L' else: raise errors.HidError('Invalid value s...
[ "def", "ReadLsbBytes", "(", "rd", ",", "offset", ",", "value_size", ")", ":", "encoding", "=", "None", "if", "value_size", "==", "1", ":", "encoding", "=", "'<B'", "elif", "value_size", "==", "2", ":", "encoding", "=", "'<H'", "elif", "value_size", "==",...
Reads value_size bytes from rd at offset, least signifcant byte first.
[ "Reads", "value_size", "bytes", "from", "rd", "at", "offset", "least", "signifcant", "byte", "first", "." ]
train
https://github.com/google/pyu2f/blob/8742d798027a21cbde0704aac0e93269bad2c3d0/pyu2f/hid/linux.py#L75-L89
google/pyu2f
pyu2f/hid/linux.py
ParseReportDescriptor
def ParseReportDescriptor(rd, desc): """Parse the binary report descriptor. Parse the binary report descriptor into a DeviceDescriptor object. Args: rd: The binary report descriptor desc: The DeviceDescriptor object to update with the results from parsing the descriptor. Returns: None "...
python
def ParseReportDescriptor(rd, desc): """Parse the binary report descriptor. Parse the binary report descriptor into a DeviceDescriptor object. Args: rd: The binary report descriptor desc: The DeviceDescriptor object to update with the results from parsing the descriptor. Returns: None "...
[ "def", "ParseReportDescriptor", "(", "rd", ",", "desc", ")", ":", "rd", "=", "bytearray", "(", "rd", ")", "pos", "=", "0", "report_count", "=", "None", "report_size", "=", "None", "usage_page", "=", "None", "usage", "=", "None", "while", "pos", "<", "l...
Parse the binary report descriptor. Parse the binary report descriptor into a DeviceDescriptor object. Args: rd: The binary report descriptor desc: The DeviceDescriptor object to update with the results from parsing the descriptor. Returns: None
[ "Parse", "the", "binary", "report", "descriptor", "." ]
train
https://github.com/google/pyu2f/blob/8742d798027a21cbde0704aac0e93269bad2c3d0/pyu2f/hid/linux.py#L96-L156
google/pyu2f
pyu2f/hid/linux.py
LinuxHidDevice.Write
def Write(self, packet): """See base class.""" out = bytearray([0] + packet) # Prepend the zero-byte (report ID) os.write(self.dev, out)
python
def Write(self, packet): """See base class.""" out = bytearray([0] + packet) # Prepend the zero-byte (report ID) os.write(self.dev, out)
[ "def", "Write", "(", "self", ",", "packet", ")", ":", "out", "=", "bytearray", "(", "[", "0", "]", "+", "packet", ")", "# Prepend the zero-byte (report ID)", "os", ".", "write", "(", "self", ".", "dev", ",", "out", ")" ]
See base class.
[ "See", "base", "class", "." ]
train
https://github.com/google/pyu2f/blob/8742d798027a21cbde0704aac0e93269bad2c3d0/pyu2f/hid/linux.py#L220-L223
google/pyu2f
pyu2f/hid/linux.py
LinuxHidDevice.Read
def Read(self): """See base class.""" raw_in = os.read(self.dev, self.GetInReportDataLength()) decoded_in = list(bytearray(raw_in)) return decoded_in
python
def Read(self): """See base class.""" raw_in = os.read(self.dev, self.GetInReportDataLength()) decoded_in = list(bytearray(raw_in)) return decoded_in
[ "def", "Read", "(", "self", ")", ":", "raw_in", "=", "os", ".", "read", "(", "self", ".", "dev", ",", "self", ".", "GetInReportDataLength", "(", ")", ")", "decoded_in", "=", "list", "(", "bytearray", "(", "raw_in", ")", ")", "return", "decoded_in" ]
See base class.
[ "See", "base", "class", "." ]
train
https://github.com/google/pyu2f/blob/8742d798027a21cbde0704aac0e93269bad2c3d0/pyu2f/hid/linux.py#L225-L229
google/pyu2f
pyu2f/hid/windows.py
FillDeviceAttributes
def FillDeviceAttributes(device, descriptor): """Fill out the attributes of the device. Fills the devices HidAttributes and product string into the descriptor. Args: device: A handle to the open device descriptor: The DeviceDescriptor to populate with the attributes. Returns: None Rais...
python
def FillDeviceAttributes(device, descriptor): """Fill out the attributes of the device. Fills the devices HidAttributes and product string into the descriptor. Args: device: A handle to the open device descriptor: The DeviceDescriptor to populate with the attributes. Returns: None Rais...
[ "def", "FillDeviceAttributes", "(", "device", ",", "descriptor", ")", ":", "attributes", "=", "HidAttributes", "(", ")", "result", "=", "hid", ".", "HidD_GetAttributes", "(", "device", ",", "ctypes", ".", "byref", "(", "attributes", ")", ")", "if", "not", ...
Fill out the attributes of the device. Fills the devices HidAttributes and product string into the descriptor. Args: device: A handle to the open device descriptor: The DeviceDescriptor to populate with the attributes. Returns: None Raises: WindowsError when unable to obtain attribut...
[ "Fill", "out", "the", "attributes", "of", "the", "device", "." ]
train
https://github.com/google/pyu2f/blob/8742d798027a21cbde0704aac0e93269bad2c3d0/pyu2f/hid/windows.py#L147-L178
google/pyu2f
pyu2f/hid/windows.py
FillDeviceCapabilities
def FillDeviceCapabilities(device, descriptor): """Fill out device capabilities. Fills the HidCapabilitites of the device into descriptor. Args: device: A handle to the open device descriptor: DeviceDescriptor to populate with the capabilities Returns: none Raises: WindowsError when ...
python
def FillDeviceCapabilities(device, descriptor): """Fill out device capabilities. Fills the HidCapabilitites of the device into descriptor. Args: device: A handle to the open device descriptor: DeviceDescriptor to populate with the capabilities Returns: none Raises: WindowsError when ...
[ "def", "FillDeviceCapabilities", "(", "device", ",", "descriptor", ")", ":", "preparsed_data", "=", "PHIDP_PREPARSED_DATA", "(", "0", ")", "ret", "=", "hid", ".", "HidD_GetPreparsedData", "(", "device", ",", "ctypes", ".", "byref", "(", "preparsed_data", ")", ...
Fill out device capabilities. Fills the HidCapabilitites of the device into descriptor. Args: device: A handle to the open device descriptor: DeviceDescriptor to populate with the capabilities Returns: none Raises: WindowsError when unable to obtain capabilitites.
[ "Fill", "out", "device", "capabilities", "." ]
train
https://github.com/google/pyu2f/blob/8742d798027a21cbde0704aac0e93269bad2c3d0/pyu2f/hid/windows.py#L181-L215
google/pyu2f
pyu2f/hid/windows.py
OpenDevice
def OpenDevice(path, enum=False): """Open the device and return a handle to it.""" desired_access = GENERIC_WRITE | GENERIC_READ share_mode = FILE_SHARE_READ | FILE_SHARE_WRITE if enum: desired_access = 0 h = kernel32.CreateFileA(path, desired_access, ...
python
def OpenDevice(path, enum=False): """Open the device and return a handle to it.""" desired_access = GENERIC_WRITE | GENERIC_READ share_mode = FILE_SHARE_READ | FILE_SHARE_WRITE if enum: desired_access = 0 h = kernel32.CreateFileA(path, desired_access, ...
[ "def", "OpenDevice", "(", "path", ",", "enum", "=", "False", ")", ":", "desired_access", "=", "GENERIC_WRITE", "|", "GENERIC_READ", "share_mode", "=", "FILE_SHARE_READ", "|", "FILE_SHARE_WRITE", "if", "enum", ":", "desired_access", "=", "0", "h", "=", "kernel3...
Open the device and return a handle to it.
[ "Open", "the", "device", "and", "return", "a", "handle", "to", "it", "." ]
train
https://github.com/google/pyu2f/blob/8742d798027a21cbde0704aac0e93269bad2c3d0/pyu2f/hid/windows.py#L225-L238
google/pyu2f
pyu2f/hid/windows.py
WindowsHidDevice.Enumerate
def Enumerate(): """See base class.""" hid_guid = GUID() hid.HidD_GetHidGuid(ctypes.byref(hid_guid)) devices = setupapi.SetupDiGetClassDevsA( ctypes.byref(hid_guid), None, None, 0x12) index = 0 interface_info = DeviceInterfaceData() interface_info.cbSize = ctypes.sizeof(DeviceInterf...
python
def Enumerate(): """See base class.""" hid_guid = GUID() hid.HidD_GetHidGuid(ctypes.byref(hid_guid)) devices = setupapi.SetupDiGetClassDevsA( ctypes.byref(hid_guid), None, None, 0x12) index = 0 interface_info = DeviceInterfaceData() interface_info.cbSize = ctypes.sizeof(DeviceInterf...
[ "def", "Enumerate", "(", ")", ":", "hid_guid", "=", "GUID", "(", ")", "hid", ".", "HidD_GetHidGuid", "(", "ctypes", ".", "byref", "(", "hid_guid", ")", ")", "devices", "=", "setupapi", ".", "SetupDiGetClassDevsA", "(", "ctypes", ".", "byref", "(", "hid_g...
See base class.
[ "See", "base", "class", "." ]
train
https://github.com/google/pyu2f/blob/8742d798027a21cbde0704aac0e93269bad2c3d0/pyu2f/hid/windows.py#L245-L317
google/pyu2f
pyu2f/hid/windows.py
WindowsHidDevice.Write
def Write(self, packet): """See base class.""" if len(packet) != self.GetOutReportDataLength(): raise errors.HidError("Packet length must match report data length.") packet_data = [0] + packet # Prepend the zero-byte (report ID) out = bytes(bytearray(packet_data)) num_written = wintypes.DWOR...
python
def Write(self, packet): """See base class.""" if len(packet) != self.GetOutReportDataLength(): raise errors.HidError("Packet length must match report data length.") packet_data = [0] + packet # Prepend the zero-byte (report ID) out = bytes(bytearray(packet_data)) num_written = wintypes.DWOR...
[ "def", "Write", "(", "self", ",", "packet", ")", ":", "if", "len", "(", "packet", ")", "!=", "self", ".", "GetOutReportDataLength", "(", ")", ":", "raise", "errors", ".", "HidError", "(", "\"Packet length must match report data length.\"", ")", "packet_data", ...
See base class.
[ "See", "base", "class", "." ]
train
https://github.com/google/pyu2f/blob/8742d798027a21cbde0704aac0e93269bad2c3d0/pyu2f/hid/windows.py#L334-L351
google/pyu2f
pyu2f/hid/windows.py
WindowsHidDevice.Read
def Read(self): """See base class.""" buf = ctypes.create_string_buffer(self.desc.internal_max_in_report_len) num_read = wintypes.DWORD() ret = kernel32.ReadFile( self.dev, buf, len(buf), ctypes.byref(num_read), None) if num_read.value != self.desc.internal_max_in_report_len: raise er...
python
def Read(self): """See base class.""" buf = ctypes.create_string_buffer(self.desc.internal_max_in_report_len) num_read = wintypes.DWORD() ret = kernel32.ReadFile( self.dev, buf, len(buf), ctypes.byref(num_read), None) if num_read.value != self.desc.internal_max_in_report_len: raise er...
[ "def", "Read", "(", "self", ")", ":", "buf", "=", "ctypes", ".", "create_string_buffer", "(", "self", ".", "desc", ".", "internal_max_in_report_len", ")", "num_read", "=", "wintypes", ".", "DWORD", "(", ")", "ret", "=", "kernel32", ".", "ReadFile", "(", ...
See base class.
[ "See", "base", "class", "." ]
train
https://github.com/google/pyu2f/blob/8742d798027a21cbde0704aac0e93269bad2c3d0/pyu2f/hid/windows.py#L353-L368
google/pyu2f
pyu2f/convenience/authenticator.py
CompositeAuthenticator.Authenticate
def Authenticate(self, app_id, challenge_data, print_callback=sys.stderr.write): """See base class.""" for authenticator in self.authenticators: if authenticator.IsAvailable(): result = authenticator.Authenticate(app_id, challenge_data...
python
def Authenticate(self, app_id, challenge_data, print_callback=sys.stderr.write): """See base class.""" for authenticator in self.authenticators: if authenticator.IsAvailable(): result = authenticator.Authenticate(app_id, challenge_data...
[ "def", "Authenticate", "(", "self", ",", "app_id", ",", "challenge_data", ",", "print_callback", "=", "sys", ".", "stderr", ".", "write", ")", ":", "for", "authenticator", "in", "self", ".", "authenticators", ":", "if", "authenticator", ".", "IsAvailable", "...
See base class.
[ "See", "base", "class", "." ]
train
https://github.com/google/pyu2f/blob/8742d798027a21cbde0704aac0e93269bad2c3d0/pyu2f/convenience/authenticator.py#L39-L49
google/pyu2f
pyu2f/u2f.py
GetLocalU2FInterface
def GetLocalU2FInterface(origin=socket.gethostname()): """Obtains a U2FInterface for the first valid local U2FHID device found.""" hid_transports = hidtransport.DiscoverLocalHIDU2FDevices() for t in hid_transports: try: return U2FInterface(security_key=hardware.SecurityKey(transport=t), ...
python
def GetLocalU2FInterface(origin=socket.gethostname()): """Obtains a U2FInterface for the first valid local U2FHID device found.""" hid_transports = hidtransport.DiscoverLocalHIDU2FDevices() for t in hid_transports: try: return U2FInterface(security_key=hardware.SecurityKey(transport=t), ...
[ "def", "GetLocalU2FInterface", "(", "origin", "=", "socket", ".", "gethostname", "(", ")", ")", ":", "hid_transports", "=", "hidtransport", ".", "DiscoverLocalHIDU2FDevices", "(", ")", "for", "t", "in", "hid_transports", ":", "try", ":", "return", "U2FInterface"...
Obtains a U2FInterface for the first valid local U2FHID device found.
[ "Obtains", "a", "U2FInterface", "for", "the", "first", "valid", "local", "U2FHID", "device", "found", "." ]
train
https://github.com/google/pyu2f/blob/8742d798027a21cbde0704aac0e93269bad2c3d0/pyu2f/u2f.py#L33-L45
google/pyu2f
pyu2f/u2f.py
U2FInterface.Register
def Register(self, app_id, challenge, registered_keys): """Registers app_id with the security key. Executes the U2F registration flow with the security key. Args: app_id: The app_id to register the security key against. challenge: Server challenge passed to the security key. registered_k...
python
def Register(self, app_id, challenge, registered_keys): """Registers app_id with the security key. Executes the U2F registration flow with the security key. Args: app_id: The app_id to register the security key against. challenge: Server challenge passed to the security key. registered_k...
[ "def", "Register", "(", "self", ",", "app_id", ",", "challenge", ",", "registered_keys", ")", ":", "client_data", "=", "model", ".", "ClientData", "(", "model", ".", "ClientData", ".", "TYP_REGISTRATION", ",", "challenge", ",", "self", ".", "origin", ")", ...
Registers app_id with the security key. Executes the U2F registration flow with the security key. Args: app_id: The app_id to register the security key against. challenge: Server challenge passed to the security key. registered_keys: List of keys already registered for this app_id+user. ...
[ "Registers", "app_id", "with", "the", "security", "key", "." ]
train
https://github.com/google/pyu2f/blob/8742d798027a21cbde0704aac0e93269bad2c3d0/pyu2f/u2f.py#L74-L129
google/pyu2f
pyu2f/u2f.py
U2FInterface.Authenticate
def Authenticate(self, app_id, challenge, registered_keys): """Authenticates app_id with the security key. Executes the U2F authentication/signature flow with the security key. Args: app_id: The app_id to register the security key against. challenge: Server challenge passed to the security key...
python
def Authenticate(self, app_id, challenge, registered_keys): """Authenticates app_id with the security key. Executes the U2F authentication/signature flow with the security key. Args: app_id: The app_id to register the security key against. challenge: Server challenge passed to the security key...
[ "def", "Authenticate", "(", "self", ",", "app_id", ",", "challenge", ",", "registered_keys", ")", ":", "client_data", "=", "model", ".", "ClientData", "(", "model", ".", "ClientData", ".", "TYP_AUTHENTICATION", ",", "challenge", ",", "self", ".", "origin", "...
Authenticates app_id with the security key. Executes the U2F authentication/signature flow with the security key. Args: app_id: The app_id to register the security key against. challenge: Server challenge passed to the security key as a bytes object. registered_keys: List of keys already reg...
[ "Authenticates", "app_id", "with", "the", "security", "key", "." ]
train
https://github.com/google/pyu2f/blob/8742d798027a21cbde0704aac0e93269bad2c3d0/pyu2f/u2f.py#L131-L178
google/pyu2f
pyu2f/hardware.py
SecurityKey.CmdRegister
def CmdRegister(self, challenge_param, app_param): """Register security key. Ask the security key to register with a particular origin & client. Args: challenge_param: Arbitrary 32 byte challenge string. app_param: Arbitrary 32 byte applciation parameter. Returns: A binary structure...
python
def CmdRegister(self, challenge_param, app_param): """Register security key. Ask the security key to register with a particular origin & client. Args: challenge_param: Arbitrary 32 byte challenge string. app_param: Arbitrary 32 byte applciation parameter. Returns: A binary structure...
[ "def", "CmdRegister", "(", "self", ",", "challenge_param", ",", "app_param", ")", ":", "self", ".", "logger", ".", "debug", "(", "'CmdRegister'", ")", "if", "len", "(", "challenge_param", ")", "!=", "32", "or", "len", "(", "app_param", ")", "!=", "32", ...
Register security key. Ask the security key to register with a particular origin & client. Args: challenge_param: Arbitrary 32 byte challenge string. app_param: Arbitrary 32 byte applciation parameter. Returns: A binary structure containing the key handle, attestation, and a signa...
[ "Register", "security", "key", "." ]
train
https://github.com/google/pyu2f/blob/8742d798027a21cbde0704aac0e93269bad2c3d0/pyu2f/hardware.py#L38-L69
google/pyu2f
pyu2f/hardware.py
SecurityKey.CmdAuthenticate
def CmdAuthenticate(self, challenge_param, app_param, key_handle, check_only=False): """Attempt to obtain an authentication signature. Ask the security key to sign a challenge for a particular key handle in order to aut...
python
def CmdAuthenticate(self, challenge_param, app_param, key_handle, check_only=False): """Attempt to obtain an authentication signature. Ask the security key to sign a challenge for a particular key handle in order to aut...
[ "def", "CmdAuthenticate", "(", "self", ",", "challenge_param", ",", "app_param", ",", "key_handle", ",", "check_only", "=", "False", ")", ":", "self", ".", "logger", ".", "debug", "(", "'CmdAuthenticate'", ")", "if", "len", "(", "challenge_param", ")", "!=",...
Attempt to obtain an authentication signature. Ask the security key to sign a challenge for a particular key handle in order to authenticate the user. Args: challenge_param: SHA-256 hash of client_data object as a bytes object. app_param: SHA-256 hash of the app id as a bytes object....
[ "Attempt", "to", "obtain", "an", "authentication", "signature", "." ]
train
https://github.com/google/pyu2f/blob/8742d798027a21cbde0704aac0e93269bad2c3d0/pyu2f/hardware.py#L71-L112
google/pyu2f
pyu2f/hardware.py
SecurityKey.CmdVersion
def CmdVersion(self): """Obtain the version of the device and test transport format. Obtains the version of the device and determines whether to use ISO 7816-4 or the U2f variant. This function should be called at least once before CmdAuthenticate or CmdRegister to make sure the object is using the ...
python
def CmdVersion(self): """Obtain the version of the device and test transport format. Obtains the version of the device and determines whether to use ISO 7816-4 or the U2f variant. This function should be called at least once before CmdAuthenticate or CmdRegister to make sure the object is using the ...
[ "def", "CmdVersion", "(", "self", ")", ":", "self", ".", "logger", ".", "debug", "(", "'CmdVersion'", ")", "response", "=", "self", ".", "InternalSendApdu", "(", "apdu", ".", "CommandApdu", "(", "0", ",", "apdu", ".", "CMD_VERSION", ",", "0x00", ",", "...
Obtain the version of the device and test transport format. Obtains the version of the device and determines whether to use ISO 7816-4 or the U2f variant. This function should be called at least once before CmdAuthenticate or CmdRegister to make sure the object is using the proper transport for the de...
[ "Obtain", "the", "version", "of", "the", "device", "and", "test", "transport", "format", "." ]
train
https://github.com/google/pyu2f/blob/8742d798027a21cbde0704aac0e93269bad2c3d0/pyu2f/hardware.py#L114-L132
google/pyu2f
pyu2f/hardware.py
SecurityKey.InternalSendApdu
def InternalSendApdu(self, apdu_to_send): """Send an APDU to the device. Sends an APDU to the device, possibly falling back to the legacy encoding format that is not ISO7816-4 compatible. Args: apdu_to_send: The CommandApdu object to send Returns: The ResponseApdu object constructed o...
python
def InternalSendApdu(self, apdu_to_send): """Send an APDU to the device. Sends an APDU to the device, possibly falling back to the legacy encoding format that is not ISO7816-4 compatible. Args: apdu_to_send: The CommandApdu object to send Returns: The ResponseApdu object constructed o...
[ "def", "InternalSendApdu", "(", "self", ",", "apdu_to_send", ")", ":", "response", "=", "None", "if", "not", "self", ".", "use_legacy_format", ":", "response", "=", "apdu", ".", "ResponseApdu", "(", "self", ".", "transport", ".", "SendMsgBytes", "(", "apdu_t...
Send an APDU to the device. Sends an APDU to the device, possibly falling back to the legacy encoding format that is not ISO7816-4 compatible. Args: apdu_to_send: The CommandApdu object to send Returns: The ResponseApdu object constructed out of the devices reply.
[ "Send", "an", "APDU", "to", "the", "device", "." ]
train
https://github.com/google/pyu2f/blob/8742d798027a21cbde0704aac0e93269bad2c3d0/pyu2f/hardware.py#L146-L170
google/pyu2f
pyu2f/hid/macos.py
GetDeviceIntProperty
def GetDeviceIntProperty(dev_ref, key): """Reads int property from the HID device.""" cf_key = CFStr(key) type_ref = iokit.IOHIDDeviceGetProperty(dev_ref, cf_key) cf.CFRelease(cf_key) if not type_ref: return None if cf.CFGetTypeID(type_ref) != cf.CFNumberGetTypeID(): raise errors.OsHidError('Expect...
python
def GetDeviceIntProperty(dev_ref, key): """Reads int property from the HID device.""" cf_key = CFStr(key) type_ref = iokit.IOHIDDeviceGetProperty(dev_ref, cf_key) cf.CFRelease(cf_key) if not type_ref: return None if cf.CFGetTypeID(type_ref) != cf.CFNumberGetTypeID(): raise errors.OsHidError('Expect...
[ "def", "GetDeviceIntProperty", "(", "dev_ref", ",", "key", ")", ":", "cf_key", "=", "CFStr", "(", "key", ")", "type_ref", "=", "iokit", ".", "IOHIDDeviceGetProperty", "(", "dev_ref", ",", "cf_key", ")", "cf", ".", "CFRelease", "(", "cf_key", ")", "if", "...
Reads int property from the HID device.
[ "Reads", "int", "property", "from", "the", "HID", "device", "." ]
train
https://github.com/google/pyu2f/blob/8742d798027a21cbde0704aac0e93269bad2c3d0/pyu2f/hid/macos.py#L194-L212
google/pyu2f
pyu2f/hid/macos.py
GetDeviceStringProperty
def GetDeviceStringProperty(dev_ref, key): """Reads string property from the HID device.""" cf_key = CFStr(key) type_ref = iokit.IOHIDDeviceGetProperty(dev_ref, cf_key) cf.CFRelease(cf_key) if not type_ref: return None if cf.CFGetTypeID(type_ref) != cf.CFStringGetTypeID(): raise errors.OsHidError('...
python
def GetDeviceStringProperty(dev_ref, key): """Reads string property from the HID device.""" cf_key = CFStr(key) type_ref = iokit.IOHIDDeviceGetProperty(dev_ref, cf_key) cf.CFRelease(cf_key) if not type_ref: return None if cf.CFGetTypeID(type_ref) != cf.CFStringGetTypeID(): raise errors.OsHidError('...
[ "def", "GetDeviceStringProperty", "(", "dev_ref", ",", "key", ")", ":", "cf_key", "=", "CFStr", "(", "key", ")", "type_ref", "=", "iokit", ".", "IOHIDDeviceGetProperty", "(", "dev_ref", ",", "cf_key", ")", "cf", ".", "CFRelease", "(", "cf_key", ")", "if", ...
Reads string property from the HID device.
[ "Reads", "string", "property", "from", "the", "HID", "device", "." ]
train
https://github.com/google/pyu2f/blob/8742d798027a21cbde0704aac0e93269bad2c3d0/pyu2f/hid/macos.py#L215-L234
google/pyu2f
pyu2f/hid/macos.py
GetDevicePath
def GetDevicePath(device_handle): """Obtains the unique path for the device. Args: device_handle: reference to the device Returns: A unique path for the device, obtained from the IO Registry """ # Obtain device path from IO Registry io_service_obj = iokit.IOHIDDeviceGetService(device_handle) st...
python
def GetDevicePath(device_handle): """Obtains the unique path for the device. Args: device_handle: reference to the device Returns: A unique path for the device, obtained from the IO Registry """ # Obtain device path from IO Registry io_service_obj = iokit.IOHIDDeviceGetService(device_handle) st...
[ "def", "GetDevicePath", "(", "device_handle", ")", ":", "# Obtain device path from IO Registry", "io_service_obj", "=", "iokit", ".", "IOHIDDeviceGetService", "(", "device_handle", ")", "str_buffer", "=", "ctypes", ".", "create_string_buffer", "(", "DEVICE_PATH_BUFFER_SIZE"...
Obtains the unique path for the device. Args: device_handle: reference to the device Returns: A unique path for the device, obtained from the IO Registry
[ "Obtains", "the", "unique", "path", "for", "the", "device", "." ]
train
https://github.com/google/pyu2f/blob/8742d798027a21cbde0704aac0e93269bad2c3d0/pyu2f/hid/macos.py#L237-L252
google/pyu2f
pyu2f/hid/macos.py
HidReadCallback
def HidReadCallback(read_queue, result, sender, report_type, report_id, report, report_length): """Handles incoming IN report from HID device.""" del result, sender, report_type, report_id # Unused by the callback function incoming_bytes = [report[i] for i in range(report_length)] read_que...
python
def HidReadCallback(read_queue, result, sender, report_type, report_id, report, report_length): """Handles incoming IN report from HID device.""" del result, sender, report_type, report_id # Unused by the callback function incoming_bytes = [report[i] for i in range(report_length)] read_que...
[ "def", "HidReadCallback", "(", "read_queue", ",", "result", ",", "sender", ",", "report_type", ",", "report_id", ",", "report", ",", "report_length", ")", ":", "del", "result", ",", "sender", ",", "report_type", ",", "report_id", "# Unused by the callback function...
Handles incoming IN report from HID device.
[ "Handles", "incoming", "IN", "report", "from", "HID", "device", "." ]
train
https://github.com/google/pyu2f/blob/8742d798027a21cbde0704aac0e93269bad2c3d0/pyu2f/hid/macos.py#L255-L261
google/pyu2f
pyu2f/hid/macos.py
DeviceReadThread
def DeviceReadThread(hid_device): """Binds a device to the thread's run loop, then starts the run loop. Args: hid_device: The MacOsHidDevice object The HID manager requires a run loop to handle Report reads. This thread function serves that purpose. """ # Schedule device events with run loop hid_de...
python
def DeviceReadThread(hid_device): """Binds a device to the thread's run loop, then starts the run loop. Args: hid_device: The MacOsHidDevice object The HID manager requires a run loop to handle Report reads. This thread function serves that purpose. """ # Schedule device events with run loop hid_de...
[ "def", "DeviceReadThread", "(", "hid_device", ")", ":", "# Schedule device events with run loop", "hid_device", ".", "run_loop_ref", "=", "cf", ".", "CFRunLoopGetCurrent", "(", ")", "if", "not", "hid_device", ".", "run_loop_ref", ":", "logger", ".", "error", "(", ...
Binds a device to the thread's run loop, then starts the run loop. Args: hid_device: The MacOsHidDevice object The HID manager requires a run loop to handle Report reads. This thread function serves that purpose.
[ "Binds", "a", "device", "to", "the", "thread", "s", "run", "loop", "then", "starts", "the", "run", "loop", "." ]
train
https://github.com/google/pyu2f/blob/8742d798027a21cbde0704aac0e93269bad2c3d0/pyu2f/hid/macos.py#L268-L304
google/pyu2f
pyu2f/hid/macos.py
MacOsHidDevice.Enumerate
def Enumerate(): """See base class.""" # Init a HID manager hid_mgr = iokit.IOHIDManagerCreate(None, None) if not hid_mgr: raise errors.OsHidError('Unable to obtain HID manager reference') iokit.IOHIDManagerSetDeviceMatching(hid_mgr, None) # Get devices from HID manager device_set_ref...
python
def Enumerate(): """See base class.""" # Init a HID manager hid_mgr = iokit.IOHIDManagerCreate(None, None) if not hid_mgr: raise errors.OsHidError('Unable to obtain HID manager reference') iokit.IOHIDManagerSetDeviceMatching(hid_mgr, None) # Get devices from HID manager device_set_ref...
[ "def", "Enumerate", "(", ")", ":", "# Init a HID manager", "hid_mgr", "=", "iokit", ".", "IOHIDManagerCreate", "(", "None", ",", "None", ")", "if", "not", "hid_mgr", ":", "raise", "errors", ".", "OsHidError", "(", "'Unable to obtain HID manager reference'", ")", ...
See base class.
[ "See", "base", "class", "." ]
train
https://github.com/google/pyu2f/blob/8742d798027a21cbde0704aac0e93269bad2c3d0/pyu2f/hid/macos.py#L314-L350
google/pyu2f
pyu2f/hid/macos.py
MacOsHidDevice.Write
def Write(self, packet): """See base class.""" report_id = 0 out_report_buffer = (ctypes.c_uint8 * self.internal_max_out_report_len)() out_report_buffer[:] = packet[:] result = iokit.IOHIDDeviceSetReport(self.device_handle, K_IO_HID_REPORT_TYPE_OUTPUT, ...
python
def Write(self, packet): """See base class.""" report_id = 0 out_report_buffer = (ctypes.c_uint8 * self.internal_max_out_report_len)() out_report_buffer[:] = packet[:] result = iokit.IOHIDDeviceSetReport(self.device_handle, K_IO_HID_REPORT_TYPE_OUTPUT, ...
[ "def", "Write", "(", "self", ",", "packet", ")", ":", "report_id", "=", "0", "out_report_buffer", "=", "(", "ctypes", ".", "c_uint8", "*", "self", ".", "internal_max_out_report_len", ")", "(", ")", "out_report_buffer", "[", ":", "]", "=", "packet", "[", ...
See base class.
[ "See", "base", "class", "." ]
train
https://github.com/google/pyu2f/blob/8742d798027a21cbde0704aac0e93269bad2c3d0/pyu2f/hid/macos.py#L414-L428
google/pyu2f
pyu2f/hid/macos.py
MacOsHidDevice.Read
def Read(self): """See base class.""" result = None while result is None: try: result = self.read_queue.get(timeout=60) except queue.Empty: continue return result
python
def Read(self): """See base class.""" result = None while result is None: try: result = self.read_queue.get(timeout=60) except queue.Empty: continue return result
[ "def", "Read", "(", "self", ")", ":", "result", "=", "None", "while", "result", "is", "None", ":", "try", ":", "result", "=", "self", ".", "read_queue", ".", "get", "(", "timeout", "=", "60", ")", "except", "queue", ".", "Empty", ":", "continue", "...
See base class.
[ "See", "base", "class", "." ]
train
https://github.com/google/pyu2f/blob/8742d798027a21cbde0704aac0e93269bad2c3d0/pyu2f/hid/macos.py#L430-L440
idlesign/django-admirarchy
admirarchy/utils.py
HierarchicalModelAdmin.change_view
def change_view(self, *args, **kwargs): """Renders detailed model edit page.""" Hierarchy.init_hierarchy(self) self.hierarchy.hook_change_view(self, args, kwargs) return super(HierarchicalModelAdmin, self).change_view(*args, **kwargs)
python
def change_view(self, *args, **kwargs): """Renders detailed model edit page.""" Hierarchy.init_hierarchy(self) self.hierarchy.hook_change_view(self, args, kwargs) return super(HierarchicalModelAdmin, self).change_view(*args, **kwargs)
[ "def", "change_view", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "Hierarchy", ".", "init_hierarchy", "(", "self", ")", "self", ".", "hierarchy", ".", "hook_change_view", "(", "self", ",", "args", ",", "kwargs", ")", "return", "su...
Renders detailed model edit page.
[ "Renders", "detailed", "model", "edit", "page", "." ]
train
https://github.com/idlesign/django-admirarchy/blob/723e4fd212fdebcc156492cb16b9d65356f5ca73/admirarchy/utils.py#L37-L43
idlesign/django-admirarchy
admirarchy/utils.py
HierarchicalModelAdmin.action_checkbox
def action_checkbox(self, obj): """Renders checkboxes. Disable checkbox for parent item navigation link. """ if getattr(obj, Hierarchy.UPPER_LEVEL_MODEL_ATTR, False): return '' return super(HierarchicalModelAdmin, self).action_checkbox(obj)
python
def action_checkbox(self, obj): """Renders checkboxes. Disable checkbox for parent item navigation link. """ if getattr(obj, Hierarchy.UPPER_LEVEL_MODEL_ATTR, False): return '' return super(HierarchicalModelAdmin, self).action_checkbox(obj)
[ "def", "action_checkbox", "(", "self", ",", "obj", ")", ":", "if", "getattr", "(", "obj", ",", "Hierarchy", ".", "UPPER_LEVEL_MODEL_ATTR", ",", "False", ")", ":", "return", "''", "return", "super", "(", "HierarchicalModelAdmin", ",", "self", ")", ".", "act...
Renders checkboxes. Disable checkbox for parent item navigation link.
[ "Renders", "checkboxes", "." ]
train
https://github.com/idlesign/django-admirarchy/blob/723e4fd212fdebcc156492cb16b9d65356f5ca73/admirarchy/utils.py#L45-L54
idlesign/django-admirarchy
admirarchy/utils.py
HierarchicalModelAdmin.hierarchy_nav
def hierarchy_nav(self, obj): """Renders hierarchy navigation elements (folders).""" result_repr = '' # For items without children. ch_count = getattr(obj, Hierarchy.CHILD_COUNT_MODEL_ATTR, 0) is_parent_link = getattr(obj, Hierarchy.UPPER_LEVEL_MODEL_ATTR, False) if is_parent...
python
def hierarchy_nav(self, obj): """Renders hierarchy navigation elements (folders).""" result_repr = '' # For items without children. ch_count = getattr(obj, Hierarchy.CHILD_COUNT_MODEL_ATTR, 0) is_parent_link = getattr(obj, Hierarchy.UPPER_LEVEL_MODEL_ATTR, False) if is_parent...
[ "def", "hierarchy_nav", "(", "self", ",", "obj", ")", ":", "result_repr", "=", "''", "# For items without children.", "ch_count", "=", "getattr", "(", "obj", ",", "Hierarchy", ".", "CHILD_COUNT_MODEL_ATTR", ",", "0", ")", "is_parent_link", "=", "getattr", "(", ...
Renders hierarchy navigation elements (folders).
[ "Renders", "hierarchy", "navigation", "elements", "(", "folders", ")", "." ]
train
https://github.com/idlesign/django-admirarchy/blob/723e4fd212fdebcc156492cb16b9d65356f5ca73/admirarchy/utils.py#L56-L92
idlesign/django-admirarchy
admirarchy/utils.py
HierarchicalChangeList.get_queryset
def get_queryset(self, request): """Constructs a query set. :param request: :return: """ self._hierarchy.hook_get_queryset(self, request) return super(HierarchicalChangeList, self).get_queryset(request)
python
def get_queryset(self, request): """Constructs a query set. :param request: :return: """ self._hierarchy.hook_get_queryset(self, request) return super(HierarchicalChangeList, self).get_queryset(request)
[ "def", "get_queryset", "(", "self", ",", "request", ")", ":", "self", ".", "_hierarchy", ".", "hook_get_queryset", "(", "self", ",", "request", ")", "return", "super", "(", "HierarchicalChangeList", ",", "self", ")", ".", "get_queryset", "(", "request", ")" ...
Constructs a query set. :param request: :return:
[ "Constructs", "a", "query", "set", "." ]
train
https://github.com/idlesign/django-admirarchy/blob/723e4fd212fdebcc156492cb16b9d65356f5ca73/admirarchy/utils.py#L121-L129
idlesign/django-admirarchy
admirarchy/utils.py
HierarchicalChangeList.get_results
def get_results(self, request): """Gets query set results. :param request: :return: """ super(HierarchicalChangeList, self).get_results(request) self._hierarchy.hook_get_results(self)
python
def get_results(self, request): """Gets query set results. :param request: :return: """ super(HierarchicalChangeList, self).get_results(request) self._hierarchy.hook_get_results(self)
[ "def", "get_results", "(", "self", ",", "request", ")", ":", "super", "(", "HierarchicalChangeList", ",", "self", ")", ".", "get_results", "(", "request", ")", "self", ".", "_hierarchy", ".", "hook_get_results", "(", "self", ")" ]
Gets query set results. :param request: :return:
[ "Gets", "query", "set", "results", "." ]
train
https://github.com/idlesign/django-admirarchy/blob/723e4fd212fdebcc156492cb16b9d65356f5ca73/admirarchy/utils.py#L131-L139
idlesign/django-admirarchy
admirarchy/utils.py
HierarchicalChangeList.check_field_exists
def check_field_exists(self, field_name): """Implements field exists check for debugging purposes. :param field_name: :return: """ if not settings.DEBUG: return try: self.lookup_opts.get_field(field_name) except FieldDoesNotExist as e: ...
python
def check_field_exists(self, field_name): """Implements field exists check for debugging purposes. :param field_name: :return: """ if not settings.DEBUG: return try: self.lookup_opts.get_field(field_name) except FieldDoesNotExist as e: ...
[ "def", "check_field_exists", "(", "self", ",", "field_name", ")", ":", "if", "not", "settings", ".", "DEBUG", ":", "return", "try", ":", "self", ".", "lookup_opts", ".", "get_field", "(", "field_name", ")", "except", "FieldDoesNotExist", "as", "e", ":", "r...
Implements field exists check for debugging purposes. :param field_name: :return:
[ "Implements", "field", "exists", "check", "for", "debugging", "purposes", "." ]
train
https://github.com/idlesign/django-admirarchy/blob/723e4fd212fdebcc156492cb16b9d65356f5ca73/admirarchy/utils.py#L141-L154
idlesign/django-admirarchy
admirarchy/utils.py
Hierarchy.init_hierarchy
def init_hierarchy(cls, model_admin): """Initializes model admin with hierarchy data.""" hierarchy = getattr(model_admin, 'hierarchy') if hierarchy: if not isinstance(hierarchy, Hierarchy): hierarchy = AdjacencyList() # For `True` and etc. TODO heuristics maybe. ...
python
def init_hierarchy(cls, model_admin): """Initializes model admin with hierarchy data.""" hierarchy = getattr(model_admin, 'hierarchy') if hierarchy: if not isinstance(hierarchy, Hierarchy): hierarchy = AdjacencyList() # For `True` and etc. TODO heuristics maybe. ...
[ "def", "init_hierarchy", "(", "cls", ",", "model_admin", ")", ":", "hierarchy", "=", "getattr", "(", "model_admin", ",", "'hierarchy'", ")", "if", "hierarchy", ":", "if", "not", "isinstance", "(", "hierarchy", ",", "Hierarchy", ")", ":", "hierarchy", "=", ...
Initializes model admin with hierarchy data.
[ "Initializes", "model", "admin", "with", "hierarchy", "data", "." ]
train
https://github.com/idlesign/django-admirarchy/blob/723e4fd212fdebcc156492cb16b9d65356f5ca73/admirarchy/utils.py#L169-L180
idlesign/django-admirarchy
admirarchy/utils.py
Hierarchy.get_pid_from_request
def get_pid_from_request(cls, changelist, request): """Gets parent ID from query string. :param changelist: :param request: :return: """ val = request.GET.get(cls.PARENT_ID_QS_PARAM, False) pid = val or None try: del changelist.params[cls.PAR...
python
def get_pid_from_request(cls, changelist, request): """Gets parent ID from query string. :param changelist: :param request: :return: """ val = request.GET.get(cls.PARENT_ID_QS_PARAM, False) pid = val or None try: del changelist.params[cls.PAR...
[ "def", "get_pid_from_request", "(", "cls", ",", "changelist", ",", "request", ")", ":", "val", "=", "request", ".", "GET", ".", "get", "(", "cls", ".", "PARENT_ID_QS_PARAM", ",", "False", ")", "pid", "=", "val", "or", "None", "try", ":", "del", "change...
Gets parent ID from query string. :param changelist: :param request: :return:
[ "Gets", "parent", "ID", "from", "query", "string", "." ]
train
https://github.com/idlesign/django-admirarchy/blob/723e4fd212fdebcc156492cb16b9d65356f5ca73/admirarchy/utils.py#L183-L199
idlesign/django-admirarchy
admirarchy/utils.py
AdjacencyList.hook_get_queryset
def hook_get_queryset(self, changelist, request): """Triggered by `ChangeList.get_queryset()`.""" changelist.check_field_exists(self.pid_field) self.pid = self.get_pid_from_request(changelist, request) changelist.params[self.pid_field] = self.pid
python
def hook_get_queryset(self, changelist, request): """Triggered by `ChangeList.get_queryset()`.""" changelist.check_field_exists(self.pid_field) self.pid = self.get_pid_from_request(changelist, request) changelist.params[self.pid_field] = self.pid
[ "def", "hook_get_queryset", "(", "self", ",", "changelist", ",", "request", ")", ":", "changelist", ".", "check_field_exists", "(", "self", ".", "pid_field", ")", "self", ".", "pid", "=", "self", ".", "get_pid_from_request", "(", "changelist", ",", "request", ...
Triggered by `ChangeList.get_queryset()`.
[ "Triggered", "by", "ChangeList", ".", "get_queryset", "()", "." ]
train
https://github.com/idlesign/django-admirarchy/blob/723e4fd212fdebcc156492cb16b9d65356f5ca73/admirarchy/utils.py#L231-L235
idlesign/django-admirarchy
admirarchy/utils.py
AdjacencyList.hook_get_results
def hook_get_results(self, changelist): """Triggered by `ChangeList.get_results()`.""" result_list = list(changelist.result_list) if self.pid: # Render to upper level link. parent = changelist.model.objects.get(pk=self.pid) parent = changelist.model(pk=getatt...
python
def hook_get_results(self, changelist): """Triggered by `ChangeList.get_results()`.""" result_list = list(changelist.result_list) if self.pid: # Render to upper level link. parent = changelist.model.objects.get(pk=self.pid) parent = changelist.model(pk=getatt...
[ "def", "hook_get_results", "(", "self", ",", "changelist", ")", ":", "result_list", "=", "list", "(", "changelist", ".", "result_list", ")", "if", "self", ".", "pid", ":", "# Render to upper level link.", "parent", "=", "changelist", ".", "model", ".", "object...
Triggered by `ChangeList.get_results()`.
[ "Triggered", "by", "ChangeList", ".", "get_results", "()", "." ]
train
https://github.com/idlesign/django-admirarchy/blob/723e4fd212fdebcc156492cb16b9d65356f5ca73/admirarchy/utils.py#L237-L267
idlesign/django-admirarchy
admirarchy/utils.py
NestedSet.hook_get_queryset
def hook_get_queryset(self, changelist, request): """Triggered by `ChangeList.get_queryset()`.""" changelist.check_field_exists(self.left_field) changelist.check_field_exists(self.right_field) self.pid = self.get_pid_from_request(changelist, request) # Get parent item first. ...
python
def hook_get_queryset(self, changelist, request): """Triggered by `ChangeList.get_queryset()`.""" changelist.check_field_exists(self.left_field) changelist.check_field_exists(self.right_field) self.pid = self.get_pid_from_request(changelist, request) # Get parent item first. ...
[ "def", "hook_get_queryset", "(", "self", ",", "changelist", ",", "request", ")", ":", "changelist", ".", "check_field_exists", "(", "self", ".", "left_field", ")", "changelist", ".", "check_field_exists", "(", "self", ".", "right_field", ")", "self", ".", "pid...
Triggered by `ChangeList.get_queryset()`.
[ "Triggered", "by", "ChangeList", ".", "get_queryset", "()", "." ]
train
https://github.com/idlesign/django-admirarchy/blob/723e4fd212fdebcc156492cb16b9d65356f5ca73/admirarchy/utils.py#L290-L305
idlesign/django-admirarchy
admirarchy/utils.py
NestedSet.hook_get_results
def hook_get_results(self, changelist): """Triggered by `ChangeList.get_results()`.""" # Poor NestedSet guys they've punished themselves once chosen that approach, # and now we punish them again with all those DB hits. result_list = list(changelist.result_list) # Get children ...
python
def hook_get_results(self, changelist): """Triggered by `ChangeList.get_results()`.""" # Poor NestedSet guys they've punished themselves once chosen that approach, # and now we punish them again with all those DB hits. result_list = list(changelist.result_list) # Get children ...
[ "def", "hook_get_results", "(", "self", ",", "changelist", ")", ":", "# Poor NestedSet guys they've punished themselves once chosen that approach,", "# and now we punish them again with all those DB hits.", "result_list", "=", "list", "(", "changelist", ".", "result_list", ")", "...
Triggered by `ChangeList.get_results()`.
[ "Triggered", "by", "ChangeList", ".", "get_results", "()", "." ]
train
https://github.com/idlesign/django-admirarchy/blob/723e4fd212fdebcc156492cb16b9d65356f5ca73/admirarchy/utils.py#L307-L349
idlesign/django-admirarchy
setup.py
read_file
def read_file(fpath): """Reads a file within package directories.""" with io.open(os.path.join(PATH_BASE, fpath)) as f: return f.read()
python
def read_file(fpath): """Reads a file within package directories.""" with io.open(os.path.join(PATH_BASE, fpath)) as f: return f.read()
[ "def", "read_file", "(", "fpath", ")", ":", "with", "io", ".", "open", "(", "os", ".", "path", ".", "join", "(", "PATH_BASE", ",", "fpath", ")", ")", "as", "f", ":", "return", "f", ".", "read", "(", ")" ]
Reads a file within package directories.
[ "Reads", "a", "file", "within", "package", "directories", "." ]
train
https://github.com/idlesign/django-admirarchy/blob/723e4fd212fdebcc156492cb16b9d65356f5ca73/setup.py#L10-L13
idlesign/django-admirarchy
setup.py
get_version
def get_version(): """Returns version number, without module import (which can lead to ImportError if some dependencies are unavailable before install.""" contents = read_file(os.path.join('admirarchy', '__init__.py')) version = re.search('VERSION = \(([^)]+)\)', contents) version = version.group(1)...
python
def get_version(): """Returns version number, without module import (which can lead to ImportError if some dependencies are unavailable before install.""" contents = read_file(os.path.join('admirarchy', '__init__.py')) version = re.search('VERSION = \(([^)]+)\)', contents) version = version.group(1)...
[ "def", "get_version", "(", ")", ":", "contents", "=", "read_file", "(", "os", ".", "path", ".", "join", "(", "'admirarchy'", ",", "'__init__.py'", ")", ")", "version", "=", "re", ".", "search", "(", "'VERSION = \\(([^)]+)\\)'", ",", "contents", ")", "versi...
Returns version number, without module import (which can lead to ImportError if some dependencies are unavailable before install.
[ "Returns", "version", "number", "without", "module", "import", "(", "which", "can", "lead", "to", "ImportError", "if", "some", "dependencies", "are", "unavailable", "before", "install", "." ]
train
https://github.com/idlesign/django-admirarchy/blob/723e4fd212fdebcc156492cb16b9d65356f5ca73/setup.py#L16-L22
robotpy/pynetworktables2js
pynetworktables2js/nt_serial.py
NTSerial.process_update
def process_update(self, update): """Process an incoming update from a remote NetworkTables""" data = json.loads(update) NetworkTables.getEntry(data["k"]).setValue(data["v"])
python
def process_update(self, update): """Process an incoming update from a remote NetworkTables""" data = json.loads(update) NetworkTables.getEntry(data["k"]).setValue(data["v"])
[ "def", "process_update", "(", "self", ",", "update", ")", ":", "data", "=", "json", ".", "loads", "(", "update", ")", "NetworkTables", ".", "getEntry", "(", "data", "[", "\"k\"", "]", ")", ".", "setValue", "(", "data", "[", "\"v\"", "]", ")" ]
Process an incoming update from a remote NetworkTables
[ "Process", "an", "incoming", "update", "from", "a", "remote", "NetworkTables" ]
train
https://github.com/robotpy/pynetworktables2js/blob/a2a925013b17de38306da36f091262d68610624c/pynetworktables2js/nt_serial.py#L25-L28
robotpy/pynetworktables2js
pynetworktables2js/nt_serial.py
NTSerial._send_update
def _send_update(self, data): """Send a NetworkTables update via the stored send_update callback""" if isinstance(data, dict): data = json.dumps(data) self.update_callback(data)
python
def _send_update(self, data): """Send a NetworkTables update via the stored send_update callback""" if isinstance(data, dict): data = json.dumps(data) self.update_callback(data)
[ "def", "_send_update", "(", "self", ",", "data", ")", ":", "if", "isinstance", "(", "data", ",", "dict", ")", ":", "data", "=", "json", ".", "dumps", "(", "data", ")", "self", ".", "update_callback", "(", "data", ")" ]
Send a NetworkTables update via the stored send_update callback
[ "Send", "a", "NetworkTables", "update", "via", "the", "stored", "send_update", "callback" ]
train
https://github.com/robotpy/pynetworktables2js/blob/a2a925013b17de38306da36f091262d68610624c/pynetworktables2js/nt_serial.py#L30-L34
robotpy/pynetworktables2js
pynetworktables2js/nt_serial.py
NTSerial._nt_on_change
def _nt_on_change(self, key, value, isNew): """NetworkTables global listener callback""" self._send_update({"k": key, "v": value, "n": isNew})
python
def _nt_on_change(self, key, value, isNew): """NetworkTables global listener callback""" self._send_update({"k": key, "v": value, "n": isNew})
[ "def", "_nt_on_change", "(", "self", ",", "key", ",", "value", ",", "isNew", ")", ":", "self", ".", "_send_update", "(", "{", "\"k\"", ":", "key", ",", "\"v\"", ":", "value", ",", "\"n\"", ":", "isNew", "}", ")" ]
NetworkTables global listener callback
[ "NetworkTables", "global", "listener", "callback" ]
train
https://github.com/robotpy/pynetworktables2js/blob/a2a925013b17de38306da36f091262d68610624c/pynetworktables2js/nt_serial.py#L36-L38
robotpy/pynetworktables2js
pynetworktables2js/nt_serial.py
NTSerial.close
def close(self): """ Clean up NetworkTables listeners """ NetworkTables.removeGlobalListener(self._nt_on_change) NetworkTables.removeConnectionListener(self._nt_connected)
python
def close(self): """ Clean up NetworkTables listeners """ NetworkTables.removeGlobalListener(self._nt_on_change) NetworkTables.removeConnectionListener(self._nt_connected)
[ "def", "close", "(", "self", ")", ":", "NetworkTables", ".", "removeGlobalListener", "(", "self", ".", "_nt_on_change", ")", "NetworkTables", ".", "removeConnectionListener", "(", "self", ".", "_nt_connected", ")" ]
Clean up NetworkTables listeners
[ "Clean", "up", "NetworkTables", "listeners" ]
train
https://github.com/robotpy/pynetworktables2js/blob/a2a925013b17de38306da36f091262d68610624c/pynetworktables2js/nt_serial.py#L44-L49
openeemeter/eeweather
eeweather/geo.py
get_lat_long_climate_zones
def get_lat_long_climate_zones(latitude, longitude): """ Get climate zones that contain lat/long coordinates. Parameters ---------- latitude : float Latitude of point. longitude : float Longitude of point. Returns ------- climate_zones: dict of str Region ids fo...
python
def get_lat_long_climate_zones(latitude, longitude): """ Get climate zones that contain lat/long coordinates. Parameters ---------- latitude : float Latitude of point. longitude : float Longitude of point. Returns ------- climate_zones: dict of str Region ids fo...
[ "def", "get_lat_long_climate_zones", "(", "latitude", ",", "longitude", ")", ":", "try", ":", "from", "shapely", ".", "geometry", "import", "Point", "except", "ImportError", ":", "# pragma: no cover", "raise", "ImportError", "(", "\"Finding climate zone of lat/long poin...
Get climate zones that contain lat/long coordinates. Parameters ---------- latitude : float Latitude of point. longitude : float Longitude of point. Returns ------- climate_zones: dict of str Region ids for each climate zone type.
[ "Get", "climate", "zones", "that", "contain", "lat", "/", "long", "coordinates", "." ]
train
https://github.com/openeemeter/eeweather/blob/d32b7369b26edfa3ee431c60457afeb0593123a7/eeweather/geo.py#L104-L161
openeemeter/eeweather
eeweather/geo.py
get_zcta_metadata
def get_zcta_metadata(zcta): """ Get metadata about a ZIP Code Tabulation Area (ZCTA). Parameters ---------- zcta : str ID of ZIP Code Tabulation Area Returns ------- metadata : dict Dict of data about the ZCTA, including lat/long coordinates. """ conn = metadata_db...
python
def get_zcta_metadata(zcta): """ Get metadata about a ZIP Code Tabulation Area (ZCTA). Parameters ---------- zcta : str ID of ZIP Code Tabulation Area Returns ------- metadata : dict Dict of data about the ZCTA, including lat/long coordinates. """ conn = metadata_db...
[ "def", "get_zcta_metadata", "(", "zcta", ")", ":", "conn", "=", "metadata_db_connection_proxy", ".", "get_connection", "(", ")", "cur", "=", "conn", ".", "cursor", "(", ")", "cur", ".", "execute", "(", "\"\"\"\n select\n *\n from\n zcta_metadat...
Get metadata about a ZIP Code Tabulation Area (ZCTA). Parameters ---------- zcta : str ID of ZIP Code Tabulation Area Returns ------- metadata : dict Dict of data about the ZCTA, including lat/long coordinates.
[ "Get", "metadata", "about", "a", "ZIP", "Code", "Tabulation", "Area", "(", "ZCTA", ")", "." ]
train
https://github.com/openeemeter/eeweather/blob/d32b7369b26edfa3ee431c60457afeb0593123a7/eeweather/geo.py#L164-L193
openeemeter/eeweather
eeweather/geo.py
zcta_to_lat_long
def zcta_to_lat_long(zcta): """Get location of ZCTA centroid Retrieves latitude and longitude of centroid of ZCTA to use for matching with weather station. Parameters ---------- zcta : str ID of the target ZCTA. Returns ------- latitude : float Latitude of centroid...
python
def zcta_to_lat_long(zcta): """Get location of ZCTA centroid Retrieves latitude and longitude of centroid of ZCTA to use for matching with weather station. Parameters ---------- zcta : str ID of the target ZCTA. Returns ------- latitude : float Latitude of centroid...
[ "def", "zcta_to_lat_long", "(", "zcta", ")", ":", "valid_zcta_or_raise", "(", "zcta", ")", "conn", "=", "metadata_db_connection_proxy", ".", "get_connection", "(", ")", "cur", "=", "conn", ".", "cursor", "(", ")", "cur", ".", "execute", "(", "\"\"\"\n sel...
Get location of ZCTA centroid Retrieves latitude and longitude of centroid of ZCTA to use for matching with weather station. Parameters ---------- zcta : str ID of the target ZCTA. Returns ------- latitude : float Latitude of centroid of ZCTA. longitude : float ...
[ "Get", "location", "of", "ZCTA", "centroid" ]
train
https://github.com/openeemeter/eeweather/blob/d32b7369b26edfa3ee431c60457afeb0593123a7/eeweather/geo.py#L196-L234
openeemeter/eeweather
eeweather/summaries.py
get_zcta_ids
def get_zcta_ids(state=None): """ Get ids of all supported ZCTAs, optionally by state. Parameters ---------- state : str, optional Select zipcodes only from this state or territory, given as 2-letter abbreviation (e.g., ``'CA'``, ``'PR'``). Returns ------- results : list of...
python
def get_zcta_ids(state=None): """ Get ids of all supported ZCTAs, optionally by state. Parameters ---------- state : str, optional Select zipcodes only from this state or territory, given as 2-letter abbreviation (e.g., ``'CA'``, ``'PR'``). Returns ------- results : list of...
[ "def", "get_zcta_ids", "(", "state", "=", "None", ")", ":", "conn", "=", "metadata_db_connection_proxy", ".", "get_connection", "(", ")", "cur", "=", "conn", ".", "cursor", "(", ")", "if", "state", "is", "None", ":", "cur", ".", "execute", "(", "\"\"\"\n...
Get ids of all supported ZCTAs, optionally by state. Parameters ---------- state : str, optional Select zipcodes only from this state or territory, given as 2-letter abbreviation (e.g., ``'CA'``, ``'PR'``). Returns ------- results : list of str List of all supported sel...
[ "Get", "ids", "of", "all", "supported", "ZCTAs", "optionally", "by", "state", "." ]
train
https://github.com/openeemeter/eeweather/blob/d32b7369b26edfa3ee431c60457afeb0593123a7/eeweather/summaries.py#L25-L55
openeemeter/eeweather
eeweather/validation.py
valid_zcta_or_raise
def valid_zcta_or_raise(zcta): """ Check if ZCTA is valid and raise eeweather.UnrecognizedZCTAError if not. """ conn = metadata_db_connection_proxy.get_connection() cur = conn.cursor() cur.execute( """ select exists ( select zcta_id from zcta_metadata ...
python
def valid_zcta_or_raise(zcta): """ Check if ZCTA is valid and raise eeweather.UnrecognizedZCTAError if not. """ conn = metadata_db_connection_proxy.get_connection() cur = conn.cursor() cur.execute( """ select exists ( select zcta_id from zcta_metadata ...
[ "def", "valid_zcta_or_raise", "(", "zcta", ")", ":", "conn", "=", "metadata_db_connection_proxy", ".", "get_connection", "(", ")", "cur", "=", "conn", ".", "cursor", "(", ")", "cur", ".", "execute", "(", "\"\"\"\n select exists (\n select\n zcta_i...
Check if ZCTA is valid and raise eeweather.UnrecognizedZCTAError if not.
[ "Check", "if", "ZCTA", "is", "valid", "and", "raise", "eeweather", ".", "UnrecognizedZCTAError", "if", "not", "." ]
train
https://github.com/openeemeter/eeweather/blob/d32b7369b26edfa3ee431c60457afeb0593123a7/eeweather/validation.py#L27-L49
openeemeter/eeweather
eeweather/validation.py
valid_usaf_id_or_raise
def valid_usaf_id_or_raise(usaf_id): """ Check if USAF ID is valid and raise eeweather.UnrecognizedUSAFIDError if not. """ conn = metadata_db_connection_proxy.get_connection() cur = conn.cursor() cur.execute( """ select exists ( select usaf_id from isd_...
python
def valid_usaf_id_or_raise(usaf_id): """ Check if USAF ID is valid and raise eeweather.UnrecognizedUSAFIDError if not. """ conn = metadata_db_connection_proxy.get_connection() cur = conn.cursor() cur.execute( """ select exists ( select usaf_id from isd_...
[ "def", "valid_usaf_id_or_raise", "(", "usaf_id", ")", ":", "conn", "=", "metadata_db_connection_proxy", ".", "get_connection", "(", ")", "cur", "=", "conn", ".", "cursor", "(", ")", "cur", ".", "execute", "(", "\"\"\"\n select exists (\n select\n ...
Check if USAF ID is valid and raise eeweather.UnrecognizedUSAFIDError if not.
[ "Check", "if", "USAF", "ID", "is", "valid", "and", "raise", "eeweather", ".", "UnrecognizedUSAFIDError", "if", "not", "." ]
train
https://github.com/openeemeter/eeweather/blob/d32b7369b26edfa3ee431c60457afeb0593123a7/eeweather/validation.py#L52-L74
openeemeter/eeweather
eeweather/ranking.py
rank_stations
def rank_stations( site_latitude, site_longitude, site_state=None, site_elevation=None, match_iecc_climate_zone=False, match_iecc_moisture_regime=False, match_ba_climate_zone=False, match_ca_climate_zone=False, match_state=False, minimum_quality=None, minimum_tmy3_class=None,...
python
def rank_stations( site_latitude, site_longitude, site_state=None, site_elevation=None, match_iecc_climate_zone=False, match_iecc_moisture_regime=False, match_ba_climate_zone=False, match_ca_climate_zone=False, match_state=False, minimum_quality=None, minimum_tmy3_class=None,...
[ "def", "rank_stations", "(", "site_latitude", ",", "site_longitude", ",", "site_state", "=", "None", ",", "site_elevation", "=", "None", ",", "match_iecc_climate_zone", "=", "False", ",", "match_iecc_moisture_regime", "=", "False", ",", "match_ba_climate_zone", "=", ...
Get a ranked, filtered set of candidate weather stations and metadata for a particular site. Parameters ---------- site_latitude : float Latitude of target site for which to find candidate weather stations. site_longitude : float Longitude of target site for which to find candidate ...
[ "Get", "a", "ranked", "filtered", "set", "of", "candidate", "weather", "stations", "and", "metadata", "for", "a", "particular", "site", "." ]
train
https://github.com/openeemeter/eeweather/blob/d32b7369b26edfa3ee431c60457afeb0593123a7/eeweather/ranking.py#L107-L320
openeemeter/eeweather
eeweather/ranking.py
combine_ranked_stations
def combine_ranked_stations(rankings): """ Combine :any:`pandas.DataFrame` s of candidate weather stations to form a hybrid ranking dataframe. Parameters ---------- rankings : list of :any:`pandas.DataFrame` Dataframes of ranked weather station candidates and metadata. All ranking d...
python
def combine_ranked_stations(rankings): """ Combine :any:`pandas.DataFrame` s of candidate weather stations to form a hybrid ranking dataframe. Parameters ---------- rankings : list of :any:`pandas.DataFrame` Dataframes of ranked weather station candidates and metadata. All ranking d...
[ "def", "combine_ranked_stations", "(", "rankings", ")", ":", "if", "len", "(", "rankings", ")", "==", "0", ":", "raise", "ValueError", "(", "\"Requires at least one ranking.\"", ")", "combined_ranking", "=", "rankings", "[", "0", "]", "for", "ranking", "in", "...
Combine :any:`pandas.DataFrame` s of candidate weather stations to form a hybrid ranking dataframe. Parameters ---------- rankings : list of :any:`pandas.DataFrame` Dataframes of ranked weather station candidates and metadata. All ranking dataframes should have the same columns and must...
[ "Combine", ":", "any", ":", "pandas", ".", "DataFrame", "s", "of", "candidate", "weather", "stations", "to", "form", "a", "hybrid", "ranking", "dataframe", "." ]
train
https://github.com/openeemeter/eeweather/blob/d32b7369b26edfa3ee431c60457afeb0593123a7/eeweather/ranking.py#L323-L350
openeemeter/eeweather
eeweather/ranking.py
select_station
def select_station( candidates, coverage_range=None, min_fraction_coverage=0.9, distance_warnings=(50000, 200000), rank=1, ): """ Select a station from a list of candidates that meets given data quality criteria. Parameters ---------- candidates : :any:`pandas.DataFrame` ...
python
def select_station( candidates, coverage_range=None, min_fraction_coverage=0.9, distance_warnings=(50000, 200000), rank=1, ): """ Select a station from a list of candidates that meets given data quality criteria. Parameters ---------- candidates : :any:`pandas.DataFrame` ...
[ "def", "select_station", "(", "candidates", ",", "coverage_range", "=", "None", ",", "min_fraction_coverage", "=", "0.9", ",", "distance_warnings", "=", "(", "50000", ",", "200000", ")", ",", "rank", "=", "1", ",", ")", ":", "def", "_test_station", "(", "s...
Select a station from a list of candidates that meets given data quality criteria. Parameters ---------- candidates : :any:`pandas.DataFrame` A dataframe of the form given by :any:`eeweather.rank_stations` or :any:`eeweather.combine_ranked_stations`, specifically having at least ...
[ "Select", "a", "station", "from", "a", "list", "of", "candidates", "that", "meets", "given", "data", "quality", "criteria", "." ]
train
https://github.com/openeemeter/eeweather/blob/d32b7369b26edfa3ee431c60457afeb0593123a7/eeweather/ranking.py#L358-L438
openeemeter/eeweather
eeweather/database.py
_load_isd_station_metadata
def _load_isd_station_metadata(download_path): """ Collect metadata for US isd stations. """ from shapely.geometry import Point # load ISD history which contains metadata isd_history = pd.read_csv( os.path.join(download_path, "isd-history.csv"), dtype=str, parse_dates=["BEGI...
python
def _load_isd_station_metadata(download_path): """ Collect metadata for US isd stations. """ from shapely.geometry import Point # load ISD history which contains metadata isd_history = pd.read_csv( os.path.join(download_path, "isd-history.csv"), dtype=str, parse_dates=["BEGI...
[ "def", "_load_isd_station_metadata", "(", "download_path", ")", ":", "from", "shapely", ".", "geometry", "import", "Point", "# load ISD history which contains metadata", "isd_history", "=", "pd", ".", "read_csv", "(", "os", ".", "path", ".", "join", "(", "download_p...
Collect metadata for US isd stations.
[ "Collect", "metadata", "for", "US", "isd", "stations", "." ]
train
https://github.com/openeemeter/eeweather/blob/d32b7369b26edfa3ee431c60457afeb0593123a7/eeweather/database.py#L160-L202
openeemeter/eeweather
eeweather/database.py
_load_isd_file_metadata
def _load_isd_file_metadata(download_path, isd_station_metadata): """ Collect data counts for isd files. """ isd_inventory = pd.read_csv( os.path.join(download_path, "isd-inventory.csv"), dtype=str ) # filter to stations with metadata station_keep = [usaf in isd_station_metadata for us...
python
def _load_isd_file_metadata(download_path, isd_station_metadata): """ Collect data counts for isd files. """ isd_inventory = pd.read_csv( os.path.join(download_path, "isd-inventory.csv"), dtype=str ) # filter to stations with metadata station_keep = [usaf in isd_station_metadata for us...
[ "def", "_load_isd_file_metadata", "(", "download_path", ",", "isd_station_metadata", ")", ":", "isd_inventory", "=", "pd", ".", "read_csv", "(", "os", ".", "path", ".", "join", "(", "download_path", ",", "\"isd-inventory.csv\"", ")", ",", "dtype", "=", "str", ...
Collect data counts for isd files.
[ "Collect", "data", "counts", "for", "isd", "files", "." ]
train
https://github.com/openeemeter/eeweather/blob/d32b7369b26edfa3ee431c60457afeb0593123a7/eeweather/database.py#L205-L244
openeemeter/eeweather
eeweather/database.py
build_metadata_db
def build_metadata_db( zcta_geometry=False, iecc_climate_zone_geometry=True, iecc_moisture_regime_geometry=True, ba_climate_zone_geometry=True, ca_climate_zone_geometry=True, ): """ Build database of metadata from primary sources. Downloads primary sources, clears existing DB, and rebuilds ...
python
def build_metadata_db( zcta_geometry=False, iecc_climate_zone_geometry=True, iecc_moisture_regime_geometry=True, ba_climate_zone_geometry=True, ca_climate_zone_geometry=True, ): """ Build database of metadata from primary sources. Downloads primary sources, clears existing DB, and rebuilds ...
[ "def", "build_metadata_db", "(", "zcta_geometry", "=", "False", ",", "iecc_climate_zone_geometry", "=", "True", ",", "iecc_moisture_regime_geometry", "=", "True", ",", "ba_climate_zone_geometry", "=", "True", ",", "ca_climate_zone_geometry", "=", "True", ",", ")", ":"...
Build database of metadata from primary sources. Downloads primary sources, clears existing DB, and rebuilds from scratch. Parameters ---------- zcta_geometry : bool, optional Whether or not to include ZCTA geometry in database. iecc_climate_zone_geometry : bool, optional Whether o...
[ "Build", "database", "of", "metadata", "from", "primary", "sources", "." ]
train
https://github.com/openeemeter/eeweather/blob/d32b7369b26edfa3ee431c60457afeb0593123a7/eeweather/database.py#L1130-L1275
openeemeter/eeweather
eeweather/stations.py
ISDStation.json
def json(self): """ Return a JSON-serializeable object containing station metadata.""" return { "elevation": self.elevation, "latitude": self.latitude, "longitude": self.longitude, "icao_code": self.icao_code, "name": self.name, "qu...
python
def json(self): """ Return a JSON-serializeable object containing station metadata.""" return { "elevation": self.elevation, "latitude": self.latitude, "longitude": self.longitude, "icao_code": self.icao_code, "name": self.name, "qu...
[ "def", "json", "(", "self", ")", ":", "return", "{", "\"elevation\"", ":", "self", ".", "elevation", ",", "\"latitude\"", ":", "self", ".", "latitude", ",", "\"longitude\"", ":", "self", ".", "longitude", ",", "\"icao_code\"", ":", "self", ".", "icao_code"...
Return a JSON-serializeable object containing station metadata.
[ "Return", "a", "JSON", "-", "serializeable", "object", "containing", "station", "metadata", "." ]
train
https://github.com/openeemeter/eeweather/blob/d32b7369b26edfa3ee431c60457afeb0593123a7/eeweather/stations.py#L1151-L1168
openeemeter/eeweather
eeweather/stations.py
ISDStation.get_isd_filenames
def get_isd_filenames(self, year=None, with_host=False): """ Get filenames of raw ISD station data. """ return get_isd_filenames(self.usaf_id, year, with_host=with_host)
python
def get_isd_filenames(self, year=None, with_host=False): """ Get filenames of raw ISD station data. """ return get_isd_filenames(self.usaf_id, year, with_host=with_host)
[ "def", "get_isd_filenames", "(", "self", ",", "year", "=", "None", ",", "with_host", "=", "False", ")", ":", "return", "get_isd_filenames", "(", "self", ".", "usaf_id", ",", "year", ",", "with_host", "=", "with_host", ")" ]
Get filenames of raw ISD station data.
[ "Get", "filenames", "of", "raw", "ISD", "station", "data", "." ]
train
https://github.com/openeemeter/eeweather/blob/d32b7369b26edfa3ee431c60457afeb0593123a7/eeweather/stations.py#L1170-L1172
openeemeter/eeweather
eeweather/stations.py
ISDStation.get_gsod_filenames
def get_gsod_filenames(self, year=None, with_host=False): """ Get filenames of raw GSOD station data. """ return get_gsod_filenames(self.usaf_id, year, with_host=with_host)
python
def get_gsod_filenames(self, year=None, with_host=False): """ Get filenames of raw GSOD station data. """ return get_gsod_filenames(self.usaf_id, year, with_host=with_host)
[ "def", "get_gsod_filenames", "(", "self", ",", "year", "=", "None", ",", "with_host", "=", "False", ")", ":", "return", "get_gsod_filenames", "(", "self", ".", "usaf_id", ",", "year", ",", "with_host", "=", "with_host", ")" ]
Get filenames of raw GSOD station data.
[ "Get", "filenames", "of", "raw", "GSOD", "station", "data", "." ]
train
https://github.com/openeemeter/eeweather/blob/d32b7369b26edfa3ee431c60457afeb0593123a7/eeweather/stations.py#L1174-L1176
openeemeter/eeweather
eeweather/stations.py
ISDStation.load_isd_hourly_temp_data
def load_isd_hourly_temp_data( self, start, end, read_from_cache=True, write_to_cache=True, error_on_missing_years=True, ): """ Load resampled hourly ISD temperature data from start date to end date (inclusive). This is the primary convenience method ...
python
def load_isd_hourly_temp_data( self, start, end, read_from_cache=True, write_to_cache=True, error_on_missing_years=True, ): """ Load resampled hourly ISD temperature data from start date to end date (inclusive). This is the primary convenience method ...
[ "def", "load_isd_hourly_temp_data", "(", "self", ",", "start", ",", "end", ",", "read_from_cache", "=", "True", ",", "write_to_cache", "=", "True", ",", "error_on_missing_years", "=", "True", ",", ")", ":", "return", "load_isd_hourly_temp_data", "(", "self", "."...
Load resampled hourly ISD temperature data from start date to end date (inclusive). This is the primary convenience method for loading resampled hourly ISD temperature data. Parameters ---------- start : datetime.datetime The earliest date from which to load data. e...
[ "Load", "resampled", "hourly", "ISD", "temperature", "data", "from", "start", "date", "to", "end", "date", "(", "inclusive", ")", "." ]
train
https://github.com/openeemeter/eeweather/blob/d32b7369b26edfa3ee431c60457afeb0593123a7/eeweather/stations.py#L1394-L1424
openeemeter/eeweather
eeweather/stations.py
ISDStation.load_isd_daily_temp_data
def load_isd_daily_temp_data( self, start, end, read_from_cache=True, write_to_cache=True ): """ Load resampled daily ISD temperature data from start date to end date (inclusive). This is the primary convenience method for loading resampled daily ISD temperature data. Parameters ...
python
def load_isd_daily_temp_data( self, start, end, read_from_cache=True, write_to_cache=True ): """ Load resampled daily ISD temperature data from start date to end date (inclusive). This is the primary convenience method for loading resampled daily ISD temperature data. Parameters ...
[ "def", "load_isd_daily_temp_data", "(", "self", ",", "start", ",", "end", ",", "read_from_cache", "=", "True", ",", "write_to_cache", "=", "True", ")", ":", "return", "load_isd_daily_temp_data", "(", "self", ".", "usaf_id", ",", "start", ",", "end", ",", "re...
Load resampled daily ISD temperature data from start date to end date (inclusive). This is the primary convenience method for loading resampled daily ISD temperature data. Parameters ---------- start : datetime.datetime The earliest date from which to load data. end...
[ "Load", "resampled", "daily", "ISD", "temperature", "data", "from", "start", "date", "to", "end", "date", "(", "inclusive", ")", "." ]
train
https://github.com/openeemeter/eeweather/blob/d32b7369b26edfa3ee431c60457afeb0593123a7/eeweather/stations.py#L1426-L1450
openeemeter/eeweather
eeweather/stations.py
ISDStation.load_gsod_daily_temp_data
def load_gsod_daily_temp_data( self, start, end, read_from_cache=True, write_to_cache=True ): """ Load resampled daily GSOD temperature data from start date to end date (inclusive). This is the primary convenience method for loading resampled daily GSOD temperature data. Parameters...
python
def load_gsod_daily_temp_data( self, start, end, read_from_cache=True, write_to_cache=True ): """ Load resampled daily GSOD temperature data from start date to end date (inclusive). This is the primary convenience method for loading resampled daily GSOD temperature data. Parameters...
[ "def", "load_gsod_daily_temp_data", "(", "self", ",", "start", ",", "end", ",", "read_from_cache", "=", "True", ",", "write_to_cache", "=", "True", ")", ":", "return", "load_gsod_daily_temp_data", "(", "self", ".", "usaf_id", ",", "start", ",", "end", ",", "...
Load resampled daily GSOD temperature data from start date to end date (inclusive). This is the primary convenience method for loading resampled daily GSOD temperature data. Parameters ---------- start : datetime.datetime The earliest date from which to load data. e...
[ "Load", "resampled", "daily", "GSOD", "temperature", "data", "from", "start", "date", "to", "end", "date", "(", "inclusive", ")", "." ]
train
https://github.com/openeemeter/eeweather/blob/d32b7369b26edfa3ee431c60457afeb0593123a7/eeweather/stations.py#L1452-L1476
openeemeter/eeweather
eeweather/stations.py
ISDStation.load_tmy3_hourly_temp_data
def load_tmy3_hourly_temp_data( self, start, end, read_from_cache=True, write_to_cache=True ): """ Load hourly TMY3 temperature data from start date to end date (inclusive). This is the primary convenience method for loading hourly TMY3 temperature data. Parameters --------...
python
def load_tmy3_hourly_temp_data( self, start, end, read_from_cache=True, write_to_cache=True ): """ Load hourly TMY3 temperature data from start date to end date (inclusive). This is the primary convenience method for loading hourly TMY3 temperature data. Parameters --------...
[ "def", "load_tmy3_hourly_temp_data", "(", "self", ",", "start", ",", "end", ",", "read_from_cache", "=", "True", ",", "write_to_cache", "=", "True", ")", ":", "return", "load_tmy3_hourly_temp_data", "(", "self", ".", "usaf_id", ",", "start", ",", "end", ",", ...
Load hourly TMY3 temperature data from start date to end date (inclusive). This is the primary convenience method for loading hourly TMY3 temperature data. Parameters ---------- start : datetime.datetime The earliest date from which to load data. end : datetime.date...
[ "Load", "hourly", "TMY3", "temperature", "data", "from", "start", "date", "to", "end", "date", "(", "inclusive", ")", "." ]
train
https://github.com/openeemeter/eeweather/blob/d32b7369b26edfa3ee431c60457afeb0593123a7/eeweather/stations.py#L1478-L1502
openeemeter/eeweather
eeweather/stations.py
ISDStation.load_cz2010_hourly_temp_data
def load_cz2010_hourly_temp_data( self, start, end, read_from_cache=True, write_to_cache=True ): """ Load hourly CZ2010 temperature data from start date to end date (inclusive). This is the primary convenience method for loading hourly CZ2010 temperature data. Parameters --...
python
def load_cz2010_hourly_temp_data( self, start, end, read_from_cache=True, write_to_cache=True ): """ Load hourly CZ2010 temperature data from start date to end date (inclusive). This is the primary convenience method for loading hourly CZ2010 temperature data. Parameters --...
[ "def", "load_cz2010_hourly_temp_data", "(", "self", ",", "start", ",", "end", ",", "read_from_cache", "=", "True", ",", "write_to_cache", "=", "True", ")", ":", "return", "load_cz2010_hourly_temp_data", "(", "self", ".", "usaf_id", ",", "start", ",", "end", ",...
Load hourly CZ2010 temperature data from start date to end date (inclusive). This is the primary convenience method for loading hourly CZ2010 temperature data. Parameters ---------- start : datetime.datetime The earliest date from which to load data. end : datetime....
[ "Load", "hourly", "CZ2010", "temperature", "data", "from", "start", "date", "to", "end", "date", "(", "inclusive", ")", "." ]
train
https://github.com/openeemeter/eeweather/blob/d32b7369b26edfa3ee431c60457afeb0593123a7/eeweather/stations.py#L1504-L1528
openeemeter/eeweather
eeweather/visualization.py
plot_station_mapping
def plot_station_mapping( target_latitude, target_longitude, isd_station, distance_meters, target_label="target", ): # pragma: no cover """ Plots this mapping on a map.""" try: import matplotlib.pyplot as plt except ImportError: raise ImportError("Plotting requires matpl...
python
def plot_station_mapping( target_latitude, target_longitude, isd_station, distance_meters, target_label="target", ): # pragma: no cover """ Plots this mapping on a map.""" try: import matplotlib.pyplot as plt except ImportError: raise ImportError("Plotting requires matpl...
[ "def", "plot_station_mapping", "(", "target_latitude", ",", "target_longitude", ",", "isd_station", ",", "distance_meters", ",", "target_label", "=", "\"target\"", ",", ")", ":", "# pragma: no cover", "try", ":", "import", "matplotlib", ".", "pyplot", "as", "plt", ...
Plots this mapping on a map.
[ "Plots", "this", "mapping", "on", "a", "map", "." ]
train
https://github.com/openeemeter/eeweather/blob/d32b7369b26edfa3ee431c60457afeb0593123a7/eeweather/visualization.py#L29-L132
openeemeter/eeweather
eeweather/visualization.py
plot_station_mappings
def plot_station_mappings(mapping_results): # pragma: no cover """ Plot a list of mapping results on a map. Requires matplotlib and cartopy. Parameters ---------- mapping_results : list of MappingResult objects Mapping results to plot """ try: import matplotlib.pyplot as p...
python
def plot_station_mappings(mapping_results): # pragma: no cover """ Plot a list of mapping results on a map. Requires matplotlib and cartopy. Parameters ---------- mapping_results : list of MappingResult objects Mapping results to plot """ try: import matplotlib.pyplot as p...
[ "def", "plot_station_mappings", "(", "mapping_results", ")", ":", "# pragma: no cover", "try", ":", "import", "matplotlib", ".", "pyplot", "as", "plt", "except", "ImportError", ":", "raise", "ImportError", "(", "\"Plotting requires matplotlib.\"", ")", "try", ":", "...
Plot a list of mapping results on a map. Requires matplotlib and cartopy. Parameters ---------- mapping_results : list of MappingResult objects Mapping results to plot
[ "Plot", "a", "list", "of", "mapping", "results", "on", "a", "map", "." ]
train
https://github.com/openeemeter/eeweather/blob/d32b7369b26edfa3ee431c60457afeb0593123a7/eeweather/visualization.py#L135-L289
SuperCowPowers/workbench
workbench/workers/view_pdf.py
ViewPDF.execute
def execute(self, input_data): ''' Execute the ViewPDF worker ''' # Just a small check to make sure we haven't been called on the wrong file type if (input_data['meta']['type_tag'] != 'pdf'): return {'error': self.__class__.__name__+': called on '+input_data['meta']['type_tag']} ...
python
def execute(self, input_data): ''' Execute the ViewPDF worker ''' # Just a small check to make sure we haven't been called on the wrong file type if (input_data['meta']['type_tag'] != 'pdf'): return {'error': self.__class__.__name__+': called on '+input_data['meta']['type_tag']} ...
[ "def", "execute", "(", "self", ",", "input_data", ")", ":", "# Just a small check to make sure we haven't been called on the wrong file type", "if", "(", "input_data", "[", "'meta'", "]", "[", "'type_tag'", "]", "!=", "'pdf'", ")", ":", "return", "{", "'error'", ":"...
Execute the ViewPDF worker
[ "Execute", "the", "ViewPDF", "worker" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/view_pdf.py#L9-L19
SuperCowPowers/workbench
workbench/workers/view_pcap.py
ViewPcap.execute
def execute(self, input_data): ''' Execute ''' view = {} # Grab logs from Bro view['bro_logs'] = {key: input_data['pcap_bro'][key] for key in input_data['pcap_bro'].keys() if '_log' in key} # Grab logs from Bro view['extracted_files'] = input_data['pcap_bro']['extracted...
python
def execute(self, input_data): ''' Execute ''' view = {} # Grab logs from Bro view['bro_logs'] = {key: input_data['pcap_bro'][key] for key in input_data['pcap_bro'].keys() if '_log' in key} # Grab logs from Bro view['extracted_files'] = input_data['pcap_bro']['extracted...
[ "def", "execute", "(", "self", ",", "input_data", ")", ":", "view", "=", "{", "}", "# Grab logs from Bro", "view", "[", "'bro_logs'", "]", "=", "{", "key", ":", "input_data", "[", "'pcap_bro'", "]", "[", "key", "]", "for", "key", "in", "input_data", "[...
Execute
[ "Execute" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/view_pcap.py#L14-L24
SuperCowPowers/workbench
workbench/workers/pcap_graph.py
PcapGraph.add_node
def add_node(self, node_id, name, labels): ''' Cache aware add_node ''' if node_id not in self.node_cache: self.workbench.add_node(node_id, name, labels) self.node_cache.add(node_id)
python
def add_node(self, node_id, name, labels): ''' Cache aware add_node ''' if node_id not in self.node_cache: self.workbench.add_node(node_id, name, labels) self.node_cache.add(node_id)
[ "def", "add_node", "(", "self", ",", "node_id", ",", "name", ",", "labels", ")", ":", "if", "node_id", "not", "in", "self", ".", "node_cache", ":", "self", ".", "workbench", ".", "add_node", "(", "node_id", ",", "name", ",", "labels", ")", "self", "....
Cache aware add_node
[ "Cache", "aware", "add_node" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/pcap_graph.py#L33-L37
SuperCowPowers/workbench
workbench/workers/pcap_graph.py
PcapGraph.add_rel
def add_rel(self, source_id, target_id, rel): ''' Cache aware add_rel ''' if (source_id, target_id) not in self.rel_cache: self.workbench.add_rel(source_id, target_id, rel) self.rel_cache.add((source_id, target_id))
python
def add_rel(self, source_id, target_id, rel): ''' Cache aware add_rel ''' if (source_id, target_id) not in self.rel_cache: self.workbench.add_rel(source_id, target_id, rel) self.rel_cache.add((source_id, target_id))
[ "def", "add_rel", "(", "self", ",", "source_id", ",", "target_id", ",", "rel", ")", ":", "if", "(", "source_id", ",", "target_id", ")", "not", "in", "self", ".", "rel_cache", ":", "self", ".", "workbench", ".", "add_rel", "(", "source_id", ",", "target...
Cache aware add_rel
[ "Cache", "aware", "add_rel" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/pcap_graph.py#L39-L43
SuperCowPowers/workbench
workbench/workers/pcap_graph.py
PcapGraph.conn_log_graph
def conn_log_graph(self, stream): ''' Build up a graph (nodes and edges from a Bro conn.log) ''' conn_log = list(stream) print 'Entering conn_log_graph...(%d rows)' % len(conn_log) for row in stream: # Add the connection id with service as one of the labels self....
python
def conn_log_graph(self, stream): ''' Build up a graph (nodes and edges from a Bro conn.log) ''' conn_log = list(stream) print 'Entering conn_log_graph...(%d rows)' % len(conn_log) for row in stream: # Add the connection id with service as one of the labels self....
[ "def", "conn_log_graph", "(", "self", ",", "stream", ")", ":", "conn_log", "=", "list", "(", "stream", ")", "print", "'Entering conn_log_graph...(%d rows)'", "%", "len", "(", "conn_log", ")", "for", "row", "in", "stream", ":", "# Add the connection id with service...
Build up a graph (nodes and edges from a Bro conn.log)
[ "Build", "up", "a", "graph", "(", "nodes", "and", "edges", "from", "a", "Bro", "conn", ".", "log", ")" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/pcap_graph.py#L80-L97
SuperCowPowers/workbench
workbench/workers/pcap_graph.py
PcapGraph.dns_log_graph
def dns_log_graph(self, stream): ''' Build up a graph (nodes and edges from a Bro dns.log) ''' dns_log = list(stream) print 'Entering dns_log_graph...(%d rows)' % len(dns_log) for row in dns_log: # Skip '-' hosts if (row['id.orig_h'] == '-'): ...
python
def dns_log_graph(self, stream): ''' Build up a graph (nodes and edges from a Bro dns.log) ''' dns_log = list(stream) print 'Entering dns_log_graph...(%d rows)' % len(dns_log) for row in dns_log: # Skip '-' hosts if (row['id.orig_h'] == '-'): ...
[ "def", "dns_log_graph", "(", "self", ",", "stream", ")", ":", "dns_log", "=", "list", "(", "stream", ")", "print", "'Entering dns_log_graph...(%d rows)'", "%", "len", "(", "dns_log", ")", "for", "row", "in", "dns_log", ":", "# Skip '-' hosts", "if", "(", "ro...
Build up a graph (nodes and edges from a Bro dns.log)
[ "Build", "up", "a", "graph", "(", "nodes", "and", "edges", "from", "a", "Bro", "dns", ".", "log", ")" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/pcap_graph.py#L127-L149
SuperCowPowers/workbench
workbench/workers/pcap_graph.py
PcapGraph.weird_log_graph
def weird_log_graph(self, stream): ''' Build up a graph (nodes and edges from a Bro weird.log) ''' weird_log = list(stream) print 'Entering weird_log_graph...(%d rows)' % len(weird_log) # Here we're just going to capture that something weird # happened between two hosts ...
python
def weird_log_graph(self, stream): ''' Build up a graph (nodes and edges from a Bro weird.log) ''' weird_log = list(stream) print 'Entering weird_log_graph...(%d rows)' % len(weird_log) # Here we're just going to capture that something weird # happened between two hosts ...
[ "def", "weird_log_graph", "(", "self", ",", "stream", ")", ":", "weird_log", "=", "list", "(", "stream", ")", "print", "'Entering weird_log_graph...(%d rows)'", "%", "len", "(", "weird_log", ")", "# Here we're just going to capture that something weird", "# happened betwe...
Build up a graph (nodes and edges from a Bro weird.log)
[ "Build", "up", "a", "graph", "(", "nodes", "and", "edges", "from", "a", "Bro", "weird", ".", "log", ")" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/pcap_graph.py#L151-L181
SuperCowPowers/workbench
workbench/workers/pcap_graph.py
PcapGraph.files_log_graph
def files_log_graph(self, stream): ''' Build up a graph (nodes and edges from a Bro files.log) ''' file_log = list(stream) print 'Entering file_log_graph...(%d rows)' % len(file_log) for row in file_log: # If the mime-type is interesting add the uri and the host->uri->host r...
python
def files_log_graph(self, stream): ''' Build up a graph (nodes and edges from a Bro files.log) ''' file_log = list(stream) print 'Entering file_log_graph...(%d rows)' % len(file_log) for row in file_log: # If the mime-type is interesting add the uri and the host->uri->host r...
[ "def", "files_log_graph", "(", "self", ",", "stream", ")", ":", "file_log", "=", "list", "(", "stream", ")", "print", "'Entering file_log_graph...(%d rows)'", "%", "len", "(", "file_log", ")", "for", "row", "in", "file_log", ":", "# If the mime-type is interesting...
Build up a graph (nodes and edges from a Bro files.log)
[ "Build", "up", "a", "graph", "(", "nodes", "and", "edges", "from", "a", "Bro", "files", ".", "log", ")" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/pcap_graph.py#L183-L217
SuperCowPowers/workbench
workbench/clients/help_client.py
run
def run(): ''' This client calls a bunch of help commands from workbench ''' # Grab server args args = client_helper.grab_server_args() # Start up workbench connection workbench = zerorpc.Client(timeout=300, heartbeat=60) workbench.connect('tcp://'+args['server']+':'+args['port']) # C...
python
def run(): ''' This client calls a bunch of help commands from workbench ''' # Grab server args args = client_helper.grab_server_args() # Start up workbench connection workbench = zerorpc.Client(timeout=300, heartbeat=60) workbench.connect('tcp://'+args['server']+':'+args['port']) # C...
[ "def", "run", "(", ")", ":", "# Grab server args", "args", "=", "client_helper", ".", "grab_server_args", "(", ")", "# Start up workbench connection", "workbench", "=", "zerorpc", ".", "Client", "(", "timeout", "=", "300", ",", "heartbeat", "=", "60", ")", "wo...
This client calls a bunch of help commands from workbench
[ "This", "client", "calls", "a", "bunch", "of", "help", "commands", "from", "workbench" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/clients/help_client.py#L5-L24
SuperCowPowers/workbench
workbench/workers/url.py
URLS.execute
def execute(self, input_data): ''' Execute the URL worker ''' string_output = input_data['strings']['string_list'] flatten = ' '.join(string_output) urls = self.url_match.findall(flatten) return {'url_list': urls}
python
def execute(self, input_data): ''' Execute the URL worker ''' string_output = input_data['strings']['string_list'] flatten = ' '.join(string_output) urls = self.url_match.findall(flatten) return {'url_list': urls}
[ "def", "execute", "(", "self", ",", "input_data", ")", ":", "string_output", "=", "input_data", "[", "'strings'", "]", "[", "'string_list'", "]", "flatten", "=", "' '", ".", "join", "(", "string_output", ")", "urls", "=", "self", ".", "url_match", ".", "...
Execute the URL worker
[ "Execute", "the", "URL", "worker" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/workers/url.py#L14-L19
SuperCowPowers/workbench
workbench_apps/workbench_cli/repr_to_str_decorator.py
r_to_s
def r_to_s(func): """Decorator method for Workbench methods returning a str""" @functools.wraps(func) def wrapper(*args, **kwargs): """Decorator method for Workbench methods returning a str""" class ReprToStr(str): """Replaces a class __repr__ with it's string representation"""...
python
def r_to_s(func): """Decorator method for Workbench methods returning a str""" @functools.wraps(func) def wrapper(*args, **kwargs): """Decorator method for Workbench methods returning a str""" class ReprToStr(str): """Replaces a class __repr__ with it's string representation"""...
[ "def", "r_to_s", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"Decorator method for Workbench methods returning a str\"\"\"", "class", "ReprToStr", "(", "s...
Decorator method for Workbench methods returning a str
[ "Decorator", "method", "for", "Workbench", "methods", "returning", "a", "str" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench_apps/workbench_cli/repr_to_str_decorator.py#L6-L18
SuperCowPowers/workbench
workbench/clients/upload_dir.py
all_files_in_directory
def all_files_in_directory(path): """ Recursively ist all files under a directory """ file_list = [] for dirname, dirnames, filenames in os.walk(path): for filename in filenames: file_list.append(os.path.join(dirname, filename)) return file_list
python
def all_files_in_directory(path): """ Recursively ist all files under a directory """ file_list = [] for dirname, dirnames, filenames in os.walk(path): for filename in filenames: file_list.append(os.path.join(dirname, filename)) return file_list
[ "def", "all_files_in_directory", "(", "path", ")", ":", "file_list", "=", "[", "]", "for", "dirname", ",", "dirnames", ",", "filenames", "in", "os", ".", "walk", "(", "path", ")", ":", "for", "filename", "in", "filenames", ":", "file_list", ".", "append"...
Recursively ist all files under a directory
[ "Recursively", "ist", "all", "files", "under", "a", "directory" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/clients/upload_dir.py#L9-L15
SuperCowPowers/workbench
workbench/clients/upload_dir.py
run
def run(): """This client pushes a big directory of different files into Workbench.""" # Grab server args args = client_helper.grab_server_args() # Start up workbench connection workbench = zerorpc.Client(timeout=300, heartbeat=60) workbench.connect('tcp://'+args['server']+':'+args['port']...
python
def run(): """This client pushes a big directory of different files into Workbench.""" # Grab server args args = client_helper.grab_server_args() # Start up workbench connection workbench = zerorpc.Client(timeout=300, heartbeat=60) workbench.connect('tcp://'+args['server']+':'+args['port']...
[ "def", "run", "(", ")", ":", "# Grab server args", "args", "=", "client_helper", ".", "grab_server_args", "(", ")", "# Start up workbench connection", "workbench", "=", "zerorpc", ".", "Client", "(", "timeout", "=", "300", ",", "heartbeat", "=", "60", ")", "wo...
This client pushes a big directory of different files into Workbench.
[ "This", "client", "pushes", "a", "big", "directory", "of", "different", "files", "into", "Workbench", "." ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/clients/upload_dir.py#L17-L72
SuperCowPowers/workbench
workbench/server/plugin_manager.py
PluginManager.load_all_plugins
def load_all_plugins(self): """Load all the plugins in the plugin directory""" # Go through the existing python files in the plugin directory self.plugin_path = os.path.realpath(self.plugin_dir) sys.path.append(self.plugin_dir) print '<<< Plugin Manager >>>' for f in [os...
python
def load_all_plugins(self): """Load all the plugins in the plugin directory""" # Go through the existing python files in the plugin directory self.plugin_path = os.path.realpath(self.plugin_dir) sys.path.append(self.plugin_dir) print '<<< Plugin Manager >>>' for f in [os...
[ "def", "load_all_plugins", "(", "self", ")", ":", "# Go through the existing python files in the plugin directory", "self", ".", "plugin_path", "=", "os", ".", "path", ".", "realpath", "(", "self", ".", "plugin_dir", ")", "sys", ".", "path", ".", "append", "(", ...
Load all the plugins in the plugin directory
[ "Load", "all", "the", "plugins", "in", "the", "plugin", "directory" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/plugin_manager.py#L35-L49
SuperCowPowers/workbench
workbench/server/plugin_manager.py
PluginManager.remove_plugin
def remove_plugin(self, f): """Remvoing a deleted plugin. Args: f: the filepath for the plugin. """ if f.endswith('.py'): plugin_name = os.path.splitext(os.path.basename(f))[0] print '- %s %sREMOVED' % (plugin_name, color.Red) print '\t%sN...
python
def remove_plugin(self, f): """Remvoing a deleted plugin. Args: f: the filepath for the plugin. """ if f.endswith('.py'): plugin_name = os.path.splitext(os.path.basename(f))[0] print '- %s %sREMOVED' % (plugin_name, color.Red) print '\t%sN...
[ "def", "remove_plugin", "(", "self", ",", "f", ")", ":", "if", "f", ".", "endswith", "(", "'.py'", ")", ":", "plugin_name", "=", "os", ".", "path", ".", "splitext", "(", "os", ".", "path", ".", "basename", "(", "f", ")", ")", "[", "0", "]", "pr...
Remvoing a deleted plugin. Args: f: the filepath for the plugin.
[ "Remvoing", "a", "deleted", "plugin", "." ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/plugin_manager.py#L78-L88
SuperCowPowers/workbench
workbench/server/plugin_manager.py
PluginManager.add_plugin
def add_plugin(self, f): """Adding and verifying plugin. Args: f: the filepath for the plugin. """ if f.endswith('.py'): # Just the basename without extension plugin_name = os.path.splitext(os.path.basename(f))[0] # It's possible the plu...
python
def add_plugin(self, f): """Adding and verifying plugin. Args: f: the filepath for the plugin. """ if f.endswith('.py'): # Just the basename without extension plugin_name = os.path.splitext(os.path.basename(f))[0] # It's possible the plu...
[ "def", "add_plugin", "(", "self", ",", "f", ")", ":", "if", "f", ".", "endswith", "(", "'.py'", ")", ":", "# Just the basename without extension", "plugin_name", "=", "os", ".", "path", ".", "splitext", "(", "os", ".", "path", ".", "basename", "(", "f", ...
Adding and verifying plugin. Args: f: the filepath for the plugin.
[ "Adding", "and", "verifying", "plugin", "." ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/plugin_manager.py#L90-L136
SuperCowPowers/workbench
workbench/server/plugin_manager.py
PluginManager.validate
def validate(self, handler): """Validate the plugin, each plugin must have the following: 1) The worker class must have an execute method: execute(self, input_data). 2) The worker class must have a dependencies list (even if it's empty). 3) The file must have a top level test...
python
def validate(self, handler): """Validate the plugin, each plugin must have the following: 1) The worker class must have an execute method: execute(self, input_data). 2) The worker class must have a dependencies list (even if it's empty). 3) The file must have a top level test...
[ "def", "validate", "(", "self", ",", "handler", ")", ":", "# Check for the test method first", "test_method", "=", "self", ".", "plugin_test_validation", "(", "handler", ")", "if", "not", "test_method", ":", "return", "None", "# Here we iterate through the classes found...
Validate the plugin, each plugin must have the following: 1) The worker class must have an execute method: execute(self, input_data). 2) The worker class must have a dependencies list (even if it's empty). 3) The file must have a top level test() method. Args: ha...
[ "Validate", "the", "plugin", "each", "plugin", "must", "have", "the", "following", ":", "1", ")", "The", "worker", "class", "must", "have", "an", "execute", "method", ":", "execute", "(", "self", "input_data", ")", ".", "2", ")", "The", "worker", "class"...
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/plugin_manager.py#L138-L162
SuperCowPowers/workbench
workbench/server/plugin_manager.py
PluginManager.plugin_class_validation
def plugin_class_validation(self, plugin_class): """Plugin validation Every workbench plugin must have a dependencies list (even if it's empty). Every workbench plugin must have an execute method. Args: plugin_class: The loaded plugun class. Returns: ...
python
def plugin_class_validation(self, plugin_class): """Plugin validation Every workbench plugin must have a dependencies list (even if it's empty). Every workbench plugin must have an execute method. Args: plugin_class: The loaded plugun class. Returns: ...
[ "def", "plugin_class_validation", "(", "self", ",", "plugin_class", ")", ":", "try", ":", "getattr", "(", "plugin_class", ",", "'dependencies'", ")", "getattr", "(", "plugin_class", ",", "'execute'", ")", "except", "AttributeError", ":", "return", "False", "retu...
Plugin validation Every workbench plugin must have a dependencies list (even if it's empty). Every workbench plugin must have an execute method. Args: plugin_class: The loaded plugun class. Returns: True if dependencies and execute are present, else F...
[ "Plugin", "validation", "Every", "workbench", "plugin", "must", "have", "a", "dependencies", "list", "(", "even", "if", "it", "s", "empty", ")", ".", "Every", "workbench", "plugin", "must", "have", "an", "execute", "method", "." ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/plugin_manager.py#L183-L202
SuperCowPowers/workbench
workbench/server/data_store.py
DataStore.store_sample
def store_sample(self, sample_bytes, filename, type_tag): """Store a sample into the datastore. Args: filename: Name of the file. sample_bytes: Actual bytes of sample. type_tag: Type of sample ('exe','pcap','pdf','json','swf', or ...) Returns: m...
python
def store_sample(self, sample_bytes, filename, type_tag): """Store a sample into the datastore. Args: filename: Name of the file. sample_bytes: Actual bytes of sample. type_tag: Type of sample ('exe','pcap','pdf','json','swf', or ...) Returns: m...
[ "def", "store_sample", "(", "self", ",", "sample_bytes", ",", "filename", ",", "type_tag", ")", ":", "# Temp sanity check for old clients", "if", "len", "(", "filename", ")", ">", "1000", ":", "print", "'switched bytes/filename... %s %s'", "%", "(", "sample_bytes", ...
Store a sample into the datastore. Args: filename: Name of the file. sample_bytes: Actual bytes of sample. type_tag: Type of sample ('exe','pcap','pdf','json','swf', or ...) Returns: md5 digest of the sample.
[ "Store", "a", "sample", "into", "the", "datastore", "." ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/data_store.py#L51-L102
SuperCowPowers/workbench
workbench/server/data_store.py
DataStore.sample_storage_size
def sample_storage_size(self): """Get the storage size of the samples storage collection.""" try: coll_stats = self.database.command('collStats', 'fs.chunks') sample_storage_size = coll_stats['size']/1024.0/1024.0 return sample_storage_size except pymongo.err...
python
def sample_storage_size(self): """Get the storage size of the samples storage collection.""" try: coll_stats = self.database.command('collStats', 'fs.chunks') sample_storage_size = coll_stats['size']/1024.0/1024.0 return sample_storage_size except pymongo.err...
[ "def", "sample_storage_size", "(", "self", ")", ":", "try", ":", "coll_stats", "=", "self", ".", "database", ".", "command", "(", "'collStats'", ",", "'fs.chunks'", ")", "sample_storage_size", "=", "coll_stats", "[", "'size'", "]", "/", "1024.0", "/", "1024....
Get the storage size of the samples storage collection.
[ "Get", "the", "storage", "size", "of", "the", "samples", "storage", "collection", "." ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/data_store.py#L104-L112
SuperCowPowers/workbench
workbench/server/data_store.py
DataStore.expire_data
def expire_data(self): """Expire data within the samples collection.""" # Do we need to start deleting stuff? while self.sample_storage_size() > self.samples_cap: # This should return the 'oldest' record in samples record = self.database[self.sample_collection].find().s...
python
def expire_data(self): """Expire data within the samples collection.""" # Do we need to start deleting stuff? while self.sample_storage_size() > self.samples_cap: # This should return the 'oldest' record in samples record = self.database[self.sample_collection].find().s...
[ "def", "expire_data", "(", "self", ")", ":", "# Do we need to start deleting stuff?", "while", "self", ".", "sample_storage_size", "(", ")", ">", "self", ".", "samples_cap", ":", "# This should return the 'oldest' record in samples", "record", "=", "self", ".", "databas...
Expire data within the samples collection.
[ "Expire", "data", "within", "the", "samples", "collection", "." ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/data_store.py#L114-L122
SuperCowPowers/workbench
workbench/server/data_store.py
DataStore.remove_sample
def remove_sample(self, md5): """Delete a specific sample""" # Grab the sample record = self.database[self.sample_collection].find_one({'md5': md5}) if not record: return # Delete it print 'Deleting sample: %s (%.2f MB)...' % (record['md5'], record['length']...
python
def remove_sample(self, md5): """Delete a specific sample""" # Grab the sample record = self.database[self.sample_collection].find_one({'md5': md5}) if not record: return # Delete it print 'Deleting sample: %s (%.2f MB)...' % (record['md5'], record['length']...
[ "def", "remove_sample", "(", "self", ",", "md5", ")", ":", "# Grab the sample", "record", "=", "self", ".", "database", "[", "self", ".", "sample_collection", "]", ".", "find_one", "(", "{", "'md5'", ":", "md5", "}", ")", "if", "not", "record", ":", "r...
Delete a specific sample
[ "Delete", "a", "specific", "sample" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/data_store.py#L124-L138
SuperCowPowers/workbench
workbench/server/data_store.py
DataStore.clean_for_serialization
def clean_for_serialization(self, data): """Clean data in preparation for serialization. Deletes items having key either a BSON, datetime, dict or a list instance, or starting with __. Args: data: Sample data to be serialized. Returns: Cleaned data dict...
python
def clean_for_serialization(self, data): """Clean data in preparation for serialization. Deletes items having key either a BSON, datetime, dict or a list instance, or starting with __. Args: data: Sample data to be serialized. Returns: Cleaned data dict...
[ "def", "clean_for_serialization", "(", "self", ",", "data", ")", ":", "if", "isinstance", "(", "data", ",", "dict", ")", ":", "for", "k", "in", "data", ".", "keys", "(", ")", ":", "if", "(", "k", ".", "startswith", "(", "'__'", ")", ")", ":", "de...
Clean data in preparation for serialization. Deletes items having key either a BSON, datetime, dict or a list instance, or starting with __. Args: data: Sample data to be serialized. Returns: Cleaned data dictionary.
[ "Clean", "data", "in", "preparation", "for", "serialization", "." ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/data_store.py#L140-L165
SuperCowPowers/workbench
workbench/server/data_store.py
DataStore.clean_for_storage
def clean_for_storage(self, data): """Clean data in preparation for storage. Deletes items with key having a '.' or is '_id'. Also deletes those items whose value is a dictionary or a list. Args: data: Sample data dictionary to be cleaned. Returns: Clea...
python
def clean_for_storage(self, data): """Clean data in preparation for storage. Deletes items with key having a '.' or is '_id'. Also deletes those items whose value is a dictionary or a list. Args: data: Sample data dictionary to be cleaned. Returns: Clea...
[ "def", "clean_for_storage", "(", "self", ",", "data", ")", ":", "data", "=", "self", ".", "data_to_unicode", "(", "data", ")", "if", "isinstance", "(", "data", ",", "dict", ")", ":", "for", "k", "in", "dict", "(", "data", ")", ".", "keys", "(", ")"...
Clean data in preparation for storage. Deletes items with key having a '.' or is '_id'. Also deletes those items whose value is a dictionary or a list. Args: data: Sample data dictionary to be cleaned. Returns: Cleaned data dictionary.
[ "Clean", "data", "in", "preparation", "for", "storage", "." ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/data_store.py#L167-L194
SuperCowPowers/workbench
workbench/server/data_store.py
DataStore.get_full_md5
def get_full_md5(self, partial_md5, collection): """Support partial/short md5s, return the full md5 with this method""" print 'Notice: Performing slow md5 search...' starts_with = '%s.*' % partial_md5 sample_info = self.database[collection].find_one({'md5': {'$regex' : starts_with}},{'md...
python
def get_full_md5(self, partial_md5, collection): """Support partial/short md5s, return the full md5 with this method""" print 'Notice: Performing slow md5 search...' starts_with = '%s.*' % partial_md5 sample_info = self.database[collection].find_one({'md5': {'$regex' : starts_with}},{'md...
[ "def", "get_full_md5", "(", "self", ",", "partial_md5", ",", "collection", ")", ":", "print", "'Notice: Performing slow md5 search...'", "starts_with", "=", "'%s.*'", "%", "partial_md5", "sample_info", "=", "self", ".", "database", "[", "collection", "]", ".", "fi...
Support partial/short md5s, return the full md5 with this method
[ "Support", "partial", "/", "short", "md5s", "return", "the", "full", "md5", "with", "this", "method" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/data_store.py#L196-L201
SuperCowPowers/workbench
workbench/server/data_store.py
DataStore.get_sample
def get_sample(self, md5): """Get the sample from the data store. This method first fetches the data from datastore, then cleans it for serialization and then updates it with 'raw_bytes' item. Args: md5: The md5 digest of the sample to be fetched from datastore. ...
python
def get_sample(self, md5): """Get the sample from the data store. This method first fetches the data from datastore, then cleans it for serialization and then updates it with 'raw_bytes' item. Args: md5: The md5 digest of the sample to be fetched from datastore. ...
[ "def", "get_sample", "(", "self", ",", "md5", ")", ":", "# Support 'short' md5s but don't waste performance if the full md5 is provided", "if", "len", "(", "md5", ")", "<", "32", ":", "md5", "=", "self", ".", "get_full_md5", "(", "md5", ",", "self", ".", "sample...
Get the sample from the data store. This method first fetches the data from datastore, then cleans it for serialization and then updates it with 'raw_bytes' item. Args: md5: The md5 digest of the sample to be fetched from datastore. Returns: The sample ...
[ "Get", "the", "sample", "from", "the", "data", "store", "." ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/data_store.py#L203-L234
SuperCowPowers/workbench
workbench/server/data_store.py
DataStore.get_sample_window
def get_sample_window(self, type_tag, size=10): """Get a window of samples not to exceed size (in MB). Args: type_tag: Type of sample ('exe','pcap','pdf','json','swf', or ...). size: Size of samples in MBs. Returns: a list of md5s. """ # Con...
python
def get_sample_window(self, type_tag, size=10): """Get a window of samples not to exceed size (in MB). Args: type_tag: Type of sample ('exe','pcap','pdf','json','swf', or ...). size: Size of samples in MBs. Returns: a list of md5s. """ # Con...
[ "def", "get_sample_window", "(", "self", ",", "type_tag", ",", "size", "=", "10", ")", ":", "# Convert size to MB", "size", "=", "size", "*", "1024", "*", "1024", "# Grab all the samples of type=type_tag, sort by import_time (newest to oldest)", "cursor", "=", "self", ...
Get a window of samples not to exceed size (in MB). Args: type_tag: Type of sample ('exe','pcap','pdf','json','swf', or ...). size: Size of samples in MBs. Returns: a list of md5s.
[ "Get", "a", "window", "of", "samples", "not", "to", "exceed", "size", "(", "in", "MB", ")", "." ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/data_store.py#L236-L263
SuperCowPowers/workbench
workbench/server/data_store.py
DataStore.has_sample
def has_sample(self, md5): """Checks if data store has this sample. Args: md5: The md5 digest of the required sample. Returns: True if sample with this md5 is present, else False. """ # The easiest thing is to simply get the sample and if that #...
python
def has_sample(self, md5): """Checks if data store has this sample. Args: md5: The md5 digest of the required sample. Returns: True if sample with this md5 is present, else False. """ # The easiest thing is to simply get the sample and if that #...
[ "def", "has_sample", "(", "self", ",", "md5", ")", ":", "# The easiest thing is to simply get the sample and if that", "# succeeds than return True, else return False", "sample", "=", "self", ".", "get_sample", "(", "md5", ")", "return", "True", "if", "sample", "else", ...
Checks if data store has this sample. Args: md5: The md5 digest of the required sample. Returns: True if sample with this md5 is present, else False.
[ "Checks", "if", "data", "store", "has", "this", "sample", "." ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/data_store.py#L265-L278
SuperCowPowers/workbench
workbench/server/data_store.py
DataStore._list_samples
def _list_samples(self, predicate=None): """List all samples that meet the predicate or all if predicate is not specified. Args: predicate: Match samples against this predicate (or all if not specified) Returns: List of the md5s for the matching samples """ ...
python
def _list_samples(self, predicate=None): """List all samples that meet the predicate or all if predicate is not specified. Args: predicate: Match samples against this predicate (or all if not specified) Returns: List of the md5s for the matching samples """ ...
[ "def", "_list_samples", "(", "self", ",", "predicate", "=", "None", ")", ":", "cursor", "=", "self", ".", "database", "[", "self", ".", "sample_collection", "]", ".", "find", "(", "predicate", ",", "{", "'_id'", ":", "0", ",", "'md5'", ":", "1", "}",...
List all samples that meet the predicate or all if predicate is not specified. Args: predicate: Match samples against this predicate (or all if not specified) Returns: List of the md5s for the matching samples
[ "List", "all", "samples", "that", "meet", "the", "predicate", "or", "all", "if", "predicate", "is", "not", "specified", "." ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/data_store.py#L280-L290
SuperCowPowers/workbench
workbench/server/data_store.py
DataStore.tag_match
def tag_match(self, tags=None): """List all samples that match the tags or all if tags are not specified. Args: tags: Match samples against these tags (or all if not specified) Returns: List of the md5s for the matching samples """ if 'tags' not in self....
python
def tag_match(self, tags=None): """List all samples that match the tags or all if tags are not specified. Args: tags: Match samples against these tags (or all if not specified) Returns: List of the md5s for the matching samples """ if 'tags' not in self....
[ "def", "tag_match", "(", "self", ",", "tags", "=", "None", ")", ":", "if", "'tags'", "not", "in", "self", ".", "database", ".", "collection_names", "(", ")", ":", "print", "'Warning: Searching on non-existance tags collection'", "return", "None", "if", "not", ...
List all samples that match the tags or all if tags are not specified. Args: tags: Match samples against these tags (or all if not specified) Returns: List of the md5s for the matching samples
[ "List", "all", "samples", "that", "match", "the", "tags", "or", "all", "if", "tags", "are", "not", "specified", "." ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/data_store.py#L292-L313
SuperCowPowers/workbench
workbench/server/data_store.py
DataStore.tags_all
def tags_all(self): """List of the tags and md5s for all samples Args: None Returns: List of the tags and md5s for all samples """ if 'tags' not in self.database.collection_names(): print 'Warning: Searching on non-existance tags collection' ...
python
def tags_all(self): """List of the tags and md5s for all samples Args: None Returns: List of the tags and md5s for all samples """ if 'tags' not in self.database.collection_names(): print 'Warning: Searching on non-existance tags collection' ...
[ "def", "tags_all", "(", "self", ")", ":", "if", "'tags'", "not", "in", "self", ".", "database", ".", "collection_names", "(", ")", ":", "print", "'Warning: Searching on non-existance tags collection'", "return", "None", "cursor", "=", "self", ".", "database", "[...
List of the tags and md5s for all samples Args: None Returns: List of the tags and md5s for all samples
[ "List", "of", "the", "tags", "and", "md5s", "for", "all", "samples", "Args", ":", "None" ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/data_store.py#L315-L328
SuperCowPowers/workbench
workbench/server/data_store.py
DataStore.store_work_results
def store_work_results(self, results, collection, md5): """Store the output results of the worker. Args: results: a dictionary. collection: the database collection to store the results in. md5: the md5 of sample data to be updated. """ # Make sure t...
python
def store_work_results(self, results, collection, md5): """Store the output results of the worker. Args: results: a dictionary. collection: the database collection to store the results in. md5: the md5 of sample data to be updated. """ # Make sure t...
[ "def", "store_work_results", "(", "self", ",", "results", ",", "collection", ",", "md5", ")", ":", "# Make sure the md5 and time stamp is on the data before storing", "results", "[", "'md5'", "]", "=", "md5", "results", "[", "'__time_stamp'", "]", "=", "datetime", "...
Store the output results of the worker. Args: results: a dictionary. collection: the database collection to store the results in. md5: the md5 of sample data to be updated.
[ "Store", "the", "output", "results", "of", "the", "worker", "." ]
train
https://github.com/SuperCowPowers/workbench/blob/710232756dd717f734253315e3d0b33c9628dafb/workbench/server/data_store.py#L330-L356