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
openpermissions/perch
perch/model.py
Document.get
def get(cls, resource_id, include_deactivated=False): """ Get a resource :param resource_id: a resource's ID :param include_deactivated: Include deactivated resources in response :returns: Document instance :raises: SocketError, CouchException """ resour...
python
def get(cls, resource_id, include_deactivated=False): """ Get a resource :param resource_id: a resource's ID :param include_deactivated: Include deactivated resources in response :returns: Document instance :raises: SocketError, CouchException """ resour...
[ "def", "get", "(", "cls", ",", "resource_id", ",", "include_deactivated", "=", "False", ")", ":", "resource", "=", "yield", "cls", ".", "db_client", "(", ")", ".", "get_doc", "(", "resource_id", ")", "if", "resource", ".", "get", "(", "'type'", ")", "!...
Get a resource :param resource_id: a resource's ID :param include_deactivated: Include deactivated resources in response :returns: Document instance :raises: SocketError, CouchException
[ "Get", "a", "resource" ]
train
https://github.com/openpermissions/perch/blob/36d78994133918f3c52c187f19e50132960a0156/perch/model.py#L177-L195
openpermissions/perch
perch/model.py
Document.all
def all(cls, include_deactivated=False): """ Get all resources :param include_deactivated: Include deactivated resources in response :returns: list of Document instances :raises: SocketError, CouchException """ if include_deactivated: resources = yiel...
python
def all(cls, include_deactivated=False): """ Get all resources :param include_deactivated: Include deactivated resources in response :returns: list of Document instances :raises: SocketError, CouchException """ if include_deactivated: resources = yiel...
[ "def", "all", "(", "cls", ",", "include_deactivated", "=", "False", ")", ":", "if", "include_deactivated", ":", "resources", "=", "yield", "cls", ".", "view", ".", "get", "(", "include_docs", "=", "True", ")", "else", ":", "resources", "=", "yield", "cls...
Get all resources :param include_deactivated: Include deactivated resources in response :returns: list of Document instances :raises: SocketError, CouchException
[ "Get", "all", "resources", ":", "param", "include_deactivated", ":", "Include", "deactivated", "resources", "in", "response" ]
train
https://github.com/openpermissions/perch/blob/36d78994133918f3c52c187f19e50132960a0156/perch/model.py#L199-L211
openpermissions/perch
perch/model.py
Document.validate_state_transition
def validate_state_transition(self, user, start_state, end_state, **kwargs): """ Validate whether user can transition resource from start state to end state :param user :param start_state :param end_state :return: bool """ if start_state == end_state: ...
python
def validate_state_transition(self, user, start_state, end_state, **kwargs): """ Validate whether user can transition resource from start state to end state :param user :param start_state :param end_state :return: bool """ if start_state == end_state: ...
[ "def", "validate_state_transition", "(", "self", ",", "user", ",", "start_state", ",", "end_state", ",", "*", "*", "kwargs", ")", ":", "if", "start_state", "==", "end_state", ":", "raise", "Return", "(", "True", ")", "transitions", "=", "self", ".", "state...
Validate whether user can transition resource from start state to end state :param user :param start_state :param end_state :return: bool
[ "Validate", "whether", "user", "can", "transition", "resource", "from", "start", "state", "to", "end", "state", ":", "param", "user", ":", "param", "start_state", ":", "param", "end_state", ":", "return", ":", "bool" ]
train
https://github.com/openpermissions/perch/blob/36d78994133918f3c52c187f19e50132960a0156/perch/model.py#L246-L267
openpermissions/perch
perch/model.py
Document._save
def _save(self): """ Save the resource It's better to use the create, updated & delete methods intsead of modifying an instance and calling save, because then we call the can_create, can_update & can_delete methods to check whether a user is permitted to make the changes...
python
def _save(self): """ Save the resource It's better to use the create, updated & delete methods intsead of modifying an instance and calling save, because then we call the can_create, can_update & can_delete methods to check whether a user is permitted to make the changes...
[ "def", "_save", "(", "self", ")", ":", "yield", "self", ".", "validate", "(", ")", "db", "=", "self", ".", "db_client", "(", ")", "saved", "=", "yield", "db", ".", "save_doc", "(", "self", ".", "_resource", ")", "# Allow couch to create Document IDs", "i...
Save the resource It's better to use the create, updated & delete methods intsead of modifying an instance and calling save, because then we call the can_create, can_update & can_delete methods to check whether a user is permitted to make the changes.
[ "Save", "the", "resource" ]
train
https://github.com/openpermissions/perch/blob/36d78994133918f3c52c187f19e50132960a0156/perch/model.py#L321-L337
openpermissions/perch
perch/model.py
Document.save_subresource
def save_subresource(self, subresource): """ Save the sub-resource NOTE: Currently assumes subresources are stored within a dictionary, keyed with the subresource's ID """ data = deepcopy(subresource._resource) data.pop('id', None) data.pop(self.resource_...
python
def save_subresource(self, subresource): """ Save the sub-resource NOTE: Currently assumes subresources are stored within a dictionary, keyed with the subresource's ID """ data = deepcopy(subresource._resource) data.pop('id', None) data.pop(self.resource_...
[ "def", "save_subresource", "(", "self", ",", "subresource", ")", ":", "data", "=", "deepcopy", "(", "subresource", ".", "_resource", ")", "data", ".", "pop", "(", "'id'", ",", "None", ")", "data", ".", "pop", "(", "self", ".", "resource_type", "+", "'_...
Save the sub-resource NOTE: Currently assumes subresources are stored within a dictionary, keyed with the subresource's ID
[ "Save", "the", "sub", "-", "resource" ]
train
https://github.com/openpermissions/perch/blob/36d78994133918f3c52c187f19e50132960a0156/perch/model.py#L340-L355
openpermissions/perch
perch/model.py
Document.delete
def delete(self, user): """Delete a resource""" if user: can_delete = yield self.can_delete(user) else: can_delete = False if not can_delete: raise exceptions.Unauthorized('User may not delete the resource') doc = { '_id': self.id...
python
def delete(self, user): """Delete a resource""" if user: can_delete = yield self.can_delete(user) else: can_delete = False if not can_delete: raise exceptions.Unauthorized('User may not delete the resource') doc = { '_id': self.id...
[ "def", "delete", "(", "self", ",", "user", ")", ":", "if", "user", ":", "can_delete", "=", "yield", "self", ".", "can_delete", "(", "user", ")", "else", ":", "can_delete", "=", "False", "if", "not", "can_delete", ":", "raise", "exceptions", ".", "Unaut...
Delete a resource
[ "Delete", "a", "resource" ]
train
https://github.com/openpermissions/perch/blob/36d78994133918f3c52c187f19e50132960a0156/perch/model.py#L358-L381
openpermissions/perch
perch/model.py
Document.delete_subresource
def delete_subresource(self, subresource): """ Delete the sub-resource NOTE: Currently assumes subresources are stored within a dictionary, keyed with the subresource's ID """ subresources = getattr(self, subresource.parent_key, {}) del subresources[subresource.i...
python
def delete_subresource(self, subresource): """ Delete the sub-resource NOTE: Currently assumes subresources are stored within a dictionary, keyed with the subresource's ID """ subresources = getattr(self, subresource.parent_key, {}) del subresources[subresource.i...
[ "def", "delete_subresource", "(", "self", ",", "subresource", ")", ":", "subresources", "=", "getattr", "(", "self", ",", "subresource", ".", "parent_key", ",", "{", "}", ")", "del", "subresources", "[", "subresource", ".", "id", "]", "yield", "self", ".",...
Delete the sub-resource NOTE: Currently assumes subresources are stored within a dictionary, keyed with the subresource's ID
[ "Delete", "the", "sub", "-", "resource" ]
train
https://github.com/openpermissions/perch/blob/36d78994133918f3c52c187f19e50132960a0156/perch/model.py#L384-L393
openpermissions/perch
perch/model.py
Document.clean
def clean(self): """Remove internal fields""" doc = self._resource result = {k: v for k, v in doc.iteritems() if k not in self.internal_fields} if '_id' in doc and 'id' not in result: result['id'] = doc['_id'] return result
python
def clean(self): """Remove internal fields""" doc = self._resource result = {k: v for k, v in doc.iteritems() if k not in self.internal_fields} if '_id' in doc and 'id' not in result: result['id'] = doc['_id'] return result
[ "def", "clean", "(", "self", ")", ":", "doc", "=", "self", ".", "_resource", "result", "=", "{", "k", ":", "v", "for", "k", ",", "v", "in", "doc", ".", "iteritems", "(", ")", "if", "k", "not", "in", "self", ".", "internal_fields", "}", "if", "'...
Remove internal fields
[ "Remove", "internal", "fields" ]
train
https://github.com/openpermissions/perch/blob/36d78994133918f3c52c187f19e50132960a0156/perch/model.py#L395-L404
openpermissions/perch
perch/model.py
Document.state
def state(self): """Get the Document's state""" state = self._resource.get('state', self.default_state) if state in State: return state else: return getattr(State, state)
python
def state(self): """Get the Document's state""" state = self._resource.get('state', self.default_state) if state in State: return state else: return getattr(State, state)
[ "def", "state", "(", "self", ")", ":", "state", "=", "self", ".", "_resource", ".", "get", "(", "'state'", ",", "self", ".", "default_state", ")", "if", "state", "in", "State", ":", "return", "state", "else", ":", "return", "getattr", "(", "State", "...
Get the Document's state
[ "Get", "the", "Document", "s", "state" ]
train
https://github.com/openpermissions/perch/blob/36d78994133918f3c52c187f19e50132960a0156/perch/model.py#L433-L440
openpermissions/perch
perch/model.py
SubResource.get_parent
def get_parent(self): """ Get the parent resource from the database The get, create & update methods will populate the parent for you. Use this method in the cases where parent has not been populated. """ if not self._parent: self._parent = yield self.parent_...
python
def get_parent(self): """ Get the parent resource from the database The get, create & update methods will populate the parent for you. Use this method in the cases where parent has not been populated. """ if not self._parent: self._parent = yield self.parent_...
[ "def", "get_parent", "(", "self", ")", ":", "if", "not", "self", ".", "_parent", ":", "self", ".", "_parent", "=", "yield", "self", ".", "parent_resource", ".", "get", "(", "self", ".", "parent_id", ")", "raise", "Return", "(", "self", ".", "_parent", ...
Get the parent resource from the database The get, create & update methods will populate the parent for you. Use this method in the cases where parent has not been populated.
[ "Get", "the", "parent", "resource", "from", "the", "database" ]
train
https://github.com/openpermissions/perch/blob/36d78994133918f3c52c187f19e50132960a0156/perch/model.py#L469-L479
openpermissions/perch
perch/model.py
SubResource.parent_resources
def parent_resources(cls): """Get a list of parent resources, starting from the Document""" parent = cls.parent_resource parents = [parent] try: while True: parent = parent.parent_resource parents.append(parent) except AttributeError: ...
python
def parent_resources(cls): """Get a list of parent resources, starting from the Document""" parent = cls.parent_resource parents = [parent] try: while True: parent = parent.parent_resource parents.append(parent) except AttributeError: ...
[ "def", "parent_resources", "(", "cls", ")", ":", "parent", "=", "cls", ".", "parent_resource", "parents", "=", "[", "parent", "]", "try", ":", "while", "True", ":", "parent", "=", "parent", ".", "parent_resource", "parents", ".", "append", "(", "parent", ...
Get a list of parent resources, starting from the Document
[ "Get", "a", "list", "of", "parent", "resources", "starting", "from", "the", "Document" ]
train
https://github.com/openpermissions/perch/blob/36d78994133918f3c52c187f19e50132960a0156/perch/model.py#L482-L495
openpermissions/perch
perch/model.py
SubResource.create
def create(cls, user, **kwargs): """If parent resource is not an editable state, should not be able to create.""" parent_id = kwargs.get(cls.parent_resource.resource_type + '_id') try: parent = yield cls.parent_resource.get(parent_id) except couch.NotFound: msg = ...
python
def create(cls, user, **kwargs): """If parent resource is not an editable state, should not be able to create.""" parent_id = kwargs.get(cls.parent_resource.resource_type + '_id') try: parent = yield cls.parent_resource.get(parent_id) except couch.NotFound: msg = ...
[ "def", "create", "(", "cls", ",", "user", ",", "*", "*", "kwargs", ")", ":", "parent_id", "=", "kwargs", ".", "get", "(", "cls", ".", "parent_resource", ".", "resource_type", "+", "'_id'", ")", "try", ":", "parent", "=", "yield", "cls", ".", "parent_...
If parent resource is not an editable state, should not be able to create.
[ "If", "parent", "resource", "is", "not", "an", "editable", "state", "should", "not", "be", "able", "to", "create", "." ]
train
https://github.com/openpermissions/perch/blob/36d78994133918f3c52c187f19e50132960a0156/perch/model.py#L520-L538
openpermissions/perch
perch/model.py
SubResource.update
def update(self, user, **kwargs): """If parent resource is not an editable state, should not be able to update""" yield self.get_parent() if not self.parent.editable: err = 'Cannot update child of {} resource'.format(self.parent.state.name) raise exceptions.Unauthorized(...
python
def update(self, user, **kwargs): """If parent resource is not an editable state, should not be able to update""" yield self.get_parent() if not self.parent.editable: err = 'Cannot update child of {} resource'.format(self.parent.state.name) raise exceptions.Unauthorized(...
[ "def", "update", "(", "self", ",", "user", ",", "*", "*", "kwargs", ")", ":", "yield", "self", ".", "get_parent", "(", ")", "if", "not", "self", ".", "parent", ".", "editable", ":", "err", "=", "'Cannot update child of {} resource'", ".", "format", "(", ...
If parent resource is not an editable state, should not be able to update
[ "If", "parent", "resource", "is", "not", "an", "editable", "state", "should", "not", "be", "able", "to", "update" ]
train
https://github.com/openpermissions/perch/blob/36d78994133918f3c52c187f19e50132960a0156/perch/model.py#L541-L549
openpermissions/perch
perch/model.py
SubResource._save
def _save(self): """Save the sub-resource within the parent resource""" yield self.validate() try: self._parent = yield self.parent_resource.get(self.parent_id) except couch.NotFound: msg = '{}_id {} not found'.format( self.parent_resource.resourc...
python
def _save(self): """Save the sub-resource within the parent resource""" yield self.validate() try: self._parent = yield self.parent_resource.get(self.parent_id) except couch.NotFound: msg = '{}_id {} not found'.format( self.parent_resource.resourc...
[ "def", "_save", "(", "self", ")", ":", "yield", "self", ".", "validate", "(", ")", "try", ":", "self", ".", "_parent", "=", "yield", "self", ".", "parent_resource", ".", "get", "(", "self", ".", "parent_id", ")", "except", "couch", ".", "NotFound", "...
Save the sub-resource within the parent resource
[ "Save", "the", "sub", "-", "resource", "within", "the", "parent", "resource" ]
train
https://github.com/openpermissions/perch/blob/36d78994133918f3c52c187f19e50132960a0156/perch/model.py#L552-L564
openpermissions/perch
perch/model.py
SubResource.get
def get(cls, resource_id, include_deactivated=False): """ Get a resource :param resource_id: the resource ID :param include_deactivated: Include deactivated resources in response :returns: a SubResource instance :raises: SocketError, CouchException """ if...
python
def get(cls, resource_id, include_deactivated=False): """ Get a resource :param resource_id: the resource ID :param include_deactivated: Include deactivated resources in response :returns: a SubResource instance :raises: SocketError, CouchException """ if...
[ "def", "get", "(", "cls", ",", "resource_id", ",", "include_deactivated", "=", "False", ")", ":", "if", "include_deactivated", ":", "resource", "=", "yield", "cls", ".", "view", ".", "first", "(", "key", "=", "resource_id", ",", "include_docs", "=", "True"...
Get a resource :param resource_id: the resource ID :param include_deactivated: Include deactivated resources in response :returns: a SubResource instance :raises: SocketError, CouchException
[ "Get", "a", "resource" ]
train
https://github.com/openpermissions/perch/blob/36d78994133918f3c52c187f19e50132960a0156/perch/model.py#L568-L583
openpermissions/perch
perch/model.py
SubResource.all
def all(cls, include_deactivated=False): """ Get all sub-resources :param include_deactivated: Include deactivated resources in response :returns: list of SubResource instances :raises: SocketError, CouchException """ if include_deactivated: resources...
python
def all(cls, include_deactivated=False): """ Get all sub-resources :param include_deactivated: Include deactivated resources in response :returns: list of SubResource instances :raises: SocketError, CouchException """ if include_deactivated: resources...
[ "def", "all", "(", "cls", ",", "include_deactivated", "=", "False", ")", ":", "if", "include_deactivated", ":", "resources", "=", "yield", "cls", ".", "view", ".", "get", "(", "include_docs", "=", "True", ")", "else", ":", "resources", "=", "yield", "cls...
Get all sub-resources :param include_deactivated: Include deactivated resources in response :returns: list of SubResource instances :raises: SocketError, CouchException
[ "Get", "all", "sub", "-", "resources", ":", "param", "include_deactivated", ":", "Include", "deactivated", "resources", "in", "response" ]
train
https://github.com/openpermissions/perch/blob/36d78994133918f3c52c187f19e50132960a0156/perch/model.py#L587-L606
openpermissions/perch
perch/model.py
SubResource.delete
def delete(self, user): """Delete a sub-resource""" if user: can_delete = yield self.can_delete(user) else: can_delete = False if not can_delete: raise exceptions.Unauthorized('User may not delete the resource') try: parent = yiel...
python
def delete(self, user): """Delete a sub-resource""" if user: can_delete = yield self.can_delete(user) else: can_delete = False if not can_delete: raise exceptions.Unauthorized('User may not delete the resource') try: parent = yiel...
[ "def", "delete", "(", "self", ",", "user", ")", ":", "if", "user", ":", "can_delete", "=", "yield", "self", ".", "can_delete", "(", "user", ")", "else", ":", "can_delete", "=", "False", "if", "not", "can_delete", ":", "raise", "exceptions", ".", "Unaut...
Delete a sub-resource
[ "Delete", "a", "sub", "-", "resource" ]
train
https://github.com/openpermissions/perch/blob/36d78994133918f3c52c187f19e50132960a0156/perch/model.py#L609-L627
openpermissions/perch
perch/model.py
SubResource.state
def state(self): """ Get the SubResource state If the parents state has a higher priority, then it overrides the SubResource state ..note:: This assumes that self.parent is populated """ state = self._resource.get('state', self.default_state) if state no...
python
def state(self): """ Get the SubResource state If the parents state has a higher priority, then it overrides the SubResource state ..note:: This assumes that self.parent is populated """ state = self._resource.get('state', self.default_state) if state no...
[ "def", "state", "(", "self", ")", ":", "state", "=", "self", ".", "_resource", ".", "get", "(", "'state'", ",", "self", ".", "default_state", ")", "if", "state", "not", "in", "State", ":", "state", "=", "getattr", "(", "State", ",", "state", ")", "...
Get the SubResource state If the parents state has a higher priority, then it overrides the SubResource state ..note:: This assumes that self.parent is populated
[ "Get", "the", "SubResource", "state" ]
train
https://github.com/openpermissions/perch/blob/36d78994133918f3c52c187f19e50132960a0156/perch/model.py#L630-L648
veltzer/pydmt
pydmt/core/cache.py
Cache.list_sig_ok
def list_sig_ok(self, signature: str): """ return if a signature is indeed a list and all objects are intact :param signature: :return: """ list_filename = self.get_list_filename(signature) if list_filename not in self.name_cache: return False ...
python
def list_sig_ok(self, signature: str): """ return if a signature is indeed a list and all objects are intact :param signature: :return: """ list_filename = self.get_list_filename(signature) if list_filename not in self.name_cache: return False ...
[ "def", "list_sig_ok", "(", "self", ",", "signature", ":", "str", ")", ":", "list_filename", "=", "self", ".", "get_list_filename", "(", "signature", ")", "if", "list_filename", "not", "in", "self", ".", "name_cache", ":", "return", "False", "for", "_object_n...
return if a signature is indeed a list and all objects are intact :param signature: :return:
[ "return", "if", "a", "signature", "is", "indeed", "a", "list", "and", "all", "objects", "are", "intact", ":", "param", "signature", ":", ":", "return", ":" ]
train
https://github.com/veltzer/pydmt/blob/11d3db7ea079756c1e4137d3dd8a2cabbcc98bf7/pydmt/core/cache.py#L29-L41
ktdreyer/txproductpages
txproductpages/release.py
Release.schedule_tasks
def schedule_tasks(self): """ Get all the tasks for a release. :param release_id: int, release id number. :returns: deferred that when fired returns a list of Munch (dict-like) objects representing all tasks. """ url = 'api/v6/releases/%d/schedule-tasks...
python
def schedule_tasks(self): """ Get all the tasks for a release. :param release_id: int, release id number. :returns: deferred that when fired returns a list of Munch (dict-like) objects representing all tasks. """ url = 'api/v6/releases/%d/schedule-tasks...
[ "def", "schedule_tasks", "(", "self", ")", ":", "url", "=", "'api/v6/releases/%d/schedule-tasks'", "%", "self", ".", "id", "tasks", "=", "yield", "self", ".", "connection", ".", "_get", "(", "url", ")", "defer", ".", "returnValue", "(", "munchify", "(", "t...
Get all the tasks for a release. :param release_id: int, release id number. :returns: deferred that when fired returns a list of Munch (dict-like) objects representing all tasks.
[ "Get", "all", "the", "tasks", "for", "a", "release", "." ]
train
https://github.com/ktdreyer/txproductpages/blob/96c85c498c0eef1d37cddb031db32e8b885fcbd9/txproductpages/release.py#L11-L21
ktdreyer/txproductpages
txproductpages/release.py
Release.task_date
def task_date(self, task_re): """ Get a datetime.date object for the last task that matches a regex. :param task_re: regex, eg re.compile('Development Freeze'). See txproductpages.milestones for some useful regex constants to pass in here. :return...
python
def task_date(self, task_re): """ Get a datetime.date object for the last task that matches a regex. :param task_re: regex, eg re.compile('Development Freeze'). See txproductpages.milestones for some useful regex constants to pass in here. :return...
[ "def", "task_date", "(", "self", ",", "task_re", ")", ":", "tasks", "=", "yield", "self", ".", "schedule_tasks", "(", ")", "task_date", "=", "None", "for", "task", "in", "tasks", ":", "if", "task_re", ".", "match", "(", "task", "[", "'name'", "]", ")...
Get a datetime.date object for the last task that matches a regex. :param task_re: regex, eg re.compile('Development Freeze'). See txproductpages.milestones for some useful regex constants to pass in here. :returns: deferred that when fired returns a date...
[ "Get", "a", "datetime", ".", "date", "object", "for", "the", "last", "task", "that", "matches", "a", "regex", "." ]
train
https://github.com/ktdreyer/txproductpages/blob/96c85c498c0eef1d37cddb031db32e8b885fcbd9/txproductpages/release.py#L24-L41
chrisnorman7/confmanager
confmanager/confframe.py
ConfFrame.Show
def Show(self, value = True): """Before we show the frame, we need to add the finishing touches:""" self.Bind(wx.EVT_BUTTON, lambda event: self.Close(True), wx.Button(self.pane, label = '&Cancel')) # Add a cancel button ok = wx.Button(self.pane, label = '&OK') # Add the ok button ok.SetDefault() # When the ...
python
def Show(self, value = True): """Before we show the frame, we need to add the finishing touches:""" self.Bind(wx.EVT_BUTTON, lambda event: self.Close(True), wx.Button(self.pane, label = '&Cancel')) # Add a cancel button ok = wx.Button(self.pane, label = '&OK') # Add the ok button ok.SetDefault() # When the ...
[ "def", "Show", "(", "self", ",", "value", "=", "True", ")", ":", "self", ".", "Bind", "(", "wx", ".", "EVT_BUTTON", ",", "lambda", "event", ":", "self", ".", "Close", "(", "True", ")", ",", "wx", ".", "Button", "(", "self", ".", "pane", ",", "l...
Before we show the frame, we need to add the finishing touches:
[ "Before", "we", "show", "the", "frame", "we", "need", "to", "add", "the", "finishing", "touches", ":" ]
train
https://github.com/chrisnorman7/confmanager/blob/54a3ce0b596f9da32ae82fd4ff4cb46bb1cf23b1/confmanager/confframe.py#L42-L53
chrisnorman7/confmanager
confmanager/confframe.py
ConfFrame.apply
def apply(self, event = None): """Before self.onOk closes the window, it calls this function to sync the config changes from the GUI back to self.config.""" for section in self.config.sections(): # Run through the sections to check all the option values: for option, o in self.config.config[section].items(...
python
def apply(self, event = None): """Before self.onOk closes the window, it calls this function to sync the config changes from the GUI back to self.config.""" for section in self.config.sections(): # Run through the sections to check all the option values: for option, o in self.config.config[section].items(...
[ "def", "apply", "(", "self", ",", "event", "=", "None", ")", ":", "for", "section", "in", "self", ".", "config", ".", "sections", "(", ")", ":", "# Run through the sections to check all the option values:\r", "for", "option", ",", "o", "in", "self", ".", "co...
Before self.onOk closes the window, it calls this function to sync the config changes from the GUI back to self.config.
[ "Before", "self", ".", "onOk", "closes", "the", "window", "it", "calls", "this", "function", "to", "sync", "the", "config", "changes", "from", "the", "GUI", "back", "to", "self", ".", "config", "." ]
train
https://github.com/chrisnorman7/confmanager/blob/54a3ce0b596f9da32ae82fd4ff4cb46bb1cf23b1/confmanager/confframe.py#L55-L78
chrisnorman7/confmanager
confmanager/confframe.py
ConfFrame.displayError
def displayError(self, section, option, message): """ Complain about something that was entered into a field on the notebook. Made this into a seporate function, because it was used more than once. displayError(self, section, option, message) Arguments are like those given to ConfManager.get, wit...
python
def displayError(self, section, option, message): """ Complain about something that was entered into a field on the notebook. Made this into a seporate function, because it was used more than once. displayError(self, section, option, message) Arguments are like those given to ConfManager.get, wit...
[ "def", "displayError", "(", "self", ",", "section", ",", "option", ",", "message", ")", ":", "self", ".", "notebook", ".", "SetSelection", "(", "self", ".", "config", ".", "sections", "(", ")", ".", "index", "(", "section", ")", ")", "# Jump pages, using...
Complain about something that was entered into a field on the notebook. Made this into a seporate function, because it was used more than once. displayError(self, section, option, message) Arguments are like those given to ConfManager.get, with the additional message as text. Shows message as an...
[ "Complain", "about", "something", "that", "was", "entered", "into", "a", "field", "on", "the", "notebook", ".", "Made", "this", "into", "a", "seporate", "function", "because", "it", "was", "used", "more", "than", "once", ".", "displayError", "(", "self", "...
train
https://github.com/chrisnorman7/confmanager/blob/54a3ce0b596f9da32ae82fd4ff4cb46bb1cf23b1/confmanager/confframe.py#L85-L98
alexhayes/django-toolkit
django_toolkit/dict_helper.py
dict_merge
def dict_merge(a, b): """ Recursively merge dicts. recursively merges dict's. not just simple a['key'] = b['key'], if both a and bhave a key who's value is a dict then dict_merge is called on both values and the result stored in the returned dictionary. @see http://www.xormedia.com/rec...
python
def dict_merge(a, b): """ Recursively merge dicts. recursively merges dict's. not just simple a['key'] = b['key'], if both a and bhave a key who's value is a dict then dict_merge is called on both values and the result stored in the returned dictionary. @see http://www.xormedia.com/rec...
[ "def", "dict_merge", "(", "a", ",", "b", ")", ":", "if", "not", "isinstance", "(", "b", ",", "dict", ")", ":", "return", "b", "result", "=", "deepcopy", "(", "a", ")", "for", "k", ",", "v", "in", "b", ".", "iteritems", "(", ")", ":", "if", "k...
Recursively merge dicts. recursively merges dict's. not just simple a['key'] = b['key'], if both a and bhave a key who's value is a dict then dict_merge is called on both values and the result stored in the returned dictionary. @see http://www.xormedia.com/recursively-merge-dictionaries-in-pyt...
[ "Recursively", "merge", "dicts", ".", "recursively", "merges", "dict", "s", ".", "not", "just", "simple", "a", "[", "key", "]", "=", "b", "[", "key", "]", "if", "both", "a", "and", "bhave", "a", "key", "who", "s", "value", "is", "a", "dict", "then"...
train
https://github.com/alexhayes/django-toolkit/blob/b64106392fad596defc915b8235fe6e1d0013b5b/django_toolkit/dict_helper.py#L3-L21
jwkvam/piecharts
piecharts/__init__.py
_detect_notebook
def _detect_notebook(): """ This isn't 100% correct but seems good enough Returns ------- bool True if it detects this is a notebook, otherwise False. """ try: from IPython import get_ipython from ipykernel import zmqshell except ImportError: return False...
python
def _detect_notebook(): """ This isn't 100% correct but seems good enough Returns ------- bool True if it detects this is a notebook, otherwise False. """ try: from IPython import get_ipython from ipykernel import zmqshell except ImportError: return False...
[ "def", "_detect_notebook", "(", ")", ":", "try", ":", "from", "IPython", "import", "get_ipython", "from", "ipykernel", "import", "zmqshell", "except", "ImportError", ":", "return", "False", "kernel", "=", "get_ipython", "(", ")", "return", "isinstance", "(", "...
This isn't 100% correct but seems good enough Returns ------- bool True if it detects this is a notebook, otherwise False.
[ "This", "isn", "t", "100%", "correct", "but", "seems", "good", "enough" ]
train
https://github.com/jwkvam/piecharts/blob/b6cd6102c01f0761c991adb2ba949128aebeb818/piecharts/__init__.py#L41-L56
jwkvam/piecharts
piecharts/__init__.py
json_conversion
def json_conversion(obj): """Encode additional objects to JSON.""" try: # numpy isn't an explicit dependency of bowtie # so we can't assume it's available import numpy as np if isinstance(obj, (np.ndarray, np.generic)): return obj.tolist() except ImportError: ...
python
def json_conversion(obj): """Encode additional objects to JSON.""" try: # numpy isn't an explicit dependency of bowtie # so we can't assume it's available import numpy as np if isinstance(obj, (np.ndarray, np.generic)): return obj.tolist() except ImportError: ...
[ "def", "json_conversion", "(", "obj", ")", ":", "try", ":", "# numpy isn't an explicit dependency of bowtie", "# so we can't assume it's available", "import", "numpy", "as", "np", "if", "isinstance", "(", "obj", ",", "(", "np", ".", "ndarray", ",", "np", ".", "gen...
Encode additional objects to JSON.
[ "Encode", "additional", "objects", "to", "JSON", "." ]
train
https://github.com/jwkvam/piecharts/blob/b6cd6102c01f0761c991adb2ba949128aebeb818/piecharts/__init__.py#L99-L121
jwkvam/piecharts
piecharts/__init__.py
_simple_chart
def _simple_chart(x=None, y=None, name=None, color=None, width=None, dash=None, opacity=None, mode='lines+markers', yaxis=1, fill=None, text='', style='line', markersize=6): """Draws connected dots. Parameters ---------- x : array-like, optional y : array-like, o...
python
def _simple_chart(x=None, y=None, name=None, color=None, width=None, dash=None, opacity=None, mode='lines+markers', yaxis=1, fill=None, text='', style='line', markersize=6): """Draws connected dots. Parameters ---------- x : array-like, optional y : array-like, o...
[ "def", "_simple_chart", "(", "x", "=", "None", ",", "y", "=", "None", ",", "name", "=", "None", ",", "color", "=", "None", ",", "width", "=", "None", ",", "dash", "=", "None", ",", "opacity", "=", "None", ",", "mode", "=", "'lines+markers'", ",", ...
Draws connected dots. Parameters ---------- x : array-like, optional y : array-like, optional label : array-like, optional Returns ------- Chart
[ "Draws", "connected", "dots", "." ]
train
https://github.com/jwkvam/piecharts/blob/b6cd6102c01f0761c991adb2ba949128aebeb818/piecharts/__init__.py#L548-L594
jwkvam/piecharts
piecharts/__init__.py
Chart.xlim
def xlim(self, low, high): """Set xaxis limits Parameters ---------- low : number high : number Returns ------- Chart """ self.chart['xAxis'][0]['min'] = low self.chart['xAxis'][0]['max'] = high return self
python
def xlim(self, low, high): """Set xaxis limits Parameters ---------- low : number high : number Returns ------- Chart """ self.chart['xAxis'][0]['min'] = low self.chart['xAxis'][0]['max'] = high return self
[ "def", "xlim", "(", "self", ",", "low", ",", "high", ")", ":", "self", ".", "chart", "[", "'xAxis'", "]", "[", "0", "]", "[", "'min'", "]", "=", "low", "self", ".", "chart", "[", "'xAxis'", "]", "[", "0", "]", "[", "'max'", "]", "=", "high", ...
Set xaxis limits Parameters ---------- low : number high : number Returns ------- Chart
[ "Set", "xaxis", "limits" ]
train
https://github.com/jwkvam/piecharts/blob/b6cd6102c01f0761c991adb2ba949128aebeb818/piecharts/__init__.py#L372-L387
jwkvam/piecharts
piecharts/__init__.py
Chart.ylim
def ylim(self, low, high): """Set yaxis limits Parameters ---------- low : number high : number index : int, optional Returns ------- Chart """ self.chart['yAxis'][0]['min'] = low self.chart['yAxis'][0]['max'] = high ...
python
def ylim(self, low, high): """Set yaxis limits Parameters ---------- low : number high : number index : int, optional Returns ------- Chart """ self.chart['yAxis'][0]['min'] = low self.chart['yAxis'][0]['max'] = high ...
[ "def", "ylim", "(", "self", ",", "low", ",", "high", ")", ":", "self", ".", "chart", "[", "'yAxis'", "]", "[", "0", "]", "[", "'min'", "]", "=", "low", "self", ".", "chart", "[", "'yAxis'", "]", "[", "0", "]", "[", "'max'", "]", "=", "high", ...
Set yaxis limits Parameters ---------- low : number high : number index : int, optional Returns ------- Chart
[ "Set", "yaxis", "limits" ]
train
https://github.com/jwkvam/piecharts/blob/b6cd6102c01f0761c991adb2ba949128aebeb818/piecharts/__init__.py#L389-L405
treycucco/bidon
bidon/util/transform.py
get_val
def get_val(source, extract=None, transform=None): """Extract a value from a source, transform and return it.""" if extract is None: raw_value = source else: raw_value = extract(source) if transform is None: return raw_value else: return transform(raw_value)
python
def get_val(source, extract=None, transform=None): """Extract a value from a source, transform and return it.""" if extract is None: raw_value = source else: raw_value = extract(source) if transform is None: return raw_value else: return transform(raw_value)
[ "def", "get_val", "(", "source", ",", "extract", "=", "None", ",", "transform", "=", "None", ")", ":", "if", "extract", "is", "None", ":", "raw_value", "=", "source", "else", ":", "raw_value", "=", "extract", "(", "source", ")", "if", "transform", "is"...
Extract a value from a source, transform and return it.
[ "Extract", "a", "value", "from", "a", "source", "transform", "and", "return", "it", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/util/transform.py#L10-L20
treycucco/bidon
bidon/util/transform.py
get_obj
def get_obj(source, extract=None, child_transform=None, transform=None): """Maps an object based on a key->extractor child_transform dict.""" if extract is None: obj = source else: obj = extract(source) if child_transform is None: data = obj else: data = dict() for k, v in child_transform...
python
def get_obj(source, extract=None, child_transform=None, transform=None): """Maps an object based on a key->extractor child_transform dict.""" if extract is None: obj = source else: obj = extract(source) if child_transform is None: data = obj else: data = dict() for k, v in child_transform...
[ "def", "get_obj", "(", "source", ",", "extract", "=", "None", ",", "child_transform", "=", "None", ",", "transform", "=", "None", ")", ":", "if", "extract", "is", "None", ":", "obj", "=", "source", "else", ":", "obj", "=", "extract", "(", "source", "...
Maps an object based on a key->extractor child_transform dict.
[ "Maps", "an", "object", "based", "on", "a", "key", "-", ">", "extractor", "child_transform", "dict", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/util/transform.py#L23-L43
treycucco/bidon
bidon/util/transform.py
get_lst
def get_lst(source, extract=None, transform=None): """Extract a list from a source, transform each item, and return the result.""" if extract is None: raw_list = source else: raw_list = extract(source) if transform is None: return raw_list else: tlist = [] for idx, item in enumerate(raw_l...
python
def get_lst(source, extract=None, transform=None): """Extract a list from a source, transform each item, and return the result.""" if extract is None: raw_list = source else: raw_list = extract(source) if transform is None: return raw_list else: tlist = [] for idx, item in enumerate(raw_l...
[ "def", "get_lst", "(", "source", ",", "extract", "=", "None", ",", "transform", "=", "None", ")", ":", "if", "extract", "is", "None", ":", "raw_list", "=", "source", "else", ":", "raw_list", "=", "extract", "(", "source", ")", "if", "transform", "is", ...
Extract a list from a source, transform each item, and return the result.
[ "Extract", "a", "list", "from", "a", "source", "transform", "each", "item", "and", "return", "the", "result", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/util/transform.py#L46-L62
treycucco/bidon
bidon/util/transform.py
get_composition
def get_composition(source, *fxns): """Compose several extractors together, on a source.""" val = source for fxn in fxns: val = fxn(val) return val
python
def get_composition(source, *fxns): """Compose several extractors together, on a source.""" val = source for fxn in fxns: val = fxn(val) return val
[ "def", "get_composition", "(", "source", ",", "*", "fxns", ")", ":", "val", "=", "source", "for", "fxn", "in", "fxns", ":", "val", "=", "fxn", "(", "val", ")", "return", "val" ]
Compose several extractors together, on a source.
[ "Compose", "several", "extractors", "together", "on", "a", "source", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/util/transform.py#L65-L70
treycucco/bidon
bidon/util/transform.py
get_flattened
def get_flattened(dct, names, path_joiner="_"): """Flatten a child dicts, whose resulting keys are joined by path_joiner. E.G. { "valuation": { "currency": "USD", "amount": "100" } } -> { "valuation_currency": "USD", "valuation_amount": "100" } """ new_dct = dict() for key, val in dct.items(): if ...
python
def get_flattened(dct, names, path_joiner="_"): """Flatten a child dicts, whose resulting keys are joined by path_joiner. E.G. { "valuation": { "currency": "USD", "amount": "100" } } -> { "valuation_currency": "USD", "valuation_amount": "100" } """ new_dct = dict() for key, val in dct.items(): if ...
[ "def", "get_flattened", "(", "dct", ",", "names", ",", "path_joiner", "=", "\"_\"", ")", ":", "new_dct", "=", "dict", "(", ")", "for", "key", ",", "val", "in", "dct", ".", "items", "(", ")", ":", "if", "key", "in", "names", ":", "child", "=", "{"...
Flatten a child dicts, whose resulting keys are joined by path_joiner. E.G. { "valuation": { "currency": "USD", "amount": "100" } } -> { "valuation_currency": "USD", "valuation_amount": "100" }
[ "Flatten", "a", "child", "dicts", "whose", "resulting", "keys", "are", "joined", "by", "path_joiner", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/util/transform.py#L73-L86
treycucco/bidon
bidon/util/transform.py
get_hoisted
def get_hoisted(dct, child_name): """Pulls all of a child's keys up to the parent, with the names unchanged.""" child = dct[child_name] del dct[child_name] dct.update(child) return dct
python
def get_hoisted(dct, child_name): """Pulls all of a child's keys up to the parent, with the names unchanged.""" child = dct[child_name] del dct[child_name] dct.update(child) return dct
[ "def", "get_hoisted", "(", "dct", ",", "child_name", ")", ":", "child", "=", "dct", "[", "child_name", "]", "del", "dct", "[", "child_name", "]", "dct", ".", "update", "(", "child", ")", "return", "dct" ]
Pulls all of a child's keys up to the parent, with the names unchanged.
[ "Pulls", "all", "of", "a", "child", "s", "keys", "up", "to", "the", "parent", "with", "the", "names", "unchanged", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/util/transform.py#L89-L94
treycucco/bidon
bidon/util/transform.py
obj
def obj(extract=None, child_transform=None, transform=None): """Returns a partial of get_obj that only needs a source argument.""" return lambda source: get_obj(source, extract, child_transform, transform)
python
def obj(extract=None, child_transform=None, transform=None): """Returns a partial of get_obj that only needs a source argument.""" return lambda source: get_obj(source, extract, child_transform, transform)
[ "def", "obj", "(", "extract", "=", "None", ",", "child_transform", "=", "None", ",", "transform", "=", "None", ")", ":", "return", "lambda", "source", ":", "get_obj", "(", "source", ",", "extract", ",", "child_transform", ",", "transform", ")" ]
Returns a partial of get_obj that only needs a source argument.
[ "Returns", "a", "partial", "of", "get_obj", "that", "only", "needs", "a", "source", "argument", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/util/transform.py#L102-L104
treycucco/bidon
bidon/util/transform.py
get_xml_attr
def get_xml_attr(source, name, path=None): """Get the XML attribute with name from source. If path is not Mone, it will instead get the XML attribute with name from the child indicated by path. """ if path is None: return source.attrib[name] else: return get_xml_attr(get_xml_child(source, path), name)
python
def get_xml_attr(source, name, path=None): """Get the XML attribute with name from source. If path is not Mone, it will instead get the XML attribute with name from the child indicated by path. """ if path is None: return source.attrib[name] else: return get_xml_attr(get_xml_child(source, path), name)
[ "def", "get_xml_attr", "(", "source", ",", "name", ",", "path", "=", "None", ")", ":", "if", "path", "is", "None", ":", "return", "source", ".", "attrib", "[", "name", "]", "else", ":", "return", "get_xml_attr", "(", "get_xml_child", "(", "source", ","...
Get the XML attribute with name from source. If path is not Mone, it will instead get the XML attribute with name from the child indicated by path.
[ "Get", "the", "XML", "attribute", "with", "name", "from", "source", ".", "If", "path", "is", "not", "Mone", "it", "will", "instead", "get", "the", "XML", "attribute", "with", "name", "from", "the", "child", "indicated", "by", "path", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/util/transform.py#L127-L134
treycucco/bidon
bidon/util/transform.py
get_xml_text
def get_xml_text(source, path=None): """Get the text of the XML node. If path is not None, it will get the text of the descendant of source indicated by path. """ if path is None: return source.text else: return get_xml_text(get_xml_child(source, path))
python
def get_xml_text(source, path=None): """Get the text of the XML node. If path is not None, it will get the text of the descendant of source indicated by path. """ if path is None: return source.text else: return get_xml_text(get_xml_child(source, path))
[ "def", "get_xml_text", "(", "source", ",", "path", "=", "None", ")", ":", "if", "path", "is", "None", ":", "return", "source", ".", "text", "else", ":", "return", "get_xml_text", "(", "get_xml_child", "(", "source", ",", "path", ")", ")" ]
Get the text of the XML node. If path is not None, it will get the text of the descendant of source indicated by path.
[ "Get", "the", "text", "of", "the", "XML", "node", ".", "If", "path", "is", "not", "None", "it", "will", "get", "the", "text", "of", "the", "descendant", "of", "source", "indicated", "by", "path", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/util/transform.py#L137-L144
treycucco/bidon
bidon/util/transform.py
get_xml_child
def get_xml_child(source, path): """Get the first descendant of source identified by path. Path must be either a an xpath string, or a 2-tuple of (xpath, namespace_dict). """ if isinstance(path, (tuple, list)): return source.find(*path) else: return source.find(path)
python
def get_xml_child(source, path): """Get the first descendant of source identified by path. Path must be either a an xpath string, or a 2-tuple of (xpath, namespace_dict). """ if isinstance(path, (tuple, list)): return source.find(*path) else: return source.find(path)
[ "def", "get_xml_child", "(", "source", ",", "path", ")", ":", "if", "isinstance", "(", "path", ",", "(", "tuple", ",", "list", ")", ")", ":", "return", "source", ".", "find", "(", "*", "path", ")", "else", ":", "return", "source", ".", "find", "(",...
Get the first descendant of source identified by path. Path must be either a an xpath string, or a 2-tuple of (xpath, namespace_dict).
[ "Get", "the", "first", "descendant", "of", "source", "identified", "by", "path", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/util/transform.py#L147-L155
treycucco/bidon
bidon/util/transform.py
get_xml_children
def get_xml_children(source, path): """Get all the descendants of source identified by path. Path must be either a an xpath string, or a 2-tuple of (xpath, namespace_dict). """ if isinstance(path, (tuple, list)): return source.findall(*path) else: return source.findall(path)
python
def get_xml_children(source, path): """Get all the descendants of source identified by path. Path must be either a an xpath string, or a 2-tuple of (xpath, namespace_dict). """ if isinstance(path, (tuple, list)): return source.findall(*path) else: return source.findall(path)
[ "def", "get_xml_children", "(", "source", ",", "path", ")", ":", "if", "isinstance", "(", "path", ",", "(", "tuple", ",", "list", ")", ")", ":", "return", "source", ".", "findall", "(", "*", "path", ")", "else", ":", "return", "source", ".", "findall...
Get all the descendants of source identified by path. Path must be either a an xpath string, or a 2-tuple of (xpath, namespace_dict).
[ "Get", "all", "the", "descendants", "of", "source", "identified", "by", "path", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/util/transform.py#L158-L166
treycucco/bidon
bidon/util/transform.py
get_json_val
def get_json_val(source, path, *, ignore_bad_path=False): """Get the nested value identified by the json path, rooted at source.""" try: return JP.find(source, path) except JP.JSONPathError as ex: if ignore_bad_path: return None else: raise
python
def get_json_val(source, path, *, ignore_bad_path=False): """Get the nested value identified by the json path, rooted at source.""" try: return JP.find(source, path) except JP.JSONPathError as ex: if ignore_bad_path: return None else: raise
[ "def", "get_json_val", "(", "source", ",", "path", ",", "*", ",", "ignore_bad_path", "=", "False", ")", ":", "try", ":", "return", "JP", ".", "find", "(", "source", ",", "path", ")", "except", "JP", ".", "JSONPathError", "as", "ex", ":", "if", "ignor...
Get the nested value identified by the json path, rooted at source.
[ "Get", "the", "nested", "value", "identified", "by", "the", "json", "path", "rooted", "at", "source", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/util/transform.py#L189-L197
treycucco/bidon
bidon/util/transform.py
json_val
def json_val(path, *, ignore_bad_path=False): """Returns a partial of get_json_val that only needs a source argument.""" return lambda source: get_json_val(source, path, ignore_bad_path=ignore_bad_path)
python
def json_val(path, *, ignore_bad_path=False): """Returns a partial of get_json_val that only needs a source argument.""" return lambda source: get_json_val(source, path, ignore_bad_path=ignore_bad_path)
[ "def", "json_val", "(", "path", ",", "*", ",", "ignore_bad_path", "=", "False", ")", ":", "return", "lambda", "source", ":", "get_json_val", "(", "source", ",", "path", ",", "ignore_bad_path", "=", "ignore_bad_path", ")" ]
Returns a partial of get_json_val that only needs a source argument.
[ "Returns", "a", "partial", "of", "get_json_val", "that", "only", "needs", "a", "source", "argument", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/util/transform.py#L205-L207
FreshXOpenSource/wallaby-frontend-qt
wallaby/frontends/qt/reactor/threadedselect.py
install
def install(): """Configure the twisted mainloop to be run using the select() reactor. """ reactor = ThreadedSelectReactor() from twisted.internet.main import installReactor installReactor(reactor) return reactor
python
def install(): """Configure the twisted mainloop to be run using the select() reactor. """ reactor = ThreadedSelectReactor() from twisted.internet.main import installReactor installReactor(reactor) return reactor
[ "def", "install", "(", ")", ":", "reactor", "=", "ThreadedSelectReactor", "(", ")", "from", "twisted", ".", "internet", ".", "main", "import", "installReactor", "installReactor", "(", "reactor", ")", "return", "reactor" ]
Configure the twisted mainloop to be run using the select() reactor.
[ "Configure", "the", "twisted", "mainloop", "to", "be", "run", "using", "the", "select", "()", "reactor", "." ]
train
https://github.com/FreshXOpenSource/wallaby-frontend-qt/blob/eee70d0ec4ce34827f62a1654e28dbff8a8afb1a/wallaby/frontends/qt/reactor/threadedselect.py#L367-L373
FreshXOpenSource/wallaby-frontend-qt
wallaby/frontends/qt/reactor/threadedselect.py
ThreadedSelectReactor._doSelectInThread
def _doSelectInThread(self, timeout): """Run one iteration of the I/O monitor loop. This will run all selectables who had input or output readiness waiting for them. """ reads = self.reads writes = self.writes while 1: try: r, w, ignor...
python
def _doSelectInThread(self, timeout): """Run one iteration of the I/O monitor loop. This will run all selectables who had input or output readiness waiting for them. """ reads = self.reads writes = self.writes while 1: try: r, w, ignor...
[ "def", "_doSelectInThread", "(", "self", ",", "timeout", ")", ":", "reads", "=", "self", ".", "reads", "writes", "=", "self", ".", "writes", "while", "1", ":", "try", ":", "r", ",", "w", ",", "ignored", "=", "_select", "(", "reads", ".", "keys", "(...
Run one iteration of the I/O monitor loop. This will run all selectables who had input or output readiness waiting for them.
[ "Run", "one", "iteration", "of", "the", "I", "/", "O", "monitor", "loop", "." ]
train
https://github.com/FreshXOpenSource/wallaby-frontend-qt/blob/eee70d0ec4ce34827f62a1654e28dbff8a8afb1a/wallaby/frontends/qt/reactor/threadedselect.py#L159-L197
FreshXOpenSource/wallaby-frontend-qt
wallaby/frontends/qt/reactor/threadedselect.py
ThreadedSelectReactor.interleave
def interleave(self, waker, *args, **kw): """ interleave(waker) interleaves this reactor with the current application by moving the blocking parts of the reactor (select() in this case) to a separate thread. This is typically useful for integration with GUI applications ...
python
def interleave(self, waker, *args, **kw): """ interleave(waker) interleaves this reactor with the current application by moving the blocking parts of the reactor (select() in this case) to a separate thread. This is typically useful for integration with GUI applications ...
[ "def", "interleave", "(", "self", ",", "waker", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "self", ".", "startRunning", "(", "*", "args", ",", "*", "*", "kw", ")", "loop", "=", "self", ".", "_interleave", "(", ")", "def", "mainWaker", "(", ...
interleave(waker) interleaves this reactor with the current application by moving the blocking parts of the reactor (select() in this case) to a separate thread. This is typically useful for integration with GUI applications which have their own event loop already running. ...
[ "interleave", "(", "waker", ")", "interleaves", "this", "reactor", "with", "the", "current", "application", "by", "moving", "the", "blocking", "parts", "of", "the", "reactor", "(", "select", "()", "in", "this", "case", ")", "to", "a", "separate", "thread", ...
train
https://github.com/FreshXOpenSource/wallaby-frontend-qt/blob/eee70d0ec4ce34827f62a1654e28dbff8a8afb1a/wallaby/frontends/qt/reactor/threadedselect.py#L248-L266
FreshXOpenSource/wallaby-frontend-qt
wallaby/frontends/qt/reactor/threadedselect.py
ThreadedSelectReactor.addReader
def addReader(self, reader): """Add a FileDescriptor for notification of data available to read. """ self._sendToThread(self.reads.__setitem__, reader, 1) self.wakeUp()
python
def addReader(self, reader): """Add a FileDescriptor for notification of data available to read. """ self._sendToThread(self.reads.__setitem__, reader, 1) self.wakeUp()
[ "def", "addReader", "(", "self", ",", "reader", ")", ":", "self", ".", "_sendToThread", "(", "self", ".", "reads", ".", "__setitem__", ",", "reader", ",", "1", ")", "self", ".", "wakeUp", "(", ")" ]
Add a FileDescriptor for notification of data available to read.
[ "Add", "a", "FileDescriptor", "for", "notification", "of", "data", "available", "to", "read", "." ]
train
https://github.com/FreshXOpenSource/wallaby-frontend-qt/blob/eee70d0ec4ce34827f62a1654e28dbff8a8afb1a/wallaby/frontends/qt/reactor/threadedselect.py#L309-L313
FreshXOpenSource/wallaby-frontend-qt
wallaby/frontends/qt/reactor/threadedselect.py
ThreadedSelectReactor.addWriter
def addWriter(self, writer): """Add a FileDescriptor for notification of data available to write. """ self._sendToThread(self.writes.__setitem__, writer, 1) self.wakeUp()
python
def addWriter(self, writer): """Add a FileDescriptor for notification of data available to write. """ self._sendToThread(self.writes.__setitem__, writer, 1) self.wakeUp()
[ "def", "addWriter", "(", "self", ",", "writer", ")", ":", "self", ".", "_sendToThread", "(", "self", ".", "writes", ".", "__setitem__", ",", "writer", ",", "1", ")", "self", ".", "wakeUp", "(", ")" ]
Add a FileDescriptor for notification of data available to write.
[ "Add", "a", "FileDescriptor", "for", "notification", "of", "data", "available", "to", "write", "." ]
train
https://github.com/FreshXOpenSource/wallaby-frontend-qt/blob/eee70d0ec4ce34827f62a1654e28dbff8a8afb1a/wallaby/frontends/qt/reactor/threadedselect.py#L315-L319
KnowledgeLinks/rdfframework
rdfframework/rml/rmlmanager.py
RmlManager.register_defs
def register_defs(self, def_list, **kwargs): """ Registers a list of Rml defintions objects Args: ----- def_list: list of objects defining the rml definitons """ for item in def_list: if isinstance(item, tuple): self.register_rml_d...
python
def register_defs(self, def_list, **kwargs): """ Registers a list of Rml defintions objects Args: ----- def_list: list of objects defining the rml definitons """ for item in def_list: if isinstance(item, tuple): self.register_rml_d...
[ "def", "register_defs", "(", "self", ",", "def_list", ",", "*", "*", "kwargs", ")", ":", "for", "item", "in", "def_list", ":", "if", "isinstance", "(", "item", ",", "tuple", ")", ":", "self", ".", "register_rml_def", "(", "*", "item", ",", "*", "*", ...
Registers a list of Rml defintions objects Args: ----- def_list: list of objects defining the rml definitons
[ "Registers", "a", "list", "of", "Rml", "defintions", "objects" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rml/rmlmanager.py#L43-L57
KnowledgeLinks/rdfframework
rdfframework/rml/rmlmanager.py
RmlManager.register_rml_def
def register_rml_def(self, location_type, location, filename=None, **kwargs): """ Registers the rml file locations for easy access Args: ----- location_type: ['package_all', ...
python
def register_rml_def(self, location_type, location, filename=None, **kwargs): """ Registers the rml file locations for easy access Args: ----- location_type: ['package_all', ...
[ "def", "register_rml_def", "(", "self", ",", "location_type", ",", "location", ",", "filename", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "location_type", "==", "'directory'", ":", "self", ".", "register_directory", "(", "location", ",", "*", "...
Registers the rml file locations for easy access Args: ----- location_type: ['package_all', 'package_file', 'directory', 'filepath'] location: The correlated location string based on the location...
[ "Registers", "the", "rml", "file", "locations", "for", "easy", "access" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rml/rmlmanager.py#L59-L105
KnowledgeLinks/rdfframework
rdfframework/rml/rmlmanager.py
RmlManager.register_rml
def register_rml(self, filepath, **kwargs): """ Registers the filepath for an rml mapping Args: ----- filepath: the path the rml file """ name = os.path.split(filepath)[-1] if name in self.rml_maps and self.rml_maps[name] != filepath: rais...
python
def register_rml(self, filepath, **kwargs): """ Registers the filepath for an rml mapping Args: ----- filepath: the path the rml file """ name = os.path.split(filepath)[-1] if name in self.rml_maps and self.rml_maps[name] != filepath: rais...
[ "def", "register_rml", "(", "self", ",", "filepath", ",", "*", "*", "kwargs", ")", ":", "name", "=", "os", ".", "path", ".", "split", "(", "filepath", ")", "[", "-", "1", "]", "if", "name", "in", "self", ".", "rml_maps", "and", "self", ".", "rml_...
Registers the filepath for an rml mapping Args: ----- filepath: the path the rml file
[ "Registers", "the", "filepath", "for", "an", "rml", "mapping" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rml/rmlmanager.py#L107-L120
KnowledgeLinks/rdfframework
rdfframework/rml/rmlmanager.py
RmlManager.register_directory
def register_directory(self, dirpath, **kwargs): """ Registers all of the files in the the directory path """ kwargs['file_extensions'] = kwargs.get("file_extensions", self.rdf_formats) files = list_files(file_directory=dirpath, **k...
python
def register_directory(self, dirpath, **kwargs): """ Registers all of the files in the the directory path """ kwargs['file_extensions'] = kwargs.get("file_extensions", self.rdf_formats) files = list_files(file_directory=dirpath, **k...
[ "def", "register_directory", "(", "self", ",", "dirpath", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'file_extensions'", "]", "=", "kwargs", ".", "get", "(", "\"file_extensions\"", ",", "self", ".", "rdf_formats", ")", "files", "=", "list_files", "...
Registers all of the files in the the directory path
[ "Registers", "all", "of", "the", "files", "in", "the", "the", "directory", "path" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rml/rmlmanager.py#L122-L131
KnowledgeLinks/rdfframework
rdfframework/rml/rmlmanager.py
RmlManager.make_processor
def make_processor(self, name, mappings, processor_type, **kwargs): """ Instantiates a RmlProcessor and registers it in the manager Args: ----- name: the name to register the processor mappings: the list RML mapping definitions to use processor_type: ...
python
def make_processor(self, name, mappings, processor_type, **kwargs): """ Instantiates a RmlProcessor and registers it in the manager Args: ----- name: the name to register the processor mappings: the list RML mapping definitions to use processor_type: ...
[ "def", "make_processor", "(", "self", ",", "name", ",", "mappings", ",", "processor_type", ",", "*", "*", "kwargs", ")", ":", "from", ".", "processor", "import", "Processor", "if", "self", ".", "processors", ".", "get", "(", "name", ")", ":", "raise", ...
Instantiates a RmlProcessor and registers it in the manager Args: ----- name: the name to register the processor mappings: the list RML mapping definitions to use processor_type: the name of the RML processor to use
[ "Instantiates", "a", "RmlProcessor", "and", "registers", "it", "in", "the", "manager" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rml/rmlmanager.py#L133-L152
KnowledgeLinks/rdfframework
rdfframework/rml/rmlmanager.py
RmlManager.get_processor
def get_processor(self, name, mappings=None, processor_type=None, **kwargs): """ Returns the specified RML Processor """ try: return self.processors[name] except KeyError: ...
python
def get_processor(self, name, mappings=None, processor_type=None, **kwargs): """ Returns the specified RML Processor """ try: return self.processors[name] except KeyError: ...
[ "def", "get_processor", "(", "self", ",", "name", ",", "mappings", "=", "None", ",", "processor_type", "=", "None", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "self", ".", "processors", "[", "name", "]", "except", "KeyError", ":", "return...
Returns the specified RML Processor
[ "Returns", "the", "specified", "RML", "Processor" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rml/rmlmanager.py#L154-L168
KnowledgeLinks/rdfframework
rdfframework/rml/rmlmanager.py
RmlManager.get_rml
def get_rml(self, rml_name, rtn_format="filepath"): """ returns the rml mapping filepath rml_name(str): Name of the rml mapping to retrieve rtn_format: ['filepath', 'data'] """ try: rml_path = self.rml_maps[rml_name] except KeyError: if rml_name ...
python
def get_rml(self, rml_name, rtn_format="filepath"): """ returns the rml mapping filepath rml_name(str): Name of the rml mapping to retrieve rtn_format: ['filepath', 'data'] """ try: rml_path = self.rml_maps[rml_name] except KeyError: if rml_name ...
[ "def", "get_rml", "(", "self", ",", "rml_name", ",", "rtn_format", "=", "\"filepath\"", ")", ":", "try", ":", "rml_path", "=", "self", ".", "rml_maps", "[", "rml_name", "]", "except", "KeyError", ":", "if", "rml_name", "in", "self", ".", "rml_maps", ".",...
returns the rml mapping filepath rml_name(str): Name of the rml mapping to retrieve rtn_format: ['filepath', 'data']
[ "returns", "the", "rml", "mapping", "filepath" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rml/rmlmanager.py#L193-L210
tlevine/vlermv
vlermv/_abstract.py
AbstractVlermv.memoize
def memoize(Class, *args, **kwargs): ''' Memoize/record a function inside this vlermv. :: @Vlermv.cache('~/.http') def get(url): return requests.get(url, auth = ('username', 'password')) The args and kwargs get passed to the Vlermv with some slight chang...
python
def memoize(Class, *args, **kwargs): ''' Memoize/record a function inside this vlermv. :: @Vlermv.cache('~/.http') def get(url): return requests.get(url, auth = ('username', 'password')) The args and kwargs get passed to the Vlermv with some slight chang...
[ "def", "memoize", "(", "Class", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "decorator", "(", "func", ")", ":", "if", "len", "(", "args", ")", "==", "0", ":", "if", "hasattr", "(", "func", ",", "'__name__'", ")", ":", "_args", "...
Memoize/record a function inside this vlermv. :: @Vlermv.cache('~/.http') def get(url): return requests.get(url, auth = ('username', 'password')) The args and kwargs get passed to the Vlermv with some slight changes. Here are the changes. First, the def...
[ "Memoize", "/", "record", "a", "function", "inside", "this", "vlermv", ".", "::" ]
train
https://github.com/tlevine/vlermv/blob/0b332ea1c20e4065b30f5e3ec0c1d0fffbce6b20/vlermv/_abstract.py#L18-L51
tlevine/vlermv
vlermv/_abstract.py
AbstractVlermv.filename
def filename(self, index): ''' Get the absolute filename corresponding to a key; run the key_transformer on the key and do a few other small things. :raises TypeError: if the key_transformer returns something other than a :py:class:`tuple` of :py:class:`strings <str>` ...
python
def filename(self, index): ''' Get the absolute filename corresponding to a key; run the key_transformer on the key and do a few other small things. :raises TypeError: if the key_transformer returns something other than a :py:class:`tuple` of :py:class:`strings <str>` ...
[ "def", "filename", "(", "self", ",", "index", ")", ":", "subpath", "=", "self", ".", "key_transformer", ".", "to_path", "(", "index", ")", "if", "not", "isinstance", "(", "subpath", ",", "tuple", ")", ":", "msg", "=", "'subpath is a %s, but it should be a tu...
Get the absolute filename corresponding to a key; run the key_transformer on the key and do a few other small things. :raises TypeError: if the key_transformer returns something other than a :py:class:`tuple` of :py:class:`strings <str>` :raises KeyError: if the key_transformer retu...
[ "Get", "the", "absolute", "filename", "corresponding", "to", "a", "key", ";", "run", "the", "key_transformer", "on", "the", "key", "and", "do", "a", "few", "other", "small", "things", "." ]
train
https://github.com/tlevine/vlermv/blob/0b332ea1c20e4065b30f5e3ec0c1d0fffbce6b20/vlermv/_abstract.py#L147-L167
tlevine/vlermv
vlermv/_abstract.py
AbstractVlermv.from_filename
def from_filename(self, filename): ''' Convert an absolute filename into key. ''' i = len(self.base_directory) if filename[:i] != self.base_directory: raise ValueError('Filename needs to start with "%s";\nyou passed "%s".' % (self.base_directory, filename)) i...
python
def from_filename(self, filename): ''' Convert an absolute filename into key. ''' i = len(self.base_directory) if filename[:i] != self.base_directory: raise ValueError('Filename needs to start with "%s";\nyou passed "%s".' % (self.base_directory, filename)) i...
[ "def", "from_filename", "(", "self", ",", "filename", ")", ":", "i", "=", "len", "(", "self", ".", "base_directory", ")", "if", "filename", "[", ":", "i", "]", "!=", "self", ".", "base_directory", ":", "raise", "ValueError", "(", "'Filename needs to start ...
Convert an absolute filename into key.
[ "Convert", "an", "absolute", "filename", "into", "key", "." ]
train
https://github.com/tlevine/vlermv/blob/0b332ea1c20e4065b30f5e3ec0c1d0fffbce6b20/vlermv/_abstract.py#L169-L182
untwisted/quickirc
quickirc.py
Irc.main
def main(self, spin, data): """ The function which uses irc rfc regex to extract the basic arguments from the msg. """ data = data.decode(self.encoding) field = re.match(RFC_REG, data) if not field: return prefix = self.extract...
python
def main(self, spin, data): """ The function which uses irc rfc regex to extract the basic arguments from the msg. """ data = data.decode(self.encoding) field = re.match(RFC_REG, data) if not field: return prefix = self.extract...
[ "def", "main", "(", "self", ",", "spin", ",", "data", ")", ":", "data", "=", "data", ".", "decode", "(", "self", ".", "encoding", ")", "field", "=", "re", ".", "match", "(", "RFC_REG", ",", "data", ")", "if", "not", "field", ":", "return", "prefi...
The function which uses irc rfc regex to extract the basic arguments from the msg.
[ "The", "function", "which", "uses", "irc", "rfc", "regex", "to", "extract", "the", "basic", "arguments", "from", "the", "msg", "." ]
train
https://github.com/untwisted/quickirc/blob/4e92ffd45eef03eee2ba0b659b19b4f40a2dbf99/quickirc.py#L135-L149
untwisted/quickirc
quickirc.py
Irc.extract_prefix
def extract_prefix(self, prefix): """ It extracts an irc msg prefix chunk """ field = re.match(PREFIX_REG, prefix if prefix else '') return (prefix,) if not field else field.group(1, 2, 3)
python
def extract_prefix(self, prefix): """ It extracts an irc msg prefix chunk """ field = re.match(PREFIX_REG, prefix if prefix else '') return (prefix,) if not field else field.group(1, 2, 3)
[ "def", "extract_prefix", "(", "self", ",", "prefix", ")", ":", "field", "=", "re", ".", "match", "(", "PREFIX_REG", ",", "prefix", "if", "prefix", "else", "''", ")", "return", "(", "prefix", ",", ")", "if", "not", "field", "else", "field", ".", "grou...
It extracts an irc msg prefix chunk
[ "It", "extracts", "an", "irc", "msg", "prefix", "chunk" ]
train
https://github.com/untwisted/quickirc/blob/4e92ffd45eef03eee2ba0b659b19b4f40a2dbf99/quickirc.py#L151-L158
untwisted/quickirc
quickirc.py
Irc.extract_args
def extract_args(self, data): """ It extracts irc msg arguments. """ args = [] data = data.strip(' ') if ':' in data: lhs, rhs = data.split(':', 1) if lhs: args.extend(lhs.rstrip(' ').split(' ')) args.append(rhs) else: ...
python
def extract_args(self, data): """ It extracts irc msg arguments. """ args = [] data = data.strip(' ') if ':' in data: lhs, rhs = data.split(':', 1) if lhs: args.extend(lhs.rstrip(' ').split(' ')) args.append(rhs) else: ...
[ "def", "extract_args", "(", "self", ",", "data", ")", ":", "args", "=", "[", "]", "data", "=", "data", ".", "strip", "(", "' '", ")", "if", "':'", "in", "data", ":", "lhs", ",", "rhs", "=", "data", ".", "split", "(", "':'", ",", "1", ")", "if...
It extracts irc msg arguments.
[ "It", "extracts", "irc", "msg", "arguments", "." ]
train
https://github.com/untwisted/quickirc/blob/4e92ffd45eef03eee2ba0b659b19b4f40a2dbf99/quickirc.py#L160-L172
untwisted/quickirc
quickirc.py
CTCP.extract_ctcp
def extract_ctcp(self, spin, nick, user, host, target, msg): """ it is used to extract ctcp requests into pieces. """ # The ctcp delimiter token. DELIM = '\001' if not msg.startswith(DELIM) or not msg.endswith(DELIM): return ctcp_args =...
python
def extract_ctcp(self, spin, nick, user, host, target, msg): """ it is used to extract ctcp requests into pieces. """ # The ctcp delimiter token. DELIM = '\001' if not msg.startswith(DELIM) or not msg.endswith(DELIM): return ctcp_args =...
[ "def", "extract_ctcp", "(", "self", ",", "spin", ",", "nick", ",", "user", ",", "host", ",", "target", ",", "msg", ")", ":", "# The ctcp delimiter token.", "DELIM", "=", "'\\001'", "if", "not", "msg", ".", "startswith", "(", "DELIM", ")", "or", "not", ...
it is used to extract ctcp requests into pieces.
[ "it", "is", "used", "to", "extract", "ctcp", "requests", "into", "pieces", "." ]
train
https://github.com/untwisted/quickirc/blob/4e92ffd45eef03eee2ba0b659b19b4f40a2dbf99/quickirc.py#L184-L197
untwisted/quickirc
quickirc.py
CTCP.patch
def patch(self, spin, header, *args): """ It spawns DCC TYPE as event. """ spawn(spin, 'DCC %s' % args[0], header, *args[1:])
python
def patch(self, spin, header, *args): """ It spawns DCC TYPE as event. """ spawn(spin, 'DCC %s' % args[0], header, *args[1:])
[ "def", "patch", "(", "self", ",", "spin", ",", "header", ",", "*", "args", ")", ":", "spawn", "(", "spin", ",", "'DCC %s'", "%", "args", "[", "0", "]", ",", "header", ",", "*", "args", "[", "1", ":", "]", ")" ]
It spawns DCC TYPE as event.
[ "It", "spawns", "DCC", "TYPE", "as", "event", "." ]
train
https://github.com/untwisted/quickirc/blob/4e92ffd45eef03eee2ba0b659b19b4f40a2dbf99/quickirc.py#L199-L204
fopina/tgbotplug
tgbot/tgbot.py
TGBot.print_commands
def print_commands(self, out=sys.stdout): ''' utility method to print commands and descriptions for @BotFather ''' cmds = self.list_commands() for ck in cmds: if ck.printable: out.write('%s\n' % ck)
python
def print_commands(self, out=sys.stdout): ''' utility method to print commands and descriptions for @BotFather ''' cmds = self.list_commands() for ck in cmds: if ck.printable: out.write('%s\n' % ck)
[ "def", "print_commands", "(", "self", ",", "out", "=", "sys", ".", "stdout", ")", ":", "cmds", "=", "self", ".", "list_commands", "(", ")", "for", "ck", "in", "cmds", ":", "if", "ck", ".", "printable", ":", "out", ".", "write", "(", "'%s\\n'", "%",...
utility method to print commands and descriptions for @BotFather
[ "utility", "method", "to", "print", "commands", "and", "descriptions", "for" ]
train
https://github.com/fopina/tgbotplug/blob/c115733b03f2e23ddcdecfce588d1a6a1e5bde91/tgbot/tgbot.py#L161-L169
udoprog/mimeprovider
mimeprovider/client/requests.py
RequestsClient.request
def request(self, method, uri, **kw): """ The money maker. """ expect = kw.pop("expect", []) mime_body = kw.pop("mime_body", None) headers = kw.pop("headers", {}) data = kw.pop("data", None) if mime_body: mimevalues = self.mimeobjects.get(mim...
python
def request(self, method, uri, **kw): """ The money maker. """ expect = kw.pop("expect", []) mime_body = kw.pop("mime_body", None) headers = kw.pop("headers", {}) data = kw.pop("data", None) if mime_body: mimevalues = self.mimeobjects.get(mim...
[ "def", "request", "(", "self", ",", "method", ",", "uri", ",", "*", "*", "kw", ")", ":", "expect", "=", "kw", ".", "pop", "(", "\"expect\"", ",", "[", "]", ")", "mime_body", "=", "kw", ".", "pop", "(", "\"mime_body\"", ",", "None", ")", "headers"...
The money maker.
[ "The", "money", "maker", "." ]
train
https://github.com/udoprog/mimeprovider/blob/5acd61eb0ef813b4a2eb6bbe75d07af1e11847a4/mimeprovider/client/requests.py#L56-L123
onenameio/onename-python
onename/client.py
OnenameClient.update_user
def update_user(self, username, profile, owner_privkey): """ Update profile_hash on blockchain """ url = self.base_url + "/users/" + username + "/update" owner_pubkey = get_pubkey_from_privkey(owner_privkey) payload = { 'profile': profile, '...
python
def update_user(self, username, profile, owner_privkey): """ Update profile_hash on blockchain """ url = self.base_url + "/users/" + username + "/update" owner_pubkey = get_pubkey_from_privkey(owner_privkey) payload = { 'profile': profile, '...
[ "def", "update_user", "(", "self", ",", "username", ",", "profile", ",", "owner_privkey", ")", ":", "url", "=", "self", ".", "base_url", "+", "\"/users/\"", "+", "username", "+", "\"/update\"", "owner_pubkey", "=", "get_pubkey_from_privkey", "(", "owner_privkey"...
Update profile_hash on blockchain
[ "Update", "profile_hash", "on", "blockchain" ]
train
https://github.com/onenameio/onename-python/blob/74c583282f18ad9582c6b57b826126d045321494/onename/client.py#L142-L172
onenameio/onename-python
onename/client.py
OnenameClient.transfer_user
def transfer_user(self, username, transfer_address, owner_privkey): """ Transfer name on blockchain """ url = self.base_url + "/users/" + username + "/update" owner_pubkey = get_pubkey_from_privkey(owner_privkey) payload = { 'transfer_address': transfer...
python
def transfer_user(self, username, transfer_address, owner_privkey): """ Transfer name on blockchain """ url = self.base_url + "/users/" + username + "/update" owner_pubkey = get_pubkey_from_privkey(owner_privkey) payload = { 'transfer_address': transfer...
[ "def", "transfer_user", "(", "self", ",", "username", ",", "transfer_address", ",", "owner_privkey", ")", ":", "url", "=", "self", ".", "base_url", "+", "\"/users/\"", "+", "username", "+", "\"/update\"", "owner_pubkey", "=", "get_pubkey_from_privkey", "(", "own...
Transfer name on blockchain
[ "Transfer", "name", "on", "blockchain" ]
train
https://github.com/onenameio/onename-python/blob/74c583282f18ad9582c6b57b826126d045321494/onename/client.py#L174-L198
kervi/kervi-core
kervi/controllers/__init__.py
Controller.create
def create(controller_id, name): """Turn class into a kervi controller""" def _decorator(cls): class _ControllerClass(cls, Controller): def __init__(self): Controller.__init__(self, controller_id, name) for key in cls.__dict__.keys(): ...
python
def create(controller_id, name): """Turn class into a kervi controller""" def _decorator(cls): class _ControllerClass(cls, Controller): def __init__(self): Controller.__init__(self, controller_id, name) for key in cls.__dict__.keys(): ...
[ "def", "create", "(", "controller_id", ",", "name", ")", ":", "def", "_decorator", "(", "cls", ")", ":", "class", "_ControllerClass", "(", "cls", ",", "Controller", ")", ":", "def", "__init__", "(", "self", ")", ":", "Controller", ".", "__init__", "(", ...
Turn class into a kervi controller
[ "Turn", "class", "into", "a", "kervi", "controller" ]
train
https://github.com/kervi/kervi-core/blob/3c1e3c8a17a7b4d085d8a28b99180ff2a96b0e23/kervi/controllers/__init__.py#L205-L220
kervi/kervi-core
kervi/controllers/__init__.py
Controller.input
def input(input_id, name, value_class=NumberValue): """Add input to controller""" def _init(): return value_class( name, input_id=input_id, is_input=True, index=-1 ) def _decorator(cls): setattr(c...
python
def input(input_id, name, value_class=NumberValue): """Add input to controller""" def _init(): return value_class( name, input_id=input_id, is_input=True, index=-1 ) def _decorator(cls): setattr(c...
[ "def", "input", "(", "input_id", ",", "name", ",", "value_class", "=", "NumberValue", ")", ":", "def", "_init", "(", ")", ":", "return", "value_class", "(", "name", ",", "input_id", "=", "input_id", ",", "is_input", "=", "True", ",", "index", "=", "-",...
Add input to controller
[ "Add", "input", "to", "controller" ]
train
https://github.com/kervi/kervi-core/blob/3c1e3c8a17a7b4d085d8a28b99180ff2a96b0e23/kervi/controllers/__init__.py#L223-L235
kervi/kervi-core
kervi/controllers/__init__.py
Controller.output
def output(output_id, name, value_class=NumberValue): """Add output to controller""" def _init(): return value_class( name, input_id=output_id, is_input=False, index=-1 ) def _decorator(cls): seta...
python
def output(output_id, name, value_class=NumberValue): """Add output to controller""" def _init(): return value_class( name, input_id=output_id, is_input=False, index=-1 ) def _decorator(cls): seta...
[ "def", "output", "(", "output_id", ",", "name", ",", "value_class", "=", "NumberValue", ")", ":", "def", "_init", "(", ")", ":", "return", "value_class", "(", "name", ",", "input_id", "=", "output_id", ",", "is_input", "=", "False", ",", "index", "=", ...
Add output to controller
[ "Add", "output", "to", "controller" ]
train
https://github.com/kervi/kervi-core/blob/3c1e3c8a17a7b4d085d8a28b99180ff2a96b0e23/kervi/controllers/__init__.py#L238-L250
b3j0f/utils
b3j0f/utils/ut.py
_subset
def _subset(subset, superset): """True if subset is a subset of superset. :param dict subset: subset to compare. :param dict superset: superset to compare. :return: True iif all pairs (key, value) of subset are in superset. :rtype: bool """ result = True for k in subset: result...
python
def _subset(subset, superset): """True if subset is a subset of superset. :param dict subset: subset to compare. :param dict superset: superset to compare. :return: True iif all pairs (key, value) of subset are in superset. :rtype: bool """ result = True for k in subset: result...
[ "def", "_subset", "(", "subset", ",", "superset", ")", ":", "result", "=", "True", "for", "k", "in", "subset", ":", "result", "=", "k", "in", "superset", "and", "subset", "[", "k", "]", "==", "superset", "[", "k", "]", "if", "not", "result", ":", ...
True if subset is a subset of superset. :param dict subset: subset to compare. :param dict superset: superset to compare. :return: True iif all pairs (key, value) of subset are in superset. :rtype: bool
[ "True", "if", "subset", "is", "a", "subset", "of", "superset", "." ]
train
https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/ut.py#L40-L54
alexhayes/django-toolkit
django_toolkit/templatetags/buttons.py
button_with_image
def button_with_image(size='medium', icon=None, text=None, title=None, button=False, name=None, target=False, disabled=False, extra_css=None, modal=None, data_target='#modal', viewname=None, next=None, extra_href=False, href=False, fancyajax=False, vie...
python
def button_with_image(size='medium', icon=None, text=None, title=None, button=False, name=None, target=False, disabled=False, extra_css=None, modal=None, data_target='#modal', viewname=None, next=None, extra_href=False, href=False, fancyajax=False, vie...
[ "def", "button_with_image", "(", "size", "=", "'medium'", ",", "icon", "=", "None", ",", "text", "=", "None", ",", "title", "=", "None", ",", "button", "=", "False", ",", "name", "=", "None", ",", "target", "=", "False", ",", "disabled", "=", "False"...
Output a button using Bingo's button html. @param size: The size that refers to the icon css class. @param icon: A css class that refers to an icon - for example 'send_mail' @param text: Text to display on the button @param title: Title parameter for the button or if button=False the data-tip for a...
[ "Output", "a", "button", "using", "Bingo", "s", "button", "html", "." ]
train
https://github.com/alexhayes/django-toolkit/blob/b64106392fad596defc915b8235fe6e1d0013b5b/django_toolkit/templatetags/buttons.py#L7-L83
rmed/dev-init
dev_init/dev_init.py
init_parser
def init_parser(): """ Initialize the arguments parser. """ parser = argparse.ArgumentParser( description="Automated development environment initialization") parser.add_argument('--version', action='version', version='%(prog)s ' + __version__) subparsers = parser.add_subparsers(title="...
python
def init_parser(): """ Initialize the arguments parser. """ parser = argparse.ArgumentParser( description="Automated development environment initialization") parser.add_argument('--version', action='version', version='%(prog)s ' + __version__) subparsers = parser.add_subparsers(title="...
[ "def", "init_parser", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "\"Automated development environment initialization\"", ")", "parser", ".", "add_argument", "(", "'--version'", ",", "action", "=", "'version'", ",", "ver...
Initialize the arguments parser.
[ "Initialize", "the", "arguments", "parser", "." ]
train
https://github.com/rmed/dev-init/blob/afc5da13002e563324c6291dede0bf2e0f58171f/dev_init/dev_init.py#L39-L75
rmed/dev-init
dev_init/dev_init.py
new_env
def new_env(environment): """ Create a new environment in the configuration and ask the user for the commands for this specific environment. """ if not environment: print("You need to supply an environment name") return parser = read_config() if environment in parser.sectio...
python
def new_env(environment): """ Create a new environment in the configuration and ask the user for the commands for this specific environment. """ if not environment: print("You need to supply an environment name") return parser = read_config() if environment in parser.sectio...
[ "def", "new_env", "(", "environment", ")", ":", "if", "not", "environment", ":", "print", "(", "\"You need to supply an environment name\"", ")", "return", "parser", "=", "read_config", "(", ")", "if", "environment", "in", "parser", ".", "sections", "(", ")", ...
Create a new environment in the configuration and ask the user for the commands for this specific environment.
[ "Create", "a", "new", "environment", "in", "the", "configuration", "and", "ask", "the", "user", "for", "the", "commands", "for", "this", "specific", "environment", "." ]
train
https://github.com/rmed/dev-init/blob/afc5da13002e563324c6291dede0bf2e0f58171f/dev_init/dev_init.py#L84-L121
rmed/dev-init
dev_init/dev_init.py
remove_env
def remove_env(environment): """ Remove an environment from the configuration. """ if not environment: print("You need to supply an environment name") return parser = read_config() if not parser.remove_section(environment): print("Unknown environment type '%s'" % environment) ...
python
def remove_env(environment): """ Remove an environment from the configuration. """ if not environment: print("You need to supply an environment name") return parser = read_config() if not parser.remove_section(environment): print("Unknown environment type '%s'" % environment) ...
[ "def", "remove_env", "(", "environment", ")", ":", "if", "not", "environment", ":", "print", "(", "\"You need to supply an environment name\"", ")", "return", "parser", "=", "read_config", "(", ")", "if", "not", "parser", ".", "remove_section", "(", "environment",...
Remove an environment from the configuration.
[ "Remove", "an", "environment", "from", "the", "configuration", "." ]
train
https://github.com/rmed/dev-init/blob/afc5da13002e563324c6291dede0bf2e0f58171f/dev_init/dev_init.py#L123-L137
rmed/dev-init
dev_init/dev_init.py
show_env
def show_env(environment): """ Show the commands for a given environment. """ if not environment: print("You need to supply an environment name") return parser = read_config() try: commands = parser.get(environment, "cmd").split("\n") except KeyError: print("Unknow...
python
def show_env(environment): """ Show the commands for a given environment. """ if not environment: print("You need to supply an environment name") return parser = read_config() try: commands = parser.get(environment, "cmd").split("\n") except KeyError: print("Unknow...
[ "def", "show_env", "(", "environment", ")", ":", "if", "not", "environment", ":", "print", "(", "\"You need to supply an environment name\"", ")", "return", "parser", "=", "read_config", "(", ")", "try", ":", "commands", "=", "parser", ".", "get", "(", "enviro...
Show the commands for a given environment.
[ "Show", "the", "commands", "for", "a", "given", "environment", "." ]
train
https://github.com/rmed/dev-init/blob/afc5da13002e563324c6291dede0bf2e0f58171f/dev_init/dev_init.py#L139-L157
rmed/dev-init
dev_init/dev_init.py
start_env
def start_env(environment, path): """ Initialize a new environment in specified directory. If path does not exist, will try to create the directory structure recursively. If the path is not provided, will use current working directory. """ parser = read_config() if environment...
python
def start_env(environment, path): """ Initialize a new environment in specified directory. If path does not exist, will try to create the directory structure recursively. If the path is not provided, will use current working directory. """ parser = read_config() if environment...
[ "def", "start_env", "(", "environment", ",", "path", ")", ":", "parser", "=", "read_config", "(", ")", "if", "environment", "not", "in", "parser", ".", "sections", "(", ")", ":", "print", "(", "\"Unknown environment type '%s'\"", "%", "environment", ")", "re...
Initialize a new environment in specified directory. If path does not exist, will try to create the directory structure recursively. If the path is not provided, will use current working directory.
[ "Initialize", "a", "new", "environment", "in", "specified", "directory", "." ]
train
https://github.com/rmed/dev-init/blob/afc5da13002e563324c6291dede0bf2e0f58171f/dev_init/dev_init.py#L159-L190
rmed/dev-init
dev_init/dev_init.py
read_config
def read_config(): """ Read the configuration file and parse the different environments. Returns: ConfigParser object """ if not os.path.isfile(CONFIG): with open(CONFIG, "w"): pass parser = ConfigParser() parser.read(CONFIG) return parser
python
def read_config(): """ Read the configuration file and parse the different environments. Returns: ConfigParser object """ if not os.path.isfile(CONFIG): with open(CONFIG, "w"): pass parser = ConfigParser() parser.read(CONFIG) return parser
[ "def", "read_config", "(", ")", ":", "if", "not", "os", ".", "path", ".", "isfile", "(", "CONFIG", ")", ":", "with", "open", "(", "CONFIG", ",", "\"w\"", ")", ":", "pass", "parser", "=", "ConfigParser", "(", ")", "parser", ".", "read", "(", "CONFIG...
Read the configuration file and parse the different environments. Returns: ConfigParser object
[ "Read", "the", "configuration", "file", "and", "parse", "the", "different", "environments", "." ]
train
https://github.com/rmed/dev-init/blob/afc5da13002e563324c6291dede0bf2e0f58171f/dev_init/dev_init.py#L192-L204
rmed/dev-init
dev_init/dev_init.py
parse_action
def parse_action(action, parsed): """ Parse the action to execute. """ if action == "list": list_env() elif action == "new": new_env(parsed.environment) elif action == "remove": remove_env(parsed.environment) elif action == "show": show_env(parsed.environment) ...
python
def parse_action(action, parsed): """ Parse the action to execute. """ if action == "list": list_env() elif action == "new": new_env(parsed.environment) elif action == "remove": remove_env(parsed.environment) elif action == "show": show_env(parsed.environment) ...
[ "def", "parse_action", "(", "action", ",", "parsed", ")", ":", "if", "action", "==", "\"list\"", ":", "list_env", "(", ")", "elif", "action", "==", "\"new\"", ":", "new_env", "(", "parsed", ".", "environment", ")", "elif", "action", "==", "\"remove\"", "...
Parse the action to execute.
[ "Parse", "the", "action", "to", "execute", "." ]
train
https://github.com/rmed/dev-init/blob/afc5da13002e563324c6291dede0bf2e0f58171f/dev_init/dev_init.py#L211-L226
edeposit/edeposit.amqp.pdfgen
src/edeposit/amqp/pdfgen/translator.py
_init_pdf
def _init_pdf(style_path, header=None, footer=FOOTER): """ Initialize :class:`RstToPdf` class. Args: style_path (str): Path to the style for the PDF. header (str, default None): Header which will be rendered to each page. footer (str, default FOOTER): Footer, which will be rendered ...
python
def _init_pdf(style_path, header=None, footer=FOOTER): """ Initialize :class:`RstToPdf` class. Args: style_path (str): Path to the style for the PDF. header (str, default None): Header which will be rendered to each page. footer (str, default FOOTER): Footer, which will be rendered ...
[ "def", "_init_pdf", "(", "style_path", ",", "header", "=", "None", ",", "footer", "=", "FOOTER", ")", ":", "return", "RstToPdf", "(", "language", "=", "\"cs\"", ",", "font_path", "=", "[", "\"/usr/share/fonts\"", ",", "\"/usr/share/fonts/truetype/\"", ",", "'....
Initialize :class:`RstToPdf` class. Args: style_path (str): Path to the style for the PDF. header (str, default None): Header which will be rendered to each page. footer (str, default FOOTER): Footer, which will be rendered to each page. See :attr:`FOOTER` for details. R...
[ "Initialize", ":", "class", ":", "RstToPdf", "class", "." ]
train
https://github.com/edeposit/edeposit.amqp.pdfgen/blob/1022d6d01196f4928d664a71e49273c2d8c67e63/src/edeposit/amqp/pdfgen/translator.py#L18-L46
edeposit/edeposit.amqp.pdfgen
src/edeposit/amqp/pdfgen/translator.py
gen_pdf
def gen_pdf(rst_content, style_text, header=None, footer=FOOTER): """ Create PDF file from `rst_content` using `style_text` as style. Optinally, add `header` or `footer`. Args: rst_content (str): Content of the PDF file in restructured text markup. style_text (str): Style for the :mod:...
python
def gen_pdf(rst_content, style_text, header=None, footer=FOOTER): """ Create PDF file from `rst_content` using `style_text` as style. Optinally, add `header` or `footer`. Args: rst_content (str): Content of the PDF file in restructured text markup. style_text (str): Style for the :mod:...
[ "def", "gen_pdf", "(", "rst_content", ",", "style_text", ",", "header", "=", "None", ",", "footer", "=", "FOOTER", ")", ":", "out_file_obj", "=", "StringIO", "(", ")", "with", "NamedTemporaryFile", "(", ")", "as", "f", ":", "f", ".", "write", "(", "sty...
Create PDF file from `rst_content` using `style_text` as style. Optinally, add `header` or `footer`. Args: rst_content (str): Content of the PDF file in restructured text markup. style_text (str): Style for the :mod:`rst2pdf` module. header (str, default None): Header which will be ren...
[ "Create", "PDF", "file", "from", "rst_content", "using", "style_text", "as", "style", "." ]
train
https://github.com/edeposit/edeposit.amqp.pdfgen/blob/1022d6d01196f4928d664a71e49273c2d8c67e63/src/edeposit/amqp/pdfgen/translator.py#L49-L79
townsenddw/jhubctl
jhubctl/clusters/providers/aws/aws.py
define_parameters
def define_parameters(**parameters): """Get a list of parameters to pass to AWS boto call.""" params = [] for key, value in parameters.items(): param = dict(ParameterKey=key, ParameterValue=value) params.append(param) return params
python
def define_parameters(**parameters): """Get a list of parameters to pass to AWS boto call.""" params = [] for key, value in parameters.items(): param = dict(ParameterKey=key, ParameterValue=value) params.append(param) return params
[ "def", "define_parameters", "(", "*", "*", "parameters", ")", ":", "params", "=", "[", "]", "for", "key", ",", "value", "in", "parameters", ".", "items", "(", ")", ":", "param", "=", "dict", "(", "ParameterKey", "=", "key", ",", "ParameterValue", "=", ...
Get a list of parameters to pass to AWS boto call.
[ "Get", "a", "list", "of", "parameters", "to", "pass", "to", "AWS", "boto", "call", "." ]
train
https://github.com/townsenddw/jhubctl/blob/c8c20f86a16e9d01dd90e4607d81423417cc773b/jhubctl/clusters/providers/aws/aws.py#L75-L81
townsenddw/jhubctl
jhubctl/clusters/providers/aws/aws.py
AwsEKS.create
def create(self): """Deploy a cluster on Amazon's EKS Service configured for Jupyterhub Deployments. """ steps = [ (self.create_role, (), {}), (self.create_vpc, (), {}), (self.create_cluster, (), {}), (self.create_node_group, (), {}), ...
python
def create(self): """Deploy a cluster on Amazon's EKS Service configured for Jupyterhub Deployments. """ steps = [ (self.create_role, (), {}), (self.create_vpc, (), {}), (self.create_cluster, (), {}), (self.create_node_group, (), {}), ...
[ "def", "create", "(", "self", ")", ":", "steps", "=", "[", "(", "self", ".", "create_role", ",", "(", ")", ",", "{", "}", ")", ",", "(", "self", ".", "create_vpc", ",", "(", ")", ",", "{", "}", ")", ",", "(", "self", ".", "create_cluster", ",...
Deploy a cluster on Amazon's EKS Service configured for Jupyterhub Deployments.
[ "Deploy", "a", "cluster", "on", "Amazon", "s", "EKS", "Service", "configured", "for", "Jupyterhub", "Deployments", "." ]
train
https://github.com/townsenddw/jhubctl/blob/c8c20f86a16e9d01dd90e4607d81423417cc773b/jhubctl/clusters/providers/aws/aws.py#L238-L253
townsenddw/jhubctl
jhubctl/clusters/providers/aws/aws.py
AwsEKS.delete
def delete(self): """Delete a running cluster.""" stacks = [ self.utilities_name, self.spot_nodes_name, self.node_group_name, self.cluster_name, self.vpc_name, self.role_name ] # Execute creation. for stack i...
python
def delete(self): """Delete a running cluster.""" stacks = [ self.utilities_name, self.spot_nodes_name, self.node_group_name, self.cluster_name, self.vpc_name, self.role_name ] # Execute creation. for stack i...
[ "def", "delete", "(", "self", ")", ":", "stacks", "=", "[", "self", ".", "utilities_name", ",", "self", ".", "spot_nodes_name", ",", "self", ".", "node_group_name", ",", "self", ".", "cluster_name", ",", "self", ".", "vpc_name", ",", "self", ".", "role_n...
Delete a running cluster.
[ "Delete", "a", "running", "cluster", "." ]
train
https://github.com/townsenddw/jhubctl/blob/c8c20f86a16e9d01dd90e4607d81423417cc773b/jhubctl/clusters/providers/aws/aws.py#L255-L267
townsenddw/jhubctl
jhubctl/clusters/providers/aws/aws.py
AwsEKS.get_auth_config
def get_auth_config(self): """Return the Authorization Config Map (in yaml format) for this cluster. """ return self.get_template( 'amazon-auth-cm.yaml', arn=self.node_arn, users=self.admins )
python
def get_auth_config(self): """Return the Authorization Config Map (in yaml format) for this cluster. """ return self.get_template( 'amazon-auth-cm.yaml', arn=self.node_arn, users=self.admins )
[ "def", "get_auth_config", "(", "self", ")", ":", "return", "self", ".", "get_template", "(", "'amazon-auth-cm.yaml'", ",", "arn", "=", "self", ".", "node_arn", ",", "users", "=", "self", ".", "admins", ")" ]
Return the Authorization Config Map (in yaml format) for this cluster.
[ "Return", "the", "Authorization", "Config", "Map", "(", "in", "yaml", "format", ")", "for", "this", "cluster", "." ]
train
https://github.com/townsenddw/jhubctl/blob/c8c20f86a16e9d01dd90e4607d81423417cc773b/jhubctl/clusters/providers/aws/aws.py#L269-L277
townsenddw/jhubctl
jhubctl/clusters/providers/aws/aws.py
AwsEKS.get_template
def get_template(self, template_name, **parameters): """Pull templates from the AWS templates folder""" template_path = pathlib.Path(self.template_dir).joinpath(template_name) return get_template(template_path, **parameters)
python
def get_template(self, template_name, **parameters): """Pull templates from the AWS templates folder""" template_path = pathlib.Path(self.template_dir).joinpath(template_name) return get_template(template_path, **parameters)
[ "def", "get_template", "(", "self", ",", "template_name", ",", "*", "*", "parameters", ")", ":", "template_path", "=", "pathlib", ".", "Path", "(", "self", ".", "template_dir", ")", ".", "joinpath", "(", "template_name", ")", "return", "get_template", "(", ...
Pull templates from the AWS templates folder
[ "Pull", "templates", "from", "the", "AWS", "templates", "folder" ]
train
https://github.com/townsenddw/jhubctl/blob/c8c20f86a16e9d01dd90e4607d81423417cc773b/jhubctl/clusters/providers/aws/aws.py#L285-L288
townsenddw/jhubctl
jhubctl/clusters/providers/aws/aws.py
AwsEKS.delete_stack
def delete_stack(self, stack_name): """Teardown a stack.""" get_stack(stack_name) CLIENT.delete_stack( StackName=stack_name ) DELETE_WAITER.wait(StackName=stack_name)
python
def delete_stack(self, stack_name): """Teardown a stack.""" get_stack(stack_name) CLIENT.delete_stack( StackName=stack_name ) DELETE_WAITER.wait(StackName=stack_name)
[ "def", "delete_stack", "(", "self", ",", "stack_name", ")", ":", "get_stack", "(", "stack_name", ")", "CLIENT", ".", "delete_stack", "(", "StackName", "=", "stack_name", ")", "DELETE_WAITER", ".", "wait", "(", "StackName", "=", "stack_name", ")" ]
Teardown a stack.
[ "Teardown", "a", "stack", "." ]
train
https://github.com/townsenddw/jhubctl/blob/c8c20f86a16e9d01dd90e4607d81423417cc773b/jhubctl/clusters/providers/aws/aws.py#L290-L296
townsenddw/jhubctl
jhubctl/clusters/providers/aws/aws.py
AwsEKS.create_stack
def create_stack( self, stack_name, stack_template_name, parameters=None, capabilities=None ): """Create a stack using Amazon's Cloud formation""" # Build template_path stack_template_path = pathlib.Path( self.template_dir).joinpath(st...
python
def create_stack( self, stack_name, stack_template_name, parameters=None, capabilities=None ): """Create a stack using Amazon's Cloud formation""" # Build template_path stack_template_path = pathlib.Path( self.template_dir).joinpath(st...
[ "def", "create_stack", "(", "self", ",", "stack_name", ",", "stack_template_name", ",", "parameters", "=", "None", ",", "capabilities", "=", "None", ")", ":", "# Build template_path", "stack_template_path", "=", "pathlib", ".", "Path", "(", "self", ".", "templat...
Create a stack using Amazon's Cloud formation
[ "Create", "a", "stack", "using", "Amazon", "s", "Cloud", "formation" ]
train
https://github.com/townsenddw/jhubctl/blob/c8c20f86a16e9d01dd90e4607d81423417cc773b/jhubctl/clusters/providers/aws/aws.py#L298-L316
townsenddw/jhubctl
jhubctl/clusters/providers/aws/aws.py
AwsEKS.create_vpc
def create_vpc(self): """Create a virtual private cloud on Amazon's Web services configured for deploying JupyterHubs. """ self.create_stack( self.vpc_name, 'amazon-eks-vpc.yaml', parameters=define_parameters( VpcBlock="10.42.0.0/16", ...
python
def create_vpc(self): """Create a virtual private cloud on Amazon's Web services configured for deploying JupyterHubs. """ self.create_stack( self.vpc_name, 'amazon-eks-vpc.yaml', parameters=define_parameters( VpcBlock="10.42.0.0/16", ...
[ "def", "create_vpc", "(", "self", ")", ":", "self", ".", "create_stack", "(", "self", ".", "vpc_name", ",", "'amazon-eks-vpc.yaml'", ",", "parameters", "=", "define_parameters", "(", "VpcBlock", "=", "\"10.42.0.0/16\"", ",", "Subnet01Block", "=", "\"10.42.1.0/24\"...
Create a virtual private cloud on Amazon's Web services configured for deploying JupyterHubs.
[ "Create", "a", "virtual", "private", "cloud", "on", "Amazon", "s", "Web", "services", "configured", "for", "deploying", "JupyterHubs", "." ]
train
https://github.com/townsenddw/jhubctl/blob/c8c20f86a16e9d01dd90e4607d81423417cc773b/jhubctl/clusters/providers/aws/aws.py#L328-L341
townsenddw/jhubctl
jhubctl/clusters/providers/aws/aws.py
AwsEKS.create_cluster
def create_cluster(self): """Creates a cluster on Amazon EKS . """ self.create_stack( self.cluster_name, 'amazon-eks-cluster.yaml', parameters=define_parameters( ClusterName=self.cluster_name, ControlPlaneSecurityGroup=self.secu...
python
def create_cluster(self): """Creates a cluster on Amazon EKS . """ self.create_stack( self.cluster_name, 'amazon-eks-cluster.yaml', parameters=define_parameters( ClusterName=self.cluster_name, ControlPlaneSecurityGroup=self.secu...
[ "def", "create_cluster", "(", "self", ")", ":", "self", ".", "create_stack", "(", "self", ".", "cluster_name", ",", "'amazon-eks-cluster.yaml'", ",", "parameters", "=", "define_parameters", "(", "ClusterName", "=", "self", ".", "cluster_name", ",", "ControlPlaneSe...
Creates a cluster on Amazon EKS .
[ "Creates", "a", "cluster", "on", "Amazon", "EKS", "." ]
train
https://github.com/townsenddw/jhubctl/blob/c8c20f86a16e9d01dd90e4607d81423417cc773b/jhubctl/clusters/providers/aws/aws.py#L343-L354
townsenddw/jhubctl
jhubctl/clusters/providers/aws/aws.py
AwsEKS.create_node_group
def create_node_group(self): """Create on-demand node group on Amazon EKS. """ self.create_stack( self.node_group_name, 'amazon-eks-nodegroup.yaml', capabilities=['CAPABILITY_IAM'], parameters=define_parameters( ClusterName=self.clu...
python
def create_node_group(self): """Create on-demand node group on Amazon EKS. """ self.create_stack( self.node_group_name, 'amazon-eks-nodegroup.yaml', capabilities=['CAPABILITY_IAM'], parameters=define_parameters( ClusterName=self.clu...
[ "def", "create_node_group", "(", "self", ")", ":", "self", ".", "create_stack", "(", "self", ".", "node_group_name", ",", "'amazon-eks-nodegroup.yaml'", ",", "capabilities", "=", "[", "'CAPABILITY_IAM'", "]", ",", "parameters", "=", "define_parameters", "(", "Clus...
Create on-demand node group on Amazon EKS.
[ "Create", "on", "-", "demand", "node", "group", "on", "Amazon", "EKS", "." ]
train
https://github.com/townsenddw/jhubctl/blob/c8c20f86a16e9d01dd90e4607d81423417cc773b/jhubctl/clusters/providers/aws/aws.py#L356-L374
townsenddw/jhubctl
jhubctl/clusters/providers/aws/aws.py
AwsEKS.create_spot_nodes
def create_spot_nodes(self): """Create spot nodes. """ self.create_stack( self.spot_nodes_name, 'amazon-spot-nodes.yaml', parameters=define_parameters( ClusterName=self.cluster_name, Subnets=self.subnet_ids, Node...
python
def create_spot_nodes(self): """Create spot nodes. """ self.create_stack( self.spot_nodes_name, 'amazon-spot-nodes.yaml', parameters=define_parameters( ClusterName=self.cluster_name, Subnets=self.subnet_ids, Node...
[ "def", "create_spot_nodes", "(", "self", ")", ":", "self", ".", "create_stack", "(", "self", ".", "spot_nodes_name", ",", "'amazon-spot-nodes.yaml'", ",", "parameters", "=", "define_parameters", "(", "ClusterName", "=", "self", ".", "cluster_name", ",", "Subnets",...
Create spot nodes.
[ "Create", "spot", "nodes", "." ]
train
https://github.com/townsenddw/jhubctl/blob/c8c20f86a16e9d01dd90e4607d81423417cc773b/jhubctl/clusters/providers/aws/aws.py#L376-L390
townsenddw/jhubctl
jhubctl/clusters/providers/aws/aws.py
AwsEKS.create_utilities
def create_utilities(self): """Create utitilies stack. """ self.create_stack( self.utilities_name, 'amazon-utilities.yaml', parameters=define_parameters( Subnets=self.subnet_ids, NodeSecurityGroup=self.node_security_group ...
python
def create_utilities(self): """Create utitilies stack. """ self.create_stack( self.utilities_name, 'amazon-utilities.yaml', parameters=define_parameters( Subnets=self.subnet_ids, NodeSecurityGroup=self.node_security_group ...
[ "def", "create_utilities", "(", "self", ")", ":", "self", ".", "create_stack", "(", "self", ".", "utilities_name", ",", "'amazon-utilities.yaml'", ",", "parameters", "=", "define_parameters", "(", "Subnets", "=", "self", ".", "subnet_ids", ",", "NodeSecurityGroup"...
Create utitilies stack.
[ "Create", "utitilies", "stack", "." ]
train
https://github.com/townsenddw/jhubctl/blob/c8c20f86a16e9d01dd90e4607d81423417cc773b/jhubctl/clusters/providers/aws/aws.py#L392-L402
klen/muffin-debugtoolbar
muffin_debugtoolbar/plugin.py
debugtoolbar_middleware_factory
def debugtoolbar_middleware_factory(app, handler): """Setup Debug middleware.""" dbtb = app.ps.debugtoolbar @asyncio.coroutine def debugtoolbar_middleware(request): """Integrate to application.""" # Check for debugtoolbar is enabled for the request if not dbtb.cfg.enabled or an...
python
def debugtoolbar_middleware_factory(app, handler): """Setup Debug middleware.""" dbtb = app.ps.debugtoolbar @asyncio.coroutine def debugtoolbar_middleware(request): """Integrate to application.""" # Check for debugtoolbar is enabled for the request if not dbtb.cfg.enabled or an...
[ "def", "debugtoolbar_middleware_factory", "(", "app", ",", "handler", ")", ":", "dbtb", "=", "app", ".", "ps", ".", "debugtoolbar", "@", "asyncio", ".", "coroutine", "def", "debugtoolbar_middleware", "(", "request", ")", ":", "\"\"\"Integrate to application.\"\"\"",...
Setup Debug middleware.
[ "Setup", "Debug", "middleware", "." ]
train
https://github.com/klen/muffin-debugtoolbar/blob/b650b35fbe2035888f6bba5dac3073ef01c94dc6/muffin_debugtoolbar/plugin.py#L28-L89
klen/muffin-debugtoolbar
muffin_debugtoolbar/plugin.py
Plugin.setup
def setup(self, app): """Setup the plugin and prepare application.""" super(Plugin, self).setup(app) if 'jinja2' not in app.plugins: raise PluginException('The plugin requires Muffin-Jinja2 plugin installed.') self.cfg.prefix = self.cfg.prefix.rstrip('/') + '/' self...
python
def setup(self, app): """Setup the plugin and prepare application.""" super(Plugin, self).setup(app) if 'jinja2' not in app.plugins: raise PluginException('The plugin requires Muffin-Jinja2 plugin installed.') self.cfg.prefix = self.cfg.prefix.rstrip('/') + '/' self...
[ "def", "setup", "(", "self", ",", "app", ")", ":", "super", "(", "Plugin", ",", "self", ")", ".", "setup", "(", "app", ")", "if", "'jinja2'", "not", "in", "app", ".", "plugins", ":", "raise", "PluginException", "(", "'The plugin requires Muffin-Jinja2 plug...
Setup the plugin and prepare application.
[ "Setup", "the", "plugin", "and", "prepare", "application", "." ]
train
https://github.com/klen/muffin-debugtoolbar/blob/b650b35fbe2035888f6bba5dac3073ef01c94dc6/muffin_debugtoolbar/plugin.py#L119-L164
klen/muffin-debugtoolbar
muffin_debugtoolbar/plugin.py
Plugin.start
def start(self, app): """ Start application. """ app.middlewares.insert(0, debugtoolbar_middleware_factory) self.global_panels = [Panel(self.app) for Panel in self.cfg.global_panels]
python
def start(self, app): """ Start application. """ app.middlewares.insert(0, debugtoolbar_middleware_factory) self.global_panels = [Panel(self.app) for Panel in self.cfg.global_panels]
[ "def", "start", "(", "self", ",", "app", ")", ":", "app", ".", "middlewares", ".", "insert", "(", "0", ",", "debugtoolbar_middleware_factory", ")", "self", ".", "global_panels", "=", "[", "Panel", "(", "self", ".", "app", ")", "for", "Panel", "in", "se...
Start application.
[ "Start", "application", "." ]
train
https://github.com/klen/muffin-debugtoolbar/blob/b650b35fbe2035888f6bba5dac3073ef01c94dc6/muffin_debugtoolbar/plugin.py#L167-L170
klen/muffin-debugtoolbar
muffin_debugtoolbar/plugin.py
Plugin.inject
def inject(self, state, response): """ Inject Debug Toolbar code to response body. """ html = yield from self.app.ps.jinja2.render( 'debugtoolbar/inject.html', static_path=self.cfg.prefix + 'static', toolbar_url=self.cfg.prefix + state.id, ) html = htm...
python
def inject(self, state, response): """ Inject Debug Toolbar code to response body. """ html = yield from self.app.ps.jinja2.render( 'debugtoolbar/inject.html', static_path=self.cfg.prefix + 'static', toolbar_url=self.cfg.prefix + state.id, ) html = htm...
[ "def", "inject", "(", "self", ",", "state", ",", "response", ")", ":", "html", "=", "yield", "from", "self", ".", "app", ".", "ps", ".", "jinja2", ".", "render", "(", "'debugtoolbar/inject.html'", ",", "static_path", "=", "self", ".", "cfg", ".", "pref...
Inject Debug Toolbar code to response body.
[ "Inject", "Debug", "Toolbar", "code", "to", "response", "body", "." ]
train
https://github.com/klen/muffin-debugtoolbar/blob/b650b35fbe2035888f6bba5dac3073ef01c94dc6/muffin_debugtoolbar/plugin.py#L173-L182
klen/muffin-debugtoolbar
muffin_debugtoolbar/plugin.py
Plugin.view
def view(self, request): """ Debug Toolbar. """ auth = yield from self.authorize(request) if not auth: raise HTTPForbidden() request_id = request.match_info.get('request_id') state = self.history.get(request_id, None) response = yield from self.app.ps.jinja2...
python
def view(self, request): """ Debug Toolbar. """ auth = yield from self.authorize(request) if not auth: raise HTTPForbidden() request_id = request.match_info.get('request_id') state = self.history.get(request_id, None) response = yield from self.app.ps.jinja2...
[ "def", "view", "(", "self", ",", "request", ")", ":", "auth", "=", "yield", "from", "self", ".", "authorize", "(", "request", ")", "if", "not", "auth", ":", "raise", "HTTPForbidden", "(", ")", "request_id", "=", "request", ".", "match_info", ".", "get"...
Debug Toolbar.
[ "Debug", "Toolbar", "." ]
train
https://github.com/klen/muffin-debugtoolbar/blob/b650b35fbe2035888f6bba5dac3073ef01c94dc6/muffin_debugtoolbar/plugin.py#L185-L203
klen/muffin-debugtoolbar
muffin_debugtoolbar/plugin.py
Plugin.sse
def sse(self, request): """SSE.""" response = Response(status=200) response.content_type = 'text/event-stream' response.text = '' active_request_id = request.GET.get('request_id') client_last_request_id = str(request.headers.get('Last-Event-Id', 0)) if self.histor...
python
def sse(self, request): """SSE.""" response = Response(status=200) response.content_type = 'text/event-stream' response.text = '' active_request_id = request.GET.get('request_id') client_last_request_id = str(request.headers.get('Last-Event-Id', 0)) if self.histor...
[ "def", "sse", "(", "self", ",", "request", ")", ":", "response", "=", "Response", "(", "status", "=", "200", ")", "response", ".", "content_type", "=", "'text/event-stream'", "response", ".", "text", "=", "''", "active_request_id", "=", "request", ".", "GE...
SSE.
[ "SSE", "." ]
train
https://github.com/klen/muffin-debugtoolbar/blob/b650b35fbe2035888f6bba5dac3073ef01c94dc6/muffin_debugtoolbar/plugin.py#L227-L244
qbicsoftware/mtb-parser-lib
mtbparser/snv_item.py
SNVItem._format_dict
def _format_dict(self, info_dict): """Replaces empty content with 'NA's""" for key, value in info_dict.items(): if not value: info_dict[key] = "NA" return info_dict
python
def _format_dict(self, info_dict): """Replaces empty content with 'NA's""" for key, value in info_dict.items(): if not value: info_dict[key] = "NA" return info_dict
[ "def", "_format_dict", "(", "self", ",", "info_dict", ")", ":", "for", "key", ",", "value", "in", "info_dict", ".", "items", "(", ")", ":", "if", "not", "value", ":", "info_dict", "[", "key", "]", "=", "\"NA\"", "return", "info_dict" ]
Replaces empty content with 'NA's
[ "Replaces", "empty", "content", "with", "NA", "s" ]
train
https://github.com/qbicsoftware/mtb-parser-lib/blob/e8b96e34b27e457ea7def2927fe44017fa173ba7/mtbparser/snv_item.py#L6-L11