repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
daler/trackhub
trackhub/track.py
BaseTrack._str_subgroups
def _str_subgroups(self): """ helper function to render subgroups as a string """ if not self.subgroups: return "" return ['subGroups %s' % ' '.join(['%s=%s' % (k, v) for (k, v) in self.subgroups.items()])]
python
def _str_subgroups(self): """ helper function to render subgroups as a string """ if not self.subgroups: return "" return ['subGroups %s' % ' '.join(['%s=%s' % (k, v) for (k, v) in self.subgroups.items()])]
[ "def", "_str_subgroups", "(", "self", ")", ":", "if", "not", "self", ".", "subgroups", ":", "return", "\"\"", "return", "[", "'subGroups %s'", "%", "' '", ".", "join", "(", "[", "'%s=%s'", "%", "(", "k", ",", "v", ")", "for", "(", "k", ",", "v", ...
helper function to render subgroups as a string
[ "helper", "function", "to", "render", "subgroups", "as", "a", "string" ]
train
https://github.com/daler/trackhub/blob/e4655f79177822529f80b923df117e38e28df702/trackhub/track.py#L363-L371
daler/trackhub
trackhub/track.py
CompositeTrack.add_subgroups
def add_subgroups(self, subgroups): """ Add a list of SubGroupDefinition objects to this composite. Note that in contrast to :meth:`BaseTrack`, which takes a single dictionary indicating the particular subgroups for the track, this method takes a list of :class:`SubGroupDefiniti...
python
def add_subgroups(self, subgroups): """ Add a list of SubGroupDefinition objects to this composite. Note that in contrast to :meth:`BaseTrack`, which takes a single dictionary indicating the particular subgroups for the track, this method takes a list of :class:`SubGroupDefiniti...
[ "def", "add_subgroups", "(", "self", ",", "subgroups", ")", ":", "if", "subgroups", "is", "None", ":", "subgroups", "=", "{", "}", "_subgroups", "=", "{", "}", "for", "sg", "in", "subgroups", ":", "assert", "isinstance", "(", "sg", ",", "SubGroupDefiniti...
Add a list of SubGroupDefinition objects to this composite. Note that in contrast to :meth:`BaseTrack`, which takes a single dictionary indicating the particular subgroups for the track, this method takes a list of :class:`SubGroupDefinition` objects representing the allowed subgroups f...
[ "Add", "a", "list", "of", "SubGroupDefinition", "objects", "to", "this", "composite", "." ]
train
https://github.com/daler/trackhub/blob/e4655f79177822529f80b923df117e38e28df702/trackhub/track.py#L454-L472
daler/trackhub
trackhub/track.py
CompositeTrack.add_subtrack
def add_subtrack(self, subtrack): """ Add a child :class:`Track`. """ self.add_child(subtrack) self.subtracks.append(subtrack)
python
def add_subtrack(self, subtrack): """ Add a child :class:`Track`. """ self.add_child(subtrack) self.subtracks.append(subtrack)
[ "def", "add_subtrack", "(", "self", ",", "subtrack", ")", ":", "self", ".", "add_child", "(", "subtrack", ")", "self", ".", "subtracks", ".", "append", "(", "subtrack", ")" ]
Add a child :class:`Track`.
[ "Add", "a", "child", ":", "class", ":", "Track", "." ]
train
https://github.com/daler/trackhub/blob/e4655f79177822529f80b923df117e38e28df702/trackhub/track.py#L474-L479
daler/trackhub
trackhub/track.py
CompositeTrack.add_view
def add_view(self, view): """ Add a ViewTrack object to this composite. :param view: A ViewTrack object. """ self.add_child(view) self.views.append(view)
python
def add_view(self, view): """ Add a ViewTrack object to this composite. :param view: A ViewTrack object. """ self.add_child(view) self.views.append(view)
[ "def", "add_view", "(", "self", ",", "view", ")", ":", "self", ".", "add_child", "(", "view", ")", "self", ".", "views", ".", "append", "(", "view", ")" ]
Add a ViewTrack object to this composite. :param view: A ViewTrack object.
[ "Add", "a", "ViewTrack", "object", "to", "this", "composite", "." ]
train
https://github.com/daler/trackhub/blob/e4655f79177822529f80b923df117e38e28df702/trackhub/track.py#L481-L490
daler/trackhub
trackhub/track.py
CompositeTrack._str_subgroups
def _str_subgroups(self): """ renders subgroups to a list of strings """ s = [] i = 0 # if there are any views, there must be a subGroup1 view View tag=val # as the first one. So create it automatically here if len(self.views) > 0: mapping =...
python
def _str_subgroups(self): """ renders subgroups to a list of strings """ s = [] i = 0 # if there are any views, there must be a subGroup1 view View tag=val # as the first one. So create it automatically here if len(self.views) > 0: mapping =...
[ "def", "_str_subgroups", "(", "self", ")", ":", "s", "=", "[", "]", "i", "=", "0", "# if there are any views, there must be a subGroup1 view View tag=val", "# as the first one. So create it automatically here", "if", "len", "(", "self", ".", "views", ")", ">", "0", "...
renders subgroups to a list of strings
[ "renders", "subgroups", "to", "a", "list", "of", "strings" ]
train
https://github.com/daler/trackhub/blob/e4655f79177822529f80b923df117e38e28df702/trackhub/track.py#L492-L514
daler/trackhub
trackhub/track.py
ViewTrack.add_tracks
def add_tracks(self, subtracks): """ Add one or more tracks to this view. subtracks : Track or iterable of Tracks A single Track instance or an iterable of them. """ if isinstance(subtracks, Track): subtracks = [subtracks] for subtrack in subtrack...
python
def add_tracks(self, subtracks): """ Add one or more tracks to this view. subtracks : Track or iterable of Tracks A single Track instance or an iterable of them. """ if isinstance(subtracks, Track): subtracks = [subtracks] for subtrack in subtrack...
[ "def", "add_tracks", "(", "self", ",", "subtracks", ")", ":", "if", "isinstance", "(", "subtracks", ",", "Track", ")", ":", "subtracks", "=", "[", "subtracks", "]", "for", "subtrack", "in", "subtracks", ":", "subtrack", ".", "subgroups", "[", "'view'", "...
Add one or more tracks to this view. subtracks : Track or iterable of Tracks A single Track instance or an iterable of them.
[ "Add", "one", "or", "more", "tracks", "to", "this", "view", "." ]
train
https://github.com/daler/trackhub/blob/e4655f79177822529f80b923df117e38e28df702/trackhub/track.py#L570-L582
daler/trackhub
trackhub/track.py
SuperTrack.add_tracks
def add_tracks(self, subtracks): """ Add one or more tracks. subtrack : Track or iterable of Tracks """ if isinstance(subtracks, BaseTrack): subtracks = [subtracks] for subtrack in subtracks: self.add_child(subtrack) self.subtracks.app...
python
def add_tracks(self, subtracks): """ Add one or more tracks. subtrack : Track or iterable of Tracks """ if isinstance(subtracks, BaseTrack): subtracks = [subtracks] for subtrack in subtracks: self.add_child(subtrack) self.subtracks.app...
[ "def", "add_tracks", "(", "self", ",", "subtracks", ")", ":", "if", "isinstance", "(", "subtracks", ",", "BaseTrack", ")", ":", "subtracks", "=", "[", "subtracks", "]", "for", "subtrack", "in", "subtracks", ":", "self", ".", "add_child", "(", "subtrack", ...
Add one or more tracks. subtrack : Track or iterable of Tracks
[ "Add", "one", "or", "more", "tracks", "." ]
train
https://github.com/daler/trackhub/blob/e4655f79177822529f80b923df117e38e28df702/trackhub/track.py#L624-L634
mozilla/python_moztelemetry
moztelemetry/scalar.py
Scalar._parse_scalars
def _parse_scalars(scalars): """Parse the scalars from the YAML file content to a dictionary of ScalarType(s). :return: A dictionary { 'full.scalar.label': ScalarType } """ scalar_dict = {} # Scalars are defined in a fixed two-level hierarchy within the definition file. ...
python
def _parse_scalars(scalars): """Parse the scalars from the YAML file content to a dictionary of ScalarType(s). :return: A dictionary { 'full.scalar.label': ScalarType } """ scalar_dict = {} # Scalars are defined in a fixed two-level hierarchy within the definition file. ...
[ "def", "_parse_scalars", "(", "scalars", ")", ":", "scalar_dict", "=", "{", "}", "# Scalars are defined in a fixed two-level hierarchy within the definition file.", "# The first level contains the category name, while the second level contains the", "# probe name (e.g. \"category.name: probe...
Parse the scalars from the YAML file content to a dictionary of ScalarType(s). :return: A dictionary { 'full.scalar.label': ScalarType }
[ "Parse", "the", "scalars", "from", "the", "YAML", "file", "content", "to", "a", "dictionary", "of", "ScalarType", "(", "s", ")", ".", ":", "return", ":", "A", "dictionary", "{", "full", ".", "scalar", ".", "label", ":", "ScalarType", "}" ]
train
https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/scalar.py#L85-L106
mozilla/python_moztelemetry
moztelemetry/parse_scalars.py
load_scalars
def load_scalars(filename, strict_type_checks=True): """Parses a YAML file containing the scalar definition. :param filename: the YAML file containing the scalars definition. :raises ParserError: if the scalar file cannot be opened or parsed. """ # Parse the scalar definitions from the YAML file. ...
python
def load_scalars(filename, strict_type_checks=True): """Parses a YAML file containing the scalar definition. :param filename: the YAML file containing the scalars definition. :raises ParserError: if the scalar file cannot be opened or parsed. """ # Parse the scalar definitions from the YAML file. ...
[ "def", "load_scalars", "(", "filename", ",", "strict_type_checks", "=", "True", ")", ":", "# Parse the scalar definitions from the YAML file.", "scalars", "=", "None", "try", ":", "with", "open", "(", "filename", ",", "'r'", ")", "as", "f", ":", "scalars", "=", ...
Parses a YAML file containing the scalar definition. :param filename: the YAML file containing the scalars definition. :raises ParserError: if the scalar file cannot be opened or parsed.
[ "Parses", "a", "YAML", "file", "containing", "the", "scalar", "definition", "." ]
train
https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/parse_scalars.py#L294-L331
mozilla/python_moztelemetry
moztelemetry/parse_scalars.py
ScalarType.validate_names
def validate_names(self, category_name, probe_name): """Validate the category and probe name: - Category name must be alpha-numeric + '.', no leading/trailing digit or '.'. - Probe name must be alpha-numeric + '_', no leading/trailing digit or '_'. :param category_name: the name...
python
def validate_names(self, category_name, probe_name): """Validate the category and probe name: - Category name must be alpha-numeric + '.', no leading/trailing digit or '.'. - Probe name must be alpha-numeric + '_', no leading/trailing digit or '_'. :param category_name: the name...
[ "def", "validate_names", "(", "self", ",", "category_name", ",", "probe_name", ")", ":", "# Enforce a maximum length on category and probe names.", "MAX_NAME_LENGTH", "=", "40", "for", "n", "in", "[", "category_name", ",", "probe_name", "]", ":", "if", "len", "(", ...
Validate the category and probe name: - Category name must be alpha-numeric + '.', no leading/trailing digit or '.'. - Probe name must be alpha-numeric + '_', no leading/trailing digit or '_'. :param category_name: the name of the category the probe is in. :param probe_name: the...
[ "Validate", "the", "category", "and", "probe", "name", ":", "-", "Category", "name", "must", "be", "alpha", "-", "numeric", "+", ".", "no", "leading", "/", "trailing", "digit", "or", ".", ".", "-", "Probe", "name", "must", "be", "alpha", "-", "numeric"...
train
https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/parse_scalars.py#L44-L77
mozilla/python_moztelemetry
moztelemetry/parse_scalars.py
ScalarType.validate_types
def validate_types(self, definition): """This function performs some basic sanity checks on the scalar definition: - Checks that all the required fields are available. - Checks that all the fields have the expected types. :param definition: the dictionary containing the scalar p...
python
def validate_types(self, definition): """This function performs some basic sanity checks on the scalar definition: - Checks that all the required fields are available. - Checks that all the fields have the expected types. :param definition: the dictionary containing the scalar p...
[ "def", "validate_types", "(", "self", ",", "definition", ")", ":", "if", "not", "self", ".", "_strict_type_checks", ":", "return", "# The required and optional fields in a scalar type definition.", "REQUIRED_FIELDS", "=", "{", "'bug_numbers'", ":", "list", ",", "# This ...
This function performs some basic sanity checks on the scalar definition: - Checks that all the required fields are available. - Checks that all the fields have the expected types. :param definition: the dictionary containing the scalar properties. :raises ParserError: if a scal...
[ "This", "function", "performs", "some", "basic", "sanity", "checks", "on", "the", "scalar", "definition", ":", "-", "Checks", "that", "all", "the", "required", "fields", "are", "available", ".", "-", "Checks", "that", "all", "the", "fields", "have", "the", ...
train
https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/parse_scalars.py#L79-L156
mozilla/python_moztelemetry
moztelemetry/parse_scalars.py
ScalarType.validate_values
def validate_values(self, definition): """This function checks that the fields have the correct values. :param definition: the dictionary containing the scalar properties. :raises ParserError: if a scalar definition field contains an unexpected value. """ if not self._strict_ty...
python
def validate_values(self, definition): """This function checks that the fields have the correct values. :param definition: the dictionary containing the scalar properties. :raises ParserError: if a scalar definition field contains an unexpected value. """ if not self._strict_ty...
[ "def", "validate_values", "(", "self", ",", "definition", ")", ":", "if", "not", "self", ".", "_strict_type_checks", ":", "return", "# Validate the scalar kind.", "scalar_kind", "=", "definition", ".", "get", "(", "'kind'", ")", "if", "scalar_kind", "not", "in",...
This function checks that the fields have the correct values. :param definition: the dictionary containing the scalar properties. :raises ParserError: if a scalar definition field contains an unexpected value.
[ "This", "function", "checks", "that", "the", "fields", "have", "the", "correct", "values", "." ]
train
https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/parse_scalars.py#L158-L200
daler/trackhub
trackhub/base.py
HubComponent.add_child
def add_child(self, child): """ Adds self as parent to child, and then adds child. """ child.parent = self self.children.append(child) return child
python
def add_child(self, child): """ Adds self as parent to child, and then adds child. """ child.parent = self self.children.append(child) return child
[ "def", "add_child", "(", "self", ",", "child", ")", ":", "child", ".", "parent", "=", "self", "self", ".", "children", ".", "append", "(", "child", ")", "return", "child" ]
Adds self as parent to child, and then adds child.
[ "Adds", "self", "as", "parent", "to", "child", "and", "then", "adds", "child", "." ]
train
https://github.com/daler/trackhub/blob/e4655f79177822529f80b923df117e38e28df702/trackhub/base.py#L59-L65
daler/trackhub
trackhub/base.py
HubComponent.add_parent
def add_parent(self, parent): """ Adds self as child of parent, then adds parent. """ parent.add_child(self) self.parent = parent return parent
python
def add_parent(self, parent): """ Adds self as child of parent, then adds parent. """ parent.add_child(self) self.parent = parent return parent
[ "def", "add_parent", "(", "self", ",", "parent", ")", ":", "parent", ".", "add_child", "(", "self", ")", "self", ".", "parent", "=", "parent", "return", "parent" ]
Adds self as child of parent, then adds parent.
[ "Adds", "self", "as", "child", "of", "parent", "then", "adds", "parent", "." ]
train
https://github.com/daler/trackhub/blob/e4655f79177822529f80b923df117e38e28df702/trackhub/base.py#L67-L73
daler/trackhub
trackhub/base.py
HubComponent.root
def root(self, cls=None, level=0): """ Returns the top-most HubComponent in the hierarchy. If `cls` is not None, then return the top-most attribute HubComponent that is an instance of class `cls`. For a fully-constructed track hub (and `cls=None`), this should return a ...
python
def root(self, cls=None, level=0): """ Returns the top-most HubComponent in the hierarchy. If `cls` is not None, then return the top-most attribute HubComponent that is an instance of class `cls`. For a fully-constructed track hub (and `cls=None`), this should return a ...
[ "def", "root", "(", "self", ",", "cls", "=", "None", ",", "level", "=", "0", ")", ":", "if", "cls", "is", "None", ":", "if", "self", ".", "parent", "is", "None", ":", "return", "self", ",", "level", "else", ":", "if", "isinstance", "(", "self", ...
Returns the top-most HubComponent in the hierarchy. If `cls` is not None, then return the top-most attribute HubComponent that is an instance of class `cls`. For a fully-constructed track hub (and `cls=None`), this should return a a Hub object for every component in the hierarchy.
[ "Returns", "the", "top", "-", "most", "HubComponent", "in", "the", "hierarchy", "." ]
train
https://github.com/daler/trackhub/blob/e4655f79177822529f80b923df117e38e28df702/trackhub/base.py#L75-L96
daler/trackhub
trackhub/base.py
HubComponent.leaves
def leaves(self, cls, level=0, intermediate=False): """ Returns an iterator of the HubComponent leaves that are of class `cls`. If `intermediate` is True, then return any intermediate classes as well. """ if intermediate: if isinstance(self, cls): ...
python
def leaves(self, cls, level=0, intermediate=False): """ Returns an iterator of the HubComponent leaves that are of class `cls`. If `intermediate` is True, then return any intermediate classes as well. """ if intermediate: if isinstance(self, cls): ...
[ "def", "leaves", "(", "self", ",", "cls", ",", "level", "=", "0", ",", "intermediate", "=", "False", ")", ":", "if", "intermediate", ":", "if", "isinstance", "(", "self", ",", "cls", ")", ":", "yield", "self", ",", "level", "elif", "len", "(", "sel...
Returns an iterator of the HubComponent leaves that are of class `cls`. If `intermediate` is True, then return any intermediate classes as well.
[ "Returns", "an", "iterator", "of", "the", "HubComponent", "leaves", "that", "are", "of", "class", "cls", "." ]
train
https://github.com/daler/trackhub/blob/e4655f79177822529f80b923df117e38e28df702/trackhub/base.py#L98-L116
daler/trackhub
trackhub/base.py
HubComponent.render
def render(self, staging=None): """ Renders the object to file, returning a list of created files. Calls validation code, and, as long as each child is also a subclass of :class:`HubComponent`, the rendering is recursive. """ self.validate() created_files = Order...
python
def render(self, staging=None): """ Renders the object to file, returning a list of created files. Calls validation code, and, as long as each child is also a subclass of :class:`HubComponent`, the rendering is recursive. """ self.validate() created_files = Order...
[ "def", "render", "(", "self", ",", "staging", "=", "None", ")", ":", "self", ".", "validate", "(", ")", "created_files", "=", "OrderedDict", "(", ")", "if", "staging", "is", "None", ":", "staging", "=", "tempfile", ".", "mkdtemp", "(", ")", "this", "...
Renders the object to file, returning a list of created files. Calls validation code, and, as long as each child is also a subclass of :class:`HubComponent`, the rendering is recursive.
[ "Renders", "the", "object", "to", "file", "returning", "a", "list", "of", "created", "files", "." ]
train
https://github.com/daler/trackhub/blob/e4655f79177822529f80b923df117e38e28df702/trackhub/base.py#L118-L134
Karaage-Cluster/karaage
karaage/plugins/kgapplications/emails.py
send_request_email
def send_request_email( authorised_text, authorised_role, authorised_persons, application, link, is_secret): """Sends an email to admin asking to approve user application""" context = CONTEXT.copy() context['requester'] = application.applicant context['link'] = link context['is_secre...
python
def send_request_email( authorised_text, authorised_role, authorised_persons, application, link, is_secret): """Sends an email to admin asking to approve user application""" context = CONTEXT.copy() context['requester'] = application.applicant context['link'] = link context['is_secre...
[ "def", "send_request_email", "(", "authorised_text", ",", "authorised_role", ",", "authorised_persons", ",", "application", ",", "link", ",", "is_secret", ")", ":", "context", "=", "CONTEXT", ".", "copy", "(", ")", "context", "[", "'requester'", "]", "=", "app...
Sends an email to admin asking to approve user application
[ "Sends", "an", "email", "to", "admin", "asking", "to", "approve", "user", "application" ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/emails.py#L66-L79
Karaage-Cluster/karaage
karaage/plugins/kgapplications/emails.py
send_invite_email
def send_invite_email(application, link, is_secret): """ Sends an email inviting someone to create an account""" if not application.applicant.email: return context = CONTEXT.copy() context['receiver'] = application.applicant context['application'] = application context['link'] = link ...
python
def send_invite_email(application, link, is_secret): """ Sends an email inviting someone to create an account""" if not application.applicant.email: return context = CONTEXT.copy() context['receiver'] = application.applicant context['application'] = application context['link'] = link ...
[ "def", "send_invite_email", "(", "application", ",", "link", ",", "is_secret", ")", ":", "if", "not", "application", ".", "applicant", ".", "email", ":", "return", "context", "=", "CONTEXT", ".", "copy", "(", ")", "context", "[", "'receiver'", "]", "=", ...
Sends an email inviting someone to create an account
[ "Sends", "an", "email", "inviting", "someone", "to", "create", "an", "account" ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/emails.py#L98-L113
Karaage-Cluster/karaage
karaage/plugins/kgapplications/emails.py
send_approved_email
def send_approved_email( application, created_person, created_account, link, is_secret): """Sends an email informing person application is approved""" if not application.applicant.email: return context = CONTEXT.copy() context['receiver'] = application.applicant context['application...
python
def send_approved_email( application, created_person, created_account, link, is_secret): """Sends an email informing person application is approved""" if not application.applicant.email: return context = CONTEXT.copy() context['receiver'] = application.applicant context['application...
[ "def", "send_approved_email", "(", "application", ",", "created_person", ",", "created_account", ",", "link", ",", "is_secret", ")", ":", "if", "not", "application", ".", "applicant", ".", "email", ":", "return", "context", "=", "CONTEXT", ".", "copy", "(", ...
Sends an email informing person application is approved
[ "Sends", "an", "email", "informing", "person", "application", "is", "approved" ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/emails.py#L116-L132
Karaage-Cluster/karaage
karaage/people/models.py
_add_person_to_group
def _add_person_to_group(person, group): """ Call datastores after adding a person to a group. """ from karaage.datastores import add_accounts_to_group from karaage.datastores import add_accounts_to_project from karaage.datastores import add_accounts_to_institute a_list = person.account_set add...
python
def _add_person_to_group(person, group): """ Call datastores after adding a person to a group. """ from karaage.datastores import add_accounts_to_group from karaage.datastores import add_accounts_to_project from karaage.datastores import add_accounts_to_institute a_list = person.account_set add...
[ "def", "_add_person_to_group", "(", "person", ",", "group", ")", ":", "from", "karaage", ".", "datastores", "import", "add_accounts_to_group", "from", "karaage", ".", "datastores", "import", "add_accounts_to_project", "from", "karaage", ".", "datastores", "import", ...
Call datastores after adding a person to a group.
[ "Call", "datastores", "after", "adding", "a", "person", "to", "a", "group", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/people/models.py#L461-L472
Karaage-Cluster/karaage
karaage/people/models.py
_remove_person_from_group
def _remove_person_from_group(person, group): """ Call datastores after removing a person from a group. """ from karaage.datastores import remove_accounts_from_group from karaage.datastores import remove_accounts_from_project from karaage.datastores import remove_accounts_from_institute a_list = pe...
python
def _remove_person_from_group(person, group): """ Call datastores after removing a person from a group. """ from karaage.datastores import remove_accounts_from_group from karaage.datastores import remove_accounts_from_project from karaage.datastores import remove_accounts_from_institute a_list = pe...
[ "def", "_remove_person_from_group", "(", "person", ",", "group", ")", ":", "from", "karaage", ".", "datastores", "import", "remove_accounts_from_group", "from", "karaage", ".", "datastores", "import", "remove_accounts_from_project", "from", "karaage", ".", "datastores",...
Call datastores after removing a person from a group.
[ "Call", "datastores", "after", "removing", "a", "person", "from", "a", "group", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/people/models.py#L475-L486
Karaage-Cluster/karaage
karaage/people/models.py
_members_changed
def _members_changed( sender, instance, action, reverse, model, pk_set, **kwargs): """ Hook that executes whenever the group members are changed. """ if action == "post_add": if not reverse: group = instance for person in model.objects.filter(pk__in=pk_set): ...
python
def _members_changed( sender, instance, action, reverse, model, pk_set, **kwargs): """ Hook that executes whenever the group members are changed. """ if action == "post_add": if not reverse: group = instance for person in model.objects.filter(pk__in=pk_set): ...
[ "def", "_members_changed", "(", "sender", ",", "instance", ",", "action", ",", "reverse", ",", "model", ",", "pk_set", ",", "*", "*", "kwargs", ")", ":", "if", "action", "==", "\"post_add\"", ":", "if", "not", "reverse", ":", "group", "=", "instance", ...
Hook that executes whenever the group members are changed.
[ "Hook", "that", "executes", "whenever", "the", "group", "members", "are", "changed", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/people/models.py#L489-L536
daler/trackhub
trackhub/helpers.py
dimensions_from_subgroups
def dimensions_from_subgroups(s): """ Given a sorted list of subgroups, return a string appropriate to provide as a composite track's `dimensions` arg. Parameters ---------- s : list of SubGroup objects (or anything with a `name` attribute) """ letters = 'XYABCDEFGHIJKLMNOPQRSTUVWZ' ...
python
def dimensions_from_subgroups(s): """ Given a sorted list of subgroups, return a string appropriate to provide as a composite track's `dimensions` arg. Parameters ---------- s : list of SubGroup objects (or anything with a `name` attribute) """ letters = 'XYABCDEFGHIJKLMNOPQRSTUVWZ' ...
[ "def", "dimensions_from_subgroups", "(", "s", ")", ":", "letters", "=", "'XYABCDEFGHIJKLMNOPQRSTUVWZ'", "return", "' '", ".", "join", "(", "[", "'dim{0}={1}'", ".", "format", "(", "dim", ",", "sg", ".", "name", ")", "for", "dim", ",", "sg", "in", "zip", ...
Given a sorted list of subgroups, return a string appropriate to provide as a composite track's `dimensions` arg. Parameters ---------- s : list of SubGroup objects (or anything with a `name` attribute)
[ "Given", "a", "sorted", "list", "of", "subgroups", "return", "a", "string", "appropriate", "to", "provide", "as", "a", "composite", "track", "s", "dimensions", "arg", "." ]
train
https://github.com/daler/trackhub/blob/e4655f79177822529f80b923df117e38e28df702/trackhub/helpers.py#L12-L22
daler/trackhub
trackhub/helpers.py
filter_composite_from_subgroups
def filter_composite_from_subgroups(s): """ Given a sorted list of subgroups, return a string appropriate to provide as the a composite track's `filterComposite` argument >>> import trackhub >>> trackhub.helpers.filter_composite_from_subgroups(['cell', 'ab', 'lab', 'knockdown']) 'dimA dimB' ...
python
def filter_composite_from_subgroups(s): """ Given a sorted list of subgroups, return a string appropriate to provide as the a composite track's `filterComposite` argument >>> import trackhub >>> trackhub.helpers.filter_composite_from_subgroups(['cell', 'ab', 'lab', 'knockdown']) 'dimA dimB' ...
[ "def", "filter_composite_from_subgroups", "(", "s", ")", ":", "dims", "=", "[", "]", "for", "letter", ",", "sg", "in", "zip", "(", "'ABCDEFGHIJKLMNOPQRSTUVWZ'", ",", "s", "[", "2", ":", "]", ")", ":", "dims", ".", "append", "(", "'dim{0}'", ".", "forma...
Given a sorted list of subgroups, return a string appropriate to provide as the a composite track's `filterComposite` argument >>> import trackhub >>> trackhub.helpers.filter_composite_from_subgroups(['cell', 'ab', 'lab', 'knockdown']) 'dimA dimB' Parameters ---------- s : list A l...
[ "Given", "a", "sorted", "list", "of", "subgroups", "return", "a", "string", "appropriate", "to", "provide", "as", "the", "a", "composite", "track", "s", "filterComposite", "argument" ]
train
https://github.com/daler/trackhub/blob/e4655f79177822529f80b923df117e38e28df702/trackhub/helpers.py#L25-L45
daler/trackhub
trackhub/helpers.py
hex2rgb
def hex2rgb(h): """ Convert hex colors to RGB tuples Parameters ---------- h : str String hex color value >>> hex2rgb("#ff0033") '255,0,51' """ if not h.startswith('#') or len(h) != 7: raise ValueError("Does not look like a hex color: '{0}'".format(h)) return ',...
python
def hex2rgb(h): """ Convert hex colors to RGB tuples Parameters ---------- h : str String hex color value >>> hex2rgb("#ff0033") '255,0,51' """ if not h.startswith('#') or len(h) != 7: raise ValueError("Does not look like a hex color: '{0}'".format(h)) return ',...
[ "def", "hex2rgb", "(", "h", ")", ":", "if", "not", "h", ".", "startswith", "(", "'#'", ")", "or", "len", "(", "h", ")", "!=", "7", ":", "raise", "ValueError", "(", "\"Does not look like a hex color: '{0}'\"", ".", "format", "(", "h", ")", ")", "return"...
Convert hex colors to RGB tuples Parameters ---------- h : str String hex color value >>> hex2rgb("#ff0033") '255,0,51'
[ "Convert", "hex", "colors", "to", "RGB", "tuples" ]
train
https://github.com/daler/trackhub/blob/e4655f79177822529f80b923df117e38e28df702/trackhub/helpers.py#L48-L66
daler/trackhub
trackhub/helpers.py
sanitize
def sanitize(s, strict=True): """ Sanitize a string. Spaces are converted to underscore; if strict=True they are then removed. Parameters ---------- s : str String to sanitize strict : bool If True, only alphanumeric characters are allowed. If False, a limited set ...
python
def sanitize(s, strict=True): """ Sanitize a string. Spaces are converted to underscore; if strict=True they are then removed. Parameters ---------- s : str String to sanitize strict : bool If True, only alphanumeric characters are allowed. If False, a limited set ...
[ "def", "sanitize", "(", "s", ",", "strict", "=", "True", ")", ":", "allowed", "=", "''", ".", "join", "(", "[", "'ABCDEFGHIJKLMNOPQRSTUVWXYZ'", ",", "'abcdefghijklmnopqrstuvwxyz'", ",", "'0123456789'", ",", "]", ")", "if", "not", "strict", ":", "allowed", ...
Sanitize a string. Spaces are converted to underscore; if strict=True they are then removed. Parameters ---------- s : str String to sanitize strict : bool If True, only alphanumeric characters are allowed. If False, a limited set of additional characters (-._) will be all...
[ "Sanitize", "a", "string", "." ]
train
https://github.com/daler/trackhub/blob/e4655f79177822529f80b923df117e38e28df702/trackhub/helpers.py#L69-L97
daler/trackhub
trackhub/helpers.py
auto_track_url
def auto_track_url(track): """ Automatically sets the bigDataUrl for `track`. Requirements: * the track must be fully connected, such that its root is a Hub object * the root Hub object must have the Hub.url attribute set * the track must have the `source` attribute set """ ...
python
def auto_track_url(track): """ Automatically sets the bigDataUrl for `track`. Requirements: * the track must be fully connected, such that its root is a Hub object * the root Hub object must have the Hub.url attribute set * the track must have the `source` attribute set """ ...
[ "def", "auto_track_url", "(", "track", ")", ":", "hub", "=", "track", ".", "root", "(", "cls", "=", "Hub", ")", "if", "hub", "is", "None", ":", "raise", "ValueError", "(", "\"track is not fully connected because the root is %s\"", "%", "repr", "(", "hub", ")...
Automatically sets the bigDataUrl for `track`. Requirements: * the track must be fully connected, such that its root is a Hub object * the root Hub object must have the Hub.url attribute set * the track must have the `source` attribute set
[ "Automatically", "sets", "the", "bigDataUrl", "for", "track", "." ]
train
https://github.com/daler/trackhub/blob/e4655f79177822529f80b923df117e38e28df702/trackhub/helpers.py#L100-L118
daler/trackhub
trackhub/helpers.py
show_rendered_files
def show_rendered_files(results_dict): """ Parses a nested dictionary returned from :meth:`Hub.render` and just prints the resulting files. """ for k, v in results_dict.items(): if isinstance(v, string_types): print("rendered file: %s (created by: %s)" % (v, k)) else: ...
python
def show_rendered_files(results_dict): """ Parses a nested dictionary returned from :meth:`Hub.render` and just prints the resulting files. """ for k, v in results_dict.items(): if isinstance(v, string_types): print("rendered file: %s (created by: %s)" % (v, k)) else: ...
[ "def", "show_rendered_files", "(", "results_dict", ")", ":", "for", "k", ",", "v", "in", "results_dict", ".", "items", "(", ")", ":", "if", "isinstance", "(", "v", ",", "string_types", ")", ":", "print", "(", "\"rendered file: %s (created by: %s)\"", "%", "(...
Parses a nested dictionary returned from :meth:`Hub.render` and just prints the resulting files.
[ "Parses", "a", "nested", "dictionary", "returned", "from", ":", "meth", ":", "Hub", ".", "render", "and", "just", "prints", "the", "resulting", "files", "." ]
train
https://github.com/daler/trackhub/blob/e4655f79177822529f80b923df117e38e28df702/trackhub/helpers.py#L121-L131
daler/trackhub
trackhub/helpers.py
print_rendered_results
def print_rendered_results(results_dict): """ Pretty-prints the rendered results dictionary. Rendered results can be multiply-nested dictionaries; this uses JSON serialization to print a nice representation. """ class _HubComponentEncoder(json.JSONEncoder): def default(self, o): ...
python
def print_rendered_results(results_dict): """ Pretty-prints the rendered results dictionary. Rendered results can be multiply-nested dictionaries; this uses JSON serialization to print a nice representation. """ class _HubComponentEncoder(json.JSONEncoder): def default(self, o): ...
[ "def", "print_rendered_results", "(", "results_dict", ")", ":", "class", "_HubComponentEncoder", "(", "json", ".", "JSONEncoder", ")", ":", "def", "default", "(", "self", ",", "o", ")", ":", "if", "isinstance", "(", "o", ",", "base", ".", "HubComponent", "...
Pretty-prints the rendered results dictionary. Rendered results can be multiply-nested dictionaries; this uses JSON serialization to print a nice representation.
[ "Pretty", "-", "prints", "the", "rendered", "results", "dictionary", "." ]
train
https://github.com/daler/trackhub/blob/e4655f79177822529f80b923df117e38e28df702/trackhub/helpers.py#L134-L150
daler/trackhub
trackhub/helpers.py
example_bigbeds
def example_bigbeds(): """ Returns list of example bigBed files """ hits = [] d = data_dir() for fn in os.listdir(d): fn = os.path.join(d, fn) if os.path.splitext(fn)[-1] == '.bigBed': hits.append(os.path.abspath(fn)) return hits
python
def example_bigbeds(): """ Returns list of example bigBed files """ hits = [] d = data_dir() for fn in os.listdir(d): fn = os.path.join(d, fn) if os.path.splitext(fn)[-1] == '.bigBed': hits.append(os.path.abspath(fn)) return hits
[ "def", "example_bigbeds", "(", ")", ":", "hits", "=", "[", "]", "d", "=", "data_dir", "(", ")", "for", "fn", "in", "os", ".", "listdir", "(", "d", ")", ":", "fn", "=", "os", ".", "path", ".", "join", "(", "d", ",", "fn", ")", "if", "os", "....
Returns list of example bigBed files
[ "Returns", "list", "of", "example", "bigBed", "files" ]
train
https://github.com/daler/trackhub/blob/e4655f79177822529f80b923df117e38e28df702/trackhub/helpers.py#L161-L171
Karaage-Cluster/karaage
karaage/plugins/kgusage/graphs.py
get_colour
def get_colour(index): """ get color number index. """ colours = [ 'red', 'blue', 'green', 'pink', 'yellow', 'magenta', 'orange', 'cyan', ] default_colour = 'purple' if index < len(colours): return colours[index] else: return default_colour
python
def get_colour(index): """ get color number index. """ colours = [ 'red', 'blue', 'green', 'pink', 'yellow', 'magenta', 'orange', 'cyan', ] default_colour = 'purple' if index < len(colours): return colours[index] else: return default_colour
[ "def", "get_colour", "(", "index", ")", ":", "colours", "=", "[", "'red'", ",", "'blue'", ",", "'green'", ",", "'pink'", ",", "'yellow'", ",", "'magenta'", ",", "'orange'", ",", "'cyan'", ",", "]", "default_colour", "=", "'purple'", "if", "index", "<", ...
get color number index.
[ "get", "color", "number", "index", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgusage/graphs.py#L32-L42
Karaage-Cluster/karaage
karaage/plugins/kgusage/graphs.py
get_project_trend_graph_url
def get_project_trend_graph_url(project, start, end): """Generates a bar graph for a project. """ filename = get_project_trend_graph_filename(project, start, end) urls = { 'graph_url': urlparse.urljoin(GRAPH_URL, filename + ".png"), 'data_url': urlparse.urljoin(GRAPH_URL, filename + ".csv")...
python
def get_project_trend_graph_url(project, start, end): """Generates a bar graph for a project. """ filename = get_project_trend_graph_filename(project, start, end) urls = { 'graph_url': urlparse.urljoin(GRAPH_URL, filename + ".png"), 'data_url': urlparse.urljoin(GRAPH_URL, filename + ".csv")...
[ "def", "get_project_trend_graph_url", "(", "project", ",", "start", ",", "end", ")", ":", "filename", "=", "get_project_trend_graph_filename", "(", "project", ",", "start", ",", "end", ")", "urls", "=", "{", "'graph_url'", ":", "urlparse", ".", "urljoin", "(",...
Generates a bar graph for a project.
[ "Generates", "a", "bar", "graph", "for", "a", "project", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgusage/graphs.py#L102-L111
Karaage-Cluster/karaage
karaage/plugins/kgusage/graphs.py
get_institute_graph_url
def get_institute_graph_url(start, end): """ Pie chart comparing institutes usage. """ filename = get_institute_graph_filename(start, end) urls = { 'graph_url': urlparse.urljoin(GRAPH_URL, filename + ".png"), 'data_url': urlparse.urljoin(GRAPH_URL, filename + ".csv"), } return urls
python
def get_institute_graph_url(start, end): """ Pie chart comparing institutes usage. """ filename = get_institute_graph_filename(start, end) urls = { 'graph_url': urlparse.urljoin(GRAPH_URL, filename + ".png"), 'data_url': urlparse.urljoin(GRAPH_URL, filename + ".csv"), } return urls
[ "def", "get_institute_graph_url", "(", "start", ",", "end", ")", ":", "filename", "=", "get_institute_graph_filename", "(", "start", ",", "end", ")", "urls", "=", "{", "'graph_url'", ":", "urlparse", ".", "urljoin", "(", "GRAPH_URL", ",", "filename", "+", "\...
Pie chart comparing institutes usage.
[ "Pie", "chart", "comparing", "institutes", "usage", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgusage/graphs.py#L114-L123
Karaage-Cluster/karaage
karaage/plugins/kgusage/graphs.py
get_machine_graph_url
def get_machine_graph_url(start, end): """ Pie chart comparing machines usage. """ filename = get_machine_graph_filename(start, end) urls = { 'graph_url': urlparse.urljoin(GRAPH_URL, filename + ".png"), 'data_url': urlparse.urljoin(GRAPH_URL, filename + ".csv"), } return urls
python
def get_machine_graph_url(start, end): """ Pie chart comparing machines usage. """ filename = get_machine_graph_filename(start, end) urls = { 'graph_url': urlparse.urljoin(GRAPH_URL, filename + ".png"), 'data_url': urlparse.urljoin(GRAPH_URL, filename + ".csv"), } return urls
[ "def", "get_machine_graph_url", "(", "start", ",", "end", ")", ":", "filename", "=", "get_machine_graph_filename", "(", "start", ",", "end", ")", "urls", "=", "{", "'graph_url'", ":", "urlparse", ".", "urljoin", "(", "GRAPH_URL", ",", "filename", "+", "\".pn...
Pie chart comparing machines usage.
[ "Pie", "chart", "comparing", "machines", "usage", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgusage/graphs.py#L126-L135
Karaage-Cluster/karaage
karaage/plugins/kgusage/graphs.py
get_trend_graph_url
def get_trend_graph_url(start, end): """ Total trend graph for machine category. """ filename = get_trend_graph_filename(start, end) urls = { 'graph_url': urlparse.urljoin(GRAPH_URL, filename + ".png"), 'data_url': urlparse.urljoin(GRAPH_URL, filename + ".csv"), } return urls
python
def get_trend_graph_url(start, end): """ Total trend graph for machine category. """ filename = get_trend_graph_filename(start, end) urls = { 'graph_url': urlparse.urljoin(GRAPH_URL, filename + ".png"), 'data_url': urlparse.urljoin(GRAPH_URL, filename + ".csv"), } return urls
[ "def", "get_trend_graph_url", "(", "start", ",", "end", ")", ":", "filename", "=", "get_trend_graph_filename", "(", "start", ",", "end", ")", "urls", "=", "{", "'graph_url'", ":", "urlparse", ".", "urljoin", "(", "GRAPH_URL", ",", "filename", "+", "\".png\""...
Total trend graph for machine category.
[ "Total", "trend", "graph", "for", "machine", "category", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgusage/graphs.py#L138-L147
Karaage-Cluster/karaage
karaage/plugins/kgusage/graphs.py
get_institute_trend_graph_url
def get_institute_trend_graph_url(institute, start, end): """ Institute trend graph for machine category. """ filename = get_institute_trend_graph_filename(institute, start, end) urls = { 'graph_url': urlparse.urljoin(GRAPH_URL, filename + ".png"), 'data_url': urlparse.urljoin(GRAPH_URL, fi...
python
def get_institute_trend_graph_url(institute, start, end): """ Institute trend graph for machine category. """ filename = get_institute_trend_graph_filename(institute, start, end) urls = { 'graph_url': urlparse.urljoin(GRAPH_URL, filename + ".png"), 'data_url': urlparse.urljoin(GRAPH_URL, fi...
[ "def", "get_institute_trend_graph_url", "(", "institute", ",", "start", ",", "end", ")", ":", "filename", "=", "get_institute_trend_graph_filename", "(", "institute", ",", "start", ",", "end", ")", "urls", "=", "{", "'graph_url'", ":", "urlparse", ".", "urljoin"...
Institute trend graph for machine category.
[ "Institute", "trend", "graph", "for", "machine", "category", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgusage/graphs.py#L150-L159
Karaage-Cluster/karaage
karaage/plugins/kgusage/graphs.py
get_institutes_trend_graph_urls
def get_institutes_trend_graph_urls(start, end): """ Get all institute trend graphs. """ graph_list = [] for institute in Institute.objects.all(): urls = get_institute_trend_graph_url(institute, start, end) urls['institute'] = institute graph_list.append(urls) return graph_list
python
def get_institutes_trend_graph_urls(start, end): """ Get all institute trend graphs. """ graph_list = [] for institute in Institute.objects.all(): urls = get_institute_trend_graph_url(institute, start, end) urls['institute'] = institute graph_list.append(urls) return graph_list
[ "def", "get_institutes_trend_graph_urls", "(", "start", ",", "end", ")", ":", "graph_list", "=", "[", "]", "for", "institute", "in", "Institute", ".", "objects", ".", "all", "(", ")", ":", "urls", "=", "get_institute_trend_graph_url", "(", "institute", ",", ...
Get all institute trend graphs.
[ "Get", "all", "institute", "trend", "graphs", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgusage/graphs.py#L162-L171
Karaage-Cluster/karaage
karaage/common/context_processors.py
common
def common(request): """ Set context with common variables. """ ctx = { 'SHIB_SUPPORTED': settings.SHIB_SUPPORTED, 'org_name': settings.ACCOUNTS_ORG_NAME, 'accounts_email': settings.ACCOUNTS_EMAIL, 'is_admin': is_admin(request), 'kgversion': __version__, 'BUILD_DA...
python
def common(request): """ Set context with common variables. """ ctx = { 'SHIB_SUPPORTED': settings.SHIB_SUPPORTED, 'org_name': settings.ACCOUNTS_ORG_NAME, 'accounts_email': settings.ACCOUNTS_EMAIL, 'is_admin': is_admin(request), 'kgversion': __version__, 'BUILD_DA...
[ "def", "common", "(", "request", ")", ":", "ctx", "=", "{", "'SHIB_SUPPORTED'", ":", "settings", ".", "SHIB_SUPPORTED", ",", "'org_name'", ":", "settings", ".", "ACCOUNTS_ORG_NAME", ",", "'accounts_email'", ":", "settings", ".", "ACCOUNTS_EMAIL", ",", "'is_admin...
Set context with common variables.
[ "Set", "context", "with", "common", "variables", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/common/context_processors.py#L25-L38
Karaage-Cluster/karaage
karaage/plugins/kgapplications/__init__.py
context_processor
def context_processor(request): """ Set context with common variables. """ from .models import Application ctx = {} if request.user.is_authenticated: person = request.user my_applications = Application.objects.get_for_applicant(person) requires_attention = Application.objects.re...
python
def context_processor(request): """ Set context with common variables. """ from .models import Application ctx = {} if request.user.is_authenticated: person = request.user my_applications = Application.objects.get_for_applicant(person) requires_attention = Application.objects.re...
[ "def", "context_processor", "(", "request", ")", ":", "from", ".", "models", "import", "Application", "ctx", "=", "{", "}", "if", "request", ".", "user", ".", "is_authenticated", ":", "person", "=", "request", ".", "user", "my_applications", "=", "Applicatio...
Set context with common variables.
[ "Set", "context", "with", "common", "variables", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/__init__.py#L37-L51
Karaage-Cluster/karaage
karaage/people/managers.py
PersonManager._create_user
def _create_user( self, username, email, short_name, full_name, institute, password, is_admin, **extra_fields): """Creates a new active person. """ # Create Person person = self.model( username=username, email=email, short_name=short_name, full_na...
python
def _create_user( self, username, email, short_name, full_name, institute, password, is_admin, **extra_fields): """Creates a new active person. """ # Create Person person = self.model( username=username, email=email, short_name=short_name, full_na...
[ "def", "_create_user", "(", "self", ",", "username", ",", "email", ",", "short_name", ",", "full_name", ",", "institute", ",", "password", ",", "is_admin", ",", "*", "*", "extra_fields", ")", ":", "# Create Person", "person", "=", "self", ".", "model", "("...
Creates a new active person.
[ "Creates", "a", "new", "active", "person", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/people/managers.py#L31-L46
Karaage-Cluster/karaage
karaage/people/managers.py
PersonManager.create_user
def create_user( self, username, email, short_name, full_name, institute, password=None, **extra_fields): """ Creates a new ordinary person. """ return self._create_user( username=username, email=email, short_name=short_name, full_name=full_name, ...
python
def create_user( self, username, email, short_name, full_name, institute, password=None, **extra_fields): """ Creates a new ordinary person. """ return self._create_user( username=username, email=email, short_name=short_name, full_name=full_name, ...
[ "def", "create_user", "(", "self", ",", "username", ",", "email", ",", "short_name", ",", "full_name", ",", "institute", ",", "password", "=", "None", ",", "*", "*", "extra_fields", ")", ":", "return", "self", ".", "_create_user", "(", "username", "=", "...
Creates a new ordinary person.
[ "Creates", "a", "new", "ordinary", "person", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/people/managers.py#L48-L56
Karaage-Cluster/karaage
karaage/people/managers.py
PersonManager.create_superuser
def create_superuser( self, username, email, short_name, full_name, institute, password, **extra_fields): """ Creates a new person with super powers. """ return self._create_user( username=username, email=email, institute=institute, password=password, ...
python
def create_superuser( self, username, email, short_name, full_name, institute, password, **extra_fields): """ Creates a new person with super powers. """ return self._create_user( username=username, email=email, institute=institute, password=password, ...
[ "def", "create_superuser", "(", "self", ",", "username", ",", "email", ",", "short_name", ",", "full_name", ",", "institute", ",", "password", ",", "*", "*", "extra_fields", ")", ":", "return", "self", ".", "_create_user", "(", "username", "=", "username", ...
Creates a new person with super powers.
[ "Creates", "a", "new", "person", "with", "super", "powers", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/people/managers.py#L58-L66
Karaage-Cluster/karaage
karaage/plugins/kgapplications/templatetags/applications.py
application_state
def application_state(context, application): """ Render current state of application, verbose. """ new_context = { 'roles': context['roles'], 'org_name': context['org_name'], 'application': application, } nodelist = template.loader.get_template( 'kgapplications/%s_common_...
python
def application_state(context, application): """ Render current state of application, verbose. """ new_context = { 'roles': context['roles'], 'org_name': context['org_name'], 'application': application, } nodelist = template.loader.get_template( 'kgapplications/%s_common_...
[ "def", "application_state", "(", "context", ",", "application", ")", ":", "new_context", "=", "{", "'roles'", ":", "context", "[", "'roles'", "]", ",", "'org_name'", ":", "context", "[", "'org_name'", "]", ",", "'application'", ":", "application", ",", "}", ...
Render current state of application, verbose.
[ "Render", "current", "state", "of", "application", "verbose", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/templatetags/applications.py#L33-L43
Karaage-Cluster/karaage
karaage/plugins/kgapplications/templatetags/applications.py
application_simple_state
def application_simple_state(context, application): """ Render current state of application, verbose. """ state_machine = get_state_machine(application) state = state_machine.get_state(application) return state.name
python
def application_simple_state(context, application): """ Render current state of application, verbose. """ state_machine = get_state_machine(application) state = state_machine.get_state(application) return state.name
[ "def", "application_simple_state", "(", "context", ",", "application", ")", ":", "state_machine", "=", "get_state_machine", "(", "application", ")", "state", "=", "state_machine", ".", "get_state", "(", "application", ")", "return", "state", ".", "name" ]
Render current state of application, verbose.
[ "Render", "current", "state", "of", "application", "verbose", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/templatetags/applications.py#L61-L65
Karaage-Cluster/karaage
karaage/plugins/kgapplications/templatetags/applications.py
do_application_actions_plus
def do_application_actions_plus(parser, token): """ Render actions available with extra text. """ nodelist = parser.parse(('end_application_actions',)) parser.delete_first_token() return ApplicationActionsPlus(nodelist)
python
def do_application_actions_plus(parser, token): """ Render actions available with extra text. """ nodelist = parser.parse(('end_application_actions',)) parser.delete_first_token() return ApplicationActionsPlus(nodelist)
[ "def", "do_application_actions_plus", "(", "parser", ",", "token", ")", ":", "nodelist", "=", "parser", ".", "parse", "(", "(", "'end_application_actions'", ",", ")", ")", "parser", ".", "delete_first_token", "(", ")", "return", "ApplicationActionsPlus", "(", "n...
Render actions available with extra text.
[ "Render", "actions", "available", "with", "extra", "text", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/templatetags/applications.py#L80-L84
daler/trackhub
trackhub/upload.py
run
def run(cmds, **kwargs): """ Wrapper around subprocess.run, with unicode decoding of output. Additional kwargs are passed to subprocess.run. """ proc = sp.Popen(cmds, bufsize=-1, stdout=sp.PIPE, stderr=sp.STDOUT, close_fds=sys.platform != 'win32') for line in proc.stdout: ...
python
def run(cmds, **kwargs): """ Wrapper around subprocess.run, with unicode decoding of output. Additional kwargs are passed to subprocess.run. """ proc = sp.Popen(cmds, bufsize=-1, stdout=sp.PIPE, stderr=sp.STDOUT, close_fds=sys.platform != 'win32') for line in proc.stdout: ...
[ "def", "run", "(", "cmds", ",", "*", "*", "kwargs", ")", ":", "proc", "=", "sp", ".", "Popen", "(", "cmds", ",", "bufsize", "=", "-", "1", ",", "stdout", "=", "sp", ".", "PIPE", ",", "stderr", "=", "sp", ".", "STDOUT", ",", "close_fds", "=", ...
Wrapper around subprocess.run, with unicode decoding of output. Additional kwargs are passed to subprocess.run.
[ "Wrapper", "around", "subprocess", ".", "run", "with", "unicode", "decoding", "of", "output", "." ]
train
https://github.com/daler/trackhub/blob/e4655f79177822529f80b923df117e38e28df702/trackhub/upload.py#L18-L30
daler/trackhub
trackhub/upload.py
symlink
def symlink(target, linkname): """ Create a symlink to `target` called `linkname`. Converts `target` and `linkname` to absolute paths; creates `dirname(linkname)` if needed. """ target = os.path.abspath(target) linkname = os.path.abspath(linkname) if not os.path.exists(target): ...
python
def symlink(target, linkname): """ Create a symlink to `target` called `linkname`. Converts `target` and `linkname` to absolute paths; creates `dirname(linkname)` if needed. """ target = os.path.abspath(target) linkname = os.path.abspath(linkname) if not os.path.exists(target): ...
[ "def", "symlink", "(", "target", ",", "linkname", ")", ":", "target", "=", "os", ".", "path", ".", "abspath", "(", "target", ")", "linkname", "=", "os", ".", "path", ".", "abspath", "(", "linkname", ")", "if", "not", "os", ".", "path", ".", "exists...
Create a symlink to `target` called `linkname`. Converts `target` and `linkname` to absolute paths; creates `dirname(linkname)` if needed.
[ "Create", "a", "symlink", "to", "target", "called", "linkname", "." ]
train
https://github.com/daler/trackhub/blob/e4655f79177822529f80b923df117e38e28df702/trackhub/upload.py#L33-L50
daler/trackhub
trackhub/upload.py
upload
def upload(host, user, local_dir, remote_dir, rsync_options=RSYNC_OPTIONS): """ Upload a file or directory via rsync. Parameters ---------- host : str or None If None, omit the host part and just transfer locally user : str or None If None, omit the user part local_dir : s...
python
def upload(host, user, local_dir, remote_dir, rsync_options=RSYNC_OPTIONS): """ Upload a file or directory via rsync. Parameters ---------- host : str or None If None, omit the host part and just transfer locally user : str or None If None, omit the user part local_dir : s...
[ "def", "upload", "(", "host", ",", "user", ",", "local_dir", ",", "remote_dir", ",", "rsync_options", "=", "RSYNC_OPTIONS", ")", ":", "if", "user", "is", "None", ":", "user", "=", "\"\"", "else", ":", "user", "=", "user", "+", "\"@\"", "if", "host", ...
Upload a file or directory via rsync. Parameters ---------- host : str or None If None, omit the host part and just transfer locally user : str or None If None, omit the user part local_dir : str If a directory, a trailing "/" will be added. remote_dir : str I...
[ "Upload", "a", "file", "or", "directory", "via", "rsync", "." ]
train
https://github.com/daler/trackhub/blob/e4655f79177822529f80b923df117e38e28df702/trackhub/upload.py#L53-L91
daler/trackhub
trackhub/upload.py
local_link
def local_link(local_fn, remote_fn, staging): """ Creates a symlink to a local staging area. The link name is built from `remote_fn`, but the absolute path is put inside the staging directory. Example ------- If we have the following initial setup:: cwd="/home/user" local...
python
def local_link(local_fn, remote_fn, staging): """ Creates a symlink to a local staging area. The link name is built from `remote_fn`, but the absolute path is put inside the staging directory. Example ------- If we have the following initial setup:: cwd="/home/user" local...
[ "def", "local_link", "(", "local_fn", ",", "remote_fn", ",", "staging", ")", ":", "linkname", "=", "os", ".", "path", ".", "join", "(", "staging", ",", "remote_fn", ".", "lstrip", "(", "os", ".", "path", ".", "sep", ")", ")", "return", "symlink", "("...
Creates a symlink to a local staging area. The link name is built from `remote_fn`, but the absolute path is put inside the staging directory. Example ------- If we have the following initial setup:: cwd="/home/user" local="data/sample1.bw" remote="/hubs/hg19/a.bw" ...
[ "Creates", "a", "symlink", "to", "a", "local", "staging", "area", "." ]
train
https://github.com/daler/trackhub/blob/e4655f79177822529f80b923df117e38e28df702/trackhub/upload.py#L94-L119
daler/trackhub
trackhub/upload.py
stage
def stage(x, staging): """ Stage an object to the `staging` directory. If the object is a Track and is one of the types that needs an index file (bam, vcfTabix), then the index file will be staged as well. Returns a list of the linknames created. """ linknames = [] # Objects that don'...
python
def stage(x, staging): """ Stage an object to the `staging` directory. If the object is a Track and is one of the types that needs an index file (bam, vcfTabix), then the index file will be staged as well. Returns a list of the linknames created. """ linknames = [] # Objects that don'...
[ "def", "stage", "(", "x", ",", "staging", ")", ":", "linknames", "=", "[", "]", "# Objects that don't represent a file shouldn't be staged", "non_file_objects", "=", "(", "track", ".", "ViewTrack", ",", "track", ".", "CompositeTrack", ",", "track", ".", "Aggregate...
Stage an object to the `staging` directory. If the object is a Track and is one of the types that needs an index file (bam, vcfTabix), then the index file will be staged as well. Returns a list of the linknames created.
[ "Stage", "an", "object", "to", "the", "staging", "directory", "." ]
train
https://github.com/daler/trackhub/blob/e4655f79177822529f80b923df117e38e28df702/trackhub/upload.py#L122-L176
daler/trackhub
trackhub/upload.py
stage_hub
def stage_hub(hub, staging=None): """ Stage a hub by symlinking all its connected files to a local directory. """ linknames = [] if staging is None: staging = tempfile.mkdtemp() for obj, level in hub.leaves(base.HubComponent, intermediate=True): linknames.extend(stage(obj, stagin...
python
def stage_hub(hub, staging=None): """ Stage a hub by symlinking all its connected files to a local directory. """ linknames = [] if staging is None: staging = tempfile.mkdtemp() for obj, level in hub.leaves(base.HubComponent, intermediate=True): linknames.extend(stage(obj, stagin...
[ "def", "stage_hub", "(", "hub", ",", "staging", "=", "None", ")", ":", "linknames", "=", "[", "]", "if", "staging", "is", "None", ":", "staging", "=", "tempfile", ".", "mkdtemp", "(", ")", "for", "obj", ",", "level", "in", "hub", ".", "leaves", "("...
Stage a hub by symlinking all its connected files to a local directory.
[ "Stage", "a", "hub", "by", "symlinking", "all", "its", "connected", "files", "to", "a", "local", "directory", "." ]
train
https://github.com/daler/trackhub/blob/e4655f79177822529f80b923df117e38e28df702/trackhub/upload.py#L180-L190
daler/trackhub
trackhub/upload.py
upload_hub
def upload_hub(hub, host, remote_dir, user=None, port=22, rsync_options=RSYNC_OPTIONS, staging=None): """ Renders, stages, and uploads a hub. """ hub.render() if staging is None: staging = tempfile.mkdtemp() staging, linknames = stage_hub(hub, staging=staging) local_dir = os.path.joi...
python
def upload_hub(hub, host, remote_dir, user=None, port=22, rsync_options=RSYNC_OPTIONS, staging=None): """ Renders, stages, and uploads a hub. """ hub.render() if staging is None: staging = tempfile.mkdtemp() staging, linknames = stage_hub(hub, staging=staging) local_dir = os.path.joi...
[ "def", "upload_hub", "(", "hub", ",", "host", ",", "remote_dir", ",", "user", "=", "None", ",", "port", "=", "22", ",", "rsync_options", "=", "RSYNC_OPTIONS", ",", "staging", "=", "None", ")", ":", "hub", ".", "render", "(", ")", "if", "staging", "is...
Renders, stages, and uploads a hub.
[ "Renders", "stages", "and", "uploads", "a", "hub", "." ]
train
https://github.com/daler/trackhub/blob/e4655f79177822529f80b923df117e38e28df702/trackhub/upload.py#L193-L203
Karaage-Cluster/karaage
karaage/projects/xmlrpc.py
get_project_members
def get_project_members(machine, project_id): """ Returns list of usernames given a project id """ try: project = Project.objects.get(pid=project_id) except Project.DoesNotExist: return 'Project not found' return [x.username for x in project.group.members.all()]
python
def get_project_members(machine, project_id): """ Returns list of usernames given a project id """ try: project = Project.objects.get(pid=project_id) except Project.DoesNotExist: return 'Project not found' return [x.username for x in project.group.members.all()]
[ "def", "get_project_members", "(", "machine", ",", "project_id", ")", ":", "try", ":", "project", "=", "Project", ".", "objects", ".", "get", "(", "pid", "=", "project_id", ")", "except", "Project", ".", "DoesNotExist", ":", "return", "'Project not found'", ...
Returns list of usernames given a project id
[ "Returns", "list", "of", "usernames", "given", "a", "project", "id" ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/projects/xmlrpc.py#L28-L37
Karaage-Cluster/karaage
karaage/projects/xmlrpc.py
get_projects
def get_projects(machine): """ Returns list of project ids """ query = Project.active.all() return [x.pid for x in query]
python
def get_projects(machine): """ Returns list of project ids """ query = Project.active.all() return [x.pid for x in query]
[ "def", "get_projects", "(", "machine", ")", ":", "query", "=", "Project", ".", "active", ".", "all", "(", ")", "return", "[", "x", ".", "pid", "for", "x", "in", "query", "]" ]
Returns list of project ids
[ "Returns", "list", "of", "project", "ids" ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/projects/xmlrpc.py#L42-L48
Karaage-Cluster/karaage
karaage/projects/xmlrpc.py
get_project
def get_project(username, project, machine_name=None): """ Used in the submit filter to make sure user is in project """ try: account = Account.objects.get( username=username, date_deleted__isnull=True) except Account.DoesNotExist: return "Account '%s' not fo...
python
def get_project(username, project, machine_name=None): """ Used in the submit filter to make sure user is in project """ try: account = Account.objects.get( username=username, date_deleted__isnull=True) except Account.DoesNotExist: return "Account '%s' not fo...
[ "def", "get_project", "(", "username", ",", "project", ",", "machine_name", "=", "None", ")", ":", "try", ":", "account", "=", "Account", ".", "objects", ".", "get", "(", "username", "=", "username", ",", "date_deleted__isnull", "=", "True", ")", "except",...
Used in the submit filter to make sure user is in project
[ "Used", "in", "the", "submit", "filter", "to", "make", "sure", "user", "is", "in", "project" ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/projects/xmlrpc.py#L52-L84
Karaage-Cluster/karaage
karaage/projects/xmlrpc.py
get_users_projects
def get_users_projects(user): """ List projects a user is part of """ person = user projects = person.projects.filter(is_active=True) return 0, [x.pid for x in projects]
python
def get_users_projects(user): """ List projects a user is part of """ person = user projects = person.projects.filter(is_active=True) return 0, [x.pid for x in projects]
[ "def", "get_users_projects", "(", "user", ")", ":", "person", "=", "user", "projects", "=", "person", ".", "projects", ".", "filter", "(", "is_active", "=", "True", ")", "return", "0", ",", "[", "x", ".", "pid", "for", "x", "in", "projects", "]" ]
List projects a user is part of
[ "List", "projects", "a", "user", "is", "part", "of" ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/projects/xmlrpc.py#L89-L95
Karaage-Cluster/karaage
karaage/common/simple.py
direct_to_template
def direct_to_template( request, template, extra_context=None, mimetype=None, **kwargs): """ Render a given template with any extra URL parameters in the context as ``{{ params }}``. """ if extra_context is None: extra_context = {} dictionary = {'params': kwargs} for key, val...
python
def direct_to_template( request, template, extra_context=None, mimetype=None, **kwargs): """ Render a given template with any extra URL parameters in the context as ``{{ params }}``. """ if extra_context is None: extra_context = {} dictionary = {'params': kwargs} for key, val...
[ "def", "direct_to_template", "(", "request", ",", "template", ",", "extra_context", "=", "None", ",", "mimetype", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "extra_context", "is", "None", ":", "extra_context", "=", "{", "}", "dictionary", "=", ...
Render a given template with any extra URL parameters in the context as ``{{ params }}``.
[ "Render", "a", "given", "template", "with", "any", "extra", "URL", "parameters", "in", "the", "context", "as", "{{", "params", "}}", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/common/simple.py#L35-L52
Karaage-Cluster/karaage
karaage/common/simple.py
redirect_to
def redirect_to(request, url, permanent=True, query_string=False, **kwargs): r""" Redirect to a given URL. The given url may contain dict-style string formatting, which will be interpolated against the params in the URL. For example, to redirect from ``/foo/<id>/`` to ``/bar/<id>/``, you could use...
python
def redirect_to(request, url, permanent=True, query_string=False, **kwargs): r""" Redirect to a given URL. The given url may contain dict-style string formatting, which will be interpolated against the params in the URL. For example, to redirect from ``/foo/<id>/`` to ``/bar/<id>/``, you could use...
[ "def", "redirect_to", "(", "request", ",", "url", ",", "permanent", "=", "True", ",", "query_string", "=", "False", ",", "*", "*", "kwargs", ")", ":", "args", "=", "request", ".", "META", ".", "get", "(", "'QUERY_STRING'", ",", "''", ")", "if", "url"...
r""" Redirect to a given URL. The given url may contain dict-style string formatting, which will be interpolated against the params in the URL. For example, to redirect from ``/foo/<id>/`` to ``/bar/<id>/``, you could use the following URLconf:: urlpatterns = patterns('', (r'^foo/...
[ "r", "Redirect", "to", "a", "given", "URL", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/common/simple.py#L55-L98
Karaage-Cluster/karaage
karaage/common/passwords.py
assert_strong_password
def assert_strong_password(username, password, old_password=None): """Raises ValueError if the password isn't strong. Returns the password otherwise.""" # test the length try: minlength = settings.MIN_PASSWORD_LENGTH except AttributeError: minlength = 12 if len(password) < minl...
python
def assert_strong_password(username, password, old_password=None): """Raises ValueError if the password isn't strong. Returns the password otherwise.""" # test the length try: minlength = settings.MIN_PASSWORD_LENGTH except AttributeError: minlength = 12 if len(password) < minl...
[ "def", "assert_strong_password", "(", "username", ",", "password", ",", "old_password", "=", "None", ")", ":", "# test the length", "try", ":", "minlength", "=", "settings", ".", "MIN_PASSWORD_LENGTH", "except", "AttributeError", ":", "minlength", "=", "12", "if",...
Raises ValueError if the password isn't strong. Returns the password otherwise.
[ "Raises", "ValueError", "if", "the", "password", "isn", "t", "strong", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/common/passwords.py#L50-L67
Karaage-Cluster/karaage
karaage/datastores/ldap.py
_lookup
def _lookup(cls: str) -> LdapObjectClass: """ Lookup module.class. """ if isinstance(cls, str): module_name, _, name = cls.rpartition(".") module = importlib.import_module(module_name) try: cls = getattr(module, name) except AttributeError: raise Attribute...
python
def _lookup(cls: str) -> LdapObjectClass: """ Lookup module.class. """ if isinstance(cls, str): module_name, _, name = cls.rpartition(".") module = importlib.import_module(module_name) try: cls = getattr(module, name) except AttributeError: raise Attribute...
[ "def", "_lookup", "(", "cls", ":", "str", ")", "->", "LdapObjectClass", ":", "if", "isinstance", "(", "cls", ",", "str", ")", ":", "module_name", ",", "_", ",", "name", "=", "cls", ".", "rpartition", "(", "\".\"", ")", "module", "=", "importlib", "."...
Lookup module.class.
[ "Lookup", "module", ".", "class", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/ldap.py#L55-L64
Karaage-Cluster/karaage
karaage/datastores/ldap.py
DataStore.save_account
def save_account(self, account: Account) -> None: """ Account was saved. """ person = account.person if self._primary_group == 'institute': lgroup = self._get_group(person.institute.group.name) elif self._primary_group == 'default_project': if account.default_proj...
python
def save_account(self, account: Account) -> None: """ Account was saved. """ person = account.person if self._primary_group == 'institute': lgroup = self._get_group(person.institute.group.name) elif self._primary_group == 'default_project': if account.default_proj...
[ "def", "save_account", "(", "self", ",", "account", ":", "Account", ")", "->", "None", ":", "person", "=", "account", ".", "person", "if", "self", ".", "_primary_group", "==", "'institute'", ":", "lgroup", "=", "self", ".", "_get_group", "(", "person", "...
Account was saved.
[ "Account", "was", "saved", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/ldap.py#L97-L144
Karaage-Cluster/karaage
karaage/datastores/ldap.py
DataStore.delete_account
def delete_account(self, account): """ Account was deleted. """ try: luser = self._get_account(account.username) groups = luser['groups'].load(database=self._database) for group in groups: changes = changeset(group, {}) changes = group....
python
def delete_account(self, account): """ Account was deleted. """ try: luser = self._get_account(account.username) groups = luser['groups'].load(database=self._database) for group in groups: changes = changeset(group, {}) changes = group....
[ "def", "delete_account", "(", "self", ",", "account", ")", ":", "try", ":", "luser", "=", "self", ".", "_get_account", "(", "account", ".", "username", ")", "groups", "=", "luser", "[", "'groups'", "]", ".", "load", "(", "database", "=", "self", ".", ...
Account was deleted.
[ "Account", "was", "deleted", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/ldap.py#L146-L159
Karaage-Cluster/karaage
karaage/datastores/ldap.py
DataStore.set_account_password
def set_account_password(self, account, raw_password): """ Account's password was changed. """ luser = self._get_account(account.username) changes = changeset(luser, { 'password': raw_password, }) save(changes, database=self._database)
python
def set_account_password(self, account, raw_password): """ Account's password was changed. """ luser = self._get_account(account.username) changes = changeset(luser, { 'password': raw_password, }) save(changes, database=self._database)
[ "def", "set_account_password", "(", "self", ",", "account", ",", "raw_password", ")", ":", "luser", "=", "self", ".", "_get_account", "(", "account", ".", "username", ")", "changes", "=", "changeset", "(", "luser", ",", "{", "'password'", ":", "raw_password"...
Account's password was changed.
[ "Account", "s", "password", "was", "changed", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/ldap.py#L161-L167
Karaage-Cluster/karaage
karaage/datastores/ldap.py
DataStore.set_account_username
def set_account_username(self, account, old_username, new_username): """ Account's username was changed. """ luser = self._get_account(old_username) rename(luser, database=self._database, uid=new_username)
python
def set_account_username(self, account, old_username, new_username): """ Account's username was changed. """ luser = self._get_account(old_username) rename(luser, database=self._database, uid=new_username)
[ "def", "set_account_username", "(", "self", ",", "account", ",", "old_username", ",", "new_username", ")", ":", "luser", "=", "self", ".", "_get_account", "(", "old_username", ")", "rename", "(", "luser", ",", "database", "=", "self", ".", "_database", ",", ...
Account's username was changed.
[ "Account", "s", "username", "was", "changed", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/ldap.py#L169-L172
Karaage-Cluster/karaage
karaage/datastores/ldap.py
DataStore.add_account_to_group
def add_account_to_group(self, account, group): """ Add account to group. """ lgroup: OpenldapGroup = self._get_group(group.name) person: OpenldapAccount = self._get_account(account.username) changes = changeset(lgroup, {}) changes = lgroup.add_member(changes, person) sa...
python
def add_account_to_group(self, account, group): """ Add account to group. """ lgroup: OpenldapGroup = self._get_group(group.name) person: OpenldapAccount = self._get_account(account.username) changes = changeset(lgroup, {}) changes = lgroup.add_member(changes, person) sa...
[ "def", "add_account_to_group", "(", "self", ",", "account", ",", "group", ")", ":", "lgroup", ":", "OpenldapGroup", "=", "self", ".", "_get_group", "(", "group", ".", "name", ")", "person", ":", "OpenldapAccount", "=", "self", ".", "_get_account", "(", "ac...
Add account to group.
[ "Add", "account", "to", "group", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/ldap.py#L174-L181
Karaage-Cluster/karaage
karaage/datastores/ldap.py
DataStore.get_account_details
def get_account_details(self, account): """ Get the account details. """ result = {} try: luser = self._get_account(account.username) luser = preload(luser, database=self._database) except ObjectDoesNotExist: return result for i, j in luser.it...
python
def get_account_details(self, account): """ Get the account details. """ result = {} try: luser = self._get_account(account.username) luser = preload(luser, database=self._database) except ObjectDoesNotExist: return result for i, j in luser.it...
[ "def", "get_account_details", "(", "self", ",", "account", ")", ":", "result", "=", "{", "}", "try", ":", "luser", "=", "self", ".", "_get_account", "(", "account", ".", "username", ")", "luser", "=", "preload", "(", "luser", ",", "database", "=", "sel...
Get the account details.
[ "Get", "the", "account", "details", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/ldap.py#L192-L205
Karaage-Cluster/karaage
karaage/datastores/ldap.py
DataStore.save_group
def save_group(self, group): """ Group was saved. """ # If group already exists, take over existing group rather then error. try: lgroup = self._get_group(group.name) changes = changeset(lgroup, {}) except ObjectDoesNotExist: lgroup = self._group_class...
python
def save_group(self, group): """ Group was saved. """ # If group already exists, take over existing group rather then error. try: lgroup = self._get_group(group.name) changes = changeset(lgroup, {}) except ObjectDoesNotExist: lgroup = self._group_class...
[ "def", "save_group", "(", "self", ",", "group", ")", ":", "# If group already exists, take over existing group rather then error.", "try", ":", "lgroup", "=", "self", ".", "_get_group", "(", "group", ".", "name", ")", "changes", "=", "changeset", "(", "lgroup", ",...
Group was saved.
[ "Group", "was", "saved", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/ldap.py#L215-L230
Karaage-Cluster/karaage
karaage/datastores/ldap.py
DataStore.delete_group
def delete_group(self, group): """ Group was deleted. """ try: lgroup = self._get_group(group.name) delete(lgroup, database=self._database) except ObjectDoesNotExist: # it doesn't matter if it doesn't exist pass
python
def delete_group(self, group): """ Group was deleted. """ try: lgroup = self._get_group(group.name) delete(lgroup, database=self._database) except ObjectDoesNotExist: # it doesn't matter if it doesn't exist pass
[ "def", "delete_group", "(", "self", ",", "group", ")", ":", "try", ":", "lgroup", "=", "self", ".", "_get_group", "(", "group", ".", "name", ")", "delete", "(", "lgroup", ",", "database", "=", "self", ".", "_database", ")", "except", "ObjectDoesNotExist"...
Group was deleted.
[ "Group", "was", "deleted", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/ldap.py#L232-L239
Karaage-Cluster/karaage
karaage/datastores/ldap.py
DataStore.set_group_name
def set_group_name(self, group, old_name, new_name): """ Group was renamed. """ lgroup = self._get_group(old_name) rename(lgroup, database=self._database, cn=new_name)
python
def set_group_name(self, group, old_name, new_name): """ Group was renamed. """ lgroup = self._get_group(old_name) rename(lgroup, database=self._database, cn=new_name)
[ "def", "set_group_name", "(", "self", ",", "group", ",", "old_name", ",", "new_name", ")", ":", "lgroup", "=", "self", ".", "_get_group", "(", "old_name", ")", "rename", "(", "lgroup", ",", "database", "=", "self", ".", "_database", ",", "cn", "=", "ne...
Group was renamed.
[ "Group", "was", "renamed", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/ldap.py#L241-L244
Karaage-Cluster/karaage
karaage/datastores/ldap.py
DataStore.get_group_details
def get_group_details(self, group): """ Get the group details. """ result = {} try: lgroup = self._get_group(group.name) lgroup = preload(lgroup, database=self._database) except ObjectDoesNotExist: return result for i, j in lgroup.items(): ...
python
def get_group_details(self, group): """ Get the group details. """ result = {} try: lgroup = self._get_group(group.name) lgroup = preload(lgroup, database=self._database) except ObjectDoesNotExist: return result for i, j in lgroup.items(): ...
[ "def", "get_group_details", "(", "self", ",", "group", ")", ":", "result", "=", "{", "}", "try", ":", "lgroup", "=", "self", ".", "_get_group", "(", "group", ".", "name", ")", "lgroup", "=", "preload", "(", "lgroup", ",", "database", "=", "self", "."...
Get the group details.
[ "Get", "the", "group", "details", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/ldap.py#L246-L259
mozilla/python_moztelemetry
moztelemetry/stats.py
_rank
def _rank(sample): """ Assign numeric ranks to all values in the sample. The ranks begin with 1 for the smallest value. When there are groups of tied values, assign a rank equal to the midpoint of unadjusted rankings. E.g.:: >>> rank({3: 1, 5: 4, 9: 1}) {3: 1.0, 5: 3.5, 9: 6.0} ...
python
def _rank(sample): """ Assign numeric ranks to all values in the sample. The ranks begin with 1 for the smallest value. When there are groups of tied values, assign a rank equal to the midpoint of unadjusted rankings. E.g.:: >>> rank({3: 1, 5: 4, 9: 1}) {3: 1.0, 5: 3.5, 9: 6.0} ...
[ "def", "_rank", "(", "sample", ")", ":", "rank", "=", "1", "ranks", "=", "{", "}", "for", "k", "in", "sorted", "(", "sample", ".", "keys", "(", ")", ")", ":", "n", "=", "sample", "[", "k", "]", "ranks", "[", "k", "]", "=", "rank", "+", "(",...
Assign numeric ranks to all values in the sample. The ranks begin with 1 for the smallest value. When there are groups of tied values, assign a rank equal to the midpoint of unadjusted rankings. E.g.:: >>> rank({3: 1, 5: 4, 9: 1}) {3: 1.0, 5: 3.5, 9: 6.0}
[ "Assign", "numeric", "ranks", "to", "all", "values", "in", "the", "sample", "." ]
train
https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/stats.py#L14-L35
mozilla/python_moztelemetry
moztelemetry/stats.py
_tie_correct
def _tie_correct(sample): """ Returns the tie correction value for U. See: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.tiecorrect.html """ tc = 0 n = sum(sample.values()) if n < 2: return 1.0 # Avoid a ``ZeroDivisionError``. for k in sorted(sample.keys()...
python
def _tie_correct(sample): """ Returns the tie correction value for U. See: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.tiecorrect.html """ tc = 0 n = sum(sample.values()) if n < 2: return 1.0 # Avoid a ``ZeroDivisionError``. for k in sorted(sample.keys()...
[ "def", "_tie_correct", "(", "sample", ")", ":", "tc", "=", "0", "n", "=", "sum", "(", "sample", ".", "values", "(", ")", ")", "if", "n", "<", "2", ":", "return", "1.0", "# Avoid a ``ZeroDivisionError``.", "for", "k", "in", "sorted", "(", "sample", "....
Returns the tie correction value for U. See: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.tiecorrect.html
[ "Returns", "the", "tie", "correction", "value", "for", "U", "." ]
train
https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/stats.py#L38-L55
mozilla/python_moztelemetry
moztelemetry/stats.py
ndtr
def ndtr(a): """ Returns the area under the Gaussian probability density function, integrated from minus infinity to x. See: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.ndtr.html#scipy.special.ndtr """ sqrth = math.sqrt(2) / 2 x = float(a) * sqrth z = abs(x) ...
python
def ndtr(a): """ Returns the area under the Gaussian probability density function, integrated from minus infinity to x. See: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.ndtr.html#scipy.special.ndtr """ sqrth = math.sqrt(2) / 2 x = float(a) * sqrth z = abs(x) ...
[ "def", "ndtr", "(", "a", ")", ":", "sqrth", "=", "math", ".", "sqrt", "(", "2", ")", "/", "2", "x", "=", "float", "(", "a", ")", "*", "sqrth", "z", "=", "abs", "(", "x", ")", "if", "z", "<", "sqrth", ":", "y", "=", "0.5", "+", "0.5", "*...
Returns the area under the Gaussian probability density function, integrated from minus infinity to x. See: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.ndtr.html#scipy.special.ndtr
[ "Returns", "the", "area", "under", "the", "Gaussian", "probability", "density", "function", "integrated", "from", "minus", "infinity", "to", "x", "." ]
train
https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/stats.py#L58-L75
mozilla/python_moztelemetry
moztelemetry/stats.py
mann_whitney_u
def mann_whitney_u(sample1, sample2, use_continuity=True): """ Computes the Mann-Whitney rank test on both samples. Each sample is expected to be of the form:: {1: 5, 2: 20, 3: 12, ...} Returns a named tuple with: ``u`` equal to min(U for sample1, U for sample2), and ``p`` equ...
python
def mann_whitney_u(sample1, sample2, use_continuity=True): """ Computes the Mann-Whitney rank test on both samples. Each sample is expected to be of the form:: {1: 5, 2: 20, 3: 12, ...} Returns a named tuple with: ``u`` equal to min(U for sample1, U for sample2), and ``p`` equ...
[ "def", "mann_whitney_u", "(", "sample1", ",", "sample2", ",", "use_continuity", "=", "True", ")", ":", "# Merge dictionaries, adding values if keys match.", "sample", "=", "sample1", ".", "copy", "(", ")", "for", "k", ",", "v", "in", "sample2", ".", "items", "...
Computes the Mann-Whitney rank test on both samples. Each sample is expected to be of the form:: {1: 5, 2: 20, 3: 12, ...} Returns a named tuple with: ``u`` equal to min(U for sample1, U for sample2), and ``p`` equal to the p-value.
[ "Computes", "the", "Mann", "-", "Whitney", "rank", "test", "on", "both", "samples", "." ]
train
https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/stats.py#L81-L118
mozilla/python_moztelemetry
moztelemetry/spark.py
deprecated
def deprecated(func): """This is a decorator which can be used to mark functions as deprecated. It will result in a warning being emitted when the function is used.""" def newFunc(*args, **kwargs): print("Call to deprecated function %s." % func.__name__) return func(*args, **kwargs) ...
python
def deprecated(func): """This is a decorator which can be used to mark functions as deprecated. It will result in a warning being emitted when the function is used.""" def newFunc(*args, **kwargs): print("Call to deprecated function %s." % func.__name__) return func(*args, **kwargs) ...
[ "def", "deprecated", "(", "func", ")", ":", "def", "newFunc", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "print", "(", "\"Call to deprecated function %s.\"", "%", "func", ".", "__name__", ")", "return", "func", "(", "*", "args", ",", "*", "*"...
This is a decorator which can be used to mark functions as deprecated. It will result in a warning being emitted when the function is used.
[ "This", "is", "a", "decorator", "which", "can", "be", "used", "to", "mark", "functions", "as", "deprecated", ".", "It", "will", "result", "in", "a", "warning", "being", "emitted", "when", "the", "function", "is", "used", "." ]
train
https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/spark.py#L22-L32
mozilla/python_moztelemetry
moztelemetry/spark.py
get_pings
def get_pings(sc, app=None, build_id=None, channel=None, doc_type='saved_session', fraction=1.0, schema=None, source_name='telemetry', source_version='4', submission_date=None, version=None): """ Returns a RDD of Telemetry submissions for a given filtering criteria. :param sc: an in...
python
def get_pings(sc, app=None, build_id=None, channel=None, doc_type='saved_session', fraction=1.0, schema=None, source_name='telemetry', source_version='4', submission_date=None, version=None): """ Returns a RDD of Telemetry submissions for a given filtering criteria. :param sc: an in...
[ "def", "get_pings", "(", "sc", ",", "app", "=", "None", ",", "build_id", "=", "None", ",", "channel", "=", "None", ",", "doc_type", "=", "'saved_session'", ",", "fraction", "=", "1.0", ",", "schema", "=", "None", ",", "source_name", "=", "'telemetry'", ...
Returns a RDD of Telemetry submissions for a given filtering criteria. :param sc: an instance of SparkContext :param app: an application name, e.g.: "Firefox" :param channel: a channel name, e.g.: "nightly" :param version: the application version, e.g.: "40.0a1" :param build_id: a build_id or a ran...
[ "Returns", "a", "RDD", "of", "Telemetry", "submissions", "for", "a", "given", "filtering", "criteria", "." ]
train
https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/spark.py#L70-L129
mozilla/python_moztelemetry
moztelemetry/spark.py
get_pings_properties
def get_pings_properties(pings, paths, only_median=False, with_processes=False, histograms_url=None, additional_histograms=None): """ Returns a RDD of a subset of properties of pings. Child histograms are automatically merged with the parent histogram. If one of the paths point...
python
def get_pings_properties(pings, paths, only_median=False, with_processes=False, histograms_url=None, additional_histograms=None): """ Returns a RDD of a subset of properties of pings. Child histograms are automatically merged with the parent histogram. If one of the paths point...
[ "def", "get_pings_properties", "(", "pings", ",", "paths", ",", "only_median", "=", "False", ",", "with_processes", "=", "False", ",", "histograms_url", "=", "None", ",", "additional_histograms", "=", "None", ")", ":", "if", "isinstance", "(", "pings", ".", ...
Returns a RDD of a subset of properties of pings. Child histograms are automatically merged with the parent histogram. If one of the paths points to a keyedHistogram name without supplying the actual key, returns a dict of all available subhistograms for that property. :param with_processes: should se...
[ "Returns", "a", "RDD", "of", "a", "subset", "of", "properties", "of", "pings", ".", "Child", "histograms", "are", "automatically", "merged", "with", "the", "parent", "histogram", "." ]
train
https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/spark.py#L133-L172
mozilla/python_moztelemetry
moztelemetry/spark.py
get_one_ping_per_client
def get_one_ping_per_client(pings): """ Returns a single ping for each client in the RDD. THIS METHOD IS NOT RECOMMENDED: The ping to be returned is essentially selected at random. It is also expensive as it requires data to be shuffled around. It should be run only after extracting a subset with ...
python
def get_one_ping_per_client(pings): """ Returns a single ping for each client in the RDD. THIS METHOD IS NOT RECOMMENDED: The ping to be returned is essentially selected at random. It is also expensive as it requires data to be shuffled around. It should be run only after extracting a subset with ...
[ "def", "get_one_ping_per_client", "(", "pings", ")", ":", "if", "isinstance", "(", "pings", ".", "first", "(", ")", ",", "binary_type", ")", ":", "pings", "=", "pings", ".", "map", "(", "lambda", "p", ":", "json", ".", "loads", "(", "p", ".", "decode...
Returns a single ping for each client in the RDD. THIS METHOD IS NOT RECOMMENDED: The ping to be returned is essentially selected at random. It is also expensive as it requires data to be shuffled around. It should be run only after extracting a subset with get_pings_properties.
[ "Returns", "a", "single", "ping", "for", "each", "client", "in", "the", "RDD", "." ]
train
https://github.com/mozilla/python_moztelemetry/blob/09ddf1ec7d953a4308dfdcb0ed968f27bd5921bb/moztelemetry/spark.py#L176-L200
Karaage-Cluster/karaage
karaage/common/decorators.py
admin_required
def admin_required(function=None): """ Decorator for views that checks that the user is an administrator, redirecting to the log-in page if necessary. """ def check_perms(user): # if user not logged in, show login form if not user.is_authenticated: return False # ...
python
def admin_required(function=None): """ Decorator for views that checks that the user is an administrator, redirecting to the log-in page if necessary. """ def check_perms(user): # if user not logged in, show login form if not user.is_authenticated: return False # ...
[ "def", "admin_required", "(", "function", "=", "None", ")", ":", "def", "check_perms", "(", "user", ")", ":", "# if user not logged in, show login form", "if", "not", "user", ".", "is_authenticated", ":", "return", "False", "# if this site doesn't allow admin access, fa...
Decorator for views that checks that the user is an administrator, redirecting to the log-in page if necessary.
[ "Decorator", "for", "views", "that", "checks", "that", "the", "user", "is", "an", "administrator", "redirecting", "to", "the", "log", "-", "in", "page", "if", "necessary", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/common/decorators.py#L30-L50
Karaage-Cluster/karaage
karaage/common/decorators.py
login_required
def login_required(function=None): """ Decorator for views that checks that the user is logged in, redirecting to the log-in page if necessary. """ def check_perms(user): # if user not logged in, show login form if not user.is_authenticated: return False # if this...
python
def login_required(function=None): """ Decorator for views that checks that the user is logged in, redirecting to the log-in page if necessary. """ def check_perms(user): # if user not logged in, show login form if not user.is_authenticated: return False # if this...
[ "def", "login_required", "(", "function", "=", "None", ")", ":", "def", "check_perms", "(", "user", ")", ":", "# if user not logged in, show login form", "if", "not", "user", ".", "is_authenticated", ":", "return", "False", "# if this is the admin site only admin access...
Decorator for views that checks that the user is logged in, redirecting to the log-in page if necessary.
[ "Decorator", "for", "views", "that", "checks", "that", "the", "user", "is", "logged", "in", "redirecting", "to", "the", "log", "-", "in", "page", "if", "necessary", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/common/decorators.py#L53-L70
Karaage-Cluster/karaage
karaage/common/decorators.py
xmlrpc_machine_required
def xmlrpc_machine_required(function=None): """ Decorator for views that checks that the user is logged in, redirecting to the log-in page if necessary. """ def actual_decorator(func): def wrapper(machine_name, password, *args): from django_xmlrpc.decorators import Authentication...
python
def xmlrpc_machine_required(function=None): """ Decorator for views that checks that the user is logged in, redirecting to the log-in page if necessary. """ def actual_decorator(func): def wrapper(machine_name, password, *args): from django_xmlrpc.decorators import Authentication...
[ "def", "xmlrpc_machine_required", "(", "function", "=", "None", ")", ":", "def", "actual_decorator", "(", "func", ")", ":", "def", "wrapper", "(", "machine_name", ",", "password", ",", "*", "args", ")", ":", "from", "django_xmlrpc", ".", "decorators", "impor...
Decorator for views that checks that the user is logged in, redirecting to the log-in page if necessary.
[ "Decorator", "for", "views", "that", "checks", "that", "the", "user", "is", "logged", "in", "redirecting", "to", "the", "log", "-", "in", "page", "if", "necessary", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/common/decorators.py#L97-L123
Karaage-Cluster/karaage
karaage/datastores/slurm.py
SlurmDataStore._call
def _call(self, command, ignore_errors=None): """ Call remote command with logging. """ if ignore_errors is None: ignore_errors = [] cmd = [] cmd.extend(self._prefix) cmd.extend([self._path, "-iP"]) cmd.extend(command) command = cmd logger.deb...
python
def _call(self, command, ignore_errors=None): """ Call remote command with logging. """ if ignore_errors is None: ignore_errors = [] cmd = [] cmd.extend(self._prefix) cmd.extend([self._path, "-iP"]) cmd.extend(command) command = cmd logger.deb...
[ "def", "_call", "(", "self", ",", "command", ",", "ignore_errors", "=", "None", ")", ":", "if", "ignore_errors", "is", "None", ":", "ignore_errors", "=", "[", "]", "cmd", "=", "[", "]", "cmd", ".", "extend", "(", "self", ".", "_prefix", ")", "cmd", ...
Call remote command with logging.
[ "Call", "remote", "command", "with", "logging", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/slurm.py#L90-L116
Karaage-Cluster/karaage
karaage/datastores/slurm.py
SlurmDataStore._read_output
def _read_output(self, command): """ Read CSV delimited input from Slurm. """ cmd = [] cmd.extend(self._prefix) cmd.extend([self._path, "-iP"]) cmd.extend(command) command = cmd logger.debug("Cmd %s" % command) null = open('/dev/null', 'w') proces...
python
def _read_output(self, command): """ Read CSV delimited input from Slurm. """ cmd = [] cmd.extend(self._prefix) cmd.extend([self._path, "-iP"]) cmd.extend(command) command = cmd logger.debug("Cmd %s" % command) null = open('/dev/null', 'w') proces...
[ "def", "_read_output", "(", "self", ",", "command", ")", ":", "cmd", "=", "[", "]", "cmd", ".", "extend", "(", "self", ".", "_prefix", ")", "cmd", ".", "extend", "(", "[", "self", ".", "_path", ",", "\"-iP\"", "]", ")", "cmd", ".", "extend", "(",...
Read CSV delimited input from Slurm.
[ "Read", "CSV", "delimited", "input", "from", "Slurm", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/slurm.py#L118-L167
Karaage-Cluster/karaage
karaage/datastores/slurm.py
SlurmDataStore.get_project
def get_project(self, projectname): """ Get the project details from Slurm. """ cmd = ["list", "accounts", "where", "name=%s" % projectname] results = self._read_output(cmd) if len(results) == 0: return None elif len(results) > 1: logger.error( ...
python
def get_project(self, projectname): """ Get the project details from Slurm. """ cmd = ["list", "accounts", "where", "name=%s" % projectname] results = self._read_output(cmd) if len(results) == 0: return None elif len(results) > 1: logger.error( ...
[ "def", "get_project", "(", "self", ",", "projectname", ")", ":", "cmd", "=", "[", "\"list\"", ",", "\"accounts\"", ",", "\"where\"", ",", "\"name=%s\"", "%", "projectname", "]", "results", "=", "self", ".", "_read_output", "(", "cmd", ")", "if", "len", "...
Get the project details from Slurm.
[ "Get", "the", "project", "details", "from", "Slurm", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/slurm.py#L194-L217
Karaage-Cluster/karaage
karaage/datastores/slurm.py
SlurmDataStore.get_users_in_project
def get_users_in_project(self, projectname): """ Get list of users in project from Slurm. """ cmd = ["list", "assoc", "where", "account=%s" % projectname] results = self._read_output(cmd) user_list = [] for result in results: if result["User"] != "": ...
python
def get_users_in_project(self, projectname): """ Get list of users in project from Slurm. """ cmd = ["list", "assoc", "where", "account=%s" % projectname] results = self._read_output(cmd) user_list = [] for result in results: if result["User"] != "": ...
[ "def", "get_users_in_project", "(", "self", ",", "projectname", ")", ":", "cmd", "=", "[", "\"list\"", ",", "\"assoc\"", ",", "\"where\"", ",", "\"account=%s\"", "%", "projectname", "]", "results", "=", "self", ".", "_read_output", "(", "cmd", ")", "user_lis...
Get list of users in project from Slurm.
[ "Get", "list", "of", "users", "in", "project", "from", "Slurm", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/slurm.py#L219-L228
Karaage-Cluster/karaage
karaage/datastores/slurm.py
SlurmDataStore.get_projects_in_user
def get_projects_in_user(self, username): """ Get list of projects in user from Slurm. """ cmd = ["list", "assoc", "where", "user=%s" % username] results = self._read_output(cmd) project_list = [] for result in results: project_list.append(result["Account"]) ...
python
def get_projects_in_user(self, username): """ Get list of projects in user from Slurm. """ cmd = ["list", "assoc", "where", "user=%s" % username] results = self._read_output(cmd) project_list = [] for result in results: project_list.append(result["Account"]) ...
[ "def", "get_projects_in_user", "(", "self", ",", "username", ")", ":", "cmd", "=", "[", "\"list\"", ",", "\"assoc\"", ",", "\"where\"", ",", "\"user=%s\"", "%", "username", "]", "results", "=", "self", ".", "_read_output", "(", "cmd", ")", "project_list", ...
Get list of projects in user from Slurm.
[ "Get", "list", "of", "projects", "in", "user", "from", "Slurm", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/slurm.py#L230-L238
Karaage-Cluster/karaage
karaage/datastores/slurm.py
SlurmDataStore._save_account
def _save_account(self, account, username): """ Called when account is created/updated. With username override. """ # retrieve default project, or use null project if none default_project_name = self._null_project if account.default_project is not None: default_project_name ...
python
def _save_account(self, account, username): """ Called when account is created/updated. With username override. """ # retrieve default project, or use null project if none default_project_name = self._null_project if account.default_project is not None: default_project_name ...
[ "def", "_save_account", "(", "self", ",", "account", ",", "username", ")", ":", "# retrieve default project, or use null project if none", "default_project_name", "=", "self", ".", "_null_project", "if", "account", ".", "default_project", "is", "not", "None", ":", "de...
Called when account is created/updated. With username override.
[ "Called", "when", "account", "is", "created", "/", "updated", ".", "With", "username", "override", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/slurm.py#L246-L293
Karaage-Cluster/karaage
karaage/datastores/slurm.py
SlurmDataStore._delete_account
def _delete_account(self, username): """ Called when account is deleted. With username override. """ # account deleted ds_user = self.get_user(username) if ds_user is not None: self._call(["delete", "user", "name=%s" % username]) return
python
def _delete_account(self, username): """ Called when account is deleted. With username override. """ # account deleted ds_user = self.get_user(username) if ds_user is not None: self._call(["delete", "user", "name=%s" % username]) return
[ "def", "_delete_account", "(", "self", ",", "username", ")", ":", "# account deleted", "ds_user", "=", "self", ".", "get_user", "(", "username", ")", "if", "ds_user", "is", "not", "None", ":", "self", ".", "_call", "(", "[", "\"delete\"", ",", "\"user\"", ...
Called when account is deleted. With username override.
[ "Called", "when", "account", "is", "deleted", ".", "With", "username", "override", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/slurm.py#L299-L308
Karaage-Cluster/karaage
karaage/datastores/slurm.py
SlurmDataStore.save_project
def save_project(self, project): """ Called when project is saved/updated. """ pid = project.pid # project created # project updated if project.is_active: # project is not deleted logger.debug("project is active") ds_project = self.get_projec...
python
def save_project(self, project): """ Called when project is saved/updated. """ pid = project.pid # project created # project updated if project.is_active: # project is not deleted logger.debug("project is active") ds_project = self.get_projec...
[ "def", "save_project", "(", "self", ",", "project", ")", ":", "pid", "=", "project", ".", "pid", "# project created", "# project updated", "if", "project", ".", "is_active", ":", "# project is not deleted", "logger", ".", "debug", "(", "\"project is active\"", ")"...
Called when project is saved/updated.
[ "Called", "when", "project", "is", "saved", "/", "updated", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/slurm.py#L367-L399
Karaage-Cluster/karaage
karaage/datastores/slurm.py
SlurmDataStore.delete_project
def delete_project(self, project): """ Called when project is deleted. """ pid = project.pid # project deleted ds_project = self.get_project(pid) if ds_project is not None: self._call(["delete", "account", "name=%s" % pid]) return
python
def delete_project(self, project): """ Called when project is deleted. """ pid = project.pid # project deleted ds_project = self.get_project(pid) if ds_project is not None: self._call(["delete", "account", "name=%s" % pid]) return
[ "def", "delete_project", "(", "self", ",", "project", ")", ":", "pid", "=", "project", ".", "pid", "# project deleted", "ds_project", "=", "self", ".", "get_project", "(", "pid", ")", "if", "ds_project", "is", "not", "None", ":", "self", ".", "_call", "(...
Called when project is deleted.
[ "Called", "when", "project", "is", "deleted", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/datastores/slurm.py#L401-L411
Karaage-Cluster/karaage
karaage/projects/lookups.py
ProjectLookup.get_query
def get_query(self, q, request): """ return a query set searching for the query string q either implement this method yourself or set the search_field in the LookupChannel class definition """ return Project.objects.filter( Q(pid__icontains=q) | Q(...
python
def get_query(self, q, request): """ return a query set searching for the query string q either implement this method yourself or set the search_field in the LookupChannel class definition """ return Project.objects.filter( Q(pid__icontains=q) | Q(...
[ "def", "get_query", "(", "self", ",", "q", ",", "request", ")", ":", "return", "Project", ".", "objects", ".", "filter", "(", "Q", "(", "pid__icontains", "=", "q", ")", "|", "Q", "(", "name__icontains", "=", "q", ")", ")" ]
return a query set searching for the query string q either implement this method yourself or set the search_field in the LookupChannel class definition
[ "return", "a", "query", "set", "searching", "for", "the", "query", "string", "q", "either", "implement", "this", "method", "yourself", "or", "set", "the", "search_field", "in", "the", "LookupChannel", "class", "definition" ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/projects/lookups.py#L49-L57
daler/trackhub
trackhub/trackdb.py
TrackDb.add_tracks
def add_tracks(self, track): """ Add a track or iterable of tracks. Parameters ---------- track : iterable or Track Iterable of :class:`Track` objects, or a single :class:`Track` object. """ from trackhub import BaseTrack if isins...
python
def add_tracks(self, track): """ Add a track or iterable of tracks. Parameters ---------- track : iterable or Track Iterable of :class:`Track` objects, or a single :class:`Track` object. """ from trackhub import BaseTrack if isins...
[ "def", "add_tracks", "(", "self", ",", "track", ")", ":", "from", "trackhub", "import", "BaseTrack", "if", "isinstance", "(", "track", ",", "BaseTrack", ")", ":", "self", ".", "add_child", "(", "track", ")", "self", ".", "_tracks", ".", "append", "(", ...
Add a track or iterable of tracks. Parameters ---------- track : iterable or Track Iterable of :class:`Track` objects, or a single :class:`Track` object.
[ "Add", "a", "track", "or", "iterable", "of", "tracks", "." ]
train
https://github.com/daler/trackhub/blob/e4655f79177822529f80b923df117e38e28df702/trackhub/trackdb.py#L75-L93
Karaage-Cluster/karaage
karaage/management/commands/unlock_training_accounts.py
nicepass
def nicepass(alpha=8, numeric=4): """ returns a human-readble password (say rol86din instead of a difficult to remember K8Yn9muL ) """ import string import random vowels = ['a', 'e', 'i', 'o', 'u'] consonants = [a for a in string.ascii_lowercase if a not in vowels] digits = string.di...
python
def nicepass(alpha=8, numeric=4): """ returns a human-readble password (say rol86din instead of a difficult to remember K8Yn9muL ) """ import string import random vowels = ['a', 'e', 'i', 'o', 'u'] consonants = [a for a in string.ascii_lowercase if a not in vowels] digits = string.di...
[ "def", "nicepass", "(", "alpha", "=", "8", ",", "numeric", "=", "4", ")", ":", "import", "string", "import", "random", "vowels", "=", "[", "'a'", ",", "'e'", ",", "'i'", ",", "'o'", ",", "'u'", "]", "consonants", "=", "[", "a", "for", "a", "in", ...
returns a human-readble password (say rol86din instead of a difficult to remember K8Yn9muL )
[ "returns", "a", "human", "-", "readble", "password", "(", "say", "rol86din", "instead", "of", "a", "difficult", "to", "remember", "K8Yn9muL", ")" ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/management/commands/unlock_training_accounts.py#L42-L82
Karaage-Cluster/karaage
karaage/people/lookups.py
PersonLookup.get_query
def get_query(self, q, request): """ return a query set searching for the query string q either implement this method yourself or set the search_field in the LookupChannel class definition """ return Person.objects.filter( Q(username__icontains=q) ...
python
def get_query(self, q, request): """ return a query set searching for the query string q either implement this method yourself or set the search_field in the LookupChannel class definition """ return Person.objects.filter( Q(username__icontains=q) ...
[ "def", "get_query", "(", "self", ",", "q", ",", "request", ")", ":", "return", "Person", ".", "objects", ".", "filter", "(", "Q", "(", "username__icontains", "=", "q", ")", "|", "Q", "(", "short_name__icontains", "=", "q", ")", "|", "Q", "(", "full_n...
return a query set searching for the query string q either implement this method yourself or set the search_field in the LookupChannel class definition
[ "return", "a", "query", "set", "searching", "for", "the", "query", "string", "q", "either", "implement", "this", "method", "yourself", "or", "set", "the", "search_field", "in", "the", "LookupChannel", "class", "definition" ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/people/lookups.py#L48-L57
Karaage-Cluster/karaage
karaage/people/lookups.py
GroupLookup.get_query
def get_query(self, q, request): """ return a query set searching for the query string q either implement this method yourself or set the search_field in the LookupChannel class definition """ return Group.objects.filter( Q(name__icontains=q) | Q(d...
python
def get_query(self, q, request): """ return a query set searching for the query string q either implement this method yourself or set the search_field in the LookupChannel class definition """ return Group.objects.filter( Q(name__icontains=q) | Q(d...
[ "def", "get_query", "(", "self", ",", "q", ",", "request", ")", ":", "return", "Group", ".", "objects", ".", "filter", "(", "Q", "(", "name__icontains", "=", "q", ")", "|", "Q", "(", "description__icontains", "=", "q", ")", ")" ]
return a query set searching for the query string q either implement this method yourself or set the search_field in the LookupChannel class definition
[ "return", "a", "query", "set", "searching", "for", "the", "query", "string", "q", "either", "implement", "this", "method", "yourself", "or", "set", "the", "search_field", "in", "the", "LookupChannel", "class", "definition" ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/people/lookups.py#L87-L95
Karaage-Cluster/karaage
karaage/people/lookups.py
GroupLookup.format_match
def format_match(self, obj): """ (HTML) formatted item for display in the dropdown """ result = [escape(obj.name)] if obj.description: result.append(escape(obj.description)) return " ".join(result)
python
def format_match(self, obj): """ (HTML) formatted item for display in the dropdown """ result = [escape(obj.name)] if obj.description: result.append(escape(obj.description)) return " ".join(result)
[ "def", "format_match", "(", "self", ",", "obj", ")", ":", "result", "=", "[", "escape", "(", "obj", ".", "name", ")", "]", "if", "obj", ".", "description", ":", "result", ".", "append", "(", "escape", "(", "obj", ".", "description", ")", ")", "retu...
(HTML) formatted item for display in the dropdown
[ "(", "HTML", ")", "formatted", "item", "for", "display", "in", "the", "dropdown" ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/people/lookups.py#L104-L113
Karaage-Cluster/karaage
karaage/common/trace.py
loggable
def loggable(obj): """Return "True" if the obj implements the minimum Logger API required by the 'trace' decorator. """ if isinstance(obj, logging.Logger): return True else: return (inspect.isclass(obj) and inspect.ismethod(getattr(obj, 'debug', None)) ...
python
def loggable(obj): """Return "True" if the obj implements the minimum Logger API required by the 'trace' decorator. """ if isinstance(obj, logging.Logger): return True else: return (inspect.isclass(obj) and inspect.ismethod(getattr(obj, 'debug', None)) ...
[ "def", "loggable", "(", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "logging", ".", "Logger", ")", ":", "return", "True", "else", ":", "return", "(", "inspect", ".", "isclass", "(", "obj", ")", "and", "inspect", ".", "ismethod", "(", "getat...
Return "True" if the obj implements the minimum Logger API required by the 'trace' decorator.
[ "Return", "True", "if", "the", "obj", "implements", "the", "minimum", "Logger", "API", "required", "by", "the", "trace", "decorator", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/common/trace.py#L131-L141
Karaage-Cluster/karaage
karaage/common/trace.py
_formatter_self
def _formatter_self(name, value): """Format the "self" variable and value on instance methods. """ __mname = value.__module__ if __mname != '__main__': return '%s = <%s.%s object at 0x%x>' \ % (name, __mname, value.__class__.__name__, id(value)) else: return '%s = <%s obj...
python
def _formatter_self(name, value): """Format the "self" variable and value on instance methods. """ __mname = value.__module__ if __mname != '__main__': return '%s = <%s.%s object at 0x%x>' \ % (name, __mname, value.__class__.__name__, id(value)) else: return '%s = <%s obj...
[ "def", "_formatter_self", "(", "name", ",", "value", ")", ":", "__mname", "=", "value", ".", "__module__", "if", "__mname", "!=", "'__main__'", ":", "return", "'%s = <%s.%s object at 0x%x>'", "%", "(", "name", ",", "__mname", ",", "value", ".", "__class__", ...
Format the "self" variable and value on instance methods.
[ "Format", "the", "self", "variable", "and", "value", "on", "instance", "methods", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/common/trace.py#L245-L254
Karaage-Cluster/karaage
karaage/common/trace.py
_formatter_class
def _formatter_class(name, value): """Format the "klass" variable and value on class methods. """ __mname = value.__module__ if __mname != '__main__': return "%s = <type '%s.%s'>" % (name, __mname, value.__name__) else: return "%s = <type '%s'>" % (name, value.__name__)
python
def _formatter_class(name, value): """Format the "klass" variable and value on class methods. """ __mname = value.__module__ if __mname != '__main__': return "%s = <type '%s.%s'>" % (name, __mname, value.__name__) else: return "%s = <type '%s'>" % (name, value.__name__)
[ "def", "_formatter_class", "(", "name", ",", "value", ")", ":", "__mname", "=", "value", ".", "__module__", "if", "__mname", "!=", "'__main__'", ":", "return", "\"%s = <type '%s.%s'>\"", "%", "(", "name", ",", "__mname", ",", "value", ".", "__name__", ")", ...
Format the "klass" variable and value on class methods.
[ "Format", "the", "klass", "variable", "and", "value", "on", "class", "methods", "." ]
train
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/common/trace.py#L257-L264