id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
41,900
rackerlabs/python-lunrclient
lunrclient/lunr_shell.py
Account.create
def create(self, id): """ Create a new tenant id """ resp = self.client.accounts.create(id=id) self.display(resp)
python
def create(self, id): """ Create a new tenant id """ resp = self.client.accounts.create(id=id) self.display(resp)
[ "def", "create", "(", "self", ",", "id", ")", ":", "resp", "=", "self", ".", "client", ".", "accounts", ".", "create", "(", "id", "=", "id", ")", "self", ".", "display", "(", "resp", ")" ]
Create a new tenant id
[ "Create", "a", "new", "tenant", "id" ]
f26a450a422600f492480bfa42cbee50a5c7016f
https://github.com/rackerlabs/python-lunrclient/blob/f26a450a422600f492480bfa42cbee50a5c7016f/lunrclient/lunr_shell.py#L324-L327
41,901
rackerlabs/python-lunrclient
lunrclient/lunr_shell.py
Account.delete
def delete(self, id): """ Delete an tenant id """ resp = self.client.accounts.delete(id) self.display(resp)
python
def delete(self, id): """ Delete an tenant id """ resp = self.client.accounts.delete(id) self.display(resp)
[ "def", "delete", "(", "self", ",", "id", ")", ":", "resp", "=", "self", ".", "client", ".", "accounts", ".", "delete", "(", "id", ")", "self", ".", "display", "(", "resp", ")" ]
Delete an tenant id
[ "Delete", "an", "tenant", "id" ]
f26a450a422600f492480bfa42cbee50a5c7016f
https://github.com/rackerlabs/python-lunrclient/blob/f26a450a422600f492480bfa42cbee50a5c7016f/lunrclient/lunr_shell.py#L330-L333
41,902
bimbar/pykwb
pykwb/kwb.py
main
def main(): """Main method for debug purposes.""" parser = argparse.ArgumentParser() group_tcp = parser.add_argument_group('TCP') group_tcp.add_argument('--tcp', dest='mode', action='store_const', const=PROP_MODE_TCP, help="Set tcp mode") group_tcp.add_argument('--host', dest='hostname', help="Speci...
python
def main(): """Main method for debug purposes.""" parser = argparse.ArgumentParser() group_tcp = parser.add_argument_group('TCP') group_tcp.add_argument('--tcp', dest='mode', action='store_const', const=PROP_MODE_TCP, help="Set tcp mode") group_tcp.add_argument('--host', dest='hostname', help="Speci...
[ "def", "main", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "group_tcp", "=", "parser", ".", "add_argument_group", "(", "'TCP'", ")", "group_tcp", ".", "add_argument", "(", "'--tcp'", ",", "dest", "=", "'mode'", ",", "action",...
Main method for debug purposes.
[ "Main", "method", "for", "debug", "purposes", "." ]
3f607c064cc53b8310d22d42506ce817a5b735fe
https://github.com/bimbar/pykwb/blob/3f607c064cc53b8310d22d42506ce817a5b735fe/pykwb/kwb.py#L427-L446
41,903
bimbar/pykwb
pykwb/kwb.py
KWBEasyfire._open_connection
def _open_connection(self): """Open a connection to the easyfire unit.""" if (self._mode == PROP_MODE_SERIAL): self._serial = serial.Serial(self._serial_device, self._serial_speed) elif (self._mode == PROP_MODE_TCP): self._socket = socket.socket(socket.AF_INET, socket.SOC...
python
def _open_connection(self): """Open a connection to the easyfire unit.""" if (self._mode == PROP_MODE_SERIAL): self._serial = serial.Serial(self._serial_device, self._serial_speed) elif (self._mode == PROP_MODE_TCP): self._socket = socket.socket(socket.AF_INET, socket.SOC...
[ "def", "_open_connection", "(", "self", ")", ":", "if", "(", "self", ".", "_mode", "==", "PROP_MODE_SERIAL", ")", ":", "self", ".", "_serial", "=", "serial", ".", "Serial", "(", "self", ".", "_serial_device", ",", "self", ".", "_serial_speed", ")", "elif...
Open a connection to the easyfire unit.
[ "Open", "a", "connection", "to", "the", "easyfire", "unit", "." ]
3f607c064cc53b8310d22d42506ce817a5b735fe
https://github.com/bimbar/pykwb/blob/3f607c064cc53b8310d22d42506ce817a5b735fe/pykwb/kwb.py#L187-L195
41,904
bimbar/pykwb
pykwb/kwb.py
KWBEasyfire._close_connection
def _close_connection(self): """Close the connection to the easyfire unit.""" if (self._mode == PROP_MODE_SERIAL): self._serial.close() elif (self._mode == PROP_MODE_TCP): self._socket.close() elif (self._mode == PROP_MODE_FILE): self._file.close()
python
def _close_connection(self): """Close the connection to the easyfire unit.""" if (self._mode == PROP_MODE_SERIAL): self._serial.close() elif (self._mode == PROP_MODE_TCP): self._socket.close() elif (self._mode == PROP_MODE_FILE): self._file.close()
[ "def", "_close_connection", "(", "self", ")", ":", "if", "(", "self", ".", "_mode", "==", "PROP_MODE_SERIAL", ")", ":", "self", ".", "_serial", ".", "close", "(", ")", "elif", "(", "self", ".", "_mode", "==", "PROP_MODE_TCP", ")", ":", "self", ".", "...
Close the connection to the easyfire unit.
[ "Close", "the", "connection", "to", "the", "easyfire", "unit", "." ]
3f607c064cc53b8310d22d42506ce817a5b735fe
https://github.com/bimbar/pykwb/blob/3f607c064cc53b8310d22d42506ce817a5b735fe/pykwb/kwb.py#L197-L204
41,905
bimbar/pykwb
pykwb/kwb.py
KWBEasyfire._add_to_checksum
def _add_to_checksum(self, checksum, value): """Add a byte to the checksum.""" checksum = self._byte_rot_left(checksum, 1) checksum = checksum + value if (checksum > 255): checksum = checksum - 255 self._debug(PROP_LOGLEVEL_TRACE, "C: " + str(checksum) + " V: " + str(...
python
def _add_to_checksum(self, checksum, value): """Add a byte to the checksum.""" checksum = self._byte_rot_left(checksum, 1) checksum = checksum + value if (checksum > 255): checksum = checksum - 255 self._debug(PROP_LOGLEVEL_TRACE, "C: " + str(checksum) + " V: " + str(...
[ "def", "_add_to_checksum", "(", "self", ",", "checksum", ",", "value", ")", ":", "checksum", "=", "self", ".", "_byte_rot_left", "(", "checksum", ",", "1", ")", "checksum", "=", "checksum", "+", "value", "if", "(", "checksum", ">", "255", ")", ":", "ch...
Add a byte to the checksum.
[ "Add", "a", "byte", "to", "the", "checksum", "." ]
3f607c064cc53b8310d22d42506ce817a5b735fe
https://github.com/bimbar/pykwb/blob/3f607c064cc53b8310d22d42506ce817a5b735fe/pykwb/kwb.py#L211-L218
41,906
bimbar/pykwb
pykwb/kwb.py
KWBEasyfire._read_byte
def _read_byte(self): """Read a byte from input.""" to_return = "" if (self._mode == PROP_MODE_SERIAL): to_return = self._serial.read(1) elif (self._mode == PROP_MODE_TCP): to_return = self._socket.recv(1) elif (self._mode == PROP_MODE_FILE): ...
python
def _read_byte(self): """Read a byte from input.""" to_return = "" if (self._mode == PROP_MODE_SERIAL): to_return = self._serial.read(1) elif (self._mode == PROP_MODE_TCP): to_return = self._socket.recv(1) elif (self._mode == PROP_MODE_FILE): ...
[ "def", "_read_byte", "(", "self", ")", ":", "to_return", "=", "\"\"", "if", "(", "self", ".", "_mode", "==", "PROP_MODE_SERIAL", ")", ":", "to_return", "=", "self", ".", "_serial", ".", "read", "(", "1", ")", "elif", "(", "self", ".", "_mode", "==", ...
Read a byte from input.
[ "Read", "a", "byte", "from", "input", "." ]
3f607c064cc53b8310d22d42506ce817a5b735fe
https://github.com/bimbar/pykwb/blob/3f607c064cc53b8310d22d42506ce817a5b735fe/pykwb/kwb.py#L220-L238
41,907
bimbar/pykwb
pykwb/kwb.py
KWBEasyfire._decode_temp
def _decode_temp(byte_1, byte_2): """Decode a signed short temperature as two bytes to a single number.""" temp = (byte_1 << 8) + byte_2 if (temp > 32767): temp = temp - 65536 temp = temp / 10 return temp
python
def _decode_temp(byte_1, byte_2): """Decode a signed short temperature as two bytes to a single number.""" temp = (byte_1 << 8) + byte_2 if (temp > 32767): temp = temp - 65536 temp = temp / 10 return temp
[ "def", "_decode_temp", "(", "byte_1", ",", "byte_2", ")", ":", "temp", "=", "(", "byte_1", "<<", "8", ")", "+", "byte_2", "if", "(", "temp", ">", "32767", ")", ":", "temp", "=", "temp", "-", "65536", "temp", "=", "temp", "/", "10", "return", "tem...
Decode a signed short temperature as two bytes to a single number.
[ "Decode", "a", "signed", "short", "temperature", "as", "two", "bytes", "to", "a", "single", "number", "." ]
3f607c064cc53b8310d22d42506ce817a5b735fe
https://github.com/bimbar/pykwb/blob/3f607c064cc53b8310d22d42506ce817a5b735fe/pykwb/kwb.py#L259-L265
41,908
bimbar/pykwb
pykwb/kwb.py
KWBEasyfire._read_packet
def _read_packet(self): """Read a packet from the input.""" status = STATUS_WAITING mode = 0 checksum = 0 checksum_calculated = 0 length = 0 version = 0 i = 0 cnt = 0 packet = bytearray(0) while (status != STATUS_PACKET_DONE): ...
python
def _read_packet(self): """Read a packet from the input.""" status = STATUS_WAITING mode = 0 checksum = 0 checksum_calculated = 0 length = 0 version = 0 i = 0 cnt = 0 packet = bytearray(0) while (status != STATUS_PACKET_DONE): ...
[ "def", "_read_packet", "(", "self", ")", ":", "status", "=", "STATUS_WAITING", "mode", "=", "0", "checksum", "=", "0", "checksum_calculated", "=", "0", "length", "=", "0", "version", "=", "0", "i", "=", "0", "cnt", "=", "0", "packet", "=", "bytearray",...
Read a packet from the input.
[ "Read", "a", "packet", "from", "the", "input", "." ]
3f607c064cc53b8310d22d42506ce817a5b735fe
https://github.com/bimbar/pykwb/blob/3f607c064cc53b8310d22d42506ce817a5b735fe/pykwb/kwb.py#L268-L346
41,909
bimbar/pykwb
pykwb/kwb.py
KWBEasyfire._decode_sense_packet
def _decode_sense_packet(self, version, packet): """Decode a sense packet into the list of sensors.""" data = self._sense_packet_to_data(packet) offset = 4 i = 0 datalen = len(data) - offset - 6 temp_count = int(datalen / 2) temp = [] for i in range(te...
python
def _decode_sense_packet(self, version, packet): """Decode a sense packet into the list of sensors.""" data = self._sense_packet_to_data(packet) offset = 4 i = 0 datalen = len(data) - offset - 6 temp_count = int(datalen / 2) temp = [] for i in range(te...
[ "def", "_decode_sense_packet", "(", "self", ",", "version", ",", "packet", ")", ":", "data", "=", "self", ".", "_sense_packet_to_data", "(", "packet", ")", "offset", "=", "4", "i", "=", "0", "datalen", "=", "len", "(", "data", ")", "-", "offset", "-", ...
Decode a sense packet into the list of sensors.
[ "Decode", "a", "sense", "packet", "into", "the", "list", "of", "sensors", "." ]
3f607c064cc53b8310d22d42506ce817a5b735fe
https://github.com/bimbar/pykwb/blob/3f607c064cc53b8310d22d42506ce817a5b735fe/pykwb/kwb.py#L348-L372
41,910
bimbar/pykwb
pykwb/kwb.py
KWBEasyfire._decode_ctrl_packet
def _decode_ctrl_packet(self, version, packet): """Decode a control packet into the list of sensors.""" for i in range(5): input_bit = packet[i] self._debug(PROP_LOGLEVEL_DEBUG, "Byte " + str(i) + ": " + str((input_bit >> 7) & 1) + str((input_bit >> 6) & 1) + str((input_bit >> 5...
python
def _decode_ctrl_packet(self, version, packet): """Decode a control packet into the list of sensors.""" for i in range(5): input_bit = packet[i] self._debug(PROP_LOGLEVEL_DEBUG, "Byte " + str(i) + ": " + str((input_bit >> 7) & 1) + str((input_bit >> 6) & 1) + str((input_bit >> 5...
[ "def", "_decode_ctrl_packet", "(", "self", ",", "version", ",", "packet", ")", ":", "for", "i", "in", "range", "(", "5", ")", ":", "input_bit", "=", "packet", "[", "i", "]", "self", ".", "_debug", "(", "PROP_LOGLEVEL_DEBUG", ",", "\"Byte \"", "+", "str...
Decode a control packet into the list of sensors.
[ "Decode", "a", "control", "packet", "into", "the", "list", "of", "sensors", "." ]
3f607c064cc53b8310d22d42506ce817a5b735fe
https://github.com/bimbar/pykwb/blob/3f607c064cc53b8310d22d42506ce817a5b735fe/pykwb/kwb.py#L374-L385
41,911
bimbar/pykwb
pykwb/kwb.py
KWBEasyfire.run
def run(self): """Main thread that reads from input and populates the sensors.""" while (self._run_thread): (mode, version, packet) = self._read_packet() if (mode == PROP_PACKET_SENSE): self._decode_sense_packet(version, packet) elif (mode == PROP_PACK...
python
def run(self): """Main thread that reads from input and populates the sensors.""" while (self._run_thread): (mode, version, packet) = self._read_packet() if (mode == PROP_PACKET_SENSE): self._decode_sense_packet(version, packet) elif (mode == PROP_PACK...
[ "def", "run", "(", "self", ")", ":", "while", "(", "self", ".", "_run_thread", ")", ":", "(", "mode", ",", "version", ",", "packet", ")", "=", "self", ".", "_read_packet", "(", ")", "if", "(", "mode", "==", "PROP_PACKET_SENSE", ")", ":", "self", "....
Main thread that reads from input and populates the sensors.
[ "Main", "thread", "that", "reads", "from", "input", "and", "populates", "the", "sensors", "." ]
3f607c064cc53b8310d22d42506ce817a5b735fe
https://github.com/bimbar/pykwb/blob/3f607c064cc53b8310d22d42506ce817a5b735fe/pykwb/kwb.py#L403-L410
41,912
bimbar/pykwb
pykwb/kwb.py
KWBEasyfire.run_thread
def run_thread(self): """Run the main thread.""" self._run_thread = True self._thread.setDaemon(True) self._thread.start()
python
def run_thread(self): """Run the main thread.""" self._run_thread = True self._thread.setDaemon(True) self._thread.start()
[ "def", "run_thread", "(", "self", ")", ":", "self", ".", "_run_thread", "=", "True", "self", ".", "_thread", ".", "setDaemon", "(", "True", ")", "self", ".", "_thread", ".", "start", "(", ")" ]
Run the main thread.
[ "Run", "the", "main", "thread", "." ]
3f607c064cc53b8310d22d42506ce817a5b735fe
https://github.com/bimbar/pykwb/blob/3f607c064cc53b8310d22d42506ce817a5b735fe/pykwb/kwb.py#L412-L416
41,913
rackerlabs/python-lunrclient
lunrclient/base.py
BaseAPI.unused
def unused(self, _dict): """ Remove empty parameters from the dict """ for key, value in _dict.items(): if value is None: del _dict[key] return _dict
python
def unused(self, _dict): """ Remove empty parameters from the dict """ for key, value in _dict.items(): if value is None: del _dict[key] return _dict
[ "def", "unused", "(", "self", ",", "_dict", ")", ":", "for", "key", ",", "value", "in", "_dict", ".", "items", "(", ")", ":", "if", "value", "is", "None", ":", "del", "_dict", "[", "key", "]", "return", "_dict" ]
Remove empty parameters from the dict
[ "Remove", "empty", "parameters", "from", "the", "dict" ]
f26a450a422600f492480bfa42cbee50a5c7016f
https://github.com/rackerlabs/python-lunrclient/blob/f26a450a422600f492480bfa42cbee50a5c7016f/lunrclient/base.py#L115-L122
41,914
rackerlabs/python-lunrclient
lunrclient/base.py
BaseAPI.required
def required(self, method, _dict, require): """ Ensure the required items are in the dictionary """ for key in require: if key not in _dict: raise LunrError("'%s' is required argument for method '%s'" % (key, method))
python
def required(self, method, _dict, require): """ Ensure the required items are in the dictionary """ for key in require: if key not in _dict: raise LunrError("'%s' is required argument for method '%s'" % (key, method))
[ "def", "required", "(", "self", ",", "method", ",", "_dict", ",", "require", ")", ":", "for", "key", "in", "require", ":", "if", "key", "not", "in", "_dict", ":", "raise", "LunrError", "(", "\"'%s' is required argument for method '%s'\"", "%", "(", "key", ...
Ensure the required items are in the dictionary
[ "Ensure", "the", "required", "items", "are", "in", "the", "dictionary" ]
f26a450a422600f492480bfa42cbee50a5c7016f
https://github.com/rackerlabs/python-lunrclient/blob/f26a450a422600f492480bfa42cbee50a5c7016f/lunrclient/base.py#L124-L131
41,915
rackerlabs/python-lunrclient
lunrclient/base.py
BaseAPI.allowed
def allowed(self, method, _dict, allow): """ Only these items are allowed in the dictionary """ for key in _dict.keys(): if key not in allow: raise LunrError("'%s' is not an argument for method '%s'" % (key, method))
python
def allowed(self, method, _dict, allow): """ Only these items are allowed in the dictionary """ for key in _dict.keys(): if key not in allow: raise LunrError("'%s' is not an argument for method '%s'" % (key, method))
[ "def", "allowed", "(", "self", ",", "method", ",", "_dict", ",", "allow", ")", ":", "for", "key", "in", "_dict", ".", "keys", "(", ")", ":", "if", "key", "not", "in", "allow", ":", "raise", "LunrError", "(", "\"'%s' is not an argument for method '%s'\"", ...
Only these items are allowed in the dictionary
[ "Only", "these", "items", "are", "allowed", "in", "the", "dictionary" ]
f26a450a422600f492480bfa42cbee50a5c7016f
https://github.com/rackerlabs/python-lunrclient/blob/f26a450a422600f492480bfa42cbee50a5c7016f/lunrclient/base.py#L133-L140
41,916
Yipit/eventlib
eventlib/core.py
parse_event_name
def parse_event_name(name): """Returns the python module and obj given an event name """ try: app, event = name.split('.') return '{}.{}'.format(app, EVENTS_MODULE_NAME), event except ValueError: raise InvalidEventNameError( (u'The name "{}" is invalid. ' ...
python
def parse_event_name(name): """Returns the python module and obj given an event name """ try: app, event = name.split('.') return '{}.{}'.format(app, EVENTS_MODULE_NAME), event except ValueError: raise InvalidEventNameError( (u'The name "{}" is invalid. ' ...
[ "def", "parse_event_name", "(", "name", ")", ":", "try", ":", "app", ",", "event", "=", "name", ".", "split", "(", "'.'", ")", "return", "'{}.{}'", ".", "format", "(", "app", ",", "EVENTS_MODULE_NAME", ")", ",", "event", "except", "ValueError", ":", "r...
Returns the python module and obj given an event name
[ "Returns", "the", "python", "module", "and", "obj", "given", "an", "event", "name" ]
0cf29e5251a59fcbfc727af5f5157a3bb03832e2
https://github.com/Yipit/eventlib/blob/0cf29e5251a59fcbfc727af5f5157a3bb03832e2/eventlib/core.py#L44-L54
41,917
Yipit/eventlib
eventlib/core.py
find_event
def find_event(name): """Actually import the event represented by name Raises the `EventNotFoundError` if it's not possible to find the event class refered by `name`. """ try: module, klass = parse_event_name(name) return getattr(import_module(module), klass) except (ImportError...
python
def find_event(name): """Actually import the event represented by name Raises the `EventNotFoundError` if it's not possible to find the event class refered by `name`. """ try: module, klass = parse_event_name(name) return getattr(import_module(module), klass) except (ImportError...
[ "def", "find_event", "(", "name", ")", ":", "try", ":", "module", ",", "klass", "=", "parse_event_name", "(", "name", ")", "return", "getattr", "(", "import_module", "(", "module", ")", ",", "klass", ")", "except", "(", "ImportError", ",", "AttributeError"...
Actually import the event represented by name Raises the `EventNotFoundError` if it's not possible to find the event class refered by `name`.
[ "Actually", "import", "the", "event", "represented", "by", "name" ]
0cf29e5251a59fcbfc727af5f5157a3bb03832e2
https://github.com/Yipit/eventlib/blob/0cf29e5251a59fcbfc727af5f5157a3bb03832e2/eventlib/core.py#L63-L76
41,918
Yipit/eventlib
eventlib/core.py
cleanup_handlers
def cleanup_handlers(event=None): """Remove handlers of a given `event`. If no event is informed, wipe out all events registered. Be careful!! This function is intended to help when writing tests and for debugging purposes. If you call it, all handlers associated to an event (or to all of them) wil...
python
def cleanup_handlers(event=None): """Remove handlers of a given `event`. If no event is informed, wipe out all events registered. Be careful!! This function is intended to help when writing tests and for debugging purposes. If you call it, all handlers associated to an event (or to all of them) wil...
[ "def", "cleanup_handlers", "(", "event", "=", "None", ")", ":", "if", "event", ":", "if", "event", "in", "HANDLER_REGISTRY", ":", "del", "HANDLER_REGISTRY", "[", "event", "]", "if", "event", "in", "EXTERNAL_HANDLER_REGISTRY", ":", "del", "EXTERNAL_HANDLER_REGIST...
Remove handlers of a given `event`. If no event is informed, wipe out all events registered. Be careful!! This function is intended to help when writing tests and for debugging purposes. If you call it, all handlers associated to an event (or to all of them) will be disassociated. Which means that ...
[ "Remove", "handlers", "of", "a", "given", "event", ".", "If", "no", "event", "is", "informed", "wipe", "out", "all", "events", "registered", "." ]
0cf29e5251a59fcbfc727af5f5157a3bb03832e2
https://github.com/Yipit/eventlib/blob/0cf29e5251a59fcbfc727af5f5157a3bb03832e2/eventlib/core.py#L79-L96
41,919
Yipit/eventlib
eventlib/core.py
find_handlers
def find_handlers(event_name, registry=HANDLER_REGISTRY): """Small helper to find all handlers associated to a given event If the event can't be found, an empty list will be returned, since this is an internal function and all validation against the event name and its existence was already performed. ...
python
def find_handlers(event_name, registry=HANDLER_REGISTRY): """Small helper to find all handlers associated to a given event If the event can't be found, an empty list will be returned, since this is an internal function and all validation against the event name and its existence was already performed. ...
[ "def", "find_handlers", "(", "event_name", ",", "registry", "=", "HANDLER_REGISTRY", ")", ":", "handlers", "=", "[", "]", "# event_name can be a BaseEvent or the string representation", "if", "isinstance", "(", "event_name", ",", "basestring", ")", ":", "matched_events"...
Small helper to find all handlers associated to a given event If the event can't be found, an empty list will be returned, since this is an internal function and all validation against the event name and its existence was already performed.
[ "Small", "helper", "to", "find", "all", "handlers", "associated", "to", "a", "given", "event" ]
0cf29e5251a59fcbfc727af5f5157a3bb03832e2
https://github.com/Yipit/eventlib/blob/0cf29e5251a59fcbfc727af5f5157a3bb03832e2/eventlib/core.py#L99-L117
41,920
Yipit/eventlib
eventlib/core.py
get_default_values
def get_default_values(data): """Return all default values that an event should have""" request = data.get('request') result = {} result['__datetime__'] = datetime.now() result['__ip_address__'] = request and get_ip(request) or '0.0.0.0' return result
python
def get_default_values(data): """Return all default values that an event should have""" request = data.get('request') result = {} result['__datetime__'] = datetime.now() result['__ip_address__'] = request and get_ip(request) or '0.0.0.0' return result
[ "def", "get_default_values", "(", "data", ")", ":", "request", "=", "data", ".", "get", "(", "'request'", ")", "result", "=", "{", "}", "result", "[", "'__datetime__'", "]", "=", "datetime", ".", "now", "(", ")", "result", "[", "'__ip_address__'", "]", ...
Return all default values that an event should have
[ "Return", "all", "default", "values", "that", "an", "event", "should", "have" ]
0cf29e5251a59fcbfc727af5f5157a3bb03832e2
https://github.com/Yipit/eventlib/blob/0cf29e5251a59fcbfc727af5f5157a3bb03832e2/eventlib/core.py#L176-L182
41,921
Yipit/eventlib
eventlib/core.py
filter_data_values
def filter_data_values(data): """Remove special values that log function can take There are some special values, like "request" that the `log()` function can take, but they're not meant to be passed to the celery task neither for the event handlers. This function filter these keys and return anothe...
python
def filter_data_values(data): """Remove special values that log function can take There are some special values, like "request" that the `log()` function can take, but they're not meant to be passed to the celery task neither for the event handlers. This function filter these keys and return anothe...
[ "def", "filter_data_values", "(", "data", ")", ":", "banned", "=", "(", "'request'", ",", ")", "return", "{", "key", ":", "val", "for", "key", ",", "val", "in", "data", ".", "items", "(", ")", "if", "not", "key", "in", "banned", "}" ]
Remove special values that log function can take There are some special values, like "request" that the `log()` function can take, but they're not meant to be passed to the celery task neither for the event handlers. This function filter these keys and return another dict without them.
[ "Remove", "special", "values", "that", "log", "function", "can", "take" ]
0cf29e5251a59fcbfc727af5f5157a3bb03832e2
https://github.com/Yipit/eventlib/blob/0cf29e5251a59fcbfc727af5f5157a3bb03832e2/eventlib/core.py#L185-L194
41,922
Yipit/eventlib
eventlib/core.py
import_event_modules
def import_event_modules(): """Import all events declared for all currently installed apps This function walks through the list of installed apps and tries to import a module named `EVENTS_MODULE_NAME`. """ for installed_app in getsetting('INSTALLED_APPS'): module_name = u'{}.{}'.format(ins...
python
def import_event_modules(): """Import all events declared for all currently installed apps This function walks through the list of installed apps and tries to import a module named `EVENTS_MODULE_NAME`. """ for installed_app in getsetting('INSTALLED_APPS'): module_name = u'{}.{}'.format(ins...
[ "def", "import_event_modules", "(", ")", ":", "for", "installed_app", "in", "getsetting", "(", "'INSTALLED_APPS'", ")", ":", "module_name", "=", "u'{}.{}'", ".", "format", "(", "installed_app", ",", "EVENTS_MODULE_NAME", ")", "try", ":", "import_module", "(", "m...
Import all events declared for all currently installed apps This function walks through the list of installed apps and tries to import a module named `EVENTS_MODULE_NAME`.
[ "Import", "all", "events", "declared", "for", "all", "currently", "installed", "apps" ]
0cf29e5251a59fcbfc727af5f5157a3bb03832e2
https://github.com/Yipit/eventlib/blob/0cf29e5251a59fcbfc727af5f5157a3bb03832e2/eventlib/core.py#L197-L208
41,923
callowayproject/Calloway
calloway/apps/custom_registration/backends/email/__init__.py
handle_expired_accounts
def handle_expired_accounts(): """ Check of expired accounts. """ ACTIVATED = RegistrationProfile.ACTIVATED expiration_date = datetime.timedelta(days=settings.ACCOUNT_ACTIVATION_DAYS) to_delete = [] print "Processing %s registration profiles..." % str(RegistrationProfile.objects.all().c...
python
def handle_expired_accounts(): """ Check of expired accounts. """ ACTIVATED = RegistrationProfile.ACTIVATED expiration_date = datetime.timedelta(days=settings.ACCOUNT_ACTIVATION_DAYS) to_delete = [] print "Processing %s registration profiles..." % str(RegistrationProfile.objects.all().c...
[ "def", "handle_expired_accounts", "(", ")", ":", "ACTIVATED", "=", "RegistrationProfile", ".", "ACTIVATED", "expiration_date", "=", "datetime", ".", "timedelta", "(", "days", "=", "settings", ".", "ACCOUNT_ACTIVATION_DAYS", ")", "to_delete", "=", "[", "]", "print"...
Check of expired accounts.
[ "Check", "of", "expired", "accounts", "." ]
d22e98d41fbd298ab6393ba7bd84a75528be9f81
https://github.com/callowayproject/Calloway/blob/d22e98d41fbd298ab6393ba7bd84a75528be9f81/calloway/apps/custom_registration/backends/email/__init__.py#L203-L250
41,924
callowayproject/Calloway
calloway/apps/custom_registration/backends/email/__init__.py
EmailBackend.activate
def activate(self, request, activation_key): """ Override default activation process. This will activate the user even if its passed its expiration date. """ if SHA1_RE.search(activation_key): try: profile = RegistrationProfile.objects.get(activation...
python
def activate(self, request, activation_key): """ Override default activation process. This will activate the user even if its passed its expiration date. """ if SHA1_RE.search(activation_key): try: profile = RegistrationProfile.objects.get(activation...
[ "def", "activate", "(", "self", ",", "request", ",", "activation_key", ")", ":", "if", "SHA1_RE", ".", "search", "(", "activation_key", ")", ":", "try", ":", "profile", "=", "RegistrationProfile", ".", "objects", ".", "get", "(", "activation_key", "=", "ac...
Override default activation process. This will activate the user even if its passed its expiration date.
[ "Override", "default", "activation", "process", ".", "This", "will", "activate", "the", "user", "even", "if", "its", "passed", "its", "expiration", "date", "." ]
d22e98d41fbd298ab6393ba7bd84a75528be9f81
https://github.com/callowayproject/Calloway/blob/d22e98d41fbd298ab6393ba7bd84a75528be9f81/calloway/apps/custom_registration/backends/email/__init__.py#L59-L76
41,925
callowayproject/Calloway
calloway/apps/custom_registration/backends/email/__init__.py
EmailBackend.register
def register(self, request, **kwargs): """ Create and immediately log in a new user. Only require a email to register, username is generated automatically and a password is random generated and emailed to the user. Activation is still required for accou...
python
def register(self, request, **kwargs): """ Create and immediately log in a new user. Only require a email to register, username is generated automatically and a password is random generated and emailed to the user. Activation is still required for accou...
[ "def", "register", "(", "self", ",", "request", ",", "*", "*", "kwargs", ")", ":", "if", "Site", ".", "_meta", ".", "installed", ":", "site", "=", "Site", ".", "objects", ".", "get_current", "(", ")", "else", ":", "site", "=", "RequestSite", "(", "...
Create and immediately log in a new user. Only require a email to register, username is generated automatically and a password is random generated and emailed to the user. Activation is still required for account uses after specified number of days.
[ "Create", "and", "immediately", "log", "in", "a", "new", "user", ".", "Only", "require", "a", "email", "to", "register", "username", "is", "generated", "automatically", "and", "a", "password", "is", "random", "generated", "and", "emailed", "to", "the", "user...
d22e98d41fbd298ab6393ba7bd84a75528be9f81
https://github.com/callowayproject/Calloway/blob/d22e98d41fbd298ab6393ba7bd84a75528be9f81/calloway/apps/custom_registration/backends/email/__init__.py#L78-L145
41,926
callowayproject/Calloway
calloway/apps/custom_registration/backends/email/__init__.py
EmailBackend.send_activation_email
def send_activation_email(self, user, profile, password, site): """ Custom send email method to supplied the activation link and new generated password. """ ctx_dict = { 'password': password, 'site': site, 'activation_key': profile.act...
python
def send_activation_email(self, user, profile, password, site): """ Custom send email method to supplied the activation link and new generated password. """ ctx_dict = { 'password': password, 'site': site, 'activation_key': profile.act...
[ "def", "send_activation_email", "(", "self", ",", "user", ",", "profile", ",", "password", ",", "site", ")", ":", "ctx_dict", "=", "{", "'password'", ":", "password", ",", "'site'", ":", "site", ",", "'activation_key'", ":", "profile", ".", "activation_key",...
Custom send email method to supplied the activation link and new generated password.
[ "Custom", "send", "email", "method", "to", "supplied", "the", "activation", "link", "and", "new", "generated", "password", "." ]
d22e98d41fbd298ab6393ba7bd84a75528be9f81
https://github.com/callowayproject/Calloway/blob/d22e98d41fbd298ab6393ba7bd84a75528be9f81/calloway/apps/custom_registration/backends/email/__init__.py#L147-L169
41,927
callowayproject/Calloway
calloway/apps/custom_registration/backends/email/__init__.py
EmailBackend.post_registration_redirect
def post_registration_redirect(self, request, user): """ After registration, redirect to the home page or supplied "next" query string or hidden field value. """ next_url = "/registration/register/complete/" if "next" in request.GET or "next" in request.POST: ...
python
def post_registration_redirect(self, request, user): """ After registration, redirect to the home page or supplied "next" query string or hidden field value. """ next_url = "/registration/register/complete/" if "next" in request.GET or "next" in request.POST: ...
[ "def", "post_registration_redirect", "(", "self", ",", "request", ",", "user", ")", ":", "next_url", "=", "\"/registration/register/complete/\"", "if", "\"next\"", "in", "request", ".", "GET", "or", "\"next\"", "in", "request", ".", "POST", ":", "next_url", "=",...
After registration, redirect to the home page or supplied "next" query string or hidden field value.
[ "After", "registration", "redirect", "to", "the", "home", "page", "or", "supplied", "next", "query", "string", "or", "hidden", "field", "value", "." ]
d22e98d41fbd298ab6393ba7bd84a75528be9f81
https://github.com/callowayproject/Calloway/blob/d22e98d41fbd298ab6393ba7bd84a75528be9f81/calloway/apps/custom_registration/backends/email/__init__.py#L190-L200
41,928
helixyte/everest
everest/batch.py
Batch.next
def next(self): """ Returns the next batch for the batched sequence or `None`, if this batch is already the last batch. :rtype: :class:`Batch` instance or `None`. """ if self.start + self.size > self.total_size: result = None else: result ...
python
def next(self): """ Returns the next batch for the batched sequence or `None`, if this batch is already the last batch. :rtype: :class:`Batch` instance or `None`. """ if self.start + self.size > self.total_size: result = None else: result ...
[ "def", "next", "(", "self", ")", ":", "if", "self", ".", "start", "+", "self", ".", "size", ">", "self", ".", "total_size", ":", "result", "=", "None", "else", ":", "result", "=", "Batch", "(", "self", ".", "start", "+", "self", ".", "size", ",",...
Returns the next batch for the batched sequence or `None`, if this batch is already the last batch. :rtype: :class:`Batch` instance or `None`.
[ "Returns", "the", "next", "batch", "for", "the", "batched", "sequence", "or", "None", "if", "this", "batch", "is", "already", "the", "last", "batch", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/batch.py#L35-L46
41,929
helixyte/everest
everest/batch.py
Batch.previous
def previous(self): """ Returns the previous batch for the batched sequence or `None`, if this batch is already the first batch. :rtype: :class:`Batch` instance or `None`. """ if self.start - self.size < 0: result = None else: result = Bat...
python
def previous(self): """ Returns the previous batch for the batched sequence or `None`, if this batch is already the first batch. :rtype: :class:`Batch` instance or `None`. """ if self.start - self.size < 0: result = None else: result = Bat...
[ "def", "previous", "(", "self", ")", ":", "if", "self", ".", "start", "-", "self", ".", "size", "<", "0", ":", "result", "=", "None", "else", ":", "result", "=", "Batch", "(", "self", ".", "start", "-", "self", ".", "size", ",", "self", ".", "s...
Returns the previous batch for the batched sequence or `None`, if this batch is already the first batch. :rtype: :class:`Batch` instance or `None`.
[ "Returns", "the", "previous", "batch", "for", "the", "batched", "sequence", "or", "None", "if", "this", "batch", "is", "already", "the", "first", "batch", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/batch.py#L49-L60
41,930
helixyte/everest
everest/batch.py
Batch.last
def last(self): """ Returns the last batch for the batched sequence. :rtype: :class:`Batch` instance. """ start = max(self.number - 1, 0) * self.size return Batch(start, self.size, self.total_size)
python
def last(self): """ Returns the last batch for the batched sequence. :rtype: :class:`Batch` instance. """ start = max(self.number - 1, 0) * self.size return Batch(start, self.size, self.total_size)
[ "def", "last", "(", "self", ")", ":", "start", "=", "max", "(", "self", ".", "number", "-", "1", ",", "0", ")", "*", "self", ".", "size", "return", "Batch", "(", "start", ",", "self", ".", "size", ",", "self", ".", "total_size", ")" ]
Returns the last batch for the batched sequence. :rtype: :class:`Batch` instance.
[ "Returns", "the", "last", "batch", "for", "the", "batched", "sequence", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/batch.py#L72-L79
41,931
helixyte/everest
everest/batch.py
Batch.number
def number(self): """ Returns the number of batches the batched sequence contains. :rtype: integer. """ return int(math.ceil(self.total_size / float(self.size)))
python
def number(self): """ Returns the number of batches the batched sequence contains. :rtype: integer. """ return int(math.ceil(self.total_size / float(self.size)))
[ "def", "number", "(", "self", ")", ":", "return", "int", "(", "math", ".", "ceil", "(", "self", ".", "total_size", "/", "float", "(", "self", ".", "size", ")", ")", ")" ]
Returns the number of batches the batched sequence contains. :rtype: integer.
[ "Returns", "the", "number", "of", "batches", "the", "batched", "sequence", "contains", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/batch.py#L82-L88
41,932
bashu/django-watermark
watermarker/templatetags/watermark.py
watermark
def watermark(url, args=''): """ Returns the URL to a watermarked copy of the image specified. """ # initialize some variables args = args.split(',') params = dict( name=args.pop(0), opacity=0.5, tile=False, scale=1.0, greyscale=False, rotation=0...
python
def watermark(url, args=''): """ Returns the URL to a watermarked copy of the image specified. """ # initialize some variables args = args.split(',') params = dict( name=args.pop(0), opacity=0.5, tile=False, scale=1.0, greyscale=False, rotation=0...
[ "def", "watermark", "(", "url", ",", "args", "=", "''", ")", ":", "# initialize some variables", "args", "=", "args", ".", "split", "(", "','", ")", "params", "=", "dict", "(", "name", "=", "args", ".", "pop", "(", "0", ")", ",", "opacity", "=", "0...
Returns the URL to a watermarked copy of the image specified.
[ "Returns", "the", "URL", "to", "a", "watermarked", "copy", "of", "the", "image", "specified", "." ]
0ed47b35156d9a3dd893ca744789f38fdfe08fbe
https://github.com/bashu/django-watermark/blob/0ed47b35156d9a3dd893ca744789f38fdfe08fbe/watermarker/templatetags/watermark.py#L262-L308
41,933
bashu/django-watermark
watermarker/templatetags/watermark.py
Watermarker._get_filesystem_path
def _get_filesystem_path(self, url_path, basedir=settings.MEDIA_ROOT): """Makes a filesystem path from the specified URL path""" if url_path.startswith(settings.MEDIA_URL): url_path = url_path[len(settings.MEDIA_URL):] # strip media root url return os.path.normpath(os.path.join(ba...
python
def _get_filesystem_path(self, url_path, basedir=settings.MEDIA_ROOT): """Makes a filesystem path from the specified URL path""" if url_path.startswith(settings.MEDIA_URL): url_path = url_path[len(settings.MEDIA_URL):] # strip media root url return os.path.normpath(os.path.join(ba...
[ "def", "_get_filesystem_path", "(", "self", ",", "url_path", ",", "basedir", "=", "settings", ".", "MEDIA_ROOT", ")", ":", "if", "url_path", ".", "startswith", "(", "settings", ".", "MEDIA_URL", ")", ":", "url_path", "=", "url_path", "[", "len", "(", "sett...
Makes a filesystem path from the specified URL path
[ "Makes", "a", "filesystem", "path", "from", "the", "specified", "URL", "path" ]
0ed47b35156d9a3dd893ca744789f38fdfe08fbe
https://github.com/bashu/django-watermark/blob/0ed47b35156d9a3dd893ca744789f38fdfe08fbe/watermarker/templatetags/watermark.py#L181-L187
41,934
bashu/django-watermark
watermarker/templatetags/watermark.py
Watermarker.generate_filename
def generate_filename(self, mark, **kwargs): """Comes up with a good filename for the watermarked image""" kwargs = kwargs.copy() kwargs['opacity'] = int(kwargs['opacity'] * 100) kwargs['st_mtime'] = kwargs['fstat'].st_mtime kwargs['st_size'] = kwargs['fstat'].st_size ...
python
def generate_filename(self, mark, **kwargs): """Comes up with a good filename for the watermarked image""" kwargs = kwargs.copy() kwargs['opacity'] = int(kwargs['opacity'] * 100) kwargs['st_mtime'] = kwargs['fstat'].st_mtime kwargs['st_size'] = kwargs['fstat'].st_size ...
[ "def", "generate_filename", "(", "self", ",", "mark", ",", "*", "*", "kwargs", ")", ":", "kwargs", "=", "kwargs", ".", "copy", "(", ")", "kwargs", "[", "'opacity'", "]", "=", "int", "(", "kwargs", "[", "'opacity'", "]", "*", "100", ")", "kwargs", "...
Comes up with a good filename for the watermarked image
[ "Comes", "up", "with", "a", "good", "filename", "for", "the", "watermarked", "image" ]
0ed47b35156d9a3dd893ca744789f38fdfe08fbe
https://github.com/bashu/django-watermark/blob/0ed47b35156d9a3dd893ca744789f38fdfe08fbe/watermarker/templatetags/watermark.py#L189-L220
41,935
bashu/django-watermark
watermarker/templatetags/watermark.py
Watermarker.get_url_path
def get_url_path(self, basedir, original_basename, ext, name, obscure=True): """Determines an appropriate watermark path""" try: hash = hashlib.sha1(smart_str(name)).hexdigest() except TypeError: hash = hashlib.sha1(smart_str(name).encode('utf-8')).hexdigest() #...
python
def get_url_path(self, basedir, original_basename, ext, name, obscure=True): """Determines an appropriate watermark path""" try: hash = hashlib.sha1(smart_str(name)).hexdigest() except TypeError: hash = hashlib.sha1(smart_str(name).encode('utf-8')).hexdigest() #...
[ "def", "get_url_path", "(", "self", ",", "basedir", ",", "original_basename", ",", "ext", ",", "name", ",", "obscure", "=", "True", ")", ":", "try", ":", "hash", "=", "hashlib", ".", "sha1", "(", "smart_str", "(", "name", ")", ")", ".", "hexdigest", ...
Determines an appropriate watermark path
[ "Determines", "an", "appropriate", "watermark", "path" ]
0ed47b35156d9a3dd893ca744789f38fdfe08fbe
https://github.com/bashu/django-watermark/blob/0ed47b35156d9a3dd893ca744789f38fdfe08fbe/watermarker/templatetags/watermark.py#L222-L251
41,936
bashu/django-watermark
watermarker/templatetags/watermark.py
Watermarker.create_watermark
def create_watermark(self, target, mark, fpath, quality=QUALITY, **kwargs): """Create the watermarked image on the filesystem""" im = utils.watermark(target, mark, **kwargs) im.save(fpath, quality=quality) return im
python
def create_watermark(self, target, mark, fpath, quality=QUALITY, **kwargs): """Create the watermarked image on the filesystem""" im = utils.watermark(target, mark, **kwargs) im.save(fpath, quality=quality) return im
[ "def", "create_watermark", "(", "self", ",", "target", ",", "mark", ",", "fpath", ",", "quality", "=", "QUALITY", ",", "*", "*", "kwargs", ")", ":", "im", "=", "utils", ".", "watermark", "(", "target", ",", "mark", ",", "*", "*", "kwargs", ")", "im...
Create the watermarked image on the filesystem
[ "Create", "the", "watermarked", "image", "on", "the", "filesystem" ]
0ed47b35156d9a3dd893ca744789f38fdfe08fbe
https://github.com/bashu/django-watermark/blob/0ed47b35156d9a3dd893ca744789f38fdfe08fbe/watermarker/templatetags/watermark.py#L253-L258
41,937
bashu/django-watermark
watermarker/utils.py
_val
def _val(var, is_percent=False): """ Tries to determine the appropriate value of a particular variable that is passed in. If the value is supposed to be a percentage, a whole integer will be sought after and then turned into a floating point number between 0 and 1. If the value is supposed to be a...
python
def _val(var, is_percent=False): """ Tries to determine the appropriate value of a particular variable that is passed in. If the value is supposed to be a percentage, a whole integer will be sought after and then turned into a floating point number between 0 and 1. If the value is supposed to be a...
[ "def", "_val", "(", "var", ",", "is_percent", "=", "False", ")", ":", "try", ":", "if", "is_percent", ":", "var", "=", "float", "(", "int", "(", "var", ".", "strip", "(", "'%'", ")", ")", "/", "100.0", ")", "else", ":", "var", "=", "int", "(", ...
Tries to determine the appropriate value of a particular variable that is passed in. If the value is supposed to be a percentage, a whole integer will be sought after and then turned into a floating point number between 0 and 1. If the value is supposed to be an integer, the variable is cast into an i...
[ "Tries", "to", "determine", "the", "appropriate", "value", "of", "a", "particular", "variable", "that", "is", "passed", "in", ".", "If", "the", "value", "is", "supposed", "to", "be", "a", "percentage", "a", "whole", "integer", "will", "be", "sought", "afte...
0ed47b35156d9a3dd893ca744789f38fdfe08fbe
https://github.com/bashu/django-watermark/blob/0ed47b35156d9a3dd893ca744789f38fdfe08fbe/watermarker/utils.py#L34-L50
41,938
bashu/django-watermark
watermarker/utils.py
reduce_opacity
def reduce_opacity(img, opacity): """ Returns an image with reduced opacity. """ assert opacity >= 0 and opacity <= 1 if img.mode != 'RGBA': img = img.convert('RGBA') else: img = img.copy() alpha = img.split()[3] alpha = ImageEnhance.Brightness(alpha).enhance(opacity) ...
python
def reduce_opacity(img, opacity): """ Returns an image with reduced opacity. """ assert opacity >= 0 and opacity <= 1 if img.mode != 'RGBA': img = img.convert('RGBA') else: img = img.copy() alpha = img.split()[3] alpha = ImageEnhance.Brightness(alpha).enhance(opacity) ...
[ "def", "reduce_opacity", "(", "img", ",", "opacity", ")", ":", "assert", "opacity", ">=", "0", "and", "opacity", "<=", "1", "if", "img", ".", "mode", "!=", "'RGBA'", ":", "img", "=", "img", ".", "convert", "(", "'RGBA'", ")", "else", ":", "img", "=...
Returns an image with reduced opacity.
[ "Returns", "an", "image", "with", "reduced", "opacity", "." ]
0ed47b35156d9a3dd893ca744789f38fdfe08fbe
https://github.com/bashu/django-watermark/blob/0ed47b35156d9a3dd893ca744789f38fdfe08fbe/watermarker/utils.py#L53-L68
41,939
bashu/django-watermark
watermarker/utils.py
determine_scale
def determine_scale(scale, img, mark): """ Scales an image using a specified ratio, 'F' or 'R'. If `scale` is 'F', the image is scaled to be as big as possible to fit in `img` without falling off the edges. If `scale` is 'R', the watermark resizes to a percentage of minimum size of source image. R...
python
def determine_scale(scale, img, mark): """ Scales an image using a specified ratio, 'F' or 'R'. If `scale` is 'F', the image is scaled to be as big as possible to fit in `img` without falling off the edges. If `scale` is 'R', the watermark resizes to a percentage of minimum size of source image. R...
[ "def", "determine_scale", "(", "scale", ",", "img", ",", "mark", ")", ":", "if", "scale", ":", "try", ":", "scale", "=", "float", "(", "scale", ")", "except", "(", "ValueError", ",", "TypeError", ")", ":", "pass", "if", "isinstance", "(", "scale", ",...
Scales an image using a specified ratio, 'F' or 'R'. If `scale` is 'F', the image is scaled to be as big as possible to fit in `img` without falling off the edges. If `scale` is 'R', the watermark resizes to a percentage of minimum size of source image. Returns the scaled `mark`.
[ "Scales", "an", "image", "using", "a", "specified", "ratio", "F", "or", "R", ".", "If", "scale", "is", "F", "the", "image", "is", "scaled", "to", "be", "as", "big", "as", "possible", "to", "fit", "in", "img", "without", "falling", "off", "the", "edge...
0ed47b35156d9a3dd893ca744789f38fdfe08fbe
https://github.com/bashu/django-watermark/blob/0ed47b35156d9a3dd893ca744789f38fdfe08fbe/watermarker/utils.py#L71-L111
41,940
bashu/django-watermark
watermarker/utils.py
determine_rotation
def determine_rotation(rotation, mark): """ Determines the number of degrees to rotate the watermark image. """ if isinstance(rotation, six.string_types) and rotation.lower() == 'r': rotation = random.randint(0, 359) else: rotation = _int(rotation) return rotation
python
def determine_rotation(rotation, mark): """ Determines the number of degrees to rotate the watermark image. """ if isinstance(rotation, six.string_types) and rotation.lower() == 'r': rotation = random.randint(0, 359) else: rotation = _int(rotation) return rotation
[ "def", "determine_rotation", "(", "rotation", ",", "mark", ")", ":", "if", "isinstance", "(", "rotation", ",", "six", ".", "string_types", ")", "and", "rotation", ".", "lower", "(", ")", "==", "'r'", ":", "rotation", "=", "random", ".", "randint", "(", ...
Determines the number of degrees to rotate the watermark image.
[ "Determines", "the", "number", "of", "degrees", "to", "rotate", "the", "watermark", "image", "." ]
0ed47b35156d9a3dd893ca744789f38fdfe08fbe
https://github.com/bashu/django-watermark/blob/0ed47b35156d9a3dd893ca744789f38fdfe08fbe/watermarker/utils.py#L114-L123
41,941
bashu/django-watermark
watermarker/utils.py
watermark
def watermark(img, mark, position=(0, 0), opacity=1, scale=1.0, tile=False, greyscale=False, rotation=0, return_name=False, **kwargs): """Adds a watermark to an image""" if opacity < 1: mark = reduce_opacity(mark, opacity) if not isinstance(scale, tuple): scale = determine_sc...
python
def watermark(img, mark, position=(0, 0), opacity=1, scale=1.0, tile=False, greyscale=False, rotation=0, return_name=False, **kwargs): """Adds a watermark to an image""" if opacity < 1: mark = reduce_opacity(mark, opacity) if not isinstance(scale, tuple): scale = determine_sc...
[ "def", "watermark", "(", "img", ",", "mark", ",", "position", "=", "(", "0", ",", "0", ")", ",", "opacity", "=", "1", ",", "scale", "=", "1.0", ",", "tile", "=", "False", ",", "greyscale", "=", "False", ",", "rotation", "=", "0", ",", "return_nam...
Adds a watermark to an image
[ "Adds", "a", "watermark", "to", "an", "image" ]
0ed47b35156d9a3dd893ca744789f38fdfe08fbe
https://github.com/bashu/django-watermark/blob/0ed47b35156d9a3dd893ca744789f38fdfe08fbe/watermarker/utils.py#L197-L249
41,942
icemac/toll
src/toll/config.py
parsed_file
def parsed_file(config_file): """Parse an ini-style config file.""" parser = ConfigParser(allow_no_value=True) parser.readfp(config_file) return parser
python
def parsed_file(config_file): """Parse an ini-style config file.""" parser = ConfigParser(allow_no_value=True) parser.readfp(config_file) return parser
[ "def", "parsed_file", "(", "config_file", ")", ":", "parser", "=", "ConfigParser", "(", "allow_no_value", "=", "True", ")", "parser", ".", "readfp", "(", "config_file", ")", "return", "parser" ]
Parse an ini-style config file.
[ "Parse", "an", "ini", "-", "style", "config", "file", "." ]
aa25480fcbc2017519516ec1e7fe60d78fb2f30b
https://github.com/icemac/toll/blob/aa25480fcbc2017519516ec1e7fe60d78fb2f30b/src/toll/config.py#L7-L11
41,943
icemac/toll
src/toll/config.py
commands
def commands(config, names): """Return the list of commands to run.""" commands = {cmd: Command(**dict((minus_to_underscore(k), v) for k, v in config.items(cmd))) for cmd in config.sections() if cmd != 'packages'} try: return tuple(...
python
def commands(config, names): """Return the list of commands to run.""" commands = {cmd: Command(**dict((minus_to_underscore(k), v) for k, v in config.items(cmd))) for cmd in config.sections() if cmd != 'packages'} try: return tuple(...
[ "def", "commands", "(", "config", ",", "names", ")", ":", "commands", "=", "{", "cmd", ":", "Command", "(", "*", "*", "dict", "(", "(", "minus_to_underscore", "(", "k", ")", ",", "v", ")", "for", "k", ",", "v", "in", "config", ".", "items", "(", ...
Return the list of commands to run.
[ "Return", "the", "list", "of", "commands", "to", "run", "." ]
aa25480fcbc2017519516ec1e7fe60d78fb2f30b
https://github.com/icemac/toll/blob/aa25480fcbc2017519516ec1e7fe60d78fb2f30b/src/toll/config.py#L52-L63
41,944
icemac/toll
setup.py
project_path
def project_path(*names): """Path to a file in the project.""" return os.path.join(os.path.dirname(__file__), *names)
python
def project_path(*names): """Path to a file in the project.""" return os.path.join(os.path.dirname(__file__), *names)
[ "def", "project_path", "(", "*", "names", ")", ":", "return", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ",", "*", "names", ")" ]
Path to a file in the project.
[ "Path", "to", "a", "file", "in", "the", "project", "." ]
aa25480fcbc2017519516ec1e7fe60d78fb2f30b
https://github.com/icemac/toll/blob/aa25480fcbc2017519516ec1e7fe60d78fb2f30b/setup.py#L8-L10
41,945
rcbops/rpc_differ
rpc_differ/rpc_differ.py
get_osa_commit
def get_osa_commit(repo, ref, rpc_product=None): """Get the OSA sha referenced by an RPCO Repo.""" osa_differ.checkout(repo, ref) functions_path = os.path.join(repo.working_tree_dir, 'scripts/functions.sh') release_path = os.path.join(repo.working_tree_dir, ...
python
def get_osa_commit(repo, ref, rpc_product=None): """Get the OSA sha referenced by an RPCO Repo.""" osa_differ.checkout(repo, ref) functions_path = os.path.join(repo.working_tree_dir, 'scripts/functions.sh') release_path = os.path.join(repo.working_tree_dir, ...
[ "def", "get_osa_commit", "(", "repo", ",", "ref", ",", "rpc_product", "=", "None", ")", ":", "osa_differ", ".", "checkout", "(", "repo", ",", "ref", ")", "functions_path", "=", "os", ".", "path", ".", "join", "(", "repo", ".", "working_tree_dir", ",", ...
Get the OSA sha referenced by an RPCO Repo.
[ "Get", "the", "OSA", "sha", "referenced", "by", "an", "RPCO", "Repo", "." ]
07c9e645b13f9af15d58bad533753d3a9447b78a
https://github.com/rcbops/rpc_differ/blob/07c9e645b13f9af15d58bad533753d3a9447b78a/rpc_differ/rpc_differ.py#L189-L225
41,946
rcbops/rpc_differ
rpc_differ/rpc_differ.py
publish_report
def publish_report(report, args, old_commit, new_commit): """Publish the RST report based on the user request.""" # Print the report to stdout unless the user specified --quiet. output = "" if not args.quiet and not args.gist and not args.file: return report if args.gist: gist_url ...
python
def publish_report(report, args, old_commit, new_commit): """Publish the RST report based on the user request.""" # Print the report to stdout unless the user specified --quiet. output = "" if not args.quiet and not args.gist and not args.file: return report if args.gist: gist_url ...
[ "def", "publish_report", "(", "report", ",", "args", ",", "old_commit", ",", "new_commit", ")", ":", "# Print the report to stdout unless the user specified --quiet.", "output", "=", "\"\"", "if", "not", "args", ".", "quiet", "and", "not", "args", ".", "gist", "an...
Publish the RST report based on the user request.
[ "Publish", "the", "RST", "report", "based", "on", "the", "user", "request", "." ]
07c9e645b13f9af15d58bad533753d3a9447b78a
https://github.com/rcbops/rpc_differ/blob/07c9e645b13f9af15d58bad533753d3a9447b78a/rpc_differ/rpc_differ.py#L308-L325
41,947
rcbops/rpc_differ
rpc_differ/rpc_differ.py
run_rpc_differ
def run_rpc_differ(): """The script starts here.""" args = parse_arguments() # Set up DEBUG logging if needed if args.debug: log.setLevel(logging.DEBUG) elif args.verbose: log.setLevel(logging.INFO) # Create the storage directory if it doesn't exist already. try: st...
python
def run_rpc_differ(): """The script starts here.""" args = parse_arguments() # Set up DEBUG logging if needed if args.debug: log.setLevel(logging.DEBUG) elif args.verbose: log.setLevel(logging.INFO) # Create the storage directory if it doesn't exist already. try: st...
[ "def", "run_rpc_differ", "(", ")", ":", "args", "=", "parse_arguments", "(", ")", "# Set up DEBUG logging if needed", "if", "args", ".", "debug", ":", "log", ".", "setLevel", "(", "logging", ".", "DEBUG", ")", "elif", "args", ".", "verbose", ":", "log", "....
The script starts here.
[ "The", "script", "starts", "here", "." ]
07c9e645b13f9af15d58bad533753d3a9447b78a
https://github.com/rcbops/rpc_differ/blob/07c9e645b13f9af15d58bad533753d3a9447b78a/rpc_differ/rpc_differ.py#L343-L489
41,948
icemac/toll
src/toll/main.py
main
def main(raw_args=None): """Console script entry point.""" parser = argparse.ArgumentParser( description="poor man's integration testing") parser.add_argument( 'cmds', metavar='cmd', default=['test'], nargs='*', help='Run command(s) defined in the configuration file. Each command ' ...
python
def main(raw_args=None): """Console script entry point.""" parser = argparse.ArgumentParser( description="poor man's integration testing") parser.add_argument( 'cmds', metavar='cmd', default=['test'], nargs='*', help='Run command(s) defined in the configuration file. Each command ' ...
[ "def", "main", "(", "raw_args", "=", "None", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "\"poor man's integration testing\"", ")", "parser", ".", "add_argument", "(", "'cmds'", ",", "metavar", "=", "'cmd'", ",", "defau...
Console script entry point.
[ "Console", "script", "entry", "point", "." ]
aa25480fcbc2017519516ec1e7fe60d78fb2f30b
https://github.com/icemac/toll/blob/aa25480fcbc2017519516ec1e7fe60d78fb2f30b/src/toll/main.py#L6-L29
41,949
ox-it/python-sharepoint
sharepoint/lists/__init__.py
SharePointLists.remove
def remove(self, list): """ Removes a list from the site. """ xml = SP.DeleteList(SP.listName(list.id)) self.opener.post_soap(LIST_WEBSERVICE, xml, soapaction='http://schemas.microsoft.com/sharepoint/soap/DeleteList') self.all_lists.remove(li...
python
def remove(self, list): """ Removes a list from the site. """ xml = SP.DeleteList(SP.listName(list.id)) self.opener.post_soap(LIST_WEBSERVICE, xml, soapaction='http://schemas.microsoft.com/sharepoint/soap/DeleteList') self.all_lists.remove(li...
[ "def", "remove", "(", "self", ",", "list", ")", ":", "xml", "=", "SP", ".", "DeleteList", "(", "SP", ".", "listName", "(", "list", ".", "id", ")", ")", "self", ".", "opener", ".", "post_soap", "(", "LIST_WEBSERVICE", ",", "xml", ",", "soapaction", ...
Removes a list from the site.
[ "Removes", "a", "list", "from", "the", "site", "." ]
f1a1e19189d78115fcfc25850d27319e34d7e699
https://github.com/ox-it/python-sharepoint/blob/f1a1e19189d78115fcfc25850d27319e34d7e699/sharepoint/lists/__init__.py#L44-L51
41,950
ox-it/python-sharepoint
sharepoint/lists/__init__.py
SharePointLists.create
def create(self, name, description='', template=100): """ Creates a new list in the site. """ try: template = int(template) except ValueError: template = LIST_TEMPLATES[template] if name in self: raise ValueError("List already exists: '...
python
def create(self, name, description='', template=100): """ Creates a new list in the site. """ try: template = int(template) except ValueError: template = LIST_TEMPLATES[template] if name in self: raise ValueError("List already exists: '...
[ "def", "create", "(", "self", ",", "name", ",", "description", "=", "''", ",", "template", "=", "100", ")", ":", "try", ":", "template", "=", "int", "(", "template", ")", "except", "ValueError", ":", "template", "=", "LIST_TEMPLATES", "[", "template", ...
Creates a new list in the site.
[ "Creates", "a", "new", "list", "in", "the", "site", "." ]
f1a1e19189d78115fcfc25850d27319e34d7e699
https://github.com/ox-it/python-sharepoint/blob/f1a1e19189d78115fcfc25850d27319e34d7e699/sharepoint/lists/__init__.py#L53-L71
41,951
ox-it/python-sharepoint
sharepoint/lists/__init__.py
SharePointList.Row
def Row(self): """ The class for a row in this list. """ if not hasattr(self, '_row_class'): attrs = {'fields': self.fields, 'list': self, 'opener': self.opener} for field in self.fields.values(): attrs[field.name] = field.descriptor se...
python
def Row(self): """ The class for a row in this list. """ if not hasattr(self, '_row_class'): attrs = {'fields': self.fields, 'list': self, 'opener': self.opener} for field in self.fields.values(): attrs[field.name] = field.descriptor se...
[ "def", "Row", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_row_class'", ")", ":", "attrs", "=", "{", "'fields'", ":", "self", ".", "fields", ",", "'list'", ":", "self", ",", "'opener'", ":", "self", ".", "opener", "}", "for",...
The class for a row in this list.
[ "The", "class", "for", "a", "row", "in", "this", "list", "." ]
f1a1e19189d78115fcfc25850d27319e34d7e699
https://github.com/ox-it/python-sharepoint/blob/f1a1e19189d78115fcfc25850d27319e34d7e699/sharepoint/lists/__init__.py#L201-L210
41,952
ox-it/python-sharepoint
sharepoint/lists/__init__.py
SharePointList.append
def append(self, row): """ Appends a row to the list. Takes a dictionary, returns a row. """ if isinstance(row, dict): row = self.Row(row) elif isinstance(row, self.Row): pass elif isinstance(row, SharePointListRow): raise TypeError("ro...
python
def append(self, row): """ Appends a row to the list. Takes a dictionary, returns a row. """ if isinstance(row, dict): row = self.Row(row) elif isinstance(row, self.Row): pass elif isinstance(row, SharePointListRow): raise TypeError("ro...
[ "def", "append", "(", "self", ",", "row", ")", ":", "if", "isinstance", "(", "row", ",", "dict", ")", ":", "row", "=", "self", ".", "Row", "(", "row", ")", "elif", "isinstance", "(", "row", ",", "self", ".", "Row", ")", ":", "pass", "elif", "is...
Appends a row to the list. Takes a dictionary, returns a row.
[ "Appends", "a", "row", "to", "the", "list", ".", "Takes", "a", "dictionary", "returns", "a", "row", "." ]
f1a1e19189d78115fcfc25850d27319e34d7e699
https://github.com/ox-it/python-sharepoint/blob/f1a1e19189d78115fcfc25850d27319e34d7e699/sharepoint/lists/__init__.py#L237-L251
41,953
ox-it/python-sharepoint
sharepoint/lists/__init__.py
SharePointList.remove
def remove(self, row): """ Removes the row from the list. """ self._rows.remove(row) self._deleted_rows.add(row)
python
def remove(self, row): """ Removes the row from the list. """ self._rows.remove(row) self._deleted_rows.add(row)
[ "def", "remove", "(", "self", ",", "row", ")", ":", "self", ".", "_rows", ".", "remove", "(", "row", ")", "self", ".", "_deleted_rows", ".", "add", "(", "row", ")" ]
Removes the row from the list.
[ "Removes", "the", "row", "from", "the", "list", "." ]
f1a1e19189d78115fcfc25850d27319e34d7e699
https://github.com/ox-it/python-sharepoint/blob/f1a1e19189d78115fcfc25850d27319e34d7e699/sharepoint/lists/__init__.py#L257-L262
41,954
ox-it/python-sharepoint
sharepoint/lists/__init__.py
SharePointList.save
def save(self): """ Updates the list with changes. """ # Based on the documentation at # http://msdn.microsoft.com/en-us/library/lists.lists.updatelistitems%28v=office.12%29.aspx # Note, this ends up un-namespaced. SharePoint doesn't care about # namespaces on th...
python
def save(self): """ Updates the list with changes. """ # Based on the documentation at # http://msdn.microsoft.com/en-us/library/lists.lists.updatelistitems%28v=office.12%29.aspx # Note, this ends up un-namespaced. SharePoint doesn't care about # namespaces on th...
[ "def", "save", "(", "self", ")", ":", "# Based on the documentation at", "# http://msdn.microsoft.com/en-us/library/lists.lists.updatelistitems%28v=office.12%29.aspx", "# Note, this ends up un-namespaced. SharePoint doesn't care about", "# namespaces on this XML node, and will bork if any of these...
Updates the list with changes.
[ "Updates", "the", "list", "with", "changes", "." ]
f1a1e19189d78115fcfc25850d27319e34d7e699
https://github.com/ox-it/python-sharepoint/blob/f1a1e19189d78115fcfc25850d27319e34d7e699/sharepoint/lists/__init__.py#L270-L331
41,955
ox-it/python-sharepoint
sharepoint/lists/__init__.py
SharePointListRow.get_batch_method
def get_batch_method(self): """ Returns a change batch for SharePoint's UpdateListItems operation. """ if not self._changed: return None batch_method = E.Method(Cmd='Update' if self.id else 'New') batch_method.append(E.Field(text_type(self.id) if self.id else...
python
def get_batch_method(self): """ Returns a change batch for SharePoint's UpdateListItems operation. """ if not self._changed: return None batch_method = E.Method(Cmd='Update' if self.id else 'New') batch_method.append(E.Field(text_type(self.id) if self.id else...
[ "def", "get_batch_method", "(", "self", ")", ":", "if", "not", "self", ".", "_changed", ":", "return", "None", "batch_method", "=", "E", ".", "Method", "(", "Cmd", "=", "'Update'", "if", "self", ".", "id", "else", "'New'", ")", "batch_method", ".", "ap...
Returns a change batch for SharePoint's UpdateListItems operation.
[ "Returns", "a", "change", "batch", "for", "SharePoint", "s", "UpdateListItems", "operation", "." ]
f1a1e19189d78115fcfc25850d27319e34d7e699
https://github.com/ox-it/python-sharepoint/blob/f1a1e19189d78115fcfc25850d27319e34d7e699/sharepoint/lists/__init__.py#L374-L388
41,956
maxcutler/python-wordpress-xmlrpc
wordpress_xmlrpc/fieldmaps.py
FieldMap.convert_to_python
def convert_to_python(self, xmlrpc=None): """ Extracts a value for the field from an XML-RPC response. """ if xmlrpc: return xmlrpc.get(self.name, self.default) elif self.default: return self.default else: return None
python
def convert_to_python(self, xmlrpc=None): """ Extracts a value for the field from an XML-RPC response. """ if xmlrpc: return xmlrpc.get(self.name, self.default) elif self.default: return self.default else: return None
[ "def", "convert_to_python", "(", "self", ",", "xmlrpc", "=", "None", ")", ":", "if", "xmlrpc", ":", "return", "xmlrpc", ".", "get", "(", "self", ".", "name", ",", "self", ".", "default", ")", "elif", "self", ".", "default", ":", "return", "self", "."...
Extracts a value for the field from an XML-RPC response.
[ "Extracts", "a", "value", "for", "the", "field", "from", "an", "XML", "-", "RPC", "response", "." ]
7ac0a6e9934fdbf02c2250932e0c026cf530d400
https://github.com/maxcutler/python-wordpress-xmlrpc/blob/7ac0a6e9934fdbf02c2250932e0c026cf530d400/wordpress_xmlrpc/fieldmaps.py#L24-L33
41,957
maxcutler/python-wordpress-xmlrpc
wordpress_xmlrpc/fieldmaps.py
FieldMap.get_outputs
def get_outputs(self, input_value): """ Generate a set of output values for a given input. """ output_value = self.convert_to_xmlrpc(input_value) output = {} for name in self.output_names: output[name] = output_value return output
python
def get_outputs(self, input_value): """ Generate a set of output values for a given input. """ output_value = self.convert_to_xmlrpc(input_value) output = {} for name in self.output_names: output[name] = output_value return output
[ "def", "get_outputs", "(", "self", ",", "input_value", ")", ":", "output_value", "=", "self", ".", "convert_to_xmlrpc", "(", "input_value", ")", "output", "=", "{", "}", "for", "name", "in", "self", ".", "output_names", ":", "output", "[", "name", "]", "...
Generate a set of output values for a given input.
[ "Generate", "a", "set", "of", "output", "values", "for", "a", "given", "input", "." ]
7ac0a6e9934fdbf02c2250932e0c026cf530d400
https://github.com/maxcutler/python-wordpress-xmlrpc/blob/7ac0a6e9934fdbf02c2250932e0c026cf530d400/wordpress_xmlrpc/fieldmaps.py#L44-L54
41,958
maxcutler/python-wordpress-xmlrpc
wordpress_xmlrpc/wordpress.py
WordPressBase.struct
def struct(self): """ XML-RPC-friendly representation of the current object state """ data = {} for var, fmap in self._def.items(): if hasattr(self, var): data.update(fmap.get_outputs(getattr(self, var))) return data
python
def struct(self): """ XML-RPC-friendly representation of the current object state """ data = {} for var, fmap in self._def.items(): if hasattr(self, var): data.update(fmap.get_outputs(getattr(self, var))) return data
[ "def", "struct", "(", "self", ")", ":", "data", "=", "{", "}", "for", "var", ",", "fmap", "in", "self", ".", "_def", ".", "items", "(", ")", ":", "if", "hasattr", "(", "self", ",", "var", ")", ":", "data", ".", "update", "(", "fmap", ".", "ge...
XML-RPC-friendly representation of the current object state
[ "XML", "-", "RPC", "-", "friendly", "representation", "of", "the", "current", "object", "state" ]
7ac0a6e9934fdbf02c2250932e0c026cf530d400
https://github.com/maxcutler/python-wordpress-xmlrpc/blob/7ac0a6e9934fdbf02c2250932e0c026cf530d400/wordpress_xmlrpc/wordpress.py#L40-L48
41,959
maxcutler/python-wordpress-xmlrpc
wordpress_xmlrpc/base.py
XmlrpcMethod.get_args
def get_args(self, client): """ Builds final set of XML-RPC method arguments based on the method's arguments, any default arguments, and their defined respective ordering. """ default_args = self.default_args(client) if self.method_args or self.optional_a...
python
def get_args(self, client): """ Builds final set of XML-RPC method arguments based on the method's arguments, any default arguments, and their defined respective ordering. """ default_args = self.default_args(client) if self.method_args or self.optional_a...
[ "def", "get_args", "(", "self", ",", "client", ")", ":", "default_args", "=", "self", ".", "default_args", "(", "client", ")", "if", "self", ".", "method_args", "or", "self", ".", "optional_args", ":", "optional_args", "=", "getattr", "(", "self", ",", "...
Builds final set of XML-RPC method arguments based on the method's arguments, any default arguments, and their defined respective ordering.
[ "Builds", "final", "set", "of", "XML", "-", "RPC", "method", "arguments", "based", "on", "the", "method", "s", "arguments", "any", "default", "arguments", "and", "their", "defined", "respective", "ordering", "." ]
7ac0a6e9934fdbf02c2250932e0c026cf530d400
https://github.com/maxcutler/python-wordpress-xmlrpc/blob/7ac0a6e9934fdbf02c2250932e0c026cf530d400/wordpress_xmlrpc/base.py#L95-L117
41,960
maxcutler/python-wordpress-xmlrpc
wordpress_xmlrpc/base.py
XmlrpcMethod.process_result
def process_result(self, raw_result): """ Performs actions on the raw result from the XML-RPC response. If a `results_class` is defined, the response will be converted into one or more object instances of that class. """ if self.results_class and raw_result: ...
python
def process_result(self, raw_result): """ Performs actions on the raw result from the XML-RPC response. If a `results_class` is defined, the response will be converted into one or more object instances of that class. """ if self.results_class and raw_result: ...
[ "def", "process_result", "(", "self", ",", "raw_result", ")", ":", "if", "self", ".", "results_class", "and", "raw_result", ":", "if", "isinstance", "(", "raw_result", ",", "dict_type", ")", ":", "return", "self", ".", "results_class", "(", "raw_result", ")"...
Performs actions on the raw result from the XML-RPC response. If a `results_class` is defined, the response will be converted into one or more object instances of that class.
[ "Performs", "actions", "on", "the", "raw", "result", "from", "the", "XML", "-", "RPC", "response", ".", "If", "a", "results_class", "is", "defined", "the", "response", "will", "be", "converted", "into", "one", "or", "more", "object", "instances", "of", "th...
7ac0a6e9934fdbf02c2250932e0c026cf530d400
https://github.com/maxcutler/python-wordpress-xmlrpc/blob/7ac0a6e9934fdbf02c2250932e0c026cf530d400/wordpress_xmlrpc/base.py#L119-L132
41,961
vladimarius/pyap
pyap/parser.py
AddressParser.parse
def parse(self, text): '''Returns a list of addresses found in text together with parsed address parts ''' results = [] if isinstance(text, str): if six.PY2: text = unicode(text, 'utf-8') self.clean_text = self._normalize_string(text) ...
python
def parse(self, text): '''Returns a list of addresses found in text together with parsed address parts ''' results = [] if isinstance(text, str): if six.PY2: text = unicode(text, 'utf-8') self.clean_text = self._normalize_string(text) ...
[ "def", "parse", "(", "self", ",", "text", ")", ":", "results", "=", "[", "]", "if", "isinstance", "(", "text", ",", "str", ")", ":", "if", "six", ".", "PY2", ":", "text", "=", "unicode", "(", "text", ",", "'utf-8'", ")", "self", ".", "clean_text"...
Returns a list of addresses found in text together with parsed address parts
[ "Returns", "a", "list", "of", "addresses", "found", "in", "text", "together", "with", "parsed", "address", "parts" ]
7896b5293982a30c1443e0c81c1ca32eeb8db15c
https://github.com/vladimarius/pyap/blob/7896b5293982a30c1443e0c81c1ca32eeb8db15c/pyap/parser.py#L50-L66
41,962
vladimarius/pyap
pyap/parser.py
AddressParser._parse_address
def _parse_address(self, address_string): '''Parses address into parts''' match = utils.match(self.rules, address_string, flags=re.VERBOSE | re.U) if match: match_as_dict = match.groupdict() match_as_dict.update({'country_id': self.country}) # combine results ...
python
def _parse_address(self, address_string): '''Parses address into parts''' match = utils.match(self.rules, address_string, flags=re.VERBOSE | re.U) if match: match_as_dict = match.groupdict() match_as_dict.update({'country_id': self.country}) # combine results ...
[ "def", "_parse_address", "(", "self", ",", "address_string", ")", ":", "match", "=", "utils", ".", "match", "(", "self", ".", "rules", ",", "address_string", ",", "flags", "=", "re", ".", "VERBOSE", "|", "re", ".", "U", ")", "if", "match", ":", "matc...
Parses address into parts
[ "Parses", "address", "into", "parts" ]
7896b5293982a30c1443e0c81c1ca32eeb8db15c
https://github.com/vladimarius/pyap/blob/7896b5293982a30c1443e0c81c1ca32eeb8db15c/pyap/parser.py#L68-L79
41,963
vladimarius/pyap
pyap/parser.py
AddressParser._get_addresses
def _get_addresses(self, text): '''Returns a list of addresses found in text''' # find addresses addresses = [] matches = utils.findall( self.rules, text, flags=re.VERBOSE | re.U) if(matches): for match in matches: ...
python
def _get_addresses(self, text): '''Returns a list of addresses found in text''' # find addresses addresses = [] matches = utils.findall( self.rules, text, flags=re.VERBOSE | re.U) if(matches): for match in matches: ...
[ "def", "_get_addresses", "(", "self", ",", "text", ")", ":", "# find addresses", "addresses", "=", "[", "]", "matches", "=", "utils", ".", "findall", "(", "self", ".", "rules", ",", "text", ",", "flags", "=", "re", ".", "VERBOSE", "|", "re", ".", "U"...
Returns a list of addresses found in text
[ "Returns", "a", "list", "of", "addresses", "found", "in", "text" ]
7896b5293982a30c1443e0c81c1ca32eeb8db15c
https://github.com/vladimarius/pyap/blob/7896b5293982a30c1443e0c81c1ca32eeb8db15c/pyap/parser.py#L129-L141
41,964
vladimarius/pyap
pyap/api.py
parse
def parse(some_text, **kwargs): """Creates request to AddressParser and returns list of Address objects """ ap = parser.AddressParser(**kwargs) return ap.parse(some_text)
python
def parse(some_text, **kwargs): """Creates request to AddressParser and returns list of Address objects """ ap = parser.AddressParser(**kwargs) return ap.parse(some_text)
[ "def", "parse", "(", "some_text", ",", "*", "*", "kwargs", ")", ":", "ap", "=", "parser", ".", "AddressParser", "(", "*", "*", "kwargs", ")", "return", "ap", ".", "parse", "(", "some_text", ")" ]
Creates request to AddressParser and returns list of Address objects
[ "Creates", "request", "to", "AddressParser", "and", "returns", "list", "of", "Address", "objects" ]
7896b5293982a30c1443e0c81c1ca32eeb8db15c
https://github.com/vladimarius/pyap/blob/7896b5293982a30c1443e0c81c1ca32eeb8db15c/pyap/api.py#L16-L21
41,965
ga4gh/ga4gh-schemas
python/ga4gh/schemas/protocol.py
setAttribute
def setAttribute(values, value): """ Takes the values of an attribute value list and attempts to append attributes of the proper type, inferred from their Python type. """ if isinstance(value, int): values.add().int32_value = value elif isinstance(value, float): values.add().doub...
python
def setAttribute(values, value): """ Takes the values of an attribute value list and attempts to append attributes of the proper type, inferred from their Python type. """ if isinstance(value, int): values.add().int32_value = value elif isinstance(value, float): values.add().doub...
[ "def", "setAttribute", "(", "values", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "int", ")", ":", "values", ".", "add", "(", ")", ".", "int32_value", "=", "value", "elif", "isinstance", "(", "value", ",", "float", ")", ":", "value...
Takes the values of an attribute value list and attempts to append attributes of the proper type, inferred from their Python type.
[ "Takes", "the", "values", "of", "an", "attribute", "value", "list", "and", "attempts", "to", "append", "attributes", "of", "the", "proper", "type", "inferred", "from", "their", "Python", "type", "." ]
30ec8db9b8dfdccf03274025f27920cb41d6d56e
https://github.com/ga4gh/ga4gh-schemas/blob/30ec8db9b8dfdccf03274025f27920cb41d6d56e/python/ga4gh/schemas/protocol.py#L49-L72
41,966
ga4gh/ga4gh-schemas
python/ga4gh/schemas/protocol.py
deepSetAttr
def deepSetAttr(obj, path, val): """ Sets a deep attribute on an object by resolving a dot-delimited path. If path does not exist an `AttributeError` will be raised`. """ first, _, rest = path.rpartition('.') return setattr(deepGetAttr(obj, first) if first else obj, rest, val)
python
def deepSetAttr(obj, path, val): """ Sets a deep attribute on an object by resolving a dot-delimited path. If path does not exist an `AttributeError` will be raised`. """ first, _, rest = path.rpartition('.') return setattr(deepGetAttr(obj, first) if first else obj, rest, val)
[ "def", "deepSetAttr", "(", "obj", ",", "path", ",", "val", ")", ":", "first", ",", "_", ",", "rest", "=", "path", ".", "rpartition", "(", "'.'", ")", "return", "setattr", "(", "deepGetAttr", "(", "obj", ",", "first", ")", "if", "first", "else", "ob...
Sets a deep attribute on an object by resolving a dot-delimited path. If path does not exist an `AttributeError` will be raised`.
[ "Sets", "a", "deep", "attribute", "on", "an", "object", "by", "resolving", "a", "dot", "-", "delimited", "path", ".", "If", "path", "does", "not", "exist", "an", "AttributeError", "will", "be", "raised", "." ]
30ec8db9b8dfdccf03274025f27920cb41d6d56e
https://github.com/ga4gh/ga4gh-schemas/blob/30ec8db9b8dfdccf03274025f27920cb41d6d56e/python/ga4gh/schemas/protocol.py#L83-L89
41,967
ga4gh/ga4gh-schemas
python/ga4gh/schemas/protocol.py
convertDatetime
def convertDatetime(t): """ Converts the specified datetime object into its appropriate protocol value. This is the number of milliseconds from the epoch. """ epoch = datetime.datetime.utcfromtimestamp(0) delta = t - epoch millis = delta.total_seconds() * 1000 return int(millis)
python
def convertDatetime(t): """ Converts the specified datetime object into its appropriate protocol value. This is the number of milliseconds from the epoch. """ epoch = datetime.datetime.utcfromtimestamp(0) delta = t - epoch millis = delta.total_seconds() * 1000 return int(millis)
[ "def", "convertDatetime", "(", "t", ")", ":", "epoch", "=", "datetime", ".", "datetime", ".", "utcfromtimestamp", "(", "0", ")", "delta", "=", "t", "-", "epoch", "millis", "=", "delta", ".", "total_seconds", "(", ")", "*", "1000", "return", "int", "(",...
Converts the specified datetime object into its appropriate protocol value. This is the number of milliseconds from the epoch.
[ "Converts", "the", "specified", "datetime", "object", "into", "its", "appropriate", "protocol", "value", ".", "This", "is", "the", "number", "of", "milliseconds", "from", "the", "epoch", "." ]
30ec8db9b8dfdccf03274025f27920cb41d6d56e
https://github.com/ga4gh/ga4gh-schemas/blob/30ec8db9b8dfdccf03274025f27920cb41d6d56e/python/ga4gh/schemas/protocol.py#L110-L118
41,968
ga4gh/ga4gh-schemas
python/ga4gh/schemas/protocol.py
getValueFromValue
def getValueFromValue(value): """ Extract the currently set field from a Value structure """ if type(value) != common.AttributeValue: raise TypeError( "Expected an AttributeValue, but got {}".format(type(value))) if value.WhichOneof("value") is None: raise AttributeError(...
python
def getValueFromValue(value): """ Extract the currently set field from a Value structure """ if type(value) != common.AttributeValue: raise TypeError( "Expected an AttributeValue, but got {}".format(type(value))) if value.WhichOneof("value") is None: raise AttributeError(...
[ "def", "getValueFromValue", "(", "value", ")", ":", "if", "type", "(", "value", ")", "!=", "common", ".", "AttributeValue", ":", "raise", "TypeError", "(", "\"Expected an AttributeValue, but got {}\"", ".", "format", "(", "type", "(", "value", ")", ")", ")", ...
Extract the currently set field from a Value structure
[ "Extract", "the", "currently", "set", "field", "from", "a", "Value", "structure" ]
30ec8db9b8dfdccf03274025f27920cb41d6d56e
https://github.com/ga4gh/ga4gh-schemas/blob/30ec8db9b8dfdccf03274025f27920cb41d6d56e/python/ga4gh/schemas/protocol.py#L121-L130
41,969
ga4gh/ga4gh-schemas
python/ga4gh/schemas/protocol.py
toJson
def toJson(protoObject, indent=None): """ Serialises a protobuf object as json """ # Using the internal method because this way we can reformat the JSON js = json_format.MessageToDict(protoObject, False) return json.dumps(js, indent=indent)
python
def toJson(protoObject, indent=None): """ Serialises a protobuf object as json """ # Using the internal method because this way we can reformat the JSON js = json_format.MessageToDict(protoObject, False) return json.dumps(js, indent=indent)
[ "def", "toJson", "(", "protoObject", ",", "indent", "=", "None", ")", ":", "# Using the internal method because this way we can reformat the JSON", "js", "=", "json_format", ".", "MessageToDict", "(", "protoObject", ",", "False", ")", "return", "json", ".", "dumps", ...
Serialises a protobuf object as json
[ "Serialises", "a", "protobuf", "object", "as", "json" ]
30ec8db9b8dfdccf03274025f27920cb41d6d56e
https://github.com/ga4gh/ga4gh-schemas/blob/30ec8db9b8dfdccf03274025f27920cb41d6d56e/python/ga4gh/schemas/protocol.py#L133-L139
41,970
ga4gh/ga4gh-schemas
python/ga4gh/schemas/protocol.py
getProtocolClasses
def getProtocolClasses(superclass=message.Message): """ Returns all the protocol classes that are subclasses of the specified superclass. Only 'leaf' classes are returned, corresponding directly to the classes defined in the protocol. """ # We keep a manual list of the superclasses that we defin...
python
def getProtocolClasses(superclass=message.Message): """ Returns all the protocol classes that are subclasses of the specified superclass. Only 'leaf' classes are returned, corresponding directly to the classes defined in the protocol. """ # We keep a manual list of the superclasses that we defin...
[ "def", "getProtocolClasses", "(", "superclass", "=", "message", ".", "Message", ")", ":", "# We keep a manual list of the superclasses that we define here", "# so we can filter them out when we're getting the protocol", "# classes.", "superclasses", "=", "set", "(", "[", "message...
Returns all the protocol classes that are subclasses of the specified superclass. Only 'leaf' classes are returned, corresponding directly to the classes defined in the protocol.
[ "Returns", "all", "the", "protocol", "classes", "that", "are", "subclasses", "of", "the", "specified", "superclass", ".", "Only", "leaf", "classes", "are", "returned", "corresponding", "directly", "to", "the", "classes", "defined", "in", "the", "protocol", "." ]
30ec8db9b8dfdccf03274025f27920cb41d6d56e
https://github.com/ga4gh/ga4gh-schemas/blob/30ec8db9b8dfdccf03274025f27920cb41d6d56e/python/ga4gh/schemas/protocol.py#L170-L187
41,971
ga4gh/ga4gh-schemas
scripts/process_schemas.py
runCommandSplits
def runCommandSplits(splits, silent=False, shell=False): """ Run a shell command given the command's parsed command line """ try: if silent: with open(os.devnull, 'w') as devnull: subprocess.check_call( splits, stdout=devnull, stderr=devnull, shell...
python
def runCommandSplits(splits, silent=False, shell=False): """ Run a shell command given the command's parsed command line """ try: if silent: with open(os.devnull, 'w') as devnull: subprocess.check_call( splits, stdout=devnull, stderr=devnull, shell...
[ "def", "runCommandSplits", "(", "splits", ",", "silent", "=", "False", ",", "shell", "=", "False", ")", ":", "try", ":", "if", "silent", ":", "with", "open", "(", "os", ".", "devnull", ",", "'w'", ")", "as", "devnull", ":", "subprocess", ".", "check_...
Run a shell command given the command's parsed command line
[ "Run", "a", "shell", "command", "given", "the", "command", "s", "parsed", "command", "line" ]
30ec8db9b8dfdccf03274025f27920cb41d6d56e
https://github.com/ga4gh/ga4gh-schemas/blob/30ec8db9b8dfdccf03274025f27920cb41d6d56e/scripts/process_schemas.py#L30-L46
41,972
ga4gh/ga4gh-schemas
scripts/process_schemas.py
ProtobufGenerator._createSchemaFiles
def _createSchemaFiles(self, destPath, schemasPath): """ Create a hierarchy of proto files in a destination directory, copied from the schemasPath hierarchy """ # Create the target directory hierarchy, if neccessary ga4ghPath = os.path.join(destPath, 'ga4gh') if n...
python
def _createSchemaFiles(self, destPath, schemasPath): """ Create a hierarchy of proto files in a destination directory, copied from the schemasPath hierarchy """ # Create the target directory hierarchy, if neccessary ga4ghPath = os.path.join(destPath, 'ga4gh') if n...
[ "def", "_createSchemaFiles", "(", "self", ",", "destPath", ",", "schemasPath", ")", ":", "# Create the target directory hierarchy, if neccessary", "ga4ghPath", "=", "os", ".", "path", ".", "join", "(", "destPath", ",", "'ga4gh'", ")", "if", "not", "os", ".", "pa...
Create a hierarchy of proto files in a destination directory, copied from the schemasPath hierarchy
[ "Create", "a", "hierarchy", "of", "proto", "files", "in", "a", "destination", "directory", "copied", "from", "the", "schemasPath", "hierarchy" ]
30ec8db9b8dfdccf03274025f27920cb41d6d56e
https://github.com/ga4gh/ga4gh-schemas/blob/30ec8db9b8dfdccf03274025f27920cb41d6d56e/scripts/process_schemas.py#L64-L94
41,973
ga4gh/ga4gh-schemas
scripts/process_schemas.py
ProtobufGenerator._doLineReplacements
def _doLineReplacements(self, line): """ Given a line of a proto file, replace the line with one that is appropriate for the hierarchy that we want to compile """ # ga4gh packages packageString = 'package ga4gh;' if packageString in line: return line.r...
python
def _doLineReplacements(self, line): """ Given a line of a proto file, replace the line with one that is appropriate for the hierarchy that we want to compile """ # ga4gh packages packageString = 'package ga4gh;' if packageString in line: return line.r...
[ "def", "_doLineReplacements", "(", "self", ",", "line", ")", ":", "# ga4gh packages", "packageString", "=", "'package ga4gh;'", "if", "packageString", "in", "line", ":", "return", "line", ".", "replace", "(", "packageString", ",", "'package ga4gh.schemas.ga4gh;'", "...
Given a line of a proto file, replace the line with one that is appropriate for the hierarchy that we want to compile
[ "Given", "a", "line", "of", "a", "proto", "file", "replace", "the", "line", "with", "one", "that", "is", "appropriate", "for", "the", "hierarchy", "that", "we", "want", "to", "compile" ]
30ec8db9b8dfdccf03274025f27920cb41d6d56e
https://github.com/ga4gh/ga4gh-schemas/blob/30ec8db9b8dfdccf03274025f27920cb41d6d56e/scripts/process_schemas.py#L96-L128
41,974
ga4gh/ga4gh-schemas
scripts/process_schemas.py
ProtobufGenerator._copySchemaFile
def _copySchemaFile(self, src, dst): """ Copy a proto file to the temporary directory, with appropriate line replacements """ with open(src) as srcFile, open(dst, 'w') as dstFile: srcLines = srcFile.readlines() for srcLine in srcLines: toWr...
python
def _copySchemaFile(self, src, dst): """ Copy a proto file to the temporary directory, with appropriate line replacements """ with open(src) as srcFile, open(dst, 'w') as dstFile: srcLines = srcFile.readlines() for srcLine in srcLines: toWr...
[ "def", "_copySchemaFile", "(", "self", ",", "src", ",", "dst", ")", ":", "with", "open", "(", "src", ")", "as", "srcFile", ",", "open", "(", "dst", ",", "'w'", ")", "as", "dstFile", ":", "srcLines", "=", "srcFile", ".", "readlines", "(", ")", "for"...
Copy a proto file to the temporary directory, with appropriate line replacements
[ "Copy", "a", "proto", "file", "to", "the", "temporary", "directory", "with", "appropriate", "line", "replacements" ]
30ec8db9b8dfdccf03274025f27920cb41d6d56e
https://github.com/ga4gh/ga4gh-schemas/blob/30ec8db9b8dfdccf03274025f27920cb41d6d56e/scripts/process_schemas.py#L130-L139
41,975
ga4gh/ga4gh-schemas
tools/sphinx/protobuf-json-docs.py
convert_protodef_to_editable
def convert_protodef_to_editable(proto): """ Protobuf objects can't have arbitrary fields addedd and we need to later on add comments to them, so we instead make "Editable" objects that can do so """ class Editable(object): def __init__(self, prot): self.kind = type(prot) ...
python
def convert_protodef_to_editable(proto): """ Protobuf objects can't have arbitrary fields addedd and we need to later on add comments to them, so we instead make "Editable" objects that can do so """ class Editable(object): def __init__(self, prot): self.kind = type(prot) ...
[ "def", "convert_protodef_to_editable", "(", "proto", ")", ":", "class", "Editable", "(", "object", ")", ":", "def", "__init__", "(", "self", ",", "prot", ")", ":", "self", ".", "kind", "=", "type", "(", "prot", ")", "self", ".", "name", "=", "prot", ...
Protobuf objects can't have arbitrary fields addedd and we need to later on add comments to them, so we instead make "Editable" objects that can do so
[ "Protobuf", "objects", "can", "t", "have", "arbitrary", "fields", "addedd", "and", "we", "need", "to", "later", "on", "add", "comments", "to", "them", "so", "we", "instead", "make", "Editable", "objects", "that", "can", "do", "so" ]
30ec8db9b8dfdccf03274025f27920cb41d6d56e
https://github.com/ga4gh/ga4gh-schemas/blob/30ec8db9b8dfdccf03274025f27920cb41d6d56e/tools/sphinx/protobuf-json-docs.py#L25-L58
41,976
mapado/haversine
haversine/haversine.py
haversine
def haversine(point1, point2, unit='km'): """ Calculate the great-circle distance between two points on the Earth surface. :input: two 2-tuples, containing the latitude and longitude of each point in decimal degrees. Keyword arguments: unit -- a string containing the initials of a unit of measurem...
python
def haversine(point1, point2, unit='km'): """ Calculate the great-circle distance between two points on the Earth surface. :input: two 2-tuples, containing the latitude and longitude of each point in decimal degrees. Keyword arguments: unit -- a string containing the initials of a unit of measurem...
[ "def", "haversine", "(", "point1", ",", "point2", ",", "unit", "=", "'km'", ")", ":", "# mean earth radius - https://en.wikipedia.org/wiki/Earth_radius#Mean_radius", "AVG_EARTH_RADIUS_KM", "=", "6371.0088", "# Units values taken from http://www.unitconversion.org/unit_converter/lengt...
Calculate the great-circle distance between two points on the Earth surface. :input: two 2-tuples, containing the latitude and longitude of each point in decimal degrees. Keyword arguments: unit -- a string containing the initials of a unit of measurement (i.e. miles = mi) default 'km' (ki...
[ "Calculate", "the", "great", "-", "circle", "distance", "between", "two", "points", "on", "the", "Earth", "surface", "." ]
221d9ebd368b4e035873aaa57bd42d98e1d83282
https://github.com/mapado/haversine/blob/221d9ebd368b4e035873aaa57bd42d98e1d83282/haversine/haversine.py#L4-L50
41,977
Illumina/interop
src/examples/python/summary.py
main
def main(): """ Retrieve run folder paths from the command line Ensure only metrics required for summary are loaded Load the run metrics Calculate the summary metrics Display error by lane, read """ logging.basicConfig(level=logging.INFO) run_metrics = py_interop_run_metrics.run_metrics...
python
def main(): """ Retrieve run folder paths from the command line Ensure only metrics required for summary are loaded Load the run metrics Calculate the summary metrics Display error by lane, read """ logging.basicConfig(level=logging.INFO) run_metrics = py_interop_run_metrics.run_metrics...
[ "def", "main", "(", ")", ":", "logging", ".", "basicConfig", "(", "level", "=", "logging", ".", "INFO", ")", "run_metrics", "=", "py_interop_run_metrics", ".", "run_metrics", "(", ")", "summary", "=", "py_interop_summary", ".", "run_summary", "(", ")", "vali...
Retrieve run folder paths from the command line Ensure only metrics required for summary are loaded Load the run metrics Calculate the summary metrics Display error by lane, read
[ "Retrieve", "run", "folder", "paths", "from", "the", "command", "line", "Ensure", "only", "metrics", "required", "for", "summary", "are", "loaded", "Load", "the", "run", "metrics", "Calculate", "the", "summary", "metrics", "Display", "error", "by", "lane", "re...
a55b40bde4b764e3652758f6cdf72aef5f473370
https://github.com/Illumina/interop/blob/a55b40bde4b764e3652758f6cdf72aef5f473370/src/examples/python/summary.py#L17-L49
41,978
SteveMcGrath/pySecurityCenter
examples/sc4/csv_gen/sccsv/generator.py
gen_csv
def gen_csv(sc, filename, field_list, source, filters): '''csv SecurityCenterObj, AssetListName, CSVFields, EmailAddress ''' # First thing we need to do is initialize the csvfile and build the header # for the file. datafile = open(filename, 'wb') csvfile = csv.writer(datafile) header = [] ...
python
def gen_csv(sc, filename, field_list, source, filters): '''csv SecurityCenterObj, AssetListName, CSVFields, EmailAddress ''' # First thing we need to do is initialize the csvfile and build the header # for the file. datafile = open(filename, 'wb') csvfile = csv.writer(datafile) header = [] ...
[ "def", "gen_csv", "(", "sc", ",", "filename", ",", "field_list", ",", "source", ",", "filters", ")", ":", "# First thing we need to do is initialize the csvfile and build the header", "# for the file.", "datafile", "=", "open", "(", "filename", ",", "'wb'", ")", "csvf...
csv SecurityCenterObj, AssetListName, CSVFields, EmailAddress
[ "csv", "SecurityCenterObj", "AssetListName", "CSVFields", "EmailAddress" ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/examples/sc4/csv_gen/sccsv/generator.py#L46-L70
41,979
SteveMcGrath/pySecurityCenter
securitycenter/sc5.py
SecurityCenter5.login
def login(self, user, passwd): '''Logs the user into SecurityCenter and stores the needed token and cookies.''' resp = self.post('token', json={'username': user, 'password': passwd}) self._token = resp.json()['response']['token']
python
def login(self, user, passwd): '''Logs the user into SecurityCenter and stores the needed token and cookies.''' resp = self.post('token', json={'username': user, 'password': passwd}) self._token = resp.json()['response']['token']
[ "def", "login", "(", "self", ",", "user", ",", "passwd", ")", ":", "resp", "=", "self", ".", "post", "(", "'token'", ",", "json", "=", "{", "'username'", ":", "user", ",", "'password'", ":", "passwd", "}", ")", "self", ".", "_token", "=", "resp", ...
Logs the user into SecurityCenter and stores the needed token and cookies.
[ "Logs", "the", "user", "into", "SecurityCenter", "and", "stores", "the", "needed", "token", "and", "cookies", "." ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/securitycenter/sc5.py#L42-L45
41,980
SteveMcGrath/pySecurityCenter
examples/sc5/download_scans/downloader.py
download_scans
def download_scans(sc, age=0, unzip=False, path='scans'): '''Scan Downloader Here we will attempt to download all of the scans that have completed between now and AGE days ago. sc = SecurityCenter5 object age = how many days back do we want to pull? (default: 0) unzip = Do we want to uncompress...
python
def download_scans(sc, age=0, unzip=False, path='scans'): '''Scan Downloader Here we will attempt to download all of the scans that have completed between now and AGE days ago. sc = SecurityCenter5 object age = how many days back do we want to pull? (default: 0) unzip = Do we want to uncompress...
[ "def", "download_scans", "(", "sc", ",", "age", "=", "0", ",", "unzip", "=", "False", ",", "path", "=", "'scans'", ")", ":", "# if the download path doesn't exist, we need to create it.", "if", "not", "os", ".", "path", ".", "exists", "(", "path", ")", ":", ...
Scan Downloader Here we will attempt to download all of the scans that have completed between now and AGE days ago. sc = SecurityCenter5 object age = how many days back do we want to pull? (default: 0) unzip = Do we want to uncompress the nessus files? (default: False) path = Path where the res...
[ "Scan", "Downloader", "Here", "we", "will", "attempt", "to", "download", "all", "of", "the", "scans", "that", "have", "completed", "between", "now", "and", "AGE", "days", "ago", "." ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/examples/sc5/download_scans/downloader.py#L15-L79
41,981
SteveMcGrath/pySecurityCenter
examples/sc4/populate_asset_list/dns_populate.py
update
def update(sc, filename, asset_id): ''' Updates a DNS Asset List with the contents of the filename. The assumed format of the file is 1 entry per line. This function will convert the file contents into an array of entries and then upload that array into SecurityCenter. ''' addresses = [] ...
python
def update(sc, filename, asset_id): ''' Updates a DNS Asset List with the contents of the filename. The assumed format of the file is 1 entry per line. This function will convert the file contents into an array of entries and then upload that array into SecurityCenter. ''' addresses = [] ...
[ "def", "update", "(", "sc", ",", "filename", ",", "asset_id", ")", ":", "addresses", "=", "[", "]", "with", "open", "(", "filename", ")", "as", "hostfile", ":", "for", "line", "in", "hostfile", ".", "readlines", "(", ")", ":", "addresses", ".", "appe...
Updates a DNS Asset List with the contents of the filename. The assumed format of the file is 1 entry per line. This function will convert the file contents into an array of entries and then upload that array into SecurityCenter.
[ "Updates", "a", "DNS", "Asset", "List", "with", "the", "contents", "of", "the", "filename", ".", "The", "assumed", "format", "of", "the", "file", "is", "1", "entry", "per", "line", ".", "This", "function", "will", "convert", "the", "file", "contents", "i...
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/examples/sc4/populate_asset_list/dns_populate.py#L9-L20
41,982
SteveMcGrath/pySecurityCenter
examples/sc5/software_change/swchange/reporter.py
generate_html_report
def generate_html_report(base_path, asset_id): ''' Generates the HTML report and dumps it into the specified filename ''' jenv = Environment(loader=PackageLoader('swchange', 'templates')) s = Session() #hosts = s.query(Host).filter_by(asset_id=asset_id).all() asset = s.query(AssetList).filte...
python
def generate_html_report(base_path, asset_id): ''' Generates the HTML report and dumps it into the specified filename ''' jenv = Environment(loader=PackageLoader('swchange', 'templates')) s = Session() #hosts = s.query(Host).filter_by(asset_id=asset_id).all() asset = s.query(AssetList).filte...
[ "def", "generate_html_report", "(", "base_path", ",", "asset_id", ")", ":", "jenv", "=", "Environment", "(", "loader", "=", "PackageLoader", "(", "'swchange'", ",", "'templates'", ")", ")", "s", "=", "Session", "(", ")", "#hosts = s.query(Host).filter_by(asset_id=...
Generates the HTML report and dumps it into the specified filename
[ "Generates", "the", "HTML", "report", "and", "dumps", "it", "into", "the", "specified", "filename" ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/examples/sc5/software_change/swchange/reporter.py#L7-L27
41,983
SteveMcGrath/pySecurityCenter
examples/sc4/gen_software_report/sccsv/generator.py
gen_csv
def gen_csv(sc, filename): '''csv SecurityCenterObj, EmailAddress ''' # First thing we need to do is initialize the csvfile and build the header # for the file. datafile = open(filename, 'wb') csvfile = csv.writer(datafile) csvfile.writerow(['Software Package Name', 'Count']) debug.wri...
python
def gen_csv(sc, filename): '''csv SecurityCenterObj, EmailAddress ''' # First thing we need to do is initialize the csvfile and build the header # for the file. datafile = open(filename, 'wb') csvfile = csv.writer(datafile) csvfile.writerow(['Software Package Name', 'Count']) debug.wri...
[ "def", "gen_csv", "(", "sc", ",", "filename", ")", ":", "# First thing we need to do is initialize the csvfile and build the header", "# for the file.", "datafile", "=", "open", "(", "filename", ",", "'wb'", ")", "csvfile", "=", "csv", ".", "writer", "(", "datafile", ...
csv SecurityCenterObj, EmailAddress
[ "csv", "SecurityCenterObj", "EmailAddress" ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/examples/sc4/gen_software_report/sccsv/generator.py#L17-L37
41,984
SteveMcGrath/pySecurityCenter
examples/sc5/download_reports/report_downloader.py
download
def download(sc, age=0, path='reports', **args): '''Report Downloader The report downloader will pull reports down from SecurityCenter based on the conditions provided to the path provided. sc = SecurityCenter5 object age = number of days old the report may be to be included in the ...
python
def download(sc, age=0, path='reports', **args): '''Report Downloader The report downloader will pull reports down from SecurityCenter based on the conditions provided to the path provided. sc = SecurityCenter5 object age = number of days old the report may be to be included in the ...
[ "def", "download", "(", "sc", ",", "age", "=", "0", ",", "path", "=", "'reports'", ",", "*", "*", "args", ")", ":", "# if the download path doesn't exist, we need to create it.", "if", "not", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "logger...
Report Downloader The report downloader will pull reports down from SecurityCenter based on the conditions provided to the path provided. sc = SecurityCenter5 object age = number of days old the report may be to be included in the search. path = The path to the dow...
[ "Report", "Downloader", "The", "report", "downloader", "will", "pull", "reports", "down", "from", "SecurityCenter", "based", "on", "the", "conditions", "provided", "to", "the", "path", "provided", "." ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/examples/sc5/download_reports/report_downloader.py#L11-L76
41,985
SteveMcGrath/pySecurityCenter
securitycenter/base.py
BaseAPI.post
def post(self, path, **kwargs): '''Calls the specified path with the POST method''' resp = self._session.post(self._url(path), **self._builder(**kwargs)) if 'stream' in kwargs: return resp else: return self._resp_error_check(resp)
python
def post(self, path, **kwargs): '''Calls the specified path with the POST method''' resp = self._session.post(self._url(path), **self._builder(**kwargs)) if 'stream' in kwargs: return resp else: return self._resp_error_check(resp)
[ "def", "post", "(", "self", ",", "path", ",", "*", "*", "kwargs", ")", ":", "resp", "=", "self", ".", "_session", ".", "post", "(", "self", ".", "_url", "(", "path", ")", ",", "*", "*", "self", ".", "_builder", "(", "*", "*", "kwargs", ")", "...
Calls the specified path with the POST method
[ "Calls", "the", "specified", "path", "with", "the", "POST", "method" ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/securitycenter/base.py#L90-L96
41,986
SteveMcGrath/pySecurityCenter
examples/sc5/import_repo/import_repo.py
ExtendedSecurityCenter.import_repo
def import_repo(self, repo_id, fileobj): ''' Imports a repository package using the repository ID specified. ''' # Step 1, lets upload the file filename = self.upload(fileobj).json()['response']['filename'] # Step 2, lets tell SecurityCenter what to do with the file ...
python
def import_repo(self, repo_id, fileobj): ''' Imports a repository package using the repository ID specified. ''' # Step 1, lets upload the file filename = self.upload(fileobj).json()['response']['filename'] # Step 2, lets tell SecurityCenter what to do with the file ...
[ "def", "import_repo", "(", "self", ",", "repo_id", ",", "fileobj", ")", ":", "# Step 1, lets upload the file", "filename", "=", "self", ".", "upload", "(", "fileobj", ")", ".", "json", "(", ")", "[", "'response'", "]", "[", "'filename'", "]", "# Step 2, lets...
Imports a repository package using the repository ID specified.
[ "Imports", "a", "repository", "package", "using", "the", "repository", "ID", "specified", "." ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/examples/sc5/import_repo/import_repo.py#L6-L14
41,987
SteveMcGrath/pySecurityCenter
securitycenter/sc4.py
SecurityCenter4._revint
def _revint(self, version): ''' Internal function to convert a version string to an integer. ''' intrev = 0 vsplit = version.split('.') for c in range(len(vsplit)): item = int(vsplit[c]) * (10 ** (((len(vsplit) - c - 1) * 2))) intrev += item ...
python
def _revint(self, version): ''' Internal function to convert a version string to an integer. ''' intrev = 0 vsplit = version.split('.') for c in range(len(vsplit)): item = int(vsplit[c]) * (10 ** (((len(vsplit) - c - 1) * 2))) intrev += item ...
[ "def", "_revint", "(", "self", ",", "version", ")", ":", "intrev", "=", "0", "vsplit", "=", "version", ".", "split", "(", "'.'", ")", "for", "c", "in", "range", "(", "len", "(", "vsplit", ")", ")", ":", "item", "=", "int", "(", "vsplit", "[", "...
Internal function to convert a version string to an integer.
[ "Internal", "function", "to", "convert", "a", "version", "string", "to", "an", "integer", "." ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/securitycenter/sc4.py#L41-L50
41,988
SteveMcGrath/pySecurityCenter
securitycenter/sc4.py
SecurityCenter4._revcheck
def _revcheck(self, func, version): ''' Internal function to see if a version is func than what we have determined to be talking to. This is very useful for newer API calls to make sure we don't accidentally make a call to something that doesnt exist. ''' current...
python
def _revcheck(self, func, version): ''' Internal function to see if a version is func than what we have determined to be talking to. This is very useful for newer API calls to make sure we don't accidentally make a call to something that doesnt exist. ''' current...
[ "def", "_revcheck", "(", "self", ",", "func", ",", "version", ")", ":", "current", "=", "self", ".", "_revint", "(", "self", ".", "version", ")", "check", "=", "self", ".", "_revint", "(", "version", ")", "if", "func", "in", "(", "'lt'", ",", "'<='...
Internal function to see if a version is func than what we have determined to be talking to. This is very useful for newer API calls to make sure we don't accidentally make a call to something that doesnt exist.
[ "Internal", "function", "to", "see", "if", "a", "version", "is", "func", "than", "what", "we", "have", "determined", "to", "be", "talking", "to", ".", "This", "is", "very", "useful", "for", "newer", "API", "calls", "to", "make", "sure", "we", "don", "t...
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/securitycenter/sc4.py#L52-L68
41,989
SteveMcGrath/pySecurityCenter
securitycenter/sc4.py
SecurityCenter4._build_xrefs
def _build_xrefs(self): ''' Internal function to populate the xrefs list with the external references to be used in searching plugins and potentially other functions as well. ''' xrefs = set() plugins = self.plugins() for plugin in plugins: fo...
python
def _build_xrefs(self): ''' Internal function to populate the xrefs list with the external references to be used in searching plugins and potentially other functions as well. ''' xrefs = set() plugins = self.plugins() for plugin in plugins: fo...
[ "def", "_build_xrefs", "(", "self", ")", ":", "xrefs", "=", "set", "(", ")", "plugins", "=", "self", ".", "plugins", "(", ")", "for", "plugin", "in", "plugins", ":", "for", "xref", "in", "plugin", "[", "'xrefs'", "]", ".", "split", "(", "', '", ")"...
Internal function to populate the xrefs list with the external references to be used in searching plugins and potentially other functions as well.
[ "Internal", "function", "to", "populate", "the", "xrefs", "list", "with", "the", "external", "references", "to", "be", "used", "in", "searching", "plugins", "and", "potentially", "other", "functions", "as", "well", "." ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/securitycenter/sc4.py#L70-L84
41,990
SteveMcGrath/pySecurityCenter
securitycenter/sc4.py
SecurityCenter4.login
def login(self, user, passwd): """login user passwd Performs the login operation for Security Center, storing the token that Security Center has generated for this login session for future queries. """ data = self.raw_query('auth', 'login', da...
python
def login(self, user, passwd): """login user passwd Performs the login operation for Security Center, storing the token that Security Center has generated for this login session for future queries. """ data = self.raw_query('auth', 'login', da...
[ "def", "login", "(", "self", ",", "user", ",", "passwd", ")", ":", "data", "=", "self", ".", "raw_query", "(", "'auth'", ",", "'login'", ",", "data", "=", "{", "'username'", ":", "user", ",", "'password'", ":", "passwd", "}", ")", "self", ".", "_to...
login user passwd Performs the login operation for Security Center, storing the token that Security Center has generated for this login session for future queries.
[ "login", "user", "passwd", "Performs", "the", "login", "operation", "for", "Security", "Center", "storing", "the", "token", "that", "Security", "Center", "has", "generated", "for", "this", "login", "session", "for", "future", "queries", "." ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/securitycenter/sc4.py#L259-L268
41,991
SteveMcGrath/pySecurityCenter
securitycenter/sc4.py
SecurityCenter4.credential_add
def credential_add(self, name, cred_type, **options): ''' Adds a new credential into SecurityCenter. As credentials can be of multiple types, we have different options to specify for each type of credential. **Global Options (Required)** :param name: Unique name to be ...
python
def credential_add(self, name, cred_type, **options): ''' Adds a new credential into SecurityCenter. As credentials can be of multiple types, we have different options to specify for each type of credential. **Global Options (Required)** :param name: Unique name to be ...
[ "def", "credential_add", "(", "self", ",", "name", ",", "cred_type", ",", "*", "*", "options", ")", ":", "if", "'pirvateKey'", "in", "options", ":", "options", "[", "'privateKey'", "]", "=", "self", ".", "_upload", "(", "options", "[", "'privateKey'", "]...
Adds a new credential into SecurityCenter. As credentials can be of multiple types, we have different options to specify for each type of credential. **Global Options (Required)** :param name: Unique name to be associated to this credential :param cred_type: The type of creden...
[ "Adds", "a", "new", "credential", "into", "SecurityCenter", ".", "As", "credentials", "can", "be", "of", "multiple", "types", "we", "have", "different", "options", "to", "specify", "for", "each", "type", "of", "credential", "." ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/securitycenter/sc4.py#L419-L527
41,992
SteveMcGrath/pySecurityCenter
securitycenter/sc4.py
SecurityCenter4.credential_delete_simulate
def credential_delete_simulate(self, *ids): """Show the relationships and dependencies for one or more credentials. :param ids: one or more credential ids """ return self.raw_query("credential", "deleteSimulate", data={ "credentials": [{"id": str(id)} for id in ids] ...
python
def credential_delete_simulate(self, *ids): """Show the relationships and dependencies for one or more credentials. :param ids: one or more credential ids """ return self.raw_query("credential", "deleteSimulate", data={ "credentials": [{"id": str(id)} for id in ids] ...
[ "def", "credential_delete_simulate", "(", "self", ",", "*", "ids", ")", ":", "return", "self", ".", "raw_query", "(", "\"credential\"", ",", "\"deleteSimulate\"", ",", "data", "=", "{", "\"credentials\"", ":", "[", "{", "\"id\"", ":", "str", "(", "id", ")"...
Show the relationships and dependencies for one or more credentials. :param ids: one or more credential ids
[ "Show", "the", "relationships", "and", "dependencies", "for", "one", "or", "more", "credentials", "." ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/securitycenter/sc4.py#L551-L558
41,993
SteveMcGrath/pySecurityCenter
securitycenter/sc4.py
SecurityCenter4.credential_delete
def credential_delete(self, *ids): """Delete one or more credentials. :param ids: one or more credential ids """ return self.raw_query("credential", "delete", data={ "credentials": [{"id": str(id)} for id in ids] })
python
def credential_delete(self, *ids): """Delete one or more credentials. :param ids: one or more credential ids """ return self.raw_query("credential", "delete", data={ "credentials": [{"id": str(id)} for id in ids] })
[ "def", "credential_delete", "(", "self", ",", "*", "ids", ")", ":", "return", "self", ".", "raw_query", "(", "\"credential\"", ",", "\"delete\"", ",", "data", "=", "{", "\"credentials\"", ":", "[", "{", "\"id\"", ":", "str", "(", "id", ")", "}", "for",...
Delete one or more credentials. :param ids: one or more credential ids
[ "Delete", "one", "or", "more", "credentials", "." ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/securitycenter/sc4.py#L560-L567
41,994
SteveMcGrath/pySecurityCenter
securitycenter/sc4.py
SecurityCenter4.plugins
def plugins(self, plugin_type='all', sort='id', direction='asc', size=1000, offset=0, all=True, loops=0, since=None, **filterset): """plugins Returns a list of of the plugins and their associated families. For simplicity purposes, the plugin family names will be injected into th...
python
def plugins(self, plugin_type='all', sort='id', direction='asc', size=1000, offset=0, all=True, loops=0, since=None, **filterset): """plugins Returns a list of of the plugins and their associated families. For simplicity purposes, the plugin family names will be injected into th...
[ "def", "plugins", "(", "self", ",", "plugin_type", "=", "'all'", ",", "sort", "=", "'id'", ",", "direction", "=", "'asc'", ",", "size", "=", "1000", ",", "offset", "=", "0", ",", "all", "=", "True", ",", "loops", "=", "0", ",", "since", "=", "Non...
plugins Returns a list of of the plugins and their associated families. For simplicity purposes, the plugin family names will be injected into the plugin data so that only 1 list is returned back with all of the information.
[ "plugins", "Returns", "a", "list", "of", "of", "the", "plugins", "and", "their", "associated", "families", ".", "For", "simplicity", "purposes", "the", "plugin", "family", "names", "will", "be", "injected", "into", "the", "plugin", "data", "so", "that", "onl...
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/securitycenter/sc4.py#L569-L639
41,995
SteveMcGrath/pySecurityCenter
securitycenter/sc4.py
SecurityCenter4.plugin_counts
def plugin_counts(self): """plugin_counts Returns the plugin counts as dictionary with the last updated info if its available. """ ret = { 'total': 0, } # As ususal, we need data before we can actually do anything ;) data = self.raw_query('plu...
python
def plugin_counts(self): """plugin_counts Returns the plugin counts as dictionary with the last updated info if its available. """ ret = { 'total': 0, } # As ususal, we need data before we can actually do anything ;) data = self.raw_query('plu...
[ "def", "plugin_counts", "(", "self", ")", ":", "ret", "=", "{", "'total'", ":", "0", ",", "}", "# As ususal, we need data before we can actually do anything ;)", "data", "=", "self", ".", "raw_query", "(", "'plugin'", ",", "'init'", ")", "# For backwards compatabili...
plugin_counts Returns the plugin counts as dictionary with the last updated info if its available.
[ "plugin_counts", "Returns", "the", "plugin", "counts", "as", "dictionary", "with", "the", "last", "updated", "info", "if", "its", "available", "." ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/securitycenter/sc4.py#L641-L671
41,996
SteveMcGrath/pySecurityCenter
securitycenter/sc4.py
SecurityCenter4.ip_info
def ip_info(self, ip, repository_ids=None): """ip_info Returns information about the IP specified in the repository ids defined. """ if not repository_ids: repository_ids = [] repos = [] for rid in repository_ids: repos.append({'id': rid}) ...
python
def ip_info(self, ip, repository_ids=None): """ip_info Returns information about the IP specified in the repository ids defined. """ if not repository_ids: repository_ids = [] repos = [] for rid in repository_ids: repos.append({'id': rid}) ...
[ "def", "ip_info", "(", "self", ",", "ip", ",", "repository_ids", "=", "None", ")", ":", "if", "not", "repository_ids", ":", "repository_ids", "=", "[", "]", "repos", "=", "[", "]", "for", "rid", "in", "repository_ids", ":", "repos", ".", "append", "(",...
ip_info Returns information about the IP specified in the repository ids defined.
[ "ip_info", "Returns", "information", "about", "the", "IP", "specified", "in", "the", "repository", "ids", "defined", "." ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/securitycenter/sc4.py#L717-L728
41,997
SteveMcGrath/pySecurityCenter
securitycenter/sc4.py
SecurityCenter4.scan_list
def scan_list(self, start_time=None, end_time=None, **kwargs): """List scans stored in Security Center in a given time range. Time is given in UNIX timestamps, assumed to be UTC. If a `datetime` is passed it is converted. If `end_time` is not specified it is NOW. If `start_time` is not ...
python
def scan_list(self, start_time=None, end_time=None, **kwargs): """List scans stored in Security Center in a given time range. Time is given in UNIX timestamps, assumed to be UTC. If a `datetime` is passed it is converted. If `end_time` is not specified it is NOW. If `start_time` is not ...
[ "def", "scan_list", "(", "self", ",", "start_time", "=", "None", ",", "end_time", "=", "None", ",", "*", "*", "kwargs", ")", ":", "try", ":", "end_time", "=", "datetime", ".", "utcfromtimestamp", "(", "int", "(", "end_time", ")", ")", "except", "TypeEr...
List scans stored in Security Center in a given time range. Time is given in UNIX timestamps, assumed to be UTC. If a `datetime` is passed it is converted. If `end_time` is not specified it is NOW. If `start_time` is not specified it is 30 days previous from `end_time`. :param start_ti...
[ "List", "scans", "stored", "in", "Security", "Center", "in", "a", "given", "time", "range", "." ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/securitycenter/sc4.py#L736-L769
41,998
SteveMcGrath/pySecurityCenter
securitycenter/sc4.py
SecurityCenter4.dashboard_import
def dashboard_import(self, name, fileobj): """dashboard_import Dashboard_Name, filename Uploads a dashboard template to the current user's dashboard tabs. UN-DOCUMENTED CALL: This function is not considered stable. """ data = self._upload(fileobj) return self.raw_query('...
python
def dashboard_import(self, name, fileobj): """dashboard_import Dashboard_Name, filename Uploads a dashboard template to the current user's dashboard tabs. UN-DOCUMENTED CALL: This function is not considered stable. """ data = self._upload(fileobj) return self.raw_query('...
[ "def", "dashboard_import", "(", "self", ",", "name", ",", "fileobj", ")", ":", "data", "=", "self", ".", "_upload", "(", "fileobj", ")", "return", "self", ".", "raw_query", "(", "'dashboard'", ",", "'importTab'", ",", "data", "=", "{", "'filename'", ":",...
dashboard_import Dashboard_Name, filename Uploads a dashboard template to the current user's dashboard tabs. UN-DOCUMENTED CALL: This function is not considered stable.
[ "dashboard_import", "Dashboard_Name", "filename", "Uploads", "a", "dashboard", "template", "to", "the", "current", "user", "s", "dashboard", "tabs", "." ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/securitycenter/sc4.py#L801-L811
41,999
SteveMcGrath/pySecurityCenter
securitycenter/sc4.py
SecurityCenter4.report_import
def report_import(self, name, filename): """report_import Report_Name, filename Uploads a report template to the current user's reports UN-DOCUMENTED CALL: This function is not considered stable. """ data = self._upload(filename) return self.raw_query('report', 'import',...
python
def report_import(self, name, filename): """report_import Report_Name, filename Uploads a report template to the current user's reports UN-DOCUMENTED CALL: This function is not considered stable. """ data = self._upload(filename) return self.raw_query('report', 'import',...
[ "def", "report_import", "(", "self", ",", "name", ",", "filename", ")", ":", "data", "=", "self", ".", "_upload", "(", "filename", ")", "return", "self", ".", "raw_query", "(", "'report'", ",", "'import'", ",", "data", "=", "{", "'filename'", ":", "dat...
report_import Report_Name, filename Uploads a report template to the current user's reports UN-DOCUMENTED CALL: This function is not considered stable.
[ "report_import", "Report_Name", "filename", "Uploads", "a", "report", "template", "to", "the", "current", "user", "s", "reports" ]
f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880
https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/securitycenter/sc4.py#L813-L823