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_documentation_string stringlengths 1 47.2k | 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()])] | helper function to render subgroups as a string | 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... | 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... | 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) | Add a child :class:`Track`. | 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) | Add a ViewTrack object to this composite.
:param view:
A ViewTrack object. | 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 =... | renders subgroups to a list of strings | 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... | Add one or more tracks to this view.
subtracks : Track or iterable of Tracks
A single Track instance or an iterable of them. | 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... | Add one or more tracks.
subtrack : Track or iterable of Tracks | 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.
... | Parse the scalars from the YAML file content to a dictionary of ScalarType(s).
:return: A dictionary { 'full.scalar.label': ScalarType } | 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.
... | 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. | 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... | 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... | 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... | 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... | 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... | 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. | 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 | Adds self as parent to child, and then adds child. | 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 | Adds self as child of parent, then adds parent. | 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 ... | 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. | 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):
... | Returns an iterator of the HubComponent leaves that are of class `cls`.
If `intermediate` is True, then return any intermediate classes as
well. | 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... | 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. | 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... | Sends an email to admin asking to approve user application | 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
... | Sends an email inviting someone to create an account | 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... | Sends an email informing person application is approved | 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... | Call datastores after adding a person to a group. | 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... | Call datastores after removing a person from a group. | 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):
... | Hook that executes whenever the group members are changed. | 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'
... | 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) | 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'
... | 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... | 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 ',... | Convert hex colors to RGB tuples
Parameters
----------
h : str
String hex color value
>>> hex2rgb("#ff0033")
'255,0,51' | 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 ... | 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... | 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
"""
... | 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 | 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:
... | Parses a nested dictionary returned from :meth:`Hub.render` and just prints
the resulting files. | 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):
... | Pretty-prints the rendered results dictionary.
Rendered results can be multiply-nested dictionaries; this uses JSON
serialization to print a nice representation. | 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 | Returns list of example bigBed files | 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 | get color number index. | 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")... | Generates a bar graph for a project. | 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 | Pie chart comparing institutes usage. | 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 | Pie chart comparing machines usage. | 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 | Total trend graph for machine category. | 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... | Institute trend graph for machine category. | 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 | Get all institute trend graphs. | 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... | Set context with common variables. | 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... | Set context with common variables. | 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... | Creates a new active person. | 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,
... | Creates a new ordinary person. | 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,
... | Creates a new person with super powers. | 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_... | Render current state of application, verbose. | 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 | Render current state of application, verbose. | 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) | Render actions available with extra text. | 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:
... | Wrapper around subprocess.run, with unicode decoding of output.
Additional kwargs are passed to subprocess.run. | 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):
... | Create a symlink to `target` called `linkname`.
Converts `target` and `linkname` to absolute paths; creates
`dirname(linkname)` if needed. | 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... | 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... | 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... | 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"
... | 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'... | 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. | 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... | Stage a hub by symlinking all its connected files to a local directory. | 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... | Renders, stages, and uploads a hub. | 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()] | Returns list of usernames given a project id | 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] | Returns list of project ids | 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... | Used in the submit filter to make sure user is in project | 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] | List projects a user is part of | 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... | Render a given template with any extra URL parameters in the context as
``{{ params }}``. | 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... | 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/... | 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... | Raises ValueError if the password isn't strong.
Returns the password otherwise. | 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... | Lookup module.class. | 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... | Account was saved. | 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.... | Account was deleted. | 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) | Account's password was changed. | 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) | Account's username was changed. | 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... | Add account to group. | 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... | Get the account details. | 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... | Group was saved. | 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 | Group was deleted. | 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) | Group was renamed. | 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():
... | Get the group details. | 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}
... | 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} | 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()... | Returns the tie correction value for U.
See: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.tiecorrect.html | 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)
... | 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 | 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... | 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. | 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)
... | 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. | 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... | 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... | 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... | 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... | 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
... | 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. | 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
# ... | Decorator for views that checks that the user is an administrator,
redirecting to the log-in page if necessary. | 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... | Decorator for views that checks that the user is logged in, redirecting
to the log-in page if necessary. | 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... | Decorator for views that checks that the user is logged in, redirecting
to the log-in page if necessary. | 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... | Call remote command with logging. | 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... | Read CSV delimited input from Slurm. | 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(
... | Get the project details from Slurm. | 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"] != "":
... | Get list of users in project from Slurm. | 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"])
... | Get list of projects in user from Slurm. | 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 ... | Called when account is created/updated. With username override. | 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 | Called when account is deleted. With username override. | 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... | Called when project is saved/updated. | 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 | Called when project is deleted. | 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(... | 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 | 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... | Add a track or iterable of tracks.
Parameters
----------
track : iterable or Track
Iterable of :class:`Track` objects, or a single :class:`Track`
object. | 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... | returns a human-readble password (say rol86din instead of
a difficult to remember K8Yn9muL ) | 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)
... | 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 | 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... | 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 | 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) | (HTML) formatted item for display in the dropdown | 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))
... | Return "True" if the obj implements the minimum Logger API
required by the 'trace' decorator. | 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... | Format the "self" variable and value on instance methods. | 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__) | Format the "klass" variable and value on class methods. | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/common/trace.py#L257-L264 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.