repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
pjuren/pyokit | src/pyokit/statistics/beta.py | beta_pdf | def beta_pdf(x, a, b):
"""Beta distirbution probability density function."""
bc = 1 / beta(a, b)
fc = x ** (a - 1)
sc = (1 - x) ** (b - 1)
return bc * fc * sc | python | def beta_pdf(x, a, b):
"""Beta distirbution probability density function."""
bc = 1 / beta(a, b)
fc = x ** (a - 1)
sc = (1 - x) ** (b - 1)
return bc * fc * sc | [
"def",
"beta_pdf",
"(",
"x",
",",
"a",
",",
"b",
")",
":",
"bc",
"=",
"1",
"/",
"beta",
"(",
"a",
",",
"b",
")",
"fc",
"=",
"x",
"**",
"(",
"a",
"-",
"1",
")",
"sc",
"=",
"(",
"1",
"-",
"x",
")",
"**",
"(",
"b",
"-",
"1",
")",
"retu... | Beta distirbution probability density function. | [
"Beta",
"distirbution",
"probability",
"density",
"function",
"."
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/statistics/beta.py#L110-L115 |
limpyd/redis-limpyd-extensions | limpyd_extensions/dynamic/model.py | ModelWithDynamicFieldMixin._get_dynamic_field_for | def _get_dynamic_field_for(cls, field_name):
"""
Return the dynamic field within this class that match the given name.
Keep an internal cache to speed up future calls wieh same field name.
(The cache store the field for each individual class and subclasses, to
keep the link betwe... | python | def _get_dynamic_field_for(cls, field_name):
"""
Return the dynamic field within this class that match the given name.
Keep an internal cache to speed up future calls wieh same field name.
(The cache store the field for each individual class and subclasses, to
keep the link betwe... | [
"def",
"_get_dynamic_field_for",
"(",
"cls",
",",
"field_name",
")",
":",
"from",
".",
"fields",
"import",
"DynamicFieldMixin",
"# here to avoid circular import",
"if",
"cls",
"not",
"in",
"ModelWithDynamicFieldMixin",
".",
"_dynamic_fields_cache",
":",
"ModelWithDynamicF... | Return the dynamic field within this class that match the given name.
Keep an internal cache to speed up future calls wieh same field name.
(The cache store the field for each individual class and subclasses, to
keep the link between a field and its direct model) | [
"Return",
"the",
"dynamic",
"field",
"within",
"this",
"class",
"that",
"match",
"the",
"given",
"name",
".",
"Keep",
"an",
"internal",
"cache",
"to",
"speed",
"up",
"future",
"calls",
"wieh",
"same",
"field",
"name",
".",
"(",
"The",
"cache",
"store",
"... | train | https://github.com/limpyd/redis-limpyd-extensions/blob/13f34e39efd2f802761457da30ab2a4213b63934/limpyd_extensions/dynamic/model.py#L21-L46 |
limpyd/redis-limpyd-extensions | limpyd_extensions/dynamic/model.py | ModelWithDynamicFieldMixin.has_field | def has_field(cls, field_name):
"""
Check if the current class has a field with the name "field_name"
Add management of dynamic fields, to return True if the name matches an
existing dynamic field without existing copy for this name.
"""
if super(ModelWithDynamicFieldMixi... | python | def has_field(cls, field_name):
"""
Check if the current class has a field with the name "field_name"
Add management of dynamic fields, to return True if the name matches an
existing dynamic field without existing copy for this name.
"""
if super(ModelWithDynamicFieldMixi... | [
"def",
"has_field",
"(",
"cls",
",",
"field_name",
")",
":",
"if",
"super",
"(",
"ModelWithDynamicFieldMixin",
",",
"cls",
")",
".",
"has_field",
"(",
"field_name",
")",
":",
"return",
"True",
"try",
":",
"cls",
".",
"_get_dynamic_field_for",
"(",
"field_nam... | Check if the current class has a field with the name "field_name"
Add management of dynamic fields, to return True if the name matches an
existing dynamic field without existing copy for this name. | [
"Check",
"if",
"the",
"current",
"class",
"has",
"a",
"field",
"with",
"the",
"name",
"field_name",
"Add",
"management",
"of",
"dynamic",
"fields",
"to",
"return",
"True",
"if",
"the",
"name",
"matches",
"an",
"existing",
"dynamic",
"field",
"without",
"exis... | train | https://github.com/limpyd/redis-limpyd-extensions/blob/13f34e39efd2f802761457da30ab2a4213b63934/limpyd_extensions/dynamic/model.py#L49-L63 |
limpyd/redis-limpyd-extensions | limpyd_extensions/dynamic/model.py | ModelWithDynamicFieldMixin.get_class_field | def get_class_field(cls, field_name):
"""
Add management of dynamic fields: if a normal field cannot be retrieved,
check if it can be a dynamic field and in this case, create a copy with
the given name and associate it to the model.
"""
try:
field = super(Mode... | python | def get_class_field(cls, field_name):
"""
Add management of dynamic fields: if a normal field cannot be retrieved,
check if it can be a dynamic field and in this case, create a copy with
the given name and associate it to the model.
"""
try:
field = super(Mode... | [
"def",
"get_class_field",
"(",
"cls",
",",
"field_name",
")",
":",
"try",
":",
"field",
"=",
"super",
"(",
"ModelWithDynamicFieldMixin",
",",
"cls",
")",
".",
"get_class_field",
"(",
"field_name",
")",
"except",
"AttributeError",
":",
"# the \"has_field\" returned... | Add management of dynamic fields: if a normal field cannot be retrieved,
check if it can be a dynamic field and in this case, create a copy with
the given name and associate it to the model. | [
"Add",
"management",
"of",
"dynamic",
"fields",
":",
"if",
"a",
"normal",
"field",
"cannot",
"be",
"retrieved",
"check",
"if",
"it",
"can",
"be",
"a",
"dynamic",
"field",
"and",
"in",
"this",
"case",
"create",
"a",
"copy",
"with",
"the",
"given",
"name",... | train | https://github.com/limpyd/redis-limpyd-extensions/blob/13f34e39efd2f802761457da30ab2a4213b63934/limpyd_extensions/dynamic/model.py#L66-L79 |
limpyd/redis-limpyd-extensions | limpyd_extensions/dynamic/model.py | ModelWithDynamicFieldMixin.get_instance_field | def get_instance_field(self, field_name):
"""
Add management of dynamic fields: if a normal field cannot be retrieved,
check if it can be a dynamic field and in this case, create a copy with
the given name and associate it to the instance.
"""
try:
field = sup... | python | def get_instance_field(self, field_name):
"""
Add management of dynamic fields: if a normal field cannot be retrieved,
check if it can be a dynamic field and in this case, create a copy with
the given name and associate it to the instance.
"""
try:
field = sup... | [
"def",
"get_instance_field",
"(",
"self",
",",
"field_name",
")",
":",
"try",
":",
"field",
"=",
"super",
"(",
"ModelWithDynamicFieldMixin",
",",
"self",
")",
".",
"get_instance_field",
"(",
"field_name",
")",
"except",
"AttributeError",
":",
"# the \"has_field\" ... | Add management of dynamic fields: if a normal field cannot be retrieved,
check if it can be a dynamic field and in this case, create a copy with
the given name and associate it to the instance. | [
"Add",
"management",
"of",
"dynamic",
"fields",
":",
"if",
"a",
"normal",
"field",
"cannot",
"be",
"retrieved",
"check",
"if",
"it",
"can",
"be",
"a",
"dynamic",
"field",
"and",
"in",
"this",
"case",
"create",
"a",
"copy",
"with",
"the",
"given",
"name",... | train | https://github.com/limpyd/redis-limpyd-extensions/blob/13f34e39efd2f802761457da30ab2a4213b63934/limpyd_extensions/dynamic/model.py#L85-L99 |
limpyd/redis-limpyd-extensions | limpyd_extensions/dynamic/model.py | ModelWithDynamicFieldMixin._add_dynamic_field_to_model | def _add_dynamic_field_to_model(cls, field, field_name):
"""
Add a copy of the DynamicField "field" to the current class and its
subclasses using the "field_name" name
"""
# create the new field
new_field = field._create_dynamic_version()
new_field.name = field_na... | python | def _add_dynamic_field_to_model(cls, field, field_name):
"""
Add a copy of the DynamicField "field" to the current class and its
subclasses using the "field_name" name
"""
# create the new field
new_field = field._create_dynamic_version()
new_field.name = field_na... | [
"def",
"_add_dynamic_field_to_model",
"(",
"cls",
",",
"field",
",",
"field_name",
")",
":",
"# create the new field",
"new_field",
"=",
"field",
".",
"_create_dynamic_version",
"(",
")",
"new_field",
".",
"name",
"=",
"field_name",
"new_field",
".",
"_attach_to_mod... | Add a copy of the DynamicField "field" to the current class and its
subclasses using the "field_name" name | [
"Add",
"a",
"copy",
"of",
"the",
"DynamicField",
"field",
"to",
"the",
"current",
"class",
"and",
"its",
"subclasses",
"using",
"the",
"field_name",
"name"
] | train | https://github.com/limpyd/redis-limpyd-extensions/blob/13f34e39efd2f802761457da30ab2a4213b63934/limpyd_extensions/dynamic/model.py#L102-L127 |
limpyd/redis-limpyd-extensions | limpyd_extensions/dynamic/model.py | ModelWithDynamicFieldMixin._add_dynamic_field_to_instance | def _add_dynamic_field_to_instance(self, field, field_name):
"""
Add a copy of the DynamicField "field" to the current instance using the
"field_name" name
"""
# create the new field
new_field = field._create_dynamic_version()
new_field.name = field_name
n... | python | def _add_dynamic_field_to_instance(self, field, field_name):
"""
Add a copy of the DynamicField "field" to the current instance using the
"field_name" name
"""
# create the new field
new_field = field._create_dynamic_version()
new_field.name = field_name
n... | [
"def",
"_add_dynamic_field_to_instance",
"(",
"self",
",",
"field",
",",
"field_name",
")",
":",
"# create the new field",
"new_field",
"=",
"field",
".",
"_create_dynamic_version",
"(",
")",
"new_field",
".",
"name",
"=",
"field_name",
"new_field",
".",
"_attach_to... | Add a copy of the DynamicField "field" to the current instance using the
"field_name" name | [
"Add",
"a",
"copy",
"of",
"the",
"DynamicField",
"field",
"to",
"the",
"current",
"instance",
"using",
"the",
"field_name",
"name"
] | train | https://github.com/limpyd/redis-limpyd-extensions/blob/13f34e39efd2f802761457da30ab2a4213b63934/limpyd_extensions/dynamic/model.py#L129-L157 |
limpyd/redis-limpyd-extensions | limpyd_extensions/dynamic/model.py | ModelWithDynamicFieldMixin.get_field_name_for | def get_field_name_for(cls, field_name, dynamic_part):
"""
Given the name of a dynamic field, and a dynamic part, return the
name of the final dynamic field to use. It will then be used with
get_field.
"""
field = cls.get_field(field_name)
return field.get_name_fo... | python | def get_field_name_for(cls, field_name, dynamic_part):
"""
Given the name of a dynamic field, and a dynamic part, return the
name of the final dynamic field to use. It will then be used with
get_field.
"""
field = cls.get_field(field_name)
return field.get_name_fo... | [
"def",
"get_field_name_for",
"(",
"cls",
",",
"field_name",
",",
"dynamic_part",
")",
":",
"field",
"=",
"cls",
".",
"get_field",
"(",
"field_name",
")",
"return",
"field",
".",
"get_name_for",
"(",
"dynamic_part",
")"
] | Given the name of a dynamic field, and a dynamic part, return the
name of the final dynamic field to use. It will then be used with
get_field. | [
"Given",
"the",
"name",
"of",
"a",
"dynamic",
"field",
"and",
"a",
"dynamic",
"part",
"return",
"the",
"name",
"of",
"the",
"final",
"dynamic",
"field",
"to",
"use",
".",
"It",
"will",
"then",
"be",
"used",
"with",
"get_field",
"."
] | train | https://github.com/limpyd/redis-limpyd-extensions/blob/13f34e39efd2f802761457da30ab2a4213b63934/limpyd_extensions/dynamic/model.py#L160-L167 |
abalkin/tz | tz/main.py | main | def main(argv):
"""Program entry point.
:param argv: command-line arguments
:type argv: :class:`list`
"""
author_strings = []
for name, email in zip(metadata.authors, metadata.emails):
author_strings.append('Author: {0} <{1}>'.format(name, email))
epilog = '''
{project} {version}
... | python | def main(argv):
"""Program entry point.
:param argv: command-line arguments
:type argv: :class:`list`
"""
author_strings = []
for name, email in zip(metadata.authors, metadata.emails):
author_strings.append('Author: {0} <{1}>'.format(name, email))
epilog = '''
{project} {version}
... | [
"def",
"main",
"(",
"argv",
")",
":",
"author_strings",
"=",
"[",
"]",
"for",
"name",
",",
"email",
"in",
"zip",
"(",
"metadata",
".",
"authors",
",",
"metadata",
".",
"emails",
")",
":",
"author_strings",
".",
"append",
"(",
"'Author: {0} <{1}>'",
".",
... | Program entry point.
:param argv: command-line arguments
:type argv: :class:`list` | [
"Program",
"entry",
"point",
"."
] | train | https://github.com/abalkin/tz/blob/f25fca6afbf1abd46fd7aeb978282823c7dab5ab/tz/main.py#L13-L48 |
sbusard/wagoner | wagoner/word.py | process_arguments | def process_arguments():
"""
Process the command line arguments. The arguments are:
* the table to generate random from;
* -l (or --length) for the length of generated words (default: 10);
* -p (or --prefix) for the maximum of prefixes to consider (default: 0);
* -c (or --count) for the numb... | python | def process_arguments():
"""
Process the command line arguments. The arguments are:
* the table to generate random from;
* -l (or --length) for the length of generated words (default: 10);
* -p (or --prefix) for the maximum of prefixes to consider (default: 0);
* -c (or --count) for the numb... | [
"def",
"process_arguments",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"Generate random words from \"",
"\"the given content\"",
",",
"epilog",
"=",
"\"This script can generate random\"",
"\"words from tables, trees or \"",
"\"... | Process the command line arguments. The arguments are:
* the table to generate random from;
* -l (or --length) for the length of generated words (default: 10);
* -p (or --prefix) for the maximum of prefixes to consider (default: 0);
* -c (or --count) for the number of words to generate (default: 10)... | [
"Process",
"the",
"command",
"line",
"arguments",
".",
"The",
"arguments",
"are",
":",
"*",
"the",
"table",
"to",
"generate",
"random",
"from",
";",
"*",
"-",
"l",
"(",
"or",
"--",
"length",
")",
"for",
"the",
"length",
"of",
"generated",
"words",
"(",... | train | https://github.com/sbusard/wagoner/blob/7f83d66bbd0e009e4d4232ffdf319bd5a2a5683b/wagoner/word.py#L14-L57 |
heikomuller/sco-datastore | scodata/image.py | get_image_files | def get_image_files(directory, files):
"""Recursively iterate through directory tree and list all files that have a
valid image file suffix
Parameters
----------
directory : directory
Path to directory on disk
files : List(string)
List of file names
Returns
-------
... | python | def get_image_files(directory, files):
"""Recursively iterate through directory tree and list all files that have a
valid image file suffix
Parameters
----------
directory : directory
Path to directory on disk
files : List(string)
List of file names
Returns
-------
... | [
"def",
"get_image_files",
"(",
"directory",
",",
"files",
")",
":",
"# For each file in the directory test if it is a valid image file or a",
"# sub-directory.",
"for",
"f",
"in",
"os",
".",
"listdir",
"(",
"directory",
")",
":",
"abs_file",
"=",
"os",
".",
"path",
... | Recursively iterate through directory tree and list all files that have a
valid image file suffix
Parameters
----------
directory : directory
Path to directory on disk
files : List(string)
List of file names
Returns
-------
List(string)
List of files that have a... | [
"Recursively",
"iterate",
"through",
"directory",
"tree",
"and",
"list",
"all",
"files",
"that",
"have",
"a",
"valid",
"image",
"file",
"suffix"
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/image.py#L879-L906 |
heikomuller/sco-datastore | scodata/image.py | DefaultImageManager.create_object | def create_object(self, filename, img_properties=None):
"""Create an image object on local disk from the given file. The file
is copied to a new local directory that is created for the image object.
The optional list of image properties will be associated with the new
object together wit... | python | def create_object(self, filename, img_properties=None):
"""Create an image object on local disk from the given file. The file
is copied to a new local directory that is created for the image object.
The optional list of image properties will be associated with the new
object together wit... | [
"def",
"create_object",
"(",
"self",
",",
"filename",
",",
"img_properties",
"=",
"None",
")",
":",
"# Get the file name, i.e., last component of the given absolute path",
"prop_name",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"os",
".",
"path",
".",
"normpath",... | Create an image object on local disk from the given file. The file
is copied to a new local directory that is created for the image object.
The optional list of image properties will be associated with the new
object together with the set of default properties for images.
Parameters
... | [
"Create",
"an",
"image",
"object",
"on",
"local",
"disk",
"from",
"the",
"given",
"file",
".",
"The",
"file",
"is",
"copied",
"to",
"a",
"new",
"local",
"directory",
"that",
"is",
"created",
"for",
"the",
"image",
"object",
".",
"The",
"optional",
"list"... | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/image.py#L327-L384 |
heikomuller/sco-datastore | scodata/image.py | DefaultImageManager.from_dict | def from_dict(self, document):
"""Create image object from JSON document retrieved from database.
Parameters
----------
document : JSON
Json document in database
Returns
-------
ImageHandle
Handle for image object
"""
# Ge... | python | def from_dict(self, document):
"""Create image object from JSON document retrieved from database.
Parameters
----------
document : JSON
Json document in database
Returns
-------
ImageHandle
Handle for image object
"""
# Ge... | [
"def",
"from_dict",
"(",
"self",
",",
"document",
")",
":",
"# Get object properties from Json document",
"identifier",
"=",
"str",
"(",
"document",
"[",
"'_id'",
"]",
")",
"active",
"=",
"document",
"[",
"'active'",
"]",
"timestamp",
"=",
"datetime",
".",
"da... | Create image object from JSON document retrieved from database.
Parameters
----------
document : JSON
Json document in database
Returns
-------
ImageHandle
Handle for image object | [
"Create",
"image",
"object",
"from",
"JSON",
"document",
"retrieved",
"from",
"database",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/image.py#L386-L408 |
heikomuller/sco-datastore | scodata/image.py | DefaultImageManager.get_directory | def get_directory(self, identifier):
"""Implements the policy for naming directories for image objects. Image
object directories are name by their identifier. In addition, these
directories are grouped in parent directories named by the first two
characters of the identifier. The aim is ... | python | def get_directory(self, identifier):
"""Implements the policy for naming directories for image objects. Image
object directories are name by their identifier. In addition, these
directories are grouped in parent directories named by the first two
characters of the identifier. The aim is ... | [
"def",
"get_directory",
"(",
"self",
",",
"identifier",
")",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"directory",
",",
"identifier",
"[",
":",
"2",
"]",
")",
",",
"identifier",
")"
] | Implements the policy for naming directories for image objects. Image
object directories are name by their identifier. In addition, these
directories are grouped in parent directories named by the first two
characters of the identifier. The aim is to avoid having too many
sub-folders in ... | [
"Implements",
"the",
"policy",
"for",
"naming",
"directories",
"for",
"image",
"objects",
".",
"Image",
"object",
"directories",
"are",
"name",
"by",
"their",
"identifier",
".",
"In",
"addition",
"these",
"directories",
"are",
"grouped",
"in",
"parent",
"directo... | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/image.py#L410-L430 |
heikomuller/sco-datastore | scodata/image.py | DefaultImageGroupManager.create_object | def create_object(self, name, images, filename, options=None, object_identifier=None, read_only=False):
"""Create an image group object with the given list of images. The
file name specifies the location on local disk where the tar-file
containing the image group files is located. The file will ... | python | def create_object(self, name, images, filename, options=None, object_identifier=None, read_only=False):
"""Create an image group object with the given list of images. The
file name specifies the location on local disk where the tar-file
containing the image group files is located. The file will ... | [
"def",
"create_object",
"(",
"self",
",",
"name",
",",
"images",
",",
"filename",
",",
"options",
"=",
"None",
",",
"object_identifier",
"=",
"None",
",",
"read_only",
"=",
"False",
")",
":",
"# Raise an exception if given image group is not valied.",
"self",
".",... | Create an image group object with the given list of images. The
file name specifies the location on local disk where the tar-file
containing the image group files is located. The file will be copied
to the image groups data directory.
Parameters
----------
name : string
... | [
"Create",
"an",
"image",
"group",
"object",
"with",
"the",
"given",
"list",
"of",
"images",
".",
"The",
"file",
"name",
"specifies",
"the",
"location",
"on",
"local",
"disk",
"where",
"the",
"tar",
"-",
"file",
"containing",
"the",
"image",
"group",
"files... | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/image.py#L545-L610 |
heikomuller/sco-datastore | scodata/image.py | DefaultImageGroupManager.from_dict | def from_dict(self, document):
"""Create image group object from JSON document retrieved from database.
Parameters
----------
document : JSON
Json document in database
Returns
-------
ImageGroupHandle
Handle for image group object
... | python | def from_dict(self, document):
"""Create image group object from JSON document retrieved from database.
Parameters
----------
document : JSON
Json document in database
Returns
-------
ImageGroupHandle
Handle for image group object
... | [
"def",
"from_dict",
"(",
"self",
",",
"document",
")",
":",
"# Get object attributes from Json document",
"identifier",
"=",
"str",
"(",
"document",
"[",
"'_id'",
"]",
")",
"# Create list of group images from Json",
"images",
"=",
"list",
"(",
")",
"for",
"grp_image... | Create image group object from JSON document retrieved from database.
Parameters
----------
document : JSON
Json document in database
Returns
-------
ImageGroupHandle
Handle for image group object | [
"Create",
"image",
"group",
"object",
"from",
"JSON",
"document",
"retrieved",
"from",
"database",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/image.py#L612-L656 |
heikomuller/sco-datastore | scodata/image.py | DefaultImageGroupManager.get_collections_for_image | def get_collections_for_image(self, image_id):
"""Get identifier of all collections that contain a given image.
Parameters
----------
image_id : string
Unique identifierof image object
Returns
-------
List(string)
List of image collection... | python | def get_collections_for_image(self, image_id):
"""Get identifier of all collections that contain a given image.
Parameters
----------
image_id : string
Unique identifierof image object
Returns
-------
List(string)
List of image collection... | [
"def",
"get_collections_for_image",
"(",
"self",
",",
"image_id",
")",
":",
"result",
"=",
"[",
"]",
"# Get all active collections that contain the image identifier",
"for",
"document",
"in",
"self",
".",
"collection",
".",
"find",
"(",
"{",
"'active'",
":",
"True",... | Get identifier of all collections that contain a given image.
Parameters
----------
image_id : string
Unique identifierof image object
Returns
-------
List(string)
List of image collection identifier | [
"Get",
"identifier",
"of",
"all",
"collections",
"that",
"contain",
"a",
"given",
"image",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/image.py#L658-L675 |
heikomuller/sco-datastore | scodata/image.py | DefaultImageGroupManager.list_images | def list_images(self, identifier, offset=-1, limit=-1):
"""
Parameters
----------
identifier : string
Unique image group identifier
limit : int
Limit number of results in returned object listing
offset : int
Set offset in list (order as... | python | def list_images(self, identifier, offset=-1, limit=-1):
"""
Parameters
----------
identifier : string
Unique image group identifier
limit : int
Limit number of results in returned object listing
offset : int
Set offset in list (order as... | [
"def",
"list_images",
"(",
"self",
",",
"identifier",
",",
"offset",
"=",
"-",
"1",
",",
"limit",
"=",
"-",
"1",
")",
":",
"# Get image group to ensure that it exists. The object contains the full",
"# list of group images",
"img_grp",
"=",
"self",
".",
"get_object",
... | Parameters
----------
identifier : string
Unique image group identifier
limit : int
Limit number of results in returned object listing
offset : int
Set offset in list (order as defined by object store)
Returns
-------
ObjectLis... | [
"Parameters",
"----------",
"identifier",
":",
"string",
"Unique",
"image",
"group",
"identifier",
"limit",
":",
"int",
"Limit",
"number",
"of",
"results",
"in",
"returned",
"object",
"listing",
"offset",
":",
"int",
"Set",
"offset",
"in",
"list",
"(",
"order"... | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/image.py#L677-L709 |
heikomuller/sco-datastore | scodata/image.py | DefaultImageGroupManager.to_dict | def to_dict(self, img_coll):
"""Create a Json-like dictionary for image group. Extends the basic
object with an array of image identifiers.
Parameters
----------
img_coll : ImageGroupHandle
Returns
-------
(JSON)
Json-like object, i.e., dicti... | python | def to_dict(self, img_coll):
"""Create a Json-like dictionary for image group. Extends the basic
object with an array of image identifiers.
Parameters
----------
img_coll : ImageGroupHandle
Returns
-------
(JSON)
Json-like object, i.e., dicti... | [
"def",
"to_dict",
"(",
"self",
",",
"img_coll",
")",
":",
"# Get the basic Json object from the super class",
"json_obj",
"=",
"super",
"(",
"DefaultImageGroupManager",
",",
"self",
")",
".",
"to_dict",
"(",
"img_coll",
")",
"# Add list of images as Json array",
"images... | Create a Json-like dictionary for image group. Extends the basic
object with an array of image identifiers.
Parameters
----------
img_coll : ImageGroupHandle
Returns
-------
(JSON)
Json-like object, i.e., dictionary. | [
"Create",
"a",
"Json",
"-",
"like",
"dictionary",
"for",
"image",
"group",
".",
"Extends",
"the",
"basic",
"object",
"with",
"an",
"array",
"of",
"image",
"identifiers",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/image.py#L711-L738 |
heikomuller/sco-datastore | scodata/image.py | DefaultImageGroupManager.update_object_options | def update_object_options(self, identifier, options):
"""Update set of typed attributes (options) that are associated with
a given image group. Raises a ValueError if any of the given
attributes violates the attribute definitions associated with image
groups.
Parameters
... | python | def update_object_options(self, identifier, options):
"""Update set of typed attributes (options) that are associated with
a given image group. Raises a ValueError if any of the given
attributes violates the attribute definitions associated with image
groups.
Parameters
... | [
"def",
"update_object_options",
"(",
"self",
",",
"identifier",
",",
"options",
")",
":",
"# Retrieve object from database to ensure that it exists",
"img_group",
"=",
"self",
".",
"get_object",
"(",
"identifier",
")",
"if",
"img_group",
"is",
"None",
":",
"return",
... | Update set of typed attributes (options) that are associated with
a given image group. Raises a ValueError if any of the given
attributes violates the attribute definitions associated with image
groups.
Parameters
----------
identifier : string
Unique object ... | [
"Update",
"set",
"of",
"typed",
"attributes",
"(",
"options",
")",
"that",
"are",
"associated",
"with",
"a",
"given",
"image",
"group",
".",
"Raises",
"a",
"ValueError",
"if",
"any",
"of",
"the",
"given",
"attributes",
"violates",
"the",
"attribute",
"defini... | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/image.py#L740-L768 |
heikomuller/sco-datastore | scodata/image.py | DefaultImageGroupManager.validate_group | def validate_group(images):
"""Validates that the combination of folder and name for all images in
a group is unique. Raises a ValueError exception if uniqueness
constraint is violated.
Parameters
----------
images : List(GroupImage)
List of images in group
... | python | def validate_group(images):
"""Validates that the combination of folder and name for all images in
a group is unique. Raises a ValueError exception if uniqueness
constraint is violated.
Parameters
----------
images : List(GroupImage)
List of images in group
... | [
"def",
"validate_group",
"(",
"images",
")",
":",
"image_ids",
"=",
"set",
"(",
")",
"for",
"image",
"in",
"images",
":",
"key",
"=",
"image",
".",
"folder",
"+",
"image",
".",
"name",
"if",
"key",
"in",
"image_ids",
":",
"raise",
"ValueError",
"(",
... | Validates that the combination of folder and name for all images in
a group is unique. Raises a ValueError exception if uniqueness
constraint is violated.
Parameters
----------
images : List(GroupImage)
List of images in group | [
"Validates",
"that",
"the",
"combination",
"of",
"folder",
"and",
"name",
"for",
"all",
"images",
"in",
"a",
"group",
"is",
"unique",
".",
"Raises",
"a",
"ValueError",
"exception",
"if",
"uniqueness",
"constraint",
"is",
"violated",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/image.py#L771-L787 |
heikomuller/sco-datastore | scodata/image.py | DefaultPredictionImageSetManager.create_object | def create_object(self, name, image_sets):
"""Create a prediction image set list.
Parameters
----------
name : string
User-provided name for the image group.
image_sets : list(PredictionImageSet)
List of prediction image sets
Returns
----... | python | def create_object(self, name, image_sets):
"""Create a prediction image set list.
Parameters
----------
name : string
User-provided name for the image group.
image_sets : list(PredictionImageSet)
List of prediction image sets
Returns
----... | [
"def",
"create_object",
"(",
"self",
",",
"name",
",",
"image_sets",
")",
":",
"# Create a new object identifier",
"identifier",
"=",
"str",
"(",
"uuid",
".",
"uuid4",
"(",
")",
")",
".",
"replace",
"(",
"'-'",
",",
"''",
")",
"properties",
"=",
"{",
"da... | Create a prediction image set list.
Parameters
----------
name : string
User-provided name for the image group.
image_sets : list(PredictionImageSet)
List of prediction image sets
Returns
-------
PredictionImageSetHandle
Objec... | [
"Create",
"a",
"prediction",
"image",
"set",
"list",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/image.py#L806-L828 |
heikomuller/sco-datastore | scodata/image.py | DefaultPredictionImageSetManager.from_dict | def from_dict(self, document):
"""Create a prediction image set resource from a dictionary
serialization.
Parameters
----------
document : dict
Dictionary serialization of the resource
Returns
-------
PredictionImageSetHandle
Hand... | python | def from_dict(self, document):
"""Create a prediction image set resource from a dictionary
serialization.
Parameters
----------
document : dict
Dictionary serialization of the resource
Returns
-------
PredictionImageSetHandle
Hand... | [
"def",
"from_dict",
"(",
"self",
",",
"document",
")",
":",
"return",
"PredictionImageSetHandle",
"(",
"str",
"(",
"document",
"[",
"'_id'",
"]",
")",
",",
"document",
"[",
"'properties'",
"]",
",",
"[",
"PredictionImageSet",
".",
"from_dict",
"(",
"img",
... | Create a prediction image set resource from a dictionary
serialization.
Parameters
----------
document : dict
Dictionary serialization of the resource
Returns
-------
PredictionImageSetHandle
Handle for prediction image sets | [
"Create",
"a",
"prediction",
"image",
"set",
"resource",
"from",
"a",
"dictionary",
"serialization",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/image.py#L830-L853 |
heikomuller/sco-datastore | scodata/image.py | DefaultPredictionImageSetManager.to_dict | def to_dict(self, img_sets):
"""Create a dictionary serialization for a prediction image set handle.
Parameters
----------
img_sets : PredictionImageSetHandle
Returns
-------
dict
Dictionary serialization of the resource
"""
# Get the... | python | def to_dict(self, img_sets):
"""Create a dictionary serialization for a prediction image set handle.
Parameters
----------
img_sets : PredictionImageSetHandle
Returns
-------
dict
Dictionary serialization of the resource
"""
# Get the... | [
"def",
"to_dict",
"(",
"self",
",",
"img_sets",
")",
":",
"# Get the basic Json object from the super class",
"json_obj",
"=",
"super",
"(",
"DefaultPredictionImageSetManager",
",",
"self",
")",
".",
"to_dict",
"(",
"img_sets",
")",
"# Add list of image sets as Json array... | Create a dictionary serialization for a prediction image set handle.
Parameters
----------
img_sets : PredictionImageSetHandle
Returns
-------
dict
Dictionary serialization of the resource | [
"Create",
"a",
"dictionary",
"serialization",
"for",
"a",
"prediction",
"image",
"set",
"handle",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/image.py#L855-L871 |
cirruscluster/cirruscluster | cirruscluster/ext/ansible/playbook/play.py | Play._load_tasks | def _load_tasks(self, tasks, vars={}, additional_conditions=[]):
''' handle task and handler include statements '''
results = []
if tasks is None:
# support empty handler files, and the like.
tasks = []
for x in tasks:
task_vars = self.vars.copy()
... | python | def _load_tasks(self, tasks, vars={}, additional_conditions=[]):
''' handle task and handler include statements '''
results = []
if tasks is None:
# support empty handler files, and the like.
tasks = []
for x in tasks:
task_vars = self.vars.copy()
... | [
"def",
"_load_tasks",
"(",
"self",
",",
"tasks",
",",
"vars",
"=",
"{",
"}",
",",
"additional_conditions",
"=",
"[",
"]",
")",
":",
"results",
"=",
"[",
"]",
"if",
"tasks",
"is",
"None",
":",
"# support empty handler files, and the like.",
"tasks",
"=",
"[... | handle task and handler include statements | [
"handle",
"task",
"and",
"handler",
"include",
"statements"
] | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/playbook/play.py#L100-L152 |
cirruscluster/cirruscluster | cirruscluster/ext/ansible/playbook/play.py | Play._get_vars | def _get_vars(self):
''' load the vars section from a play, accounting for all sorts of variable features
including loading from yaml files, prompting, and conditional includes of the first
file found in a list. '''
if self.vars is None:
self.vars = {}
if type(self.... | python | def _get_vars(self):
''' load the vars section from a play, accounting for all sorts of variable features
including loading from yaml files, prompting, and conditional includes of the first
file found in a list. '''
if self.vars is None:
self.vars = {}
if type(self.... | [
"def",
"_get_vars",
"(",
"self",
")",
":",
"if",
"self",
".",
"vars",
"is",
"None",
":",
"self",
".",
"vars",
"=",
"{",
"}",
"if",
"type",
"(",
"self",
".",
"vars",
")",
"not",
"in",
"[",
"dict",
",",
"list",
"]",
":",
"raise",
"errors",
".",
... | load the vars section from a play, accounting for all sorts of variable features
including loading from yaml files, prompting, and conditional includes of the first
file found in a list. | [
"load",
"the",
"vars",
"section",
"from",
"a",
"play",
"accounting",
"for",
"all",
"sorts",
"of",
"variable",
"features",
"including",
"loading",
"from",
"yaml",
"files",
"prompting",
"and",
"conditional",
"includes",
"of",
"the",
"first",
"file",
"found",
"in... | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/playbook/play.py#L166-L225 |
cirruscluster/cirruscluster | cirruscluster/ext/ansible/playbook/play.py | Play.compare_tags | def compare_tags(self, tags):
''' given a list of tags that the user has specified, return two lists:
matched_tags: tags were found within the current play and match those given
by the user
unmatched_tags: tags that were found within the current play but do not match
... | python | def compare_tags(self, tags):
''' given a list of tags that the user has specified, return two lists:
matched_tags: tags were found within the current play and match those given
by the user
unmatched_tags: tags that were found within the current play but do not match
... | [
"def",
"compare_tags",
"(",
"self",
",",
"tags",
")",
":",
"# gather all the tags in all the tasks into one list",
"all_tags",
"=",
"[",
"]",
"for",
"task",
"in",
"self",
".",
"_tasks",
":",
"all_tags",
".",
"extend",
"(",
"task",
".",
"tags",
")",
"# compare ... | given a list of tags that the user has specified, return two lists:
matched_tags: tags were found within the current play and match those given
by the user
unmatched_tags: tags that were found within the current play but do not match
any provided by the ... | [
"given",
"a",
"list",
"of",
"tags",
"that",
"the",
"user",
"has",
"specified",
"return",
"two",
"lists",
":",
"matched_tags",
":",
"tags",
"were",
"found",
"within",
"the",
"current",
"play",
"and",
"match",
"those",
"given",
"by",
"the",
"user",
"unmatche... | train | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/playbook/play.py#L238-L256 |
FreshXOpenSource/wallaby-frontend-qt | wallaby/FXUI.py | key_event_to_name | def key_event_to_name(event):
""" Converts a keystroke event into a corresponding key name.
"""
key_code = event.key()
modifiers = event.modifiers()
if modifiers & QtCore.Qt.KeypadModifier:
key = keypad_map.get(key_code)
else:
key = None
if key is None:
key = key_map.... | python | def key_event_to_name(event):
""" Converts a keystroke event into a corresponding key name.
"""
key_code = event.key()
modifiers = event.modifiers()
if modifiers & QtCore.Qt.KeypadModifier:
key = keypad_map.get(key_code)
else:
key = None
if key is None:
key = key_map.... | [
"def",
"key_event_to_name",
"(",
"event",
")",
":",
"key_code",
"=",
"event",
".",
"key",
"(",
")",
"modifiers",
"=",
"event",
".",
"modifiers",
"(",
")",
"if",
"modifiers",
"&",
"QtCore",
".",
"Qt",
".",
"KeypadModifier",
":",
"key",
"=",
"keypad_map",
... | Converts a keystroke event into a corresponding key name. | [
"Converts",
"a",
"keystroke",
"event",
"into",
"a",
"corresponding",
"key",
"name",
"."
] | train | https://github.com/FreshXOpenSource/wallaby-frontend-qt/blob/eee70d0ec4ce34827f62a1654e28dbff8a8afb1a/wallaby/FXUI.py#L253-L282 |
AnnAnnFryingPan/data_hub_call | build/lib/data_hub_call/dataHubCallCityVervePoP.py | DataHubCallCityVervePoP.get_children_as_time_series | def get_children_as_time_series(self, json_children, time_field=['entity','occurred']):
result = []
time_field_as_path_list = time_field.strip().split(".")
if len(time_field_as_path_list) == 0:
return result
"""
FROM:
{
"id": "60411677",
... | python | def get_children_as_time_series(self, json_children, time_field=['entity','occurred']):
result = []
time_field_as_path_list = time_field.strip().split(".")
if len(time_field_as_path_list) == 0:
return result
"""
FROM:
{
"id": "60411677",
... | [
"def",
"get_children_as_time_series",
"(",
"self",
",",
"json_children",
",",
"time_field",
"=",
"[",
"'entity'",
",",
"'occurred'",
"]",
")",
":",
"result",
"=",
"[",
"]",
"time_field_as_path_list",
"=",
"time_field",
".",
"strip",
"(",
")",
".",
"split",
"... | FROM:
{
"id": "60411677",
"uri": "https://api.cityverve.org.uk/v1/entity/crime/60411677",
"type": "crime",
"name": "Anti Social Behaviour - On or near Manor Road",
"loc": {},
"entity": {
"category": "Anti Social Behaviour",
... | [
"FROM",
":",
"{",
"id",
":",
"60411677",
"uri",
":",
"https",
":",
"//",
"api",
".",
"cityverve",
".",
"org",
".",
"uk",
"/",
"v1",
"/",
"entity",
"/",
"crime",
"/",
"60411677",
"type",
":",
"crime",
"name",
":",
"Anti",
"Social",
"Behaviour",
"-",... | train | https://github.com/AnnAnnFryingPan/data_hub_call/blob/907a481bb2adfff86d311bdf5a4fa352fd7e90be/build/lib/data_hub_call/dataHubCallCityVervePoP.py#L282-L330 |
KelSolaar/Oncilla | oncilla/libraries/python/pyclbr.py | readmodule | def readmodule(module, path=None):
'''Backwards compatible interface.
Call readmodule_ex() and then only keep Class objects from the
resulting dictionary.'''
res = {}
for key, value in _readmodule(module, path or []).items():
if isinstance(value, Class):
res[key] = value
re... | python | def readmodule(module, path=None):
'''Backwards compatible interface.
Call readmodule_ex() and then only keep Class objects from the
resulting dictionary.'''
res = {}
for key, value in _readmodule(module, path or []).items():
if isinstance(value, Class):
res[key] = value
re... | [
"def",
"readmodule",
"(",
"module",
",",
"path",
"=",
"None",
")",
":",
"res",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"_readmodule",
"(",
"module",
",",
"path",
"or",
"[",
"]",
")",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
... | Backwards compatible interface.
Call readmodule_ex() and then only keep Class objects from the
resulting dictionary. | [
"Backwards",
"compatible",
"interface",
"."
] | train | https://github.com/KelSolaar/Oncilla/blob/2b4db3704cf2c22a09a207681cb041fff555a994/oncilla/libraries/python/pyclbr.py#L97-L107 |
KelSolaar/Oncilla | oncilla/libraries/python/pyclbr.py | _readmodule | def _readmodule(module, path, inpackage=None):
'''Do the hard work for readmodule[_ex].
If INPACKAGE is given, it must be the dotted name of the package in
which we are searching for a submodule, and then PATH must be the
package search path; otherwise, we are searching for a top-level
module, and ... | python | def _readmodule(module, path, inpackage=None):
'''Do the hard work for readmodule[_ex].
If INPACKAGE is given, it must be the dotted name of the package in
which we are searching for a submodule, and then PATH must be the
package search path; otherwise, we are searching for a top-level
module, and ... | [
"def",
"_readmodule",
"(",
"module",
",",
"path",
",",
"inpackage",
"=",
"None",
")",
":",
"# Compute the full module name (prepending inpackage if set)",
"if",
"inpackage",
"is",
"not",
"None",
":",
"fullmodule",
"=",
"\"%s.%s\"",
"%",
"(",
"inpackage",
",",
"mod... | Do the hard work for readmodule[_ex].
If INPACKAGE is given, it must be the dotted name of the package in
which we are searching for a submodule, and then PATH must be the
package search path; otherwise, we are searching for a top-level
module, and PATH is combined with sys.path. | [
"Do",
"the",
"hard",
"work",
"for",
"readmodule",
"[",
"_ex",
"]",
"."
] | train | https://github.com/KelSolaar/Oncilla/blob/2b4db3704cf2c22a09a207681cb041fff555a994/oncilla/libraries/python/pyclbr.py#L120-L304 |
mrallen1/pygett | pygett/user.py | GettUser.login | def login(self, **params):
"""
**login**
Use the current credentials to get a valid Gett access token.
Input:
* A dict of parameters to use for the login attempt (optional)
Output:
* ``True``
Example::
if client.user.login():
... | python | def login(self, **params):
"""
**login**
Use the current credentials to get a valid Gett access token.
Input:
* A dict of parameters to use for the login attempt (optional)
Output:
* ``True``
Example::
if client.user.login():
... | [
"def",
"login",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"if",
"not",
"params",
":",
"params",
"=",
"{",
"\"apikey\"",
":",
"self",
".",
"apikey",
",",
"\"email\"",
":",
"self",
".",
"email",
",",
"\"password\"",
":",
"self",
".",
"password",
... | **login**
Use the current credentials to get a valid Gett access token.
Input:
* A dict of parameters to use for the login attempt (optional)
Output:
* ``True``
Example::
if client.user.login():
print "You have %s bytes of storage ... | [
"**",
"login",
"**"
] | train | https://github.com/mrallen1/pygett/blob/1e21f8674a3634a901af054226670174b5ce2d87/pygett/user.py#L49-L85 |
mrallen1/pygett | pygett/user.py | GettUser.access_token | def access_token(self):
"""
**access_token**
Returns a valid access token. If the user is not currently logged in, attempts to do so.
If the current time exceeds the grace period, attempts to retrieve a new access token.
Input:
* None
Output:
*... | python | def access_token(self):
"""
**access_token**
Returns a valid access token. If the user is not currently logged in, attempts to do so.
If the current time exceeds the grace period, attempts to retrieve a new access token.
Input:
* None
Output:
*... | [
"def",
"access_token",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_access_token",
":",
"self",
".",
"login",
"(",
")",
"if",
"time",
"(",
")",
">",
"(",
"self",
".",
"access_token_expires",
"-",
"self",
".",
"access_token_grace",
")",
":",
"self... | **access_token**
Returns a valid access token. If the user is not currently logged in, attempts to do so.
If the current time exceeds the grace period, attempts to retrieve a new access token.
Input:
* None
Output:
* A valid access token
Example::
... | [
"**",
"access_token",
"**"
] | train | https://github.com/mrallen1/pygett/blob/1e21f8674a3634a901af054226670174b5ce2d87/pygett/user.py#L87-L110 |
mrallen1/pygett | pygett/user.py | GettUser.refresh | def refresh(self):
"""
**refresh**
Refresh this user object with data from the Gett service
Input:
* None
Output:
* ``True``
Example::
if client.user.refresh():
print "User data refreshed!"
print "Yo... | python | def refresh(self):
"""
**refresh**
Refresh this user object with data from the Gett service
Input:
* None
Output:
* ``True``
Example::
if client.user.refresh():
print "User data refreshed!"
print "Yo... | [
"def",
"refresh",
"(",
"self",
")",
":",
"response",
"=",
"GettRequest",
"(",
")",
".",
"get",
"(",
"\"/users/me?accesstoken=%s\"",
"%",
"self",
".",
"access_token",
"(",
")",
")",
"if",
"response",
".",
"http_status",
"==",
"200",
":",
"self",
".",
"use... | **refresh**
Refresh this user object with data from the Gett service
Input:
* None
Output:
* ``True``
Example::
if client.user.refresh():
print "User data refreshed!"
print "You have %s bytes of storage remaining." ... | [
"**",
"refresh",
"**"
] | train | https://github.com/mrallen1/pygett/blob/1e21f8674a3634a901af054226670174b5ce2d87/pygett/user.py#L112-L139 |
ojake/django-tracked-model | tracked_model/serializer.py | _basic_field_data | def _basic_field_data(field, obj):
"""Returns ``obj.field`` data as a dict"""
value = field.value_from_object(obj)
return {Field.TYPE: FieldType.VAL, Field.VALUE: value} | python | def _basic_field_data(field, obj):
"""Returns ``obj.field`` data as a dict"""
value = field.value_from_object(obj)
return {Field.TYPE: FieldType.VAL, Field.VALUE: value} | [
"def",
"_basic_field_data",
"(",
"field",
",",
"obj",
")",
":",
"value",
"=",
"field",
".",
"value_from_object",
"(",
"obj",
")",
"return",
"{",
"Field",
".",
"TYPE",
":",
"FieldType",
".",
"VAL",
",",
"Field",
".",
"VALUE",
":",
"value",
"}"
] | Returns ``obj.field`` data as a dict | [
"Returns",
"obj",
".",
"field",
"data",
"as",
"a",
"dict"
] | train | https://github.com/ojake/django-tracked-model/blob/19bc48874dd2e5fb5defedc6b8c5c3915cce1424/tracked_model/serializer.py#L9-L12 |
ojake/django-tracked-model | tracked_model/serializer.py | _related_field_data | def _related_field_data(field, obj):
"""Returns relation ``field`` as a dict.
Dict contains related pk info and some meta information
for reconstructing objects.
"""
data = _basic_field_data(field, obj)
relation_info = {
Field.REL_DB_TABLE: field.rel.to._meta.db_table,
Field.REL... | python | def _related_field_data(field, obj):
"""Returns relation ``field`` as a dict.
Dict contains related pk info and some meta information
for reconstructing objects.
"""
data = _basic_field_data(field, obj)
relation_info = {
Field.REL_DB_TABLE: field.rel.to._meta.db_table,
Field.REL... | [
"def",
"_related_field_data",
"(",
"field",
",",
"obj",
")",
":",
"data",
"=",
"_basic_field_data",
"(",
"field",
",",
"obj",
")",
"relation_info",
"=",
"{",
"Field",
".",
"REL_DB_TABLE",
":",
"field",
".",
"rel",
".",
"to",
".",
"_meta",
".",
"db_table"... | Returns relation ``field`` as a dict.
Dict contains related pk info and some meta information
for reconstructing objects. | [
"Returns",
"relation",
"field",
"as",
"a",
"dict",
"."
] | train | https://github.com/ojake/django-tracked-model/blob/19bc48874dd2e5fb5defedc6b8c5c3915cce1424/tracked_model/serializer.py#L15-L29 |
ojake/django-tracked-model | tracked_model/serializer.py | _m2m_field_data | def _m2m_field_data(field, obj):
"""Returns m2m ``field`` as a dict.
Value is an array of related primary keys and some meta information
for reconstructing objects.
"""
data = _basic_field_data(field, obj)
data[Field.TYPE] = FieldType.M2M
related = field.rel.to
relation_info = {
... | python | def _m2m_field_data(field, obj):
"""Returns m2m ``field`` as a dict.
Value is an array of related primary keys and some meta information
for reconstructing objects.
"""
data = _basic_field_data(field, obj)
data[Field.TYPE] = FieldType.M2M
related = field.rel.to
relation_info = {
... | [
"def",
"_m2m_field_data",
"(",
"field",
",",
"obj",
")",
":",
"data",
"=",
"_basic_field_data",
"(",
"field",
",",
"obj",
")",
"data",
"[",
"Field",
".",
"TYPE",
"]",
"=",
"FieldType",
".",
"M2M",
"related",
"=",
"field",
".",
"rel",
".",
"to",
"rela... | Returns m2m ``field`` as a dict.
Value is an array of related primary keys and some meta information
for reconstructing objects. | [
"Returns",
"m2m",
"field",
"as",
"a",
"dict",
"."
] | train | https://github.com/ojake/django-tracked-model/blob/19bc48874dd2e5fb5defedc6b8c5c3915cce1424/tracked_model/serializer.py#L32-L50 |
ojake/django-tracked-model | tracked_model/serializer.py | dump_model | def dump_model(obj):
"""Returns ``obj`` as a dict.
Returnded dic has a form of:
{
'field_name': {
'type': `FieldType`,
'value': field value,
# if field is a relation, it also has:
'rel': {
'db_table': model db table,
'a... | python | def dump_model(obj):
"""Returns ``obj`` as a dict.
Returnded dic has a form of:
{
'field_name': {
'type': `FieldType`,
'value': field value,
# if field is a relation, it also has:
'rel': {
'db_table': model db table,
'a... | [
"def",
"dump_model",
"(",
"obj",
")",
":",
"data",
"=",
"{",
"}",
"for",
"field",
"in",
"obj",
".",
"_meta",
".",
"fields",
":",
"if",
"isinstance",
"(",
"field",
",",
"RELATED_FIELDS",
")",
":",
"field_data",
"=",
"_related_field_data",
"(",
"field",
... | Returns ``obj`` as a dict.
Returnded dic has a form of:
{
'field_name': {
'type': `FieldType`,
'value': field value,
# if field is a relation, it also has:
'rel': {
'db_table': model db table,
'app_label': model app label,
... | [
"Returns",
"obj",
"as",
"a",
"dict",
"."
] | train | https://github.com/ojake/django-tracked-model/blob/19bc48874dd2e5fb5defedc6b8c5c3915cce1424/tracked_model/serializer.py#L53-L83 |
ojake/django-tracked-model | tracked_model/serializer.py | restore_model | def restore_model(cls, data):
"""Returns instance of ``cls`` with attributed loaded
from ``data`` dict.
"""
obj = cls()
for field in data:
setattr(obj, field, data[field][Field.VALUE])
return obj | python | def restore_model(cls, data):
"""Returns instance of ``cls`` with attributed loaded
from ``data`` dict.
"""
obj = cls()
for field in data:
setattr(obj, field, data[field][Field.VALUE])
return obj | [
"def",
"restore_model",
"(",
"cls",
",",
"data",
")",
":",
"obj",
"=",
"cls",
"(",
")",
"for",
"field",
"in",
"data",
":",
"setattr",
"(",
"obj",
",",
"field",
",",
"data",
"[",
"field",
"]",
"[",
"Field",
".",
"VALUE",
"]",
")",
"return",
"obj"
... | Returns instance of ``cls`` with attributed loaded
from ``data`` dict. | [
"Returns",
"instance",
"of",
"cls",
"with",
"attributed",
"loaded",
"from",
"data",
"dict",
"."
] | train | https://github.com/ojake/django-tracked-model/blob/19bc48874dd2e5fb5defedc6b8c5c3915cce1424/tracked_model/serializer.py#L86-L94 |
refinery29/chassis | chassis/services/cache.py | retrieve_object | def retrieve_object(cache, template, indexes):
"""Retrieve an object from Redis using a pipeline.
Arguments:
template: a dictionary containg the keys for the object and
template strings for the corresponding redis keys. The template
string uses named string interpolation format.... | python | def retrieve_object(cache, template, indexes):
"""Retrieve an object from Redis using a pipeline.
Arguments:
template: a dictionary containg the keys for the object and
template strings for the corresponding redis keys. The template
string uses named string interpolation format.... | [
"def",
"retrieve_object",
"(",
"cache",
",",
"template",
",",
"indexes",
")",
":",
"keys",
"=",
"[",
"]",
"with",
"cache",
"as",
"redis_connection",
":",
"pipe",
"=",
"redis_connection",
".",
"pipeline",
"(",
")",
"for",
"(",
"result_key",
",",
"redis_key_... | Retrieve an object from Redis using a pipeline.
Arguments:
template: a dictionary containg the keys for the object and
template strings for the corresponding redis keys. The template
string uses named string interpolation format. Example:
{
'username': '... | [
"Retrieve",
"an",
"object",
"from",
"Redis",
"using",
"a",
"pipeline",
"."
] | train | https://github.com/refinery29/chassis/blob/1238d5214cbb8f3e1fe7c0dc2fa72f45bf085192/chassis/services/cache.py#L43-L82 |
refinery29/chassis | chassis/services/cache.py | set_object | def set_object(cache, template, indexes, data):
"""Set an object in Redis using a pipeline.
Only sets the fields that are present in both the template and the data.
Arguments:
template: a dictionary containg the keys for the object and
template strings for the corresponding redis keys.... | python | def set_object(cache, template, indexes, data):
"""Set an object in Redis using a pipeline.
Only sets the fields that are present in both the template and the data.
Arguments:
template: a dictionary containg the keys for the object and
template strings for the corresponding redis keys.... | [
"def",
"set_object",
"(",
"cache",
",",
"template",
",",
"indexes",
",",
"data",
")",
":",
"# TODO(mattmillr): Handle expiration times",
"with",
"cache",
"as",
"redis_connection",
":",
"pipe",
"=",
"redis_connection",
".",
"pipeline",
"(",
")",
"for",
"key",
"in... | Set an object in Redis using a pipeline.
Only sets the fields that are present in both the template and the data.
Arguments:
template: a dictionary containg the keys for the object and
template strings for the corresponding redis keys. The template
string uses named string inte... | [
"Set",
"an",
"object",
"in",
"Redis",
"using",
"a",
"pipeline",
"."
] | train | https://github.com/refinery29/chassis/blob/1238d5214cbb8f3e1fe7c0dc2fa72f45bf085192/chassis/services/cache.py#L85-L122 |
refinery29/chassis | chassis/services/cache.py | delete_object | def delete_object(cache, template, indexes):
"""Delete an object in Redis using a pipeline.
Deletes all fields defined by the template.
Arguments:
template: a dictionary containg the keys for the object and
template strings for the corresponding redis keys. The template
str... | python | def delete_object(cache, template, indexes):
"""Delete an object in Redis using a pipeline.
Deletes all fields defined by the template.
Arguments:
template: a dictionary containg the keys for the object and
template strings for the corresponding redis keys. The template
str... | [
"def",
"delete_object",
"(",
"cache",
",",
"template",
",",
"indexes",
")",
":",
"with",
"cache",
"as",
"redis_connection",
":",
"pipe",
"=",
"redis_connection",
".",
"pipeline",
"(",
")",
"for",
"key",
"in",
"set",
"(",
"template",
".",
"keys",
"(",
")"... | Delete an object in Redis using a pipeline.
Deletes all fields defined by the template.
Arguments:
template: a dictionary containg the keys for the object and
template strings for the corresponding redis keys. The template
string uses named string interpolation format. Example:... | [
"Delete",
"an",
"object",
"in",
"Redis",
"using",
"a",
"pipeline",
"."
] | train | https://github.com/refinery29/chassis/blob/1238d5214cbb8f3e1fe7c0dc2fa72f45bf085192/chassis/services/cache.py#L125-L154 |
refinery29/chassis | chassis/services/cache.py | set_value | def set_value(cache, key, value):
"""Set a value by key.
Arguments:
cache:
instance of Cache
key:
'user:342:username',
"""
with cache as redis_connection:
return redis_connection.set(key, value) | python | def set_value(cache, key, value):
"""Set a value by key.
Arguments:
cache:
instance of Cache
key:
'user:342:username',
"""
with cache as redis_connection:
return redis_connection.set(key, value) | [
"def",
"set_value",
"(",
"cache",
",",
"key",
",",
"value",
")",
":",
"with",
"cache",
"as",
"redis_connection",
":",
"return",
"redis_connection",
".",
"set",
"(",
"key",
",",
"value",
")"
] | Set a value by key.
Arguments:
cache:
instance of Cache
key:
'user:342:username', | [
"Set",
"a",
"value",
"by",
"key",
"."
] | train | https://github.com/refinery29/chassis/blob/1238d5214cbb8f3e1fe7c0dc2fa72f45bf085192/chassis/services/cache.py#L175-L186 |
heikomuller/sco-client | scocli/subject.py | get_freesurfer_dir | def get_freesurfer_dir(directory):
"""Find a subfolder in the given directory that contains a Freesurfer
anatomy (this may be the directory itself). Currently, the test is whether
there are sub-folders with name 'surf' and 'mri'. Processes all sub-folders
recursively until a freesurfer directory is foun... | python | def get_freesurfer_dir(directory):
"""Find a subfolder in the given directory that contains a Freesurfer
anatomy (this may be the directory itself). Currently, the test is whether
there are sub-folders with name 'surf' and 'mri'. Processes all sub-folders
recursively until a freesurfer directory is foun... | [
"def",
"get_freesurfer_dir",
"(",
"directory",
")",
":",
"dir_files",
"=",
"[",
"f",
"for",
"f",
"in",
"os",
".",
"listdir",
"(",
"directory",
")",
"]",
"# Look for sub-folders 'surf' and 'mri'",
"if",
"'surf'",
"in",
"dir_files",
"and",
"'mri'",
"in",
"dir_fi... | Find a subfolder in the given directory that contains a Freesurfer
anatomy (this may be the directory itself). Currently, the test is whether
there are sub-folders with name 'surf' and 'mri'. Processes all sub-folders
recursively until a freesurfer directory is found. If no matching folder is
found the ... | [
"Find",
"a",
"subfolder",
"in",
"the",
"given",
"directory",
"that",
"contains",
"a",
"Freesurfer",
"anatomy",
"(",
"this",
"may",
"be",
"the",
"directory",
"itself",
")",
".",
"Currently",
"the",
"test",
"is",
"whether",
"there",
"are",
"sub",
"-",
"folde... | train | https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/subject.py#L132-L162 |
heikomuller/sco-client | scocli/subject.py | SubjectHandle.create | def create(url, filename, properties):
"""Create new subject at given SCO-API by uploading local file.
Expects an tar-archive containing FreeSurfer archive file. Allows to
update properties of created resource.
Parameters
----------
url : string
Url to POST i... | python | def create(url, filename, properties):
"""Create new subject at given SCO-API by uploading local file.
Expects an tar-archive containing FreeSurfer archive file. Allows to
update properties of created resource.
Parameters
----------
url : string
Url to POST i... | [
"def",
"create",
"(",
"url",
",",
"filename",
",",
"properties",
")",
":",
"# Ensure that the file has valid suffix",
"if",
"not",
"has_tar_suffix",
"(",
"filename",
")",
":",
"raise",
"ValueError",
"(",
"'invalid file suffix: '",
"+",
"filename",
")",
"# Upload fil... | Create new subject at given SCO-API by uploading local file.
Expects an tar-archive containing FreeSurfer archive file. Allows to
update properties of created resource.
Parameters
----------
url : string
Url to POST image group create request
filename : strin... | [
"Create",
"new",
"subject",
"at",
"given",
"SCO",
"-",
"API",
"by",
"uploading",
"local",
"file",
".",
"Expects",
"an",
"tar",
"-",
"archive",
"containing",
"FreeSurfer",
"archive",
"file",
".",
"Allows",
"to",
"update",
"properties",
"of",
"created",
"resou... | train | https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/subject.py#L74-L123 |
calvinku96/labreporthelper | labreporthelper/parse.py | getdata | def getdata(inputfile, argnum=None, close=False):
"""
Get data from the .dat files
args:
inputfile: file
Input File
close: bool, default=False
Closes inputfile if True
inputfile (File): Input file
close (boolean): Closes inputfile if True (default: Fa... | python | def getdata(inputfile, argnum=None, close=False):
"""
Get data from the .dat files
args:
inputfile: file
Input File
close: bool, default=False
Closes inputfile if True
inputfile (File): Input file
close (boolean): Closes inputfile if True (default: Fa... | [
"def",
"getdata",
"(",
"inputfile",
",",
"argnum",
"=",
"None",
",",
"close",
"=",
"False",
")",
":",
"# get data and converts them to list",
"# outputtype - list, dict, all",
"output",
"=",
"[",
"]",
"add_data",
"=",
"{",
"}",
"line_num",
"=",
"0",
"for",
"li... | Get data from the .dat files
args:
inputfile: file
Input File
close: bool, default=False
Closes inputfile if True
inputfile (File): Input file
close (boolean): Closes inputfile if True (default: False)
returns:
dictionary:
data: list o... | [
"Get",
"data",
"from",
"the",
".",
"dat",
"files"
] | train | https://github.com/calvinku96/labreporthelper/blob/4d436241f389c02eb188c313190df62ab28c3763/labreporthelper/parse.py#L7-L51 |
calvinku96/labreporthelper | labreporthelper/parse.py | cleandata | def cleandata(inputlist):
"""
Helper function for parse.getdata.
Remove empty variables, convert strings to float
args:
inputlist: list
List of Variables
Returns:
ouput:
Cleaned list
"""
output = []
for e in inputlist:
new = []
for... | python | def cleandata(inputlist):
"""
Helper function for parse.getdata.
Remove empty variables, convert strings to float
args:
inputlist: list
List of Variables
Returns:
ouput:
Cleaned list
"""
output = []
for e in inputlist:
new = []
for... | [
"def",
"cleandata",
"(",
"inputlist",
")",
":",
"output",
"=",
"[",
"]",
"for",
"e",
"in",
"inputlist",
":",
"new",
"=",
"[",
"]",
"for",
"f",
"in",
"e",
":",
"if",
"f",
"==",
"\"--\"",
":",
"new",
".",
"append",
"(",
"None",
")",
"else",
":",
... | Helper function for parse.getdata.
Remove empty variables, convert strings to float
args:
inputlist: list
List of Variables
Returns:
ouput:
Cleaned list | [
"Helper",
"function",
"for",
"parse",
".",
"getdata",
".",
"Remove",
"empty",
"variables",
"convert",
"strings",
"to",
"float"
] | train | https://github.com/calvinku96/labreporthelper/blob/4d436241f389c02eb188c313190df62ab28c3763/labreporthelper/parse.py#L54-L75 |
bird-house/birdhousebuilder.recipe.redis | birdhousebuilder/recipe/redis/__init__.py | Recipe.install_supervisor | def install_supervisor(self, update=False):
"""
install supervisor config for redis
"""
script = supervisor.Recipe(
self.buildout,
self.name,
{'user': self.options.get('user'),
'program': self.options.get('program'),
'command'... | python | def install_supervisor(self, update=False):
"""
install supervisor config for redis
"""
script = supervisor.Recipe(
self.buildout,
self.name,
{'user': self.options.get('user'),
'program': self.options.get('program'),
'command'... | [
"def",
"install_supervisor",
"(",
"self",
",",
"update",
"=",
"False",
")",
":",
"script",
"=",
"supervisor",
".",
"Recipe",
"(",
"self",
".",
"buildout",
",",
"self",
".",
"name",
",",
"{",
"'user'",
":",
"self",
".",
"options",
".",
"get",
"(",
"'u... | install supervisor config for redis | [
"install",
"supervisor",
"config",
"for",
"redis"
] | train | https://github.com/bird-house/birdhousebuilder.recipe.redis/blob/3e66dd2f891547665055d807277d1c8f23c57003/birdhousebuilder/recipe/redis/__init__.py#L67-L80 |
roaet/eh | eh/mdv/tabulate.py | _format | def _format(val, valtype, floatfmt, missingval="", has_invisible=True):
"""Format a value accoding to its type.
Unicode is supported:
>>> hrow = ['\u0431\u0443\u043a\u0432\u0430', '\u0446\u0438\u0444\u0440\u0430'] ; \
tbl = [['\u0430\u0437', 2], ['\u0431\u0443\u043a\u0438', 4]] ; \
good_re... | python | def _format(val, valtype, floatfmt, missingval="", has_invisible=True):
"""Format a value accoding to its type.
Unicode is supported:
>>> hrow = ['\u0431\u0443\u043a\u0432\u0430', '\u0446\u0438\u0444\u0440\u0430'] ; \
tbl = [['\u0430\u0437', 2], ['\u0431\u0443\u043a\u0438', 4]] ; \
good_re... | [
"def",
"_format",
"(",
"val",
",",
"valtype",
",",
"floatfmt",
",",
"missingval",
"=",
"\"\"",
",",
"has_invisible",
"=",
"True",
")",
":",
"if",
"val",
"is",
"None",
":",
"return",
"missingval",
"if",
"valtype",
"in",
"[",
"int",
",",
"_long_type",
",... | Format a value accoding to its type.
Unicode is supported:
>>> hrow = ['\u0431\u0443\u043a\u0432\u0430', '\u0446\u0438\u0444\u0440\u0430'] ; \
tbl = [['\u0430\u0437', 2], ['\u0431\u0443\u043a\u0438', 4]] ; \
good_result = '\\u0431\\u0443\\u043a\\u0432\\u0430 \\u0446\\u0438\\u0444\\u0440\\... | [
"Format",
"a",
"value",
"accoding",
"to",
"its",
"type",
"."
] | train | https://github.com/roaet/eh/blob/9370864a9f1d65bb0f822d0aea83f1169c98f3bd/eh/mdv/tabulate.py#L544-L575 |
roaet/eh | eh/mdv/tabulate.py | _main | def _main():
"""\
Usage: tabulate [options] [FILE ...]
Pretty-print tabular data.
See also https://bitbucket.org/astanin/python-tabulate
FILE a filename of the file with tabular data;
if "-" or missing, read data from stdin.
Options:
-h,... | python | def _main():
"""\
Usage: tabulate [options] [FILE ...]
Pretty-print tabular data.
See also https://bitbucket.org/astanin/python-tabulate
FILE a filename of the file with tabular data;
if "-" or missing, read data from stdin.
Options:
-h,... | [
"def",
"_main",
"(",
")",
":",
"import",
"getopt",
"import",
"sys",
"import",
"textwrap",
"usage",
"=",
"textwrap",
".",
"dedent",
"(",
"_main",
".",
"__doc__",
")",
"try",
":",
"opts",
",",
"args",
"=",
"getopt",
".",
"getopt",
"(",
"sys",
".",
"arg... | \
Usage: tabulate [options] [FILE ...]
Pretty-print tabular data.
See also https://bitbucket.org/astanin/python-tabulate
FILE a filename of the file with tabular data;
if "-" or missing, read data from stdin.
Options:
-h, --help ... | [
"\\",
"Usage",
":",
"tabulate",
"[",
"options",
"]",
"[",
"FILE",
"...",
"]"
] | train | https://github.com/roaet/eh/blob/9370864a9f1d65bb0f822d0aea83f1169c98f3bd/eh/mdv/tabulate.py#L1056-L1124 |
solocompt/plugs-filter | plugs_filter/decorators.py | get_view_model | def get_view_model(cls):
"""
Get the model to use in the filter_class by inspecting
the queryset or by using a declared auto_filters_model
"""
msg = 'When using get_queryset you must set a auto_filters_model field in the viewset'
if cls.queryset is not None:
return cls.queryset.model
... | python | def get_view_model(cls):
"""
Get the model to use in the filter_class by inspecting
the queryset or by using a declared auto_filters_model
"""
msg = 'When using get_queryset you must set a auto_filters_model field in the viewset'
if cls.queryset is not None:
return cls.queryset.model
... | [
"def",
"get_view_model",
"(",
"cls",
")",
":",
"msg",
"=",
"'When using get_queryset you must set a auto_filters_model field in the viewset'",
"if",
"cls",
".",
"queryset",
"is",
"not",
"None",
":",
"return",
"cls",
".",
"queryset",
".",
"model",
"else",
":",
"asser... | Get the model to use in the filter_class by inspecting
the queryset or by using a declared auto_filters_model | [
"Get",
"the",
"model",
"to",
"use",
"in",
"the",
"filter_class",
"by",
"inspecting",
"the",
"queryset",
"or",
"by",
"using",
"a",
"declared",
"auto_filters_model"
] | train | https://github.com/solocompt/plugs-filter/blob/cb34c7d662d3f96c07c10b3ed0a34bafef78b52c/plugs_filter/decorators.py#L8-L18 |
solocompt/plugs-filter | plugs_filter/decorators.py | auto_filters | def auto_filters(cls):
"""
Adds a dynamic filterclass to a viewset
with all auto filters available for the field type
that are declared in a tuple auto_filter_fields
@auto_filters
def class(...):
...
auto_filters_fields('id', 'location', 'category')
"""
msg = 'Viewset mu... | python | def auto_filters(cls):
"""
Adds a dynamic filterclass to a viewset
with all auto filters available for the field type
that are declared in a tuple auto_filter_fields
@auto_filters
def class(...):
...
auto_filters_fields('id', 'location', 'category')
"""
msg = 'Viewset mu... | [
"def",
"auto_filters",
"(",
"cls",
")",
":",
"msg",
"=",
"'Viewset must have auto_filters_fields or auto_filters_exclude attribute when using auto_filters decorator'",
"if",
"not",
"hasattr",
"(",
"cls",
",",
"'auto_filters_fields'",
")",
"and",
"not",
"hasattr",
"(",
"cls"... | Adds a dynamic filterclass to a viewset
with all auto filters available for the field type
that are declared in a tuple auto_filter_fields
@auto_filters
def class(...):
...
auto_filters_fields('id', 'location', 'category') | [
"Adds",
"a",
"dynamic",
"filterclass",
"to",
"a",
"viewset",
"with",
"all",
"auto",
"filters",
"available",
"for",
"the",
"field",
"type",
"that",
"are",
"declared",
"in",
"a",
"tuple",
"auto_filter_fields"
] | train | https://github.com/solocompt/plugs-filter/blob/cb34c7d662d3f96c07c10b3ed0a34bafef78b52c/plugs_filter/decorators.py#L32-L58 |
rackerlabs/rackspace-python-neutronclient | neutronclient/shell.py | env | def env(*_vars, **kwargs):
"""Search for the first defined of possibly many env vars.
Returns the first environment variable defined in vars, or
returns the default defined in kwargs.
"""
for v in _vars:
value = os.environ.get(v, None)
if value:
return value
return ... | python | def env(*_vars, **kwargs):
"""Search for the first defined of possibly many env vars.
Returns the first environment variable defined in vars, or
returns the default defined in kwargs.
"""
for v in _vars:
value = os.environ.get(v, None)
if value:
return value
return ... | [
"def",
"env",
"(",
"*",
"_vars",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"v",
"in",
"_vars",
":",
"value",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"v",
",",
"None",
")",
"if",
"value",
":",
"return",
"value",
"return",
"kwargs",
".",
"get... | Search for the first defined of possibly many env vars.
Returns the first environment variable defined in vars, or
returns the default defined in kwargs. | [
"Search",
"for",
"the",
"first",
"defined",
"of",
"possibly",
"many",
"env",
"vars",
"."
] | train | https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/shell.py#L126-L137 |
rackerlabs/rackspace-python-neutronclient | neutronclient/shell.py | NeutronShell.build_option_parser | def build_option_parser(self, description, version):
"""Return an argparse option parser for this application.
Subclasses may override this method to extend
the parser with more global options.
:param description: full description of the application
:paramtype description: str
... | python | def build_option_parser(self, description, version):
"""Return an argparse option parser for this application.
Subclasses may override this method to extend
the parser with more global options.
:param description: full description of the application
:paramtype description: str
... | [
"def",
"build_option_parser",
"(",
"self",
",",
"description",
",",
"version",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"description",
",",
"add_help",
"=",
"False",
",",
")",
"parser",
".",
"add_argument",
"(",
"'... | Return an argparse option parser for this application.
Subclasses may override this method to extend
the parser with more global options.
:param description: full description of the application
:paramtype description: str
:param version: version number for the application
... | [
"Return",
"an",
"argparse",
"option",
"parser",
"for",
"this",
"application",
"."
] | train | https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/shell.py#L510-L557 |
rackerlabs/rackspace-python-neutronclient | neutronclient/shell.py | NeutronShell._bash_completion | def _bash_completion(self):
"""Prints all of the commands and options for bash-completion."""
commands = set()
options = set()
for option, _action in self.parser._option_string_actions.items():
options.add(option)
for _name, _command in self.command_manager:
... | python | def _bash_completion(self):
"""Prints all of the commands and options for bash-completion."""
commands = set()
options = set()
for option, _action in self.parser._option_string_actions.items():
options.add(option)
for _name, _command in self.command_manager:
... | [
"def",
"_bash_completion",
"(",
"self",
")",
":",
"commands",
"=",
"set",
"(",
")",
"options",
"=",
"set",
"(",
")",
"for",
"option",
",",
"_action",
"in",
"self",
".",
"parser",
".",
"_option_string_actions",
".",
"items",
"(",
")",
":",
"options",
".... | Prints all of the commands and options for bash-completion. | [
"Prints",
"all",
"of",
"the",
"commands",
"and",
"options",
"for",
"bash",
"-",
"completion",
"."
] | train | https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/shell.py#L782-L795 |
rackerlabs/rackspace-python-neutronclient | neutronclient/shell.py | NeutronShell.run | def run(self, argv):
"""Equivalent to the main program for the application.
:param argv: input arguments and options
:paramtype argv: list of str
"""
try:
index = 0
command_pos = -1
help_pos = -1
help_command_pos = -1
f... | python | def run(self, argv):
"""Equivalent to the main program for the application.
:param argv: input arguments and options
:paramtype argv: list of str
"""
try:
index = 0
command_pos = -1
help_pos = -1
help_command_pos = -1
f... | [
"def",
"run",
"(",
"self",
",",
"argv",
")",
":",
"try",
":",
"index",
"=",
"0",
"command_pos",
"=",
"-",
"1",
"help_pos",
"=",
"-",
"1",
"help_command_pos",
"=",
"-",
"1",
"for",
"arg",
"in",
"argv",
":",
"if",
"arg",
"==",
"'bash-completion'",
"a... | Equivalent to the main program for the application.
:param argv: input arguments and options
:paramtype argv: list of str | [
"Equivalent",
"to",
"the",
"main",
"program",
"for",
"the",
"application",
"."
] | train | https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/shell.py#L820-L864 |
rackerlabs/rackspace-python-neutronclient | neutronclient/shell.py | NeutronShell.authenticate_user | def authenticate_user(self):
"""Confirm user authentication
Make sure the user has provided all of the authentication
info we need.
"""
cloud_config = os_client_config.OpenStackConfig().get_one_cloud(
cloud=self.options.os_cloud, argparse=self.options,
ne... | python | def authenticate_user(self):
"""Confirm user authentication
Make sure the user has provided all of the authentication
info we need.
"""
cloud_config = os_client_config.OpenStackConfig().get_one_cloud(
cloud=self.options.os_cloud, argparse=self.options,
ne... | [
"def",
"authenticate_user",
"(",
"self",
")",
":",
"cloud_config",
"=",
"os_client_config",
".",
"OpenStackConfig",
"(",
")",
".",
"get_one_cloud",
"(",
"cloud",
"=",
"self",
".",
"options",
".",
"os_cloud",
",",
"argparse",
"=",
"self",
".",
"options",
",",... | Confirm user authentication
Make sure the user has provided all of the authentication
info we need. | [
"Confirm",
"user",
"authentication"
] | train | https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/shell.py#L889-L934 |
rackerlabs/rackspace-python-neutronclient | neutronclient/shell.py | NeutronShell.initialize_app | def initialize_app(self, argv):
"""Global app init bits:
* set up API versions
* validate authentication info
"""
super(NeutronShell, self).initialize_app(argv)
self.api_version = {'network': self.api_version}
# If the user is not asking for help, make sure th... | python | def initialize_app(self, argv):
"""Global app init bits:
* set up API versions
* validate authentication info
"""
super(NeutronShell, self).initialize_app(argv)
self.api_version = {'network': self.api_version}
# If the user is not asking for help, make sure th... | [
"def",
"initialize_app",
"(",
"self",
",",
"argv",
")",
":",
"super",
"(",
"NeutronShell",
",",
"self",
")",
".",
"initialize_app",
"(",
"argv",
")",
"self",
".",
"api_version",
"=",
"{",
"'network'",
":",
"self",
".",
"api_version",
"}",
"# If the user is... | Global app init bits:
* set up API versions
* validate authentication info | [
"Global",
"app",
"init",
"bits",
":"
] | train | https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/shell.py#L936-L954 |
rackerlabs/rackspace-python-neutronclient | neutronclient/shell.py | NeutronShell.configure_logging | def configure_logging(self):
"""Create logging handlers for any log output."""
root_logger = logging.getLogger('')
# Set up logging to a file
root_logger.setLevel(logging.DEBUG)
# Send higher-level messages to the console via stderr
console = logging.StreamHandler(self.... | python | def configure_logging(self):
"""Create logging handlers for any log output."""
root_logger = logging.getLogger('')
# Set up logging to a file
root_logger.setLevel(logging.DEBUG)
# Send higher-level messages to the console via stderr
console = logging.StreamHandler(self.... | [
"def",
"configure_logging",
"(",
"self",
")",
":",
"root_logger",
"=",
"logging",
".",
"getLogger",
"(",
"''",
")",
"# Set up logging to a file",
"root_logger",
".",
"setLevel",
"(",
"logging",
".",
"DEBUG",
")",
"# Send higher-level messages to the console via stderr",... | Create logging handlers for any log output. | [
"Create",
"logging",
"handlers",
"for",
"any",
"log",
"output",
"."
] | train | https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/shell.py#L956-L984 |
TheOneHyer/arandomness | build/lib.linux-x86_64-3.6/arandomness/str/max_substring.py | max_substring | def max_substring(words, position=0, _last_letter=''):
"""Finds max substring shared by all strings starting at position
Args:
words (list): list of unicode of all words to compare
position (int): starting position in each word to begin analyzing
for substring
... | python | def max_substring(words, position=0, _last_letter=''):
"""Finds max substring shared by all strings starting at position
Args:
words (list): list of unicode of all words to compare
position (int): starting position in each word to begin analyzing
for substring
... | [
"def",
"max_substring",
"(",
"words",
",",
"position",
"=",
"0",
",",
"_last_letter",
"=",
"''",
")",
":",
"# If end of word is reached, begin reconstructing the substring",
"try",
":",
"letter",
"=",
"[",
"word",
"[",
"position",
"]",
"for",
"word",
"in",
"word... | Finds max substring shared by all strings starting at position
Args:
words (list): list of unicode of all words to compare
position (int): starting position in each word to begin analyzing
for substring
_last_letter (unicode): last common letter, only for use
... | [
"Finds",
"max",
"substring",
"shared",
"by",
"all",
"strings",
"starting",
"at",
"position"
] | train | https://github.com/TheOneHyer/arandomness/blob/ae9f630e9a1d67b0eb6d61644a49756de8a5268c/build/lib.linux-x86_64-3.6/arandomness/str/max_substring.py#L31-L71 |
contains-io/containment | containment/cli/activate.py | activate | def activate():
"""
Usage:
containment activate
"""
# This is derived from the clone
cli = CommandLineInterface()
cli.ensure_config()
cli.write_dockerfile()
cli.build()
cli.run() | python | def activate():
"""
Usage:
containment activate
"""
# This is derived from the clone
cli = CommandLineInterface()
cli.ensure_config()
cli.write_dockerfile()
cli.build()
cli.run() | [
"def",
"activate",
"(",
")",
":",
"# This is derived from the clone",
"cli",
"=",
"CommandLineInterface",
"(",
")",
"cli",
".",
"ensure_config",
"(",
")",
"cli",
".",
"write_dockerfile",
"(",
")",
"cli",
".",
"build",
"(",
")",
"cli",
".",
"run",
"(",
")"
... | Usage:
containment activate | [
"Usage",
":",
"containment",
"activate"
] | train | https://github.com/contains-io/containment/blob/4f7e2c2338e0ca7c107a7b3a9913bb5e6e07245f/containment/cli/activate.py#L11-L21 |
abhinav/reversible | reversible/tornado/generator.py | _map_generator | def _map_generator(f, generator):
"""Apply ``f`` to the results of the given bi-directional generator.
Unfortunately, generator comprehension (``f(x) for x in gen``) does not
work for as expected for bi-directional generators. It won't send
exceptions and results back.
This function implements a m... | python | def _map_generator(f, generator):
"""Apply ``f`` to the results of the given bi-directional generator.
Unfortunately, generator comprehension (``f(x) for x in gen``) does not
work for as expected for bi-directional generators. It won't send
exceptions and results back.
This function implements a m... | [
"def",
"_map_generator",
"(",
"f",
",",
"generator",
")",
":",
"item",
"=",
"next",
"(",
"generator",
")",
"while",
"True",
":",
"try",
":",
"result",
"=",
"yield",
"f",
"(",
"item",
")",
"except",
"Exception",
":",
"item",
"=",
"generator",
".",
"th... | Apply ``f`` to the results of the given bi-directional generator.
Unfortunately, generator comprehension (``f(x) for x in gen``) does not
work for as expected for bi-directional generators. It won't send
exceptions and results back.
This function implements a map function for generators that sends val... | [
"Apply",
"f",
"to",
"the",
"results",
"of",
"the",
"given",
"bi",
"-",
"directional",
"generator",
"."
] | train | https://github.com/abhinav/reversible/blob/7e28aaf0390f7d4b889c6ac14d7b340f8f314e89/reversible/tornado/generator.py#L34-L51 |
abhinav/reversible | reversible/tornado/generator.py | gen | def gen(function, io_loop=None):
"""Allows using a generator to chain together reversible actions.
This function is very similar to :py:func:`reversible.gen` except that it
may be used with actions whose ``forwards`` and/or ``backwards`` methods
are couroutines. Specifically, if either of those methods... | python | def gen(function, io_loop=None):
"""Allows using a generator to chain together reversible actions.
This function is very similar to :py:func:`reversible.gen` except that it
may be used with actions whose ``forwards`` and/or ``backwards`` methods
are couroutines. Specifically, if either of those methods... | [
"def",
"gen",
"(",
"function",
",",
"io_loop",
"=",
"None",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"function",
")",
"# TODO: use wrapt instead?",
"def",
"new_function",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"value",
"... | Allows using a generator to chain together reversible actions.
This function is very similar to :py:func:`reversible.gen` except that it
may be used with actions whose ``forwards`` and/or ``backwards`` methods
are couroutines. Specifically, if either of those methods return futures
the generated action... | [
"Allows",
"using",
"a",
"generator",
"to",
"chain",
"together",
"reversible",
"actions",
"."
] | train | https://github.com/abhinav/reversible/blob/7e28aaf0390f7d4b889c6ac14d7b340f8f314e89/reversible/tornado/generator.py#L76-L144 |
patrickayoup/md2remark | md2remark/main.py | compile_markdown_file | def compile_markdown_file(source_file):
'''Compiles a single markdown file to a remark.js slideshow.'''
template = pkg_resources.resource_string('md2remark.resources.templates', 'slideshow.mustache')
renderer = pystache.Renderer(search_dirs='./templates')
f = open(source_file, 'r')
slideshow_md = f.read()
... | python | def compile_markdown_file(source_file):
'''Compiles a single markdown file to a remark.js slideshow.'''
template = pkg_resources.resource_string('md2remark.resources.templates', 'slideshow.mustache')
renderer = pystache.Renderer(search_dirs='./templates')
f = open(source_file, 'r')
slideshow_md = f.read()
... | [
"def",
"compile_markdown_file",
"(",
"source_file",
")",
":",
"template",
"=",
"pkg_resources",
".",
"resource_string",
"(",
"'md2remark.resources.templates'",
",",
"'slideshow.mustache'",
")",
"renderer",
"=",
"pystache",
".",
"Renderer",
"(",
"search_dirs",
"=",
"'.... | Compiles a single markdown file to a remark.js slideshow. | [
"Compiles",
"a",
"single",
"markdown",
"file",
"to",
"a",
"remark",
".",
"js",
"slideshow",
"."
] | train | https://github.com/patrickayoup/md2remark/blob/04e66462046cd123c5b1810454d949c3a05bc057/md2remark/main.py#L8-L26 |
patrickayoup/md2remark | md2remark/main.py | compile_slides | def compile_slides(source):
'''Compiles the source to a remark.js slideshow.'''
# if it's a directory, do all md files.
if os.path.isdir(source):
for f in os.listdir(source):
if f.lower().endswith('.md'):
compile_markdown_file(os.path.join(source, f))
else:
compile_markdown_file(source) | python | def compile_slides(source):
'''Compiles the source to a remark.js slideshow.'''
# if it's a directory, do all md files.
if os.path.isdir(source):
for f in os.listdir(source):
if f.lower().endswith('.md'):
compile_markdown_file(os.path.join(source, f))
else:
compile_markdown_file(source) | [
"def",
"compile_slides",
"(",
"source",
")",
":",
"# if it's a directory, do all md files.",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"source",
")",
":",
"for",
"f",
"in",
"os",
".",
"listdir",
"(",
"source",
")",
":",
"if",
"f",
".",
"lower",
"(",
... | Compiles the source to a remark.js slideshow. | [
"Compiles",
"the",
"source",
"to",
"a",
"remark",
".",
"js",
"slideshow",
"."
] | train | https://github.com/patrickayoup/md2remark/blob/04e66462046cd123c5b1810454d949c3a05bc057/md2remark/main.py#L28-L36 |
patrickayoup/md2remark | md2remark/main.py | parse_cl_args | def parse_cl_args(arg_vector):
'''Parses the command line arguments'''
parser = argparse.ArgumentParser(description='Compiles markdown files into html files for remark.js')
parser.add_argument('source', metavar='source', help='the source to compile. If a directory is provided, all markdown files in that directory... | python | def parse_cl_args(arg_vector):
'''Parses the command line arguments'''
parser = argparse.ArgumentParser(description='Compiles markdown files into html files for remark.js')
parser.add_argument('source', metavar='source', help='the source to compile. If a directory is provided, all markdown files in that directory... | [
"def",
"parse_cl_args",
"(",
"arg_vector",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'Compiles markdown files into html files for remark.js'",
")",
"parser",
".",
"add_argument",
"(",
"'source'",
",",
"metavar",
"=",
"'sourc... | Parses the command line arguments | [
"Parses",
"the",
"command",
"line",
"arguments"
] | train | https://github.com/patrickayoup/md2remark/blob/04e66462046cd123c5b1810454d949c3a05bc057/md2remark/main.py#L38-L43 |
sirrice/scorpionsql | scorpionsql/sql.py | Query.to_outer_join_sql | def to_outer_join_sql(self, orig_where = []):
"""
Construct a SQL query that includes all groups that would have
existed (exists in the orig_where clause) if the WHERE clause were not present
"""
if not self.group:
return str(self)
select = str(self.select)
fr = ','.join(self.fr)
... | python | def to_outer_join_sql(self, orig_where = []):
"""
Construct a SQL query that includes all groups that would have
existed (exists in the orig_where clause) if the WHERE clause were not present
"""
if not self.group:
return str(self)
select = str(self.select)
fr = ','.join(self.fr)
... | [
"def",
"to_outer_join_sql",
"(",
"self",
",",
"orig_where",
"=",
"[",
"]",
")",
":",
"if",
"not",
"self",
".",
"group",
":",
"return",
"str",
"(",
"self",
")",
"select",
"=",
"str",
"(",
"self",
".",
"select",
")",
"fr",
"=",
"','",
".",
"join",
... | Construct a SQL query that includes all groups that would have
existed (exists in the orig_where clause) if the WHERE clause were not present | [
"Construct",
"a",
"SQL",
"query",
"that",
"includes",
"all",
"groups",
"that",
"would",
"have",
"existed",
"(",
"exists",
"in",
"the",
"orig_where",
"clause",
")",
"if",
"the",
"WHERE",
"clause",
"were",
"not",
"present"
] | train | https://github.com/sirrice/scorpionsql/blob/baa05b745fae5df3171244c3e32160bd36c99e86/scorpionsql/sql.py#L57-L103 |
sirrice/scorpionsql | scorpionsql/sql.py | Query.get_filter_qobj | def get_filter_qobj(self, keys=None):
"""
Return a copy of this Query object with additional where clauses for the
keys in the argument
"""
# only care about columns in aggregates right?
cols = set()
for agg in self.select.aggregates:
cols.update(agg.cols)
sels = [SelectExpr(col... | python | def get_filter_qobj(self, keys=None):
"""
Return a copy of this Query object with additional where clauses for the
keys in the argument
"""
# only care about columns in aggregates right?
cols = set()
for agg in self.select.aggregates:
cols.update(agg.cols)
sels = [SelectExpr(col... | [
"def",
"get_filter_qobj",
"(",
"self",
",",
"keys",
"=",
"None",
")",
":",
"# only care about columns in aggregates right?",
"cols",
"=",
"set",
"(",
")",
"for",
"agg",
"in",
"self",
".",
"select",
".",
"aggregates",
":",
"cols",
".",
"update",
"(",
"agg",
... | Return a copy of this Query object with additional where clauses for the
keys in the argument | [
"Return",
"a",
"copy",
"of",
"this",
"Query",
"object",
"with",
"additional",
"where",
"clauses",
"for",
"the",
"keys",
"in",
"the",
"argument"
] | train | https://github.com/sirrice/scorpionsql/blob/baa05b745fae5df3171244c3e32160bd36c99e86/scorpionsql/sql.py#L123-L150 |
noroute/teamcity-buildchain-stats | tc_buildchain_stats/gatherer.py | BuildChainStatsGatherer.total_build_duration_for_chain | def total_build_duration_for_chain(self, build_chain_id):
"""Returns the total duration for one specific build chain run"""
return sum([
int(self.__build_duration_for_id(id))
for id in self.__build_ids_of_chain(build_chain_id)
]) | python | def total_build_duration_for_chain(self, build_chain_id):
"""Returns the total duration for one specific build chain run"""
return sum([
int(self.__build_duration_for_id(id))
for id in self.__build_ids_of_chain(build_chain_id)
]) | [
"def",
"total_build_duration_for_chain",
"(",
"self",
",",
"build_chain_id",
")",
":",
"return",
"sum",
"(",
"[",
"int",
"(",
"self",
".",
"__build_duration_for_id",
"(",
"id",
")",
")",
"for",
"id",
"in",
"self",
".",
"__build_ids_of_chain",
"(",
"build_chain... | Returns the total duration for one specific build chain run | [
"Returns",
"the",
"total",
"duration",
"for",
"one",
"specific",
"build",
"chain",
"run"
] | train | https://github.com/noroute/teamcity-buildchain-stats/blob/54fd7194cd2b7b02dc137e7a9ed013aac96af841/tc_buildchain_stats/gatherer.py#L101-L106 |
noroute/teamcity-buildchain-stats | tc_buildchain_stats/gatherer.py | BuildChainStatsGatherer.build_cycle_time | def build_cycle_time(self, build_id):
"""Returns a BuildCycleTime object for the given build"""
json_form = self.__retrieve_as_json(self.builds_path % build_id)
return BuildCycleTime(
build_id,
json_form[u'buildTypeId'],
as_date(json_form, u'startDate'),
... | python | def build_cycle_time(self, build_id):
"""Returns a BuildCycleTime object for the given build"""
json_form = self.__retrieve_as_json(self.builds_path % build_id)
return BuildCycleTime(
build_id,
json_form[u'buildTypeId'],
as_date(json_form, u'startDate'),
... | [
"def",
"build_cycle_time",
"(",
"self",
",",
"build_id",
")",
":",
"json_form",
"=",
"self",
".",
"__retrieve_as_json",
"(",
"self",
".",
"builds_path",
"%",
"build_id",
")",
"return",
"BuildCycleTime",
"(",
"build_id",
",",
"json_form",
"[",
"u'buildTypeId'",
... | Returns a BuildCycleTime object for the given build | [
"Returns",
"a",
"BuildCycleTime",
"object",
"for",
"the",
"given",
"build"
] | train | https://github.com/noroute/teamcity-buildchain-stats/blob/54fd7194cd2b7b02dc137e7a9ed013aac96af841/tc_buildchain_stats/gatherer.py#L123-L131 |
noroute/teamcity-buildchain-stats | tc_buildchain_stats/gatherer.py | BuildChainStatsGatherer.build_stats_for_chain | def build_stats_for_chain(self, build_chain_id):
"""Returns a list of Build tuples for all elements in the build chain.
This method allows insight into the runtime of each configuratio inside the build chain.
"""
json_form = self.__retrieve_as_json(self.build_chain_path % build_chain_id... | python | def build_stats_for_chain(self, build_chain_id):
"""Returns a list of Build tuples for all elements in the build chain.
This method allows insight into the runtime of each configuratio inside the build chain.
"""
json_form = self.__retrieve_as_json(self.build_chain_path % build_chain_id... | [
"def",
"build_stats_for_chain",
"(",
"self",
",",
"build_chain_id",
")",
":",
"json_form",
"=",
"self",
".",
"__retrieve_as_json",
"(",
"self",
".",
"build_chain_path",
"%",
"build_chain_id",
")",
"builds",
"=",
"[",
"{",
"'build_id'",
":",
"build",
"[",
"u'id... | Returns a list of Build tuples for all elements in the build chain.
This method allows insight into the runtime of each configuratio inside the build chain. | [
"Returns",
"a",
"list",
"of",
"Build",
"tuples",
"for",
"all",
"elements",
"in",
"the",
"build",
"chain",
"."
] | train | https://github.com/noroute/teamcity-buildchain-stats/blob/54fd7194cd2b7b02dc137e7a9ed013aac96af841/tc_buildchain_stats/gatherer.py#L133-L148 |
mirca/muchbettermoments | muchbettermoments.py | quadratic_2d | def quadratic_2d(data):
"""
Compute the quadratic estimate of the centroid in a 2d-array.
Args:
data (2darray): two dimensional data array
Returns
center (tuple): centroid estimate on the row and column directions,
respectively
"""
arg_data_max = np.argm... | python | def quadratic_2d(data):
"""
Compute the quadratic estimate of the centroid in a 2d-array.
Args:
data (2darray): two dimensional data array
Returns
center (tuple): centroid estimate on the row and column directions,
respectively
"""
arg_data_max = np.argm... | [
"def",
"quadratic_2d",
"(",
"data",
")",
":",
"arg_data_max",
"=",
"np",
".",
"argmax",
"(",
"data",
")",
"i",
",",
"j",
"=",
"np",
".",
"unravel_index",
"(",
"arg_data_max",
",",
"data",
".",
"shape",
")",
"z_",
"=",
"data",
"[",
"i",
"-",
"1",
... | Compute the quadratic estimate of the centroid in a 2d-array.
Args:
data (2darray): two dimensional data array
Returns
center (tuple): centroid estimate on the row and column directions,
respectively | [
"Compute",
"the",
"quadratic",
"estimate",
"of",
"the",
"centroid",
"in",
"a",
"2d",
"-",
"array",
"."
] | train | https://github.com/mirca/muchbettermoments/blob/8cc2bf18ff52abf86151a12358434691bea0857d/muchbettermoments.py#L9-L46 |
bwesterb/mirte | src/mirteFile.py | depsOf_of_mirteFile_instance_definition | def depsOf_of_mirteFile_instance_definition(man, insts):
""" Returns a function that returns the dependencies of
an instance definition by its name, where insts is a
dictionary of instance definitions from a mirteFile """
return lambda x: [a[1] for a in six.iteritems(insts[x])
... | python | def depsOf_of_mirteFile_instance_definition(man, insts):
""" Returns a function that returns the dependencies of
an instance definition by its name, where insts is a
dictionary of instance definitions from a mirteFile """
return lambda x: [a[1] for a in six.iteritems(insts[x])
... | [
"def",
"depsOf_of_mirteFile_instance_definition",
"(",
"man",
",",
"insts",
")",
":",
"return",
"lambda",
"x",
":",
"[",
"a",
"[",
"1",
"]",
"for",
"a",
"in",
"six",
".",
"iteritems",
"(",
"insts",
"[",
"x",
"]",
")",
"if",
"a",
"[",
"0",
"]",
"in"... | Returns a function that returns the dependencies of
an instance definition by its name, where insts is a
dictionary of instance definitions from a mirteFile | [
"Returns",
"a",
"function",
"that",
"returns",
"the",
"dependencies",
"of",
"an",
"instance",
"definition",
"by",
"its",
"name",
"where",
"insts",
"is",
"a",
"dictionary",
"of",
"instance",
"definitions",
"from",
"a",
"mirteFile"
] | train | https://github.com/bwesterb/mirte/blob/c58db8c993cd15ffdc64b52703cd466213913200/src/mirteFile.py#L31-L38 |
bwesterb/mirte | src/mirteFile.py | depsOf_of_mirteFile_module_definition | def depsOf_of_mirteFile_module_definition(defs):
""" Returns a function that returns the dependencies of a module
definition by its name, where defs is a dictionary of module
definitions from a mirteFile """
return lambda x: (list(filter(lambda z: z is not None and z in defs,
... | python | def depsOf_of_mirteFile_module_definition(defs):
""" Returns a function that returns the dependencies of a module
definition by its name, where defs is a dictionary of module
definitions from a mirteFile """
return lambda x: (list(filter(lambda z: z is not None and z in defs,
... | [
"def",
"depsOf_of_mirteFile_module_definition",
"(",
"defs",
")",
":",
"return",
"lambda",
"x",
":",
"(",
"list",
"(",
"filter",
"(",
"lambda",
"z",
":",
"z",
"is",
"not",
"None",
"and",
"z",
"in",
"defs",
",",
"map",
"(",
"lambda",
"y",
":",
"y",
"[... | Returns a function that returns the dependencies of a module
definition by its name, where defs is a dictionary of module
definitions from a mirteFile | [
"Returns",
"a",
"function",
"that",
"returns",
"the",
"dependencies",
"of",
"a",
"module",
"definition",
"by",
"its",
"name",
"where",
"defs",
"is",
"a",
"dictionary",
"of",
"module",
"definitions",
"from",
"a",
"mirteFile"
] | train | https://github.com/bwesterb/mirte/blob/c58db8c993cd15ffdc64b52703cd466213913200/src/mirteFile.py#L41-L49 |
bwesterb/mirte | src/mirteFile.py | module_definition_from_mirteFile_dict | def module_definition_from_mirteFile_dict(man, d):
""" Creates a ModuleDefinition instance from the dictionary <d> from
a mirte-file for the Manager instance <man>. """
m = ModuleDefinition()
if 'inherits' not in d:
d['inherits'] = list()
if 'settings' not in d:
d['settings'] = d... | python | def module_definition_from_mirteFile_dict(man, d):
""" Creates a ModuleDefinition instance from the dictionary <d> from
a mirte-file for the Manager instance <man>. """
m = ModuleDefinition()
if 'inherits' not in d:
d['inherits'] = list()
if 'settings' not in d:
d['settings'] = d... | [
"def",
"module_definition_from_mirteFile_dict",
"(",
"man",
",",
"d",
")",
":",
"m",
"=",
"ModuleDefinition",
"(",
")",
"if",
"'inherits'",
"not",
"in",
"d",
":",
"d",
"[",
"'inherits'",
"]",
"=",
"list",
"(",
")",
"if",
"'settings'",
"not",
"in",
"d",
... | Creates a ModuleDefinition instance from the dictionary <d> from
a mirte-file for the Manager instance <man>. | [
"Creates",
"a",
"ModuleDefinition",
"instance",
"from",
"the",
"dictionary",
"<d",
">",
"from",
"a",
"mirte",
"-",
"file",
"for",
"the",
"Manager",
"instance",
"<man",
">",
"."
] | train | https://github.com/bwesterb/mirte/blob/c58db8c993cd15ffdc64b52703cd466213913200/src/mirteFile.py#L52-L92 |
bwesterb/mirte | src/mirteFile.py | load_mirteFile | def load_mirteFile(path, m, logger=None):
""" Loads the mirte-file at <path> into the manager <m>. """
l = logging.getLogger('load_mirteFile') if logger is None else logger
had = set()
for name, path, d in walk_mirteFiles(path, logger):
if os.path.realpath(path) in m.loaded_mirteFiles:
... | python | def load_mirteFile(path, m, logger=None):
""" Loads the mirte-file at <path> into the manager <m>. """
l = logging.getLogger('load_mirteFile') if logger is None else logger
had = set()
for name, path, d in walk_mirteFiles(path, logger):
if os.path.realpath(path) in m.loaded_mirteFiles:
... | [
"def",
"load_mirteFile",
"(",
"path",
",",
"m",
",",
"logger",
"=",
"None",
")",
":",
"l",
"=",
"logging",
".",
"getLogger",
"(",
"'load_mirteFile'",
")",
"if",
"logger",
"is",
"None",
"else",
"logger",
"had",
"=",
"set",
"(",
")",
"for",
"name",
","... | Loads the mirte-file at <path> into the manager <m>. | [
"Loads",
"the",
"mirte",
"-",
"file",
"at",
"<path",
">",
"into",
"the",
"manager",
"<m",
">",
"."
] | train | https://github.com/bwesterb/mirte/blob/c58db8c993cd15ffdc64b52703cd466213913200/src/mirteFile.py#L95-L109 |
bwesterb/mirte | src/mirteFile.py | _load_mirteFile | def _load_mirteFile(d, m):
""" Loads the dictionary from the mirteFile into <m> """
defs = d['definitions'] if 'definitions' in d else {}
insts = d['instances'] if 'instances' in d else {}
# Filter out existing instances
insts_to_skip = []
for k in insts:
if k in m.insts:
m.u... | python | def _load_mirteFile(d, m):
""" Loads the dictionary from the mirteFile into <m> """
defs = d['definitions'] if 'definitions' in d else {}
insts = d['instances'] if 'instances' in d else {}
# Filter out existing instances
insts_to_skip = []
for k in insts:
if k in m.insts:
m.u... | [
"def",
"_load_mirteFile",
"(",
"d",
",",
"m",
")",
":",
"defs",
"=",
"d",
"[",
"'definitions'",
"]",
"if",
"'definitions'",
"in",
"d",
"else",
"{",
"}",
"insts",
"=",
"d",
"[",
"'instances'",
"]",
"if",
"'instances'",
"in",
"d",
"else",
"{",
"}",
"... | Loads the dictionary from the mirteFile into <m> | [
"Loads",
"the",
"dictionary",
"from",
"the",
"mirteFile",
"into",
"<m",
">"
] | train | https://github.com/bwesterb/mirte/blob/c58db8c993cd15ffdc64b52703cd466213913200/src/mirteFile.py#L112-L156 |
bwesterb/mirte | src/mirteFile.py | find_mirteFile | def find_mirteFile(name, extra_path=None):
""" Resolves <name> to a path. Uses <extra_path> """
extra_path = () if extra_path is None else extra_path
for bp in chain(extra_path, sys.path):
pb = os.path.join(bp, name)
p = pb + FILE_SUFFIX
if os.path.exists(p):
return os.p... | python | def find_mirteFile(name, extra_path=None):
""" Resolves <name> to a path. Uses <extra_path> """
extra_path = () if extra_path is None else extra_path
for bp in chain(extra_path, sys.path):
pb = os.path.join(bp, name)
p = pb + FILE_SUFFIX
if os.path.exists(p):
return os.p... | [
"def",
"find_mirteFile",
"(",
"name",
",",
"extra_path",
"=",
"None",
")",
":",
"extra_path",
"=",
"(",
")",
"if",
"extra_path",
"is",
"None",
"else",
"extra_path",
"for",
"bp",
"in",
"chain",
"(",
"extra_path",
",",
"sys",
".",
"path",
")",
":",
"pb",... | Resolves <name> to a path. Uses <extra_path> | [
"Resolves",
"<name",
">",
"to",
"a",
"path",
".",
"Uses",
"<extra_path",
">"
] | train | https://github.com/bwesterb/mirte/blob/c58db8c993cd15ffdc64b52703cd466213913200/src/mirteFile.py#L159-L170 |
bwesterb/mirte | src/mirteFile.py | walk_mirteFiles | def walk_mirteFiles(name, logger=None):
""" Yields (cpath, d) for all dependencies of and including the
mirte-file <name>, where <d> are the dictionaries from
the mirte-file at <cpath> """
stack = [(name, find_mirteFile(name, (os.getcwd(),)))]
loadStack = []
had = dict()
while stack:... | python | def walk_mirteFiles(name, logger=None):
""" Yields (cpath, d) for all dependencies of and including the
mirte-file <name>, where <d> are the dictionaries from
the mirte-file at <cpath> """
stack = [(name, find_mirteFile(name, (os.getcwd(),)))]
loadStack = []
had = dict()
while stack:... | [
"def",
"walk_mirteFiles",
"(",
"name",
",",
"logger",
"=",
"None",
")",
":",
"stack",
"=",
"[",
"(",
"name",
",",
"find_mirteFile",
"(",
"name",
",",
"(",
"os",
".",
"getcwd",
"(",
")",
",",
")",
")",
")",
"]",
"loadStack",
"=",
"[",
"]",
"had",
... | Yields (cpath, d) for all dependencies of and including the
mirte-file <name>, where <d> are the dictionaries from
the mirte-file at <cpath> | [
"Yields",
"(",
"cpath",
"d",
")",
"for",
"all",
"dependencies",
"of",
"and",
"including",
"the",
"mirte",
"-",
"file",
"<name",
">",
"where",
"<d",
">",
"are",
"the",
"dictionaries",
"from",
"the",
"mirte",
"-",
"file",
"at",
"<cpath",
">"
] | train | https://github.com/bwesterb/mirte/blob/c58db8c993cd15ffdc64b52703cd466213913200/src/mirteFile.py#L173-L199 |
bwesterb/mirte | src/mirteFile.py | _parse_mirteFile | def _parse_mirteFile(path, logger=None):
""" Open and parses the mirteFile at <path>. """
l = logging.getLogger('_parse_mirteFile') if logger is None else logger
cache_path = os.path.join(os.path.dirname(path),
CACHE_FILENAME_TEMPLATE % os.path.basename(path))
if (os.path.e... | python | def _parse_mirteFile(path, logger=None):
""" Open and parses the mirteFile at <path>. """
l = logging.getLogger('_parse_mirteFile') if logger is None else logger
cache_path = os.path.join(os.path.dirname(path),
CACHE_FILENAME_TEMPLATE % os.path.basename(path))
if (os.path.e... | [
"def",
"_parse_mirteFile",
"(",
"path",
",",
"logger",
"=",
"None",
")",
":",
"l",
"=",
"logging",
".",
"getLogger",
"(",
"'_parse_mirteFile'",
")",
"if",
"logger",
"is",
"None",
"else",
"logger",
"cache_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
... | Open and parses the mirteFile at <path>. | [
"Open",
"and",
"parses",
"the",
"mirteFile",
"at",
"<path",
">",
"."
] | train | https://github.com/bwesterb/mirte/blob/c58db8c993cd15ffdc64b52703cd466213913200/src/mirteFile.py#L202-L221 |
eranimo/nomine | nomine/generate.py | Nomine._generate | def _generate(self, size=None):
"Generates a new word"
corpus_letters = list(self.vectors.keys())
current_letter = random.choice(corpus_letters)
if size is None:
size = int(random.normalvariate(self.avg, self.std_dev))
letters = [current_letter]
for _ in ran... | python | def _generate(self, size=None):
"Generates a new word"
corpus_letters = list(self.vectors.keys())
current_letter = random.choice(corpus_letters)
if size is None:
size = int(random.normalvariate(self.avg, self.std_dev))
letters = [current_letter]
for _ in ran... | [
"def",
"_generate",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"corpus_letters",
"=",
"list",
"(",
"self",
".",
"vectors",
".",
"keys",
"(",
")",
")",
"current_letter",
"=",
"random",
".",
"choice",
"(",
"corpus_letters",
")",
"if",
"size",
"is",... | Generates a new word | [
"Generates",
"a",
"new",
"word"
] | train | https://github.com/eranimo/nomine/blob/bd6342c7c67d772d2b603d5bb081ceda432cc681/nomine/generate.py#L65-L82 |
xtrementl/focus | focus/plugin/modules/tasks.py | _print_tasks | def _print_tasks(env, tasks, mark_active=False):
""" Prints task information using io stream.
`env`
``Environment`` object.
`tasks`
List of tuples (task_name, options, block_options).
`mark_active`
Set to ``True`` to mark active task.
"""
if ... | python | def _print_tasks(env, tasks, mark_active=False):
""" Prints task information using io stream.
`env`
``Environment`` object.
`tasks`
List of tuples (task_name, options, block_options).
`mark_active`
Set to ``True`` to mark active task.
"""
if ... | [
"def",
"_print_tasks",
"(",
"env",
",",
"tasks",
",",
"mark_active",
"=",
"False",
")",
":",
"if",
"env",
".",
"task",
".",
"active",
"and",
"mark_active",
":",
"active_task",
"=",
"env",
".",
"task",
".",
"name",
"else",
":",
"active_task",
"=",
"None... | Prints task information using io stream.
`env`
``Environment`` object.
`tasks`
List of tuples (task_name, options, block_options).
`mark_active`
Set to ``True`` to mark active task. | [
"Prints",
"task",
"information",
"using",
"io",
"stream",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/tasks.py#L18-L86 |
xtrementl/focus | focus/plugin/modules/tasks.py | _edit_task_config | def _edit_task_config(env, task_config, confirm):
""" Launches text editor to edit provided task configuration file.
`env`
Runtime ``Environment`` instance.
`task_config`
Path to task configuration file.
`confirm`
If task config is invalid after edit, pr... | python | def _edit_task_config(env, task_config, confirm):
""" Launches text editor to edit provided task configuration file.
`env`
Runtime ``Environment`` instance.
`task_config`
Path to task configuration file.
`confirm`
If task config is invalid after edit, pr... | [
"def",
"_edit_task_config",
"(",
"env",
",",
"task_config",
",",
"confirm",
")",
":",
"# get editor program",
"if",
"common",
".",
"IS_MACOSX",
":",
"def_editor",
"=",
"'open'",
"else",
":",
"def_editor",
"=",
"'vi'",
"editor",
"=",
"os",
".",
"environ",
"."... | Launches text editor to edit provided task configuration file.
`env`
Runtime ``Environment`` instance.
`task_config`
Path to task configuration file.
`confirm`
If task config is invalid after edit, prompt to re-edit.
Return boolean.
* Raise... | [
"Launches",
"text",
"editor",
"to",
"edit",
"provided",
"task",
"configuration",
"file",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/tasks.py#L89-L175 |
xtrementl/focus | focus/plugin/modules/tasks.py | TaskStart.execute | def execute(self, env, args):
""" Starts a new task.
`env`
Runtime ``Environment`` instance.
`args`
Arguments object from arg parser.
"""
# start the task
if env.task.start(args.task_name):
env.io.success(u'Task Lo... | python | def execute(self, env, args):
""" Starts a new task.
`env`
Runtime ``Environment`` instance.
`args`
Arguments object from arg parser.
"""
# start the task
if env.task.start(args.task_name):
env.io.success(u'Task Lo... | [
"def",
"execute",
"(",
"self",
",",
"env",
",",
"args",
")",
":",
"# start the task",
"if",
"env",
".",
"task",
".",
"start",
"(",
"args",
".",
"task_name",
")",
":",
"env",
".",
"io",
".",
"success",
"(",
"u'Task Loaded.'",
")"
] | Starts a new task.
`env`
Runtime ``Environment`` instance.
`args`
Arguments object from arg parser. | [
"Starts",
"a",
"new",
"task",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/tasks.py#L195-L206 |
xtrementl/focus | focus/plugin/modules/tasks.py | TaskCreate.setup_parser | def setup_parser(self, parser):
""" Setup the argument parser.
`parser`
``FocusArgParser`` object.
"""
parser.add_argument('task_name', help='task to create')
parser.add_argument('clone_task', nargs='?',
help='existing task to... | python | def setup_parser(self, parser):
""" Setup the argument parser.
`parser`
``FocusArgParser`` object.
"""
parser.add_argument('task_name', help='task to create')
parser.add_argument('clone_task', nargs='?',
help='existing task to... | [
"def",
"setup_parser",
"(",
"self",
",",
"parser",
")",
":",
"parser",
".",
"add_argument",
"(",
"'task_name'",
",",
"help",
"=",
"'task to create'",
")",
"parser",
".",
"add_argument",
"(",
"'clone_task'",
",",
"nargs",
"=",
"'?'",
",",
"help",
"=",
"'exi... | Setup the argument parser.
`parser`
``FocusArgParser`` object. | [
"Setup",
"the",
"argument",
"parser",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/tasks.py#L238-L249 |
xtrementl/focus | focus/plugin/modules/tasks.py | TaskCreate.execute | def execute(self, env, args):
""" Creates a new task.
`env`
Runtime ``Environment`` instance.
`args`
Arguments object from arg parser.
"""
task_name = args.task_name
clone_task = args.clone_task
if not env.task.create... | python | def execute(self, env, args):
""" Creates a new task.
`env`
Runtime ``Environment`` instance.
`args`
Arguments object from arg parser.
"""
task_name = args.task_name
clone_task = args.clone_task
if not env.task.create... | [
"def",
"execute",
"(",
"self",
",",
"env",
",",
"args",
")",
":",
"task_name",
"=",
"args",
".",
"task_name",
"clone_task",
"=",
"args",
".",
"clone_task",
"if",
"not",
"env",
".",
"task",
".",
"create",
"(",
"task_name",
",",
"clone_task",
")",
":",
... | Creates a new task.
`env`
Runtime ``Environment`` instance.
`args`
Arguments object from arg parser. | [
"Creates",
"a",
"new",
"task",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/tasks.py#L251-L273 |
xtrementl/focus | focus/plugin/modules/tasks.py | TaskEdit.execute | def execute(self, env, args):
""" Edits task configuration.
`env`
Runtime ``Environment`` instance.
`args`
Arguments object from arg parser.
"""
task_name = args.task_name
if not env.task.exists(task_name):
raise ... | python | def execute(self, env, args):
""" Edits task configuration.
`env`
Runtime ``Environment`` instance.
`args`
Arguments object from arg parser.
"""
task_name = args.task_name
if not env.task.exists(task_name):
raise ... | [
"def",
"execute",
"(",
"self",
",",
"env",
",",
"args",
")",
":",
"task_name",
"=",
"args",
".",
"task_name",
"if",
"not",
"env",
".",
"task",
".",
"exists",
"(",
"task_name",
")",
":",
"raise",
"errors",
".",
"TaskNotFound",
"(",
"task_name",
")",
"... | Edits task configuration.
`env`
Runtime ``Environment`` instance.
`args`
Arguments object from arg parser. | [
"Edits",
"task",
"configuration",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/tasks.py#L293-L315 |
xtrementl/focus | focus/plugin/modules/tasks.py | TaskRename.execute | def execute(self, env, args):
""" Removes a task.
`env`
Runtime ``Environment`` instance.
`args`
Arguments object from arg parser.
"""
# extract args
old_task_name = args.old_task_name
new_task_name = args.new_task_nam... | python | def execute(self, env, args):
""" Removes a task.
`env`
Runtime ``Environment`` instance.
`args`
Arguments object from arg parser.
"""
# extract args
old_task_name = args.old_task_name
new_task_name = args.new_task_nam... | [
"def",
"execute",
"(",
"self",
",",
"env",
",",
"args",
")",
":",
"# extract args",
"old_task_name",
"=",
"args",
".",
"old_task_name",
"new_task_name",
"=",
"args",
".",
"new_task_name",
"if",
"old_task_name",
"==",
"new_task_name",
":",
"raise",
"errors",
".... | Removes a task.
`env`
Runtime ``Environment`` instance.
`args`
Arguments object from arg parser. | [
"Removes",
"a",
"task",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/tasks.py#L336-L355 |
xtrementl/focus | focus/plugin/modules/tasks.py | TaskRemove.execute | def execute(self, env, args):
""" Removes a task.
`env`
Runtime ``Environment`` instance.
`args`
Arguments object from arg parser.
"""
# extract args
task_name = args.task_name
force = args.force
if env.task.a... | python | def execute(self, env, args):
""" Removes a task.
`env`
Runtime ``Environment`` instance.
`args`
Arguments object from arg parser.
"""
# extract args
task_name = args.task_name
force = args.force
if env.task.a... | [
"def",
"execute",
"(",
"self",
",",
"env",
",",
"args",
")",
":",
"# extract args",
"task_name",
"=",
"args",
".",
"task_name",
"force",
"=",
"args",
".",
"force",
"if",
"env",
".",
"task",
".",
"active",
"and",
"env",
".",
"task",
".",
"name",
"==",... | Removes a task.
`env`
Runtime ``Environment`` instance.
`args`
Arguments object from arg parser. | [
"Removes",
"a",
"task",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/tasks.py#L377-L412 |
xtrementl/focus | focus/plugin/modules/tasks.py | TaskList.execute | def execute(self, env, args):
""" Lists all valid tasks.
`env`
Runtime ``Environment`` instance.
`args`
Arguments object from arg parser.
"""
tasks = env.task.get_list_info()
if not tasks:
env.io.write("No tasks fo... | python | def execute(self, env, args):
""" Lists all valid tasks.
`env`
Runtime ``Environment`` instance.
`args`
Arguments object from arg parser.
"""
tasks = env.task.get_list_info()
if not tasks:
env.io.write("No tasks fo... | [
"def",
"execute",
"(",
"self",
",",
"env",
",",
"args",
")",
":",
"tasks",
"=",
"env",
".",
"task",
".",
"get_list_info",
"(",
")",
"if",
"not",
"tasks",
":",
"env",
".",
"io",
".",
"write",
"(",
"\"No tasks found.\"",
")",
"else",
":",
"if",
"args... | Lists all valid tasks.
`env`
Runtime ``Environment`` instance.
`args`
Arguments object from arg parser. | [
"Lists",
"all",
"valid",
"tasks",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/tasks.py#L434-L464 |
xtrementl/focus | focus/plugin/modules/tasks.py | TaskView.execute | def execute(self, env, args):
""" Prints task information.
`env`
Runtime ``Environment`` instance.
`args`
Arguments object from arg parser.
"""
task_name = args.task_name
if task_name is None:
if not env.task.acti... | python | def execute(self, env, args):
""" Prints task information.
`env`
Runtime ``Environment`` instance.
`args`
Arguments object from arg parser.
"""
task_name = args.task_name
if task_name is None:
if not env.task.acti... | [
"def",
"execute",
"(",
"self",
",",
"env",
",",
"args",
")",
":",
"task_name",
"=",
"args",
".",
"task_name",
"if",
"task_name",
"is",
"None",
":",
"if",
"not",
"env",
".",
"task",
".",
"active",
":",
"raise",
"errors",
".",
"NoActiveTask",
"task_name"... | Prints task information.
`env`
Runtime ``Environment`` instance.
`args`
Arguments object from arg parser. | [
"Prints",
"task",
"information",
"."
] | train | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/tasks.py#L485-L505 |
bruth/restlib2 | restlib2/resources.py | no_content_response | def no_content_response(response):
"Cautious assessment of the response body for no content."
if not hasattr(response, '_container'):
return True
if response._container is None:
return True
if isinstance(response._container, (list, tuple)):
if len(response._container) == 1 and ... | python | def no_content_response(response):
"Cautious assessment of the response body for no content."
if not hasattr(response, '_container'):
return True
if response._container is None:
return True
if isinstance(response._container, (list, tuple)):
if len(response._container) == 1 and ... | [
"def",
"no_content_response",
"(",
"response",
")",
":",
"if",
"not",
"hasattr",
"(",
"response",
",",
"'_container'",
")",
":",
"return",
"True",
"if",
"response",
".",
"_container",
"is",
"None",
":",
"return",
"True",
"if",
"isinstance",
"(",
"response",
... | Cautious assessment of the response body for no content. | [
"Cautious",
"assessment",
"of",
"the",
"response",
"body",
"for",
"no",
"content",
"."
] | train | https://github.com/bruth/restlib2/blob/cb147527496ddf08263364f1fb52e7c48f215667/restlib2/resources.py#L32-L44 |
melonmanchan/ResumeOS | resumeos/ResumeOs.py | render_template_file | def render_template_file(file_name, context):
""" Renders and overrides Jinja2 template files """
with open(file_name, 'r+') as f:
template = Template(f.read())
output = template.render(context)
f.seek(0)
f.write(output)
f.truncate() | python | def render_template_file(file_name, context):
""" Renders and overrides Jinja2 template files """
with open(file_name, 'r+') as f:
template = Template(f.read())
output = template.render(context)
f.seek(0)
f.write(output)
f.truncate() | [
"def",
"render_template_file",
"(",
"file_name",
",",
"context",
")",
":",
"with",
"open",
"(",
"file_name",
",",
"'r+'",
")",
"as",
"f",
":",
"template",
"=",
"Template",
"(",
"f",
".",
"read",
"(",
")",
")",
"output",
"=",
"template",
".",
"render",
... | Renders and overrides Jinja2 template files | [
"Renders",
"and",
"overrides",
"Jinja2",
"template",
"files"
] | train | https://github.com/melonmanchan/ResumeOS/blob/b7fbcdaa0b4bad27e06ca33eee9c10f5d89fe37c/resumeos/ResumeOs.py#L16-L23 |
melonmanchan/ResumeOS | resumeos/ResumeOs.py | main | def main(name, output, font):
""" Easily bootstrap an OS project to fool HR departments and pad your resume. """
# The path of the directory where the final files will end up in
bootstrapped_directory = os.getcwd() + os.sep + name.lower().replace(' ', '-') + os.sep
# Copy the template files to the ta... | python | def main(name, output, font):
""" Easily bootstrap an OS project to fool HR departments and pad your resume. """
# The path of the directory where the final files will end up in
bootstrapped_directory = os.getcwd() + os.sep + name.lower().replace(' ', '-') + os.sep
# Copy the template files to the ta... | [
"def",
"main",
"(",
"name",
",",
"output",
",",
"font",
")",
":",
"# The path of the directory where the final files will end up in",
"bootstrapped_directory",
"=",
"os",
".",
"getcwd",
"(",
")",
"+",
"os",
".",
"sep",
"+",
"name",
".",
"lower",
"(",
")",
".",... | Easily bootstrap an OS project to fool HR departments and pad your resume. | [
"Easily",
"bootstrap",
"an",
"OS",
"project",
"to",
"fool",
"HR",
"departments",
"and",
"pad",
"your",
"resume",
"."
] | train | https://github.com/melonmanchan/ResumeOS/blob/b7fbcdaa0b4bad27e06ca33eee9c10f5d89fe37c/resumeos/ResumeOs.py#L37-L62 |
tomnor/channelpack | channelpack/pulldbf.py | dbfreader | def dbfreader(f):
"""Returns an iterator over records in a Xbase DBF file.
The first row returned contains the field names.
The second row contains field specs: (type, size, decimal places).
Subsequent rows contain the data records.
If a record is marked as deleted, it is skipped.
File should ... | python | def dbfreader(f):
"""Returns an iterator over records in a Xbase DBF file.
The first row returned contains the field names.
The second row contains field specs: (type, size, decimal places).
Subsequent rows contain the data records.
If a record is marked as deleted, it is skipped.
File should ... | [
"def",
"dbfreader",
"(",
"f",
")",
":",
"# See DBF format spec at:",
"# http://www.pgts.com.au/download/public/xbase.htm#DBF_STRUCT",
"numrec",
",",
"lenheader",
"=",
"struct",
".",
"unpack",
"(",
"'<xxxxLH22x'",
",",
"f",
".",
"read",
"(",
"32",
")",
")",
"numf... | Returns an iterator over records in a Xbase DBF file.
The first row returned contains the field names.
The second row contains field specs: (type, size, decimal places).
Subsequent rows contain the data records.
If a record is marked as deleted, it is skipped.
File should be opened for binary read... | [
"Returns",
"an",
"iterator",
"over",
"records",
"in",
"a",
"Xbase",
"DBF",
"file",
"."
] | train | https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pulldbf.py#L11-L74 |
tomnor/channelpack | channelpack/pulldbf.py | dbf_asdict | def dbf_asdict(fn, usecols=None, keystyle='ints'):
"""Return data from dbf file fn as a dict.
fn: str
The filename string.
usecols: seqence
The columns to use, 0-based.
keystyle: str
'ints' or 'names' accepted. Should be 'ints' (default) when this
function is given to ... | python | def dbf_asdict(fn, usecols=None, keystyle='ints'):
"""Return data from dbf file fn as a dict.
fn: str
The filename string.
usecols: seqence
The columns to use, 0-based.
keystyle: str
'ints' or 'names' accepted. Should be 'ints' (default) when this
function is given to ... | [
"def",
"dbf_asdict",
"(",
"fn",
",",
"usecols",
"=",
"None",
",",
"keystyle",
"=",
"'ints'",
")",
":",
"if",
"keystyle",
"not",
"in",
"[",
"'ints'",
",",
"'names'",
"]",
":",
"raise",
"ValueError",
"(",
"'Unknown keyword: '",
"+",
"str",
"(",
"keystyle",... | Return data from dbf file fn as a dict.
fn: str
The filename string.
usecols: seqence
The columns to use, 0-based.
keystyle: str
'ints' or 'names' accepted. Should be 'ints' (default) when this
function is given to a ChannelPack as loadfunc. If 'names' is
used, key... | [
"Return",
"data",
"from",
"dbf",
"file",
"fn",
"as",
"a",
"dict",
"."
] | train | https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pulldbf.py#L77-L113 |
tomnor/channelpack | channelpack/pulldbf.py | channel_names | def channel_names(fn, usecols=None):
"""Return the field names (channel names) from dbf file fn. With
usecols, return only names corresponding to the integers in
usecols."""
with open(fn, 'rb') as fo:
names = dbfreader(fo).next()
return usecols and [names[i] for i in usecols] or names | python | def channel_names(fn, usecols=None):
"""Return the field names (channel names) from dbf file fn. With
usecols, return only names corresponding to the integers in
usecols."""
with open(fn, 'rb') as fo:
names = dbfreader(fo).next()
return usecols and [names[i] for i in usecols] or names | [
"def",
"channel_names",
"(",
"fn",
",",
"usecols",
"=",
"None",
")",
":",
"with",
"open",
"(",
"fn",
",",
"'rb'",
")",
"as",
"fo",
":",
"names",
"=",
"dbfreader",
"(",
"fo",
")",
".",
"next",
"(",
")",
"return",
"usecols",
"and",
"[",
"names",
"[... | Return the field names (channel names) from dbf file fn. With
usecols, return only names corresponding to the integers in
usecols. | [
"Return",
"the",
"field",
"names",
"(",
"channel",
"names",
")",
"from",
"dbf",
"file",
"fn",
".",
"With",
"usecols",
"return",
"only",
"names",
"corresponding",
"to",
"the",
"integers",
"in",
"usecols",
"."
] | train | https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pulldbf.py#L116-L124 |
kervi/kervi-core | kervi/hal/i2c.py | II2CDeviceDriver.reverse_byte_order | def reverse_byte_order(self, data):
"""Reverses the byte order of an int (16-bit) or long (32-bit) value."""
# Courtesy Vishal Sapre
byte_count = len(hex(data)[2:].replace('L', '')[::2])
val = 0
for i in range(byte_count):
val = (val << 8) | (data & 0xff)
... | python | def reverse_byte_order(self, data):
"""Reverses the byte order of an int (16-bit) or long (32-bit) value."""
# Courtesy Vishal Sapre
byte_count = len(hex(data)[2:].replace('L', '')[::2])
val = 0
for i in range(byte_count):
val = (val << 8) | (data & 0xff)
... | [
"def",
"reverse_byte_order",
"(",
"self",
",",
"data",
")",
":",
"# Courtesy Vishal Sapre",
"byte_count",
"=",
"len",
"(",
"hex",
"(",
"data",
")",
"[",
"2",
":",
"]",
".",
"replace",
"(",
"'L'",
",",
"''",
")",
"[",
":",
":",
"2",
"]",
")",
"val",... | Reverses the byte order of an int (16-bit) or long (32-bit) value. | [
"Reverses",
"the",
"byte",
"order",
"of",
"an",
"int",
"(",
"16",
"-",
"bit",
")",
"or",
"long",
"(",
"32",
"-",
"bit",
")",
"value",
"."
] | train | https://github.com/kervi/kervi-core/blob/3c1e3c8a17a7b4d085d8a28b99180ff2a96b0e23/kervi/hal/i2c.py#L23-L31 |
sbusard/wagoner | wagoner/table.py | process_arguments | def process_arguments():
"""
Process the command line arguments. The arguments are:
* the list of texts to analyse (at least one);
* -f (or --flatten) if the table must be flattened;
* -o (or --output) the output file (default: stdout).
"""
parser = argparse.ArgumentParser(description="Ex... | python | def process_arguments():
"""
Process the command line arguments. The arguments are:
* the list of texts to analyse (at least one);
* -f (or --flatten) if the table must be flattened;
* -o (or --output) the output file (default: stdout).
"""
parser = argparse.ArgumentParser(description="Ex... | [
"def",
"process_arguments",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"Extract a table from the \"",
"\"given text\"",
")",
"parser",
".",
"add_argument",
"(",
"\"text\"",
",",
"type",
"=",
"argparse",
".",
"FileTy... | Process the command line arguments. The arguments are:
* the list of texts to analyse (at least one);
* -f (or --flatten) if the table must be flattened;
* -o (or --output) the output file (default: stdout). | [
"Process",
"the",
"command",
"line",
"arguments",
".",
"The",
"arguments",
"are",
":",
"*",
"the",
"list",
"of",
"texts",
"to",
"analyse",
"(",
"at",
"least",
"one",
")",
";",
"*",
"-",
"f",
"(",
"or",
"--",
"flatten",
")",
"if",
"the",
"table",
"m... | train | https://github.com/sbusard/wagoner/blob/7f83d66bbd0e009e4d4232ffdf319bd5a2a5683b/wagoner/table.py#L199-L224 |
sbusard/wagoner | wagoner/table.py | Table.from_words | def from_words(cls, words, prefix=0, flatten=False):
"""
Given an iterable of words, return the corresponding table.
The table is built by accumulating, for each word, for each sub-word,
the number of occurrences of the corresponding next character.
:param words: an iter... | python | def from_words(cls, words, prefix=0, flatten=False):
"""
Given an iterable of words, return the corresponding table.
The table is built by accumulating, for each word, for each sub-word,
the number of occurrences of the corresponding next character.
:param words: an iter... | [
"def",
"from_words",
"(",
"cls",
",",
"words",
",",
"prefix",
"=",
"0",
",",
"flatten",
"=",
"False",
")",
":",
"table",
"=",
"defaultdict",
"(",
"lambda",
":",
"defaultdict",
"(",
"int",
")",
")",
"for",
"word",
"in",
"words",
":",
"word",
"=",
"\... | Given an iterable of words, return the corresponding table.
The table is built by accumulating, for each word, for each sub-word,
the number of occurrences of the corresponding next character.
:param words: an iterable of strings made of alphabetic characters;
:param prefix: if ... | [
"Given",
"an",
"iterable",
"of",
"words",
"return",
"the",
"corresponding",
"table",
".",
"The",
"table",
"is",
"built",
"by",
"accumulating",
"for",
"each",
"word",
"for",
"each",
"sub",
"-",
"word",
"the",
"number",
"of",
"occurrences",
"of",
"the",
"cor... | train | https://github.com/sbusard/wagoner/blob/7f83d66bbd0e009e4d4232ffdf319bd5a2a5683b/wagoner/table.py#L38-L67 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.