_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q5600 | offset_limit | train | def offset_limit(func):
"""
Decorator that converts python slicing to offset and limit
"""
def func_wrapper(self, start, stop):
offset = start
limit = stop - start
return func(self, offset, limit)
return func_wrapper | python | {
"resource": ""
} |
q5601 | generate_id | train | def generate_id(*s):
"""
generates an id from one or more given strings
it uses english as the base language in case some strings
are translated, this ensures consistent ids
"""
with translation.override("en"):
generated_id = slugify("-".join([str(i) for i in s]))
return generated_id | python | {
"resource": ""
} |
q5602 | append_query_parameter | train | def append_query_parameter(url, parameters, ignore_if_exists=True):
""" quick and dirty appending of query parameters to a url """
if ignore_if_exists:
for key in parameters.keys():
if key + "=" in url:
del parameters[key]
parameters_str = "&".join(k + "=" + v for k, v in... | python | {
"resource": ""
} |
q5603 | BetterFileInput.render | train | def render(self, name, value, attrs=None, renderer=None):
"""For django 1.10 compatibility"""
if django.VERSION >= (1, 11):
return super(BetterFileInput, self).render(name, value, attrs)
t = render_to_string(
template_name=self.template_name,
context=self.get... | python | {
"resource": ""
} |
q5604 | get_table | train | def get_table(ports):
"""
This function returns a pretty table used to display the port results.
:param ports: list of found ports
:return: the table to display
"""
table = PrettyTable(["Name", "Port", "Protocol", "Description"])
table.align["Name"] = "l"
table.align["Description"] = "l... | python | {
"resource": ""
} |
q5605 | run | train | def run(port, like, use_json, server):
"""Search port names and numbers."""
if not port and not server[0]:
raise click.UsageError("Please specify a port")
if server[0]:
app.run(host=server[0], port=server[1])
return
ports = get_ports(port, like)
if not ports:
sys.st... | python | {
"resource": ""
} |
q5606 | RPCClient.validate_addr | train | def validate_addr(self, address, id=None, endpoint=None):
"""
returns whether or not addr string is valid
Args:
address: (str) address to lookup ( in format 'AXjaFSP23Jkbe6Pk9pPGT6NBDs1HVdqaXK')
id: (int, optional) id to use for response tracking
endpoint: (R... | python | {
"resource": ""
} |
q5607 | MPIPool.map | train | def map(self, worker, tasks, callback=None):
"""Evaluate a function or callable on each task in parallel using MPI.
The callable, ``worker``, is called on each element of the ``tasks``
iterable. The results are returned in the expected order (symmetric with
``tasks``).
Paramete... | python | {
"resource": ""
} |
q5608 | MPIPool.close | train | def close(self):
""" Tell all the workers to quit."""
if self.is_worker():
return
for worker in self.workers:
self.comm.send(None, worker, 0) | python | {
"resource": ""
} |
q5609 | update_git_devstr | train | def update_git_devstr(version, path=None):
"""
Updates the git revision string if and only if the path is being imported
directly from a git working copy. This ensures that the revision number in
the version string is accurate.
"""
try:
# Quick way to determine if we're in git or not -... | python | {
"resource": ""
} |
q5610 | get_git_devstr | train | def get_git_devstr(sha=False, show_warning=True, path=None):
"""
Determines the number of revisions in this repository.
Parameters
----------
sha : bool
If True, the full SHA1 hash will be returned. Otherwise, the total
count of commits in the repository will be used as a "revision
... | python | {
"resource": ""
} |
q5611 | _get_repo_path | train | def _get_repo_path(pathname, levels=None):
"""
Given a file or directory name, determine the root of the git repository
this path is under. If given, this won't look any higher than ``levels``
(that is, if ``levels=0`` then the given path must be the root of the git
repository and is returned if so... | python | {
"resource": ""
} |
q5612 | translate | train | def translate(
nucleotide_sequence,
first_codon_is_start=True,
to_stop=True,
truncate=False):
"""Translates cDNA coding sequence into amino acid protein sequence.
Should typically start with a start codon but allowing non-methionine
first residues since the CDS we're transla... | python | {
"resource": ""
} |
q5613 | main | train | def main(args_list=None):
"""
Script which loads variants and annotates them with overlapping genes.
Example usage:
varcode-genes
--vcf mutect.vcf \
--vcf strelka.vcf \
--maf tcga_brca.maf \
--variant chr1 498584 C G \
--json-variants more... | python | {
"resource": ""
} |
q5614 | load_maf_dataframe | train | def load_maf_dataframe(path, nrows=None, raise_on_error=True, encoding=None):
"""
Load the guaranteed columns of a TCGA MAF file into a DataFrame
Parameters
----------
path : str
Path to MAF file
nrows : int
Optional limit to number of rows loaded
raise_on_error : bool
... | python | {
"resource": ""
} |
q5615 | load_maf | train | def load_maf(
path,
optional_cols=[],
sort_key=variant_ascending_position_sort_key,
distinct=True,
raise_on_error=True,
encoding=None):
"""
Load reference name and Variant objects from MAF filename.
Parameters
----------
path : str
Path to MA... | python | {
"resource": ""
} |
q5616 | apply_to_field_if_exists | train | def apply_to_field_if_exists(effect, field_name, fn, default):
"""
Apply function to specified field of effect if it is not None,
otherwise return default.
"""
value = getattr(effect, field_name, None)
if value is None:
return default
else:
return fn(value) | python | {
"resource": ""
} |
q5617 | apply_to_transcript_if_exists | train | def apply_to_transcript_if_exists(effect, fn, default):
"""
Apply function to transcript associated with effect,
if it exists, otherwise return default.
"""
return apply_to_field_if_exists(
effect=effect,
field_name="transcript",
fn=fn,
default=default) | python | {
"resource": ""
} |
q5618 | gene_id_of_associated_transcript | train | def gene_id_of_associated_transcript(effect):
"""
Ensembl gene ID of transcript associated with effect, returns
None if effect does not have transcript.
"""
return apply_to_transcript_if_exists(
effect=effect,
fn=lambda t: t.gene_id,
default=None) | python | {
"resource": ""
} |
q5619 | parse_transcript_number | train | def parse_transcript_number(effect):
"""
Try to parse the number at the end of a transcript name associated with
an effect.
e.g. TP53-001 returns the integer 1.
Parameters
----------
effect : subclass of MutationEffect
Returns int
"""
name = name_of_associated_transcript(effec... | python | {
"resource": ""
} |
q5620 | select_between_exonic_splice_site_and_alternate_effect | train | def select_between_exonic_splice_site_and_alternate_effect(effect):
"""
If the given effect is an ExonicSpliceSite then it might contain
an alternate effect of higher priority. In that case, return the
alternate effect. Otherwise, this acts as an identity function.
"""
if effect.__class__ is not... | python | {
"resource": ""
} |
q5621 | keep_max_priority_effects | train | def keep_max_priority_effects(effects):
"""
Given a list of effects, only keep the ones with the maximum priority
effect type.
Parameters
----------
effects : list of MutationEffect subclasses
Returns list of same length or shorter
"""
priority_values = map(effect_priority, effects... | python | {
"resource": ""
} |
q5622 | filter_pipeline | train | def filter_pipeline(effects, filters):
"""
Apply each filter to the effect list sequentially. If any filter
returns zero values then ignore it. As soon as only one effect is left,
return it.
Parameters
----------
effects : list of MutationEffect subclass instances
filters : list of fun... | python | {
"resource": ""
} |
q5623 | top_priority_effect_for_single_gene | train | def top_priority_effect_for_single_gene(effects):
"""
For effects which are from the same gene, check to see if there
is a canonical transcript with both the maximum length CDS
and maximum length full transcript sequence.
If not, then use number of exons and transcript name as tie-breaking
feat... | python | {
"resource": ""
} |
q5624 | VariantCollection.filter_by_transcript_expression | train | def filter_by_transcript_expression(
self,
transcript_expression_dict,
min_expression_value=0.0):
"""
Filters variants down to those which have overlap a transcript whose
expression value in the transcript_expression_dict argument is greater
than min_e... | python | {
"resource": ""
} |
q5625 | VariantCollection.filter_by_gene_expression | train | def filter_by_gene_expression(
self,
gene_expression_dict,
min_expression_value=0.0):
"""
Filters variants down to those which have overlap a gene whose
expression value in the transcript_expression_dict argument is greater
than min_expression_value.
... | python | {
"resource": ""
} |
q5626 | VariantCollection.exactly_equal | train | def exactly_equal(self, other):
'''
Comparison between VariantCollection instances that takes into account
the info field of Variant instances.
Returns
----------
True if the variants in this collection equal the variants in the other
collection. The Variant.info... | python | {
"resource": ""
} |
q5627 | VariantCollection._combine_variant_collections | train | def _combine_variant_collections(cls, combine_fn, variant_collections, kwargs):
"""
Create a single VariantCollection from multiple different collections.
Parameters
----------
cls : class
Should be VariantCollection
combine_fn : function
Functi... | python | {
"resource": ""
} |
q5628 | VariantCollection.union | train | def union(self, *others, **kwargs):
"""
Returns the union of variants in a several VariantCollection objects.
"""
return self._combine_variant_collections(
combine_fn=set.union,
variant_collections=(self,) + others,
kwargs=kwargs) | python | {
"resource": ""
} |
q5629 | VariantCollection.intersection | train | def intersection(self, *others, **kwargs):
"""
Returns the intersection of variants in several VariantCollection objects.
"""
return self._combine_variant_collections(
combine_fn=set.intersection,
variant_collections=(self,) + others,
kwargs=kwargs) | python | {
"resource": ""
} |
q5630 | VariantCollection.to_dataframe | train | def to_dataframe(self):
"""Build a DataFrame from this variant collection"""
def row_from_variant(variant):
return OrderedDict([
("chr", variant.contig),
("start", variant.original_start),
("ref", variant.original_ref),
("alt", ... | python | {
"resource": ""
} |
q5631 | trim_shared_suffix | train | def trim_shared_suffix(ref, alt):
"""
Reuse the `trim_shared_prefix` function above to implement similar
functionality for string suffixes.
Given ref='ABC' and alt='BC', we first revese both strings:
reverse_ref = 'CBA'
reverse_alt = 'CB'
and then the result of calling trim_shared_p... | python | {
"resource": ""
} |
q5632 | trim_shared_flanking_strings | train | def trim_shared_flanking_strings(ref, alt):
"""
Given two nucleotide or amino acid strings, identify
if they have a common prefix, a common suffix, and return
their unique components along with the prefix and suffix.
For example, if the input ref = "SYFFQGR" and alt = "SYMLLFIFQGR"
then the res... | python | {
"resource": ""
} |
q5633 | main | train | def main(args_list=None):
"""
Script which loads variants and annotates them with overlapping genes
and predicted coding effects.
Example usage:
varcode
--vcf mutect.vcf \
--vcf strelka.vcf \
--maf tcga_brca.maf \
--variant chr1 498584 C G \
... | python | {
"resource": ""
} |
q5634 | get_codons | train | def get_codons(
variant,
trimmed_cdna_ref,
trimmed_cdna_alt,
sequence_from_start_codon,
cds_offset):
"""
Returns indices of first and last reference codons affected by the variant,
as well as the actual sequence of the mutated codons which replace those
reference ... | python | {
"resource": ""
} |
q5635 | predict_in_frame_coding_effect | train | def predict_in_frame_coding_effect(
variant,
transcript,
trimmed_cdna_ref,
trimmed_cdna_alt,
sequence_from_start_codon,
cds_offset):
"""Coding effect of an in-frame nucleotide change
Parameters
----------
variant : Variant
transcript : Transcript
... | python | {
"resource": ""
} |
q5636 | insert_before | train | def insert_before(sequence, offset, new_residues):
"""Mutate the given sequence by inserting the string `new_residues` before
`offset`.
Parameters
----------
sequence : sequence
String of amino acids or DNA bases
offset : int
Base 0 offset from start of sequence, after which we... | python | {
"resource": ""
} |
q5637 | insert_after | train | def insert_after(sequence, offset, new_residues):
"""Mutate the given sequence by inserting the string `new_residues` after
`offset`.
Parameters
----------
sequence : sequence
String of amino acids or DNA bases
offset : int
Base 0 offset from start of sequence, after which we s... | python | {
"resource": ""
} |
q5638 | substitute | train | def substitute(sequence, offset, ref, alt):
"""Mutate a sequence by substituting given `alt` at instead of `ref` at the
given `position`.
Parameters
----------
sequence : sequence
String of amino acids or DNA bases
offset : int
Base 0 offset from start of `sequence`
ref : ... | python | {
"resource": ""
} |
q5639 | infer_genome | train | def infer_genome(genome_object_string_or_int):
"""
If given an integer, return associated human EnsemblRelease for that
Ensembl version.
If given a string, return latest EnsemblRelease which has a reference
of the same name.
If given a PyEnsembl Genome, simply return it.
"""
if isinsta... | python | {
"resource": ""
} |
q5640 | Variant.genes | train | def genes(self):
"""
Return Gene object for all genes which overlap this variant.
"""
if self._genes is None:
self._genes = self.ensembl.genes_at_locus(
self.contig, self.start, self.end)
return self._genes | python | {
"resource": ""
} |
q5641 | Variant.is_insertion | train | def is_insertion(self):
"""
Does this variant represent the insertion of nucleotides into the
reference genome?
"""
# An insertion would appear in a VCF like C>CT, so that the
# alternate allele starts with the reference nucleotides.
# Since the nucleotide strings... | python | {
"resource": ""
} |
q5642 | Variant.is_deletion | train | def is_deletion(self):
"""
Does this variant represent the deletion of nucleotides from the
reference genome?
"""
# A deletion would appear in a VCF like CT>C, so that the
# reference allele starts with the alternate nucleotides.
# This is true even in the normali... | python | {
"resource": ""
} |
q5643 | Variant.is_snv | train | def is_snv(self):
"""Is the variant a single nucleotide variant"""
return (len(self.ref) == len(self.alt) == 1) and (self.ref != self.alt) | python | {
"resource": ""
} |
q5644 | Variant.is_transition | train | def is_transition(self):
"""Is this variant and pyrimidine to pyrimidine change or purine to purine change"""
return self.is_snv and is_purine(self.ref) == is_purine(self.alt) | python | {
"resource": ""
} |
q5645 | Variant.is_transversion | train | def is_transversion(self):
"""Is this variant a pyrimidine to purine change or vice versa"""
return self.is_snv and is_purine(self.ref) != is_purine(self.alt) | python | {
"resource": ""
} |
q5646 | variant_overlaps_interval | train | def variant_overlaps_interval(
variant_start,
n_ref_bases,
interval_start,
interval_end):
"""
Does a variant overlap a given interval on the same chromosome?
Parameters
----------
variant_start : int
Inclusive base-1 position of variant's starting location
... | python | {
"resource": ""
} |
q5647 | changes_exonic_splice_site | train | def changes_exonic_splice_site(
transcript_offset,
transcript,
transcript_ref,
transcript_alt,
exon_start_offset,
exon_end_offset,
exon_number):
"""Does the given exonic mutation of a particular transcript change a
splice site?
Parameters
--------... | python | {
"resource": ""
} |
q5648 | is_purine | train | def is_purine(nucleotide, allow_extended_nucleotides=False):
"""Is the nucleotide a purine"""
if not allow_extended_nucleotides and nucleotide not in STANDARD_NUCLEOTIDES:
raise ValueError(
"{} is a non-standard nucleotide, neither purine or pyrimidine".format(nucleotide))
return nucleot... | python | {
"resource": ""
} |
q5649 | normalize_nucleotide_string | train | def normalize_nucleotide_string(
nucleotides,
allow_extended_nucleotides=False,
empty_chars=".-",
treat_nan_as_empty=True):
"""
Normalizes a nucleotide string by converting various ways of encoding empty
strings into "", making all letters upper case, and checking to make sur... | python | {
"resource": ""
} |
q5650 | load_vcf | train | def load_vcf(
path,
genome=None,
reference_vcf_key="reference",
only_passing=True,
allow_extended_nucleotides=False,
include_info=True,
chunk_size=10 ** 5,
max_variants=None,
sort_key=variant_ascending_position_sort_key,
distinct=True):
... | python | {
"resource": ""
} |
q5651 | dataframes_to_variant_collection | train | def dataframes_to_variant_collection(
dataframes,
source_path,
info_parser=None,
only_passing=True,
max_variants=None,
sample_names=None,
sample_info_parser=None,
variant_kwargs={},
variant_collection_kwargs={}):
"""
Load a VariantCollectio... | python | {
"resource": ""
} |
q5652 | read_vcf_into_dataframe | train | def read_vcf_into_dataframe(
path,
include_info=False,
sample_names=None,
chunk_size=None):
"""
Load the data of a VCF into a pandas dataframe. All headers are ignored.
Parameters
----------
path : str
Path to local file. HTTP and other protocols are not impl... | python | {
"resource": ""
} |
q5653 | stream_gzip_decompress_lines | train | def stream_gzip_decompress_lines(stream):
"""
Uncompress a gzip stream into lines of text.
Parameters
----------
Generator of chunks of gzip compressed text.
Returns
-------
Generator of uncompressed lines.
"""
dec = zlib.decompressobj(zlib.MAX_WBITS | 16)
previous = ""
... | python | {
"resource": ""
} |
q5654 | infer_genome_from_vcf | train | def infer_genome_from_vcf(genome, vcf_reader, reference_vcf_key):
"""
Helper function to make a pyensembl.Genome instance.
"""
if genome:
return infer_genome(genome)
elif reference_vcf_key not in vcf_reader.metadata:
raise ValueError("Unable to infer reference genome for %s" % (
... | python | {
"resource": ""
} |
q5655 | cdna_codon_sequence_after_insertion_frameshift | train | def cdna_codon_sequence_after_insertion_frameshift(
sequence_from_start_codon,
cds_offset_before_insertion,
inserted_nucleotides):
"""
Returns index of mutated codon and nucleotide sequence starting at the first
mutated codon.
"""
# special logic for insertions
coding_seq... | python | {
"resource": ""
} |
q5656 | cdna_codon_sequence_after_deletion_or_substitution_frameshift | train | def cdna_codon_sequence_after_deletion_or_substitution_frameshift(
sequence_from_start_codon,
cds_offset,
trimmed_cdna_ref,
trimmed_cdna_alt):
"""
Logic for any frameshift which isn't an insertion.
We have insertions as a special case since our base-inclusive
indexing me... | python | {
"resource": ""
} |
q5657 | predict_frameshift_coding_effect | train | def predict_frameshift_coding_effect(
variant,
transcript,
trimmed_cdna_ref,
trimmed_cdna_alt,
cds_offset,
sequence_from_start_codon):
"""
Coding effect of a frameshift mutation.
Parameters
----------
variant : Variant
transcript : Transcript
... | python | {
"resource": ""
} |
q5658 | predict_variant_effects | train | def predict_variant_effects(variant, raise_on_error=False):
"""Determine the effects of a variant on any transcripts it overlaps.
Returns an EffectCollection object.
Parameters
----------
variant : Variant
raise_on_error : bool
Raise an exception if we encounter an error while trying t... | python | {
"resource": ""
} |
q5659 | predict_variant_effect_on_transcript_or_failure | train | def predict_variant_effect_on_transcript_or_failure(variant, transcript):
"""
Try predicting the effect of a variant on a particular transcript but
suppress raised exceptions by converting them into `Failure` effect
values.
"""
try:
return predict_variant_effect_on_transcript(
... | python | {
"resource": ""
} |
q5660 | choose_intronic_effect_class | train | def choose_intronic_effect_class(
variant,
nearest_exon,
distance_to_exon):
"""
Infer effect of variant which does not overlap any exon of
the given transcript.
"""
assert distance_to_exon > 0, \
"Expected intronic effect to have distance_to_exon > 0, got %d" % (
... | python | {
"resource": ""
} |
q5661 | exonic_transcript_effect | train | def exonic_transcript_effect(variant, exon, exon_number, transcript):
"""Effect of this variant on a Transcript, assuming we already know
that this variant overlaps some exon of the transcript.
Parameters
----------
variant : Variant
exon : pyensembl.Exon
Exon which this variant overla... | python | {
"resource": ""
} |
q5662 | apply_groupby | train | def apply_groupby(records, fn, skip_none=False):
"""
Given a list of objects, group them into a dictionary by
applying fn to each one and using returned values as a dictionary
key.
Parameters
----------
records : list
fn : function
skip_none : bool
If False, then None can ... | python | {
"resource": ""
} |
q5663 | groupby_field | train | def groupby_field(records, field_name, skip_none=True):
"""
Given a list of objects, group them into a dictionary by
the unique values of a given field name.
"""
return apply_groupby(
records,
lambda obj: getattr(obj, field_name),
skip_none=skip_none) | python | {
"resource": ""
} |
q5664 | memoize | train | def memoize(fn):
"""
Simple memoization decorator for functions and methods,
assumes that all arguments to the function can be hashed and
compared.
"""
memoized_values = {}
@wraps(fn)
def wrapped_fn(*args, **kwargs):
key = (args, tuple(sorted(kwargs.items())))
try:
... | python | {
"resource": ""
} |
q5665 | EffectCollection.filter_by_transcript_expression | train | def filter_by_transcript_expression(
self,
transcript_expression_dict,
min_expression_value=0.0):
"""
Filters effects to those which have an associated transcript whose
expression value in the transcript_expression_dict argument is greater
than min_exp... | python | {
"resource": ""
} |
q5666 | EffectCollection.filter_by_gene_expression | train | def filter_by_gene_expression(
self,
gene_expression_dict,
min_expression_value=0.0):
"""
Filters effects to those which have an associated gene whose
expression value in the gene_expression_dict argument is greater
than min_expression_value.
... | python | {
"resource": ""
} |
q5667 | EffectCollection.filter_by_effect_priority | train | def filter_by_effect_priority(self, min_priority_class):
"""
Create a new EffectCollection containing only effects whose priority
falls below the given class.
"""
min_priority = transcript_effect_priority_dict[min_priority_class]
return self.filter(
lambda eff... | python | {
"resource": ""
} |
q5668 | EffectCollection.top_priority_effect_per_variant | train | def top_priority_effect_per_variant(self):
"""Highest priority effect for each unique variant"""
return OrderedDict(
(variant, top_priority_effect(variant_effects))
for (variant, variant_effects)
in self.groupby_variant().items()) | python | {
"resource": ""
} |
q5669 | EffectCollection.top_priority_effect_per_transcript_id | train | def top_priority_effect_per_transcript_id(self):
"""Highest priority effect for each unique transcript ID"""
return OrderedDict(
(transcript_id, top_priority_effect(variant_effects))
for (transcript_id, variant_effects)
in self.groupby_transcript_id().items()) | python | {
"resource": ""
} |
q5670 | EffectCollection.top_priority_effect_per_gene_id | train | def top_priority_effect_per_gene_id(self):
"""Highest priority effect for each unique gene ID"""
return OrderedDict(
(gene_id, top_priority_effect(variant_effects))
for (gene_id, variant_effects)
in self.groupby_gene_id().items()) | python | {
"resource": ""
} |
q5671 | EffectCollection.top_expression_effect | train | def top_expression_effect(self, expression_levels):
"""
Return effect whose transcript has the highest expression level.
If none of the effects are expressed or have associated transcripts,
then return None. In case of ties, add lexicographical sorting by
effect priority and tran... | python | {
"resource": ""
} |
q5672 | EffectCollection.to_dataframe | train | def to_dataframe(self):
"""Build a dataframe from the effect collection"""
# list of properties to extract from Variant objects if they're
# not None
variant_properties = [
"contig",
"start",
"ref",
"alt",
"is_snv",
... | python | {
"resource": ""
} |
q5673 | random_variants | train | def random_variants(
count,
genome_name="GRCh38",
deletions=True,
insertions=True,
random_seed=None):
"""
Generate a VariantCollection with random variants that overlap
at least one complete coding transcript.
"""
rng = random.Random(random_seed)
ensembl =... | python | {
"resource": ""
} |
q5674 | MSLDAP.get_server_info | train | def get_server_info(self, anonymous = True):
"""
Performs bind on the server and grabs the DSA info object.
If anonymous is set to true, then it will perform anonymous bind, not using user credentials
Otherwise it will use the credentials set in the object constructor.
"""
if anonymous == True:
logger.de... | python | {
"resource": ""
} |
q5675 | MSLDAP.get_all_user_objects | train | def get_all_user_objects(self):
"""
Fetches all user objects from the AD, and returns MSADUser object
"""
logger.debug('Polling AD for all user objects')
ldap_filter = r'(objectClass=user)'
attributes = MSADUser.ATTRS
for entry in self.pagedsearch(ldap_filter, attributes):
# TODO: return ldapuser obje... | python | {
"resource": ""
} |
q5676 | MSLDAP.get_all_knoreq_user_objects | train | def get_all_knoreq_user_objects(self, include_machine = False):
"""
Fetches all user objects with useraccountcontrol DONT_REQ_PREAUTH flag set from the AD, and returns MSADUser object.
"""
logger.debug('Polling AD for all user objects, machine accounts included: %s'% include_machine)
if include_machine == ... | python | {
"resource": ""
} |
q5677 | vn | train | def vn(x):
"""
value or none, returns none if x is an empty list
"""
if x == []:
return None
if isinstance(x, list):
return '|'.join(x)
if isinstance(x, datetime):
return x.isoformat()
return x | python | {
"resource": ""
} |
q5678 | BotoSqliteEngine.load_tables | train | def load_tables(self, query, meta):
"""
Load necessary resources tables into db to execute given query.
"""
try:
for table in meta.tables:
self.load_table(table)
except NoCredentialsError:
help_link = 'http://boto3.readthedocs.io/en/latest/... | python | {
"resource": ""
} |
q5679 | BotoSqliteEngine.load_table | train | def load_table(self, table):
"""
Load resources as specified by given table into our db.
"""
region = table.database if table.database else self.default_region
resource_name, collection_name = table.table.split('_', 1)
# we use underscore "_" instead of dash "-" for regio... | python | {
"resource": ""
} |
q5680 | json_serialize | train | def json_serialize(obj):
"""
Simple generic JSON serializer for common objects.
"""
if isinstance(obj, datetime):
return obj.isoformat()
if hasattr(obj, 'id'):
return jsonify(obj.id)
if hasattr(obj, 'name'):
return jsonify(obj.name)
raise TypeError('{0} is not JSON... | python | {
"resource": ""
} |
q5681 | json_get | train | def json_get(serialized_object, field):
"""
This emulates the HSTORE `->` get value operation.
It get value from JSON serialized column by given key and return `null` if not present.
Key can be either an integer for array index access or a string for object field access.
:return: JSON serialized va... | python | {
"resource": ""
} |
q5682 | create_table | train | def create_table(db, schema_name, table_name, columns):
"""
Create a table, schema_name.table_name, in given database with given list of column names.
"""
table = '{0}.{1}'.format(schema_name, table_name) if schema_name else table_name
db.execute('DROP TABLE IF EXISTS {0}'.format(table))
columns... | python | {
"resource": ""
} |
q5683 | insert_all | train | def insert_all(db, schema_name, table_name, columns, items):
"""
Insert all item in given items list into the specified table, schema_name.table_name.
"""
table = '{0}.{1}'.format(schema_name, table_name) if schema_name else table_name
columns_list = ', '.join(columns)
values_list = ', '.join(['... | python | {
"resource": ""
} |
q5684 | Creator.get_events | train | def get_events(self, *args, **kwargs):
"""
Returns a full EventDataWrapper object for this creator.
/creators/{creatorId}/events
:returns: EventDataWrapper -- A new request to API. Contains full results set.
"""
from .event import Event, EventDataWrapper
return... | python | {
"resource": ""
} |
q5685 | Creator.get_series | train | def get_series(self, *args, **kwargs):
"""
Returns a full SeriesDataWrapper object for this creator.
/creators/{creatorId}/series
:returns: SeriesDataWrapper -- A new request to API. Contains full results set.
"""
from .series import Series, SeriesDataWrapper
r... | python | {
"resource": ""
} |
q5686 | Creator.get_stories | train | def get_stories(self, *args, **kwargs):
"""
Returns a full StoryDataWrapper object for this creator.
/creators/{creatorId}/stories
:returns: StoriesDataWrapper -- A new request to API. Contains full results set.
"""
from .story import Story, StoryDataWrapper
re... | python | {
"resource": ""
} |
q5687 | MarvelObject.list_to_instance_list | train | def list_to_instance_list(_self, _list, _Class):
"""
Takes a list of resource dicts and returns a list
of resource instances, defined by the _Class param.
:param _self: Original resource calling the method
:type _self: core.MarvelObject
:param _list: List of dicts descri... | python | {
"resource": ""
} |
q5688 | Marvel._call | train | def _call(self, resource_url, params=None):
"""
Calls the Marvel API endpoint
:param resource_url: url slug of the resource
:type resource_url: str
:param params: query params to add to endpoint
:type params: str
:returns: response -- Requests response
... | python | {
"resource": ""
} |
q5689 | Marvel.get_character | train | def get_character(self, id):
"""Fetches a single character by id.
get /v1/public/characters
:param id: ID of Character
:type params: int
:returns: CharacterDataWrapper
>>> m = Marvel(public_key, private_key)
>>> cdw = m.get_character(1009718)
... | python | {
"resource": ""
} |
q5690 | Marvel.get_characters | train | def get_characters(self, *args, **kwargs):
"""Fetches lists of comic characters with optional filters.
get /v1/public/characters/{characterId}
:returns: CharacterDataWrapper
>>> m = Marvel(public_key, private_key)
>>> cdw = m.get_characters(orderBy="name,-modified", limit="5"... | python | {
"resource": ""
} |
q5691 | Marvel.get_comics | train | def get_comics(self, *args, **kwargs):
"""
Fetches list of comics.
get /v1/public/comics
:returns: ComicDataWrapper
>>> m = Marvel(public_key, private_key)
>>> cdw = m.get_comics(orderBy="issueNumber,-modified", limit="10", offset="15")
... | python | {
"resource": ""
} |
q5692 | Marvel.get_creator | train | def get_creator(self, id):
"""Fetches a single creator by id.
get /v1/public/creators/{creatorId}
:param id: ID of Creator
:type params: int
:returns: CreatorDataWrapper
>>> m = Marvel(public_key, private_key)
>>> cdw = m.get_creator(30)
>>> p... | python | {
"resource": ""
} |
q5693 | Marvel.get_event | train | def get_event(self, id):
"""Fetches a single event by id.
get /v1/public/event/{eventId}
:param id: ID of Event
:type params: int
:returns: EventDataWrapper
>>> m = Marvel(public_key, private_key)
>>> response = m.get_event(253)
>>> print resp... | python | {
"resource": ""
} |
q5694 | Marvel.get_single_series | train | def get_single_series(self, id):
"""Fetches a single comic series by id.
get /v1/public/series/{seriesId}
:param id: ID of Series
:type params: int
:returns: SeriesDataWrapper
>>> m = Marvel(public_key, private_key)
>>> response = m.get_single... | python | {
"resource": ""
} |
q5695 | Marvel.get_story | train | def get_story(self, id):
"""Fetches a single story by id.
get /v1/public/stories/{storyId}
:param id: ID of Story
:type params: int
:returns: StoryDataWrapper
>>> m = Marvel(public_key, private_key)
>>> response = m.get_story(29)
>>> p... | python | {
"resource": ""
} |
q5696 | Marvel.get_stories | train | def get_stories(self, *args, **kwargs):
"""Fetches lists of stories.
get /v1/public/stories
:returns: StoryDataWrapper
>>> #Find all the stories that involved both Hulk and Wolverine
>>> #hulk's id: 1009351
>>> #wolverine's id: 1009718
>>> m = ... | python | {
"resource": ""
} |
q5697 | Story.get_creators | train | def get_creators(self, *args, **kwargs):
"""
Returns a full CreatorDataWrapper object for this story.
/stories/{storyId}/creators
:returns: CreatorDataWrapper -- A new request to API. Contains full results set.
"""
from .creator import Creator, CreatorDataWrapper
... | python | {
"resource": ""
} |
q5698 | Story.get_characters | train | def get_characters(self, *args, **kwargs):
"""
Returns a full CharacterDataWrapper object for this story.
/stories/{storyId}/characters
:returns: CharacterDataWrapper -- A new request to API. Contains full results set.
"""
from .character import Character, CharacterDat... | python | {
"resource": ""
} |
q5699 | ffmpeg_version | train | def ffmpeg_version():
"""Returns the available ffmpeg version
Returns
----------
version : str
version number as string
"""
cmd = [
'ffmpeg',
'-version'
]
output = sp.check_output(cmd)
aac_codecs = [
x for x in
output.splitlines() if "ffmpeg... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.