_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q49500 | Bin.use_plenary_agent_view | train | def use_plenary_agent_view(self):
"""Pass through to provider ResourceAgentSession.use_plenary_agent_view"""
self._object_views['agent'] = PLENARY
# self._get_provider_session('resource_agent_session') # To make sure the session is tracked
for session in self._get_provider_sessions():
... | python | {
"resource": ""
} |
q49501 | _join | train | def _join(segments):
"""simply list by joining adjacent segments."""
new = []
start = segments[0][0]
end = segments[0][1]
for i in range(len(segments)-1):
if segments[i+1][0] != segments[i][1]:
new.append((start, end))
start = segments[i+1][0]
end = segments[i... | python | {
"resource": ""
} |
q49502 | _filter_messages | train | def _filter_messages(messages, products=None, levels=None):
"""filter messages for desired products and levels."""
if products is None:
products = []
if levels is None:
levels = []
segments = []
bounds = len(messages)
for i, message in enumerate(messages):
if (message[3] ... | python | {
"resource": ""
} |
q49503 | _download_segments | train | def _download_segments(filename, url, segments):
"""download segments into a single file."""
gribfile = open(filename, 'w')
for start, end in segments:
req = urllib2.Request(url)
req.add_header('User-Agent',
'caelum/0.1 +https://github.com/nrcharles/caelum')
if... | python | {
"resource": ""
} |
q49504 | download | train | def download(timestamp, dataset, path=None, products=None,
levels=None, offset=0):
"""save GFS grib file to DATA_PATH.
Args:
dataset(function): naming convention function. eg. pgrb2
timestamp(datetime): ???
path(str): if None defaults to DATA_PATH
products(list): T... | python | {
"resource": ""
} |
q49505 | message_index | train | def message_index(index_url):
"""get message index of components for urllib2.
Args:
url(string):
Returns:
list: messages
"""
idx = csv.reader(urllib2.urlopen(index_url), delimiter=':')
messages = []
for line in idx:
messages.append(line)
return messages | python | {
"resource": ""
} |
q49506 | is_log | train | def is_log(value):
"""
This function checks whether file path
that is specified at "log_file" option exists,
whether write permission to the file path.
Return the following value:
case1: exists path and write permission
is_log('/tmp')
'/tmp/hogehoge.log'
case2: non-exis... | python | {
"resource": ""
} |
q49507 | is_user | train | def is_user(value, min=None, max=None):
"""
Check whether username or uid as argument exists.
if this function recieved username, convert uid and exec validation.
"""
if type(value) == str:
try:
entry = pwd.getpwnam(value)
value = entry.pw_uid
except KeyError... | python | {
"resource": ""
} |
q49508 | is_group | train | def is_group(value):
"""
Check whether groupname or gid as argument exists.
if this function recieved groupname, convert gid and exec validation.
"""
if type(value) == str:
try:
entry = grp.getgrnam(value)
value = entry.gr_gid
except KeyError:
err... | python | {
"resource": ""
} |
q49509 | ConfigReader._configobj_factory | train | def _configobj_factory(self,
infile,
raise_errors=True,
list_values=True,
file_error=True,
interpolation=False,
configspec=None,
st... | python | {
"resource": ""
} |
q49510 | ConfigReader._validate_global_include | train | def _validate_global_include(self, path):
"""
Normally validation method is writen in each validation of parameters.
But `include` of global section needs to be read before validation.
:param str path: absolute path
:rtype: bool
:return: If given path passes validation, ... | python | {
"resource": ""
} |
q49511 | ConfigReader.global_validate | train | def global_validate(self):
"""
Validate only global section.
The options in global section
is used by other private methods of ConfigReader.
So, validate only global section at first.
"raw_spec" is configspec for global section.
"functions" is passed as an argumen... | python | {
"resource": ""
} |
q49512 | ConfigReader.validate | train | def validate(self):
"""
validate whether value in config file is correct.
"""
spec = self._create_specs()
# support in future
functions = {}
validator = validate.Validator(functions=functions)
self.config.configspec = spec
result = self.config.... | python | {
"resource": ""
} |
q49513 | ConfigReader._parse_result | train | def _parse_result(self, result):
u"""
This method parses validation results.
If result is True, then do nothing.
if include even one false to result,
this method parse result and raise Exception.
"""
if result is not True:
for section, errors in result... | python | {
"resource": ""
} |
q49514 | main | train | def main(args):
of = sys.stdout
if args.output and args.output[-4:] == '.bam':
cmd = 'samtools view -Sb - -o '+args.output
pof = Popen(cmd.split(),stdin=PIPE)
of = pof.stdin
elif args.output:
of = open(args.output,'w')
"""Use the valid input file to get the header information."""
header = Non... | python | {
"resource": ""
} |
q49515 | _do_subread_set | train | def _do_subread_set(flag,input_file,of,negative_filter,aligned):
best = {}
cmd = 'samtools view '+flag+' '+input_file
sys.stderr.write(cmd+"\n")
p = Popen(cmd.split(),stdout=PIPE)
z = 0
for line in p.stdout:
z += 1
if z%10000==0: sys.stderr.write(str(z) + " subread alignment paths sc... | python | {
"resource": ""
} |
q49516 | _traverse_unobserved | train | def _traverse_unobserved(stream,negative_filter,of):
"""Go through a stream and print out anything not in observed set"""
observed = set()
for line in stream:
name = PacBioReadName(_nameprog.match(line).group(1))
if name.get_molecule() not in negative_filter: of.write(line)
observed.add(name.get_molec... | python | {
"resource": ""
} |
q49517 | TaskFinder.default_tasks | train | def default_tasks(self):
"""Return default tasks"""
return dict((name, Task(action=name, label="Harpoon")) for name in default_actions) | python | {
"resource": ""
} |
q49518 | TaskFinder.find_tasks | train | def find_tasks(self, overrides):
"""Find the custom tasks and record the associated image with each task"""
tasks = self.default_tasks()
configuration = self.collector.configuration
for image in list(configuration["images"].keys()):
path = configuration.path(["images", image... | python | {
"resource": ""
} |
q49519 | make_file | train | def make_file(abspath, text):
"""
Make a file with utf-8 text.
"""
try:
with open(abspath, "wb") as f:
f.write(text.encode("utf-8"))
print("Made: %s" % abspath)
except: # pragma: no cover
pass | python | {
"resource": ""
} |
q49520 | AssetQuery.match_created_date | train | def match_created_date(self, start, end, match):
"""Match assets that are created between the specified time period.
arg: start (osid.calendaring.DateTime): start time of the
query
arg: end (osid.calendaring.DateTime): end time of the query
arg: match (boolean):... | python | {
"resource": ""
} |
q49521 | AssetQuery.match_published_date | train | def match_published_date(self, start, end, match):
"""Match assets that are published between the specified time period.
arg: start (osid.calendaring.DateTime): start time of the
query
arg: end (osid.calendaring.DateTime): end time of the query
arg: match (boole... | python | {
"resource": ""
} |
q49522 | CommentLookupSession.get_comment | train | def get_comment(self, comment_id):
"""Gets the ``Comment`` specified by its ``Id``.
arg: comment_id (osid.id.Id): the ``Id`` of the ``Comment``
to retrieve
return: (osid.commenting.Comment) - the returned ``Comment``
raise: NotFound - no ``Comment`` found with the gi... | python | {
"resource": ""
} |
q49523 | CommentLookupSession.get_comments_by_ids | train | def get_comments_by_ids(self, comment_ids):
"""Gets a ``CommentList`` corresponding to the given ``IdList``.
arg: comment_ids (osid.id.IdList): the list of ``Ids`` to
retrieve
return: (osid.commenting.CommentList) - the returned ``Comment
list``
raise:... | python | {
"resource": ""
} |
q49524 | CommentLookupSession.get_comments_by_genus_type | train | def get_comments_by_genus_type(self, comment_genus_type):
"""Gets a ``CommentList`` corresponding to the given comment genus ``Type`` which does not include comments of genus types derived from the specified ``Type``.
arg: comment_genus_type (osid.type.Type): a comment genus
type
... | python | {
"resource": ""
} |
q49525 | CommentLookupSession.get_comments_on_date | train | def get_comments_on_date(self, from_, to):
"""Gets a ``CommentList`` effective during the entire given date range inclusive but not confined to the date range.
arg: from (osid.calendaring.DateTime): starting date
arg: to (osid.calendaring.DateTime): ending date
return: (osid.comme... | python | {
"resource": ""
} |
q49526 | CommentLookupSession.get_comments_for_commentor_on_date | train | def get_comments_for_commentor_on_date(self, resource_id, from_, to):
"""Gets a list of all comments corresponding to a resource ``Id`` and effective during the entire given date range inclusive but not confined to the date range.
arg: resource_id (osid.id.Id): the ``Id`` of the resource
arg... | python | {
"resource": ""
} |
q49527 | CommentLookupSession.get_comments_for_reference_on_date | train | def get_comments_for_reference_on_date(self, reference_id, from_, to):
"""Gets a list of all comments corresponding to a reference ``Id`` and effective during the entire given date range inclusive but not confined to the date range.
arg: reference_id (osid.id.Id): a reference ``Id``
arg: ... | python | {
"resource": ""
} |
q49528 | CommentLookupSession.get_comments_by_genus_type_for_reference_on_date | train | def get_comments_by_genus_type_for_reference_on_date(self, reference_id, comment_genus_type, from_, to):
"""Gets a list of all comments of the given genus type corresponding to a reference ``Id`` and effective during the entire given date range inclusive but not confined to the date range.
arg: refe... | python | {
"resource": ""
} |
q49529 | CommentLookupSession.get_comments_for_commentor_and_reference | train | def get_comments_for_commentor_and_reference(self, resource_id, reference_id):
"""Gets a list of comments corresponding to a resource and reference ``Id``.
arg: resource_id (osid.id.Id): the ``Id`` of the resource
arg: reference_id (osid.id.Id): the ``Id`` of the reference
return:... | python | {
"resource": ""
} |
q49530 | CommentLookupSession.get_comments | train | def get_comments(self):
"""Gets all comments.
return: (osid.commenting.CommentList) - a list of comments
raise: OperationFailed - unable to complete request
raise: PermissionDenied - authorization failure
*compliance: mandatory -- This method must be implemented.*
"""... | python | {
"resource": ""
} |
q49531 | CommentQuerySession.get_comments_by_query | train | def get_comments_by_query(self, comment_query):
"""Gets a list of comments matching the given search.
arg: comment_query (osid.commenting.CommentQuery): the search
query array
return: (osid.commenting.CommentList) - the returned
``CommentList``
raise: ... | python | {
"resource": ""
} |
q49532 | CommentAdminSession.get_comment_form_for_create | train | def get_comment_form_for_create(self, reference_id, comment_record_types):
"""Gets the comment form for creating new comments.
A new form should be requested for each create transaction.
arg: reference_id (osid.id.Id): the ``Id`` for the reference
object
arg: comm... | python | {
"resource": ""
} |
q49533 | CommentAdminSession.create_comment | train | def create_comment(self, comment_form):
"""Creates a new ``Comment``.
arg: comment_form (osid.commenting.CommentForm): the form for
this ``Comment``
return: (osid.commenting.Comment) - the new ``Comment``
raise: IllegalState - ``comment_form`` already used in a creat... | python | {
"resource": ""
} |
q49534 | CommentAdminSession.update_comment | train | def update_comment(self, comment_form):
"""Updates an existing comment.
arg: comment_form (osid.commenting.CommentForm): the form
containing the elements to be updated
raise: IllegalState - ``comment_form`` already used in an
update transaction
raise:... | python | {
"resource": ""
} |
q49535 | CommentAdminSession.delete_comment | train | def delete_comment(self, comment_id):
"""Deletes a ``Comment``.
arg: comment_id (osid.id.Id): the ``Id`` of the ``Comment``
to remove
raise: NotFound - ``comment_id`` not found
raise: NullArgument - ``comment_id`` is ``null``
raise: OperationFailed - unable... | python | {
"resource": ""
} |
q49536 | CommentAdminSession.alias_comment | train | def alias_comment(self, comment_id, alias_id):
"""Adds an ``Id`` to a ``Comment`` for the purpose of creating compatibility.
The primary ``Id`` of the ``Comment`` is determined by the
provider. The new ``Id`` performs as an alias to the primary
``Id``. If the alias is a pointer to anoth... | python | {
"resource": ""
} |
q49537 | CommentBookSession.get_comment_ids_by_book | train | def get_comment_ids_by_book(self, book_id):
"""Gets the list of Comment Ids associated with a ``Book``.
arg: book_id (osid.id.Id): ``Id`` of a ``Book``.
return: (osid.id.IdList) - list of related comment ``Ids``
raise: NotFound - ``book_id`` is not found
raise: NullArgument... | python | {
"resource": ""
} |
q49538 | CommentBookSession.get_comments_by_book | train | def get_comments_by_book(self, book_id):
"""Gets the list of ``Comments`` associated with a ``Book``.
arg: book_id (osid.id.Id): ``Id`` of a ``Book``
return: (osid.commenting.CommentList) - list of related comments
raise: NotFound - ``book_id`` is not found
raise: NullArgum... | python | {
"resource": ""
} |
q49539 | CommentBookSession.get_comment_ids_by_books | train | def get_comment_ids_by_books(self, book_ids):
"""Gets the list of ``Comment Ids`` corresponding to a list of ``Book`` objects.
arg: book_ids (osid.id.IdList): list of book ``Ids``
return: (osid.id.IdList) - list of comment ``Ids``
raise: NullArgument - ``book_ids`` is ``null``
... | python | {
"resource": ""
} |
q49540 | CommentBookSession.get_comments_by_books | train | def get_comments_by_books(self, book_ids):
"""Gets the list of ``Comments`` corresponding to a list of ``Books``.
arg: book_ids (osid.id.IdList): list of book ``Ids``
return: (osid.commenting.CommentList) - list of comments
raise: NullArgument - ``book_ids`` is ``null``
rais... | python | {
"resource": ""
} |
q49541 | CommentBookSession.get_book_ids_by_comment | train | def get_book_ids_by_comment(self, comment_id):
"""Gets the list of ``Book`` ``Ids`` mapped to a ``Comment``.
arg: comment_id (osid.id.Id): ``Id`` of a ``Comment``
return: (osid.id.IdList) - list of book ``Ids``
raise: NotFound - ``comment_id`` is not found
raise: NullArgum... | python | {
"resource": ""
} |
q49542 | CommentBookSession.get_books_by_comment | train | def get_books_by_comment(self, comment_id):
"""Gets the list of ``Book`` objects mapped to a ``Comment``.
arg: comment_id (osid.id.Id): ``Id`` of a ``Comment``
return: (osid.commenting.BookList) - list of books
raise: NotFound - ``comment_id`` is not found
raise: NullArgume... | python | {
"resource": ""
} |
q49543 | CommentBookAssignmentSession.get_assignable_book_ids | train | def get_assignable_book_ids(self, book_id):
"""Gets a list of books including and under the given book node in which any comment can be assigned.
arg: book_id (osid.id.Id): the ``Id`` of the ``Book``
return: (osid.id.IdList) - list of assignable book ``Ids``
raise: NullArgument - ``... | python | {
"resource": ""
} |
q49544 | CommentBookAssignmentSession.assign_comment_to_book | train | def assign_comment_to_book(self, comment_id, book_id):
"""Adds an existing ``Comment`` to a ``Book``.
arg: comment_id (osid.id.Id): the ``Id`` of the ``Comment``
arg: book_id (osid.id.Id): the ``Id`` of the ``Book``
raise: AlreadyExists - ``comment_id`` is already assigned to
... | python | {
"resource": ""
} |
q49545 | CommentBookAssignmentSession.unassign_comment_from_book | train | def unassign_comment_from_book(self, comment_id, book_id):
"""Removes a ``Comment`` from a ``Book``.
arg: comment_id (osid.id.Id): the ``Id`` of the ``Comment``
arg: book_id (osid.id.Id): the ``Id`` of the ``Book``
raise: NotFound - ``comment_id`` or ``book_id`` not found or
... | python | {
"resource": ""
} |
q49546 | CommentBookAssignmentSession.reassign_comment_to_book | train | def reassign_comment_to_book(self, comment_id, from_book_id, to_book_id):
"""Moves a ``Credit`` from one ``Book`` to another.
Mappings to other ``Books`` are unaffected.
arg: comment_id (osid.id.Id): the ``Id`` of the ``Comment``
arg: from_book_id (osid.id.Id): the ``Id`` of the ... | python | {
"resource": ""
} |
q49547 | BookAdminSession.can_create_book_with_record_types | train | def can_create_book_with_record_types(self, book_record_types):
"""Tests if this user can create a single ``Book`` using the desired record types.
While ``CommentingManager.getBookRecordTypes()`` can be used to
examine which records are supported, this method tests which
record(s) are r... | python | {
"resource": ""
} |
q49548 | BookAdminSession.update_book | train | def update_book(self, book_form):
"""Updates an existing book.
arg: book_form (osid.commenting.BookForm): the form
containing the elements to be updated
raise: IllegalState - ``book_form`` already used in an update
transaction
raise: InvalidArgument ... | python | {
"resource": ""
} |
q49549 | BookAdminSession.alias_book | train | def alias_book(self, book_id, alias_id):
"""Adds an ``Id`` to a ``Book`` for the purpose of creating compatibility.
The primary ``Id`` of the ``Book`` is determined by the
provider. The new ``Id`` performs as an alias to the primary
``Id``. If the alias is a pointer to another book, it ... | python | {
"resource": ""
} |
q49550 | BookHierarchySession.get_root_books | train | def get_root_books(self):
"""Gets the root books in the book hierarchy.
A node with no parents is an orphan. While all book ``Ids`` are
known to the hierarchy, an orphan does not appear in the
hierarchy unless explicitly added as a root node or child of
another node.
re... | python | {
"resource": ""
} |
q49551 | BookHierarchySession.has_parent_books | train | def has_parent_books(self, book_id):
"""Tests if the ``Book`` has any parents.
arg: book_id (osid.id.Id): a book ``Id``
return: (boolean) - ``true`` if the book has parents, f ``alse``
otherwise
raise: NotFound - ``book_id`` is not found
raise: NullArgument ... | python | {
"resource": ""
} |
q49552 | BookHierarchySession.is_parent_of_book | train | def is_parent_of_book(self, id_, book_id):
"""Tests if an ``Id`` is a direct parent of book.
arg: id (osid.id.Id): an ``Id``
arg: book_id (osid.id.Id): the ``Id`` of a book
return: (boolean) - ``true`` if this ``id`` is a parent of
``book_id,`` f ``alse`` otherwise... | python | {
"resource": ""
} |
q49553 | BookHierarchySession.get_parent_book_ids | train | def get_parent_book_ids(self, book_id):
"""Gets the parent ``Ids`` of the given book.
arg: book_id (osid.id.Id): a book ``Id``
return: (osid.id.IdList) - the parent ``Ids`` of the book
raise: NotFound - ``book_id`` is not found
raise: NullArgument - ``book_id`` is ``null``
... | python | {
"resource": ""
} |
q49554 | BookHierarchySession.get_parent_books | train | def get_parent_books(self, book_id):
"""Gets the parent books of the given ``id``.
arg: book_id (osid.id.Id): the ``Id`` of the ``Book`` to
query
return: (osid.commenting.BookList) - the parent books of the
``id``
raise: NotFound - a ``Book`` identifi... | python | {
"resource": ""
} |
q49555 | BookHierarchySession.is_ancestor_of_book | train | def is_ancestor_of_book(self, id_, book_id):
"""Tests if an ``Id`` is an ancestor of a book.
arg: id (osid.id.Id): an ``Id``
arg: book_id (osid.id.Id): the ``Id`` of a book
return: (boolean) - ``tru`` e if this ``id`` is an ancestor of
``book_id,`` ``false`` other... | python | {
"resource": ""
} |
q49556 | BookHierarchySession.has_child_books | train | def has_child_books(self, book_id):
"""Tests if a book has any children.
arg: book_id (osid.id.Id): a book ``Id``
return: (boolean) - ``true`` if the ``book_id`` has children,
``false`` otherwise
raise: NotFound - ``book_id`` is not found
raise: NullArgument... | python | {
"resource": ""
} |
q49557 | BookHierarchySession.is_child_of_book | train | def is_child_of_book(self, id_, book_id):
"""Tests if a book is a direct child of another.
arg: id (osid.id.Id): an ``Id``
arg: book_id (osid.id.Id): the ``Id`` of a book
return: (boolean) - ``true`` if the ``id`` is a child of
``book_id,`` ``false`` otherwise
... | python | {
"resource": ""
} |
q49558 | BookHierarchySession.get_child_book_ids | train | def get_child_book_ids(self, book_id):
"""Gets the child ``Ids`` of the given book.
arg: book_id (osid.id.Id): the ``Id`` to query
return: (osid.id.IdList) - the children of the book
raise: NotFound - ``book_id`` is not found
raise: NullArgument - ``book_id`` is ``null``
... | python | {
"resource": ""
} |
q49559 | BookHierarchySession.get_child_books | train | def get_child_books(self, book_id):
"""Gets the child books of the given ``id``.
arg: book_id (osid.id.Id): the ``Id`` of the ``Book`` to
query
return: (osid.commenting.BookList) - the child books of the
``id``
raise: NotFound - a ``Book`` identified ... | python | {
"resource": ""
} |
q49560 | BookHierarchySession.is_descendant_of_book | train | def is_descendant_of_book(self, id_, book_id):
"""Tests if an ``Id`` is a descendant of a book.
arg: id (osid.id.Id): an ``Id``
arg: book_id (osid.id.Id): the ``Id`` of a book
return: (boolean) - ``true`` if the ``id`` is a descendant of
the ``book_id,`` ``false``... | python | {
"resource": ""
} |
q49561 | BookHierarchySession.get_book_nodes | train | def get_book_nodes(self, book_id, ancestor_levels, descendant_levels, include_siblings):
"""Gets a portion of the hierarchy for the given book.
arg: book_id (osid.id.Id): the ``Id`` to query
arg: ancestor_levels (cardinal): the maximum number of
ancestor levels to include.... | python | {
"resource": ""
} |
q49562 | BookHierarchyDesignSession.add_root_book | train | def add_root_book(self, book_id):
"""Adds a root book.
arg: book_id (osid.id.Id): the ``Id`` of a book
raise: AlreadyExists - ``book_id`` is already in hierarchy
raise: NotFound - ``book_id`` is not found
raise: NullArgument - ``book_id`` is ``null``
raise: Operat... | python | {
"resource": ""
} |
q49563 | BookHierarchyDesignSession.remove_root_book | train | def remove_root_book(self, book_id):
"""Removes a root book.
arg: book_id (osid.id.Id): the ``Id`` of a book
raise: NotFound - ``book_id`` is not a root
raise: NullArgument - ``book_id`` is ``null``
raise: OperationFailed - unable to complete request
raise: Permis... | python | {
"resource": ""
} |
q49564 | BookHierarchyDesignSession.add_child_book | train | def add_child_book(self, book_id, child_id):
"""Adds a child to a book.
arg: book_id (osid.id.Id): the ``Id`` of a book
arg: child_id (osid.id.Id): the ``Id`` of the new child
raise: AlreadyExists - ``book_id`` is already a parent of
``child_id``
raise: N... | python | {
"resource": ""
} |
q49565 | BookHierarchyDesignSession.remove_child_book | train | def remove_child_book(self, book_id, child_id):
"""Removes a child from a book.
arg: book_id (osid.id.Id): the ``Id`` of a book
arg: child_id (osid.id.Id): the ``Id`` of the new child
raise: NotFound - ``book_id`` not a parent of ``child_id``
raise: NullArgument - ``book... | python | {
"resource": ""
} |
q49566 | BookHierarchyDesignSession.remove_child_books | train | def remove_child_books(self, book_id):
"""Removes all children from a book.
arg: book_id (osid.id.Id): the ``Id`` of a book
raise: NotFound - ``book_id`` not found
raise: NullArgument - ``book_id`` is ``null``
raise: OperationFailed - unable to complete request
rai... | python | {
"resource": ""
} |
q49567 | ValueRetrievalSession.get_value_by_parameter | train | def get_value_by_parameter(self, parameter_id=None):
"""Gets a ``Value`` for the given parameter ``Id``.
If more than one value exists for the given parameter, the most
preferred value is returned. This method can be used as a
convenience when only one value is expected.
``get_v... | python | {
"resource": ""
} |
q49568 | parse_config | train | def parse_config():
"""Parse the configuration and create required services.
Note:
Either takes the configuration from the environment (a variable
named ``FLASH_CONFIG``) or a file at the module root (named
``config.json``). Either way, it will attempt to parse it as
JSON, expecting the... | python | {
"resource": ""
} |
q49569 | _parse_file | train | def _parse_file():
"""Parse the config from a file.
Note:
Assumes any value that ``"$LOOKS_LIKE_THIS"`` in a service
definition refers to an environment variable, and attempts to get
it accordingly.
"""
file_name = path.join(
path.abspath(path.dirname(path.dirname(__file__)))... | python | {
"resource": ""
} |
q49570 | _read_file | train | def _read_file(file_name):
"""Read the file content and load it as JSON.
Arguments:
file_name (:py:class:`str`): The filename.
Returns:
:py:class:`dict`: The loaded JSON data.
Raises:
:py:class:`FileNotFoundError`: If the file is not found.
"""
with open(file_name) as confi... | python | {
"resource": ""
} |
q49571 | Mastool.build_message | train | def build_message(self, checker):
"""Builds the checker's error message to report"""
solution = ' (%s)' % checker.solution if self.with_solutions else ''
return '{} {}{}'.format(checker.code,
checker.msg,
solution) | python | {
"resource": ""
} |
q49572 | Mastool.run | train | def run(self):
"""Primary entry point to the plugin, runs once per file."""
paths = [x for x in practices.__dict__.values()
if hasattr(x, 'code')]
for node in ast.walk(self.tree):
try:
lineno, col_offset = node.lineno, node.col_offset
exc... | python | {
"resource": ""
} |
q49573 | SQLAlchemyBackend.all_experiments | train | def all_experiments(self):
"""
Retrieve every available experiment.
Returns a list of ``cleaver.experiment.Experiment``s
"""
try:
return [
self.experiment_factory(e)
for e in model.Experiment.query.all()
]
finally:
... | python | {
"resource": ""
} |
q49574 | SQLAlchemyBackend.set_variant | train | def set_variant(self, identity, experiment_name, variant_name):
"""
Set the variant for a specific user.
:param identity a unique user identifier
:param experiment_name the string name of the experiment
:param variant_name the string name of the variant
"""
try:
... | python | {
"resource": ""
} |
q49575 | LabNotebook._parametersAsIndex | train | def _parametersAsIndex( self, ps ):
"""Private method to turn a parameter dict into a string suitable for
keying a dict.
ps: the parameters as a hash
returns: a string key"""
k = ""
for p in sorted(ps.keys()): # normalise the parameters
v = ps[p]
... | python | {
"resource": ""
} |
q49576 | LabNotebook.addPendingResult | train | def addPendingResult( self, ps, jobid ):
"""Add a "pending" result that we expect to get results for.
:param ps: the parameters for the result
:param jobid: an identifier for the pending result"""
k = self._parametersAsIndex(ps)
# retrieve or create the result list
if k... | python | {
"resource": ""
} |
q49577 | LabNotebook.cancelPendingResult | train | def cancelPendingResult( self, jobid ):
"""Cancel a particular pending result. Note that this only affects the
notebook's record, not any job running in a lab.
:param jobid: job id for pending result"""
if jobid in self._pending.keys():
k = self._pending[jobid]
d... | python | {
"resource": ""
} |
q49578 | LabNotebook.pendingResultsFor | train | def pendingResultsFor( self, ps ):
"""Retrieve a list of all pending results associated with the given parameters.
:param ps: the parameters
:returns: a list of pending result job ids, which may be empty"""
k = self._parametersAsIndex(ps)
if k in self._results.keys():
... | python | {
"resource": ""
} |
q49579 | LabNotebook.cancelPendingResultsFor | train | def cancelPendingResultsFor( self, ps ):
"""Cancel all pending results for the given parameters. Note that
this only affects the notebook's record, not any job running in a lab.
:param ps: the parameters"""
k = self._parametersAsIndex(ps)
if k in self._results.keys():
... | python | {
"resource": ""
} |
q49580 | LabNotebook.cancelAllPendingResults | train | def cancelAllPendingResults( self ):
"""Cancel all pending results. Note that this only affects the
notebook's record, not any job running in a lab."""
for k in self._results.keys():
rs = self._results[k]
self._results[k] = [ j for j in rs if isinstance(j, dict) ]
... | python | {
"resource": ""
} |
q49581 | LabNotebook.resultsFor | train | def resultsFor( self, ps ):
"""Retrieve a list of all results associated with the given parameters.
:param ps: the parameters
:returns: a list of results, which may be empty"""
k = self._parametersAsIndex(ps)
if k in self._results.keys():
# filter out pending job ids... | python | {
"resource": ""
} |
q49582 | LabNotebook.results | train | def results( self ):
"""Return a list of all the results currently available. This
excludes pending results. Results are returned as a single flat
list, so any repetition structure is lost.
:returns: a list of results"""
rs = []
for k in self._results.keys():
... | python | {
"resource": ""
} |
q49583 | LabNotebook.dataframe | train | def dataframe( self, only_successful = True ):
"""Return the results as a pandas DataFrame. Note that there is a danger
of duplicate labels here, for example if the results contain a value
with the same name as one of the parameters. To resolve this, parameter names
take precedence over ... | python | {
"resource": ""
} |
q49584 | SYLK.parse | train | def parse(self, stream):
"""
Parse the given stream
"""
lines = re.sub("[\r\n]+", "\n", stream.read()).split("\n")
for line in lines:
self.parseline(line) | python | {
"resource": ""
} |
q49585 | stream_as_text | train | async def stream_as_text(stream):
"""
Given a stream of bytes or text, if any of the items in the stream
are bytes convert them to text.
This function can be removed once we return text streams
instead of byte streams.
"""
async for data in stream:
if not isinstance(data, six.text_ty... | python | {
"resource": ""
} |
q49586 | pylint_jenkins | train | def pylint_jenkins():
"""Run PyLint on the code and produce a report suitable for the
Jenkins plugin 'violations'.
Note that there is a bug in the Violations plugin which means that
absolute paths to source (produced by PyLint) are not read. The sed command
removes the workspace part of the path ma... | python | {
"resource": ""
} |
q49587 | configure_google_analytics | train | def configure_google_analytics():
"""An optional task; if run, this will switch on Google Analystics, reporting
documentation usage to Aviser.
This is meant to be run only by Aviser when producing HTML for the main
web site.
"""
f = open(os.path.join("doc", "_templates", "google-analytics.html"... | python | {
"resource": ""
} |
q49588 | launch_modules_with_names | train | def launch_modules_with_names(modules_with_names, module_args={}, kill_before_launch=True):
'''launch module.main functions in another process'''
processes = []
if kill_before_launch:
for module_name, name in modules_with_names:
kill_module(name)
for module_name, name in modules_with... | python | {
"resource": ""
} |
q49589 | ApiAlbum._add_remove | train | def _add_remove(self, action, album, objects, object_type=None,
**kwds):
"""Common code for the add and remove endpoints."""
# Ensure we have an iterable of objects
if not isinstance(objects, collections.Iterable):
objects = [objects]
# Extract the type o... | python | {
"resource": ""
} |
q49590 | Command.clone | train | def clone(self, folder, git_repository):
"""Ensures theme destination folder and clone git specified repo in it.
:param git_repository: git url of the theme folder
:param folder: path of the git managed theme folder
"""
os.makedirs(folder)
git.Git().clone(git_repository,... | python | {
"resource": ""
} |
q49591 | Command.update_git_repository | train | def update_git_repository(self, folder, git_repository):
"""Updates git remote for the managed theme folder if has changed.
:param git_repository: git url of the theme folder
:param folder: path of the git managed theme folder
"""
# load repo object from path
repo = git... | python | {
"resource": ""
} |
q49592 | Command.update | train | def update(self, folder, git_repository):
"""Creates or updates theme folder according given git repository.
:param git_repository: git url of the theme folder
:param folder: path of the git managed theme folder
"""
# git clone
try:
self.clone(folder, git_rep... | python | {
"resource": ""
} |
q49593 | read_sex_problems | train | def read_sex_problems(file_name):
"""Reads the sex problem file.
:param file_name: the name of the file containing sex problems.
:type file_name: str
:returns: a :py:class:`frozenset` containing samples with sex problem.
If there is no ``file_name`` (*i.e.* is ``None``), then an empty
:py:cl... | python | {
"resource": ""
} |
q49594 | encode_chr | train | def encode_chr(chromosome):
"""Encodes chromosomes.
:param chromosome: the chromosome to encode.
:type chromosome: str
:returns: the encoded chromosome as :py:class:`int`.
It changes ``X``, ``Y``, ``XY`` and ``MT`` to ``23``, ``24``, ``25`` and
``26``, respectively. It changes everything els... | python | {
"resource": ""
} |
q49595 | read_bim | train | def read_bim(file_name):
"""Reads the BIM file to gather marker names.
:param file_name: the name of the ``bim`` file.
:type file_name: str
:returns: a :py:class:`dict` containing the chromosomal location of each
marker on the sexual chromosomes.
It uses the :py:func:`encode_chr` t... | python | {
"resource": ""
} |
q49596 | read_fam | train | def read_fam(file_name):
"""Reads the FAM file to gather sample names.
:param file_name: the ``fam`` file to read.
:type file_name: str
:returns: a :py:class:`dict` containing the gender of each samples.
It uses the :py:func:`encode_gender` to encode the gender from ``1``and
``2`` to ``Male`... | python | {
"resource": ""
} |
q49597 | print_data_to_file | train | def print_data_to_file(data, file_name):
"""Prints data to file.
:param data: the data to print.
:param file_name: the name of the output file.
:type data: numpy.recarray
:type file_name: str
"""
try:
with open(file_name, 'w') as output_file:
print >>output_file, "\t".... | python | {
"resource": ""
} |
q49598 | read_summarized_intensities | train | def read_summarized_intensities(prefix):
"""Reads the summarized intensities from 6 files.
:param prefix: the prefix of the six files.
:type prefix: str
:returns: a :py:class`numpy.recarray` containing the following columns (for
each of the samples): ``sampleID``, ``chr23``, ``chr24``,
... | python | {
"resource": ""
} |
q49599 | SoftDeleteManager.filter | train | def filter(self, *args, **kwargs):
"""If id or pk was specified as a kwargs, return even if it's deleteted."""
if 'pk' in kwargs or 'id' in kwargs:
return self.all_with_deleted().filter(*args, **kwargs)
return self.get_query_set().filter(*args, **kwargs) | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.