repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
fchorney/rpI2C
rpI2C.py
I2C.write_block_data
def write_block_data(self, cmd, block): """ Writes a block of bytes to the bus using I2C format to the specified command register """ self.bus.write_i2c_block_data(self.address, cmd, block) self.log.debug( "write_block_data: Wrote [%s] to command register 0x%0...
python
def write_block_data(self, cmd, block): """ Writes a block of bytes to the bus using I2C format to the specified command register """ self.bus.write_i2c_block_data(self.address, cmd, block) self.log.debug( "write_block_data: Wrote [%s] to command register 0x%0...
[ "def", "write_block_data", "(", "self", ",", "cmd", ",", "block", ")", ":", "self", ".", "bus", ".", "write_i2c_block_data", "(", "self", ".", "address", ",", "cmd", ",", "block", ")", "self", ".", "log", ".", "debug", "(", "\"write_block_data: Wrote [%s] ...
Writes a block of bytes to the bus using I2C format to the specified command register
[ "Writes", "a", "block", "of", "bytes", "to", "the", "bus", "using", "I2C", "format", "to", "the", "specified", "command", "register" ]
train
https://github.com/fchorney/rpI2C/blob/7c60f82fa8c91496a74182373da0b95a13919d6e/rpI2C.py#L75-L86
fchorney/rpI2C
rpI2C.py
I2C.read_raw_byte
def read_raw_byte(self): """ Read an 8-bit byte directly from the bus """ result = self.bus.read_byte(self.address) self.log.debug("read_raw_byte: Read 0x%02X from the bus" % result) return result
python
def read_raw_byte(self): """ Read an 8-bit byte directly from the bus """ result = self.bus.read_byte(self.address) self.log.debug("read_raw_byte: Read 0x%02X from the bus" % result) return result
[ "def", "read_raw_byte", "(", "self", ")", ":", "result", "=", "self", ".", "bus", ".", "read_byte", "(", "self", ".", "address", ")", "self", ".", "log", ".", "debug", "(", "\"read_raw_byte: Read 0x%02X from the bus\"", "%", "result", ")", "return", "result"...
Read an 8-bit byte directly from the bus
[ "Read", "an", "8", "-", "bit", "byte", "directly", "from", "the", "bus" ]
train
https://github.com/fchorney/rpI2C/blob/7c60f82fa8c91496a74182373da0b95a13919d6e/rpI2C.py#L90-L96
fchorney/rpI2C
rpI2C.py
I2C.read_block_data
def read_block_data(self, cmd, length): """ Read a block of bytes from the bus from the specified command register Amount of bytes read in is defined by length """ results = self.bus.read_i2c_block_data(self.address, cmd, length) self.log.debug( "read_block_da...
python
def read_block_data(self, cmd, length): """ Read a block of bytes from the bus from the specified command register Amount of bytes read in is defined by length """ results = self.bus.read_i2c_block_data(self.address, cmd, length) self.log.debug( "read_block_da...
[ "def", "read_block_data", "(", "self", ",", "cmd", ",", "length", ")", ":", "results", "=", "self", ".", "bus", ".", "read_i2c_block_data", "(", "self", ".", "address", ",", "cmd", ",", "length", ")", "self", ".", "log", ".", "debug", "(", "\"read_bloc...
Read a block of bytes from the bus from the specified command register Amount of bytes read in is defined by length
[ "Read", "a", "block", "of", "bytes", "from", "the", "bus", "from", "the", "specified", "command", "register", "Amount", "of", "bytes", "read", "in", "is", "defined", "by", "length" ]
train
https://github.com/fchorney/rpI2C/blob/7c60f82fa8c91496a74182373da0b95a13919d6e/rpI2C.py#L98-L110
fchorney/rpI2C
rpI2C.py
I2C.read_unsigned_byte
def read_unsigned_byte(self, cmd): """ Read an unsigned byte from the specified command register """ result = self.bus.read_byte_data(self.address, cmd) self.log.debug( "read_unsigned_byte: Read 0x%02X from command register 0x%02X" % ( result, cmd ...
python
def read_unsigned_byte(self, cmd): """ Read an unsigned byte from the specified command register """ result = self.bus.read_byte_data(self.address, cmd) self.log.debug( "read_unsigned_byte: Read 0x%02X from command register 0x%02X" % ( result, cmd ...
[ "def", "read_unsigned_byte", "(", "self", ",", "cmd", ")", ":", "result", "=", "self", ".", "bus", ".", "read_byte_data", "(", "self", ".", "address", ",", "cmd", ")", "self", ".", "log", ".", "debug", "(", "\"read_unsigned_byte: Read 0x%02X from command regis...
Read an unsigned byte from the specified command register
[ "Read", "an", "unsigned", "byte", "from", "the", "specified", "command", "register" ]
train
https://github.com/fchorney/rpI2C/blob/7c60f82fa8c91496a74182373da0b95a13919d6e/rpI2C.py#L112-L122
fchorney/rpI2C
rpI2C.py
I2C.read_unsigned_word
def read_unsigned_word(self, cmd, little_endian=True): """ Read an unsigned word from the specified command register We assume the data is in little endian mode, if it is in big endian mode then set little_endian to False """ result = self.bus.read_word_data(self.address,...
python
def read_unsigned_word(self, cmd, little_endian=True): """ Read an unsigned word from the specified command register We assume the data is in little endian mode, if it is in big endian mode then set little_endian to False """ result = self.bus.read_word_data(self.address,...
[ "def", "read_unsigned_word", "(", "self", ",", "cmd", ",", "little_endian", "=", "True", ")", ":", "result", "=", "self", ".", "bus", ".", "read_word_data", "(", "self", ".", "address", ",", "cmd", ")", "if", "not", "little_endian", ":", "result", "=", ...
Read an unsigned word from the specified command register We assume the data is in little endian mode, if it is in big endian mode then set little_endian to False
[ "Read", "an", "unsigned", "word", "from", "the", "specified", "command", "register", "We", "assume", "the", "data", "is", "in", "little", "endian", "mode", "if", "it", "is", "in", "big", "endian", "mode", "then", "set", "little_endian", "to", "False" ]
train
https://github.com/fchorney/rpI2C/blob/7c60f82fa8c91496a74182373da0b95a13919d6e/rpI2C.py#L141-L157
fchorney/rpI2C
rpI2C.py
I2C.__connect_to_bus
def __connect_to_bus(self, bus): """ Attempt to connect to an I2C bus """ def connect(bus_num): try: self.log.debug("Attempting to connect to bus %s..." % bus_num) self.bus = smbus.SMBus(bus_num) self.log.debug("Success") ...
python
def __connect_to_bus(self, bus): """ Attempt to connect to an I2C bus """ def connect(bus_num): try: self.log.debug("Attempting to connect to bus %s..." % bus_num) self.bus = smbus.SMBus(bus_num) self.log.debug("Success") ...
[ "def", "__connect_to_bus", "(", "self", ",", "bus", ")", ":", "def", "connect", "(", "bus_num", ")", ":", "try", ":", "self", ".", "log", ".", "debug", "(", "\"Attempting to connect to bus %s...\"", "%", "bus_num", ")", "self", ".", "bus", "=", "smbus", ...
Attempt to connect to an I2C bus
[ "Attempt", "to", "connect", "to", "an", "I2C", "bus" ]
train
https://github.com/fchorney/rpI2C/blob/7c60f82fa8c91496a74182373da0b95a13919d6e/rpI2C.py#L181-L213
developersociety/django-glitter
glitter/reminders/admin.py
ReminderInline.get_formset
def get_formset(self, request, obj=None, **kwargs): """ Default user to the current version owner. """ data = super().get_formset(request, obj, **kwargs) if obj: data.form.base_fields['user'].initial = request.user.id return data
python
def get_formset(self, request, obj=None, **kwargs): """ Default user to the current version owner. """ data = super().get_formset(request, obj, **kwargs) if obj: data.form.base_fields['user'].initial = request.user.id return data
[ "def", "get_formset", "(", "self", ",", "request", ",", "obj", "=", "None", ",", "*", "*", "kwargs", ")", ":", "data", "=", "super", "(", ")", ".", "get_formset", "(", "request", ",", "obj", ",", "*", "*", "kwargs", ")", "if", "obj", ":", "data",...
Default user to the current version owner.
[ "Default", "user", "to", "the", "current", "version", "owner", "." ]
train
https://github.com/developersociety/django-glitter/blob/2c0280ec83afee80deee94ee3934fc54239c2e87/glitter/reminders/admin.py#L15-L20
davidblaisonneau-orange/foreman
foreman/objects.py
ForemanObjects.reload
def reload(self): """ Function reload Reload the full object to ensure sync """ realData = self.load() self.clear() self.update(realData)
python
def reload(self): """ Function reload Reload the full object to ensure sync """ realData = self.load() self.clear() self.update(realData)
[ "def", "reload", "(", "self", ")", ":", "realData", "=", "self", ".", "load", "(", ")", "self", ".", "clear", "(", ")", "self", ".", "update", "(", "realData", ")" ]
Function reload Reload the full object to ensure sync
[ "Function", "reload", "Reload", "the", "full", "object", "to", "ensure", "sync" ]
train
https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/objects.py#L61-L67
davidblaisonneau-orange/foreman
foreman/objects.py
ForemanObjects.updateAfterDecorator
def updateAfterDecorator(function): """ Function updateAfterDecorator Decorator to ensure local dict is sync with remote foreman """ def _updateAfterDecorator(self, *args, **kwargs): ret = function(self, *args, **kwargs) self.reload() return ret ...
python
def updateAfterDecorator(function): """ Function updateAfterDecorator Decorator to ensure local dict is sync with remote foreman """ def _updateAfterDecorator(self, *args, **kwargs): ret = function(self, *args, **kwargs) self.reload() return ret ...
[ "def", "updateAfterDecorator", "(", "function", ")", ":", "def", "_updateAfterDecorator", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "function", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", "self", "...
Function updateAfterDecorator Decorator to ensure local dict is sync with remote foreman
[ "Function", "updateAfterDecorator", "Decorator", "to", "ensure", "local", "dict", "is", "sync", "with", "remote", "foreman" ]
train
https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/objects.py#L70-L78
davidblaisonneau-orange/foreman
foreman/objects.py
ForemanObjects.updateBeforeDecorator
def updateBeforeDecorator(function): """ Function updateAfterDecorator Decorator to ensure local dict is sync with remote foreman """ def _updateBeforeDecorator(self, *args, **kwargs): if self.forceFullSync: self.reload() return function(self, *arg...
python
def updateBeforeDecorator(function): """ Function updateAfterDecorator Decorator to ensure local dict is sync with remote foreman """ def _updateBeforeDecorator(self, *args, **kwargs): if self.forceFullSync: self.reload() return function(self, *arg...
[ "def", "updateBeforeDecorator", "(", "function", ")", ":", "def", "_updateBeforeDecorator", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "forceFullSync", ":", "self", ".", "reload", "(", ")", "return", "function", ...
Function updateAfterDecorator Decorator to ensure local dict is sync with remote foreman
[ "Function", "updateAfterDecorator", "Decorator", "to", "ensure", "local", "dict", "is", "sync", "with", "remote", "foreman" ]
train
https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/objects.py#L80-L88
davidblaisonneau-orange/foreman
foreman/objects.py
ForemanObjects.load
def load(self): """ Function load Get the list of all objects @return RETURN: A ForemanItem list """ return {x[self.index]: self.itemType(self.api, x['id'], self.objName, self.payloadObj, x...
python
def load(self): """ Function load Get the list of all objects @return RETURN: A ForemanItem list """ return {x[self.index]: self.itemType(self.api, x['id'], self.objName, self.payloadObj, x...
[ "def", "load", "(", "self", ")", ":", "return", "{", "x", "[", "self", ".", "index", "]", ":", "self", ".", "itemType", "(", "self", ".", "api", ",", "x", "[", "'id'", "]", ",", "self", ".", "objName", ",", "self", ".", "payloadObj", ",", "x", ...
Function load Get the list of all objects @return RETURN: A ForemanItem list
[ "Function", "load", "Get", "the", "list", "of", "all", "objects" ]
train
https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/objects.py#L141-L151
davidblaisonneau-orange/foreman
foreman/objects.py
ForemanObjects.checkAndCreate
def checkAndCreate(self, key, payload): """ Function checkAndCreate Check if an object exists and create it if not @param key: The targeted object @param payload: The targeted object description @return RETURN: The id of the object """ if key not in self: ...
python
def checkAndCreate(self, key, payload): """ Function checkAndCreate Check if an object exists and create it if not @param key: The targeted object @param payload: The targeted object description @return RETURN: The id of the object """ if key not in self: ...
[ "def", "checkAndCreate", "(", "self", ",", "key", ",", "payload", ")", ":", "if", "key", "not", "in", "self", ":", "self", "[", "key", "]", "=", "payload", "return", "self", "[", "key", "]", "[", "'id'", "]" ]
Function checkAndCreate Check if an object exists and create it if not @param key: The targeted object @param payload: The targeted object description @return RETURN: The id of the object
[ "Function", "checkAndCreate", "Check", "if", "an", "object", "exists", "and", "create", "it", "if", "not" ]
train
https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/objects.py#L163-L173
qubell/contrib-python-qubell-client
qubell/api/private/__init__.py
operations
def operations(): """ Class decorator stores all calls into list. Can be used until .invalidate() is called. :return: decorated class """ def decorator(func): @wraps(func) def wrapped_func(*args, **kwargs): self = args[0] assert self.__can_use, "User oper...
python
def operations(): """ Class decorator stores all calls into list. Can be used until .invalidate() is called. :return: decorated class """ def decorator(func): @wraps(func) def wrapped_func(*args, **kwargs): self = args[0] assert self.__can_use, "User oper...
[ "def", "operations", "(", ")", ":", "def", "decorator", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapped_func", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", "=", "args", "[", "0", "]", "assert", "self", ".", ...
Class decorator stores all calls into list. Can be used until .invalidate() is called. :return: decorated class
[ "Class", "decorator", "stores", "all", "calls", "into", "list", ".", "Can", "be", "used", "until", ".", "invalidate", "()", "is", "called", ".", ":", "return", ":", "decorated", "class" ]
train
https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/private/__init__.py#L39-L76
developersociety/django-glitter
glitter/publisher/utils.py
process_actions
def process_actions(action_ids=None): """ Process actions in the publishing schedule. Returns the number of actions processed. """ actions_taken = 0 action_list = PublishAction.objects.prefetch_related( 'content_object', ).filter( scheduled_time__lte=timezone.now(), ) ...
python
def process_actions(action_ids=None): """ Process actions in the publishing schedule. Returns the number of actions processed. """ actions_taken = 0 action_list = PublishAction.objects.prefetch_related( 'content_object', ).filter( scheduled_time__lte=timezone.now(), ) ...
[ "def", "process_actions", "(", "action_ids", "=", "None", ")", ":", "actions_taken", "=", "0", "action_list", "=", "PublishAction", ".", "objects", ".", "prefetch_related", "(", "'content_object'", ",", ")", ".", "filter", "(", "scheduled_time__lte", "=", "timez...
Process actions in the publishing schedule. Returns the number of actions processed.
[ "Process", "actions", "in", "the", "publishing", "schedule", "." ]
train
https://github.com/developersociety/django-glitter/blob/2c0280ec83afee80deee94ee3934fc54239c2e87/glitter/publisher/utils.py#L7-L28
developersociety/django-glitter
glitter/publisher/utils.py
celery_enabled
def celery_enabled(): """ Return a boolean if Celery tasks are enabled for this app. If the ``GLITTER_PUBLISHER_CELERY`` setting is ``True`` or ``False`` - then that value will be used. However if the setting isn't defined, then this will be enabled automatically if Celery is installed. """ ...
python
def celery_enabled(): """ Return a boolean if Celery tasks are enabled for this app. If the ``GLITTER_PUBLISHER_CELERY`` setting is ``True`` or ``False`` - then that value will be used. However if the setting isn't defined, then this will be enabled automatically if Celery is installed. """ ...
[ "def", "celery_enabled", "(", ")", ":", "enabled", "=", "getattr", "(", "settings", ",", "'GLITTER_PUBLISHER_CELERY'", ",", "None", ")", "if", "enabled", "is", "None", ":", "try", ":", "import", "celery", "# noqa", "enabled", "=", "True", "except", "ImportEr...
Return a boolean if Celery tasks are enabled for this app. If the ``GLITTER_PUBLISHER_CELERY`` setting is ``True`` or ``False`` - then that value will be used. However if the setting isn't defined, then this will be enabled automatically if Celery is installed.
[ "Return", "a", "boolean", "if", "Celery", "tasks", "are", "enabled", "for", "this", "app", "." ]
train
https://github.com/developersociety/django-glitter/blob/2c0280ec83afee80deee94ee3934fc54239c2e87/glitter/publisher/utils.py#L31-L48
davidblaisonneau-orange/foreman
foreman/operatingsystems.py
OperatingSystems.checkAndCreate
def checkAndCreate(self, key, payload): """ Function checkAndCreate Check if an object exists and create it if not @param key: The targeted object @param payload: The targeted object description @return RETURN: The id of the object """ if key not in self: ...
python
def checkAndCreate(self, key, payload): """ Function checkAndCreate Check if an object exists and create it if not @param key: The targeted object @param payload: The targeted object description @return RETURN: The id of the object """ if key not in self: ...
[ "def", "checkAndCreate", "(", "self", ",", "key", ",", "payload", ")", ":", "if", "key", "not", "in", "self", ":", "if", "'templates'", "in", "payload", ":", "templates", "=", "payload", ".", "pop", "(", "'templates'", ")", "self", "[", "key", "]", "...
Function checkAndCreate Check if an object exists and create it if not @param key: The targeted object @param payload: The targeted object description @return RETURN: The id of the object
[ "Function", "checkAndCreate", "Check", "if", "an", "object", "exists", "and", "create", "it", "if", "not" ]
train
https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/operatingsystems.py#L51-L64
qubell/contrib-python-qubell-client
qubell/api/private/instance.py
Instance.__collect_interfaces_return
def __collect_interfaces_return(interfaces): """Collect new style (44.1+) return values to old-style kv-list""" acc = [] for (interfaceName, interfaceData) in interfaces.items(): signalValues = interfaceData.get("signals", {}) for (signalName, signalValue) in signalValues...
python
def __collect_interfaces_return(interfaces): """Collect new style (44.1+) return values to old-style kv-list""" acc = [] for (interfaceName, interfaceData) in interfaces.items(): signalValues = interfaceData.get("signals", {}) for (signalName, signalValue) in signalValues...
[ "def", "__collect_interfaces_return", "(", "interfaces", ")", ":", "acc", "=", "[", "]", "for", "(", "interfaceName", ",", "interfaceData", ")", "in", "interfaces", ".", "items", "(", ")", ":", "signalValues", "=", "interfaceData", ".", "get", "(", "\"signal...
Collect new style (44.1+) return values to old-style kv-list
[ "Collect", "new", "style", "(", "44", ".", "1", "+", ")", "return", "values", "to", "old", "-", "style", "kv", "-", "list" ]
train
https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/private/instance.py#L113-L121
qubell/contrib-python-qubell-client
qubell/api/private/instance.py
Instance.return_values
def return_values(self): """ Guess what api we are using and return as public api does. Private has {'id':'key', 'value':'keyvalue'} format, public has {'key':'keyvalue'} """ j = self.json() #TODO: FIXME: get rid of old API when its support will be removed public_api_val...
python
def return_values(self): """ Guess what api we are using and return as public api does. Private has {'id':'key', 'value':'keyvalue'} format, public has {'key':'keyvalue'} """ j = self.json() #TODO: FIXME: get rid of old API when its support will be removed public_api_val...
[ "def", "return_values", "(", "self", ")", ":", "j", "=", "self", ".", "json", "(", ")", "#TODO: FIXME: get rid of old API when its support will be removed", "public_api_value", "=", "j", ".", "get", "(", "'returnValues'", ")", "old_private_value", "=", "j", ".", "...
Guess what api we are using and return as public api does. Private has {'id':'key', 'value':'keyvalue'} format, public has {'key':'keyvalue'}
[ "Guess", "what", "api", "we", "are", "using", "and", "return", "as", "public", "api", "does", ".", "Private", "has", "{", "id", ":", "key", "value", ":", "keyvalue", "}", "format", "public", "has", "{", "key", ":", "keyvalue", "}" ]
train
https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/private/instance.py#L124-L139
qubell/contrib-python-qubell-client
qubell/api/private/instance.py
Instance.get_activitylog
def get_activitylog(self, after=None, severity=None, start=None, end=None): """ Returns activitylog object severity - filter severity ('INFO', DEBUG') start/end - time or log text """ if after: log_raw = self._router.get_instance_activitylog(org_id=self.organ...
python
def get_activitylog(self, after=None, severity=None, start=None, end=None): """ Returns activitylog object severity - filter severity ('INFO', DEBUG') start/end - time or log text """ if after: log_raw = self._router.get_instance_activitylog(org_id=self.organ...
[ "def", "get_activitylog", "(", "self", ",", "after", "=", "None", ",", "severity", "=", "None", ",", "start", "=", "None", ",", "end", "=", "None", ")", ":", "if", "after", ":", "log_raw", "=", "self", ".", "_router", ".", "get_instance_activitylog", "...
Returns activitylog object severity - filter severity ('INFO', DEBUG') start/end - time or log text
[ "Returns", "activitylog", "object", "severity", "-", "filter", "severity", "(", "INFO", "DEBUG", ")", "start", "/", "end", "-", "time", "or", "log", "text" ]
train
https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/private/instance.py#L149-L164
qubell/contrib-python-qubell-client
qubell/api/private/instance.py
Instance.json
def json(self): """ return __cached_json, if accessed withing 300 ms. This allows to optimize calls when many parameters of entity requires withing short time. """ if self.fresh(): return self.__cached_json # noinspection PyAttributeOutsideInit self._...
python
def json(self): """ return __cached_json, if accessed withing 300 ms. This allows to optimize calls when many parameters of entity requires withing short time. """ if self.fresh(): return self.__cached_json # noinspection PyAttributeOutsideInit self._...
[ "def", "json", "(", "self", ")", ":", "if", "self", ".", "fresh", "(", ")", ":", "return", "self", ".", "__cached_json", "# noinspection PyAttributeOutsideInit", "self", ".", "__last_read_time", "=", "time", ".", "time", "(", ")", "self", ".", "__cached_json...
return __cached_json, if accessed withing 300 ms. This allows to optimize calls when many parameters of entity requires withing short time.
[ "return", "__cached_json", "if", "accessed", "withing", "300", "ms", ".", "This", "allows", "to", "optimize", "calls", "when", "many", "parameters", "of", "entity", "requires", "withing", "short", "time", "." ]
train
https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/private/instance.py#L264-L276
qubell/contrib-python-qubell-client
qubell/api/private/instance.py
Instance.get_most_recent_update_time
def get_most_recent_update_time(self): """ Indicated most recent update of the instance, assumption based on: - if currentWorkflow exists, its startedAt time is most recent update. - else max of workflowHistory startedAt is most recent update. """ def parse_time(t): ...
python
def get_most_recent_update_time(self): """ Indicated most recent update of the instance, assumption based on: - if currentWorkflow exists, its startedAt time is most recent update. - else max of workflowHistory startedAt is most recent update. """ def parse_time(t): ...
[ "def", "get_most_recent_update_time", "(", "self", ")", ":", "def", "parse_time", "(", "t", ")", ":", "if", "t", ":", "return", "time", ".", "gmtime", "(", "t", "/", "1000", ")", "return", "None", "try", ":", "max_wf_started_at", "=", "max", "(", "[", ...
Indicated most recent update of the instance, assumption based on: - if currentWorkflow exists, its startedAt time is most recent update. - else max of workflowHistory startedAt is most recent update.
[ "Indicated", "most", "recent", "update", "of", "the", "instance", "assumption", "based", "on", ":", "-", "if", "currentWorkflow", "exists", "its", "startedAt", "time", "is", "most", "recent", "update", ".", "-", "else", "max", "of", "workflowHistory", "started...
train
https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/private/instance.py#L508-L522
qubell/contrib-python-qubell-client
qubell/api/private/instance.py
Instance._is_projection_updated_instance
def _is_projection_updated_instance(self): """ This method tries to guess if instance was update since last time. If return True, definitely Yes, if False, this means more unknown :return: bool """ last = self._last_workflow_started_time if not self._router.public...
python
def _is_projection_updated_instance(self): """ This method tries to guess if instance was update since last time. If return True, definitely Yes, if False, this means more unknown :return: bool """ last = self._last_workflow_started_time if not self._router.public...
[ "def", "_is_projection_updated_instance", "(", "self", ")", ":", "last", "=", "self", ".", "_last_workflow_started_time", "if", "not", "self", ".", "_router", ".", "public_api_in_use", ":", "most_recent", "=", "self", ".", "get_most_recent_update_time", "(", ")", ...
This method tries to guess if instance was update since last time. If return True, definitely Yes, if False, this means more unknown :return: bool
[ "This", "method", "tries", "to", "guess", "if", "instance", "was", "update", "since", "last", "time", ".", "If", "return", "True", "definitely", "Yes", "if", "False", "this", "means", "more", "unknown", ":", "return", ":", "bool" ]
train
https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/private/instance.py#L524-L537
qubell/contrib-python-qubell-client
qubell/api/private/instance.py
ActivityLog.find
def find(self, item, description='', event_type=''): """ Find regexp in activitylog find record as if type are in description. """ # TODO: should be refactored, dumb logic if ': ' in item: splited = item.split(': ', 1) if splited[0] in self.TYPES: ...
python
def find(self, item, description='', event_type=''): """ Find regexp in activitylog find record as if type are in description. """ # TODO: should be refactored, dumb logic if ': ' in item: splited = item.split(': ', 1) if splited[0] in self.TYPES: ...
[ "def", "find", "(", "self", ",", "item", ",", "description", "=", "''", ",", "event_type", "=", "''", ")", ":", "# TODO: should be refactored, dumb logic", "if", "': '", "in", "item", ":", "splited", "=", "item", ".", "split", "(", "': '", ",", "1", ")",...
Find regexp in activitylog find record as if type are in description.
[ "Find", "regexp", "in", "activitylog", "find", "record", "as", "if", "type", "are", "in", "description", "." ]
train
https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/private/instance.py#L621-L647
jamescooke/flake8-aaa
src/flake8_aaa/command_line.py
do_command_line
def do_command_line(infile: typing.IO[str]) -> int: """ Currently a small stub to create an instance of Checker for the passed ``infile`` and run its test functions through linting. Args: infile Returns: int: Number of flake8 errors raised. """ lines = infile.readlines() ...
python
def do_command_line(infile: typing.IO[str]) -> int: """ Currently a small stub to create an instance of Checker for the passed ``infile`` and run its test functions through linting. Args: infile Returns: int: Number of flake8 errors raised. """ lines = infile.readlines() ...
[ "def", "do_command_line", "(", "infile", ":", "typing", ".", "IO", "[", "str", "]", ")", "->", "int", ":", "lines", "=", "infile", ".", "readlines", "(", ")", "tree", "=", "ast", ".", "parse", "(", "''", ".", "join", "(", "lines", ")", ")", "chec...
Currently a small stub to create an instance of Checker for the passed ``infile`` and run its test functions through linting. Args: infile Returns: int: Number of flake8 errors raised.
[ "Currently", "a", "small", "stub", "to", "create", "an", "instance", "of", "Checker", "for", "the", "passed", "infile", "and", "run", "its", "test", "functions", "through", "linting", "." ]
train
https://github.com/jamescooke/flake8-aaa/blob/29938b96845fe32ced4358ba66af3b3be2a37794/src/flake8_aaa/command_line.py#L8-L30
aroberge/experimental
experimental/core/import_hook.py
MyMetaFinder.find_spec
def find_spec(self, fullname, path, target=None): '''finds the appropriate properties (spec) of a module, and sets its loader.''' if not path: path = [os.getcwd()] if "." in fullname: name = fullname.split(".")[-1] else: name = fullname ...
python
def find_spec(self, fullname, path, target=None): '''finds the appropriate properties (spec) of a module, and sets its loader.''' if not path: path = [os.getcwd()] if "." in fullname: name = fullname.split(".")[-1] else: name = fullname ...
[ "def", "find_spec", "(", "self", ",", "fullname", ",", "path", ",", "target", "=", "None", ")", ":", "if", "not", "path", ":", "path", "=", "[", "os", ".", "getcwd", "(", ")", "]", "if", "\".\"", "in", "fullname", ":", "name", "=", "fullname", "....
finds the appropriate properties (spec) of a module, and sets its loader.
[ "finds", "the", "appropriate", "properties", "(", "spec", ")", "of", "a", "module", "and", "sets", "its", "loader", "." ]
train
https://github.com/aroberge/experimental/blob/031a9be10698b429998436da748b8fdb86f18b47/experimental/core/import_hook.py#L47-L70
aroberge/experimental
experimental/core/import_hook.py
MyLoader.exec_module
def exec_module(self, module): '''import the source code, transforma it before executing it so that it is known to Python.''' global MAIN_MODULE_NAME if module.__name__ == MAIN_MODULE_NAME: module.__name__ = "__main__" MAIN_MODULE_NAME = None with open...
python
def exec_module(self, module): '''import the source code, transforma it before executing it so that it is known to Python.''' global MAIN_MODULE_NAME if module.__name__ == MAIN_MODULE_NAME: module.__name__ = "__main__" MAIN_MODULE_NAME = None with open...
[ "def", "exec_module", "(", "self", ",", "module", ")", ":", "global", "MAIN_MODULE_NAME", "if", "module", ".", "__name__", "==", "MAIN_MODULE_NAME", ":", "module", ".", "__name__", "=", "\"__main__\"", "MAIN_MODULE_NAME", "=", "None", "with", "open", "(", "sel...
import the source code, transforma it before executing it so that it is known to Python.
[ "import", "the", "source", "code", "transforma", "it", "before", "executing", "it", "so", "that", "it", "is", "known", "to", "Python", "." ]
train
https://github.com/aroberge/experimental/blob/031a9be10698b429998436da748b8fdb86f18b47/experimental/core/import_hook.py#L83-L103
astroduff/commah
commah/commah.py
_izip
def _izip(*iterables): """ Iterate through multiple lists or arrays of equal size """ # This izip routine is from itertools # izip('ABCD', 'xy') --> Ax By iterators = map(iter, iterables) while iterators: yield tuple(map(next, iterators))
python
def _izip(*iterables): """ Iterate through multiple lists or arrays of equal size """ # This izip routine is from itertools # izip('ABCD', 'xy') --> Ax By iterators = map(iter, iterables) while iterators: yield tuple(map(next, iterators))
[ "def", "_izip", "(", "*", "iterables", ")", ":", "# This izip routine is from itertools", "# izip('ABCD', 'xy') --> Ax By", "iterators", "=", "map", "(", "iter", ",", "iterables", ")", "while", "iterators", ":", "yield", "tuple", "(", "map", "(", "next", ",", "i...
Iterate through multiple lists or arrays of equal size
[ "Iterate", "through", "multiple", "lists", "or", "arrays", "of", "equal", "size" ]
train
https://github.com/astroduff/commah/blob/3ec70338c5123a053c79ddcf2cb3beac26bc9137/commah/commah.py#L17-L24
astroduff/commah
commah/commah.py
_checkinput
def _checkinput(zi, Mi, z=False, verbose=None): """ Check and convert any input scalar or array to numpy array """ # How many halo redshifts provided? zi = np.array(zi, ndmin=1, dtype=float) # How many halo masses provided? Mi = np.array(Mi, ndmin=1, dtype=float) # Check the input sizes for zi...
python
def _checkinput(zi, Mi, z=False, verbose=None): """ Check and convert any input scalar or array to numpy array """ # How many halo redshifts provided? zi = np.array(zi, ndmin=1, dtype=float) # How many halo masses provided? Mi = np.array(Mi, ndmin=1, dtype=float) # Check the input sizes for zi...
[ "def", "_checkinput", "(", "zi", ",", "Mi", ",", "z", "=", "False", ",", "verbose", "=", "None", ")", ":", "# How many halo redshifts provided?", "zi", "=", "np", ".", "array", "(", "zi", ",", "ndmin", "=", "1", ",", "dtype", "=", "float", ")", "# Ho...
Check and convert any input scalar or array to numpy array
[ "Check", "and", "convert", "any", "input", "scalar", "or", "array", "to", "numpy", "array" ]
train
https://github.com/astroduff/commah/blob/3ec70338c5123a053c79ddcf2cb3beac26bc9137/commah/commah.py#L27-L67
astroduff/commah
commah/commah.py
getcosmo
def getcosmo(cosmology): """ Find cosmological parameters for named cosmo in cosmology.py list """ defaultcosmologies = {'dragons': cg.DRAGONS(), 'wmap1': cg.WMAP1_Mill(), 'wmap3': cg.WMAP3_ML(), 'wmap5': cg.WMAP5_mean(), 'wmap7': cg.WMAP7_ML(), 'wmap9': cg.W...
python
def getcosmo(cosmology): """ Find cosmological parameters for named cosmo in cosmology.py list """ defaultcosmologies = {'dragons': cg.DRAGONS(), 'wmap1': cg.WMAP1_Mill(), 'wmap3': cg.WMAP3_ML(), 'wmap5': cg.WMAP5_mean(), 'wmap7': cg.WMAP7_ML(), 'wmap9': cg.W...
[ "def", "getcosmo", "(", "cosmology", ")", ":", "defaultcosmologies", "=", "{", "'dragons'", ":", "cg", ".", "DRAGONS", "(", ")", ",", "'wmap1'", ":", "cg", ".", "WMAP1_Mill", "(", ")", ",", "'wmap3'", ":", "cg", ".", "WMAP3_ML", "(", ")", ",", "'wmap...
Find cosmological parameters for named cosmo in cosmology.py list
[ "Find", "cosmological", "parameters", "for", "named", "cosmo", "in", "cosmology", ".", "py", "list" ]
train
https://github.com/astroduff/commah/blob/3ec70338c5123a053c79ddcf2cb3beac26bc9137/commah/commah.py#L70-L108
astroduff/commah
commah/commah.py
_getcosmoheader
def _getcosmoheader(cosmo): """ Output the cosmology to a string for writing to file """ cosmoheader = ("# Cosmology (flat) Om:{0:.3f}, Ol:{1:.3f}, h:{2:.2f}, " "sigma8:{3:.3f}, ns:{4:.2f}".format( cosmo['omega_M_0'], cosmo['omega_lambda_0'], cosmo['h'], ...
python
def _getcosmoheader(cosmo): """ Output the cosmology to a string for writing to file """ cosmoheader = ("# Cosmology (flat) Om:{0:.3f}, Ol:{1:.3f}, h:{2:.2f}, " "sigma8:{3:.3f}, ns:{4:.2f}".format( cosmo['omega_M_0'], cosmo['omega_lambda_0'], cosmo['h'], ...
[ "def", "_getcosmoheader", "(", "cosmo", ")", ":", "cosmoheader", "=", "(", "\"# Cosmology (flat) Om:{0:.3f}, Ol:{1:.3f}, h:{2:.2f}, \"", "\"sigma8:{3:.3f}, ns:{4:.2f}\"", ".", "format", "(", "cosmo", "[", "'omega_M_0'", "]", ",", "cosmo", "[", "'omega_lambda_0'", "]", "...
Output the cosmology to a string for writing to file
[ "Output", "the", "cosmology", "to", "a", "string", "for", "writing", "to", "file" ]
train
https://github.com/astroduff/commah/blob/3ec70338c5123a053c79ddcf2cb3beac26bc9137/commah/commah.py#L111-L119
astroduff/commah
commah/commah.py
cduffy
def cduffy(z, M, vir='200crit', relaxed=True): """ NFW conc from Duffy 08 Table 1 for halo mass and redshift""" if(vir == '200crit'): if relaxed: params = [6.71, -0.091, -0.44] else: params = [5.71, -0.084, -0.47] elif(vir == 'tophat'): if relaxed: ...
python
def cduffy(z, M, vir='200crit', relaxed=True): """ NFW conc from Duffy 08 Table 1 for halo mass and redshift""" if(vir == '200crit'): if relaxed: params = [6.71, -0.091, -0.44] else: params = [5.71, -0.084, -0.47] elif(vir == 'tophat'): if relaxed: ...
[ "def", "cduffy", "(", "z", ",", "M", ",", "vir", "=", "'200crit'", ",", "relaxed", "=", "True", ")", ":", "if", "(", "vir", "==", "'200crit'", ")", ":", "if", "relaxed", ":", "params", "=", "[", "6.71", ",", "-", "0.091", ",", "-", "0.44", "]",...
NFW conc from Duffy 08 Table 1 for halo mass and redshift
[ "NFW", "conc", "from", "Duffy", "08", "Table", "1", "for", "halo", "mass", "and", "redshift" ]
train
https://github.com/astroduff/commah/blob/3ec70338c5123a053c79ddcf2cb3beac26bc9137/commah/commah.py#L122-L144
astroduff/commah
commah/commah.py
_delta_sigma
def _delta_sigma(**cosmo): """ Perturb best-fit constant of proportionality Ascaling for rho_crit - rho_2 relation for unknown cosmology (Correa et al 2015c) Parameters ---------- cosmo : dict Dictionary of cosmological parameters, similar in format to: {'N_nu': 0,'Y_He': 0.24, ...
python
def _delta_sigma(**cosmo): """ Perturb best-fit constant of proportionality Ascaling for rho_crit - rho_2 relation for unknown cosmology (Correa et al 2015c) Parameters ---------- cosmo : dict Dictionary of cosmological parameters, similar in format to: {'N_nu': 0,'Y_He': 0.24, ...
[ "def", "_delta_sigma", "(", "*", "*", "cosmo", ")", ":", "M8_cosmo", "=", "cp", ".", "perturbation", ".", "radius_to_mass", "(", "8", ",", "*", "*", "cosmo", ")", "perturbed_A", "=", "(", "0.796", "/", "cosmo", "[", "'sigma_8'", "]", ")", "*", "(", ...
Perturb best-fit constant of proportionality Ascaling for rho_crit - rho_2 relation for unknown cosmology (Correa et al 2015c) Parameters ---------- cosmo : dict Dictionary of cosmological parameters, similar in format to: {'N_nu': 0,'Y_He': 0.24, 'h': 0.702, 'n': 0.963,'omega_M_0':...
[ "Perturb", "best", "-", "fit", "constant", "of", "proportionality", "Ascaling", "for", "rho_crit", "-", "rho_2", "relation", "for", "unknown", "cosmology", "(", "Correa", "et", "al", "2015c", ")" ]
train
https://github.com/astroduff/commah/blob/3ec70338c5123a053c79ddcf2cb3beac26bc9137/commah/commah.py#L147-L172
astroduff/commah
commah/commah.py
getAscaling
def getAscaling(cosmology, newcosmo=None): """ Returns the normalisation constant between Rho_-2 and Rho_mean(z_formation) for a given cosmology Parameters ---------- cosmology : str or dict Can be named cosmology, default WMAP7 (aka DRAGONS), or DRAGONS, WMAP1, WMAP3, WMAP5, WM...
python
def getAscaling(cosmology, newcosmo=None): """ Returns the normalisation constant between Rho_-2 and Rho_mean(z_formation) for a given cosmology Parameters ---------- cosmology : str or dict Can be named cosmology, default WMAP7 (aka DRAGONS), or DRAGONS, WMAP1, WMAP3, WMAP5, WM...
[ "def", "getAscaling", "(", "cosmology", ",", "newcosmo", "=", "None", ")", ":", "# Values from Correa 15c", "defaultcosmologies", "=", "{", "'dragons'", ":", "887", ",", "'wmap1'", ":", "853", ",", "'wmap3'", ":", "850", ",", "'wmap5'", ":", "887", ",", "'...
Returns the normalisation constant between Rho_-2 and Rho_mean(z_formation) for a given cosmology Parameters ---------- cosmology : str or dict Can be named cosmology, default WMAP7 (aka DRAGONS), or DRAGONS, WMAP1, WMAP3, WMAP5, WMAP7, WMAP9, Planck13, Planck15 or dictionar...
[ "Returns", "the", "normalisation", "constant", "between", "Rho_", "-", "2", "and", "Rho_mean", "(", "z_formation", ")", "for", "a", "given", "cosmology" ]
train
https://github.com/astroduff/commah/blob/3ec70338c5123a053c79ddcf2cb3beac26bc9137/commah/commah.py#L175-L216
astroduff/commah
commah/commah.py
_int_growth
def _int_growth(z, **cosmo): """ Returns integral of the linear growth factor from z=200 to z=z """ zmax = 200 if hasattr(z, "__len__"): for zval in z: assert(zval < zmax) else: assert(z < zmax) y, yerr = scipy.integrate.quad( lambda z: (1 + z)/(cosmo['omega_M_...
python
def _int_growth(z, **cosmo): """ Returns integral of the linear growth factor from z=200 to z=z """ zmax = 200 if hasattr(z, "__len__"): for zval in z: assert(zval < zmax) else: assert(z < zmax) y, yerr = scipy.integrate.quad( lambda z: (1 + z)/(cosmo['omega_M_...
[ "def", "_int_growth", "(", "z", ",", "*", "*", "cosmo", ")", ":", "zmax", "=", "200", "if", "hasattr", "(", "z", ",", "\"__len__\"", ")", ":", "for", "zval", "in", "z", ":", "assert", "(", "zval", "<", "zmax", ")", "else", ":", "assert", "(", "...
Returns integral of the linear growth factor from z=200 to z=z
[ "Returns", "integral", "of", "the", "linear", "growth", "factor", "from", "z", "=", "200", "to", "z", "=", "z" ]
train
https://github.com/astroduff/commah/blob/3ec70338c5123a053c79ddcf2cb3beac26bc9137/commah/commah.py#L219-L235
astroduff/commah
commah/commah.py
_deriv_growth
def _deriv_growth(z, **cosmo): """ Returns derivative of the linear growth factor at z for a given cosmology **cosmo """ inv_h = (cosmo['omega_M_0']*(1 + z)**3 + cosmo['omega_lambda_0'])**(-0.5) fz = (1 + z) * inv_h**3 deriv_g = growthfactor(z, norm=True, **cosmo)*(inv_h**2) *\ 1.5 * c...
python
def _deriv_growth(z, **cosmo): """ Returns derivative of the linear growth factor at z for a given cosmology **cosmo """ inv_h = (cosmo['omega_M_0']*(1 + z)**3 + cosmo['omega_lambda_0'])**(-0.5) fz = (1 + z) * inv_h**3 deriv_g = growthfactor(z, norm=True, **cosmo)*(inv_h**2) *\ 1.5 * c...
[ "def", "_deriv_growth", "(", "z", ",", "*", "*", "cosmo", ")", ":", "inv_h", "=", "(", "cosmo", "[", "'omega_M_0'", "]", "*", "(", "1", "+", "z", ")", "**", "3", "+", "cosmo", "[", "'omega_lambda_0'", "]", ")", "**", "(", "-", "0.5", ")", "fz",...
Returns derivative of the linear growth factor at z for a given cosmology **cosmo
[ "Returns", "derivative", "of", "the", "linear", "growth", "factor", "at", "z", "for", "a", "given", "cosmology", "**", "cosmo" ]
train
https://github.com/astroduff/commah/blob/3ec70338c5123a053c79ddcf2cb3beac26bc9137/commah/commah.py#L238-L249
astroduff/commah
commah/commah.py
growthfactor
def growthfactor(z, norm=True, **cosmo): """ Returns linear growth factor at a given redshift, normalised to z=0 by default, for a given cosmology Parameters ---------- z : float or numpy array The redshift at which the growth factor should be calculated norm : boolean, optional ...
python
def growthfactor(z, norm=True, **cosmo): """ Returns linear growth factor at a given redshift, normalised to z=0 by default, for a given cosmology Parameters ---------- z : float or numpy array The redshift at which the growth factor should be calculated norm : boolean, optional ...
[ "def", "growthfactor", "(", "z", ",", "norm", "=", "True", ",", "*", "*", "cosmo", ")", ":", "H", "=", "np", ".", "sqrt", "(", "cosmo", "[", "'omega_M_0'", "]", "*", "(", "1", "+", "z", ")", "**", "3", "+", "cosmo", "[", "'omega_lambda_0'", "]"...
Returns linear growth factor at a given redshift, normalised to z=0 by default, for a given cosmology Parameters ---------- z : float or numpy array The redshift at which the growth factor should be calculated norm : boolean, optional If true then normalise the growth factor to...
[ "Returns", "linear", "growth", "factor", "at", "a", "given", "redshift", "normalised", "to", "z", "=", "0", "by", "default", "for", "a", "given", "cosmology" ]
train
https://github.com/astroduff/commah/blob/3ec70338c5123a053c79ddcf2cb3beac26bc9137/commah/commah.py#L252-L284
astroduff/commah
commah/commah.py
_minimize_c
def _minimize_c(c, z=0, a_tilde=1, b_tilde=-1, Ascaling=900, omega_M_0=0.25, omega_lambda_0=0.75): """ Trial function to solve 2 eqns (17 and 18) from Correa et al. (2015c) for 1 unknown, i.e. concentration, returned by a minimisation call """ # Fn 1 (LHS of Eqn 18) Y1 = np.log(2) ...
python
def _minimize_c(c, z=0, a_tilde=1, b_tilde=-1, Ascaling=900, omega_M_0=0.25, omega_lambda_0=0.75): """ Trial function to solve 2 eqns (17 and 18) from Correa et al. (2015c) for 1 unknown, i.e. concentration, returned by a minimisation call """ # Fn 1 (LHS of Eqn 18) Y1 = np.log(2) ...
[ "def", "_minimize_c", "(", "c", ",", "z", "=", "0", ",", "a_tilde", "=", "1", ",", "b_tilde", "=", "-", "1", ",", "Ascaling", "=", "900", ",", "omega_M_0", "=", "0.25", ",", "omega_lambda_0", "=", "0.75", ")", ":", "# Fn 1 (LHS of Eqn 18)", "Y1", "="...
Trial function to solve 2 eqns (17 and 18) from Correa et al. (2015c) for 1 unknown, i.e. concentration, returned by a minimisation call
[ "Trial", "function", "to", "solve", "2", "eqns", "(", "17", "and", "18", ")", "from", "Correa", "et", "al", ".", "(", "2015c", ")", "for", "1", "unknown", "i", ".", "e", ".", "concentration", "returned", "by", "a", "minimisation", "call" ]
train
https://github.com/astroduff/commah/blob/3ec70338c5123a053c79ddcf2cb3beac26bc9137/commah/commah.py#L287-L312
astroduff/commah
commah/commah.py
formationz
def formationz(c, z, Ascaling=900, omega_M_0=0.25, omega_lambda_0=0.75): """ Rearrange eqn 18 from Correa et al (2015c) to return formation redshift for a concentration at a given redshift Parameters ---------- c : float / numpy array Concentration of halo z : float / numpy array ...
python
def formationz(c, z, Ascaling=900, omega_M_0=0.25, omega_lambda_0=0.75): """ Rearrange eqn 18 from Correa et al (2015c) to return formation redshift for a concentration at a given redshift Parameters ---------- c : float / numpy array Concentration of halo z : float / numpy array ...
[ "def", "formationz", "(", "c", ",", "z", ",", "Ascaling", "=", "900", ",", "omega_M_0", "=", "0.25", ",", "omega_lambda_0", "=", "0.75", ")", ":", "Y1", "=", "np", ".", "log", "(", "2", ")", "-", "0.5", "Yc", "=", "np", ".", "log", "(", "1", ...
Rearrange eqn 18 from Correa et al (2015c) to return formation redshift for a concentration at a given redshift Parameters ---------- c : float / numpy array Concentration of halo z : float / numpy array Redshift of halo with concentration c Ascaling : float Cosmolog...
[ "Rearrange", "eqn", "18", "from", "Correa", "et", "al", "(", "2015c", ")", "to", "return", "formation", "redshift", "for", "a", "concentration", "at", "a", "given", "redshift" ]
train
https://github.com/astroduff/commah/blob/3ec70338c5123a053c79ddcf2cb3beac26bc9137/commah/commah.py#L315-L346
astroduff/commah
commah/commah.py
calc_ab
def calc_ab(zi, Mi, **cosmo): """ Calculate growth rate indices a_tilde and b_tilde Parameters ---------- zi : float Redshift Mi : float Halo mass at redshift 'zi' cosmo : dict Dictionary of cosmological parameters, similar in format to: {'N_nu': 0,'Y_He': 0.24, ...
python
def calc_ab(zi, Mi, **cosmo): """ Calculate growth rate indices a_tilde and b_tilde Parameters ---------- zi : float Redshift Mi : float Halo mass at redshift 'zi' cosmo : dict Dictionary of cosmological parameters, similar in format to: {'N_nu': 0,'Y_He': 0.24, ...
[ "def", "calc_ab", "(", "zi", ",", "Mi", ",", "*", "*", "cosmo", ")", ":", "# When zi = 0, the a_tilde becomes alpha and b_tilde becomes beta", "# Eqn 23 of Correa et al 2015a (analytically solve from Eqn 16 and 17)", "# Arbitray formation redshift, z_-2 in COM is more physically motivate...
Calculate growth rate indices a_tilde and b_tilde Parameters ---------- zi : float Redshift Mi : float Halo mass at redshift 'zi' cosmo : dict Dictionary of cosmological parameters, similar in format to: {'N_nu': 0,'Y_He': 0.24, 'h': 0.702, 'n': 0.963,'omega_M_0': 0....
[ "Calculate", "growth", "rate", "indices", "a_tilde", "and", "b_tilde" ]
train
https://github.com/astroduff/commah/blob/3ec70338c5123a053c79ddcf2cb3beac26bc9137/commah/commah.py#L349-L397
astroduff/commah
commah/commah.py
acc_rate
def acc_rate(z, zi, Mi, **cosmo): """ Calculate accretion rate and mass history of a halo at any redshift 'z' with mass 'Mi' at a lower redshift 'z' Parameters ---------- z : float Redshift to solve acc_rate / mass history. Note zi<z zi : float Redshift Mi : float ...
python
def acc_rate(z, zi, Mi, **cosmo): """ Calculate accretion rate and mass history of a halo at any redshift 'z' with mass 'Mi' at a lower redshift 'z' Parameters ---------- z : float Redshift to solve acc_rate / mass history. Note zi<z zi : float Redshift Mi : float ...
[ "def", "acc_rate", "(", "z", ",", "zi", ",", "Mi", ",", "*", "*", "cosmo", ")", ":", "# Find parameters a_tilde and b_tilde for initial redshift", "# use Eqn 9 and 10 of Correa et al. (2015c)", "a_tilde", ",", "b_tilde", "=", "calc_ab", "(", "zi", ",", "Mi", ",", ...
Calculate accretion rate and mass history of a halo at any redshift 'z' with mass 'Mi' at a lower redshift 'z' Parameters ---------- z : float Redshift to solve acc_rate / mass history. Note zi<z zi : float Redshift Mi : float Halo mass at redshift 'zi' cosmo : d...
[ "Calculate", "accretion", "rate", "and", "mass", "history", "of", "a", "halo", "at", "any", "redshift", "z", "with", "mass", "Mi", "at", "a", "lower", "redshift", "z" ]
train
https://github.com/astroduff/commah/blob/3ec70338c5123a053c79ddcf2cb3beac26bc9137/commah/commah.py#L400-L438
astroduff/commah
commah/commah.py
MAH
def MAH(z, zi, Mi, **cosmo): """ Calculate mass accretion history by looping function acc_rate over redshift steps 'z' for halo of mass 'Mi' at redshift 'zi' Parameters ---------- z : float / numpy array Redshift to output MAH over. Note zi<z always zi : float Redshift M...
python
def MAH(z, zi, Mi, **cosmo): """ Calculate mass accretion history by looping function acc_rate over redshift steps 'z' for halo of mass 'Mi' at redshift 'zi' Parameters ---------- z : float / numpy array Redshift to output MAH over. Note zi<z always zi : float Redshift M...
[ "def", "MAH", "(", "z", ",", "zi", ",", "Mi", ",", "*", "*", "cosmo", ")", ":", "# Ensure that z is a 1D NumPy array", "z", "=", "np", ".", "array", "(", "z", ",", "ndmin", "=", "1", ",", "dtype", "=", "float", ")", "# Create a full array", "dMdt_array...
Calculate mass accretion history by looping function acc_rate over redshift steps 'z' for halo of mass 'Mi' at redshift 'zi' Parameters ---------- z : float / numpy array Redshift to output MAH over. Note zi<z always zi : float Redshift Mi : float Halo mass at redshi...
[ "Calculate", "mass", "accretion", "history", "by", "looping", "function", "acc_rate", "over", "redshift", "steps", "z", "for", "halo", "of", "mass", "Mi", "at", "redshift", "zi" ]
train
https://github.com/astroduff/commah/blob/3ec70338c5123a053c79ddcf2cb3beac26bc9137/commah/commah.py#L441-L480
astroduff/commah
commah/commah.py
COM
def COM(z, M, **cosmo): """ Calculate concentration for halo of mass 'M' at redshift 'z' Parameters ---------- z : float / numpy array Redshift to find concentration of halo M : float / numpy array Halo mass at redshift 'z'. Must be same size as 'z' cosmo : dict Dictiona...
python
def COM(z, M, **cosmo): """ Calculate concentration for halo of mass 'M' at redshift 'z' Parameters ---------- z : float / numpy array Redshift to find concentration of halo M : float / numpy array Halo mass at redshift 'z'. Must be same size as 'z' cosmo : dict Dictiona...
[ "def", "COM", "(", "z", ",", "M", ",", "*", "*", "cosmo", ")", ":", "# Check that z and M are arrays", "z", "=", "np", ".", "array", "(", "z", ",", "ndmin", "=", "1", ",", "dtype", "=", "float", ")", "M", "=", "np", ".", "array", "(", "M", ",",...
Calculate concentration for halo of mass 'M' at redshift 'z' Parameters ---------- z : float / numpy array Redshift to find concentration of halo M : float / numpy array Halo mass at redshift 'z'. Must be same size as 'z' cosmo : dict Dictionary of cosmological parameters, s...
[ "Calculate", "concentration", "for", "halo", "of", "mass", "M", "at", "redshift", "z" ]
train
https://github.com/astroduff/commah/blob/3ec70338c5123a053c79ddcf2cb3beac26bc9137/commah/commah.py#L483-L552
astroduff/commah
commah/commah.py
run
def run(cosmology, zi=0, Mi=1e12, z=False, com=True, mah=True, filename=None, verbose=None, retcosmo=None): """ Run commah code on halo of mass 'Mi' at redshift 'zi' with accretion and profile history at higher redshifts 'z' This is based on Correa et al. (2015a,b,c) Parameters ----...
python
def run(cosmology, zi=0, Mi=1e12, z=False, com=True, mah=True, filename=None, verbose=None, retcosmo=None): """ Run commah code on halo of mass 'Mi' at redshift 'zi' with accretion and profile history at higher redshifts 'z' This is based on Correa et al. (2015a,b,c) Parameters ----...
[ "def", "run", "(", "cosmology", ",", "zi", "=", "0", ",", "Mi", "=", "1e12", ",", "z", "=", "False", ",", "com", "=", "True", ",", "mah", "=", "True", ",", "filename", "=", "None", ",", "verbose", "=", "None", ",", "retcosmo", "=", "None", ")",...
Run commah code on halo of mass 'Mi' at redshift 'zi' with accretion and profile history at higher redshifts 'z' This is based on Correa et al. (2015a,b,c) Parameters ---------- cosmology : str or dict Can be named cosmology, default WMAP7 (aka DRAGONS), or DRAGONS, WMAP1, W...
[ "Run", "commah", "code", "on", "halo", "of", "mass", "Mi", "at", "redshift", "zi", "with", "accretion", "and", "profile", "history", "at", "higher", "redshifts", "z", "This", "is", "based", "on", "Correa", "et", "al", ".", "(", "2015a", "b", "c", ")" ]
train
https://github.com/astroduff/commah/blob/3ec70338c5123a053c79ddcf2cb3beac26bc9137/commah/commah.py#L555-L799
MatterMiners/cobald
cobald/daemon/core/config.py
load
def load(config_path: str): """ Load a configuration and keep it alive for the given context :param config_path: path to a configuration file """ # we bind the config to _ to keep it alive if os.path.splitext(config_path)[1] in ('.yaml', '.yml'): _ = load_yaml_configuration(config_path,...
python
def load(config_path: str): """ Load a configuration and keep it alive for the given context :param config_path: path to a configuration file """ # we bind the config to _ to keep it alive if os.path.splitext(config_path)[1] in ('.yaml', '.yml'): _ = load_yaml_configuration(config_path,...
[ "def", "load", "(", "config_path", ":", "str", ")", ":", "# we bind the config to _ to keep it alive", "if", "os", ".", "path", ".", "splitext", "(", "config_path", ")", "[", "1", "]", "in", "(", "'.yaml'", ",", "'.yml'", ")", ":", "_", "=", "load_yaml_con...
Load a configuration and keep it alive for the given context :param config_path: path to a configuration file
[ "Load", "a", "configuration", "and", "keep", "it", "alive", "for", "the", "given", "context" ]
train
https://github.com/MatterMiners/cobald/blob/264138de4382d1c9b53fabcbc6660e10b33a914d/cobald/daemon/core/config.py#L10-L23
aroberge/experimental
experimental/transformers/repeat_keyword.py
transform_source
def transform_source(text): '''Replaces instances of repeat n: by for __VAR_i in range(n): where __VAR_i is a string that does not appear elsewhere in the code sample. ''' loop_keyword = 'repeat' nb = text.count(loop_keyword) if nb == 0: return text var_...
python
def transform_source(text): '''Replaces instances of repeat n: by for __VAR_i in range(n): where __VAR_i is a string that does not appear elsewhere in the code sample. ''' loop_keyword = 'repeat' nb = text.count(loop_keyword) if nb == 0: return text var_...
[ "def", "transform_source", "(", "text", ")", ":", "loop_keyword", "=", "'repeat'", "nb", "=", "text", ".", "count", "(", "loop_keyword", ")", "if", "nb", "==", "0", ":", "return", "text", "var_names", "=", "get_unique_variable_names", "(", "text", ",", "nb...
Replaces instances of repeat n: by for __VAR_i in range(n): where __VAR_i is a string that does not appear elsewhere in the code sample.
[ "Replaces", "instances", "of" ]
train
https://github.com/aroberge/experimental/blob/031a9be10698b429998436da748b8fdb86f18b47/experimental/transformers/repeat_keyword.py#L29-L70
aroberge/experimental
experimental/transformers/repeat_keyword.py
get_unique_variable_names
def get_unique_variable_names(text, nb): '''returns a list of possible variables names that are not found in the original text.''' base_name = '__VAR_' var_names = [] i = 0 j = 0 while j < nb: tentative_name = base_name + str(i) if text.count(tentative_name) == 0 and tenta...
python
def get_unique_variable_names(text, nb): '''returns a list of possible variables names that are not found in the original text.''' base_name = '__VAR_' var_names = [] i = 0 j = 0 while j < nb: tentative_name = base_name + str(i) if text.count(tentative_name) == 0 and tenta...
[ "def", "get_unique_variable_names", "(", "text", ",", "nb", ")", ":", "base_name", "=", "'__VAR_'", "var_names", "=", "[", "]", "i", "=", "0", "j", "=", "0", "while", "j", "<", "nb", ":", "tentative_name", "=", "base_name", "+", "str", "(", "i", ")",...
returns a list of possible variables names that are not found in the original text.
[ "returns", "a", "list", "of", "possible", "variables", "names", "that", "are", "not", "found", "in", "the", "original", "text", "." ]
train
https://github.com/aroberge/experimental/blob/031a9be10698b429998436da748b8fdb86f18b47/experimental/transformers/repeat_keyword.py#L75-L89
quantmind/agile-toolkit
agiletoolkit/api/releases.py
Releases.tag
def tag(self, tag): """Get a release by tag """ url = '%s/tags/%s' % (self, tag) response = self.http.get(url, auth=self.auth) response.raise_for_status() return response.json()
python
def tag(self, tag): """Get a release by tag """ url = '%s/tags/%s' % (self, tag) response = self.http.get(url, auth=self.auth) response.raise_for_status() return response.json()
[ "def", "tag", "(", "self", ",", "tag", ")", ":", "url", "=", "'%s/tags/%s'", "%", "(", "self", ",", "tag", ")", "response", "=", "self", ".", "http", ".", "get", "(", "url", ",", "auth", "=", "self", ".", "auth", ")", "response", ".", "raise_for_...
Get a release by tag
[ "Get", "a", "release", "by", "tag" ]
train
https://github.com/quantmind/agile-toolkit/blob/96028e36a842c57b171907c20583a60d1045fec1/agiletoolkit/api/releases.py#L37-L43
quantmind/agile-toolkit
agiletoolkit/api/releases.py
Releases.release_assets
def release_assets(self, release): """Assets for a given release """ release = self.as_id(release) return self.get_list(url='%s/%s/assets' % (self, release))
python
def release_assets(self, release): """Assets for a given release """ release = self.as_id(release) return self.get_list(url='%s/%s/assets' % (self, release))
[ "def", "release_assets", "(", "self", ",", "release", ")", ":", "release", "=", "self", ".", "as_id", "(", "release", ")", "return", "self", ".", "get_list", "(", "url", "=", "'%s/%s/assets'", "%", "(", "self", ",", "release", ")", ")" ]
Assets for a given release
[ "Assets", "for", "a", "given", "release" ]
train
https://github.com/quantmind/agile-toolkit/blob/96028e36a842c57b171907c20583a60d1045fec1/agiletoolkit/api/releases.py#L53-L57
quantmind/agile-toolkit
agiletoolkit/api/releases.py
Releases.upload
def upload(self, release, filename, content_type=None): """Upload a file to a release :param filename: filename to upload :param content_type: optional content type :return: json object from github """ release = self.as_id(release) name = os.path.basename(filenam...
python
def upload(self, release, filename, content_type=None): """Upload a file to a release :param filename: filename to upload :param content_type: optional content type :return: json object from github """ release = self.as_id(release) name = os.path.basename(filenam...
[ "def", "upload", "(", "self", ",", "release", ",", "filename", ",", "content_type", "=", "None", ")", ":", "release", "=", "self", ".", "as_id", "(", "release", ")", "name", "=", "os", ".", "path", ".", "basename", "(", "filename", ")", "if", "not", ...
Upload a file to a release :param filename: filename to upload :param content_type: optional content type :return: json object from github
[ "Upload", "a", "file", "to", "a", "release" ]
train
https://github.com/quantmind/agile-toolkit/blob/96028e36a842c57b171907c20583a60d1045fec1/agiletoolkit/api/releases.py#L59-L84
quantmind/agile-toolkit
agiletoolkit/api/releases.py
Releases.validate_tag
def validate_tag(self, tag_name, prefix=None): """Validate ``tag_name`` with the latest tag from github If ``tag_name`` is a valid candidate, return the latest tag from github """ new_version = semantic_version(tag_name) current = self.latest() if current: ta...
python
def validate_tag(self, tag_name, prefix=None): """Validate ``tag_name`` with the latest tag from github If ``tag_name`` is a valid candidate, return the latest tag from github """ new_version = semantic_version(tag_name) current = self.latest() if current: ta...
[ "def", "validate_tag", "(", "self", ",", "tag_name", ",", "prefix", "=", "None", ")", ":", "new_version", "=", "semantic_version", "(", "tag_name", ")", "current", "=", "self", ".", "latest", "(", ")", "if", "current", ":", "tag_name", "=", "current", "[...
Validate ``tag_name`` with the latest tag from github If ``tag_name`` is a valid candidate, return the latest tag from github
[ "Validate", "tag_name", "with", "the", "latest", "tag", "from", "github" ]
train
https://github.com/quantmind/agile-toolkit/blob/96028e36a842c57b171907c20583a60d1045fec1/agiletoolkit/api/releases.py#L86-L111
teaearlgraycold/puni
puni/base.py
Note.full_url
def full_url(self): """Return the full reddit URL associated with the usernote. Arguments: subreddit: the subreddit name for the note (PRAW Subreddit object) """ if self.link == '': return None else: return Note._expand_url(self.link, self.sub...
python
def full_url(self): """Return the full reddit URL associated with the usernote. Arguments: subreddit: the subreddit name for the note (PRAW Subreddit object) """ if self.link == '': return None else: return Note._expand_url(self.link, self.sub...
[ "def", "full_url", "(", "self", ")", ":", "if", "self", ".", "link", "==", "''", ":", "return", "None", "else", ":", "return", "Note", ".", "_expand_url", "(", "self", ".", "link", ",", "self", ".", "subreddit", ")" ]
Return the full reddit URL associated with the usernote. Arguments: subreddit: the subreddit name for the note (PRAW Subreddit object)
[ "Return", "the", "full", "reddit", "URL", "associated", "with", "the", "usernote", "." ]
train
https://github.com/teaearlgraycold/puni/blob/f6d0bfde99942b29a6f91273e48abcd2d7a94c93/puni/base.py#L87-L96
teaearlgraycold/puni
puni/base.py
Note._compress_url
def _compress_url(link): """Convert a reddit URL into the short-hand used by usernotes. Arguments: link: a link to a comment, submission, or message (str) Returns a String of the shorthand URL """ comment_re = re.compile(r'/comments/([A-Za-z\d]{2,})(?:/[^\s]+/([A-Za...
python
def _compress_url(link): """Convert a reddit URL into the short-hand used by usernotes. Arguments: link: a link to a comment, submission, or message (str) Returns a String of the shorthand URL """ comment_re = re.compile(r'/comments/([A-Za-z\d]{2,})(?:/[^\s]+/([A-Za...
[ "def", "_compress_url", "(", "link", ")", ":", "comment_re", "=", "re", ".", "compile", "(", "r'/comments/([A-Za-z\\d]{2,})(?:/[^\\s]+/([A-Za-z\\d]+))?'", ")", "message_re", "=", "re", ".", "compile", "(", "r'/message/messages/([A-Za-z\\d]+)'", ")", "matches", "=", "r...
Convert a reddit URL into the short-hand used by usernotes. Arguments: link: a link to a comment, submission, or message (str) Returns a String of the shorthand URL
[ "Convert", "a", "reddit", "URL", "into", "the", "short", "-", "hand", "used", "by", "usernotes", "." ]
train
https://github.com/teaearlgraycold/puni/blob/f6d0bfde99942b29a6f91273e48abcd2d7a94c93/puni/base.py#L99-L122
teaearlgraycold/puni
puni/base.py
Note._expand_url
def _expand_url(short_link, subreddit=None): """Convert a usernote's URL short-hand into a full reddit URL. Arguments: subreddit: the subreddit the URL is for (PRAW Subreddit object or str) short_link: the compressed link from a usernote (str) Returns a String of the fu...
python
def _expand_url(short_link, subreddit=None): """Convert a usernote's URL short-hand into a full reddit URL. Arguments: subreddit: the subreddit the URL is for (PRAW Subreddit object or str) short_link: the compressed link from a usernote (str) Returns a String of the fu...
[ "def", "_expand_url", "(", "short_link", ",", "subreddit", "=", "None", ")", ":", "# Some URL structures for notes", "message_scheme", "=", "'https://reddit.com/message/messages/{}'", "comment_scheme", "=", "'https://reddit.com/r/{}/comments/{}/-/{}'", "post_scheme", "=", "'htt...
Convert a usernote's URL short-hand into a full reddit URL. Arguments: subreddit: the subreddit the URL is for (PRAW Subreddit object or str) short_link: the compressed link from a usernote (str) Returns a String of the full URL.
[ "Convert", "a", "usernote", "s", "URL", "short", "-", "hand", "into", "a", "full", "reddit", "URL", "." ]
train
https://github.com/teaearlgraycold/puni/blob/f6d0bfde99942b29a6f91273e48abcd2d7a94c93/puni/base.py#L125-L154
teaearlgraycold/puni
puni/base.py
UserNotes.get_json
def get_json(self): """Get the JSON stored on the usernotes wiki page. Returns a dict representation of the usernotes (with the notes BLOB decoded). Raises: RuntimeError if the usernotes version is incompatible with this version of puni. """ ...
python
def get_json(self): """Get the JSON stored on the usernotes wiki page. Returns a dict representation of the usernotes (with the notes BLOB decoded). Raises: RuntimeError if the usernotes version is incompatible with this version of puni. """ ...
[ "def", "get_json", "(", "self", ")", ":", "try", ":", "usernotes", "=", "self", ".", "subreddit", ".", "wiki", "[", "self", ".", "page_name", "]", ".", "content_md", "notes", "=", "json", ".", "loads", "(", "usernotes", ")", "except", "NotFound", ":", ...
Get the JSON stored on the usernotes wiki page. Returns a dict representation of the usernotes (with the notes BLOB decoded). Raises: RuntimeError if the usernotes version is incompatible with this version of puni.
[ "Get", "the", "JSON", "stored", "on", "the", "usernotes", "wiki", "page", "." ]
train
https://github.com/teaearlgraycold/puni/blob/f6d0bfde99942b29a6f91273e48abcd2d7a94c93/puni/base.py#L186-L210
teaearlgraycold/puni
puni/base.py
UserNotes._init_notes
def _init_notes(self): """Set up the UserNotes page with the initial JSON schema.""" self.cached_json = { 'ver': self.schema, 'users': {}, 'constants': { 'users': [x.name for x in self.subreddit.moderator()], 'warnings': Note.warnings ...
python
def _init_notes(self): """Set up the UserNotes page with the initial JSON schema.""" self.cached_json = { 'ver': self.schema, 'users': {}, 'constants': { 'users': [x.name for x in self.subreddit.moderator()], 'warnings': Note.warnings ...
[ "def", "_init_notes", "(", "self", ")", ":", "self", ".", "cached_json", "=", "{", "'ver'", ":", "self", ".", "schema", ",", "'users'", ":", "{", "}", ",", "'constants'", ":", "{", "'users'", ":", "[", "x", ".", "name", "for", "x", "in", "self", ...
Set up the UserNotes page with the initial JSON schema.
[ "Set", "up", "the", "UserNotes", "page", "with", "the", "initial", "JSON", "schema", "." ]
train
https://github.com/teaearlgraycold/puni/blob/f6d0bfde99942b29a6f91273e48abcd2d7a94c93/puni/base.py#L212-L223
teaearlgraycold/puni
puni/base.py
UserNotes.set_json
def set_json(self, reason='', new_page=False): """Send the JSON from the cache to the usernotes wiki page. Arguments: reason: the change reason that will be posted to the wiki changelog (str) Raises: OverflowError if the new JSON data is greater than max_...
python
def set_json(self, reason='', new_page=False): """Send the JSON from the cache to the usernotes wiki page. Arguments: reason: the change reason that will be posted to the wiki changelog (str) Raises: OverflowError if the new JSON data is greater than max_...
[ "def", "set_json", "(", "self", ",", "reason", "=", "''", ",", "new_page", "=", "False", ")", ":", "compressed_json", "=", "json", ".", "dumps", "(", "self", ".", "_compress_json", "(", "self", ".", "cached_json", ")", ")", "if", "len", "(", "compresse...
Send the JSON from the cache to the usernotes wiki page. Arguments: reason: the change reason that will be posted to the wiki changelog (str) Raises: OverflowError if the new JSON data is greater than max_page_size
[ "Send", "the", "JSON", "from", "the", "cache", "to", "the", "usernotes", "wiki", "page", "." ]
train
https://github.com/teaearlgraycold/puni/blob/f6d0bfde99942b29a6f91273e48abcd2d7a94c93/puni/base.py#L225-L254
teaearlgraycold/puni
puni/base.py
UserNotes.get_notes
def get_notes(self, user): """Return a list of Note objects for the given user. Return an empty list if no notes are found. Arguments: user: the user to search for in the usernotes (str) """ # Try to search for all notes on a user, return an empty list if none ...
python
def get_notes(self, user): """Return a list of Note objects for the given user. Return an empty list if no notes are found. Arguments: user: the user to search for in the usernotes (str) """ # Try to search for all notes on a user, return an empty list if none ...
[ "def", "get_notes", "(", "self", ",", "user", ")", ":", "# Try to search for all notes on a user, return an empty list if none", "# are found.", "try", ":", "users_notes", "=", "[", "]", "for", "note", "in", "self", ".", "cached_json", "[", "'users'", "]", "[", "u...
Return a list of Note objects for the given user. Return an empty list if no notes are found. Arguments: user: the user to search for in the usernotes (str)
[ "Return", "a", "list", "of", "Note", "objects", "for", "the", "given", "user", "." ]
train
https://github.com/teaearlgraycold/puni/blob/f6d0bfde99942b29a6f91273e48abcd2d7a94c93/puni/base.py#L257-L284
teaearlgraycold/puni
puni/base.py
UserNotes._expand_json
def _expand_json(self, j): """Decompress the BLOB portion of the usernotes. Arguments: j: the JSON returned from the wiki page (dict) Returns a Dict with the 'blob' key removed and a 'users' key added """ decompressed_json = copy.copy(j) decompressed_json.po...
python
def _expand_json(self, j): """Decompress the BLOB portion of the usernotes. Arguments: j: the JSON returned from the wiki page (dict) Returns a Dict with the 'blob' key removed and a 'users' key added """ decompressed_json = copy.copy(j) decompressed_json.po...
[ "def", "_expand_json", "(", "self", ",", "j", ")", ":", "decompressed_json", "=", "copy", ".", "copy", "(", "j", ")", "decompressed_json", ".", "pop", "(", "'blob'", ",", "None", ")", "# Remove BLOB portion of JSON", "# Decode and decompress JSON", "compressed_dat...
Decompress the BLOB portion of the usernotes. Arguments: j: the JSON returned from the wiki page (dict) Returns a Dict with the 'blob' key removed and a 'users' key added
[ "Decompress", "the", "BLOB", "portion", "of", "the", "usernotes", "." ]
train
https://github.com/teaearlgraycold/puni/blob/f6d0bfde99942b29a6f91273e48abcd2d7a94c93/puni/base.py#L307-L324
teaearlgraycold/puni
puni/base.py
UserNotes._compress_json
def _compress_json(self, j): """Compress the BLOB data portion of the usernotes. Arguments: j: the JSON in Schema v5 format (dict) Returns a dict with the 'users' key removed and 'blob' key added """ compressed_json = copy.copy(j) compressed_json.pop('users'...
python
def _compress_json(self, j): """Compress the BLOB data portion of the usernotes. Arguments: j: the JSON in Schema v5 format (dict) Returns a dict with the 'users' key removed and 'blob' key added """ compressed_json = copy.copy(j) compressed_json.pop('users'...
[ "def", "_compress_json", "(", "self", ",", "j", ")", ":", "compressed_json", "=", "copy", ".", "copy", "(", "j", ")", "compressed_json", ".", "pop", "(", "'users'", ",", "None", ")", "compressed_data", "=", "zlib", ".", "compress", "(", "json", ".", "d...
Compress the BLOB data portion of the usernotes. Arguments: j: the JSON in Schema v5 format (dict) Returns a dict with the 'users' key removed and 'blob' key added
[ "Compress", "the", "BLOB", "data", "portion", "of", "the", "usernotes", "." ]
train
https://github.com/teaearlgraycold/puni/blob/f6d0bfde99942b29a6f91273e48abcd2d7a94c93/puni/base.py#L326-L345
teaearlgraycold/puni
puni/base.py
UserNotes.add_note
def add_note(self, note): """Add a note to the usernotes wiki page. Arguments: note: the note to be added (Note) Returns the update message for the usernotes wiki Raises: ValueError when the warning type of the note can not be found in the store...
python
def add_note(self, note): """Add a note to the usernotes wiki page. Arguments: note: the note to be added (Note) Returns the update message for the usernotes wiki Raises: ValueError when the warning type of the note can not be found in the store...
[ "def", "add_note", "(", "self", ",", "note", ")", ":", "notes", "=", "self", ".", "cached_json", "if", "not", "note", ".", "moderator", ":", "note", ".", "moderator", "=", "self", ".", "r", ".", "user", ".", "me", "(", ")", ".", "name", "# Get inde...
Add a note to the usernotes wiki page. Arguments: note: the note to be added (Note) Returns the update message for the usernotes wiki Raises: ValueError when the warning type of the note can not be found in the stored list of warnings.
[ "Add", "a", "note", "to", "the", "usernotes", "wiki", "page", "." ]
train
https://github.com/teaearlgraycold/puni/blob/f6d0bfde99942b29a6f91273e48abcd2d7a94c93/puni/base.py#L348-L397
teaearlgraycold/puni
puni/base.py
UserNotes.remove_note
def remove_note(self, username, index): """Remove a single usernote from the usernotes. Arguments: username: the user that for whom you're removing a note (str) index: the index of the note which is to be removed (int) Returns the update message for the usernotes wiki ...
python
def remove_note(self, username, index): """Remove a single usernote from the usernotes. Arguments: username: the user that for whom you're removing a note (str) index: the index of the note which is to be removed (int) Returns the update message for the usernotes wiki ...
[ "def", "remove_note", "(", "self", ",", "username", ",", "index", ")", ":", "self", ".", "cached_json", "[", "'users'", "]", "[", "username", "]", "[", "'ns'", "]", ".", "pop", "(", "index", ")", "# Go ahead and remove the user's entry if they have no more notes...
Remove a single usernote from the usernotes. Arguments: username: the user that for whom you're removing a note (str) index: the index of the note which is to be removed (int) Returns the update message for the usernotes wiki
[ "Remove", "a", "single", "usernote", "from", "the", "usernotes", "." ]
train
https://github.com/teaearlgraycold/puni/blob/f6d0bfde99942b29a6f91273e48abcd2d7a94c93/puni/base.py#L400-L415
davidblaisonneau-orange/foreman
foreman/puppetClasses.py
PuppetClasses.load
def load(self): """ Function load Get the list of all objects @return RETURN: A ForemanItem list """ cl_tmp = self.api.list(self.objName, limit=self.searchLimit).values() cl = [] for i in cl_tmp: cl.extend(i) return {x[self.index]: ItemPuppetC...
python
def load(self): """ Function load Get the list of all objects @return RETURN: A ForemanItem list """ cl_tmp = self.api.list(self.objName, limit=self.searchLimit).values() cl = [] for i in cl_tmp: cl.extend(i) return {x[self.index]: ItemPuppetC...
[ "def", "load", "(", "self", ")", ":", "cl_tmp", "=", "self", ".", "api", ".", "list", "(", "self", ".", "objName", ",", "limit", "=", "self", ".", "searchLimit", ")", ".", "values", "(", ")", "cl", "=", "[", "]", "for", "i", "in", "cl_tmp", ":"...
Function load Get the list of all objects @return RETURN: A ForemanItem list
[ "Function", "load", "Get", "the", "list", "of", "all", "objects" ]
train
https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/puppetClasses.py#L32-L45
mozilla-services/amo2kinto
amo2kinto/exporter.py
is_related_to
def is_related_to(item, app_id, app_ver=None): """Return True if the item relates to the given app_id (and app_ver, if passed).""" versionRange = item.get('versionRange') if not versionRange: return True for vR in versionRange: if not vR.get('targetApplication'): return True...
python
def is_related_to(item, app_id, app_ver=None): """Return True if the item relates to the given app_id (and app_ver, if passed).""" versionRange = item.get('versionRange') if not versionRange: return True for vR in versionRange: if not vR.get('targetApplication'): return True...
[ "def", "is_related_to", "(", "item", ",", "app_id", ",", "app_ver", "=", "None", ")", ":", "versionRange", "=", "item", ".", "get", "(", "'versionRange'", ")", "if", "not", "versionRange", ":", "return", "True", "for", "vR", "in", "versionRange", ":", "i...
Return True if the item relates to the given app_id (and app_ver, if passed).
[ "Return", "True", "if", "the", "item", "relates", "to", "the", "given", "app_id", "(", "and", "app_ver", "if", "passed", ")", "." ]
train
https://github.com/mozilla-services/amo2kinto/blob/1ec40647e77cf89badbea4a58d328243daed49a9/amo2kinto/exporter.py#L46-L57
mozilla-services/amo2kinto
amo2kinto/exporter.py
get_related_targetApplication
def get_related_targetApplication(vR, app_id, app_ver): """Return the first matching target application in this version range. Returns None if there are no target applications or no matching ones.""" targetApplication = vR.get('targetApplication') if not targetApplication: return None for t...
python
def get_related_targetApplication(vR, app_id, app_ver): """Return the first matching target application in this version range. Returns None if there are no target applications or no matching ones.""" targetApplication = vR.get('targetApplication') if not targetApplication: return None for t...
[ "def", "get_related_targetApplication", "(", "vR", ",", "app_id", ",", "app_ver", ")", ":", "targetApplication", "=", "vR", ".", "get", "(", "'targetApplication'", ")", "if", "not", "targetApplication", ":", "return", "None", "for", "tA", "in", "targetApplicatio...
Return the first matching target application in this version range. Returns None if there are no target applications or no matching ones.
[ "Return", "the", "first", "matching", "target", "application", "in", "this", "version", "range", ".", "Returns", "None", "if", "there", "are", "no", "target", "applications", "or", "no", "matching", "ones", "." ]
train
https://github.com/mozilla-services/amo2kinto/blob/1ec40647e77cf89badbea4a58d328243daed49a9/amo2kinto/exporter.py#L60-L78
mozilla-services/amo2kinto
amo2kinto/exporter.py
write_addons_items
def write_addons_items(xml_tree, records, app_id, api_ver=3, app_ver=None): """Generate the addons blocklists. <emItem blockID="i372" id="5nc3QHFgcb@r06Ws9gvNNVRfH.com"> <versionRange minVersion="0" maxVersion="*" severity="3"> <targetApplication id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"> ...
python
def write_addons_items(xml_tree, records, app_id, api_ver=3, app_ver=None): """Generate the addons blocklists. <emItem blockID="i372" id="5nc3QHFgcb@r06Ws9gvNNVRfH.com"> <versionRange minVersion="0" maxVersion="*" severity="3"> <targetApplication id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"> ...
[ "def", "write_addons_items", "(", "xml_tree", ",", "records", ",", "app_id", ",", "api_ver", "=", "3", ",", "app_ver", "=", "None", ")", ":", "if", "not", "records", ":", "return", "emItems", "=", "etree", ".", "SubElement", "(", "xml_tree", ",", "'emIte...
Generate the addons blocklists. <emItem blockID="i372" id="5nc3QHFgcb@r06Ws9gvNNVRfH.com"> <versionRange minVersion="0" maxVersion="*" severity="3"> <targetApplication id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"> <versionRange minVersion="39.0a1" maxVersion="*"/> </targetApplication...
[ "Generate", "the", "addons", "blocklists", "." ]
train
https://github.com/mozilla-services/amo2kinto/blob/1ec40647e77cf89badbea4a58d328243daed49a9/amo2kinto/exporter.py#L88-L143
mozilla-services/amo2kinto
amo2kinto/exporter.py
write_plugin_items
def write_plugin_items(xml_tree, records, app_id, api_ver=3, app_ver=None): """Generate the plugin blocklists. <pluginItem blockID="p422"> <match name="filename" exp="JavaAppletPlugin\\.plugin"/> <versionRange minVersion="Java 7 Update 16" maxVersion="Java 7 Update 24" ...
python
def write_plugin_items(xml_tree, records, app_id, api_ver=3, app_ver=None): """Generate the plugin blocklists. <pluginItem blockID="p422"> <match name="filename" exp="JavaAppletPlugin\\.plugin"/> <versionRange minVersion="Java 7 Update 16" maxVersion="Java 7 Update 24" ...
[ "def", "write_plugin_items", "(", "xml_tree", ",", "records", ",", "app_id", ",", "api_ver", "=", "3", ",", "app_ver", "=", "None", ")", ":", "if", "not", "records", ":", "return", "pluginItems", "=", "etree", ".", "SubElement", "(", "xml_tree", ",", "'p...
Generate the plugin blocklists. <pluginItem blockID="p422"> <match name="filename" exp="JavaAppletPlugin\\.plugin"/> <versionRange minVersion="Java 7 Update 16" maxVersion="Java 7 Update 24" severity="0" vulnerabilitystatus="1"> <targetApplica...
[ "Generate", "the", "plugin", "blocklists", "." ]
train
https://github.com/mozilla-services/amo2kinto/blob/1ec40647e77cf89badbea4a58d328243daed49a9/amo2kinto/exporter.py#L152-L182
mozilla-services/amo2kinto
amo2kinto/exporter.py
write_gfx_items
def write_gfx_items(xml_tree, records, app_id, api_ver=3): """Generate the gfxBlacklistEntry. <gfxBlacklistEntry blockID="g35"> <os>WINNT 6.1</os> <vendor>0x10de</vendor> <devices> <device>0x0a6c</device> </devices> <feature>DIRECT2D</feature> <featur...
python
def write_gfx_items(xml_tree, records, app_id, api_ver=3): """Generate the gfxBlacklistEntry. <gfxBlacklistEntry blockID="g35"> <os>WINNT 6.1</os> <vendor>0x10de</vendor> <devices> <device>0x0a6c</device> </devices> <feature>DIRECT2D</feature> <featur...
[ "def", "write_gfx_items", "(", "xml_tree", ",", "records", ",", "app_id", ",", "api_ver", "=", "3", ")", ":", "if", "not", "records", ":", "return", "gfxItems", "=", "etree", ".", "SubElement", "(", "xml_tree", ",", "'gfxItems'", ")", "for", "item", "in"...
Generate the gfxBlacklistEntry. <gfxBlacklistEntry blockID="g35"> <os>WINNT 6.1</os> <vendor>0x10de</vendor> <devices> <device>0x0a6c</device> </devices> <feature>DIRECT2D</feature> <featureStatus>BLOCKED_DRIVER_VERSION</featureStatus> <driverVers...
[ "Generate", "the", "gfxBlacklistEntry", "." ]
train
https://github.com/mozilla-services/amo2kinto/blob/1ec40647e77cf89badbea4a58d328243daed49a9/amo2kinto/exporter.py#L276-L323
mozilla-services/amo2kinto
amo2kinto/exporter.py
write_cert_items
def write_cert_items(xml_tree, records, api_ver=3, app_id=None, app_ver=None): """Generate the certificate blocklists. <certItem issuerName="MIGQMQswCQYD...IENB"> <serialNumber>UoRGnb96CUDTxIqVry6LBg==</serialNumber> </certItem> or <certItem subject='MCIxIDAeBgNVBAMMF0Fub3RoZXIgVGVzdCBFbmQt...
python
def write_cert_items(xml_tree, records, api_ver=3, app_id=None, app_ver=None): """Generate the certificate blocklists. <certItem issuerName="MIGQMQswCQYD...IENB"> <serialNumber>UoRGnb96CUDTxIqVry6LBg==</serialNumber> </certItem> or <certItem subject='MCIxIDAeBgNVBAMMF0Fub3RoZXIgVGVzdCBFbmQt...
[ "def", "write_cert_items", "(", "xml_tree", ",", "records", ",", "api_ver", "=", "3", ",", "app_id", "=", "None", ",", "app_ver", "=", "None", ")", ":", "if", "not", "records", "or", "not", "should_include_certs", "(", "app_id", ",", "app_ver", ")", ":",...
Generate the certificate blocklists. <certItem issuerName="MIGQMQswCQYD...IENB"> <serialNumber>UoRGnb96CUDTxIqVry6LBg==</serialNumber> </certItem> or <certItem subject='MCIxIDAeBgNVBAMMF0Fub3RoZXIgVGVzdCBFbmQtZW50aXR5' pubKeyHash='VCIlmPM9NkgFQtrs4Oa5TeFcDu6MWRTKSNdePEhOgD8='> ...
[ "Generate", "the", "certificate", "blocklists", "." ]
train
https://github.com/mozilla-services/amo2kinto/blob/1ec40647e77cf89badbea4a58d328243daed49a9/amo2kinto/exporter.py#L326-L352
quantmind/agile-toolkit
agiletoolkit/api/repo.py
GitRepo.label
def label(self, name, color, update=True): """Create or update a label """ url = '%s/labels' % self data = dict(name=name, color=color) response = self.http.post( url, json=data, auth=self.auth, headers=self.headers ) if response.status_code == 201: ...
python
def label(self, name, color, update=True): """Create or update a label """ url = '%s/labels' % self data = dict(name=name, color=color) response = self.http.post( url, json=data, auth=self.auth, headers=self.headers ) if response.status_code == 201: ...
[ "def", "label", "(", "self", ",", "name", ",", "color", ",", "update", "=", "True", ")", ":", "url", "=", "'%s/labels'", "%", "self", "data", "=", "dict", "(", "name", "=", "name", ",", "color", "=", "color", ")", "response", "=", "self", ".", "h...
Create or update a label
[ "Create", "or", "update", "a", "label" ]
train
https://github.com/quantmind/agile-toolkit/blob/96028e36a842c57b171907c20583a60d1045fec1/agiletoolkit/api/repo.py#L25-L41
aroberge/experimental
experimental/transformers/utils/one2one.py
translate
def translate(source, dictionary): '''A dictionary with a one-to-one translation of keywords is used to provide the transformation. ''' toks = tokenize.generate_tokens(StringIO(source).readline) result = [] for toktype, tokvalue, _, _, _ in toks: if toktype == tokenize.NAME and tokvalue ...
python
def translate(source, dictionary): '''A dictionary with a one-to-one translation of keywords is used to provide the transformation. ''' toks = tokenize.generate_tokens(StringIO(source).readline) result = [] for toktype, tokvalue, _, _, _ in toks: if toktype == tokenize.NAME and tokvalue ...
[ "def", "translate", "(", "source", ",", "dictionary", ")", ":", "toks", "=", "tokenize", ".", "generate_tokens", "(", "StringIO", "(", "source", ")", ".", "readline", ")", "result", "=", "[", "]", "for", "toktype", ",", "tokvalue", ",", "_", ",", "_", ...
A dictionary with a one-to-one translation of keywords is used to provide the transformation.
[ "A", "dictionary", "with", "a", "one", "-", "to", "-", "one", "translation", "of", "keywords", "is", "used", "to", "provide", "the", "transformation", "." ]
train
https://github.com/aroberge/experimental/blob/031a9be10698b429998436da748b8fdb86f18b47/experimental/transformers/utils/one2one.py#L12-L23
davidblaisonneau-orange/foreman
foreman/itemComputeRessource.py
ItemComputeRessource.enhance
def enhance(self): """ Function enhance Enhance the object with new item or enhanced items """ self.update({'images': SubDict(self.api, self.objName, self.payloadObj, self.key, SubItemImages)})
python
def enhance(self): """ Function enhance Enhance the object with new item or enhanced items """ self.update({'images': SubDict(self.api, self.objName, self.payloadObj, self.key, SubItemImages)})
[ "def", "enhance", "(", "self", ")", ":", "self", ".", "update", "(", "{", "'images'", ":", "SubDict", "(", "self", ".", "api", ",", "self", ".", "objName", ",", "self", ".", "payloadObj", ",", "self", ".", "key", ",", "SubItemImages", ")", "}", ")"...
Function enhance Enhance the object with new item or enhanced items
[ "Function", "enhance", "Enhance", "the", "object", "with", "new", "item", "or", "enhanced", "items" ]
train
https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/itemComputeRessource.py#L34-L41
MatterMiners/cobald
cobald/daemon/runners/asyncio_runner.py
AsyncioRunner._run_payloads
async def _run_payloads(self): """Async component of _run""" delay = 0.0 try: while self.running.is_set(): await self._start_payloads() await self._reap_payloads() await asyncio.sleep(delay) delay = min(delay + 0.1, 1.0)...
python
async def _run_payloads(self): """Async component of _run""" delay = 0.0 try: while self.running.is_set(): await self._start_payloads() await self._reap_payloads() await asyncio.sleep(delay) delay = min(delay + 0.1, 1.0)...
[ "async", "def", "_run_payloads", "(", "self", ")", ":", "delay", "=", "0.0", "try", ":", "while", "self", ".", "running", ".", "is_set", "(", ")", ":", "await", "self", ".", "_start_payloads", "(", ")", "await", "self", ".", "_reap_payloads", "(", ")",...
Async component of _run
[ "Async", "component", "of", "_run" ]
train
https://github.com/MatterMiners/cobald/blob/264138de4382d1c9b53fabcbc6660e10b33a914d/cobald/daemon/runners/asyncio_runner.py#L29-L40
MatterMiners/cobald
cobald/daemon/runners/asyncio_runner.py
AsyncioRunner._start_payloads
async def _start_payloads(self): """Start all queued payloads""" with self._lock: for coroutine in self._payloads: task = self.event_loop.create_task(coroutine()) self._tasks.add(task) self._payloads.clear() await asyncio.sleep(0)
python
async def _start_payloads(self): """Start all queued payloads""" with self._lock: for coroutine in self._payloads: task = self.event_loop.create_task(coroutine()) self._tasks.add(task) self._payloads.clear() await asyncio.sleep(0)
[ "async", "def", "_start_payloads", "(", "self", ")", ":", "with", "self", ".", "_lock", ":", "for", "coroutine", "in", "self", ".", "_payloads", ":", "task", "=", "self", ".", "event_loop", ".", "create_task", "(", "coroutine", "(", ")", ")", "self", "...
Start all queued payloads
[ "Start", "all", "queued", "payloads" ]
train
https://github.com/MatterMiners/cobald/blob/264138de4382d1c9b53fabcbc6660e10b33a914d/cobald/daemon/runners/asyncio_runner.py#L42-L49
MatterMiners/cobald
cobald/daemon/runners/asyncio_runner.py
AsyncioRunner._reap_payloads
async def _reap_payloads(self): """Clean up all finished payloads""" for task in self._tasks.copy(): if task.done(): self._tasks.remove(task) if task.exception() is not None: raise task.exception() await asyncio.sleep(0)
python
async def _reap_payloads(self): """Clean up all finished payloads""" for task in self._tasks.copy(): if task.done(): self._tasks.remove(task) if task.exception() is not None: raise task.exception() await asyncio.sleep(0)
[ "async", "def", "_reap_payloads", "(", "self", ")", ":", "for", "task", "in", "self", ".", "_tasks", ".", "copy", "(", ")", ":", "if", "task", ".", "done", "(", ")", ":", "self", ".", "_tasks", ".", "remove", "(", "task", ")", "if", "task", ".", ...
Clean up all finished payloads
[ "Clean", "up", "all", "finished", "payloads" ]
train
https://github.com/MatterMiners/cobald/blob/264138de4382d1c9b53fabcbc6660e10b33a914d/cobald/daemon/runners/asyncio_runner.py#L51-L58
MatterMiners/cobald
cobald/daemon/runners/asyncio_runner.py
AsyncioRunner._cancel_payloads
async def _cancel_payloads(self): """Cancel all remaining payloads""" for task in self._tasks: task.cancel() await asyncio.sleep(0) for task in self._tasks: while not task.done(): await asyncio.sleep(0.1) task.cancel()
python
async def _cancel_payloads(self): """Cancel all remaining payloads""" for task in self._tasks: task.cancel() await asyncio.sleep(0) for task in self._tasks: while not task.done(): await asyncio.sleep(0.1) task.cancel()
[ "async", "def", "_cancel_payloads", "(", "self", ")", ":", "for", "task", "in", "self", ".", "_tasks", ":", "task", ".", "cancel", "(", ")", "await", "asyncio", ".", "sleep", "(", "0", ")", "for", "task", "in", "self", ".", "_tasks", ":", "while", ...
Cancel all remaining payloads
[ "Cancel", "all", "remaining", "payloads" ]
train
https://github.com/MatterMiners/cobald/blob/264138de4382d1c9b53fabcbc6660e10b33a914d/cobald/daemon/runners/asyncio_runner.py#L60-L68
Karaage-Cluster/python-tldap
tldap/ldap_passwd.py
check_password
def check_password(password: str, encrypted: str) -> bool: """ Check a plaintext password against a hashed password. """ # some old passwords have {crypt} in lower case, and passlib wants it to be # in upper case. if encrypted.startswith("{crypt}"): encrypted = "{CRYPT}" + encrypted[7:] retu...
python
def check_password(password: str, encrypted: str) -> bool: """ Check a plaintext password against a hashed password. """ # some old passwords have {crypt} in lower case, and passlib wants it to be # in upper case. if encrypted.startswith("{crypt}"): encrypted = "{CRYPT}" + encrypted[7:] retu...
[ "def", "check_password", "(", "password", ":", "str", ",", "encrypted", ":", "str", ")", "->", "bool", ":", "# some old passwords have {crypt} in lower case, and passlib wants it to be", "# in upper case.", "if", "encrypted", ".", "startswith", "(", "\"{crypt}\"", ")", ...
Check a plaintext password against a hashed password.
[ "Check", "a", "plaintext", "password", "against", "a", "hashed", "password", "." ]
train
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/ldap_passwd.py#L36-L42
quantmind/agile-toolkit
agiletoolkit/github/validate.py
validate
def validate(ctx, sandbox): """Check if version of repository is semantic """ m = RepoManager(ctx.obj['agile']) if not sandbox or m.can_release('sandbox'): click.echo(m.validate_version())
python
def validate(ctx, sandbox): """Check if version of repository is semantic """ m = RepoManager(ctx.obj['agile']) if not sandbox or m.can_release('sandbox'): click.echo(m.validate_version())
[ "def", "validate", "(", "ctx", ",", "sandbox", ")", ":", "m", "=", "RepoManager", "(", "ctx", ".", "obj", "[", "'agile'", "]", ")", "if", "not", "sandbox", "or", "m", ".", "can_release", "(", "'sandbox'", ")", ":", "click", ".", "echo", "(", "m", ...
Check if version of repository is semantic
[ "Check", "if", "version", "of", "repository", "is", "semantic" ]
train
https://github.com/quantmind/agile-toolkit/blob/96028e36a842c57b171907c20583a60d1045fec1/agiletoolkit/github/validate.py#L11-L16
Karaage-Cluster/python-tldap
tldap/backend/fake_transactions.py
LDAPwrapper.reset
def reset(self, force_flush_cache: bool = False) -> None: """ Reset transaction back to original state, discarding all uncompleted transactions. """ super(LDAPwrapper, self).reset() if len(self._transactions) == 0: raise RuntimeError("reset called outside a tr...
python
def reset(self, force_flush_cache: bool = False) -> None: """ Reset transaction back to original state, discarding all uncompleted transactions. """ super(LDAPwrapper, self).reset() if len(self._transactions) == 0: raise RuntimeError("reset called outside a tr...
[ "def", "reset", "(", "self", ",", "force_flush_cache", ":", "bool", "=", "False", ")", "->", "None", ":", "super", "(", "LDAPwrapper", ",", "self", ")", ".", "reset", "(", ")", "if", "len", "(", "self", ".", "_transactions", ")", "==", "0", ":", "r...
Reset transaction back to original state, discarding all uncompleted transactions.
[ "Reset", "transaction", "back", "to", "original", "state", "discarding", "all", "uncompleted", "transactions", "." ]
train
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/backend/fake_transactions.py#L68-L76
Karaage-Cluster/python-tldap
tldap/backend/fake_transactions.py
LDAPwrapper._cache_get_for_dn
def _cache_get_for_dn(self, dn: str) -> Dict[str, bytes]: """ Object state is cached. When an update is required the update will be simulated on this cache, so that rollback information can be correct. This function retrieves the cached data. """ # no cached item, retrie...
python
def _cache_get_for_dn(self, dn: str) -> Dict[str, bytes]: """ Object state is cached. When an update is required the update will be simulated on this cache, so that rollback information can be correct. This function retrieves the cached data. """ # no cached item, retrie...
[ "def", "_cache_get_for_dn", "(", "self", ",", "dn", ":", "str", ")", "->", "Dict", "[", "str", ",", "bytes", "]", ":", "# no cached item, retrieve from ldap", "self", ".", "_do_with_retry", "(", "lambda", "obj", ":", "obj", ".", "search", "(", "dn", ",", ...
Object state is cached. When an update is required the update will be simulated on this cache, so that rollback information can be correct. This function retrieves the cached data.
[ "Object", "state", "is", "cached", ".", "When", "an", "update", "is", "required", "the", "update", "will", "be", "simulated", "on", "this", "cache", "so", "that", "rollback", "information", "can", "be", "correct", ".", "This", "function", "retrieves", "the",...
train
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/backend/fake_transactions.py#L78-L98
Karaage-Cluster/python-tldap
tldap/backend/fake_transactions.py
LDAPwrapper.is_dirty
def is_dirty(self) -> bool: """ Are there uncommitted changes? """ if len(self._transactions) == 0: raise RuntimeError("is_dirty called outside a transaction.") if len(self._transactions[-1]) > 0: return True return False
python
def is_dirty(self) -> bool: """ Are there uncommitted changes? """ if len(self._transactions) == 0: raise RuntimeError("is_dirty called outside a transaction.") if len(self._transactions[-1]) > 0: return True return False
[ "def", "is_dirty", "(", "self", ")", "->", "bool", ":", "if", "len", "(", "self", ".", "_transactions", ")", "==", "0", ":", "raise", "RuntimeError", "(", "\"is_dirty called outside a transaction.\"", ")", "if", "len", "(", "self", ".", "_transactions", "[",...
Are there uncommitted changes?
[ "Are", "there", "uncommitted", "changes?" ]
train
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/backend/fake_transactions.py#L104-L110
Karaage-Cluster/python-tldap
tldap/backend/fake_transactions.py
LDAPwrapper.leave_transaction_management
def leave_transaction_management(self) -> None: """ End a transaction. Must not be dirty when doing so. ie. commit() or rollback() must be called if changes made. If dirty, changes will be discarded. """ if len(self._transactions) == 0: raise RuntimeError("lea...
python
def leave_transaction_management(self) -> None: """ End a transaction. Must not be dirty when doing so. ie. commit() or rollback() must be called if changes made. If dirty, changes will be discarded. """ if len(self._transactions) == 0: raise RuntimeError("lea...
[ "def", "leave_transaction_management", "(", "self", ")", "->", "None", ":", "if", "len", "(", "self", ".", "_transactions", ")", "==", "0", ":", "raise", "RuntimeError", "(", "\"leave_transaction_management called outside transaction\"", ")", "elif", "len", "(", "...
End a transaction. Must not be dirty when doing so. ie. commit() or rollback() must be called if changes made. If dirty, changes will be discarded.
[ "End", "a", "transaction", ".", "Must", "not", "be", "dirty", "when", "doing", "so", ".", "ie", ".", "commit", "()", "or", "rollback", "()", "must", "be", "called", "if", "changes", "made", ".", "If", "dirty", "changes", "will", "be", "discarded", "." ...
train
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/backend/fake_transactions.py#L120-L131
Karaage-Cluster/python-tldap
tldap/backend/fake_transactions.py
LDAPwrapper.commit
def commit(self) -> None: """ Attempt to commit all changes to LDAP database. i.e. forget all rollbacks. However stay inside transaction management. """ if len(self._transactions) == 0: raise RuntimeError("commit called outside transaction") # If we have nes...
python
def commit(self) -> None: """ Attempt to commit all changes to LDAP database. i.e. forget all rollbacks. However stay inside transaction management. """ if len(self._transactions) == 0: raise RuntimeError("commit called outside transaction") # If we have nes...
[ "def", "commit", "(", "self", ")", "->", "None", ":", "if", "len", "(", "self", ".", "_transactions", ")", "==", "0", ":", "raise", "RuntimeError", "(", "\"commit called outside transaction\"", ")", "# If we have nested transactions, we don't actually commit, but push",...
Attempt to commit all changes to LDAP database. i.e. forget all rollbacks. However stay inside transaction management.
[ "Attempt", "to", "commit", "all", "changes", "to", "LDAP", "database", ".", "i", ".", "e", ".", "forget", "all", "rollbacks", ".", "However", "stay", "inside", "transaction", "management", "." ]
train
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/backend/fake_transactions.py#L133-L148
Karaage-Cluster/python-tldap
tldap/backend/fake_transactions.py
LDAPwrapper.rollback
def rollback(self) -> None: """ Roll back to previous database state. However stay inside transaction management. """ if len(self._transactions) == 0: raise RuntimeError("rollback called outside transaction") _debug("rollback:", self._transactions[-1]) ...
python
def rollback(self) -> None: """ Roll back to previous database state. However stay inside transaction management. """ if len(self._transactions) == 0: raise RuntimeError("rollback called outside transaction") _debug("rollback:", self._transactions[-1]) ...
[ "def", "rollback", "(", "self", ")", "->", "None", ":", "if", "len", "(", "self", ".", "_transactions", ")", "==", "0", ":", "raise", "RuntimeError", "(", "\"rollback called outside transaction\"", ")", "_debug", "(", "\"rollback:\"", ",", "self", ".", "_tra...
Roll back to previous database state. However stay inside transaction management.
[ "Roll", "back", "to", "previous", "database", "state", ".", "However", "stay", "inside", "transaction", "management", "." ]
train
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/backend/fake_transactions.py#L150-L175
Karaage-Cluster/python-tldap
tldap/backend/fake_transactions.py
LDAPwrapper._process
def _process(self, on_commit: UpdateCallable, on_rollback: UpdateCallable) -> Any: """ Process action. oncommit is a callback to execute action, onrollback is a callback to execute if the oncommit() has been called and a rollback is required """ _debug("---> commiting", ...
python
def _process(self, on_commit: UpdateCallable, on_rollback: UpdateCallable) -> Any: """ Process action. oncommit is a callback to execute action, onrollback is a callback to execute if the oncommit() has been called and a rollback is required """ _debug("---> commiting", ...
[ "def", "_process", "(", "self", ",", "on_commit", ":", "UpdateCallable", ",", "on_rollback", ":", "UpdateCallable", ")", "->", "Any", ":", "_debug", "(", "\"---> commiting\"", ",", "on_commit", ")", "result", "=", "self", ".", "_do_with_retry", "(", "on_commit...
Process action. oncommit is a callback to execute action, onrollback is a callback to execute if the oncommit() has been called and a rollback is required
[ "Process", "action", ".", "oncommit", "is", "a", "callback", "to", "execute", "action", "onrollback", "is", "a", "callback", "to", "execute", "if", "the", "oncommit", "()", "has", "been", "called", "and", "a", "rollback", "is", "required" ]
train
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/backend/fake_transactions.py#L177-L191
Karaage-Cluster/python-tldap
tldap/backend/fake_transactions.py
LDAPwrapper.add
def add(self, dn: str, mod_list: dict) -> None: """ Add a DN to the LDAP database; See ldap module. Doesn't return a result if transactions enabled. """ _debug("add", self, dn, mod_list) # if rollback of add required, delete it def on_commit(obj): ob...
python
def add(self, dn: str, mod_list: dict) -> None: """ Add a DN to the LDAP database; See ldap module. Doesn't return a result if transactions enabled. """ _debug("add", self, dn, mod_list) # if rollback of add required, delete it def on_commit(obj): ob...
[ "def", "add", "(", "self", ",", "dn", ":", "str", ",", "mod_list", ":", "dict", ")", "->", "None", ":", "_debug", "(", "\"add\"", ",", "self", ",", "dn", ",", "mod_list", ")", "# if rollback of add required, delete it", "def", "on_commit", "(", "obj", ")...
Add a DN to the LDAP database; See ldap module. Doesn't return a result if transactions enabled.
[ "Add", "a", "DN", "to", "the", "LDAP", "database", ";", "See", "ldap", "module", ".", "Doesn", "t", "return", "a", "result", "if", "transactions", "enabled", "." ]
train
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/backend/fake_transactions.py#L197-L213
Karaage-Cluster/python-tldap
tldap/backend/fake_transactions.py
LDAPwrapper.modify
def modify(self, dn: str, mod_list: dict) -> None: """ Modify a DN in the LDAP database; See ldap module. Doesn't return a result if transactions enabled. """ _debug("modify", self, dn, mod_list) # need to work out how to reverse changes in mod_list; result in revlist ...
python
def modify(self, dn: str, mod_list: dict) -> None: """ Modify a DN in the LDAP database; See ldap module. Doesn't return a result if transactions enabled. """ _debug("modify", self, dn, mod_list) # need to work out how to reverse changes in mod_list; result in revlist ...
[ "def", "modify", "(", "self", ",", "dn", ":", "str", ",", "mod_list", ":", "dict", ")", "->", "None", ":", "_debug", "(", "\"modify\"", ",", "self", ",", "dn", ",", "mod_list", ")", "# need to work out how to reverse changes in mod_list; result in revlist", "rev...
Modify a DN in the LDAP database; See ldap module. Doesn't return a result if transactions enabled.
[ "Modify", "a", "DN", "in", "the", "LDAP", "database", ";", "See", "ldap", "module", ".", "Doesn", "t", "return", "a", "result", "if", "transactions", "enabled", "." ]
train
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/backend/fake_transactions.py#L215-L294
Karaage-Cluster/python-tldap
tldap/backend/fake_transactions.py
LDAPwrapper.modify_no_rollback
def modify_no_rollback(self, dn: str, mod_list: dict): """ Modify a DN in the LDAP database; See ldap module. Doesn't return a result if transactions enabled. """ _debug("modify_no_rollback", self, dn, mod_list) result = self._do_with_retry(lambda obj: obj.modify_s(dn, m...
python
def modify_no_rollback(self, dn: str, mod_list: dict): """ Modify a DN in the LDAP database; See ldap module. Doesn't return a result if transactions enabled. """ _debug("modify_no_rollback", self, dn, mod_list) result = self._do_with_retry(lambda obj: obj.modify_s(dn, m...
[ "def", "modify_no_rollback", "(", "self", ",", "dn", ":", "str", ",", "mod_list", ":", "dict", ")", ":", "_debug", "(", "\"modify_no_rollback\"", ",", "self", ",", "dn", ",", "mod_list", ")", "result", "=", "self", ".", "_do_with_retry", "(", "lambda", "...
Modify a DN in the LDAP database; See ldap module. Doesn't return a result if transactions enabled.
[ "Modify", "a", "DN", "in", "the", "LDAP", "database", ";", "See", "ldap", "module", ".", "Doesn", "t", "return", "a", "result", "if", "transactions", "enabled", "." ]
train
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/backend/fake_transactions.py#L296-L306
Karaage-Cluster/python-tldap
tldap/backend/fake_transactions.py
LDAPwrapper.delete
def delete(self, dn: str) -> None: """ delete a dn in the ldap database; see ldap module. doesn't return a result if transactions enabled. """ _debug("delete", self) # get copy of cache result = self._cache_get_for_dn(dn) # remove special values that ca...
python
def delete(self, dn: str) -> None: """ delete a dn in the ldap database; see ldap module. doesn't return a result if transactions enabled. """ _debug("delete", self) # get copy of cache result = self._cache_get_for_dn(dn) # remove special values that ca...
[ "def", "delete", "(", "self", ",", "dn", ":", "str", ")", "->", "None", ":", "_debug", "(", "\"delete\"", ",", "self", ")", "# get copy of cache", "result", "=", "self", ".", "_cache_get_for_dn", "(", "dn", ")", "# remove special values that can't be added", "...
delete a dn in the ldap database; see ldap module. doesn't return a result if transactions enabled.
[ "delete", "a", "dn", "in", "the", "ldap", "database", ";", "see", "ldap", "module", ".", "doesn", "t", "return", "a", "result", "if", "transactions", "enabled", "." ]
train
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/backend/fake_transactions.py#L308-L347
Karaage-Cluster/python-tldap
tldap/backend/fake_transactions.py
LDAPwrapper.rename
def rename(self, dn: str, new_rdn: str, new_base_dn: Optional[str] = None) -> None: """ rename a dn in the ldap database; see ldap module. doesn't return a result if transactions enabled. """ _debug("rename", self, dn, new_rdn, new_base_dn) # split up the parameters ...
python
def rename(self, dn: str, new_rdn: str, new_base_dn: Optional[str] = None) -> None: """ rename a dn in the ldap database; see ldap module. doesn't return a result if transactions enabled. """ _debug("rename", self, dn, new_rdn, new_base_dn) # split up the parameters ...
[ "def", "rename", "(", "self", ",", "dn", ":", "str", ",", "new_rdn", ":", "str", ",", "new_base_dn", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "None", ":", "_debug", "(", "\"rename\"", ",", "self", ",", "dn", ",", "new_rdn", ",", ...
rename a dn in the ldap database; see ldap module. doesn't return a result if transactions enabled.
[ "rename", "a", "dn", "in", "the", "ldap", "database", ";", "see", "ldap", "module", ".", "doesn", "t", "return", "a", "result", "if", "transactions", "enabled", "." ]
train
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/backend/fake_transactions.py#L349-L385
Karaage-Cluster/python-tldap
tldap/backend/fake_transactions.py
LDAPwrapper.fail
def fail(self) -> None: """ for testing purposes only. always fail in commit """ _debug("fail") # on commit carry out action; on rollback reverse rename def on_commit(_obj): raise_testfailure("commit") def on_rollback(_obj): raise_testfailure("rollback"...
python
def fail(self) -> None: """ for testing purposes only. always fail in commit """ _debug("fail") # on commit carry out action; on rollback reverse rename def on_commit(_obj): raise_testfailure("commit") def on_rollback(_obj): raise_testfailure("rollback"...
[ "def", "fail", "(", "self", ")", "->", "None", ":", "_debug", "(", "\"fail\"", ")", "# on commit carry out action; on rollback reverse rename", "def", "on_commit", "(", "_obj", ")", ":", "raise_testfailure", "(", "\"commit\"", ")", "def", "on_rollback", "(", "_obj...
for testing purposes only. always fail in commit
[ "for", "testing", "purposes", "only", ".", "always", "fail", "in", "commit" ]
train
https://github.com/Karaage-Cluster/python-tldap/blob/61f1af74a3648cb6491e7eeb1ee2eb395d67bf59/tldap/backend/fake_transactions.py#L387-L399
aroberge/experimental
experimental/transformers/int_seq.py
__experimental_range
def __experimental_range(start, stop, var, cond, loc={}): '''Utility function made to reproduce range() with unit integer step but with the added possibility of specifying a condition on the looping variable (e.g. var % 2 == 0) ''' locals().update(loc) if start < stop: for __ in ...
python
def __experimental_range(start, stop, var, cond, loc={}): '''Utility function made to reproduce range() with unit integer step but with the added possibility of specifying a condition on the looping variable (e.g. var % 2 == 0) ''' locals().update(loc) if start < stop: for __ in ...
[ "def", "__experimental_range", "(", "start", ",", "stop", ",", "var", ",", "cond", ",", "loc", "=", "{", "}", ")", ":", "locals", "(", ")", ".", "update", "(", "loc", ")", "if", "start", "<", "stop", ":", "for", "__", "in", "range", "(", "start",...
Utility function made to reproduce range() with unit integer step but with the added possibility of specifying a condition on the looping variable (e.g. var % 2 == 0)
[ "Utility", "function", "made", "to", "reproduce", "range", "()", "with", "unit", "integer", "step", "but", "with", "the", "added", "possibility", "of", "specifying", "a", "condition", "on", "the", "looping", "variable", "(", "e", ".", "g", ".", "var", "%",...
train
https://github.com/aroberge/experimental/blob/031a9be10698b429998436da748b8fdb86f18b47/experimental/transformers/int_seq.py#L51-L66
aroberge/experimental
experimental/transformers/int_seq.py
create_for
def create_for(line, search_result): '''Create a new "for loop" line as a replacement for the original code. ''' try: return line.format(search_result.group("indented_for"), search_result.group("var"), search_result.group("start"), ...
python
def create_for(line, search_result): '''Create a new "for loop" line as a replacement for the original code. ''' try: return line.format(search_result.group("indented_for"), search_result.group("var"), search_result.group("start"), ...
[ "def", "create_for", "(", "line", ",", "search_result", ")", ":", "try", ":", "return", "line", ".", "format", "(", "search_result", ".", "group", "(", "\"indented_for\"", ")", ",", "search_result", ".", "group", "(", "\"var\"", ")", ",", "search_result", ...
Create a new "for loop" line as a replacement for the original code.
[ "Create", "a", "new", "for", "loop", "line", "as", "a", "replacement", "for", "the", "original", "code", "." ]
train
https://github.com/aroberge/experimental/blob/031a9be10698b429998436da748b8fdb86f18b47/experimental/transformers/int_seq.py#L180-L193
davidblaisonneau-orange/foreman
foreman/itemSmartClassParameter.py
ItemSmartClassParameter.setOverrideValue
def setOverrideValue(self, attributes, hostName): """ Function __setitem__ Set a parameter of a foreman object as a dict @param key: The key to modify @param attribute: The data @return RETURN: The API result """ self['override'] = True attrType = type(at...
python
def setOverrideValue(self, attributes, hostName): """ Function __setitem__ Set a parameter of a foreman object as a dict @param key: The key to modify @param attribute: The data @return RETURN: The API result """ self['override'] = True attrType = type(at...
[ "def", "setOverrideValue", "(", "self", ",", "attributes", ",", "hostName", ")", ":", "self", "[", "'override'", "]", "=", "True", "attrType", "=", "type", "(", "attributes", ")", "if", "attrType", "is", "dict", ":", "self", "[", "'parameter_type'", "]", ...
Function __setitem__ Set a parameter of a foreman object as a dict @param key: The key to modify @param attribute: The data @return RETURN: The API result
[ "Function", "__setitem__", "Set", "a", "parameter", "of", "a", "foreman", "object", "as", "a", "dict" ]
train
https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/itemSmartClassParameter.py#L87-L113
developersociety/django-glitter
glitter/reminders/models.py
Reminder.get_interval_timedelta
def get_interval_timedelta(self): """ Spits out the timedelta in days. """ now_datetime = timezone.now() current_month_days = monthrange(now_datetime.year, now_datetime.month)[1] # Two weeks if self.interval == reminders_choices.INTERVAL_2_WEEKS: interval_timedelta ...
python
def get_interval_timedelta(self): """ Spits out the timedelta in days. """ now_datetime = timezone.now() current_month_days = monthrange(now_datetime.year, now_datetime.month)[1] # Two weeks if self.interval == reminders_choices.INTERVAL_2_WEEKS: interval_timedelta ...
[ "def", "get_interval_timedelta", "(", "self", ")", ":", "now_datetime", "=", "timezone", ".", "now", "(", ")", "current_month_days", "=", "monthrange", "(", "now_datetime", ".", "year", ",", "now_datetime", ".", "month", ")", "[", "1", "]", "# Two weeks", "i...
Spits out the timedelta in days.
[ "Spits", "out", "the", "timedelta", "in", "days", "." ]
train
https://github.com/developersociety/django-glitter/blob/2c0280ec83afee80deee94ee3934fc54239c2e87/glitter/reminders/models.py#L34-L63
MatterMiners/cobald
cobald/daemon/runners/asyncio_watcher.py
awaitable_runner
async def awaitable_runner(runner: BaseRunner): """Execute a runner without blocking the event loop""" runner_thread = CapturingThread(target=runner.run) runner_thread.start() delay = 0.0 while not runner_thread.join(timeout=0): await asyncio.sleep(delay) delay = min(delay + 0.1, 1.0...
python
async def awaitable_runner(runner: BaseRunner): """Execute a runner without blocking the event loop""" runner_thread = CapturingThread(target=runner.run) runner_thread.start() delay = 0.0 while not runner_thread.join(timeout=0): await asyncio.sleep(delay) delay = min(delay + 0.1, 1.0...
[ "async", "def", "awaitable_runner", "(", "runner", ":", "BaseRunner", ")", ":", "runner_thread", "=", "CapturingThread", "(", "target", "=", "runner", ".", "run", ")", "runner_thread", ".", "start", "(", ")", "delay", "=", "0.0", "while", "not", "runner_thre...
Execute a runner without blocking the event loop
[ "Execute", "a", "runner", "without", "blocking", "the", "event", "loop" ]
train
https://github.com/MatterMiners/cobald/blob/264138de4382d1c9b53fabcbc6660e10b33a914d/cobald/daemon/runners/asyncio_watcher.py#L9-L16
MatterMiners/cobald
cobald/daemon/runners/asyncio_watcher.py
asyncio_main_run
def asyncio_main_run(root_runner: BaseRunner): """ Create an ``asyncio`` event loop running in the main thread and watching runners Using ``asyncio`` to handle suprocesses requires a specific loop type to run in the main thread. This function sets up and runs the correct loop in a portable way. In ...
python
def asyncio_main_run(root_runner: BaseRunner): """ Create an ``asyncio`` event loop running in the main thread and watching runners Using ``asyncio`` to handle suprocesses requires a specific loop type to run in the main thread. This function sets up and runs the correct loop in a portable way. In ...
[ "def", "asyncio_main_run", "(", "root_runner", ":", "BaseRunner", ")", ":", "assert", "threading", ".", "current_thread", "(", ")", "==", "threading", ".", "main_thread", "(", ")", ",", "'only main thread can accept asyncio subprocesses'", "if", "sys", ".", "platfor...
Create an ``asyncio`` event loop running in the main thread and watching runners Using ``asyncio`` to handle suprocesses requires a specific loop type to run in the main thread. This function sets up and runs the correct loop in a portable way. In addition, it runs a single :py:class:`~.BaseRunner` until c...
[ "Create", "an", "asyncio", "event", "loop", "running", "in", "the", "main", "thread", "and", "watching", "runners" ]
train
https://github.com/MatterMiners/cobald/blob/264138de4382d1c9b53fabcbc6660e10b33a914d/cobald/daemon/runners/asyncio_watcher.py#L19-L36
davidblaisonneau-orange/foreman
foreman/itemConfigTemplate.py
ItemConfigTemplate.enhance
def enhance(self): """ Function enhance Enhance the object with new item or enhanced items """ self.update({'os_default_templates': SubDict(self.api, self.objName, self.payloadObj, self.key, SubItemOsDefaultTe...
python
def enhance(self): """ Function enhance Enhance the object with new item or enhanced items """ self.update({'os_default_templates': SubDict(self.api, self.objName, self.payloadObj, self.key, SubItemOsDefaultTe...
[ "def", "enhance", "(", "self", ")", ":", "self", ".", "update", "(", "{", "'os_default_templates'", ":", "SubDict", "(", "self", ".", "api", ",", "self", ".", "objName", ",", "self", ".", "payloadObj", ",", "self", ".", "key", ",", "SubItemOsDefaultTempl...
Function enhance Enhance the object with new item or enhanced items
[ "Function", "enhance", "Enhance", "the", "object", "with", "new", "item", "or", "enhanced", "items" ]
train
https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/itemConfigTemplate.py#L37-L48
qubell/contrib-python-qubell-client
qubell/api/tools/__init__.py
retry
def retry(tries=10, delay=1, backoff=2, retry_exception=None): """ Retry "tries" times, with initial "delay", increasing delay "delay*backoff" each time. Without exception success means when function returns valid object. With exception success when no exceptions """ assert tries > 0, "tries mus...
python
def retry(tries=10, delay=1, backoff=2, retry_exception=None): """ Retry "tries" times, with initial "delay", increasing delay "delay*backoff" each time. Without exception success means when function returns valid object. With exception success when no exceptions """ assert tries > 0, "tries mus...
[ "def", "retry", "(", "tries", "=", "10", ",", "delay", "=", "1", ",", "backoff", "=", "2", ",", "retry_exception", "=", "None", ")", ":", "assert", "tries", ">", "0", ",", "\"tries must be 1 or greater\"", "catching_mode", "=", "bool", "(", "retry_exceptio...
Retry "tries" times, with initial "delay", increasing delay "delay*backoff" each time. Without exception success means when function returns valid object. With exception success when no exceptions
[ "Retry", "tries", "times", "with", "initial", "delay", "increasing", "delay", "delay", "*", "backoff", "each", "time", ".", "Without", "exception", "success", "means", "when", "function", "returns", "valid", "object", ".", "With", "exception", "success", "when",...
train
https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/tools/__init__.py#L37-L71
qubell/contrib-python-qubell-client
qubell/api/tools/__init__.py
dump
def dump(node): """ Dump initialized object structure to yaml """ from qubell.api.private.platform import Auth, QubellPlatform from qubell.api.private.organization import Organization from qubell.api.private.application import Application from qubell.api.private.instance import Instance fro...
python
def dump(node): """ Dump initialized object structure to yaml """ from qubell.api.private.platform import Auth, QubellPlatform from qubell.api.private.organization import Organization from qubell.api.private.application import Application from qubell.api.private.instance import Instance fro...
[ "def", "dump", "(", "node", ")", ":", "from", "qubell", ".", "api", ".", "private", ".", "platform", "import", "Auth", ",", "QubellPlatform", "from", "qubell", ".", "api", ".", "private", ".", "organization", "import", "Organization", "from", "qubell", "."...
Dump initialized object structure to yaml
[ "Dump", "initialized", "object", "structure", "to", "yaml" ]
train
https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/tools/__init__.py#L145-L191
qubell/contrib-python-qubell-client
qubell/api/tools/__init__.py
load_env
def load_env(file): """ Generate environment used for 'org.restore' method :param file: env file :return: env """ env = yaml.load(open(file)) for org in env.get('organizations', []): if not org.get('applications'): org['applications'] = [] if org.get('starter-k...
python
def load_env(file): """ Generate environment used for 'org.restore' method :param file: env file :return: env """ env = yaml.load(open(file)) for org in env.get('organizations', []): if not org.get('applications'): org['applications'] = [] if org.get('starter-k...
[ "def", "load_env", "(", "file", ")", ":", "env", "=", "yaml", ".", "load", "(", "open", "(", "file", ")", ")", "for", "org", "in", "env", ".", "get", "(", "'organizations'", ",", "[", "]", ")", ":", "if", "not", "org", ".", "get", "(", "'applic...
Generate environment used for 'org.restore' method :param file: env file :return: env
[ "Generate", "environment", "used", "for", "org", ".", "restore", "method", ":", "param", "file", ":", "env", "file", ":", "return", ":", "env" ]
train
https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/tools/__init__.py#L198-L223