id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
243,700 | fakedrake/overlay_parse | overlay_parse/util.py | rx_int_extra | def rx_int_extra(rxmatch):
"""
We didn't just match an int but the int is what we need.
"""
rxmatch = re.search("\d+", rxmatch.group(0))
return int(rxmatch.group(0)) | python | def rx_int_extra(rxmatch):
"""
We didn't just match an int but the int is what we need.
"""
rxmatch = re.search("\d+", rxmatch.group(0))
return int(rxmatch.group(0)) | [
"def",
"rx_int_extra",
"(",
"rxmatch",
")",
":",
"rxmatch",
"=",
"re",
".",
"search",
"(",
"\"\\d+\"",
",",
"rxmatch",
".",
"group",
"(",
"0",
")",
")",
"return",
"int",
"(",
"rxmatch",
".",
"group",
"(",
"0",
")",
")"
] | We didn't just match an int but the int is what we need. | [
"We",
"didn",
"t",
"just",
"match",
"an",
"int",
"but",
"the",
"int",
"is",
"what",
"we",
"need",
"."
] | 9ac362d6aef1ea41aff7375af088c6ebef93d0cd | https://github.com/fakedrake/overlay_parse/blob/9ac362d6aef1ea41aff7375af088c6ebef93d0cd/overlay_parse/util.py#L42-L48 |
243,701 | lambdalisue/django-roughpages | src/roughpages/backends/decorators.py | prepare_filename_decorator | def prepare_filename_decorator(fn):
"""
A decorator of `prepare_filename` method
1. It automatically assign `settings.ROUGHPAGES_INDEX_FILENAME` if the
`normalized_url` is ''.
2. It automatically assign file extensions to the output list.
"""
@wraps(fn)
def inner(self, normalized_url... | python | def prepare_filename_decorator(fn):
"""
A decorator of `prepare_filename` method
1. It automatically assign `settings.ROUGHPAGES_INDEX_FILENAME` if the
`normalized_url` is ''.
2. It automatically assign file extensions to the output list.
"""
@wraps(fn)
def inner(self, normalized_url... | [
"def",
"prepare_filename_decorator",
"(",
"fn",
")",
":",
"@",
"wraps",
"(",
"fn",
")",
"def",
"inner",
"(",
"self",
",",
"normalized_url",
",",
"request",
")",
":",
"ext",
"=",
"settings",
".",
"ROUGHPAGES_TEMPLATE_FILE_EXT",
"if",
"not",
"normalized_url",
... | A decorator of `prepare_filename` method
1. It automatically assign `settings.ROUGHPAGES_INDEX_FILENAME` if the
`normalized_url` is ''.
2. It automatically assign file extensions to the output list. | [
"A",
"decorator",
"of",
"prepare_filename",
"method"
] | f6a2724ece729c5deced2c2546d172561ef785ec | https://github.com/lambdalisue/django-roughpages/blob/f6a2724ece729c5deced2c2546d172561ef785ec/src/roughpages/backends/decorators.py#L9-L25 |
243,702 | praekelt/panya | panya/templatetags/panya_template_tags.py | smart_query_string | def smart_query_string(parser, token):
"""
Outputs current GET query string with additions appended.
Additions are provided in token pairs.
"""
args = token.split_contents()
additions = args[1:]
addition_pairs = []
while additions:
addition_pairs.append(additions[0:2])
... | python | def smart_query_string(parser, token):
"""
Outputs current GET query string with additions appended.
Additions are provided in token pairs.
"""
args = token.split_contents()
additions = args[1:]
addition_pairs = []
while additions:
addition_pairs.append(additions[0:2])
... | [
"def",
"smart_query_string",
"(",
"parser",
",",
"token",
")",
":",
"args",
"=",
"token",
".",
"split_contents",
"(",
")",
"additions",
"=",
"args",
"[",
"1",
":",
"]",
"addition_pairs",
"=",
"[",
"]",
"while",
"additions",
":",
"addition_pairs",
".",
"a... | Outputs current GET query string with additions appended.
Additions are provided in token pairs. | [
"Outputs",
"current",
"GET",
"query",
"string",
"with",
"additions",
"appended",
".",
"Additions",
"are",
"provided",
"in",
"token",
"pairs",
"."
] | 0fd621e15a7c11a2716a9554a2f820d6259818e5 | https://github.com/praekelt/panya/blob/0fd621e15a7c11a2716a9554a2f820d6259818e5/panya/templatetags/panya_template_tags.py#L12-L25 |
243,703 | Zaeb0s/max-threads | maxthreads/maxthreads.py | MaxThreads.start_thread | def start_thread(self, target, args=(), kwargs=None, priority=0):
""" To make sure applications work with the old name
"""
return self.add_task(target, args, kwargs, priority) | python | def start_thread(self, target, args=(), kwargs=None, priority=0):
""" To make sure applications work with the old name
"""
return self.add_task(target, args, kwargs, priority) | [
"def",
"start_thread",
"(",
"self",
",",
"target",
",",
"args",
"=",
"(",
")",
",",
"kwargs",
"=",
"None",
",",
"priority",
"=",
"0",
")",
":",
"return",
"self",
".",
"add_task",
"(",
"target",
",",
"args",
",",
"kwargs",
",",
"priority",
")"
] | To make sure applications work with the old name | [
"To",
"make",
"sure",
"applications",
"work",
"with",
"the",
"old",
"name"
] | dce4ae784aa1c07fdb910359c0099907047403f9 | https://github.com/Zaeb0s/max-threads/blob/dce4ae784aa1c07fdb910359c0099907047403f9/maxthreads/maxthreads.py#L143-L146 |
243,704 | dossier/dossier.models | dossier/models/query.py | list_projects | def list_projects(folders, folder = None, user = None):
'''List all folders or all subfolders of a folder.
If folder is provided, this method will output a list of subfolders
contained by it. Otherwise, a list of all top-level folders is produced.
:param folders: reference to folder.Folders instance
... | python | def list_projects(folders, folder = None, user = None):
'''List all folders or all subfolders of a folder.
If folder is provided, this method will output a list of subfolders
contained by it. Otherwise, a list of all top-level folders is produced.
:param folders: reference to folder.Folders instance
... | [
"def",
"list_projects",
"(",
"folders",
",",
"folder",
"=",
"None",
",",
"user",
"=",
"None",
")",
":",
"fid",
"=",
"None",
"if",
"folder",
"is",
"None",
"else",
"Folders",
".",
"name_to_id",
"(",
"folder",
")",
"# List all folders if none provided.",
"if",
... | List all folders or all subfolders of a folder.
If folder is provided, this method will output a list of subfolders
contained by it. Otherwise, a list of all top-level folders is produced.
:param folders: reference to folder.Folders instance
:param folder: folder name or None
:param user: optiona... | [
"List",
"all",
"folders",
"or",
"all",
"subfolders",
"of",
"a",
"folder",
"."
] | c9e282f690eab72963926329efe1600709e48b13 | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/query.py#L39-L64 |
243,705 | slarse/clanimtk | clanimtk/util.py | get_supervisor | def get_supervisor(func: types.AnyFunction) -> types.Supervisor:
"""Get the appropriate supervisor to use and pre-apply the function.
Args:
func: A function.
"""
if not callable(func):
raise TypeError("func is not callable")
if asyncio.iscoroutinefunction(func):
supervisor =... | python | def get_supervisor(func: types.AnyFunction) -> types.Supervisor:
"""Get the appropriate supervisor to use and pre-apply the function.
Args:
func: A function.
"""
if not callable(func):
raise TypeError("func is not callable")
if asyncio.iscoroutinefunction(func):
supervisor =... | [
"def",
"get_supervisor",
"(",
"func",
":",
"types",
".",
"AnyFunction",
")",
"->",
"types",
".",
"Supervisor",
":",
"if",
"not",
"callable",
"(",
"func",
")",
":",
"raise",
"TypeError",
"(",
"\"func is not callable\"",
")",
"if",
"asyncio",
".",
"iscoroutine... | Get the appropriate supervisor to use and pre-apply the function.
Args:
func: A function. | [
"Get",
"the",
"appropriate",
"supervisor",
"to",
"use",
"and",
"pre",
"-",
"apply",
"the",
"function",
"."
] | cb93d2e914c3ecc4e0007745ff4d546318cf3902 | https://github.com/slarse/clanimtk/blob/cb93d2e914c3ecc4e0007745ff4d546318cf3902/clanimtk/util.py#L23-L35 |
243,706 | slarse/clanimtk | clanimtk/util.py | _async_supervisor | async def _async_supervisor(func, animation_, step, *args, **kwargs):
"""Supervisor for running an animation with an asynchronous function.
Args:
func: A function to be run alongside an animation.
animation_: An infinite generator that produces
strings for the animation.
step: S... | python | async def _async_supervisor(func, animation_, step, *args, **kwargs):
"""Supervisor for running an animation with an asynchronous function.
Args:
func: A function to be run alongside an animation.
animation_: An infinite generator that produces
strings for the animation.
step: S... | [
"async",
"def",
"_async_supervisor",
"(",
"func",
",",
"animation_",
",",
"step",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"with",
"ThreadPoolExecutor",
"(",
"max_workers",
"=",
"2",
")",
"as",
"pool",
":",
"with",
"_terminating_event",
"(",
... | Supervisor for running an animation with an asynchronous function.
Args:
func: A function to be run alongside an animation.
animation_: An infinite generator that produces
strings for the animation.
step: Seconds between each animation frame.
*args: Arguments for func.
... | [
"Supervisor",
"for",
"running",
"an",
"animation",
"with",
"an",
"asynchronous",
"function",
"."
] | cb93d2e914c3ecc4e0007745ff4d546318cf3902 | https://github.com/slarse/clanimtk/blob/cb93d2e914c3ecc4e0007745ff4d546318cf3902/clanimtk/util.py#L52-L71 |
243,707 | slarse/clanimtk | clanimtk/util.py | concatechain | def concatechain(*generators: types.FrameGenerator, separator: str = ''):
"""Return a generator that in each iteration takes one value from each of the
supplied generators, joins them together with the specified separator and
yields the result. Stops as soon as any iterator raises StopIteration and
retu... | python | def concatechain(*generators: types.FrameGenerator, separator: str = ''):
"""Return a generator that in each iteration takes one value from each of the
supplied generators, joins them together with the specified separator and
yields the result. Stops as soon as any iterator raises StopIteration and
retu... | [
"def",
"concatechain",
"(",
"*",
"generators",
":",
"types",
".",
"FrameGenerator",
",",
"separator",
":",
"str",
"=",
"''",
")",
":",
"while",
"True",
":",
"try",
":",
"next_",
"=",
"[",
"next",
"(",
"gen",
")",
"for",
"gen",
"in",
"generators",
"]"... | Return a generator that in each iteration takes one value from each of the
supplied generators, joins them together with the specified separator and
yields the result. Stops as soon as any iterator raises StopIteration and
returns the value contained in it.
Primarily created for chaining string generat... | [
"Return",
"a",
"generator",
"that",
"in",
"each",
"iteration",
"takes",
"one",
"value",
"from",
"each",
"of",
"the",
"supplied",
"generators",
"joins",
"them",
"together",
"with",
"the",
"specified",
"separator",
"and",
"yields",
"the",
"result",
".",
"Stops",... | cb93d2e914c3ecc4e0007745ff4d546318cf3902 | https://github.com/slarse/clanimtk/blob/cb93d2e914c3ecc4e0007745ff4d546318cf3902/clanimtk/util.py#L94-L116 |
243,708 | staticshock/scientist.py | scientist/experiment.py | Experiment.compare | def compare(self, control_result, experimental_result):
_compare = getattr(self, '_compare', lambda x, y: x == y)
"""
Return true if the results match.
"""
return (
# Mismatch if only one of the results returned an error, or if
# different types of errors ... | python | def compare(self, control_result, experimental_result):
_compare = getattr(self, '_compare', lambda x, y: x == y)
"""
Return true if the results match.
"""
return (
# Mismatch if only one of the results returned an error, or if
# different types of errors ... | [
"def",
"compare",
"(",
"self",
",",
"control_result",
",",
"experimental_result",
")",
":",
"_compare",
"=",
"getattr",
"(",
"self",
",",
"'_compare'",
",",
"lambda",
"x",
",",
"y",
":",
"x",
"==",
"y",
")",
"return",
"(",
"# Mismatch if only one of the resu... | Return true if the results match. | [
"Return",
"true",
"if",
"the",
"results",
"match",
"."
] | 68ec0b57989d1f78614aa3b17ce196e2b53cfe25 | https://github.com/staticshock/scientist.py/blob/68ec0b57989d1f78614aa3b17ce196e2b53cfe25/scientist/experiment.py#L104-L114 |
243,709 | bwesterb/tkbd | src/ruuster.py | Ruuster.fetch_inst_id | def fetch_inst_id(self):
""" Fetches the institute id of the RU """
try:
for d in msgpack.unpack(urllib2.urlopen(
"%s/list/institutes?format=msgpack" % self.url)):
if d['name'] == 'Radboud Universiteit Nijmegen':
return d['id']
... | python | def fetch_inst_id(self):
""" Fetches the institute id of the RU """
try:
for d in msgpack.unpack(urllib2.urlopen(
"%s/list/institutes?format=msgpack" % self.url)):
if d['name'] == 'Radboud Universiteit Nijmegen':
return d['id']
... | [
"def",
"fetch_inst_id",
"(",
"self",
")",
":",
"try",
":",
"for",
"d",
"in",
"msgpack",
".",
"unpack",
"(",
"urllib2",
".",
"urlopen",
"(",
"\"%s/list/institutes?format=msgpack\"",
"%",
"self",
".",
"url",
")",
")",
":",
"if",
"d",
"[",
"'name'",
"]",
... | Fetches the institute id of the RU | [
"Fetches",
"the",
"institute",
"id",
"of",
"the",
"RU"
] | fcf16977d38a93fe9b7fa198513007ab9921b650 | https://github.com/bwesterb/tkbd/blob/fcf16977d38a93fe9b7fa198513007ab9921b650/src/ruuster.py#L31-L40 |
243,710 | collectiveacuity/labPack | labpack/records/ip.py | get_ip | def get_ip(source='aws'):
''' a method to get current public ip address of machine '''
if source == 'aws':
source_url = 'http://checkip.amazonaws.com/'
else:
raise Exception('get_ip currently only supports queries to aws')
import requests
try:
response = reques... | python | def get_ip(source='aws'):
''' a method to get current public ip address of machine '''
if source == 'aws':
source_url = 'http://checkip.amazonaws.com/'
else:
raise Exception('get_ip currently only supports queries to aws')
import requests
try:
response = reques... | [
"def",
"get_ip",
"(",
"source",
"=",
"'aws'",
")",
":",
"if",
"source",
"==",
"'aws'",
":",
"source_url",
"=",
"'http://checkip.amazonaws.com/'",
"else",
":",
"raise",
"Exception",
"(",
"'get_ip currently only supports queries to aws'",
")",
"import",
"requests",
"t... | a method to get current public ip address of machine | [
"a",
"method",
"to",
"get",
"current",
"public",
"ip",
"address",
"of",
"machine"
] | 52949ece35e72e3cc308f54d9ffa6bfbd96805b8 | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/records/ip.py#L5-L26 |
243,711 | rikrd/inspire | inspirespeech/htk.py | create_parameter | def create_parameter(samples, sample_period):
"""Create a HTK Parameter object from an array of samples and a samples period
:param samples (list of lists or array of floats): The samples to write into the file. Usually feature vectors.
:param sample_period (int): Sample period in 100ns units.
"""
... | python | def create_parameter(samples, sample_period):
"""Create a HTK Parameter object from an array of samples and a samples period
:param samples (list of lists or array of floats): The samples to write into the file. Usually feature vectors.
:param sample_period (int): Sample period in 100ns units.
"""
... | [
"def",
"create_parameter",
"(",
"samples",
",",
"sample_period",
")",
":",
"parm_kind_str",
"=",
"'USER'",
"parm_kind",
"=",
"_htk_str_to_param",
"(",
"parm_kind_str",
")",
"parm_kind_base",
",",
"parm_kind_opts",
"=",
"_htk_str_to_param",
"(",
"parm_kind_str",
")",
... | Create a HTK Parameter object from an array of samples and a samples period
:param samples (list of lists or array of floats): The samples to write into the file. Usually feature vectors.
:param sample_period (int): Sample period in 100ns units. | [
"Create",
"a",
"HTK",
"Parameter",
"object",
"from",
"an",
"array",
"of",
"samples",
"and",
"a",
"samples",
"period"
] | e281c0266a9a9633f34ab70f9c3ad58036c19b59 | https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/htk.py#L201-L220 |
243,712 | rikrd/inspire | inspirespeech/htk.py | load_mlf | def load_mlf(filename, utf8_normalization=None):
"""Load an HTK Master Label File.
:param filename: The filename of the MLF file.
:param utf8_normalization: None
"""
with codecs.open(filename, 'r', 'string_escape') as f:
data = f.read().decode('utf8')
if utf8_normalization:
... | python | def load_mlf(filename, utf8_normalization=None):
"""Load an HTK Master Label File.
:param filename: The filename of the MLF file.
:param utf8_normalization: None
"""
with codecs.open(filename, 'r', 'string_escape') as f:
data = f.read().decode('utf8')
if utf8_normalization:
... | [
"def",
"load_mlf",
"(",
"filename",
",",
"utf8_normalization",
"=",
"None",
")",
":",
"with",
"codecs",
".",
"open",
"(",
"filename",
",",
"'r'",
",",
"'string_escape'",
")",
"as",
"f",
":",
"data",
"=",
"f",
".",
"read",
"(",
")",
".",
"decode",
"("... | Load an HTK Master Label File.
:param filename: The filename of the MLF file.
:param utf8_normalization: None | [
"Load",
"an",
"HTK",
"Master",
"Label",
"File",
"."
] | e281c0266a9a9633f34ab70f9c3ad58036c19b59 | https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/htk.py#L223-L242 |
243,713 | rikrd/inspire | inspirespeech/htk.py | save_mlf | def save_mlf(mlf, output_filename):
"""Save an HTK Master Label File.
:param mlf: MLF dictionary containing a mapping from file to list of annotations.
:param output_filename: The file where to save the MLF
"""
with codecs.open(output_filename, 'w', 'utf-8') as f:
f.write(u'#!MLF!#\n')
... | python | def save_mlf(mlf, output_filename):
"""Save an HTK Master Label File.
:param mlf: MLF dictionary containing a mapping from file to list of annotations.
:param output_filename: The file where to save the MLF
"""
with codecs.open(output_filename, 'w', 'utf-8') as f:
f.write(u'#!MLF!#\n')
... | [
"def",
"save_mlf",
"(",
"mlf",
",",
"output_filename",
")",
":",
"with",
"codecs",
".",
"open",
"(",
"output_filename",
",",
"'w'",
",",
"'utf-8'",
")",
"as",
"f",
":",
"f",
".",
"write",
"(",
"u'#!MLF!#\\n'",
")",
"for",
"k",
",",
"v",
"in",
"mlf",
... | Save an HTK Master Label File.
:param mlf: MLF dictionary containing a mapping from file to list of annotations.
:param output_filename: The file where to save the MLF | [
"Save",
"an",
"HTK",
"Master",
"Label",
"File",
"."
] | e281c0266a9a9633f34ab70f9c3ad58036c19b59 | https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/htk.py#L245-L265 |
243,714 | rikrd/inspire | inspirespeech/htk.py | main | def main():
"""Test code called from commandline"""
model = load_model('../data/hmmdefs')
hmm = model.hmms['r-We']
for state_name in hmm.state_names:
print(state_name)
state = model.states[state_name]
print(state.means_)
print(model)
model2 = load_model('../data/prior.hmm... | python | def main():
"""Test code called from commandline"""
model = load_model('../data/hmmdefs')
hmm = model.hmms['r-We']
for state_name in hmm.state_names:
print(state_name)
state = model.states[state_name]
print(state.means_)
print(model)
model2 = load_model('../data/prior.hmm... | [
"def",
"main",
"(",
")",
":",
"model",
"=",
"load_model",
"(",
"'../data/hmmdefs'",
")",
"hmm",
"=",
"model",
".",
"hmms",
"[",
"'r-We'",
"]",
"for",
"state_name",
"in",
"hmm",
".",
"state_names",
":",
"print",
"(",
"state_name",
")",
"state",
"=",
"mo... | Test code called from commandline | [
"Test",
"code",
"called",
"from",
"commandline"
] | e281c0266a9a9633f34ab70f9c3ad58036c19b59 | https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/htk.py#L283-L293 |
243,715 | sassoo/goldman | goldman/models/base.py | Model.to_lower | def to_lower(cls): # NOQA
""" Return a list of all the fields that should be lowercased
This is done on fields with `lower=True`.
"""
email = cls.get_fields_by_class(EmailType)
lower = cls.get_fields_by_prop('lower', True) + email
return list(set(email + lower)) | python | def to_lower(cls): # NOQA
""" Return a list of all the fields that should be lowercased
This is done on fields with `lower=True`.
"""
email = cls.get_fields_by_class(EmailType)
lower = cls.get_fields_by_prop('lower', True) + email
return list(set(email + lower)) | [
"def",
"to_lower",
"(",
"cls",
")",
":",
"# NOQA",
"email",
"=",
"cls",
".",
"get_fields_by_class",
"(",
"EmailType",
")",
"lower",
"=",
"cls",
".",
"get_fields_by_prop",
"(",
"'lower'",
",",
"True",
")",
"+",
"email",
"return",
"list",
"(",
"set",
"(",
... | Return a list of all the fields that should be lowercased
This is done on fields with `lower=True`. | [
"Return",
"a",
"list",
"of",
"all",
"the",
"fields",
"that",
"should",
"be",
"lowercased"
] | b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2 | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/models/base.py#L84-L93 |
243,716 | sassoo/goldman | goldman/models/base.py | Model.get_fields_by_class | def get_fields_by_class(cls, field_class):
""" Return a list of field names matching a field class
:param field_class: field class object
:return: list
"""
ret = []
for key, val in getattr(cls, '_fields').items():
if isinstance(val, field_class):
... | python | def get_fields_by_class(cls, field_class):
""" Return a list of field names matching a field class
:param field_class: field class object
:return: list
"""
ret = []
for key, val in getattr(cls, '_fields').items():
if isinstance(val, field_class):
... | [
"def",
"get_fields_by_class",
"(",
"cls",
",",
"field_class",
")",
":",
"ret",
"=",
"[",
"]",
"for",
"key",
",",
"val",
"in",
"getattr",
"(",
"cls",
",",
"'_fields'",
")",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"val",
",",
"field_class... | Return a list of field names matching a field class
:param field_class: field class object
:return: list | [
"Return",
"a",
"list",
"of",
"field",
"names",
"matching",
"a",
"field",
"class"
] | b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2 | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/models/base.py#L108-L120 |
243,717 | sassoo/goldman | goldman/models/base.py | Model.get_fields_with_prop | def get_fields_with_prop(cls, prop_key):
""" Return a list of fields with a prop key defined
Each list item will be a tuple of field name containing
the prop key & the value of that prop key.
:param prop_key: key name
:return: list of tuples
"""
ret = []
... | python | def get_fields_with_prop(cls, prop_key):
""" Return a list of fields with a prop key defined
Each list item will be a tuple of field name containing
the prop key & the value of that prop key.
:param prop_key: key name
:return: list of tuples
"""
ret = []
... | [
"def",
"get_fields_with_prop",
"(",
"cls",
",",
"prop_key",
")",
":",
"ret",
"=",
"[",
"]",
"for",
"key",
",",
"val",
"in",
"getattr",
"(",
"cls",
",",
"'_fields'",
")",
".",
"items",
"(",
")",
":",
"if",
"hasattr",
"(",
"val",
",",
"prop_key",
")"... | Return a list of fields with a prop key defined
Each list item will be a tuple of field name containing
the prop key & the value of that prop key.
:param prop_key: key name
:return: list of tuples | [
"Return",
"a",
"list",
"of",
"fields",
"with",
"a",
"prop",
"key",
"defined"
] | b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2 | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/models/base.py#L139-L154 |
243,718 | sassoo/goldman | goldman/models/base.py | Model.to_exceptions | def to_exceptions(cls, errors):
""" Convert the validation errors into ValidationFailure exc's
Transform native schematics validation errors into a
goldman ValidationFailure exception.
:param errors:
dict of errors in schematics format
:return:
list of V... | python | def to_exceptions(cls, errors):
""" Convert the validation errors into ValidationFailure exc's
Transform native schematics validation errors into a
goldman ValidationFailure exception.
:param errors:
dict of errors in schematics format
:return:
list of V... | [
"def",
"to_exceptions",
"(",
"cls",
",",
"errors",
")",
":",
"ret",
"=",
"[",
"]",
"for",
"key",
",",
"val",
"in",
"errors",
".",
"items",
"(",
")",
":",
"if",
"key",
"in",
"cls",
".",
"relationships",
":",
"attr",
"=",
"'/data/relationships/%s'",
"%... | Convert the validation errors into ValidationFailure exc's
Transform native schematics validation errors into a
goldman ValidationFailure exception.
:param errors:
dict of errors in schematics format
:return:
list of ValidationFailure exception objects | [
"Convert",
"the",
"validation",
"errors",
"into",
"ValidationFailure",
"exc",
"s"
] | b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2 | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/models/base.py#L157-L180 |
243,719 | sassoo/goldman | goldman/models/base.py | Model.dirty_fields | def dirty_fields(self):
""" Return an array of field names that are dirty
Dirty means if a model was hydrated first from the
store & then had field values changed they are now
considered dirty.
For new models all fields are considered dirty.
:return: list
"""
... | python | def dirty_fields(self):
""" Return an array of field names that are dirty
Dirty means if a model was hydrated first from the
store & then had field values changed they are now
considered dirty.
For new models all fields are considered dirty.
:return: list
"""
... | [
"def",
"dirty_fields",
"(",
"self",
")",
":",
"dirty_fields",
"=",
"[",
"]",
"for",
"field",
"in",
"self",
".",
"all_fields",
":",
"if",
"field",
"not",
"in",
"self",
".",
"_original",
":",
"dirty_fields",
".",
"append",
"(",
"field",
")",
"elif",
"sel... | Return an array of field names that are dirty
Dirty means if a model was hydrated first from the
store & then had field values changed they are now
considered dirty.
For new models all fields are considered dirty.
:return: list | [
"Return",
"an",
"array",
"of",
"field",
"names",
"that",
"are",
"dirty"
] | b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2 | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/models/base.py#L189-L208 |
243,720 | sassoo/goldman | goldman/models/base.py | Model.merge | def merge(self, data, clean=False, validate=False):
""" Merge a dict with the model
This is needed because schematics doesn't auto cast
values when assigned. This method allows us to ensure
incoming data & existing data on a model are always
coerced properly.
We create ... | python | def merge(self, data, clean=False, validate=False):
""" Merge a dict with the model
This is needed because schematics doesn't auto cast
values when assigned. This method allows us to ensure
incoming data & existing data on a model are always
coerced properly.
We create ... | [
"def",
"merge",
"(",
"self",
",",
"data",
",",
"clean",
"=",
"False",
",",
"validate",
"=",
"False",
")",
":",
"try",
":",
"model",
"=",
"self",
".",
"__class__",
"(",
"data",
")",
"except",
"ConversionError",
"as",
"errors",
":",
"abort",
"(",
"self... | Merge a dict with the model
This is needed because schematics doesn't auto cast
values when assigned. This method allows us to ensure
incoming data & existing data on a model are always
coerced properly.
We create a temporary model instance with just the new
data so all... | [
"Merge",
"a",
"dict",
"with",
"the",
"model"
] | b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2 | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/models/base.py#L222-L266 |
243,721 | sassoo/goldman | goldman/models/base.py | Model.to_primitive | def to_primitive(self, load_rels=None, sparse_fields=None, *args,
**kwargs):
""" Override the schematics native to_primitive method
:param loads_rels:
List of field names that are relationships that should
be loaded for the serialization process. This needs
... | python | def to_primitive(self, load_rels=None, sparse_fields=None, *args,
**kwargs):
""" Override the schematics native to_primitive method
:param loads_rels:
List of field names that are relationships that should
be loaded for the serialization process. This needs
... | [
"def",
"to_primitive",
"(",
"self",
",",
"load_rels",
"=",
"None",
",",
"sparse_fields",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"load_rels",
":",
"for",
"rel",
"in",
"load_rels",
":",
"getattr",
"(",
"self",
",",
"rel... | Override the schematics native to_primitive method
:param loads_rels:
List of field names that are relationships that should
be loaded for the serialization process. This needs
to be run before the native schematics to_primitive is
run so the proper data is seria... | [
"Override",
"the",
"schematics",
"native",
"to_primitive",
"method"
] | b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2 | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/models/base.py#L268-L295 |
243,722 | rosenbrockc/acorn | acorn/analyze/sklearn.py | stash_split | def stash_split(fqdn, result, *argl, **argd):
"""Stashes the split between training and testing sets so that it can be
used later for automatic scoring of the models in the log.
"""
global _splits
if fqdn == "sklearn.cross_validation.train_test_split":
key = id(result[1])
_splits[key... | python | def stash_split(fqdn, result, *argl, **argd):
"""Stashes the split between training and testing sets so that it can be
used later for automatic scoring of the models in the log.
"""
global _splits
if fqdn == "sklearn.cross_validation.train_test_split":
key = id(result[1])
_splits[key... | [
"def",
"stash_split",
"(",
"fqdn",
",",
"result",
",",
"*",
"argl",
",",
"*",
"*",
"argd",
")",
":",
"global",
"_splits",
"if",
"fqdn",
"==",
"\"sklearn.cross_validation.train_test_split\"",
":",
"key",
"=",
"id",
"(",
"result",
"[",
"1",
"]",
")",
"_spl... | Stashes the split between training and testing sets so that it can be
used later for automatic scoring of the models in the log. | [
"Stashes",
"the",
"split",
"between",
"training",
"and",
"testing",
"sets",
"so",
"that",
"it",
"can",
"be",
"used",
"later",
"for",
"automatic",
"scoring",
"of",
"the",
"models",
"in",
"the",
"log",
"."
] | 9a44d1a1ad8bfc2c54a6b56d9efe54433a797820 | https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/analyze/sklearn.py#L57-L69 |
243,723 | rosenbrockc/acorn | acorn/analyze/sklearn.py | _machine_fqdn | def _machine_fqdn(machine):
"""Returns the FQDN of the given learning machine.
"""
from acorn.logging.decoration import _fqdn
if hasattr(machine, "__class__"):
return _fqdn(machine.__class__, False)
else: # pragma: no cover
#See what FQDN can get out of the class instance.
re... | python | def _machine_fqdn(machine):
"""Returns the FQDN of the given learning machine.
"""
from acorn.logging.decoration import _fqdn
if hasattr(machine, "__class__"):
return _fqdn(machine.__class__, False)
else: # pragma: no cover
#See what FQDN can get out of the class instance.
re... | [
"def",
"_machine_fqdn",
"(",
"machine",
")",
":",
"from",
"acorn",
".",
"logging",
".",
"decoration",
"import",
"_fqdn",
"if",
"hasattr",
"(",
"machine",
",",
"\"__class__\"",
")",
":",
"return",
"_fqdn",
"(",
"machine",
".",
"__class__",
",",
"False",
")"... | Returns the FQDN of the given learning machine. | [
"Returns",
"the",
"FQDN",
"of",
"the",
"given",
"learning",
"machine",
"."
] | 9a44d1a1ad8bfc2c54a6b56d9efe54433a797820 | https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/analyze/sklearn.py#L71-L79 |
243,724 | rosenbrockc/acorn | acorn/analyze/sklearn.py | fit | def fit(fqdn, result, *argl, **argd):
"""Analyzes the result of a generic fit operation performed by `sklearn`.
Args:
fqdn (str): full-qualified name of the method that was called.
result: result of calling the method with `fqdn`.
argl (tuple): positional arguments passed to the method ... | python | def fit(fqdn, result, *argl, **argd):
"""Analyzes the result of a generic fit operation performed by `sklearn`.
Args:
fqdn (str): full-qualified name of the method that was called.
result: result of calling the method with `fqdn`.
argl (tuple): positional arguments passed to the method ... | [
"def",
"fit",
"(",
"fqdn",
",",
"result",
",",
"*",
"argl",
",",
"*",
"*",
"argd",
")",
":",
"#Check the arguments to see what kind of data we are working with, then",
"#choose the appropriate function below to return the analysis dictionary.",
"#The first positional argument will ... | Analyzes the result of a generic fit operation performed by `sklearn`.
Args:
fqdn (str): full-qualified name of the method that was called.
result: result of calling the method with `fqdn`.
argl (tuple): positional arguments passed to the method call.
argd (dict): keyword arguments ... | [
"Analyzes",
"the",
"result",
"of",
"a",
"generic",
"fit",
"operation",
"performed",
"by",
"sklearn",
"."
] | 9a44d1a1ad8bfc2c54a6b56d9efe54433a797820 | https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/analyze/sklearn.py#L95-L122 |
243,725 | rosenbrockc/acorn | acorn/analyze/sklearn.py | predict | def predict(fqdn, result, *argl, **argd):
"""Analyzes the result of a generic predict operation performed by
`sklearn`.
Args:
fqdn (str): full-qualified name of the method that was called.
result: result of calling the method with `fqdn`.
argl (tuple): positional arguments passed to... | python | def predict(fqdn, result, *argl, **argd):
"""Analyzes the result of a generic predict operation performed by
`sklearn`.
Args:
fqdn (str): full-qualified name of the method that was called.
result: result of calling the method with `fqdn`.
argl (tuple): positional arguments passed to... | [
"def",
"predict",
"(",
"fqdn",
",",
"result",
",",
"*",
"argl",
",",
"*",
"*",
"argd",
")",
":",
"#Check the arguments to see what kind of data we are working with, then",
"#choose the appropriate function below to return the analysis dictionary.",
"out",
"=",
"None",
"if",
... | Analyzes the result of a generic predict operation performed by
`sklearn`.
Args:
fqdn (str): full-qualified name of the method that was called.
result: result of calling the method with `fqdn`.
argl (tuple): positional arguments passed to the method call.
argd (dict): keyword ar... | [
"Analyzes",
"the",
"result",
"of",
"a",
"generic",
"predict",
"operation",
"performed",
"by",
"sklearn",
"."
] | 9a44d1a1ad8bfc2c54a6b56d9efe54433a797820 | https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/analyze/sklearn.py#L124-L143 |
243,726 | rosenbrockc/acorn | acorn/analyze/sklearn.py | _do_auto_predict | def _do_auto_predict(machine, X, *args):
"""Performs an automatic prediction for the specified machine and returns
the predicted values.
"""
if auto_predict and hasattr(machine, "predict"):
return machine.predict(X) | python | def _do_auto_predict(machine, X, *args):
"""Performs an automatic prediction for the specified machine and returns
the predicted values.
"""
if auto_predict and hasattr(machine, "predict"):
return machine.predict(X) | [
"def",
"_do_auto_predict",
"(",
"machine",
",",
"X",
",",
"*",
"args",
")",
":",
"if",
"auto_predict",
"and",
"hasattr",
"(",
"machine",
",",
"\"predict\"",
")",
":",
"return",
"machine",
".",
"predict",
"(",
"X",
")"
] | Performs an automatic prediction for the specified machine and returns
the predicted values. | [
"Performs",
"an",
"automatic",
"prediction",
"for",
"the",
"specified",
"machine",
"and",
"returns",
"the",
"predicted",
"values",
"."
] | 9a44d1a1ad8bfc2c54a6b56d9efe54433a797820 | https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/analyze/sklearn.py#L145-L150 |
243,727 | rosenbrockc/acorn | acorn/analyze/sklearn.py | _generic_fit | def _generic_fit(fqdn, result, scorer, yP=None, *argl, **argd):
"""Performs the generic fit tests that are common to both classifier and
regressor; uses `scorer` to score the predicted values given by the machine
when tested against its training set.
Args:
scorer (function): called on the result of... | python | def _generic_fit(fqdn, result, scorer, yP=None, *argl, **argd):
"""Performs the generic fit tests that are common to both classifier and
regressor; uses `scorer` to score the predicted values given by the machine
when tested against its training set.
Args:
scorer (function): called on the result of... | [
"def",
"_generic_fit",
"(",
"fqdn",
",",
"result",
",",
"scorer",
",",
"yP",
"=",
"None",
",",
"*",
"argl",
",",
"*",
"*",
"argd",
")",
":",
"out",
"=",
"None",
"if",
"len",
"(",
"argl",
")",
">",
"0",
":",
"machine",
"=",
"argl",
"[",
"0",
"... | Performs the generic fit tests that are common to both classifier and
regressor; uses `scorer` to score the predicted values given by the machine
when tested against its training set.
Args:
scorer (function): called on the result of `machine.predict(Xtrain,
ytrain)`. | [
"Performs",
"the",
"generic",
"fit",
"tests",
"that",
"are",
"common",
"to",
"both",
"classifier",
"and",
"regressor",
";",
"uses",
"scorer",
"to",
"score",
"the",
"predicted",
"values",
"given",
"by",
"the",
"machine",
"when",
"tested",
"against",
"its",
"t... | 9a44d1a1ad8bfc2c54a6b56d9efe54433a797820 | https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/analyze/sklearn.py#L152-L176 |
243,728 | rosenbrockc/acorn | acorn/analyze/sklearn.py | _percent_match | def _percent_match(result, out, yP=None, *argl):
"""Returns the percent match for the specified prediction call; requires
that the data was split before using an analyzed method.
Args:
out (dict): output dictionary to save the result to.
"""
if len(argl) > 1:
if yP is None:
... | python | def _percent_match(result, out, yP=None, *argl):
"""Returns the percent match for the specified prediction call; requires
that the data was split before using an analyzed method.
Args:
out (dict): output dictionary to save the result to.
"""
if len(argl) > 1:
if yP is None:
... | [
"def",
"_percent_match",
"(",
"result",
",",
"out",
",",
"yP",
"=",
"None",
",",
"*",
"argl",
")",
":",
"if",
"len",
"(",
"argl",
")",
">",
"1",
":",
"if",
"yP",
"is",
"None",
":",
"Xt",
"=",
"argl",
"[",
"1",
"]",
"key",
"=",
"id",
"(",
"X... | Returns the percent match for the specified prediction call; requires
that the data was split before using an analyzed method.
Args:
out (dict): output dictionary to save the result to. | [
"Returns",
"the",
"percent",
"match",
"for",
"the",
"specified",
"prediction",
"call",
";",
"requires",
"that",
"the",
"data",
"was",
"split",
"before",
"using",
"an",
"analyzed",
"method",
"."
] | 9a44d1a1ad8bfc2c54a6b56d9efe54433a797820 | https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/analyze/sklearn.py#L188-L204 |
243,729 | basvandenbroek/gcloud_taskqueue | gcloud_taskqueue/task.py | Task.path | def path(self):
"""Getter property for the URL path to this Task.
:rtype: string
:returns: The URL path to this task.
"""
if not self.id:
raise ValueError('Cannot determine path without a task id.')
return self.path_helper(self.taskqueue.path, self.id) | python | def path(self):
"""Getter property for the URL path to this Task.
:rtype: string
:returns: The URL path to this task.
"""
if not self.id:
raise ValueError('Cannot determine path without a task id.')
return self.path_helper(self.taskqueue.path, self.id) | [
"def",
"path",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"id",
":",
"raise",
"ValueError",
"(",
"'Cannot determine path without a task id.'",
")",
"return",
"self",
".",
"path_helper",
"(",
"self",
".",
"taskqueue",
".",
"path",
",",
"self",
".",
"i... | Getter property for the URL path to this Task.
:rtype: string
:returns: The URL path to this task. | [
"Getter",
"property",
"for",
"the",
"URL",
"path",
"to",
"this",
"Task",
"."
] | b147b57f7c0ad9e8030ee9797d6526a448aa5007 | https://github.com/basvandenbroek/gcloud_taskqueue/blob/b147b57f7c0ad9e8030ee9797d6526a448aa5007/gcloud_taskqueue/task.py#L77-L86 |
243,730 | basvandenbroek/gcloud_taskqueue | gcloud_taskqueue/task.py | Task.delete | def delete(self, client=None):
"""Deletes a task from Task Queue.
:type client: :class:`gcloud.taskqueue.client.Client` or ``NoneType``
:param client: Optional. The client to use. If not passed, falls back
to the ``client`` stored on the task's taskqueue.
:rtype... | python | def delete(self, client=None):
"""Deletes a task from Task Queue.
:type client: :class:`gcloud.taskqueue.client.Client` or ``NoneType``
:param client: Optional. The client to use. If not passed, falls back
to the ``client`` stored on the task's taskqueue.
:rtype... | [
"def",
"delete",
"(",
"self",
",",
"client",
"=",
"None",
")",
":",
"return",
"self",
".",
"taskqueue",
".",
"delete_task",
"(",
"self",
".",
"id",
",",
"client",
"=",
"client",
")"
] | Deletes a task from Task Queue.
:type client: :class:`gcloud.taskqueue.client.Client` or ``NoneType``
:param client: Optional. The client to use. If not passed, falls back
to the ``client`` stored on the task's taskqueue.
:rtype: :class:`Task`
:returns: The task... | [
"Deletes",
"a",
"task",
"from",
"Task",
"Queue",
"."
] | b147b57f7c0ad9e8030ee9797d6526a448aa5007 | https://github.com/basvandenbroek/gcloud_taskqueue/blob/b147b57f7c0ad9e8030ee9797d6526a448aa5007/gcloud_taskqueue/task.py#L93-L106 |
243,731 | basvandenbroek/gcloud_taskqueue | gcloud_taskqueue/task.py | Task.update | def update(self, new_lease_time, client=None):
"""Update the duration of a task lease
:type new_lease_time: int
:param new_lease_time: the new lease time in seconds.
:type client: :class:`gcloud.taskqueue.client.Client` or ``NoneType``
:param client: Optional. The client to use... | python | def update(self, new_lease_time, client=None):
"""Update the duration of a task lease
:type new_lease_time: int
:param new_lease_time: the new lease time in seconds.
:type client: :class:`gcloud.taskqueue.client.Client` or ``NoneType``
:param client: Optional. The client to use... | [
"def",
"update",
"(",
"self",
",",
"new_lease_time",
",",
"client",
"=",
"None",
")",
":",
"return",
"self",
".",
"taskqueue",
".",
"update_task",
"(",
"self",
".",
"id",
",",
"new_lease_time",
"=",
"new_lease_time",
",",
"client",
"=",
"client",
")"
] | Update the duration of a task lease
:type new_lease_time: int
:param new_lease_time: the new lease time in seconds.
:type client: :class:`gcloud.taskqueue.client.Client` or ``NoneType``
:param client: Optional. The client to use. If not passed, falls back
to the... | [
"Update",
"the",
"duration",
"of",
"a",
"task",
"lease"
] | b147b57f7c0ad9e8030ee9797d6526a448aa5007 | https://github.com/basvandenbroek/gcloud_taskqueue/blob/b147b57f7c0ad9e8030ee9797d6526a448aa5007/gcloud_taskqueue/task.py#L108-L124 |
243,732 | basvandenbroek/gcloud_taskqueue | gcloud_taskqueue/task.py | Task.description | def description(self):
"""The description for this task.
See: https://cloud.google.com/appengine/docs/python/taskqueue/rest/tasks
:rtype: string
:returns: The description for this task.
"""
if self._description is None:
if 'payloadBase64' not in self._proper... | python | def description(self):
"""The description for this task.
See: https://cloud.google.com/appengine/docs/python/taskqueue/rest/tasks
:rtype: string
:returns: The description for this task.
"""
if self._description is None:
if 'payloadBase64' not in self._proper... | [
"def",
"description",
"(",
"self",
")",
":",
"if",
"self",
".",
"_description",
"is",
"None",
":",
"if",
"'payloadBase64'",
"not",
"in",
"self",
".",
"_properties",
":",
"self",
".",
"_properties",
"=",
"self",
".",
"taskqueue",
".",
"get_task",
"(",
"id... | The description for this task.
See: https://cloud.google.com/appengine/docs/python/taskqueue/rest/tasks
:rtype: string
:returns: The description for this task. | [
"The",
"description",
"for",
"this",
"task",
"."
] | b147b57f7c0ad9e8030ee9797d6526a448aa5007 | https://github.com/basvandenbroek/gcloud_taskqueue/blob/b147b57f7c0ad9e8030ee9797d6526a448aa5007/gcloud_taskqueue/task.py#L162-L174 |
243,733 | basvandenbroek/gcloud_taskqueue | gcloud_taskqueue/task.py | Task.time_enqueued | def time_enqueued(self):
"""Retrieve the timestamp at which the task was enqueued.
See: https://cloud.google.com/appengine/docs/python/taskqueue/rest/tasks
:rtype: :class:`datetime.datetime` or ``NoneType``
:returns: Datetime object parsed from microsecond timestamp, or
... | python | def time_enqueued(self):
"""Retrieve the timestamp at which the task was enqueued.
See: https://cloud.google.com/appengine/docs/python/taskqueue/rest/tasks
:rtype: :class:`datetime.datetime` or ``NoneType``
:returns: Datetime object parsed from microsecond timestamp, or
... | [
"def",
"time_enqueued",
"(",
"self",
")",
":",
"value",
"=",
"self",
".",
"_properties",
".",
"get",
"(",
"'enqueueTimestamp'",
")",
"if",
"value",
"is",
"not",
"None",
":",
"return",
"_datetime_from_microseconds",
"(",
"int",
"(",
"value",
")",
")"
] | Retrieve the timestamp at which the task was enqueued.
See: https://cloud.google.com/appengine/docs/python/taskqueue/rest/tasks
:rtype: :class:`datetime.datetime` or ``NoneType``
:returns: Datetime object parsed from microsecond timestamp, or
``None`` if the property is not s... | [
"Retrieve",
"the",
"timestamp",
"at",
"which",
"the",
"task",
"was",
"enqueued",
"."
] | b147b57f7c0ad9e8030ee9797d6526a448aa5007 | https://github.com/basvandenbroek/gcloud_taskqueue/blob/b147b57f7c0ad9e8030ee9797d6526a448aa5007/gcloud_taskqueue/task.py#L177-L188 |
243,734 | stormy-ua/DeepLearningToy | src/pydeeptoy/computational_graph.py | ComputationalGraph.conv2d | def conv2d(self, x_in: Connection, w_in: Connection, receptive_field_size, filters_number, stride=1, padding=1,
name=""):
"""
Computes a 2-D convolution given 4-D input and filter tensors.
"""
x_cols = self.tensor_3d_to_cols(x_in, receptive_field_size, stride=stride, paddi... | python | def conv2d(self, x_in: Connection, w_in: Connection, receptive_field_size, filters_number, stride=1, padding=1,
name=""):
"""
Computes a 2-D convolution given 4-D input and filter tensors.
"""
x_cols = self.tensor_3d_to_cols(x_in, receptive_field_size, stride=stride, paddi... | [
"def",
"conv2d",
"(",
"self",
",",
"x_in",
":",
"Connection",
",",
"w_in",
":",
"Connection",
",",
"receptive_field_size",
",",
"filters_number",
",",
"stride",
"=",
"1",
",",
"padding",
"=",
"1",
",",
"name",
"=",
"\"\"",
")",
":",
"x_cols",
"=",
"sel... | Computes a 2-D convolution given 4-D input and filter tensors. | [
"Computes",
"a",
"2",
"-",
"D",
"convolution",
"given",
"4",
"-",
"D",
"input",
"and",
"filter",
"tensors",
"."
] | 7ab0814ec0491a575ebee8eb1ccd61ce4bf9554b | https://github.com/stormy-ua/DeepLearningToy/blob/7ab0814ec0491a575ebee8eb1ccd61ce4bf9554b/src/pydeeptoy/computational_graph.py#L141-L156 |
243,735 | beatmax/redmodel | redmodel/models/writer.py | SortedSetFieldWriter.append | def append(self, hcont, value, score = None):
""" If sort_field is specified, score must be None.
If sort_field is not specified, score is mandatory. """
assert (score is None) != (self.field.sort_field is None)
if score is None:
score = getattr(value, self.field.sort_fie... | python | def append(self, hcont, value, score = None):
""" If sort_field is specified, score must be None.
If sort_field is not specified, score is mandatory. """
assert (score is None) != (self.field.sort_field is None)
if score is None:
score = getattr(value, self.field.sort_fie... | [
"def",
"append",
"(",
"self",
",",
"hcont",
",",
"value",
",",
"score",
"=",
"None",
")",
":",
"assert",
"(",
"score",
"is",
"None",
")",
"!=",
"(",
"self",
".",
"field",
".",
"sort_field",
"is",
"None",
")",
"if",
"score",
"is",
"None",
":",
"sc... | If sort_field is specified, score must be None.
If sort_field is not specified, score is mandatory. | [
"If",
"sort_field",
"is",
"specified",
"score",
"must",
"be",
"None",
".",
"If",
"sort_field",
"is",
"not",
"specified",
"score",
"is",
"mandatory",
"."
] | 1df545ecd8e36e8addeaac124db32d9d0e22938c | https://github.com/beatmax/redmodel/blob/1df545ecd8e36e8addeaac124db32d9d0e22938c/redmodel/models/writer.py#L203-L209 |
243,736 | fogcitymarathoner/s3_mysql_backup | s3_mysql_backup/copy_file.py | copy_file | def copy_file(aws_access_key_id, aws_secret_access_key, bucket_name, file, s3_folder):
"""
copies file to bucket s3_folder
"""
# Connect to the bucket
bucket = s3_bucket(aws_access_key_id, aws_secret_access_key, bucket_name)
key = boto.s3.key.Key(bucket)
if s3_folder:
target_name... | python | def copy_file(aws_access_key_id, aws_secret_access_key, bucket_name, file, s3_folder):
"""
copies file to bucket s3_folder
"""
# Connect to the bucket
bucket = s3_bucket(aws_access_key_id, aws_secret_access_key, bucket_name)
key = boto.s3.key.Key(bucket)
if s3_folder:
target_name... | [
"def",
"copy_file",
"(",
"aws_access_key_id",
",",
"aws_secret_access_key",
",",
"bucket_name",
",",
"file",
",",
"s3_folder",
")",
":",
"# Connect to the bucket",
"bucket",
"=",
"s3_bucket",
"(",
"aws_access_key_id",
",",
"aws_secret_access_key",
",",
"bucket_name",
... | copies file to bucket s3_folder | [
"copies",
"file",
"to",
"bucket",
"s3_folder"
] | 8a0fb3e51a7b873eb4287d4954548a0dbab0e734 | https://github.com/fogcitymarathoner/s3_mysql_backup/blob/8a0fb3e51a7b873eb4287d4954548a0dbab0e734/s3_mysql_backup/copy_file.py#L8-L26 |
243,737 | sliem/barrett | example/plot.py | main | def main():
""" We here demostrate the basic functionality of barrett. We use a global scan
of scalar dark matter as an example. The details aren't really important.
"""
dataset = 'RD'
observables = ['log(<\sigma v>)', '\Omega_{\chi}h^2', 'log(\sigma_p^{SI})']
var = ['log(m_{\chi})']
var +... | python | def main():
""" We here demostrate the basic functionality of barrett. We use a global scan
of scalar dark matter as an example. The details aren't really important.
"""
dataset = 'RD'
observables = ['log(<\sigma v>)', '\Omega_{\chi}h^2', 'log(\sigma_p^{SI})']
var = ['log(m_{\chi})']
var +... | [
"def",
"main",
"(",
")",
":",
"dataset",
"=",
"'RD'",
"observables",
"=",
"[",
"'log(<\\sigma v>)'",
",",
"'\\Omega_{\\chi}h^2'",
",",
"'log(\\sigma_p^{SI})'",
"]",
"var",
"=",
"[",
"'log(m_{\\chi})'",
"]",
"var",
"+=",
"[",
"'log(C_1)'",
",",
"'log(C_2)'",
",... | We here demostrate the basic functionality of barrett. We use a global scan
of scalar dark matter as an example. The details aren't really important. | [
"We",
"here",
"demostrate",
"the",
"basic",
"functionality",
"of",
"barrett",
".",
"We",
"use",
"a",
"global",
"scan",
"of",
"scalar",
"dark",
"matter",
"as",
"an",
"example",
".",
"The",
"details",
"aren",
"t",
"really",
"important",
"."
] | d48e96591577d1fcecd50c21a9be71573218cde7 | https://github.com/sliem/barrett/blob/d48e96591577d1fcecd50c21a9be71573218cde7/example/plot.py#L10-L23 |
243,738 | sliem/barrett | example/plot.py | pairplot | def pairplot(dataset, vars, filename, bins=60):
""" Plot a matrix of the specified variables with all the 2D pdfs and 1D pdfs.
"""
n = len(vars)
fig, axes = plt.subplots(nrows=n, ncols=n)
plt.subplots_adjust(wspace=0.1, hspace=0.1)
for i, x in enumerate(vars):
for j, y in enumerate(var... | python | def pairplot(dataset, vars, filename, bins=60):
""" Plot a matrix of the specified variables with all the 2D pdfs and 1D pdfs.
"""
n = len(vars)
fig, axes = plt.subplots(nrows=n, ncols=n)
plt.subplots_adjust(wspace=0.1, hspace=0.1)
for i, x in enumerate(vars):
for j, y in enumerate(var... | [
"def",
"pairplot",
"(",
"dataset",
",",
"vars",
",",
"filename",
",",
"bins",
"=",
"60",
")",
":",
"n",
"=",
"len",
"(",
"vars",
")",
"fig",
",",
"axes",
"=",
"plt",
".",
"subplots",
"(",
"nrows",
"=",
"n",
",",
"ncols",
"=",
"n",
")",
"plt",
... | Plot a matrix of the specified variables with all the 2D pdfs and 1D pdfs. | [
"Plot",
"a",
"matrix",
"of",
"the",
"specified",
"variables",
"with",
"all",
"the",
"2D",
"pdfs",
"and",
"1D",
"pdfs",
"."
] | d48e96591577d1fcecd50c21a9be71573218cde7 | https://github.com/sliem/barrett/blob/d48e96591577d1fcecd50c21a9be71573218cde7/example/plot.py#L26-L73 |
243,739 | sliem/barrett | example/plot.py | plot_vs_mass | def plot_vs_mass(dataset, vars, filename, bins=60):
""" Plot 2D marginalised posteriors of the 'vars' vs the dark matter mass.
We plot the one sigma, and two sigma filled contours. More contours can be plotted
which produces something more akin to a heatmap.
If one require more complicated plotting, it... | python | def plot_vs_mass(dataset, vars, filename, bins=60):
""" Plot 2D marginalised posteriors of the 'vars' vs the dark matter mass.
We plot the one sigma, and two sigma filled contours. More contours can be plotted
which produces something more akin to a heatmap.
If one require more complicated plotting, it... | [
"def",
"plot_vs_mass",
"(",
"dataset",
",",
"vars",
",",
"filename",
",",
"bins",
"=",
"60",
")",
":",
"n",
"=",
"len",
"(",
"vars",
")",
"fig",
",",
"axes",
"=",
"plt",
".",
"subplots",
"(",
"nrows",
"=",
"n",
",",
"ncols",
"=",
"1",
",",
"sha... | Plot 2D marginalised posteriors of the 'vars' vs the dark matter mass.
We plot the one sigma, and two sigma filled contours. More contours can be plotted
which produces something more akin to a heatmap.
If one require more complicated plotting, it is recommended to write a custom
plotting function by e... | [
"Plot",
"2D",
"marginalised",
"posteriors",
"of",
"the",
"vars",
"vs",
"the",
"dark",
"matter",
"mass",
".",
"We",
"plot",
"the",
"one",
"sigma",
"and",
"two",
"sigma",
"filled",
"contours",
".",
"More",
"contours",
"can",
"be",
"plotted",
"which",
"produc... | d48e96591577d1fcecd50c21a9be71573218cde7 | https://github.com/sliem/barrett/blob/d48e96591577d1fcecd50c21a9be71573218cde7/example/plot.py#L76-L110 |
243,740 | sliem/barrett | example/plot.py | plot_oneD | def plot_oneD(dataset, vars, filename, bins=60):
""" Plot 1D marginalised posteriors for the 'vars' of interest."""
n = len(vars)
fig, axes = plt.subplots(nrows=n,
ncols=1,
sharex=False,
sharey=False)
for i, x in en... | python | def plot_oneD(dataset, vars, filename, bins=60):
""" Plot 1D marginalised posteriors for the 'vars' of interest."""
n = len(vars)
fig, axes = plt.subplots(nrows=n,
ncols=1,
sharex=False,
sharey=False)
for i, x in en... | [
"def",
"plot_oneD",
"(",
"dataset",
",",
"vars",
",",
"filename",
",",
"bins",
"=",
"60",
")",
":",
"n",
"=",
"len",
"(",
"vars",
")",
"fig",
",",
"axes",
"=",
"plt",
".",
"subplots",
"(",
"nrows",
"=",
"n",
",",
"ncols",
"=",
"1",
",",
"sharex... | Plot 1D marginalised posteriors for the 'vars' of interest. | [
"Plot",
"1D",
"marginalised",
"posteriors",
"for",
"the",
"vars",
"of",
"interest",
"."
] | d48e96591577d1fcecd50c21a9be71573218cde7 | https://github.com/sliem/barrett/blob/d48e96591577d1fcecd50c21a9be71573218cde7/example/plot.py#L113-L131 |
243,741 | Vesuvium/frustum | frustum/Frustum.py | Frustum.start_logger | def start_logger(self):
"""
Enables the root logger and configures extra loggers.
"""
level = self.real_level(self.level)
logging.basicConfig(level=level)
self.set_logger(self.name, self.level)
config.dictConfig(self.config)
self.logger = logging.getLogger... | python | def start_logger(self):
"""
Enables the root logger and configures extra loggers.
"""
level = self.real_level(self.level)
logging.basicConfig(level=level)
self.set_logger(self.name, self.level)
config.dictConfig(self.config)
self.logger = logging.getLogger... | [
"def",
"start_logger",
"(",
"self",
")",
":",
"level",
"=",
"self",
".",
"real_level",
"(",
"self",
".",
"level",
")",
"logging",
".",
"basicConfig",
"(",
"level",
"=",
"level",
")",
"self",
".",
"set_logger",
"(",
"self",
".",
"name",
",",
"self",
"... | Enables the root logger and configures extra loggers. | [
"Enables",
"the",
"root",
"logger",
"and",
"configures",
"extra",
"loggers",
"."
] | 3ee354df5ce12c31bc2d18febea0cca912a7c4e3 | https://github.com/Vesuvium/frustum/blob/3ee354df5ce12c31bc2d18febea0cca912a7c4e3/frustum/Frustum.py#L22-L30 |
243,742 | Vesuvium/frustum | frustum/Frustum.py | Frustum.set_logger | def set_logger(self, logger_name, level, handler=None):
"""
Sets the level of a logger
"""
if 'loggers' not in self.config:
self.config['loggers'] = {}
real_level = self.real_level(level)
self.config['loggers'][logger_name] = {'level': real_level}
if h... | python | def set_logger(self, logger_name, level, handler=None):
"""
Sets the level of a logger
"""
if 'loggers' not in self.config:
self.config['loggers'] = {}
real_level = self.real_level(level)
self.config['loggers'][logger_name] = {'level': real_level}
if h... | [
"def",
"set_logger",
"(",
"self",
",",
"logger_name",
",",
"level",
",",
"handler",
"=",
"None",
")",
":",
"if",
"'loggers'",
"not",
"in",
"self",
".",
"config",
":",
"self",
".",
"config",
"[",
"'loggers'",
"]",
"=",
"{",
"}",
"real_level",
"=",
"se... | Sets the level of a logger | [
"Sets",
"the",
"level",
"of",
"a",
"logger"
] | 3ee354df5ce12c31bc2d18febea0cca912a7c4e3 | https://github.com/Vesuvium/frustum/blob/3ee354df5ce12c31bc2d18febea0cca912a7c4e3/frustum/Frustum.py#L37-L46 |
243,743 | Vesuvium/frustum | frustum/Frustum.py | Frustum.register_event | def register_event(self, event_name, event_level, message):
"""
Registers an event so that it can be logged later.
"""
self.events[event_name] = (event_level, message) | python | def register_event(self, event_name, event_level, message):
"""
Registers an event so that it can be logged later.
"""
self.events[event_name] = (event_level, message) | [
"def",
"register_event",
"(",
"self",
",",
"event_name",
",",
"event_level",
",",
"message",
")",
":",
"self",
".",
"events",
"[",
"event_name",
"]",
"=",
"(",
"event_level",
",",
"message",
")"
] | Registers an event so that it can be logged later. | [
"Registers",
"an",
"event",
"so",
"that",
"it",
"can",
"be",
"logged",
"later",
"."
] | 3ee354df5ce12c31bc2d18febea0cca912a7c4e3 | https://github.com/Vesuvium/frustum/blob/3ee354df5ce12c31bc2d18febea0cca912a7c4e3/frustum/Frustum.py#L55-L59 |
243,744 | ikalnytskyi/dooku | dooku/datetime.py | to_iso8601 | def to_iso8601(dt, tz=None):
"""
Returns an ISO-8601 representation of a given datetime instance.
>>> to_iso8601(datetime.datetime.now())
'2014-10-01T23:21:33.718508Z'
:param dt: a :class:`~datetime.datetime` instance
:param tz: a :class:`~datetime.tzinfo` to use; if None - use a defau... | python | def to_iso8601(dt, tz=None):
"""
Returns an ISO-8601 representation of a given datetime instance.
>>> to_iso8601(datetime.datetime.now())
'2014-10-01T23:21:33.718508Z'
:param dt: a :class:`~datetime.datetime` instance
:param tz: a :class:`~datetime.tzinfo` to use; if None - use a defau... | [
"def",
"to_iso8601",
"(",
"dt",
",",
"tz",
"=",
"None",
")",
":",
"if",
"tz",
"is",
"not",
"None",
":",
"dt",
"=",
"dt",
".",
"replace",
"(",
"tzinfo",
"=",
"tz",
")",
"iso8601",
"=",
"dt",
".",
"isoformat",
"(",
")",
"# Naive datetime objects usuall... | Returns an ISO-8601 representation of a given datetime instance.
>>> to_iso8601(datetime.datetime.now())
'2014-10-01T23:21:33.718508Z'
:param dt: a :class:`~datetime.datetime` instance
:param tz: a :class:`~datetime.tzinfo` to use; if None - use a default one | [
"Returns",
"an",
"ISO",
"-",
"8601",
"representation",
"of",
"a",
"given",
"datetime",
"instance",
"."
] | 77e6c82c9c41211c86ee36ae5e591d477945fedf | https://github.com/ikalnytskyi/dooku/blob/77e6c82c9c41211c86ee36ae5e591d477945fedf/dooku/datetime.py#L20-L39 |
243,745 | ikalnytskyi/dooku | dooku/datetime.py | Local._is_dst | def _is_dst(dt):
"""
Returns True if a given datetime object represents a time with
DST shift.
"""
# we can't use `dt.timestamp()` here since it requires a `utcoffset`
# and we don't want to get into a recursive loop
localtime = time.localtime(time.mktime((
... | python | def _is_dst(dt):
"""
Returns True if a given datetime object represents a time with
DST shift.
"""
# we can't use `dt.timestamp()` here since it requires a `utcoffset`
# and we don't want to get into a recursive loop
localtime = time.localtime(time.mktime((
... | [
"def",
"_is_dst",
"(",
"dt",
")",
":",
"# we can't use `dt.timestamp()` here since it requires a `utcoffset`",
"# and we don't want to get into a recursive loop",
"localtime",
"=",
"time",
".",
"localtime",
"(",
"time",
".",
"mktime",
"(",
"(",
"dt",
".",
"year",
",",
"... | Returns True if a given datetime object represents a time with
DST shift. | [
"Returns",
"True",
"if",
"a",
"given",
"datetime",
"object",
"represents",
"a",
"time",
"with",
"DST",
"shift",
"."
] | 77e6c82c9c41211c86ee36ae5e591d477945fedf | https://github.com/ikalnytskyi/dooku/blob/77e6c82c9c41211c86ee36ae5e591d477945fedf/dooku/datetime.py#L93-L111 |
243,746 | ikalnytskyi/dooku | dooku/datetime.py | Local.dst | def dst(self, dt):
"""
Returns a difference in seconds between standard offset and
dst offset.
"""
if not self._is_dst(dt):
return datetime.timedelta(0)
offset = time.timezone - time.altzone
return datetime.timedelta(seconds=-offset) | python | def dst(self, dt):
"""
Returns a difference in seconds between standard offset and
dst offset.
"""
if not self._is_dst(dt):
return datetime.timedelta(0)
offset = time.timezone - time.altzone
return datetime.timedelta(seconds=-offset) | [
"def",
"dst",
"(",
"self",
",",
"dt",
")",
":",
"if",
"not",
"self",
".",
"_is_dst",
"(",
"dt",
")",
":",
"return",
"datetime",
".",
"timedelta",
"(",
"0",
")",
"offset",
"=",
"time",
".",
"timezone",
"-",
"time",
".",
"altzone",
"return",
"datetim... | Returns a difference in seconds between standard offset and
dst offset. | [
"Returns",
"a",
"difference",
"in",
"seconds",
"between",
"standard",
"offset",
"and",
"dst",
"offset",
"."
] | 77e6c82c9c41211c86ee36ae5e591d477945fedf | https://github.com/ikalnytskyi/dooku/blob/77e6c82c9c41211c86ee36ae5e591d477945fedf/dooku/datetime.py#L118-L127 |
243,747 | collectiveacuity/labPack | labpack/parsing/conversion.py | _to_camelcase | def _to_camelcase(input_string):
''' a helper method to convert python to camelcase'''
camel_string = ''
for i in range(len(input_string)):
if input_string[i] == '_':
pass
elif not camel_string:
camel_string += input_string[i].upper()
elif input_string[i-1] ==... | python | def _to_camelcase(input_string):
''' a helper method to convert python to camelcase'''
camel_string = ''
for i in range(len(input_string)):
if input_string[i] == '_':
pass
elif not camel_string:
camel_string += input_string[i].upper()
elif input_string[i-1] ==... | [
"def",
"_to_camelcase",
"(",
"input_string",
")",
":",
"camel_string",
"=",
"''",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"input_string",
")",
")",
":",
"if",
"input_string",
"[",
"i",
"]",
"==",
"'_'",
":",
"pass",
"elif",
"not",
"camel_string",
"... | a helper method to convert python to camelcase | [
"a",
"helper",
"method",
"to",
"convert",
"python",
"to",
"camelcase"
] | 52949ece35e72e3cc308f54d9ffa6bfbd96805b8 | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/parsing/conversion.py#L6-L18 |
243,748 | collectiveacuity/labPack | labpack/parsing/conversion.py | _to_python | def _to_python(input_string):
''' a helper method to convert camelcase to python'''
python_string = ''
for i in range(len(input_string)):
if not python_string:
python_string += input_string[i].lower()
elif input_string[i].isupper():
python_string += '_%s' % input_stri... | python | def _to_python(input_string):
''' a helper method to convert camelcase to python'''
python_string = ''
for i in range(len(input_string)):
if not python_string:
python_string += input_string[i].lower()
elif input_string[i].isupper():
python_string += '_%s' % input_stri... | [
"def",
"_to_python",
"(",
"input_string",
")",
":",
"python_string",
"=",
"''",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"input_string",
")",
")",
":",
"if",
"not",
"python_string",
":",
"python_string",
"+=",
"input_string",
"[",
"i",
"]",
".",
"lowe... | a helper method to convert camelcase to python | [
"a",
"helper",
"method",
"to",
"convert",
"camelcase",
"to",
"python"
] | 52949ece35e72e3cc308f54d9ffa6bfbd96805b8 | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/parsing/conversion.py#L20-L30 |
243,749 | GemHQ/round-py | round/subscriptions.py | Subscriptions.create | def create(self, callback_url):
"""Register a new Subscription on this collection's parent object.
Args:
callback_url (str): URI of an active endpoint which can receive
notifications.
Returns:
A round.Subscription object if successful.
"""
resourc... | python | def create(self, callback_url):
"""Register a new Subscription on this collection's parent object.
Args:
callback_url (str): URI of an active endpoint which can receive
notifications.
Returns:
A round.Subscription object if successful.
"""
resourc... | [
"def",
"create",
"(",
"self",
",",
"callback_url",
")",
":",
"resource",
"=",
"self",
".",
"resource",
".",
"create",
"(",
"{",
"'subscribed_to'",
":",
"'address'",
",",
"'callback_url'",
":",
"callback_url",
"}",
")",
"subscription",
"=",
"self",
".",
"wr... | Register a new Subscription on this collection's parent object.
Args:
callback_url (str): URI of an active endpoint which can receive
notifications.
Returns:
A round.Subscription object if successful. | [
"Register",
"a",
"new",
"Subscription",
"on",
"this",
"collection",
"s",
"parent",
"object",
"."
] | d0838f849cd260b1eb5df67ed3c6f2fe56c91c21 | https://github.com/GemHQ/round-py/blob/d0838f849cd260b1eb5df67ed3c6f2fe56c91c21/round/subscriptions.py#L15-L29 |
243,750 | mbodenhamer/syn | syn/schema/b/sequence.py | Sequence.match | def match(self, seq, **kwargs):
'''If the schema matches seq, returns a list of the matched objects.
Otherwise, returns MatchFailure instance.
'''
strict = kwargs.get('strict', False)
top_level = kwargs.get('top_level', True)
match = kwargs.get('match', list())
i... | python | def match(self, seq, **kwargs):
'''If the schema matches seq, returns a list of the matched objects.
Otherwise, returns MatchFailure instance.
'''
strict = kwargs.get('strict', False)
top_level = kwargs.get('top_level', True)
match = kwargs.get('match', list())
i... | [
"def",
"match",
"(",
"self",
",",
"seq",
",",
"*",
"*",
"kwargs",
")",
":",
"strict",
"=",
"kwargs",
".",
"get",
"(",
"'strict'",
",",
"False",
")",
"top_level",
"=",
"kwargs",
".",
"get",
"(",
"'top_level'",
",",
"True",
")",
"match",
"=",
"kwargs... | If the schema matches seq, returns a list of the matched objects.
Otherwise, returns MatchFailure instance. | [
"If",
"the",
"schema",
"matches",
"seq",
"returns",
"a",
"list",
"of",
"the",
"matched",
"objects",
".",
"Otherwise",
"returns",
"MatchFailure",
"instance",
"."
] | aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258 | https://github.com/mbodenhamer/syn/blob/aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258/syn/schema/b/sequence.py#L259-L285 |
243,751 | scieloorg/accessstatsapi | accessstats/queries.py | downloads_per_year | def downloads_per_year(collection, code, raw=False):
"""
This method retrieve the total of downloads per year.
arguments
collection: SciELO 3 letters Acronym
code: (Journal ISSN, Issue PID, Article PID)
return
[
("2017", "20101"),
("2016", "11201"),
("2015", "12311"... | python | def downloads_per_year(collection, code, raw=False):
"""
This method retrieve the total of downloads per year.
arguments
collection: SciELO 3 letters Acronym
code: (Journal ISSN, Issue PID, Article PID)
return
[
("2017", "20101"),
("2016", "11201"),
("2015", "12311"... | [
"def",
"downloads_per_year",
"(",
"collection",
",",
"code",
",",
"raw",
"=",
"False",
")",
":",
"tc",
"=",
"ThriftClient",
"(",
")",
"body",
"=",
"{",
"\"query\"",
":",
"{",
"\"filtered\"",
":",
"{",
"}",
"}",
"}",
"fltr",
"=",
"{",
"}",
"query",
... | This method retrieve the total of downloads per year.
arguments
collection: SciELO 3 letters Acronym
code: (Journal ISSN, Issue PID, Article PID)
return
[
("2017", "20101"),
("2016", "11201"),
("2015", "12311"),
...
] | [
"This",
"method",
"retrieve",
"the",
"total",
"of",
"downloads",
"per",
"year",
"."
] | 8092d76bedab9e82efce4005f9bcd21fb94e8e98 | https://github.com/scieloorg/accessstatsapi/blob/8092d76bedab9e82efce4005f9bcd21fb94e8e98/accessstats/queries.py#L38-L115 |
243,752 | zorg/zorg-emic | zorg_emic/emic2.py | Emic2.word_wrap | def word_wrap(self, text, width=1023):
"""
A simple word wrapping greedy algorithm that puts
as many words into a single string as possible.
"""
substrings = []
string = text
while len(string) > width:
index = width - 1
while not string[in... | python | def word_wrap(self, text, width=1023):
"""
A simple word wrapping greedy algorithm that puts
as many words into a single string as possible.
"""
substrings = []
string = text
while len(string) > width:
index = width - 1
while not string[in... | [
"def",
"word_wrap",
"(",
"self",
",",
"text",
",",
"width",
"=",
"1023",
")",
":",
"substrings",
"=",
"[",
"]",
"string",
"=",
"text",
"while",
"len",
"(",
"string",
")",
">",
"width",
":",
"index",
"=",
"width",
"-",
"1",
"while",
"not",
"string",... | A simple word wrapping greedy algorithm that puts
as many words into a single string as possible. | [
"A",
"simple",
"word",
"wrapping",
"greedy",
"algorithm",
"that",
"puts",
"as",
"many",
"words",
"into",
"a",
"single",
"string",
"as",
"possible",
"."
] | 34d49897131cf7773b2b0f46e1e0a796911144e3 | https://github.com/zorg/zorg-emic/blob/34d49897131cf7773b2b0f46e1e0a796911144e3/zorg_emic/emic2.py#L66-L86 |
243,753 | zorg/zorg-emic | zorg_emic/emic2.py | Emic2.speak | def speak(self, text):
"""
The main function to convert text into speech.
"""
if not self.is_valid_string(text):
raise Exception("%s is not ISO-8859-1 compatible." % (text))
# Maximum allowable 1023 characters per message
if len(text) > 1023:
line... | python | def speak(self, text):
"""
The main function to convert text into speech.
"""
if not self.is_valid_string(text):
raise Exception("%s is not ISO-8859-1 compatible." % (text))
# Maximum allowable 1023 characters per message
if len(text) > 1023:
line... | [
"def",
"speak",
"(",
"self",
",",
"text",
")",
":",
"if",
"not",
"self",
".",
"is_valid_string",
"(",
"text",
")",
":",
"raise",
"Exception",
"(",
"\"%s is not ISO-8859-1 compatible.\"",
"%",
"(",
"text",
")",
")",
"# Maximum allowable 1023 characters per message"... | The main function to convert text into speech. | [
"The",
"main",
"function",
"to",
"convert",
"text",
"into",
"speech",
"."
] | 34d49897131cf7773b2b0f46e1e0a796911144e3 | https://github.com/zorg/zorg-emic/blob/34d49897131cf7773b2b0f46e1e0a796911144e3/zorg_emic/emic2.py#L88-L101 |
243,754 | xtream1101/web-wrapper | web_wrapper/selenium_utils.py | SeleniumUtils._get_site | def _get_site(self, url, headers, cookies, timeout, driver_args, driver_kwargs):
"""
Try and return page content in the requested format using selenium
"""
try:
# **TODO**: Find what exception this will throw and catch it and call
# self.driver.execute_script("w... | python | def _get_site(self, url, headers, cookies, timeout, driver_args, driver_kwargs):
"""
Try and return page content in the requested format using selenium
"""
try:
# **TODO**: Find what exception this will throw and catch it and call
# self.driver.execute_script("w... | [
"def",
"_get_site",
"(",
"self",
",",
"url",
",",
"headers",
",",
"cookies",
",",
"timeout",
",",
"driver_args",
",",
"driver_kwargs",
")",
":",
"try",
":",
"# **TODO**: Find what exception this will throw and catch it and call",
"# self.driver.execute_script(\"window.sto... | Try and return page content in the requested format using selenium | [
"Try",
"and",
"return",
"page",
"content",
"in",
"the",
"requested",
"format",
"using",
"selenium"
] | 2bfc63caa7d316564088951f01a490db493ea240 | https://github.com/xtream1101/web-wrapper/blob/2bfc63caa7d316564088951f01a490db493ea240/web_wrapper/selenium_utils.py#L63-L101 |
243,755 | delfick/aws_syncr | aws_syncr/option_spec/encryption_keys.py | EncryptionKeys.sync_one | def sync_one(self, aws_syncr, amazon, key):
"""Make sure this key is as defined"""
key_info = amazon.kms.key_info(key.name, key.location)
if not key_info:
amazon.kms.create_key(key.name, key.description, key.location, key.grant, key.policy.document)
else:
amazon.k... | python | def sync_one(self, aws_syncr, amazon, key):
"""Make sure this key is as defined"""
key_info = amazon.kms.key_info(key.name, key.location)
if not key_info:
amazon.kms.create_key(key.name, key.description, key.location, key.grant, key.policy.document)
else:
amazon.k... | [
"def",
"sync_one",
"(",
"self",
",",
"aws_syncr",
",",
"amazon",
",",
"key",
")",
":",
"key_info",
"=",
"amazon",
".",
"kms",
".",
"key_info",
"(",
"key",
".",
"name",
",",
"key",
".",
"location",
")",
"if",
"not",
"key_info",
":",
"amazon",
".",
"... | Make sure this key is as defined | [
"Make",
"sure",
"this",
"key",
"is",
"as",
"defined"
] | 8cd214b27c1eee98dfba4632cbb8bc0ae36356bd | https://github.com/delfick/aws_syncr/blob/8cd214b27c1eee98dfba4632cbb8bc0ae36356bd/aws_syncr/option_spec/encryption_keys.py#L50-L56 |
243,756 | collectiveacuity/labPack | labpack/storage/dropbox.py | dropboxClient._walk | def _walk(self, root_path=''):
''' an iterator method which walks the file structure of the dropbox collection '''
title = '%s._walk' % self.__class__.__name__
if root_path:
root_path = '/%s' % root_path
try:
response = self.dropbox.files_list_folder(path=ro... | python | def _walk(self, root_path=''):
''' an iterator method which walks the file structure of the dropbox collection '''
title = '%s._walk' % self.__class__.__name__
if root_path:
root_path = '/%s' % root_path
try:
response = self.dropbox.files_list_folder(path=ro... | [
"def",
"_walk",
"(",
"self",
",",
"root_path",
"=",
"''",
")",
":",
"title",
"=",
"'%s._walk'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"if",
"root_path",
":",
"root_path",
"=",
"'/%s'",
"%",
"root_path",
"try",
":",
"response",
"=",
"self",
".... | an iterator method which walks the file structure of the dropbox collection | [
"an",
"iterator",
"method",
"which",
"walks",
"the",
"file",
"structure",
"of",
"the",
"dropbox",
"collection"
] | 52949ece35e72e3cc308f54d9ffa6bfbd96805b8 | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/storage/dropbox.py#L277-L296 |
243,757 | edeposit/edeposit.amqp.ftp | src/edeposit/amqp/ftp/monitor.py | _read_stdin | def _read_stdin():
"""
Generator for reading from standard input in nonblocking mode.
Other ways of reading from ``stdin`` in python waits, until the buffer is
big enough, or until EOF character is sent.
This functions yields immediately after each line.
"""
line = sys.stdin.readline()
... | python | def _read_stdin():
"""
Generator for reading from standard input in nonblocking mode.
Other ways of reading from ``stdin`` in python waits, until the buffer is
big enough, or until EOF character is sent.
This functions yields immediately after each line.
"""
line = sys.stdin.readline()
... | [
"def",
"_read_stdin",
"(",
")",
":",
"line",
"=",
"sys",
".",
"stdin",
".",
"readline",
"(",
")",
"while",
"line",
":",
"yield",
"line",
"line",
"=",
"sys",
".",
"stdin",
".",
"readline",
"(",
")"
] | Generator for reading from standard input in nonblocking mode.
Other ways of reading from ``stdin`` in python waits, until the buffer is
big enough, or until EOF character is sent.
This functions yields immediately after each line. | [
"Generator",
"for",
"reading",
"from",
"standard",
"input",
"in",
"nonblocking",
"mode",
"."
] | fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71 | https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/monitor.py#L36-L48 |
243,758 | edeposit/edeposit.amqp.ftp | src/edeposit/amqp/ftp/monitor.py | _parse_line | def _parse_line(line):
"""
Convert one line from the extended log to dict.
Args:
line (str): Line which will be converted.
Returns:
dict: dict with ``timestamp``, ``command``, ``username`` and ``path`` \
keys.
Note:
Typical line looks like this::
... | python | def _parse_line(line):
"""
Convert one line from the extended log to dict.
Args:
line (str): Line which will be converted.
Returns:
dict: dict with ``timestamp``, ``command``, ``username`` and ``path`` \
keys.
Note:
Typical line looks like this::
... | [
"def",
"_parse_line",
"(",
"line",
")",
":",
"line",
",",
"timestamp",
"=",
"line",
".",
"rsplit",
"(",
"\",\"",
",",
"1",
")",
"line",
",",
"command",
"=",
"line",
".",
"rsplit",
"(",
"\",\"",
",",
"1",
")",
"path",
",",
"username",
"=",
"line",
... | Convert one line from the extended log to dict.
Args:
line (str): Line which will be converted.
Returns:
dict: dict with ``timestamp``, ``command``, ``username`` and ``path`` \
keys.
Note:
Typical line looks like this::
/home/ftp/xex/asd bsd.dat, xex, ST... | [
"Convert",
"one",
"line",
"from",
"the",
"extended",
"log",
"to",
"dict",
"."
] | fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71 | https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/monitor.py#L51-L79 |
243,759 | edeposit/edeposit.amqp.ftp | src/edeposit/amqp/ftp/monitor.py | process_log | def process_log(file_iterator):
"""
Process the extended ProFTPD log.
Args:
file_iterator (file): any file-like iterator for reading the log or
stdin (see :func:`_read_stdin`).
Yields:
ImportRequest: with each import.
"""
for line in file_iterator:... | python | def process_log(file_iterator):
"""
Process the extended ProFTPD log.
Args:
file_iterator (file): any file-like iterator for reading the log or
stdin (see :func:`_read_stdin`).
Yields:
ImportRequest: with each import.
"""
for line in file_iterator:... | [
"def",
"process_log",
"(",
"file_iterator",
")",
":",
"for",
"line",
"in",
"file_iterator",
":",
"if",
"\",\"",
"not",
"in",
"line",
":",
"continue",
"parsed",
"=",
"_parse_line",
"(",
"line",
")",
"if",
"not",
"parsed",
"[",
"\"command\"",
"]",
".",
"up... | Process the extended ProFTPD log.
Args:
file_iterator (file): any file-like iterator for reading the log or
stdin (see :func:`_read_stdin`).
Yields:
ImportRequest: with each import. | [
"Process",
"the",
"extended",
"ProFTPD",
"log",
"."
] | fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71 | https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/monitor.py#L82-L130 |
243,760 | edeposit/edeposit.amqp.ftp | src/edeposit/amqp/ftp/monitor.py | main | def main(filename):
"""
Open `filename` and start processing it line by line. If `filename` is
none, process lines from `stdin`.
"""
if filename:
if not os.path.exists(filename):
logger.error("'%s' doesn't exists!" % filename)
sys.stderr.write("'%s' doesn't exists!\n"... | python | def main(filename):
"""
Open `filename` and start processing it line by line. If `filename` is
none, process lines from `stdin`.
"""
if filename:
if not os.path.exists(filename):
logger.error("'%s' doesn't exists!" % filename)
sys.stderr.write("'%s' doesn't exists!\n"... | [
"def",
"main",
"(",
"filename",
")",
":",
"if",
"filename",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"filename",
")",
":",
"logger",
".",
"error",
"(",
"\"'%s' doesn't exists!\"",
"%",
"filename",
")",
"sys",
".",
"stderr",
".",
"write"... | Open `filename` and start processing it line by line. If `filename` is
none, process lines from `stdin`. | [
"Open",
"filename",
"and",
"start",
"processing",
"it",
"line",
"by",
"line",
".",
"If",
"filename",
"is",
"none",
"process",
"lines",
"from",
"stdin",
"."
] | fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71 | https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/monitor.py#L133-L150 |
243,761 | sassoo/goldman | goldman/serializers/base.py | Serializer.serialize | def serialize(self, data):
""" Invoke the serializer
These are common things for all serializers. Mostly,
stuff to do with managing headers. The data passed
in may not be reliable for much of anything.
Conditionally, set the Content-Type header unless it
has already bee... | python | def serialize(self, data):
""" Invoke the serializer
These are common things for all serializers. Mostly,
stuff to do with managing headers. The data passed
in may not be reliable for much of anything.
Conditionally, set the Content-Type header unless it
has already bee... | [
"def",
"serialize",
"(",
"self",
",",
"data",
")",
":",
"if",
"not",
"self",
".",
"resp",
".",
"content_type",
":",
"self",
".",
"resp",
".",
"set_header",
"(",
"'Content-Type'",
",",
"getattr",
"(",
"self",
",",
"'MIMETYPE'",
")",
")"
] | Invoke the serializer
These are common things for all serializers. Mostly,
stuff to do with managing headers. The data passed
in may not be reliable for much of anything.
Conditionally, set the Content-Type header unless it
has already been set. | [
"Invoke",
"the",
"serializer"
] | b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2 | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/serializers/base.py#L21-L33 |
243,762 | TC01/calcpkg | calcrepo/info.py | FileInfo.printData | def printData(self, output = sys.stdout):
"""Output all the file data to be written to any writable output"""
self.printDatum("Name : ", self.fileName, output)
self.printDatum("Author : ", self.author, output)
self.printDatum("Repository : ", self.repository, output)
self.printDatum("Catego... | python | def printData(self, output = sys.stdout):
"""Output all the file data to be written to any writable output"""
self.printDatum("Name : ", self.fileName, output)
self.printDatum("Author : ", self.author, output)
self.printDatum("Repository : ", self.repository, output)
self.printDatum("Catego... | [
"def",
"printData",
"(",
"self",
",",
"output",
"=",
"sys",
".",
"stdout",
")",
":",
"self",
".",
"printDatum",
"(",
"\"Name : \"",
",",
"self",
".",
"fileName",
",",
"output",
")",
"self",
".",
"printDatum",
"(",
"\"Author : \"",
",",
"sel... | Output all the file data to be written to any writable output | [
"Output",
"all",
"the",
"file",
"data",
"to",
"be",
"written",
"to",
"any",
"writable",
"output"
] | 5168f606264620a090b42a64354331d208b00d5f | https://github.com/TC01/calcpkg/blob/5168f606264620a090b42a64354331d208b00d5f/calcrepo/info.py#L58-L71 |
243,763 | ronaldguillen/wave | wave/serializers.py | raise_errors_on_nested_writes | def raise_errors_on_nested_writes(method_name, serializer, validated_data):
"""
Give explicit errors when users attempt to pass writable nested data.
If we don't do this explicitly they'd get a less helpful error when
calling `.save()` on the serializer.
We don't *automatically* support these sort... | python | def raise_errors_on_nested_writes(method_name, serializer, validated_data):
"""
Give explicit errors when users attempt to pass writable nested data.
If we don't do this explicitly they'd get a less helpful error when
calling `.save()` on the serializer.
We don't *automatically* support these sort... | [
"def",
"raise_errors_on_nested_writes",
"(",
"method_name",
",",
"serializer",
",",
"validated_data",
")",
":",
"# Ensure we don't have a writable nested field. For example:",
"#",
"# class UserSerializer(ModelSerializer):",
"# ...",
"# profile = ProfileSerializer()",
"assert",... | Give explicit errors when users attempt to pass writable nested data.
If we don't do this explicitly they'd get a less helpful error when
calling `.save()` on the serializer.
We don't *automatically* support these sorts of nested writes because
there are too many ambiguities to define a default behavi... | [
"Give",
"explicit",
"errors",
"when",
"users",
"attempt",
"to",
"pass",
"writable",
"nested",
"data",
"."
] | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/serializers.py#L688-L747 |
243,764 | ronaldguillen/wave | wave/serializers.py | BaseSerializer.many_init | def many_init(cls, *args, **kwargs):
"""
This method implements the creation of a `ListSerializer` parent
class when `many=True` is used. You can customize it if you need to
control which keyword arguments are passed to the parent, and
which are passed to the child.
Note... | python | def many_init(cls, *args, **kwargs):
"""
This method implements the creation of a `ListSerializer` parent
class when `many=True` is used. You can customize it if you need to
control which keyword arguments are passed to the parent, and
which are passed to the child.
Note... | [
"def",
"many_init",
"(",
"cls",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"allow_empty",
"=",
"kwargs",
".",
"pop",
"(",
"'allow_empty'",
",",
"None",
")",
"child_serializer",
"=",
"cls",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"... | This method implements the creation of a `ListSerializer` parent
class when `many=True` is used. You can customize it if you need to
control which keyword arguments are passed to the parent, and
which are passed to the child.
Note that we're over-cautious in passing most arguments to bo... | [
"This",
"method",
"implements",
"the",
"creation",
"of",
"a",
"ListSerializer",
"parent",
"class",
"when",
"many",
"=",
"True",
"is",
"used",
".",
"You",
"can",
"customize",
"it",
"if",
"you",
"need",
"to",
"control",
"which",
"keyword",
"arguments",
"are",
... | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/serializers.py#L105-L134 |
243,765 | ronaldguillen/wave | wave/serializers.py | ListSerializer.get_value | def get_value(self, dictionary):
"""
Given the input dictionary, return the field value.
"""
# We override the default field access in order to support
# lists in HTML forms.
if html.is_html_input(dictionary):
return html.parse_html_list(dictionary, prefix=sel... | python | def get_value(self, dictionary):
"""
Given the input dictionary, return the field value.
"""
# We override the default field access in order to support
# lists in HTML forms.
if html.is_html_input(dictionary):
return html.parse_html_list(dictionary, prefix=sel... | [
"def",
"get_value",
"(",
"self",
",",
"dictionary",
")",
":",
"# We override the default field access in order to support",
"# lists in HTML forms.",
"if",
"html",
".",
"is_html_input",
"(",
"dictionary",
")",
":",
"return",
"html",
".",
"parse_html_list",
"(",
"diction... | Given the input dictionary, return the field value. | [
"Given",
"the",
"input",
"dictionary",
"return",
"the",
"field",
"value",
"."
] | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/serializers.py#L537-L545 |
243,766 | ronaldguillen/wave | wave/serializers.py | ModelSerializer.get_field_names | def get_field_names(self, declared_fields, info):
"""
Returns the list of all field names that should be created when
instantiating this serializer class. This is based on the default
set of fields, but also takes into account the `Meta.fields` or
`Meta.exclude` options if they h... | python | def get_field_names(self, declared_fields, info):
"""
Returns the list of all field names that should be created when
instantiating this serializer class. This is based on the default
set of fields, but also takes into account the `Meta.fields` or
`Meta.exclude` options if they h... | [
"def",
"get_field_names",
"(",
"self",
",",
"declared_fields",
",",
"info",
")",
":",
"fields",
"=",
"getattr",
"(",
"self",
".",
"Meta",
",",
"'fields'",
",",
"None",
")",
"exclude",
"=",
"getattr",
"(",
"self",
".",
"Meta",
",",
"'exclude'",
",",
"No... | Returns the list of all field names that should be created when
instantiating this serializer class. This is based on the default
set of fields, but also takes into account the `Meta.fields` or
`Meta.exclude` options if they have been specified. | [
"Returns",
"the",
"list",
"of",
"all",
"field",
"names",
"that",
"should",
"be",
"created",
"when",
"instantiating",
"this",
"serializer",
"class",
".",
"This",
"is",
"based",
"on",
"the",
"default",
"set",
"of",
"fields",
"but",
"also",
"takes",
"into",
"... | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/serializers.py#L958-L1039 |
243,767 | ronaldguillen/wave | wave/serializers.py | ModelSerializer.build_standard_field | def build_standard_field(self, field_name, model_field):
"""
Create regular model fields.
"""
field_mapping = ClassLookupDict(self.serializer_field_mapping)
field_class = field_mapping[model_field]
field_kwargs = get_field_kwargs(field_name, model_field)
if 'cho... | python | def build_standard_field(self, field_name, model_field):
"""
Create regular model fields.
"""
field_mapping = ClassLookupDict(self.serializer_field_mapping)
field_class = field_mapping[model_field]
field_kwargs = get_field_kwargs(field_name, model_field)
if 'cho... | [
"def",
"build_standard_field",
"(",
"self",
",",
"field_name",
",",
"model_field",
")",
":",
"field_mapping",
"=",
"ClassLookupDict",
"(",
"self",
".",
"serializer_field_mapping",
")",
"field_class",
"=",
"field_mapping",
"[",
"model_field",
"]",
"field_kwargs",
"="... | Create regular model fields. | [
"Create",
"regular",
"model",
"fields",
"."
] | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/serializers.py#L1078-L1124 |
243,768 | ronaldguillen/wave | wave/serializers.py | ModelSerializer.build_relational_field | def build_relational_field(self, field_name, relation_info):
"""
Create fields for forward and reverse relationships.
"""
field_class = self.serializer_related_field
field_kwargs = get_relation_kwargs(field_name, relation_info)
to_field = field_kwargs.pop('to_field', Non... | python | def build_relational_field(self, field_name, relation_info):
"""
Create fields for forward and reverse relationships.
"""
field_class = self.serializer_related_field
field_kwargs = get_relation_kwargs(field_name, relation_info)
to_field = field_kwargs.pop('to_field', Non... | [
"def",
"build_relational_field",
"(",
"self",
",",
"field_name",
",",
"relation_info",
")",
":",
"field_class",
"=",
"self",
".",
"serializer_related_field",
"field_kwargs",
"=",
"get_relation_kwargs",
"(",
"field_name",
",",
"relation_info",
")",
"to_field",
"=",
"... | Create fields for forward and reverse relationships. | [
"Create",
"fields",
"for",
"forward",
"and",
"reverse",
"relationships",
"."
] | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/serializers.py#L1126-L1142 |
243,769 | ronaldguillen/wave | wave/serializers.py | ModelSerializer.include_extra_kwargs | def include_extra_kwargs(self, kwargs, extra_kwargs):
"""
Include any 'extra_kwargs' that have been included for this field,
possibly removing any incompatible existing keyword arguments.
"""
if extra_kwargs.get('read_only', False):
for attr in [
'requ... | python | def include_extra_kwargs(self, kwargs, extra_kwargs):
"""
Include any 'extra_kwargs' that have been included for this field,
possibly removing any incompatible existing keyword arguments.
"""
if extra_kwargs.get('read_only', False):
for attr in [
'requ... | [
"def",
"include_extra_kwargs",
"(",
"self",
",",
"kwargs",
",",
"extra_kwargs",
")",
":",
"if",
"extra_kwargs",
".",
"get",
"(",
"'read_only'",
",",
"False",
")",
":",
"for",
"attr",
"in",
"[",
"'required'",
",",
"'default'",
",",
"'allow_blank'",
",",
"'a... | Include any 'extra_kwargs' that have been included for this field,
possibly removing any incompatible existing keyword arguments. | [
"Include",
"any",
"extra_kwargs",
"that",
"have",
"been",
"included",
"for",
"this",
"field",
"possibly",
"removing",
"any",
"incompatible",
"existing",
"keyword",
"arguments",
"."
] | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/serializers.py#L1185-L1206 |
243,770 | ronaldguillen/wave | wave/serializers.py | ModelSerializer.get_extra_kwargs | def get_extra_kwargs(self):
"""
Return a dictionary mapping field names to a dictionary of
additional keyword arguments.
"""
extra_kwargs = getattr(self.Meta, 'extra_kwargs', {})
read_only_fields = getattr(self.Meta, 'read_only_fields', None)
if read_only_fields ... | python | def get_extra_kwargs(self):
"""
Return a dictionary mapping field names to a dictionary of
additional keyword arguments.
"""
extra_kwargs = getattr(self.Meta, 'extra_kwargs', {})
read_only_fields = getattr(self.Meta, 'read_only_fields', None)
if read_only_fields ... | [
"def",
"get_extra_kwargs",
"(",
"self",
")",
":",
"extra_kwargs",
"=",
"getattr",
"(",
"self",
".",
"Meta",
",",
"'extra_kwargs'",
",",
"{",
"}",
")",
"read_only_fields",
"=",
"getattr",
"(",
"self",
".",
"Meta",
",",
"'read_only_fields'",
",",
"None",
")"... | Return a dictionary mapping field names to a dictionary of
additional keyword arguments. | [
"Return",
"a",
"dictionary",
"mapping",
"field",
"names",
"to",
"a",
"dictionary",
"of",
"additional",
"keyword",
"arguments",
"."
] | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/serializers.py#L1210-L1224 |
243,771 | ronaldguillen/wave | wave/serializers.py | ModelSerializer._get_model_fields | def _get_model_fields(self, field_names, declared_fields, extra_kwargs):
"""
Returns all the model fields that are being mapped to by fields
on the serializer class.
Returned as a dict of 'model field name' -> 'model field'.
Used internally by `get_uniqueness_field_options`.
... | python | def _get_model_fields(self, field_names, declared_fields, extra_kwargs):
"""
Returns all the model fields that are being mapped to by fields
on the serializer class.
Returned as a dict of 'model field name' -> 'model field'.
Used internally by `get_uniqueness_field_options`.
... | [
"def",
"_get_model_fields",
"(",
"self",
",",
"field_names",
",",
"declared_fields",
",",
"extra_kwargs",
")",
":",
"model",
"=",
"getattr",
"(",
"self",
".",
"Meta",
",",
"'model'",
")",
"model_fields",
"=",
"{",
"}",
"for",
"field_name",
"in",
"field_names... | Returns all the model fields that are being mapped to by fields
on the serializer class.
Returned as a dict of 'model field name' -> 'model field'.
Used internally by `get_uniqueness_field_options`. | [
"Returns",
"all",
"the",
"model",
"fields",
"that",
"are",
"being",
"mapped",
"to",
"by",
"fields",
"on",
"the",
"serializer",
"class",
".",
"Returned",
"as",
"a",
"dict",
"of",
"model",
"field",
"name",
"-",
">",
"model",
"field",
".",
"Used",
"internal... | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/serializers.py#L1298-L1331 |
243,772 | ronaldguillen/wave | wave/serializers.py | ModelSerializer.get_validators | def get_validators(self):
"""
Determine the set of validators to use when instantiating serializer.
"""
# If the validators have been declared explicitly then use that.
validators = getattr(getattr(self, 'Meta', None), 'validators', None)
if validators is not None:
... | python | def get_validators(self):
"""
Determine the set of validators to use when instantiating serializer.
"""
# If the validators have been declared explicitly then use that.
validators = getattr(getattr(self, 'Meta', None), 'validators', None)
if validators is not None:
... | [
"def",
"get_validators",
"(",
"self",
")",
":",
"# If the validators have been declared explicitly then use that.",
"validators",
"=",
"getattr",
"(",
"getattr",
"(",
"self",
",",
"'Meta'",
",",
"None",
")",
",",
"'validators'",
",",
"None",
")",
"if",
"validators",... | Determine the set of validators to use when instantiating serializer. | [
"Determine",
"the",
"set",
"of",
"validators",
"to",
"use",
"when",
"instantiating",
"serializer",
"."
] | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/serializers.py#L1335-L1348 |
243,773 | ronaldguillen/wave | wave/serializers.py | ModelSerializer.get_unique_together_validators | def get_unique_together_validators(self):
"""
Determine a default set of validators for any unique_together contraints.
"""
model_class_inheritance_tree = (
[self.Meta.model] +
list(self.Meta.model._meta.parents.keys())
)
# The field names we're p... | python | def get_unique_together_validators(self):
"""
Determine a default set of validators for any unique_together contraints.
"""
model_class_inheritance_tree = (
[self.Meta.model] +
list(self.Meta.model._meta.parents.keys())
)
# The field names we're p... | [
"def",
"get_unique_together_validators",
"(",
"self",
")",
":",
"model_class_inheritance_tree",
"=",
"(",
"[",
"self",
".",
"Meta",
".",
"model",
"]",
"+",
"list",
"(",
"self",
".",
"Meta",
".",
"model",
".",
"_meta",
".",
"parents",
".",
"keys",
"(",
")... | Determine a default set of validators for any unique_together contraints. | [
"Determine",
"a",
"default",
"set",
"of",
"validators",
"for",
"any",
"unique_together",
"contraints",
"."
] | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/serializers.py#L1350-L1379 |
243,774 | ronaldguillen/wave | wave/serializers.py | HyperlinkedModelSerializer.build_nested_field | def build_nested_field(self, field_name, relation_info, nested_depth):
"""
Create nested fields for forward and reverse relationships.
"""
class NestedSerializer(HyperlinkedModelSerializer):
class Meta:
model = relation_info.related_model
depth... | python | def build_nested_field(self, field_name, relation_info, nested_depth):
"""
Create nested fields for forward and reverse relationships.
"""
class NestedSerializer(HyperlinkedModelSerializer):
class Meta:
model = relation_info.related_model
depth... | [
"def",
"build_nested_field",
"(",
"self",
",",
"field_name",
",",
"relation_info",
",",
"nested_depth",
")",
":",
"class",
"NestedSerializer",
"(",
"HyperlinkedModelSerializer",
")",
":",
"class",
"Meta",
":",
"model",
"=",
"relation_info",
".",
"related_model",
"... | Create nested fields for forward and reverse relationships. | [
"Create",
"nested",
"fields",
"for",
"forward",
"and",
"reverse",
"relationships",
"."
] | 20bb979c917f7634d8257992e6d449dc751256a9 | https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/serializers.py#L1460-L1472 |
243,775 | bfontaine/p7magma | magma/session.py | Session.get_url | def get_url(self, url):
"""
Get an absolute URL from a given one.
"""
if url.startswith('/'):
url = '%s%s' % (self.base_url, url)
return url | python | def get_url(self, url):
"""
Get an absolute URL from a given one.
"""
if url.startswith('/'):
url = '%s%s' % (self.base_url, url)
return url | [
"def",
"get_url",
"(",
"self",
",",
"url",
")",
":",
"if",
"url",
".",
"startswith",
"(",
"'/'",
")",
":",
"url",
"=",
"'%s%s'",
"%",
"(",
"self",
".",
"base_url",
",",
"url",
")",
"return",
"url"
] | Get an absolute URL from a given one. | [
"Get",
"an",
"absolute",
"URL",
"from",
"a",
"given",
"one",
"."
] | 713647aa9e3187c93c2577ef812f33ec42ae5494 | https://github.com/bfontaine/p7magma/blob/713647aa9e3187c93c2577ef812f33ec42ae5494/magma/session.py#L57-L63 |
243,776 | bfontaine/p7magma | magma/session.py | Session.get_soup | def get_soup(self, *args, **kwargs):
"""
Shortcut for ``get`` which returns a ``BeautifulSoup`` element
"""
return BeautifulSoup(self.get(*args, **kwargs).text) | python | def get_soup(self, *args, **kwargs):
"""
Shortcut for ``get`` which returns a ``BeautifulSoup`` element
"""
return BeautifulSoup(self.get(*args, **kwargs).text) | [
"def",
"get_soup",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"BeautifulSoup",
"(",
"self",
".",
"get",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
".",
"text",
")"
] | Shortcut for ``get`` which returns a ``BeautifulSoup`` element | [
"Shortcut",
"for",
"get",
"which",
"returns",
"a",
"BeautifulSoup",
"element"
] | 713647aa9e3187c93c2577ef812f33ec42ae5494 | https://github.com/bfontaine/p7magma/blob/713647aa9e3187c93c2577ef812f33ec42ae5494/magma/session.py#L73-L77 |
243,777 | bfontaine/p7magma | magma/session.py | Session.post_soup | def post_soup(self, *args, **kwargs):
"""
Shortcut for ``post`` which returns a ``BeautifulSoup`` element
"""
return BeautifulSoup(self.post(*args, **kwargs).text) | python | def post_soup(self, *args, **kwargs):
"""
Shortcut for ``post`` which returns a ``BeautifulSoup`` element
"""
return BeautifulSoup(self.post(*args, **kwargs).text) | [
"def",
"post_soup",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"BeautifulSoup",
"(",
"self",
".",
"post",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
".",
"text",
")"
] | Shortcut for ``post`` which returns a ``BeautifulSoup`` element | [
"Shortcut",
"for",
"post",
"which",
"returns",
"a",
"BeautifulSoup",
"element"
] | 713647aa9e3187c93c2577ef812f33ec42ae5494 | https://github.com/bfontaine/p7magma/blob/713647aa9e3187c93c2577ef812f33ec42ae5494/magma/session.py#L79-L83 |
243,778 | bfontaine/p7magma | magma/session.py | Session.get_results_soup | def get_results_soup(self, year=None):
"""
``get_soup`` on the results page. The page URL depends on the year.
"""
if year is None:
year = self.year
year = YEARS.get(year, year)
return self.get_soup(URLS['results'][year]) | python | def get_results_soup(self, year=None):
"""
``get_soup`` on the results page. The page URL depends on the year.
"""
if year is None:
year = self.year
year = YEARS.get(year, year)
return self.get_soup(URLS['results'][year]) | [
"def",
"get_results_soup",
"(",
"self",
",",
"year",
"=",
"None",
")",
":",
"if",
"year",
"is",
"None",
":",
"year",
"=",
"self",
".",
"year",
"year",
"=",
"YEARS",
".",
"get",
"(",
"year",
",",
"year",
")",
"return",
"self",
".",
"get_soup",
"(",
... | ``get_soup`` on the results page. The page URL depends on the year. | [
"get_soup",
"on",
"the",
"results",
"page",
".",
"The",
"page",
"URL",
"depends",
"on",
"the",
"year",
"."
] | 713647aa9e3187c93c2577ef812f33ec42ae5494 | https://github.com/bfontaine/p7magma/blob/713647aa9e3187c93c2577ef812f33ec42ae5494/magma/session.py#L85-L93 |
243,779 | bfontaine/p7magma | magma/session.py | Session.login | def login(self, year, firstname, lastname, passwd, with_year=True):
"""
Authenticate an user
"""
firstname = firstname.upper()
lastname = lastname.upper()
if with_year and not self.set_year(year):
return False
url = URLS['login']
params = {
... | python | def login(self, year, firstname, lastname, passwd, with_year=True):
"""
Authenticate an user
"""
firstname = firstname.upper()
lastname = lastname.upper()
if with_year and not self.set_year(year):
return False
url = URLS['login']
params = {
... | [
"def",
"login",
"(",
"self",
",",
"year",
",",
"firstname",
",",
"lastname",
",",
"passwd",
",",
"with_year",
"=",
"True",
")",
":",
"firstname",
"=",
"firstname",
".",
"upper",
"(",
")",
"lastname",
"=",
"lastname",
".",
"upper",
"(",
")",
"if",
"wi... | Authenticate an user | [
"Authenticate",
"an",
"user"
] | 713647aa9e3187c93c2577ef812f33ec42ae5494 | https://github.com/bfontaine/p7magma/blob/713647aa9e3187c93c2577ef812f33ec42ae5494/magma/session.py#L95-L114 |
243,780 | bfontaine/p7magma | magma/session.py | Session.set_year | def set_year(self, year):
"""
Set an user's year. This is required on magma just before the login.
It's called by default by ``login``.
"""
self.year = YEARS.get(year, year)
data = {'idCursus': self.year}
soup = self.post_soup('/~etudiant/login.php', data=data)
... | python | def set_year(self, year):
"""
Set an user's year. This is required on magma just before the login.
It's called by default by ``login``.
"""
self.year = YEARS.get(year, year)
data = {'idCursus': self.year}
soup = self.post_soup('/~etudiant/login.php', data=data)
... | [
"def",
"set_year",
"(",
"self",
",",
"year",
")",
":",
"self",
".",
"year",
"=",
"YEARS",
".",
"get",
"(",
"year",
",",
"year",
")",
"data",
"=",
"{",
"'idCursus'",
":",
"self",
".",
"year",
"}",
"soup",
"=",
"self",
".",
"post_soup",
"(",
"'/~et... | Set an user's year. This is required on magma just before the login.
It's called by default by ``login``. | [
"Set",
"an",
"user",
"s",
"year",
".",
"This",
"is",
"required",
"on",
"magma",
"just",
"before",
"the",
"login",
".",
"It",
"s",
"called",
"by",
"default",
"by",
"login",
"."
] | 713647aa9e3187c93c2577ef812f33ec42ae5494 | https://github.com/bfontaine/p7magma/blob/713647aa9e3187c93c2577ef812f33ec42ae5494/magma/session.py#L122-L130 |
243,781 | xaptum/xtt-python | xtt/exceptions.py | _build_return_code_enum | def _build_return_code_enum():
"""
Creates an IntEnum containing all the XTT return codes.
Finds all return codes by scanning the FFI for items whose names match
the pattern "XTT_RETURN_<X>". The name of the result enum value is the
suffix "<X>".
"""
prefix = 'XTT_RETURN_'
codes = {k[l... | python | def _build_return_code_enum():
"""
Creates an IntEnum containing all the XTT return codes.
Finds all return codes by scanning the FFI for items whose names match
the pattern "XTT_RETURN_<X>". The name of the result enum value is the
suffix "<X>".
"""
prefix = 'XTT_RETURN_'
codes = {k[l... | [
"def",
"_build_return_code_enum",
"(",
")",
":",
"prefix",
"=",
"'XTT_RETURN_'",
"codes",
"=",
"{",
"k",
"[",
"len",
"(",
"prefix",
")",
":",
"]",
":",
"v",
"for",
"(",
"k",
",",
"v",
")",
"in",
"vars",
"(",
"_lib",
")",
".",
"items",
"(",
")",
... | Creates an IntEnum containing all the XTT return codes.
Finds all return codes by scanning the FFI for items whose names match
the pattern "XTT_RETURN_<X>". The name of the result enum value is the
suffix "<X>". | [
"Creates",
"an",
"IntEnum",
"containing",
"all",
"the",
"XTT",
"return",
"codes",
"."
] | 23ee469488d710d730314bec1136c4dd7ac2cd5c | https://github.com/xaptum/xtt-python/blob/23ee469488d710d730314bec1136c4dd7ac2cd5c/xtt/exceptions.py#L33-L43 |
243,782 | 20c/twentyc.database | twentyc/database/base.py | Client | def Client(engine="couchbase", host="", auth="", database="", logger=None, verbose=True):
"""
Return new database client
Arguments
engine <str> defines which engine to use, currently supports "couchdb" and "couchbase"
host <str|couchdb.Server> host url, when using couchdb this can also be a server instan... | python | def Client(engine="couchbase", host="", auth="", database="", logger=None, verbose=True):
"""
Return new database client
Arguments
engine <str> defines which engine to use, currently supports "couchdb" and "couchbase"
host <str|couchdb.Server> host url, when using couchdb this can also be a server instan... | [
"def",
"Client",
"(",
"engine",
"=",
"\"couchbase\"",
",",
"host",
"=",
"\"\"",
",",
"auth",
"=",
"\"\"",
",",
"database",
"=",
"\"\"",
",",
"logger",
"=",
"None",
",",
"verbose",
"=",
"True",
")",
":",
"if",
"engine",
"==",
"\"couchbase\"",
":",
"fr... | Return new database client
Arguments
engine <str> defines which engine to use, currently supports "couchdb" and "couchbase"
host <str|couchdb.Server> host url, when using couchdb this can also be a server instance
auth <str> bucket_auth for couchbase, auth for couchdb
database <str> database name for couchd... | [
"Return",
"new",
"database",
"client"
] | c6b7184d66dddafb306c94c4f98234bef1df1291 | https://github.com/20c/twentyc.database/blob/c6b7184d66dddafb306c94c4f98234bef1df1291/twentyc/database/base.py#L8-L36 |
243,783 | sassoo/goldman | goldman/serializers/jsonapi.py | Serializer._serialize_data | def _serialize_data(self, data):
""" Turn the data into a JSON API compliant resource object
WARN: This function has both side effects & a return.
It's complete shit because it mutates data &
yet returns a new doc. FIX.
:spec:
jsonapi.org/format/#documen... | python | def _serialize_data(self, data):
""" Turn the data into a JSON API compliant resource object
WARN: This function has both side effects & a return.
It's complete shit because it mutates data &
yet returns a new doc. FIX.
:spec:
jsonapi.org/format/#documen... | [
"def",
"_serialize_data",
"(",
"self",
",",
"data",
")",
":",
"rels",
"=",
"{",
"}",
"rlink",
"=",
"rid_url",
"(",
"data",
"[",
"'rtype'",
"]",
",",
"data",
"[",
"'rid'",
"]",
")",
"doc",
"=",
"{",
"'id'",
":",
"data",
".",
"pop",
"(",
"'rid'",
... | Turn the data into a JSON API compliant resource object
WARN: This function has both side effects & a return.
It's complete shit because it mutates data &
yet returns a new doc. FIX.
:spec:
jsonapi.org/format/#document-resource-objects
:param data:
... | [
"Turn",
"the",
"data",
"into",
"a",
"JSON",
"API",
"compliant",
"resource",
"object"
] | b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2 | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/serializers/jsonapi.py#L78-L117 |
243,784 | sassoo/goldman | goldman/serializers/jsonapi.py | Serializer._serialize_pages | def _serialize_pages(self):
""" Return a JSON API compliant pagination links section
If the paginator has a value for a given link then this
method will also add the same links to the response
objects `link` header according to the guidance of
RFC 5988.
Falcon has a nat... | python | def _serialize_pages(self):
""" Return a JSON API compliant pagination links section
If the paginator has a value for a given link then this
method will also add the same links to the response
objects `link` header according to the guidance of
RFC 5988.
Falcon has a nat... | [
"def",
"_serialize_pages",
"(",
"self",
")",
":",
"pages",
"=",
"self",
".",
"req",
".",
"pages",
".",
"to_dict",
"(",
")",
"links",
"=",
"{",
"}",
"for",
"key",
",",
"val",
"in",
"pages",
".",
"items",
"(",
")",
":",
"if",
"val",
":",
"params",
... | Return a JSON API compliant pagination links section
If the paginator has a value for a given link then this
method will also add the same links to the response
objects `link` header according to the guidance of
RFC 5988.
Falcon has a native add_link helper for forming the
... | [
"Return",
"a",
"JSON",
"API",
"compliant",
"pagination",
"links",
"section"
] | b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2 | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/serializers/jsonapi.py#L119-L145 |
243,785 | sassoo/goldman | goldman/serializers/jsonapi.py | Serializer._serialize_to_many | def _serialize_to_many(self, key, vals, rlink):
""" Make a to_many JSON API compliant
:spec:
jsonapi.org/format/#document-resource-object-relationships
:param key:
the string name of the relationship field
:param vals:
array of dict's containing `rid`... | python | def _serialize_to_many(self, key, vals, rlink):
""" Make a to_many JSON API compliant
:spec:
jsonapi.org/format/#document-resource-object-relationships
:param key:
the string name of the relationship field
:param vals:
array of dict's containing `rid`... | [
"def",
"_serialize_to_many",
"(",
"self",
",",
"key",
",",
"vals",
",",
"rlink",
")",
":",
"rel",
"=",
"{",
"key",
":",
"{",
"'data'",
":",
"[",
"]",
",",
"'links'",
":",
"{",
"'related'",
":",
"rlink",
"+",
"'/'",
"+",
"key",
"}",
"}",
"}",
"t... | Make a to_many JSON API compliant
:spec:
jsonapi.org/format/#document-resource-object-relationships
:param key:
the string name of the relationship field
:param vals:
array of dict's containing `rid` & `rtype` keys for the
to_many, empty array if ... | [
"Make",
"a",
"to_many",
"JSON",
"API",
"compliant"
] | b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2 | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/serializers/jsonapi.py#L147-L180 |
243,786 | sassoo/goldman | goldman/serializers/jsonapi.py | Serializer._serialize_to_one | def _serialize_to_one(self, key, val, rlink):
""" Make a to_one JSON API compliant
:spec:
jsonapi.org/format/#document-resource-object-relationships
:param key:
the string name of the relationship field
:param val:
dict containing `rid` & `rtype` keys... | python | def _serialize_to_one(self, key, val, rlink):
""" Make a to_one JSON API compliant
:spec:
jsonapi.org/format/#document-resource-object-relationships
:param key:
the string name of the relationship field
:param val:
dict containing `rid` & `rtype` keys... | [
"def",
"_serialize_to_one",
"(",
"self",
",",
"key",
",",
"val",
",",
"rlink",
")",
":",
"data",
"=",
"None",
"if",
"val",
"and",
"val",
"[",
"'rid'",
"]",
":",
"data",
"=",
"{",
"'id'",
":",
"val",
"[",
"'rid'",
"]",
",",
"'type'",
":",
"val",
... | Make a to_one JSON API compliant
:spec:
jsonapi.org/format/#document-resource-object-relationships
:param key:
the string name of the relationship field
:param val:
dict containing `rid` & `rtype` keys for the to_one &
None if the to_one is null
... | [
"Make",
"a",
"to_one",
"JSON",
"API",
"compliant"
] | b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2 | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/serializers/jsonapi.py#L182-L207 |
243,787 | sassoo/goldman | goldman/validators/__init__.py | validate_uuid | def validate_uuid(value):
""" UUID 128-bit validator """
if value and not isinstance(value, UUID):
try:
return UUID(str(value), version=4)
except (AttributeError, ValueError):
raise ValidationError('not a valid UUID')
return value | python | def validate_uuid(value):
""" UUID 128-bit validator """
if value and not isinstance(value, UUID):
try:
return UUID(str(value), version=4)
except (AttributeError, ValueError):
raise ValidationError('not a valid UUID')
return value | [
"def",
"validate_uuid",
"(",
"value",
")",
":",
"if",
"value",
"and",
"not",
"isinstance",
"(",
"value",
",",
"UUID",
")",
":",
"try",
":",
"return",
"UUID",
"(",
"str",
"(",
"value",
")",
",",
"version",
"=",
"4",
")",
"except",
"(",
"AttributeError... | UUID 128-bit validator | [
"UUID",
"128",
"-",
"bit",
"validator"
] | b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2 | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/validators/__init__.py#L24-L32 |
243,788 | pybel/pybel-artifactory | src/pybel_artifactory/utils.py | get_namespace_url | def get_namespace_url(module, version):
"""Get a BEL namespace file from Artifactory given the name and version.
:param str module:
:param str version:
:type: str
"""
module = module.strip('/')
return '{module}/{name}'.format(
module=get_namespace_module_url(module),
name=g... | python | def get_namespace_url(module, version):
"""Get a BEL namespace file from Artifactory given the name and version.
:param str module:
:param str version:
:type: str
"""
module = module.strip('/')
return '{module}/{name}'.format(
module=get_namespace_module_url(module),
name=g... | [
"def",
"get_namespace_url",
"(",
"module",
",",
"version",
")",
":",
"module",
"=",
"module",
".",
"strip",
"(",
"'/'",
")",
"return",
"'{module}/{name}'",
".",
"format",
"(",
"module",
"=",
"get_namespace_module_url",
"(",
"module",
")",
",",
"name",
"=",
... | Get a BEL namespace file from Artifactory given the name and version.
:param str module:
:param str version:
:type: str | [
"Get",
"a",
"BEL",
"namespace",
"file",
"from",
"Artifactory",
"given",
"the",
"name",
"and",
"version",
"."
] | 720107780a59be2ef08885290dfa519b1da62871 | https://github.com/pybel/pybel-artifactory/blob/720107780a59be2ef08885290dfa519b1da62871/src/pybel_artifactory/utils.py#L20-L32 |
243,789 | pybel/pybel-artifactory | src/pybel_artifactory/utils.py | get_annotation_url | def get_annotation_url(module, version):
"""Get a BEL annotation file from artifactory given the name and version.
:param str module:
:param str version:
:type: str
"""
module = module.strip('/')
return '{module}/{name}'.format(
module=get_annotation_module_url(module),
nam... | python | def get_annotation_url(module, version):
"""Get a BEL annotation file from artifactory given the name and version.
:param str module:
:param str version:
:type: str
"""
module = module.strip('/')
return '{module}/{name}'.format(
module=get_annotation_module_url(module),
nam... | [
"def",
"get_annotation_url",
"(",
"module",
",",
"version",
")",
":",
"module",
"=",
"module",
".",
"strip",
"(",
"'/'",
")",
"return",
"'{module}/{name}'",
".",
"format",
"(",
"module",
"=",
"get_annotation_module_url",
"(",
"module",
")",
",",
"name",
"=",... | Get a BEL annotation file from artifactory given the name and version.
:param str module:
:param str version:
:type: str | [
"Get",
"a",
"BEL",
"annotation",
"file",
"from",
"artifactory",
"given",
"the",
"name",
"and",
"version",
"."
] | 720107780a59be2ef08885290dfa519b1da62871 | https://github.com/pybel/pybel-artifactory/blob/720107780a59be2ef08885290dfa519b1da62871/src/pybel_artifactory/utils.py#L35-L47 |
243,790 | pybel/pybel-artifactory | src/pybel_artifactory/utils.py | get_knowledge_url | def get_knowledge_url(module, version):
"""Get a BEL knowledge file from Artifactory given the name and version.
:param str module:
:param str version:
:rtype: str
"""
module = module.strip('/')
return '{module}/{name}'.format(
module=get_knowledge_module_url(module),
name=... | python | def get_knowledge_url(module, version):
"""Get a BEL knowledge file from Artifactory given the name and version.
:param str module:
:param str version:
:rtype: str
"""
module = module.strip('/')
return '{module}/{name}'.format(
module=get_knowledge_module_url(module),
name=... | [
"def",
"get_knowledge_url",
"(",
"module",
",",
"version",
")",
":",
"module",
"=",
"module",
".",
"strip",
"(",
"'/'",
")",
"return",
"'{module}/{name}'",
".",
"format",
"(",
"module",
"=",
"get_knowledge_module_url",
"(",
"module",
")",
",",
"name",
"=",
... | Get a BEL knowledge file from Artifactory given the name and version.
:param str module:
:param str version:
:rtype: str | [
"Get",
"a",
"BEL",
"knowledge",
"file",
"from",
"Artifactory",
"given",
"the",
"name",
"and",
"version",
"."
] | 720107780a59be2ef08885290dfa519b1da62871 | https://github.com/pybel/pybel-artifactory/blob/720107780a59be2ef08885290dfa519b1da62871/src/pybel_artifactory/utils.py#L50-L62 |
243,791 | xaptum/xtt-python | _build_xtt.py | local_path | def local_path(path):
"""
Return the absolute path relative to the root of this project
"""
current = os.path.dirname(__file__)
root = current
return os.path.abspath(os.path.join(root, path)) | python | def local_path(path):
"""
Return the absolute path relative to the root of this project
"""
current = os.path.dirname(__file__)
root = current
return os.path.abspath(os.path.join(root, path)) | [
"def",
"local_path",
"(",
"path",
")",
":",
"current",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
"root",
"=",
"current",
"return",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"root",
",",
"path",... | Return the absolute path relative to the root of this project | [
"Return",
"the",
"absolute",
"path",
"relative",
"to",
"the",
"root",
"of",
"this",
"project"
] | 23ee469488d710d730314bec1136c4dd7ac2cd5c | https://github.com/xaptum/xtt-python/blob/23ee469488d710d730314bec1136c4dd7ac2cd5c/_build_xtt.py#L42-L48 |
243,792 | quasipedia/swaggery | swaggery/application.py | Swaggery._register_resources | def _register_resources(self, api_dirs, do_checks):
'''Register all Apis, Resources and Models with the application.'''
msg = 'Looking-up for APIs in the following directories: {}'
log.debug(msg.format(api_dirs))
if do_checks:
check_and_load(api_dirs)
else:
... | python | def _register_resources(self, api_dirs, do_checks):
'''Register all Apis, Resources and Models with the application.'''
msg = 'Looking-up for APIs in the following directories: {}'
log.debug(msg.format(api_dirs))
if do_checks:
check_and_load(api_dirs)
else:
... | [
"def",
"_register_resources",
"(",
"self",
",",
"api_dirs",
",",
"do_checks",
")",
":",
"msg",
"=",
"'Looking-up for APIs in the following directories: {}'",
"log",
".",
"debug",
"(",
"msg",
".",
"format",
"(",
"api_dirs",
")",
")",
"if",
"do_checks",
":",
"chec... | Register all Apis, Resources and Models with the application. | [
"Register",
"all",
"Apis",
"Resources",
"and",
"Models",
"with",
"the",
"application",
"."
] | 89a2e1b2bebbc511c781c9e63972f65aef73cc2f | https://github.com/quasipedia/swaggery/blob/89a2e1b2bebbc511c781c9e63972f65aef73cc2f/swaggery/application.py#L35-L46 |
243,793 | quasipedia/swaggery | swaggery/application.py | Swaggery._mount_resources | def _mount_resources(self):
'''Mount all registered resources onto the application.'''
rules = []
self.callback_map = {}
for ep in Resource:
for rule, callback in ep.get_routing_tuples():
log.debug('Path "{}" mapped to "{}"'.format(
rule.ru... | python | def _mount_resources(self):
'''Mount all registered resources onto the application.'''
rules = []
self.callback_map = {}
for ep in Resource:
for rule, callback in ep.get_routing_tuples():
log.debug('Path "{}" mapped to "{}"'.format(
rule.ru... | [
"def",
"_mount_resources",
"(",
"self",
")",
":",
"rules",
"=",
"[",
"]",
"self",
".",
"callback_map",
"=",
"{",
"}",
"for",
"ep",
"in",
"Resource",
":",
"for",
"rule",
",",
"callback",
"in",
"ep",
".",
"get_routing_tuples",
"(",
")",
":",
"log",
"."... | Mount all registered resources onto the application. | [
"Mount",
"all",
"registered",
"resources",
"onto",
"the",
"application",
"."
] | 89a2e1b2bebbc511c781c9e63972f65aef73cc2f | https://github.com/quasipedia/swaggery/blob/89a2e1b2bebbc511c781c9e63972f65aef73cc2f/swaggery/application.py#L48-L58 |
243,794 | quasipedia/swaggery | swaggery/application.py | Swaggery._get_coroutine | def _get_coroutine(self, request, start_response):
'''Try to dispapch the request and get the matching coroutine.'''
adapter = self.url_map.bind_to_environ(request.environ)
resource, kwargs = adapter.match()
callback = self.callback_map[resource]
inject_extra_args(callback, reque... | python | def _get_coroutine(self, request, start_response):
'''Try to dispapch the request and get the matching coroutine.'''
adapter = self.url_map.bind_to_environ(request.environ)
resource, kwargs = adapter.match()
callback = self.callback_map[resource]
inject_extra_args(callback, reque... | [
"def",
"_get_coroutine",
"(",
"self",
",",
"request",
",",
"start_response",
")",
":",
"adapter",
"=",
"self",
".",
"url_map",
".",
"bind_to_environ",
"(",
"request",
".",
"environ",
")",
"resource",
",",
"kwargs",
"=",
"adapter",
".",
"match",
"(",
")",
... | Try to dispapch the request and get the matching coroutine. | [
"Try",
"to",
"dispapch",
"the",
"request",
"and",
"get",
"the",
"matching",
"coroutine",
"."
] | 89a2e1b2bebbc511c781c9e63972f65aef73cc2f | https://github.com/quasipedia/swaggery/blob/89a2e1b2bebbc511c781c9e63972f65aef73cc2f/swaggery/application.py#L60-L66 |
243,795 | rameshg87/pyremotevbox | pyremotevbox/ZSI/client.py | _Binding.SetAuth | def SetAuth(self, style, user=None, password=None):
'''Change auth style, return object to user.
'''
self.auth_style, self.auth_user, self.auth_pass = \
style, user, password
return self | python | def SetAuth(self, style, user=None, password=None):
'''Change auth style, return object to user.
'''
self.auth_style, self.auth_user, self.auth_pass = \
style, user, password
return self | [
"def",
"SetAuth",
"(",
"self",
",",
"style",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
")",
":",
"self",
".",
"auth_style",
",",
"self",
".",
"auth_user",
",",
"self",
".",
"auth_pass",
"=",
"style",
",",
"user",
",",
"password",
"retur... | Change auth style, return object to user. | [
"Change",
"auth",
"style",
"return",
"object",
"to",
"user",
"."
] | 123dffff27da57c8faa3ac1dd4c68b1cf4558b1a | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/client.py#L139-L144 |
243,796 | rameshg87/pyremotevbox | pyremotevbox/ZSI/client.py | _Binding.AddHeader | def AddHeader(self, header, value):
'''Add a header to send.
'''
self.user_headers.append((header, value))
return self | python | def AddHeader(self, header, value):
'''Add a header to send.
'''
self.user_headers.append((header, value))
return self | [
"def",
"AddHeader",
"(",
"self",
",",
"header",
",",
"value",
")",
":",
"self",
".",
"user_headers",
".",
"append",
"(",
"(",
"header",
",",
"value",
")",
")",
"return",
"self"
] | Add a header to send. | [
"Add",
"a",
"header",
"to",
"send",
"."
] | 123dffff27da57c8faa3ac1dd4c68b1cf4558b1a | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/client.py#L163-L167 |
243,797 | rameshg87/pyremotevbox | pyremotevbox/ZSI/client.py | _Binding.__addcookies | def __addcookies(self):
'''Add cookies from self.cookies to request in self.h
'''
for cname, morsel in self.cookies.items():
attrs = []
value = morsel.get('version', '')
if value != '' and value != '0':
attrs.append('$Version=%s' % value)
... | python | def __addcookies(self):
'''Add cookies from self.cookies to request in self.h
'''
for cname, morsel in self.cookies.items():
attrs = []
value = morsel.get('version', '')
if value != '' and value != '0':
attrs.append('$Version=%s' % value)
... | [
"def",
"__addcookies",
"(",
"self",
")",
":",
"for",
"cname",
",",
"morsel",
"in",
"self",
".",
"cookies",
".",
"items",
"(",
")",
":",
"attrs",
"=",
"[",
"]",
"value",
"=",
"morsel",
".",
"get",
"(",
"'version'",
",",
"''",
")",
"if",
"value",
"... | Add cookies from self.cookies to request in self.h | [
"Add",
"cookies",
"from",
"self",
".",
"cookies",
"to",
"request",
"in",
"self",
".",
"h"
] | 123dffff27da57c8faa3ac1dd4c68b1cf4558b1a | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/client.py#L169-L184 |
243,798 | rameshg87/pyremotevbox | pyremotevbox/ZSI/client.py | _Binding.ReceiveRaw | def ReceiveRaw(self, **kw):
'''Read a server reply, unconverted to any format and return it.
'''
if self.data: return self.data
trace = self.trace
while 1:
response = self.h.getresponse()
self.reply_code, self.reply_msg, self.reply_headers, self.data = \
... | python | def ReceiveRaw(self, **kw):
'''Read a server reply, unconverted to any format and return it.
'''
if self.data: return self.data
trace = self.trace
while 1:
response = self.h.getresponse()
self.reply_code, self.reply_msg, self.reply_headers, self.data = \
... | [
"def",
"ReceiveRaw",
"(",
"self",
",",
"*",
"*",
"kw",
")",
":",
"if",
"self",
".",
"data",
":",
"return",
"self",
".",
"data",
"trace",
"=",
"self",
".",
"trace",
"while",
"1",
":",
"response",
"=",
"self",
".",
"h",
".",
"getresponse",
"(",
")"... | Read a server reply, unconverted to any format and return it. | [
"Read",
"a",
"server",
"reply",
"unconverted",
"to",
"any",
"format",
"and",
"return",
"it",
"."
] | 123dffff27da57c8faa3ac1dd4c68b1cf4558b1a | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/client.py#L367-L402 |
243,799 | rameshg87/pyremotevbox | pyremotevbox/ZSI/client.py | _Binding.ReceiveSOAP | def ReceiveSOAP(self, readerclass=None, **kw):
'''Get back a SOAP message.
'''
if self.ps: return self.ps
if not self.IsSOAP():
raise TypeError(
'Response is "%s", not "text/xml"' % self.reply_headers.type)
if len(self.data) == 0:
raise Typ... | python | def ReceiveSOAP(self, readerclass=None, **kw):
'''Get back a SOAP message.
'''
if self.ps: return self.ps
if not self.IsSOAP():
raise TypeError(
'Response is "%s", not "text/xml"' % self.reply_headers.type)
if len(self.data) == 0:
raise Typ... | [
"def",
"ReceiveSOAP",
"(",
"self",
",",
"readerclass",
"=",
"None",
",",
"*",
"*",
"kw",
")",
":",
"if",
"self",
".",
"ps",
":",
"return",
"self",
".",
"ps",
"if",
"not",
"self",
".",
"IsSOAP",
"(",
")",
":",
"raise",
"TypeError",
"(",
"'Response i... | Get back a SOAP message. | [
"Get",
"back",
"a",
"SOAP",
"message",
"."
] | 123dffff27da57c8faa3ac1dd4c68b1cf4558b1a | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/client.py#L410-L427 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.