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 |
|---|---|---|---|---|---|---|---|---|---|---|
heikomuller/sco-client | scocli/funcdata.py | FunctionalDataHandle.create | def create(url, filename):
"""Create new fMRI for given experiment by uploading local file.
Expects an tar-archive.
Parameters
----------
url : string
Url to POST fMRI create request
filename : string
Path to tar-archive on local disk
Ret... | python | def create(url, filename):
"""Create new fMRI for given experiment by uploading local file.
Expects an tar-archive.
Parameters
----------
url : string
Url to POST fMRI create request
filename : string
Path to tar-archive on local disk
Ret... | [
"def",
"create",
"(",
"url",
",",
"filename",
")",
":",
"# Upload file to create fMRI resource. If response is not 201 the",
"# uploaded file is not a valid functional data archive",
"files",
"=",
"{",
"'file'",
":",
"open",
"(",
"filename",
",",
"'rb'",
")",
"}",
"respon... | Create new fMRI for given experiment by uploading local file.
Expects an tar-archive.
Parameters
----------
url : string
Url to POST fMRI create request
filename : string
Path to tar-archive on local disk
Returns
-------
string
... | [
"Create",
"new",
"fMRI",
"for",
"given",
"experiment",
"by",
"uploading",
"local",
"file",
".",
"Expects",
"an",
"tar",
"-",
"archive",
"."
] | train | https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/funcdata.py#L51-L73 |
cbrand/vpnchooser | src/vpnchooser/resources/user.py | UserResource.get | def get(self, user_name: str) -> User:
"""
Gets the User Resource.
"""
user = current_user()
if user.is_admin or user.name == user_name:
return self._get_or_abort(user_name)
else:
abort(403) | python | def get(self, user_name: str) -> User:
"""
Gets the User Resource.
"""
user = current_user()
if user.is_admin or user.name == user_name:
return self._get_or_abort(user_name)
else:
abort(403) | [
"def",
"get",
"(",
"self",
",",
"user_name",
":",
"str",
")",
"->",
"User",
":",
"user",
"=",
"current_user",
"(",
")",
"if",
"user",
".",
"is_admin",
"or",
"user",
".",
"name",
"==",
"user_name",
":",
"return",
"self",
".",
"_get_or_abort",
"(",
"us... | Gets the User Resource. | [
"Gets",
"the",
"User",
"Resource",
"."
] | train | https://github.com/cbrand/vpnchooser/blob/d153e3d05555c23cf5e8e15e507eecad86465923/src/vpnchooser/resources/user.py#L83-L91 |
cbrand/vpnchooser | src/vpnchooser/resources/user.py | UserResource.put | def put(self, user_name: str) -> User:
"""
Updates the User Resource with the
name.
"""
current = current_user()
if current.name == user_name or current.is_admin:
user = self._get_or_abort(user_name)
self.update(user)
session.commit()
... | python | def put(self, user_name: str) -> User:
"""
Updates the User Resource with the
name.
"""
current = current_user()
if current.name == user_name or current.is_admin:
user = self._get_or_abort(user_name)
self.update(user)
session.commit()
... | [
"def",
"put",
"(",
"self",
",",
"user_name",
":",
"str",
")",
"->",
"User",
":",
"current",
"=",
"current_user",
"(",
")",
"if",
"current",
".",
"name",
"==",
"user_name",
"or",
"current",
".",
"is_admin",
":",
"user",
"=",
"self",
".",
"_get_or_abort"... | Updates the User Resource with the
name. | [
"Updates",
"the",
"User",
"Resource",
"with",
"the",
"name",
"."
] | train | https://github.com/cbrand/vpnchooser/blob/d153e3d05555c23cf5e8e15e507eecad86465923/src/vpnchooser/resources/user.py#L95-L108 |
cbrand/vpnchooser | src/vpnchooser/resources/user.py | UserResource.delete | def delete(self, user_name: str):
"""
Deletes the resource with the given name.
"""
user = self._get_or_abort(user_name)
session.delete(user)
session.commit()
return '', 204 | python | def delete(self, user_name: str):
"""
Deletes the resource with the given name.
"""
user = self._get_or_abort(user_name)
session.delete(user)
session.commit()
return '', 204 | [
"def",
"delete",
"(",
"self",
",",
"user_name",
":",
"str",
")",
":",
"user",
"=",
"self",
".",
"_get_or_abort",
"(",
"user_name",
")",
"session",
".",
"delete",
"(",
"user",
")",
"session",
".",
"commit",
"(",
")",
"return",
"''",
",",
"204"
] | Deletes the resource with the given name. | [
"Deletes",
"the",
"resource",
"with",
"the",
"given",
"name",
"."
] | train | https://github.com/cbrand/vpnchooser/blob/d153e3d05555c23cf5e8e15e507eecad86465923/src/vpnchooser/resources/user.py#L111-L118 |
rcook/pyprelude | pyprelude/util.py | try_pop | def try_pop(d, key, default):
"""
>>> d = {"a": "b", "c": "d", "e": "f"}
>>> try_pop(d, "g", "default")
'default'
>>> d
{'a': 'b', 'c': 'd', 'e': 'f'}
>>> try_pop(d, "c", "default")
'd'
>>> d
{'a': 'b', 'e': 'f'}
"""
value = d.get(key, default)
if key in d:
d.... | python | def try_pop(d, key, default):
"""
>>> d = {"a": "b", "c": "d", "e": "f"}
>>> try_pop(d, "g", "default")
'default'
>>> d
{'a': 'b', 'c': 'd', 'e': 'f'}
>>> try_pop(d, "c", "default")
'd'
>>> d
{'a': 'b', 'e': 'f'}
"""
value = d.get(key, default)
if key in d:
d.... | [
"def",
"try_pop",
"(",
"d",
",",
"key",
",",
"default",
")",
":",
"value",
"=",
"d",
".",
"get",
"(",
"key",
",",
"default",
")",
"if",
"key",
"in",
"d",
":",
"d",
".",
"pop",
"(",
"key",
")",
"return",
"value"
] | >>> d = {"a": "b", "c": "d", "e": "f"}
>>> try_pop(d, "g", "default")
'default'
>>> d
{'a': 'b', 'c': 'd', 'e': 'f'}
>>> try_pop(d, "c", "default")
'd'
>>> d
{'a': 'b', 'e': 'f'} | [
">>>",
"d",
"=",
"{",
"a",
":",
"b",
"c",
":",
"d",
"e",
":",
"f",
"}",
">>>",
"try_pop",
"(",
"d",
"g",
"default",
")",
"default",
">>>",
"d",
"{",
"a",
":",
"b",
"c",
":",
"d",
"e",
":",
"f",
"}",
">>>",
"try_pop",
"(",
"d",
"c",
"def... | train | https://github.com/rcook/pyprelude/blob/a473b34db8045e8715154b8840291d4facc8f94c/pyprelude/util.py#L14-L29 |
diefans/objective | src/objective/core.py | Item.node | def node(self):
"""Create a :py:class:`Node` instance.
All args and kwargs are forwarded to the node.
:returns: a :py:class:`Node` instance
"""
if self.node_class is None:
raise ValueError("You have to create an ``Item`` by calling ``__init__`` with ``node_class`` ... | python | def node(self):
"""Create a :py:class:`Node` instance.
All args and kwargs are forwarded to the node.
:returns: a :py:class:`Node` instance
"""
if self.node_class is None:
raise ValueError("You have to create an ``Item`` by calling ``__init__`` with ``node_class`` ... | [
"def",
"node",
"(",
"self",
")",
":",
"if",
"self",
".",
"node_class",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"You have to create an ``Item`` by calling ``__init__`` with ``node_class`` argument\"",
"\" or by decorating a ``Node`` class.\"",
")",
"node",
"=",
"sel... | Create a :py:class:`Node` instance.
All args and kwargs are forwarded to the node.
:returns: a :py:class:`Node` instance | [
"Create",
"a",
":",
"py",
":",
"class",
":",
"Node",
"instance",
"."
] | train | https://github.com/diefans/objective/blob/e2de37f1cd4f5ad147ab3a5dee7dffd6806f2f88/src/objective/core.py#L134-L149 |
diefans/objective | src/objective/core.py | Field._resolve_value | def _resolve_value(self, value, environment=None):
"""Resolve the value.
Either apply missing or leave the value as is.
:param value: the value either from deserialize or serialize
:param environment: an optional environment
"""
# here we care about Undefined values
... | python | def _resolve_value(self, value, environment=None):
"""Resolve the value.
Either apply missing or leave the value as is.
:param value: the value either from deserialize or serialize
:param environment: an optional environment
"""
# here we care about Undefined values
... | [
"def",
"_resolve_value",
"(",
"self",
",",
"value",
",",
"environment",
"=",
"None",
")",
":",
"# here we care about Undefined values",
"if",
"value",
"==",
"values",
".",
"Undefined",
":",
"if",
"isinstance",
"(",
"self",
".",
"_missing",
",",
"type",
")",
... | Resolve the value.
Either apply missing or leave the value as is.
:param value: the value either from deserialize or serialize
:param environment: an optional environment | [
"Resolve",
"the",
"value",
"."
] | train | https://github.com/diefans/objective/blob/e2de37f1cd4f5ad147ab3a5dee7dffd6806f2f88/src/objective/core.py#L283-L309 |
diefans/objective | src/objective/core.py | Field.serialize | def serialize(self, value, environment=None):
"""Serialze a value into a transportable and interchangeable format.
The default assumption is that the value is JSON e.g. string or number.
Some encoders also support datetime by default.
Serialization should not be validated, since the de... | python | def serialize(self, value, environment=None):
"""Serialze a value into a transportable and interchangeable format.
The default assumption is that the value is JSON e.g. string or number.
Some encoders also support datetime by default.
Serialization should not be validated, since the de... | [
"def",
"serialize",
"(",
"self",
",",
"value",
",",
"environment",
"=",
"None",
")",
":",
"value",
"=",
"self",
".",
"_resolve_value",
"(",
"value",
",",
"environment",
")",
"value",
"=",
"self",
".",
"_serialize",
"(",
"value",
",",
"environment",
")",
... | Serialze a value into a transportable and interchangeable format.
The default assumption is that the value is JSON e.g. string or number.
Some encoders also support datetime by default.
Serialization should not be validated, since the developer app would be
bounced, since the mistake c... | [
"Serialze",
"a",
"value",
"into",
"a",
"transportable",
"and",
"interchangeable",
"format",
"."
] | train | https://github.com/diefans/objective/blob/e2de37f1cd4f5ad147ab3a5dee7dffd6806f2f88/src/objective/core.py#L316-L330 |
diefans/objective | src/objective/core.py | Field.deserialize | def deserialize(self, value, environment=None):
"""Deserialize a value into a special application specific format or type.
`value` can be `Missing`, `None` or something else.
:param value: the value to be deserialized
:param environment: additional environment
"""
valu... | python | def deserialize(self, value, environment=None):
"""Deserialize a value into a special application specific format or type.
`value` can be `Missing`, `None` or something else.
:param value: the value to be deserialized
:param environment: additional environment
"""
valu... | [
"def",
"deserialize",
"(",
"self",
",",
"value",
",",
"environment",
"=",
"None",
")",
":",
"value",
"=",
"self",
".",
"_resolve_value",
"(",
"value",
",",
"environment",
")",
"try",
":",
"value",
"=",
"self",
".",
"_deserialize",
"(",
"value",
",",
"e... | Deserialize a value into a special application specific format or type.
`value` can be `Missing`, `None` or something else.
:param value: the value to be deserialized
:param environment: additional environment | [
"Deserialize",
"a",
"value",
"into",
"a",
"special",
"application",
"specific",
"format",
"or",
"type",
"."
] | train | https://github.com/diefans/objective/blob/e2de37f1cd4f5ad147ab3a5dee7dffd6806f2f88/src/objective/core.py#L337-L362 |
necrolyte2/filehandle | filehandle.py | open | def open(filepath, mode='rb', buffcompress=None):
'''
Open a file based on the extension of the file
if the filepath ends in .gz then use gzip module's open otherwise
use the normal builtin open
:param str filepath: Path to .gz or any other file
:param str mode: mode to open file
:param int... | python | def open(filepath, mode='rb', buffcompress=None):
'''
Open a file based on the extension of the file
if the filepath ends in .gz then use gzip module's open otherwise
use the normal builtin open
:param str filepath: Path to .gz or any other file
:param str mode: mode to open file
:param int... | [
"def",
"open",
"(",
"filepath",
",",
"mode",
"=",
"'rb'",
",",
"buffcompress",
"=",
"None",
")",
":",
"root",
",",
"ext",
"=",
"splitext",
"(",
"filepath",
".",
"replace",
"(",
"'.gz'",
",",
"''",
")",
")",
"# get rid of period",
"ext",
"=",
"ext",
"... | Open a file based on the extension of the file
if the filepath ends in .gz then use gzip module's open otherwise
use the normal builtin open
:param str filepath: Path to .gz or any other file
:param str mode: mode to open file
:param int buffcompress: 3rd option for builtin.open or gzip.open
:r... | [
"Open",
"a",
"file",
"based",
"on",
"the",
"extension",
"of",
"the",
"file",
"if",
"the",
"filepath",
"ends",
"in",
".",
"gz",
"then",
"use",
"gzip",
"module",
"s",
"open",
"otherwise",
"use",
"the",
"normal",
"builtin",
"open"
] | train | https://github.com/necrolyte2/filehandle/blob/48218ffae1915c28f26ff270400f29ee8e379ca9/filehandle.py#L11-L35 |
pjuren/pyokit | src/pyokit/datastruct/retrotransposon.py | from_repeat_masker_string | def from_repeat_masker_string(s):
"""
Parse a RepeatMasker string. This format is white-space separated and has
15 columns. The first 11 are invariably as follows:
+----------------------+---------+-----------+----------------------------+
| Description | Type | Example | Notes ... | python | def from_repeat_masker_string(s):
"""
Parse a RepeatMasker string. This format is white-space separated and has
15 columns. The first 11 are invariably as follows:
+----------------------+---------+-----------+----------------------------+
| Description | Type | Example | Notes ... | [
"def",
"from_repeat_masker_string",
"(",
"s",
")",
":",
"parts",
"=",
"s",
".",
"split",
"(",
")",
"if",
"len",
"(",
"parts",
")",
"!=",
"15",
"and",
"len",
"(",
"parts",
")",
"!=",
"14",
":",
"raise",
"RetrotransposonError",
"(",
"\"incorrectly formated... | Parse a RepeatMasker string. This format is white-space separated and has
15 columns. The first 11 are invariably as follows:
+----------------------+---------+-----------+----------------------------+
| Description | Type | Example | Notes |
+======================+=========... | [
"Parse",
"a",
"RepeatMasker",
"string",
".",
"This",
"format",
"is",
"white",
"-",
"space",
"separated",
"and",
"has",
"15",
"columns",
".",
"The",
"first",
"11",
"are",
"invariably",
"as",
"follows",
":"
] | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/datastruct/retrotransposon.py#L59-L194 |
pjuren/pyokit | src/pyokit/datastruct/retrotransposon.py | RetrotransposonOccurrence.liftover | def liftover(self, intersecting_region):
"""
Lift a region that overlaps the genomic occurrence of the retrotransposon
to consensus sequence co-ordinates. This method will behave differently
depending on whether this retrotransposon occurrance contains a full
alignment or not. If it does, the alignm... | python | def liftover(self, intersecting_region):
"""
Lift a region that overlaps the genomic occurrence of the retrotransposon
to consensus sequence co-ordinates. This method will behave differently
depending on whether this retrotransposon occurrance contains a full
alignment or not. If it does, the alignm... | [
"def",
"liftover",
"(",
"self",
",",
"intersecting_region",
")",
":",
"# a little sanity check here to make sure intersecting_region really does..",
"if",
"not",
"self",
".",
"intersects",
"(",
"intersecting_region",
")",
":",
"raise",
"RetrotransposonError",
"(",
"\"trying... | Lift a region that overlaps the genomic occurrence of the retrotransposon
to consensus sequence co-ordinates. This method will behave differently
depending on whether this retrotransposon occurrance contains a full
alignment or not. If it does, the alignment is used to do the liftover and
an exact resul... | [
"Lift",
"a",
"region",
"that",
"overlaps",
"the",
"genomic",
"occurrence",
"of",
"the",
"retrotransposon",
"to",
"consensus",
"sequence",
"co",
"-",
"ordinates",
".",
"This",
"method",
"will",
"behave",
"differently",
"depending",
"on",
"whether",
"this",
"retro... | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/datastruct/retrotransposon.py#L279-L308 |
pjuren/pyokit | src/pyokit/datastruct/retrotransposon.py | RetrotransposonOccurrence.liftover_coordinates | def liftover_coordinates(self, intersecting_region):
"""
Lift a region that overlaps the genomic occurrence of the retrotransposon
to consensus sequence co-ordinates. Use only the coordinates of the
occurrence and the consensus match (i.e. ignore a full alignment, even
if one is present). If the gen... | python | def liftover_coordinates(self, intersecting_region):
"""
Lift a region that overlaps the genomic occurrence of the retrotransposon
to consensus sequence co-ordinates. Use only the coordinates of the
occurrence and the consensus match (i.e. ignore a full alignment, even
if one is present). If the gen... | [
"def",
"liftover_coordinates",
"(",
"self",
",",
"intersecting_region",
")",
":",
"# a little sanity check here to make sure intersecting_region really does..",
"if",
"not",
"self",
".",
"intersects",
"(",
"intersecting_region",
")",
":",
"raise",
"RetrotransposonError",
"(",... | Lift a region that overlaps the genomic occurrence of the retrotransposon
to consensus sequence co-ordinates. Use only the coordinates of the
occurrence and the consensus match (i.e. ignore a full alignment, even
if one is present). If the genomic size of the match is the same as the
size of the match i... | [
"Lift",
"a",
"region",
"that",
"overlaps",
"the",
"genomic",
"occurrence",
"of",
"the",
"retrotransposon",
"to",
"consensus",
"sequence",
"co",
"-",
"ordinates",
".",
"Use",
"only",
"the",
"coordinates",
"of",
"the",
"occurrence",
"and",
"the",
"consensus",
"m... | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/datastruct/retrotransposon.py#L310-L340 |
pjuren/pyokit | src/pyokit/datastruct/retrotransposon.py | RetrotransposonOccurrence.__liftover_coordinates_size_match | def __liftover_coordinates_size_match(self, intersecting_region):
"""
Lift a region that overlaps the genomic occurrence of the retrotransposon
to consensus sequence coordinates using just the coordinates (not the full)
alignment, when they have the same length. This is an internal helper
method. Th... | python | def __liftover_coordinates_size_match(self, intersecting_region):
"""
Lift a region that overlaps the genomic occurrence of the retrotransposon
to consensus sequence coordinates using just the coordinates (not the full)
alignment, when they have the same length. This is an internal helper
method. Th... | [
"def",
"__liftover_coordinates_size_match",
"(",
"self",
",",
"intersecting_region",
")",
":",
"# should always pass, but check anyway...",
"consensus_match_length",
"=",
"self",
".",
"consensus_end",
"-",
"self",
".",
"consensus_start",
"assert",
"(",
"consensus_match_length... | Lift a region that overlaps the genomic occurrence of the retrotransposon
to consensus sequence coordinates using just the coordinates (not the full)
alignment, when they have the same length. This is an internal helper
method. The above length constraint must be true, otherwise an assertion
is failed.
... | [
"Lift",
"a",
"region",
"that",
"overlaps",
"the",
"genomic",
"occurrence",
"of",
"the",
"retrotransposon",
"to",
"consensus",
"sequence",
"coordinates",
"using",
"just",
"the",
"coordinates",
"(",
"not",
"the",
"full",
")",
"alignment",
"when",
"they",
"have",
... | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/datastruct/retrotransposon.py#L342-L376 |
pjuren/pyokit | src/pyokit/datastruct/retrotransposon.py | RetrotransposonOccurrence.__liftover_coordinates_genomic_indels | def __liftover_coordinates_genomic_indels(self, intersect_region):
"""
Lift a region that overlaps the genomic occurrence of the retrotransposon
to consensus sequence coordinates using just the coordinates (not the full
alignment), when they have differing length. This is an internal helper
method. ... | python | def __liftover_coordinates_genomic_indels(self, intersect_region):
"""
Lift a region that overlaps the genomic occurrence of the retrotransposon
to consensus sequence coordinates using just the coordinates (not the full
alignment), when they have differing length. This is an internal helper
method. ... | [
"def",
"__liftover_coordinates_genomic_indels",
"(",
"self",
",",
"intersect_region",
")",
":",
"# should never happen, but check anyway...",
"consensus_match_length",
"=",
"self",
".",
"consensus_end",
"-",
"self",
".",
"consensus_start",
"size_dif",
"=",
"consensus_match_le... | Lift a region that overlaps the genomic occurrence of the retrotransposon
to consensus sequence coordinates using just the coordinates (not the full
alignment), when they have differing length. This is an internal helper
method. The above length constraint must be true, otherwise an assertion
is failed.... | [
"Lift",
"a",
"region",
"that",
"overlaps",
"the",
"genomic",
"occurrence",
"of",
"the",
"retrotransposon",
"to",
"consensus",
"sequence",
"coordinates",
"using",
"just",
"the",
"coordinates",
"(",
"not",
"the",
"full",
"alignment",
")",
"when",
"they",
"have",
... | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/datastruct/retrotransposon.py#L378-L403 |
pjuren/pyokit | src/pyokit/datastruct/retrotransposon.py | RetrotransposonOccurrence.__liftover_coordinates_genomic_insertions | def __liftover_coordinates_genomic_insertions(self, intersecting_region):
"""
Lift a region that overlaps the genomic occurrence of this repeat to the
consensus sequence coordinates using just coordinates (not the full
alignment, even if it is avaialble), when the length of the genomic match
is grea... | python | def __liftover_coordinates_genomic_insertions(self, intersecting_region):
"""
Lift a region that overlaps the genomic occurrence of this repeat to the
consensus sequence coordinates using just coordinates (not the full
alignment, even if it is avaialble), when the length of the genomic match
is grea... | [
"def",
"__liftover_coordinates_genomic_insertions",
"(",
"self",
",",
"intersecting_region",
")",
":",
"# should never happen, but check anyway...",
"consensus_match_length",
"=",
"self",
".",
"consensus_end",
"-",
"self",
".",
"consensus_start",
"size_dif",
"=",
"consensus_m... | Lift a region that overlaps the genomic occurrence of this repeat to the
consensus sequence coordinates using just coordinates (not the full
alignment, even if it is avaialble), when the length of the genomic match
is greater than the concensus match. We assume there are insertions in
the genomic sequen... | [
"Lift",
"a",
"region",
"that",
"overlaps",
"the",
"genomic",
"occurrence",
"of",
"this",
"repeat",
"to",
"the",
"consensus",
"sequence",
"coordinates",
"using",
"just",
"coordinates",
"(",
"not",
"the",
"full",
"alignment",
"even",
"if",
"it",
"is",
"avaialble... | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/datastruct/retrotransposon.py#L405-L450 |
pjuren/pyokit | src/pyokit/datastruct/retrotransposon.py | RetrotransposonOccurrence.__liftover_coordinates_genomic_deletions | def __liftover_coordinates_genomic_deletions(self, intersecting_region):
"""
A 'private' helper member function to perform liftover in coordinate space
when the length of the genomic match is smaller than the concensus match.
We assume the genomic region contains deletions. In this case, we uniformly
... | python | def __liftover_coordinates_genomic_deletions(self, intersecting_region):
"""
A 'private' helper member function to perform liftover in coordinate space
when the length of the genomic match is smaller than the concensus match.
We assume the genomic region contains deletions. In this case, we uniformly
... | [
"def",
"__liftover_coordinates_genomic_deletions",
"(",
"self",
",",
"intersecting_region",
")",
":",
"# should never happen, but check anyway...",
"consensus_match_length",
"=",
"self",
".",
"consensus_end",
"-",
"self",
".",
"consensus_start",
"size_dif",
"=",
"consensus_ma... | A 'private' helper member function to perform liftover in coordinate space
when the length of the genomic match is smaller than the concensus match.
We assume the genomic region contains deletions. In this case, we uniformly
distribute the deletions (gaps) through the genomic region. This is the
trickie... | [
"A",
"private",
"helper",
"member",
"function",
"to",
"perform",
"liftover",
"in",
"coordinate",
"space",
"when",
"the",
"length",
"of",
"the",
"genomic",
"match",
"is",
"smaller",
"than",
"the",
"concensus",
"match",
".",
"We",
"assume",
"the",
"genomic",
"... | train | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/datastruct/retrotransposon.py#L452-L512 |
cdumay/cdumay-result | src/cdumay_result/__init__.py | Result.from_exception | def from_exception(exc, uuid=None):
""" Serialize an exception into a result
:param Exception exc: Exception raised
:param str uuid: Current Kafka :class:`kser.transport.Message` uuid
:rtype: :class:`kser.result.Result`
"""
if not isinstance(exc, Error):
exc ... | python | def from_exception(exc, uuid=None):
""" Serialize an exception into a result
:param Exception exc: Exception raised
:param str uuid: Current Kafka :class:`kser.transport.Message` uuid
:rtype: :class:`kser.result.Result`
"""
if not isinstance(exc, Error):
exc ... | [
"def",
"from_exception",
"(",
"exc",
",",
"uuid",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"exc",
",",
"Error",
")",
":",
"exc",
"=",
"Error",
"(",
"code",
"=",
"500",
",",
"message",
"=",
"str",
"(",
"exc",
")",
")",
"return",
"Res... | Serialize an exception into a result
:param Exception exc: Exception raised
:param str uuid: Current Kafka :class:`kser.transport.Message` uuid
:rtype: :class:`kser.result.Result` | [
"Serialize",
"an",
"exception",
"into",
"a",
"result"
] | train | https://github.com/cdumay/cdumay-result/blob/b6db33813025641620fa1a3b19809a0ccb7c6dd2/src/cdumay_result/__init__.py#L51-L65 |
cdumay/cdumay-result | src/cdumay_result/__init__.py | Result.search_value | def search_value(self, xpath, default=None, single_value=True):
""" Try to find a value in the result
:param str xpath: a xpath filter see https://github.com/kennknowles/python-jsonpath-rw#jsonpath-syntax
:param any default: default value if not found
:param bool single_value: is the re... | python | def search_value(self, xpath, default=None, single_value=True):
""" Try to find a value in the result
:param str xpath: a xpath filter see https://github.com/kennknowles/python-jsonpath-rw#jsonpath-syntax
:param any default: default value if not found
:param bool single_value: is the re... | [
"def",
"search_value",
"(",
"self",
",",
"xpath",
",",
"default",
"=",
"None",
",",
"single_value",
"=",
"True",
")",
":",
"matches",
"=",
"[",
"match",
".",
"value",
"for",
"match",
"in",
"parse",
"(",
"xpath",
")",
".",
"find",
"(",
"self",
".",
... | Try to find a value in the result
:param str xpath: a xpath filter see https://github.com/kennknowles/python-jsonpath-rw#jsonpath-syntax
:param any default: default value if not found
:param bool single_value: is the result is multivalued
:return: the value found or None | [
"Try",
"to",
"find",
"a",
"value",
"in",
"the",
"result"
] | train | https://github.com/cdumay/cdumay-result/blob/b6db33813025641620fa1a3b19809a0ccb7c6dd2/src/cdumay_result/__init__.py#L67-L78 |
jeff-regier/authortoolkit | authortoolkit/utils.py | compatible_names | def compatible_names(e1, e2):
"""This function takes either PartitionParts or Mentions as arguments
"""
if e1.ln() != e2.ln():
return False
short, long = list(e1.mns()), e2.mns()
if len(short) > len(long):
return compatible_names(e2, e1)
# the front first names must be compati... | python | def compatible_names(e1, e2):
"""This function takes either PartitionParts or Mentions as arguments
"""
if e1.ln() != e2.ln():
return False
short, long = list(e1.mns()), e2.mns()
if len(short) > len(long):
return compatible_names(e2, e1)
# the front first names must be compati... | [
"def",
"compatible_names",
"(",
"e1",
",",
"e2",
")",
":",
"if",
"e1",
".",
"ln",
"(",
")",
"!=",
"e2",
".",
"ln",
"(",
")",
":",
"return",
"False",
"short",
",",
"long",
"=",
"list",
"(",
"e1",
".",
"mns",
"(",
")",
")",
",",
"e2",
".",
"m... | This function takes either PartitionParts or Mentions as arguments | [
"This",
"function",
"takes",
"either",
"PartitionParts",
"or",
"Mentions",
"as",
"arguments"
] | train | https://github.com/jeff-regier/authortoolkit/blob/b119a953d46b2e23ad346927a0fb5c5047f28b9b/authortoolkit/utils.py#L17-L42 |
clearclaw/qeventlog | qeventlog/tasks.py | sentry_exception | def sentry_exception (e, request, message = None):
"""Yes, this eats exceptions"""
try:
logtool.log_fault (e, message = message, level = logging.INFO)
data = {
"task": task,
"request": {
"args": task.request.args,
"callbacks": task.request.callbacks,
"called_directly": ta... | python | def sentry_exception (e, request, message = None):
"""Yes, this eats exceptions"""
try:
logtool.log_fault (e, message = message, level = logging.INFO)
data = {
"task": task,
"request": {
"args": task.request.args,
"callbacks": task.request.callbacks,
"called_directly": ta... | [
"def",
"sentry_exception",
"(",
"e",
",",
"request",
",",
"message",
"=",
"None",
")",
":",
"try",
":",
"logtool",
".",
"log_fault",
"(",
"e",
",",
"message",
"=",
"message",
",",
"level",
"=",
"logging",
".",
"INFO",
")",
"data",
"=",
"{",
"\"task\"... | Yes, this eats exceptions | [
"Yes",
"this",
"eats",
"exceptions"
] | train | https://github.com/clearclaw/qeventlog/blob/bcd6184a9df0c91c0a881a3ae594bcdbf08b2ca8/qeventlog/tasks.py#L20-L60 |
Othernet-Project/hwd | hwd/wrapper.py | Wrapper.device | def device(self):
"""
The underlaying ``pyudev.Device`` instance can be accessed by using the
``device`` property. This propety is cached, so only one lookup is
performed to obtain the device object. This cache is invalidated by
:py:meth:`~refresh` method.
"""
# W... | python | def device(self):
"""
The underlaying ``pyudev.Device`` instance can be accessed by using the
``device`` property. This propety is cached, so only one lookup is
performed to obtain the device object. This cache is invalidated by
:py:meth:`~refresh` method.
"""
# W... | [
"def",
"device",
"(",
"self",
")",
":",
"# We always create a new context and look up the devices because they",
"# may disappear or change their state between lookups.",
"if",
"not",
"self",
".",
"_device",
":",
"ctx",
"=",
"pyudev",
".",
"Context",
"(",
")",
"devs",
"="... | The underlaying ``pyudev.Device`` instance can be accessed by using the
``device`` property. This propety is cached, so only one lookup is
performed to obtain the device object. This cache is invalidated by
:py:meth:`~refresh` method. | [
"The",
"underlaying",
"pyudev",
".",
"Device",
"instance",
"can",
"be",
"accessed",
"by",
"using",
"the",
"device",
"property",
".",
"This",
"propety",
"is",
"cached",
"so",
"only",
"one",
"lookup",
"is",
"performed",
"to",
"obtain",
"the",
"device",
"object... | train | https://github.com/Othernet-Project/hwd/blob/7f4445bac61aa2305806aa80338e2ce5baa1093c/hwd/wrapper.py#L18-L35 |
Othernet-Project/hwd | hwd/wrapper.py | Wrapper.devid | def devid(self):
"""
Two-tuple containing device's vendor ID and model ID (hex).
"""
d = self.device
vend_id = d.get('ID_VENDOR_ID')
model_id = d.get('ID_MODEL_ID')
return (vend_id, model_id) | python | def devid(self):
"""
Two-tuple containing device's vendor ID and model ID (hex).
"""
d = self.device
vend_id = d.get('ID_VENDOR_ID')
model_id = d.get('ID_MODEL_ID')
return (vend_id, model_id) | [
"def",
"devid",
"(",
"self",
")",
":",
"d",
"=",
"self",
".",
"device",
"vend_id",
"=",
"d",
".",
"get",
"(",
"'ID_VENDOR_ID'",
")",
"model_id",
"=",
"d",
".",
"get",
"(",
"'ID_MODEL_ID'",
")",
"return",
"(",
"vend_id",
",",
"model_id",
")"
] | Two-tuple containing device's vendor ID and model ID (hex). | [
"Two",
"-",
"tuple",
"containing",
"device",
"s",
"vendor",
"ID",
"and",
"model",
"ID",
"(",
"hex",
")",
"."
] | train | https://github.com/Othernet-Project/hwd/blob/7f4445bac61aa2305806aa80338e2ce5baa1093c/hwd/wrapper.py#L59-L66 |
Othernet-Project/hwd | hwd/wrapper.py | Wrapper._get_first | def _get_first(self, keys, default=None):
"""
For given keys, return value for first key that isn't ``None``. If such
a key is not found, ``default`` is returned.
"""
d = self.device
for k in keys:
v = d.get(k)
if not v is None:
ret... | python | def _get_first(self, keys, default=None):
"""
For given keys, return value for first key that isn't ``None``. If such
a key is not found, ``default`` is returned.
"""
d = self.device
for k in keys:
v = d.get(k)
if not v is None:
ret... | [
"def",
"_get_first",
"(",
"self",
",",
"keys",
",",
"default",
"=",
"None",
")",
":",
"d",
"=",
"self",
".",
"device",
"for",
"k",
"in",
"keys",
":",
"v",
"=",
"d",
".",
"get",
"(",
"k",
")",
"if",
"not",
"v",
"is",
"None",
":",
"return",
"v"... | For given keys, return value for first key that isn't ``None``. If such
a key is not found, ``default`` is returned. | [
"For",
"given",
"keys",
"return",
"value",
"for",
"first",
"key",
"that",
"isn",
"t",
"None",
".",
"If",
"such",
"a",
"key",
"is",
"not",
"found",
"default",
"is",
"returned",
"."
] | train | https://github.com/Othernet-Project/hwd/blob/7f4445bac61aa2305806aa80338e2ce5baa1093c/hwd/wrapper.py#L118-L128 |
Othernet-Project/hwd | hwd/wrapper.py | Wrapper.aliases | def aliases(self):
"""
Return a list of device aliases (symlinks) that match this device. This
list also includes the device node so it can be treated as a list of
all filesystem objects that point to this device.
"""
links = list(self.device.device_links)
links.i... | python | def aliases(self):
"""
Return a list of device aliases (symlinks) that match this device. This
list also includes the device node so it can be treated as a list of
all filesystem objects that point to this device.
"""
links = list(self.device.device_links)
links.i... | [
"def",
"aliases",
"(",
"self",
")",
":",
"links",
"=",
"list",
"(",
"self",
".",
"device",
".",
"device_links",
")",
"links",
".",
"insert",
"(",
"0",
",",
"self",
".",
"node",
")",
"return",
"links"
] | Return a list of device aliases (symlinks) that match this device. This
list also includes the device node so it can be treated as a list of
all filesystem objects that point to this device. | [
"Return",
"a",
"list",
"of",
"device",
"aliases",
"(",
"symlinks",
")",
"that",
"match",
"this",
"device",
".",
"This",
"list",
"also",
"includes",
"the",
"device",
"node",
"so",
"it",
"can",
"be",
"treated",
"as",
"a",
"list",
"of",
"all",
"filesystem",... | train | https://github.com/Othernet-Project/hwd/blob/7f4445bac61aa2305806aa80338e2ce5baa1093c/hwd/wrapper.py#L131-L139 |
darkfeline/mir.sqlite3m | mir/sqlite3m/__init__.py | CheckForeignKeysWrapper | def CheckForeignKeysWrapper(conn):
"""Migration wrapper that checks foreign keys.
Note that this may raise different exceptions depending on the
underlying database API.
"""
yield
cur = conn.cursor()
cur.execute('PRAGMA foreign_key_check')
errors = cur.fetchall()
if errors:
... | python | def CheckForeignKeysWrapper(conn):
"""Migration wrapper that checks foreign keys.
Note that this may raise different exceptions depending on the
underlying database API.
"""
yield
cur = conn.cursor()
cur.execute('PRAGMA foreign_key_check')
errors = cur.fetchall()
if errors:
... | [
"def",
"CheckForeignKeysWrapper",
"(",
"conn",
")",
":",
"yield",
"cur",
"=",
"conn",
".",
"cursor",
"(",
")",
"cur",
".",
"execute",
"(",
"'PRAGMA foreign_key_check'",
")",
"errors",
"=",
"cur",
".",
"fetchall",
"(",
")",
"if",
"errors",
":",
"raise",
"... | Migration wrapper that checks foreign keys.
Note that this may raise different exceptions depending on the
underlying database API. | [
"Migration",
"wrapper",
"that",
"checks",
"foreign",
"keys",
"."
] | train | https://github.com/darkfeline/mir.sqlite3m/blob/9080c3347c8f0f59ec6117f33ba9ad07c6ca0afc/mir/sqlite3m/__init__.py#L157-L168 |
darkfeline/mir.sqlite3m | mir/sqlite3m/__init__.py | MigrationManager.register_migration | def register_migration(self, migration: 'Migration'):
"""Register a migration.
You can only register migrations in order. For example, you can
register migrations from version 1 to 2, then 2 to 3, then 3 to
4. You cannot register 1 to 2 followed by 3 to 4.
"""
if migra... | python | def register_migration(self, migration: 'Migration'):
"""Register a migration.
You can only register migrations in order. For example, you can
register migrations from version 1 to 2, then 2 to 3, then 3 to
4. You cannot register 1 to 2 followed by 3 to 4.
"""
if migra... | [
"def",
"register_migration",
"(",
"self",
",",
"migration",
":",
"'Migration'",
")",
":",
"if",
"migration",
".",
"from_ver",
">=",
"migration",
".",
"to_ver",
":",
"raise",
"ValueError",
"(",
"'Migration cannot downgrade verson'",
")",
"if",
"migration",
".",
"... | Register a migration.
You can only register migrations in order. For example, you can
register migrations from version 1 to 2, then 2 to 3, then 3 to
4. You cannot register 1 to 2 followed by 3 to 4. | [
"Register",
"a",
"migration",
"."
] | train | https://github.com/darkfeline/mir.sqlite3m/blob/9080c3347c8f0f59ec6117f33ba9ad07c6ca0afc/mir/sqlite3m/__init__.py#L56-L68 |
darkfeline/mir.sqlite3m | mir/sqlite3m/__init__.py | MigrationManager.migration | def migration(self, from_ver: int, to_ver: int):
"""Decorator to create and register a migration.
>>> manager = MigrationManager()
>>> @manager.migration(0, 1)
... def migrate(conn):
... pass
"""
def decorator(func):
migration = Migration(from_ver... | python | def migration(self, from_ver: int, to_ver: int):
"""Decorator to create and register a migration.
>>> manager = MigrationManager()
>>> @manager.migration(0, 1)
... def migrate(conn):
... pass
"""
def decorator(func):
migration = Migration(from_ver... | [
"def",
"migration",
"(",
"self",
",",
"from_ver",
":",
"int",
",",
"to_ver",
":",
"int",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"migration",
"=",
"Migration",
"(",
"from_ver",
",",
"to_ver",
",",
"func",
")",
"self",
".",
"register_migrat... | Decorator to create and register a migration.
>>> manager = MigrationManager()
>>> @manager.migration(0, 1)
... def migrate(conn):
... pass | [
"Decorator",
"to",
"create",
"and",
"register",
"a",
"migration",
"."
] | train | https://github.com/darkfeline/mir.sqlite3m/blob/9080c3347c8f0f59ec6117f33ba9ad07c6ca0afc/mir/sqlite3m/__init__.py#L70-L82 |
darkfeline/mir.sqlite3m | mir/sqlite3m/__init__.py | MigrationManager.migrate | def migrate(self, conn):
"""Migrate a database as needed.
This method is safe to call on an up-to-date database, on an old
database, on a newer database, or an uninitialized database
(version 0).
This method is idempotent.
"""
while self.should_migrate(conn):
... | python | def migrate(self, conn):
"""Migrate a database as needed.
This method is safe to call on an up-to-date database, on an old
database, on a newer database, or an uninitialized database
(version 0).
This method is idempotent.
"""
while self.should_migrate(conn):
... | [
"def",
"migrate",
"(",
"self",
",",
"conn",
")",
":",
"while",
"self",
".",
"should_migrate",
"(",
"conn",
")",
":",
"current_version",
"=",
"get_user_version",
"(",
"conn",
")",
"migration",
"=",
"self",
".",
"_get_migration",
"(",
"current_version",
")",
... | Migrate a database as needed.
This method is safe to call on an up-to-date database, on an old
database, on a newer database, or an uninitialized database
(version 0).
This method is idempotent. | [
"Migrate",
"a",
"database",
"as",
"needed",
"."
] | train | https://github.com/darkfeline/mir.sqlite3m/blob/9080c3347c8f0f59ec6117f33ba9ad07c6ca0afc/mir/sqlite3m/__init__.py#L92-L109 |
darkfeline/mir.sqlite3m | mir/sqlite3m/__init__.py | MigrationManager._migrate_single | def _migrate_single(self, conn, migration):
"""Perform a single migration starting from the given version."""
with contextlib.ExitStack() as stack:
for wrapper in self._wrappers:
stack.enter_context(wrapper(conn))
migration.func(conn) | python | def _migrate_single(self, conn, migration):
"""Perform a single migration starting from the given version."""
with contextlib.ExitStack() as stack:
for wrapper in self._wrappers:
stack.enter_context(wrapper(conn))
migration.func(conn) | [
"def",
"_migrate_single",
"(",
"self",
",",
"conn",
",",
"migration",
")",
":",
"with",
"contextlib",
".",
"ExitStack",
"(",
")",
"as",
"stack",
":",
"for",
"wrapper",
"in",
"self",
".",
"_wrappers",
":",
"stack",
".",
"enter_context",
"(",
"wrapper",
"(... | Perform a single migration starting from the given version. | [
"Perform",
"a",
"single",
"migration",
"starting",
"from",
"the",
"given",
"version",
"."
] | train | https://github.com/darkfeline/mir.sqlite3m/blob/9080c3347c8f0f59ec6117f33ba9ad07c6ca0afc/mir/sqlite3m/__init__.py#L115-L120 |
dr4ke616/pinky | twisted/plugins/broker.py | BrokerServiceMaker.makeService | def makeService(self, options):
""" Construct a Broker Server
"""
return BrokerService(
port=options['port'],
debug=options['debug'],
activate_ssh_server=options['activate-ssh-server'],
ssh_user=options['ssh-user'],
ssh_password=options... | python | def makeService(self, options):
""" Construct a Broker Server
"""
return BrokerService(
port=options['port'],
debug=options['debug'],
activate_ssh_server=options['activate-ssh-server'],
ssh_user=options['ssh-user'],
ssh_password=options... | [
"def",
"makeService",
"(",
"self",
",",
"options",
")",
":",
"return",
"BrokerService",
"(",
"port",
"=",
"options",
"[",
"'port'",
"]",
",",
"debug",
"=",
"options",
"[",
"'debug'",
"]",
",",
"activate_ssh_server",
"=",
"options",
"[",
"'activate-ssh-server... | Construct a Broker Server | [
"Construct",
"a",
"Broker",
"Server"
] | train | https://github.com/dr4ke616/pinky/blob/35c165f5a1d410be467621f3152df1dbf458622a/twisted/plugins/broker.py#L31-L41 |
jroyal/pyIDS | pyIDS/ids.py | IDS.get_work_items | def get_work_items(self, **filters):
'''
Get a work item's information
:param filters: A series of key value pairs to filter on
:return: list of Workitems or None
'''
filter_string = ""
for key, val in filters.iteritems():
filter_string += "%s='%s'" % ... | python | def get_work_items(self, **filters):
'''
Get a work item's information
:param filters: A series of key value pairs to filter on
:return: list of Workitems or None
'''
filter_string = ""
for key, val in filters.iteritems():
filter_string += "%s='%s'" % ... | [
"def",
"get_work_items",
"(",
"self",
",",
"*",
"*",
"filters",
")",
":",
"filter_string",
"=",
"\"\"",
"for",
"key",
",",
"val",
"in",
"filters",
".",
"iteritems",
"(",
")",
":",
"filter_string",
"+=",
"\"%s='%s'\"",
"%",
"(",
"key",
",",
"val",
")",
... | Get a work item's information
:param filters: A series of key value pairs to filter on
:return: list of Workitems or None | [
"Get",
"a",
"work",
"item",
"s",
"information",
":",
"param",
"filters",
":",
"A",
"series",
"of",
"key",
"value",
"pairs",
"to",
"filter",
"on",
":",
"return",
":",
"list",
"of",
"Workitems",
"or",
"None"
] | train | https://github.com/jroyal/pyIDS/blob/3c2d3ff4bdc7bfe116dfd02152dadd26f92f74b5/pyIDS/ids.py#L38-L80 |
jroyal/pyIDS | pyIDS/ids.py | IDS.get_work_item_by_id | def get_work_item_by_id(self, wi_id):
'''
Retrieves a single work item based off of the supplied ID
:param wi_id: The work item ID number
:return: Workitem or None
'''
work_items = self.get_work_items(id=wi_id)
if work_items is not None:
return work_i... | python | def get_work_item_by_id(self, wi_id):
'''
Retrieves a single work item based off of the supplied ID
:param wi_id: The work item ID number
:return: Workitem or None
'''
work_items = self.get_work_items(id=wi_id)
if work_items is not None:
return work_i... | [
"def",
"get_work_item_by_id",
"(",
"self",
",",
"wi_id",
")",
":",
"work_items",
"=",
"self",
".",
"get_work_items",
"(",
"id",
"=",
"wi_id",
")",
"if",
"work_items",
"is",
"not",
"None",
":",
"return",
"work_items",
"[",
"0",
"]",
"return",
"None"
] | Retrieves a single work item based off of the supplied ID
:param wi_id: The work item ID number
:return: Workitem or None | [
"Retrieves",
"a",
"single",
"work",
"item",
"based",
"off",
"of",
"the",
"supplied",
"ID"
] | train | https://github.com/jroyal/pyIDS/blob/3c2d3ff4bdc7bfe116dfd02152dadd26f92f74b5/pyIDS/ids.py#L82-L92 |
thespacedoctor/sloancone | build/lib/sloancone/cone_search.py | cone_search.get | def get(self):
"""
*get the cone_search object*
**Return:**
- ``results`` -- the results of the conesearch
"""
self.log.info('starting the ``get`` method')
# sort results by angular separation
from operator import itemgetter
results = list(s... | python | def get(self):
"""
*get the cone_search object*
**Return:**
- ``results`` -- the results of the conesearch
"""
self.log.info('starting the ``get`` method')
# sort results by angular separation
from operator import itemgetter
results = list(s... | [
"def",
"get",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"'starting the ``get`` method'",
")",
"# sort results by angular separation",
"from",
"operator",
"import",
"itemgetter",
"results",
"=",
"list",
"(",
"self",
".",
"squareResults",
")",
"... | *get the cone_search object*
**Return:**
- ``results`` -- the results of the conesearch | [
"*",
"get",
"the",
"cone_search",
"object",
"*"
] | train | https://github.com/thespacedoctor/sloancone/blob/106ea6533ad57f5f0ca82bf6db3053132bdb42e1/build/lib/sloancone/cone_search.py#L211-L275 |
mikejarrett/pipcheck | pipcheck/clients.py | PyPIClient.package_releases | def package_releases(self, project_name):
""" Retrieve the versions from PyPI by ``project_name``.
Args:
project_name (str): The name of the project we wish to retrieve
the versions of.
Returns:
list: Of string versions.
"""
try:
... | python | def package_releases(self, project_name):
""" Retrieve the versions from PyPI by ``project_name``.
Args:
project_name (str): The name of the project we wish to retrieve
the versions of.
Returns:
list: Of string versions.
"""
try:
... | [
"def",
"package_releases",
"(",
"self",
",",
"project_name",
")",
":",
"try",
":",
"return",
"self",
".",
"_connection",
".",
"package_releases",
"(",
"project_name",
")",
"except",
"Exception",
"as",
"err",
":",
"raise",
"PyPIClientError",
"(",
"err",
")"
] | Retrieve the versions from PyPI by ``project_name``.
Args:
project_name (str): The name of the project we wish to retrieve
the versions of.
Returns:
list: Of string versions. | [
"Retrieve",
"the",
"versions",
"from",
"PyPI",
"by",
"project_name",
"."
] | train | https://github.com/mikejarrett/pipcheck/blob/2ff47b9fd8914e1764c6e659ef39b77c1b1a12ad/pipcheck/clients.py#L17-L30 |
mikejarrett/pipcheck | pipcheck/clients.py | PyPIClientPureMemory.set_package_releases | def set_package_releases(self, project_name, versions):
""" Storage package information in ``self.packages``
Args:
project_name (str): This will be used as a the key in the
dictionary.
versions (list): List of ``str`` representing the available
ve... | python | def set_package_releases(self, project_name, versions):
""" Storage package information in ``self.packages``
Args:
project_name (str): This will be used as a the key in the
dictionary.
versions (list): List of ``str`` representing the available
ve... | [
"def",
"set_package_releases",
"(",
"self",
",",
"project_name",
",",
"versions",
")",
":",
"self",
".",
"packages",
"[",
"project_name",
"]",
"=",
"sorted",
"(",
"versions",
",",
"reverse",
"=",
"True",
")"
] | Storage package information in ``self.packages``
Args:
project_name (str): This will be used as a the key in the
dictionary.
versions (list): List of ``str`` representing the available
versions of a project. | [
"Storage",
"package",
"information",
"in",
"self",
".",
"packages"
] | train | https://github.com/mikejarrett/pipcheck/blob/2ff47b9fd8914e1764c6e659ef39b77c1b1a12ad/pipcheck/clients.py#L60-L69 |
zerc/django-vest | django_vest/utils.py | load_object | def load_object(s):
""" Load backend by dotted path.
"""
try:
m_path, o_name = s.rsplit('.', 1)
except ValueError:
raise ImportError('Cant import backend from path: {}'.format(s))
module = import_module(m_path)
return getattr(module, o_name) | python | def load_object(s):
""" Load backend by dotted path.
"""
try:
m_path, o_name = s.rsplit('.', 1)
except ValueError:
raise ImportError('Cant import backend from path: {}'.format(s))
module = import_module(m_path)
return getattr(module, o_name) | [
"def",
"load_object",
"(",
"s",
")",
":",
"try",
":",
"m_path",
",",
"o_name",
"=",
"s",
".",
"rsplit",
"(",
"'.'",
",",
"1",
")",
"except",
"ValueError",
":",
"raise",
"ImportError",
"(",
"'Cant import backend from path: {}'",
".",
"format",
"(",
"s",
"... | Load backend by dotted path. | [
"Load",
"backend",
"by",
"dotted",
"path",
"."
] | train | https://github.com/zerc/django-vest/blob/39dbd0cd4de59ad8f5d06d1cc4d5fbcd210ab764/django_vest/utils.py#L11-L20 |
zerc/django-vest | django_vest/utils.py | get_available_themes | def get_available_themes():
""" Iterator on available themes
"""
for d in settings.TEMPLATE_DIRS:
for _d in os.listdir(d):
if os.path.isdir(os.path.join(d, _d)) and is_theme_dir(_d):
yield _d | python | def get_available_themes():
""" Iterator on available themes
"""
for d in settings.TEMPLATE_DIRS:
for _d in os.listdir(d):
if os.path.isdir(os.path.join(d, _d)) and is_theme_dir(_d):
yield _d | [
"def",
"get_available_themes",
"(",
")",
":",
"for",
"d",
"in",
"settings",
".",
"TEMPLATE_DIRS",
":",
"for",
"_d",
"in",
"os",
".",
"listdir",
"(",
"d",
")",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"os",
".",
"path",
".",
"join",
"(",
"... | Iterator on available themes | [
"Iterator",
"on",
"available",
"themes"
] | train | https://github.com/zerc/django-vest/blob/39dbd0cd4de59ad8f5d06d1cc4d5fbcd210ab764/django_vest/utils.py#L23-L29 |
WhereSoftwareGoesToDie/pymarquise | marquise/oslo_strutils.py | safe_encode | def safe_encode(text, incoming=None,
encoding='utf-8', errors='strict'):
"""Encodes incoming text/bytes string using `encoding`.
If incoming is not specified, text is expected to be encoded with
current python's default encoding. (`sys.getdefaultencoding`)
:param incoming: Text's curre... | python | def safe_encode(text, incoming=None,
encoding='utf-8', errors='strict'):
"""Encodes incoming text/bytes string using `encoding`.
If incoming is not specified, text is expected to be encoded with
current python's default encoding. (`sys.getdefaultencoding`)
:param incoming: Text's curre... | [
"def",
"safe_encode",
"(",
"text",
",",
"incoming",
"=",
"None",
",",
"encoding",
"=",
"'utf-8'",
",",
"errors",
"=",
"'strict'",
")",
":",
"if",
"not",
"isinstance",
"(",
"text",
",",
"(",
"six",
".",
"string_types",
",",
"six",
".",
"binary_type",
")... | Encodes incoming text/bytes string using `encoding`.
If incoming is not specified, text is expected to be encoded with
current python's default encoding. (`sys.getdefaultencoding`)
:param incoming: Text's current encoding
:param encoding: Expected encoding for text (Default UTF-8)
:param errors: E... | [
"Encodes",
"incoming",
"text",
"/",
"bytes",
"string",
"using",
"encoding",
"."
] | train | https://github.com/WhereSoftwareGoesToDie/pymarquise/blob/67e52df70c50ed53ad315a64fea430a9567e2b1b/marquise/oslo_strutils.py#L70-L99 |
autonimo/autonimo | autonimo/tasks/task.py | Task._check_ui_parameters | def _check_ui_parameters(self):
"""
Checks that tasks parameters exist in the task and are of the right type. Runs before the task is run.
:return: None
:raises TaskValidationError: the task parameter is missing or invalid.
"""
if isinstance(self.PARAMETER_UI_STUFF, dict)... | python | def _check_ui_parameters(self):
"""
Checks that tasks parameters exist in the task and are of the right type. Runs before the task is run.
:return: None
:raises TaskValidationError: the task parameter is missing or invalid.
"""
if isinstance(self.PARAMETER_UI_STUFF, dict)... | [
"def",
"_check_ui_parameters",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"PARAMETER_UI_STUFF",
",",
"dict",
")",
":",
"for",
"param",
"in",
"self",
".",
"PARAMETER_UI_STUFF",
".",
"keys",
"(",
")",
":",
"# check parameter value can be found",
... | Checks that tasks parameters exist in the task and are of the right type. Runs before the task is run.
:return: None
:raises TaskValidationError: the task parameter is missing or invalid. | [
"Checks",
"that",
"tasks",
"parameters",
"exist",
"in",
"the",
"task",
"and",
"are",
"of",
"the",
"right",
"type",
".",
"Runs",
"before",
"the",
"task",
"is",
"run",
".",
":",
"return",
":",
"None",
":",
"raises",
"TaskValidationError",
":",
"the",
"task... | train | https://github.com/autonimo/autonimo/blob/72acfe05cc08207442317794f6c3afbbf077be58/autonimo/tasks/task.py#L44-L62 |
autonimo/autonimo | autonimo/tasks/task.py | Task.check_pause | def check_pause(self):
"""
Call at regular intervals within long running tasks to add pause breakpoints.
:return: time that the task was paused for, always 0.0 if it didn't pause
:rtype: float
"""
# todo task_runner vs model
pause_time = 0.0
sleep_time =... | python | def check_pause(self):
"""
Call at regular intervals within long running tasks to add pause breakpoints.
:return: time that the task was paused for, always 0.0 if it didn't pause
:rtype: float
"""
# todo task_runner vs model
pause_time = 0.0
sleep_time =... | [
"def",
"check_pause",
"(",
"self",
")",
":",
"# todo task_runner vs model",
"pause_time",
"=",
"0.0",
"sleep_time",
"=",
"0.1",
"if",
"self",
".",
"model",
".",
"tasks_paused",
":",
"while",
"self",
".",
"model",
".",
"tasks_paused",
":",
"sleep",
"(",
"paus... | Call at regular intervals within long running tasks to add pause breakpoints.
:return: time that the task was paused for, always 0.0 if it didn't pause
:rtype: float | [
"Call",
"at",
"regular",
"intervals",
"within",
"long",
"running",
"tasks",
"to",
"add",
"pause",
"breakpoints",
".",
":",
"return",
":",
"time",
"that",
"the",
"task",
"was",
"paused",
"for",
"always",
"0",
".",
"0",
"if",
"it",
"didn",
"t",
"pause",
... | train | https://github.com/autonimo/autonimo/blob/72acfe05cc08207442317794f6c3afbbf077be58/autonimo/tasks/task.py#L90-L105 |
minhhoit/yacms | yacms/pages/admin.py | PageAdminForm.clean_slug | def clean_slug(self):
"""
Save the old slug to be used later in PageAdmin.save_model()
to make the slug change propagate down the page tree, and clean
leading and trailing slashes which are added on elsewhere.
"""
self.instance._old_slug = self.instance.slug
new_s... | python | def clean_slug(self):
"""
Save the old slug to be used later in PageAdmin.save_model()
to make the slug change propagate down the page tree, and clean
leading and trailing slashes which are added on elsewhere.
"""
self.instance._old_slug = self.instance.slug
new_s... | [
"def",
"clean_slug",
"(",
"self",
")",
":",
"self",
".",
"instance",
".",
"_old_slug",
"=",
"self",
".",
"instance",
".",
"slug",
"new_slug",
"=",
"self",
".",
"cleaned_data",
"[",
"'slug'",
"]",
"if",
"not",
"isinstance",
"(",
"self",
".",
"instance",
... | Save the old slug to be used later in PageAdmin.save_model()
to make the slug change propagate down the page tree, and clean
leading and trailing slashes which are added on elsewhere. | [
"Save",
"the",
"old",
"slug",
"to",
"be",
"used",
"later",
"in",
"PageAdmin",
".",
"save_model",
"()",
"to",
"make",
"the",
"slug",
"change",
"propagate",
"down",
"the",
"page",
"tree",
"and",
"clean",
"leading",
"and",
"trailing",
"slashes",
"which",
"are... | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/pages/admin.py#L27-L37 |
minhhoit/yacms | yacms/pages/admin.py | PageAdmin.check_permission | def check_permission(self, request, page, permission):
"""
Runs the custom permission check and raises an
exception if False.
"""
if not getattr(page, "can_" + permission)(request):
raise PermissionDenied | python | def check_permission(self, request, page, permission):
"""
Runs the custom permission check and raises an
exception if False.
"""
if not getattr(page, "can_" + permission)(request):
raise PermissionDenied | [
"def",
"check_permission",
"(",
"self",
",",
"request",
",",
"page",
",",
"permission",
")",
":",
"if",
"not",
"getattr",
"(",
"page",
",",
"\"can_\"",
"+",
"permission",
")",
"(",
"request",
")",
":",
"raise",
"PermissionDenied"
] | Runs the custom permission check and raises an
exception if False. | [
"Runs",
"the",
"custom",
"permission",
"check",
"and",
"raises",
"an",
"exception",
"if",
"False",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/pages/admin.py#L51-L57 |
minhhoit/yacms | yacms/pages/admin.py | PageAdmin.add_view | def add_view(self, request, **kwargs):
"""
For the ``Page`` model, redirect to the add view for the
first page model, based on the ``ADD_PAGE_ORDER`` setting.
"""
if self.model is Page:
return HttpResponseRedirect(self.get_content_models()[0].add_url)
return s... | python | def add_view(self, request, **kwargs):
"""
For the ``Page`` model, redirect to the add view for the
first page model, based on the ``ADD_PAGE_ORDER`` setting.
"""
if self.model is Page:
return HttpResponseRedirect(self.get_content_models()[0].add_url)
return s... | [
"def",
"add_view",
"(",
"self",
",",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"model",
"is",
"Page",
":",
"return",
"HttpResponseRedirect",
"(",
"self",
".",
"get_content_models",
"(",
")",
"[",
"0",
"]",
".",
"add_url",
")",
... | For the ``Page`` model, redirect to the add view for the
first page model, based on the ``ADD_PAGE_ORDER`` setting. | [
"For",
"the",
"Page",
"model",
"redirect",
"to",
"the",
"add",
"view",
"for",
"the",
"first",
"page",
"model",
"based",
"on",
"the",
"ADD_PAGE_ORDER",
"setting",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/pages/admin.py#L59-L66 |
minhhoit/yacms | yacms/pages/admin.py | PageAdmin.change_view | def change_view(self, request, object_id, **kwargs):
"""
Enforce custom permissions for the page instance.
"""
page = get_object_or_404(Page, pk=object_id)
content_model = page.get_content_model()
kwargs.setdefault("extra_context", {})
kwargs["extra_context"].upd... | python | def change_view(self, request, object_id, **kwargs):
"""
Enforce custom permissions for the page instance.
"""
page = get_object_or_404(Page, pk=object_id)
content_model = page.get_content_model()
kwargs.setdefault("extra_context", {})
kwargs["extra_context"].upd... | [
"def",
"change_view",
"(",
"self",
",",
"request",
",",
"object_id",
",",
"*",
"*",
"kwargs",
")",
":",
"page",
"=",
"get_object_or_404",
"(",
"Page",
",",
"pk",
"=",
"object_id",
")",
"content_model",
"=",
"page",
".",
"get_content_model",
"(",
")",
"kw... | Enforce custom permissions for the page instance. | [
"Enforce",
"custom",
"permissions",
"for",
"the",
"page",
"instance",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/pages/admin.py#L68-L81 |
minhhoit/yacms | yacms/pages/admin.py | PageAdmin.delete_view | def delete_view(self, request, object_id, **kwargs):
"""
Enforce custom delete permissions for the page instance.
"""
page = get_object_or_404(Page, pk=object_id)
content_model = page.get_content_model()
self.check_permission(request, content_model, "delete")
retu... | python | def delete_view(self, request, object_id, **kwargs):
"""
Enforce custom delete permissions for the page instance.
"""
page = get_object_or_404(Page, pk=object_id)
content_model = page.get_content_model()
self.check_permission(request, content_model, "delete")
retu... | [
"def",
"delete_view",
"(",
"self",
",",
"request",
",",
"object_id",
",",
"*",
"*",
"kwargs",
")",
":",
"page",
"=",
"get_object_or_404",
"(",
"Page",
",",
"pk",
"=",
"object_id",
")",
"content_model",
"=",
"page",
".",
"get_content_model",
"(",
")",
"se... | Enforce custom delete permissions for the page instance. | [
"Enforce",
"custom",
"delete",
"permissions",
"for",
"the",
"page",
"instance",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/pages/admin.py#L83-L90 |
minhhoit/yacms | yacms/pages/admin.py | PageAdmin.save_model | def save_model(self, request, obj, form, change):
"""
Set the ID of the parent page if passed in via querystring, and
make sure the new slug propagates to all descendant pages.
"""
if change and obj._old_slug != obj.slug:
# _old_slug was set in PageAdminForm.clean_slu... | python | def save_model(self, request, obj, form, change):
"""
Set the ID of the parent page if passed in via querystring, and
make sure the new slug propagates to all descendant pages.
"""
if change and obj._old_slug != obj.slug:
# _old_slug was set in PageAdminForm.clean_slu... | [
"def",
"save_model",
"(",
"self",
",",
"request",
",",
"obj",
",",
"form",
",",
"change",
")",
":",
"if",
"change",
"and",
"obj",
".",
"_old_slug",
"!=",
"obj",
".",
"slug",
":",
"# _old_slug was set in PageAdminForm.clean_slug().",
"new_slug",
"=",
"obj",
"... | Set the ID of the parent page if passed in via querystring, and
make sure the new slug propagates to all descendant pages. | [
"Set",
"the",
"ID",
"of",
"the",
"parent",
"page",
"if",
"passed",
"in",
"via",
"querystring",
"and",
"make",
"sure",
"the",
"new",
"slug",
"propagates",
"to",
"all",
"descendant",
"pages",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/pages/admin.py#L92-L108 |
minhhoit/yacms | yacms/pages/admin.py | PageAdmin._maintain_parent | def _maintain_parent(self, request, response):
"""
Maintain the parent ID in the querystring for response_add and
response_change.
"""
location = response._headers.get("location")
parent = request.GET.get("parent")
if parent and location and "?" not in location[1]... | python | def _maintain_parent(self, request, response):
"""
Maintain the parent ID in the querystring for response_add and
response_change.
"""
location = response._headers.get("location")
parent = request.GET.get("parent")
if parent and location and "?" not in location[1]... | [
"def",
"_maintain_parent",
"(",
"self",
",",
"request",
",",
"response",
")",
":",
"location",
"=",
"response",
".",
"_headers",
".",
"get",
"(",
"\"location\"",
")",
"parent",
"=",
"request",
".",
"GET",
".",
"get",
"(",
"\"parent\"",
")",
"if",
"parent... | Maintain the parent ID in the querystring for response_add and
response_change. | [
"Maintain",
"the",
"parent",
"ID",
"in",
"the",
"querystring",
"for",
"response_add",
"and",
"response_change",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/pages/admin.py#L110-L120 |
minhhoit/yacms | yacms/pages/admin.py | PageAdmin.response_add | def response_add(self, request, obj):
"""
Enforce page permissions and maintain the parent ID in the
querystring.
"""
response = super(PageAdmin, self).response_add(request, obj)
return self._maintain_parent(request, response) | python | def response_add(self, request, obj):
"""
Enforce page permissions and maintain the parent ID in the
querystring.
"""
response = super(PageAdmin, self).response_add(request, obj)
return self._maintain_parent(request, response) | [
"def",
"response_add",
"(",
"self",
",",
"request",
",",
"obj",
")",
":",
"response",
"=",
"super",
"(",
"PageAdmin",
",",
"self",
")",
".",
"response_add",
"(",
"request",
",",
"obj",
")",
"return",
"self",
".",
"_maintain_parent",
"(",
"request",
",",
... | Enforce page permissions and maintain the parent ID in the
querystring. | [
"Enforce",
"page",
"permissions",
"and",
"maintain",
"the",
"parent",
"ID",
"in",
"the",
"querystring",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/pages/admin.py#L122-L128 |
minhhoit/yacms | yacms/pages/admin.py | PageAdmin.response_change | def response_change(self, request, obj):
"""
Enforce page permissions and maintain the parent ID in the
querystring.
"""
response = super(PageAdmin, self).response_change(request, obj)
return self._maintain_parent(request, response) | python | def response_change(self, request, obj):
"""
Enforce page permissions and maintain the parent ID in the
querystring.
"""
response = super(PageAdmin, self).response_change(request, obj)
return self._maintain_parent(request, response) | [
"def",
"response_change",
"(",
"self",
",",
"request",
",",
"obj",
")",
":",
"response",
"=",
"super",
"(",
"PageAdmin",
",",
"self",
")",
".",
"response_change",
"(",
"request",
",",
"obj",
")",
"return",
"self",
".",
"_maintain_parent",
"(",
"request",
... | Enforce page permissions and maintain the parent ID in the
querystring. | [
"Enforce",
"page",
"permissions",
"and",
"maintain",
"the",
"parent",
"ID",
"in",
"the",
"querystring",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/pages/admin.py#L130-L136 |
minhhoit/yacms | yacms/pages/admin.py | PageAdmin.get_content_models | def get_content_models(self):
"""
Return all Page subclasses that are admin registered, ordered
based on the ``ADD_PAGE_ORDER`` setting.
"""
models = super(PageAdmin, self).get_content_models()
order = [name.lower() for name in settings.ADD_PAGE_ORDER]
def sort_... | python | def get_content_models(self):
"""
Return all Page subclasses that are admin registered, ordered
based on the ``ADD_PAGE_ORDER`` setting.
"""
models = super(PageAdmin, self).get_content_models()
order = [name.lower() for name in settings.ADD_PAGE_ORDER]
def sort_... | [
"def",
"get_content_models",
"(",
"self",
")",
":",
"models",
"=",
"super",
"(",
"PageAdmin",
",",
"self",
")",
".",
"get_content_models",
"(",
")",
"order",
"=",
"[",
"name",
".",
"lower",
"(",
")",
"for",
"name",
"in",
"settings",
".",
"ADD_PAGE_ORDER"... | Return all Page subclasses that are admin registered, ordered
based on the ``ADD_PAGE_ORDER`` setting. | [
"Return",
"all",
"Page",
"subclasses",
"that",
"are",
"admin",
"registered",
"ordered",
"based",
"on",
"the",
"ADD_PAGE_ORDER",
"setting",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/pages/admin.py#L138-L154 |
minhhoit/yacms | yacms/pages/admin.py | LinkAdmin.formfield_for_dbfield | def formfield_for_dbfield(self, db_field, **kwargs):
"""
Make slug mandatory.
"""
if db_field.name == "slug":
kwargs["required"] = True
kwargs["help_text"] = None
return super(LinkAdmin, self).formfield_for_dbfield(db_field, **kwargs) | python | def formfield_for_dbfield(self, db_field, **kwargs):
"""
Make slug mandatory.
"""
if db_field.name == "slug":
kwargs["required"] = True
kwargs["help_text"] = None
return super(LinkAdmin, self).formfield_for_dbfield(db_field, **kwargs) | [
"def",
"formfield_for_dbfield",
"(",
"self",
",",
"db_field",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"db_field",
".",
"name",
"==",
"\"slug\"",
":",
"kwargs",
"[",
"\"required\"",
"]",
"=",
"True",
"kwargs",
"[",
"\"help_text\"",
"]",
"=",
"None",
"ret... | Make slug mandatory. | [
"Make",
"slug",
"mandatory",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/pages/admin.py#L166-L173 |
minhhoit/yacms | yacms/pages/admin.py | LinkAdmin.save_form | def save_form(self, request, form, change):
"""
Don't show links in the sitemap.
"""
obj = form.save(commit=False)
if not obj.id and "in_sitemap" not in form.fields:
obj.in_sitemap = False
return super(LinkAdmin, self).save_form(request, form, change) | python | def save_form(self, request, form, change):
"""
Don't show links in the sitemap.
"""
obj = form.save(commit=False)
if not obj.id and "in_sitemap" not in form.fields:
obj.in_sitemap = False
return super(LinkAdmin, self).save_form(request, form, change) | [
"def",
"save_form",
"(",
"self",
",",
"request",
",",
"form",
",",
"change",
")",
":",
"obj",
"=",
"form",
".",
"save",
"(",
"commit",
"=",
"False",
")",
"if",
"not",
"obj",
".",
"id",
"and",
"\"in_sitemap\"",
"not",
"in",
"form",
".",
"fields",
":... | Don't show links in the sitemap. | [
"Don",
"t",
"show",
"links",
"in",
"the",
"sitemap",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/pages/admin.py#L175-L182 |
darkfeline/mir.anidb | mir/anidb/titles.py | _request_titles_xml | def _request_titles_xml() -> ET.ElementTree:
"""Request AniDB titles file."""
response = api.titles_request()
return api.unpack_xml(response.text) | python | def _request_titles_xml() -> ET.ElementTree:
"""Request AniDB titles file."""
response = api.titles_request()
return api.unpack_xml(response.text) | [
"def",
"_request_titles_xml",
"(",
")",
"->",
"ET",
".",
"ElementTree",
":",
"response",
"=",
"api",
".",
"titles_request",
"(",
")",
"return",
"api",
".",
"unpack_xml",
"(",
"response",
".",
"text",
")"
] | Request AniDB titles file. | [
"Request",
"AniDB",
"titles",
"file",
"."
] | train | https://github.com/darkfeline/mir.anidb/blob/a0d25908f85fb1ff4bc595954bfc3f223f1b5acc/mir/anidb/titles.py#L157-L160 |
darkfeline/mir.anidb | mir/anidb/titles.py | _unpack_titles | def _unpack_titles(etree: ET.ElementTree) -> 'Generator':
"""Unpack Titles from titles XML."""
for anime in etree.getroot():
yield Titles(
aid=int(anime.get('aid')),
titles=tuple(unpack_anime_title(title) for title in anime),
) | python | def _unpack_titles(etree: ET.ElementTree) -> 'Generator':
"""Unpack Titles from titles XML."""
for anime in etree.getroot():
yield Titles(
aid=int(anime.get('aid')),
titles=tuple(unpack_anime_title(title) for title in anime),
) | [
"def",
"_unpack_titles",
"(",
"etree",
":",
"ET",
".",
"ElementTree",
")",
"->",
"'Generator'",
":",
"for",
"anime",
"in",
"etree",
".",
"getroot",
"(",
")",
":",
"yield",
"Titles",
"(",
"aid",
"=",
"int",
"(",
"anime",
".",
"get",
"(",
"'aid'",
")",... | Unpack Titles from titles XML. | [
"Unpack",
"Titles",
"from",
"titles",
"XML",
"."
] | train | https://github.com/darkfeline/mir.anidb/blob/a0d25908f85fb1ff4bc595954bfc3f223f1b5acc/mir/anidb/titles.py#L163-L169 |
darkfeline/mir.anidb | mir/anidb/titles.py | CachedTitlesGetter.get | def get(self, force=False) -> 'List[Titles]':
"""Get list of Titles.
Pass force=True to bypass the cache.
"""
try:
if force:
raise CacheMissingError
return self._cache.load()
except CacheMissingError:
titles = self._requester()... | python | def get(self, force=False) -> 'List[Titles]':
"""Get list of Titles.
Pass force=True to bypass the cache.
"""
try:
if force:
raise CacheMissingError
return self._cache.load()
except CacheMissingError:
titles = self._requester()... | [
"def",
"get",
"(",
"self",
",",
"force",
"=",
"False",
")",
"->",
"'List[Titles]'",
":",
"try",
":",
"if",
"force",
":",
"raise",
"CacheMissingError",
"return",
"self",
".",
"_cache",
".",
"load",
"(",
")",
"except",
"CacheMissingError",
":",
"titles",
"... | Get list of Titles.
Pass force=True to bypass the cache. | [
"Get",
"list",
"of",
"Titles",
"."
] | train | https://github.com/darkfeline/mir.anidb/blob/a0d25908f85fb1ff4bc595954bfc3f223f1b5acc/mir/anidb/titles.py#L61-L73 |
pydsigner/taskit | taskit/frontend.py | FrontEnd._sending_task | def _sending_task(self, backend):
"""
Used internally to safely increment `backend`s task count. Returns the
overall count of tasks for `backend`.
"""
with self.backend_mutex:
self.backends[backend] += 1
self.task_counter[backend] += 1
this_ta... | python | def _sending_task(self, backend):
"""
Used internally to safely increment `backend`s task count. Returns the
overall count of tasks for `backend`.
"""
with self.backend_mutex:
self.backends[backend] += 1
self.task_counter[backend] += 1
this_ta... | [
"def",
"_sending_task",
"(",
"self",
",",
"backend",
")",
":",
"with",
"self",
".",
"backend_mutex",
":",
"self",
".",
"backends",
"[",
"backend",
"]",
"+=",
"1",
"self",
".",
"task_counter",
"[",
"backend",
"]",
"+=",
"1",
"this_task",
"=",
"self",
".... | Used internally to safely increment `backend`s task count. Returns the
overall count of tasks for `backend`. | [
"Used",
"internally",
"to",
"safely",
"increment",
"backend",
"s",
"task",
"count",
".",
"Returns",
"the",
"overall",
"count",
"of",
"tasks",
"for",
"backend",
"."
] | train | https://github.com/pydsigner/taskit/blob/3b228e2dbac16b3b84b2581f5b46e027d1d8fa7f/taskit/frontend.py#L73-L82 |
pydsigner/taskit | taskit/frontend.py | FrontEnd._canceling_task | def _canceling_task(self, backend):
"""
Used internally to decrement `backend`s current and total task counts
when `backend` could not be reached.
"""
with self.backend_mutex:
self.backends[backend] -= 1
self.task_counter[backend] -= 1 | python | def _canceling_task(self, backend):
"""
Used internally to decrement `backend`s current and total task counts
when `backend` could not be reached.
"""
with self.backend_mutex:
self.backends[backend] -= 1
self.task_counter[backend] -= 1 | [
"def",
"_canceling_task",
"(",
"self",
",",
"backend",
")",
":",
"with",
"self",
".",
"backend_mutex",
":",
"self",
".",
"backends",
"[",
"backend",
"]",
"-=",
"1",
"self",
".",
"task_counter",
"[",
"backend",
"]",
"-=",
"1"
] | Used internally to decrement `backend`s current and total task counts
when `backend` could not be reached. | [
"Used",
"internally",
"to",
"decrement",
"backend",
"s",
"current",
"and",
"total",
"task",
"counts",
"when",
"backend",
"could",
"not",
"be",
"reached",
"."
] | train | https://github.com/pydsigner/taskit/blob/3b228e2dbac16b3b84b2581f5b46e027d1d8fa7f/taskit/frontend.py#L84-L91 |
pydsigner/taskit | taskit/frontend.py | FrontEnd._expand_host | def _expand_host(self, host):
"""
Used internally to add the default port to hosts not including
portnames.
"""
if isinstance(host, basestring):
return (host, self.default_port)
return tuple(host) | python | def _expand_host(self, host):
"""
Used internally to add the default port to hosts not including
portnames.
"""
if isinstance(host, basestring):
return (host, self.default_port)
return tuple(host) | [
"def",
"_expand_host",
"(",
"self",
",",
"host",
")",
":",
"if",
"isinstance",
"(",
"host",
",",
"basestring",
")",
":",
"return",
"(",
"host",
",",
"self",
".",
"default_port",
")",
"return",
"tuple",
"(",
"host",
")"
] | Used internally to add the default port to hosts not including
portnames. | [
"Used",
"internally",
"to",
"add",
"the",
"default",
"port",
"to",
"hosts",
"not",
"including",
"portnames",
"."
] | train | https://github.com/pydsigner/taskit/blob/3b228e2dbac16b3b84b2581f5b46e027d1d8fa7f/taskit/frontend.py#L100-L107 |
pydsigner/taskit | taskit/frontend.py | FrontEnd._do_cb | def _do_cb(self, task, cb, error_cb, *args, **kw):
"""
Called internally by callback(). Does cb and error_cb selection.
"""
try:
res = self.work(task, *args, **kw)
except BackendProcessingError as e:
if error_cb is None:
self.log(ERROR, e._... | python | def _do_cb(self, task, cb, error_cb, *args, **kw):
"""
Called internally by callback(). Does cb and error_cb selection.
"""
try:
res = self.work(task, *args, **kw)
except BackendProcessingError as e:
if error_cb is None:
self.log(ERROR, e._... | [
"def",
"_do_cb",
"(",
"self",
",",
"task",
",",
"cb",
",",
"error_cb",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"try",
":",
"res",
"=",
"self",
".",
"work",
"(",
"task",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
"except",
"BackendPr... | Called internally by callback(). Does cb and error_cb selection. | [
"Called",
"internally",
"by",
"callback",
"()",
".",
"Does",
"cb",
"and",
"error_cb",
"selection",
"."
] | train | https://github.com/pydsigner/taskit/blob/3b228e2dbac16b3b84b2581f5b46e027d1d8fa7f/taskit/frontend.py#L115-L129 |
pydsigner/taskit | taskit/frontend.py | FrontEnd._package | def _package(self, task, *args, **kw):
"""
Used internally. Simply wraps the arguments up in a list and encodes
the list.
"""
# Implementation note: it is faster to use a tuple than a list here,
# because json does the list-like check like so (json/encoder.py:424):
... | python | def _package(self, task, *args, **kw):
"""
Used internally. Simply wraps the arguments up in a list and encodes
the list.
"""
# Implementation note: it is faster to use a tuple than a list here,
# because json does the list-like check like so (json/encoder.py:424):
... | [
"def",
"_package",
"(",
"self",
",",
"task",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"# Implementation note: it is faster to use a tuple than a list here, ",
"# because json does the list-like check like so (json/encoder.py:424):",
"# isinstance(o, (list, tuple))",
"# ... | Used internally. Simply wraps the arguments up in a list and encodes
the list. | [
"Used",
"internally",
".",
"Simply",
"wraps",
"the",
"arguments",
"up",
"in",
"a",
"list",
"and",
"encodes",
"the",
"list",
"."
] | train | https://github.com/pydsigner/taskit/blob/3b228e2dbac16b3b84b2581f5b46e027d1d8fa7f/taskit/frontend.py#L131-L150 |
pydsigner/taskit | taskit/frontend.py | FrontEnd._work | def _work(self, backend, package, ident='', log=True):
"""
Centralized task worker code. Used internally, see send_signal() and
work() for the external interfaces.
"""
num = self._sending_task(backend)
if log:
self.log(INFO, 'Starting %s backend task #%s (%s)... | python | def _work(self, backend, package, ident='', log=True):
"""
Centralized task worker code. Used internally, see send_signal() and
work() for the external interfaces.
"""
num = self._sending_task(backend)
if log:
self.log(INFO, 'Starting %s backend task #%s (%s)... | [
"def",
"_work",
"(",
"self",
",",
"backend",
",",
"package",
",",
"ident",
"=",
"''",
",",
"log",
"=",
"True",
")",
":",
"num",
"=",
"self",
".",
"_sending_task",
"(",
"backend",
")",
"if",
"log",
":",
"self",
".",
"log",
"(",
"INFO",
",",
"'Star... | Centralized task worker code. Used internally, see send_signal() and
work() for the external interfaces. | [
"Centralized",
"task",
"worker",
"code",
".",
"Used",
"internally",
"see",
"send_signal",
"()",
"and",
"work",
"()",
"for",
"the",
"external",
"interfaces",
"."
] | train | https://github.com/pydsigner/taskit/blob/3b228e2dbac16b3b84b2581f5b46e027d1d8fa7f/taskit/frontend.py#L152-L183 |
pydsigner/taskit | taskit/frontend.py | FrontEnd.send_signal | def send_signal(self, backend, signal):
"""
Sends the `signal` signal to `backend`. Raises ValueError if `backend`
is not registered with the client. Returns the result.
"""
backend = self._expand_host(backend)
if backend in self.backends:
try:
... | python | def send_signal(self, backend, signal):
"""
Sends the `signal` signal to `backend`. Raises ValueError if `backend`
is not registered with the client. Returns the result.
"""
backend = self._expand_host(backend)
if backend in self.backends:
try:
... | [
"def",
"send_signal",
"(",
"self",
",",
"backend",
",",
"signal",
")",
":",
"backend",
"=",
"self",
".",
"_expand_host",
"(",
"backend",
")",
"if",
"backend",
"in",
"self",
".",
"backends",
":",
"try",
":",
"return",
"self",
".",
"_work",
"(",
"backend... | Sends the `signal` signal to `backend`. Raises ValueError if `backend`
is not registered with the client. Returns the result. | [
"Sends",
"the",
"signal",
"signal",
"to",
"backend",
".",
"Raises",
"ValueError",
"if",
"backend",
"is",
"not",
"registered",
"with",
"the",
"client",
".",
"Returns",
"the",
"result",
"."
] | train | https://github.com/pydsigner/taskit/blob/3b228e2dbac16b3b84b2581f5b46e027d1d8fa7f/taskit/frontend.py#L185-L197 |
pydsigner/taskit | taskit/frontend.py | FrontEnd.get_tasks | def get_tasks(self, backend):
"""
Gets a string of the tasks running on `backend`. This string will
either be an integer if the backend is up, or else 'down'.Raises
ValueError if `backend` is not registered with the client.
Example:
>>> frontend = Fron... | python | def get_tasks(self, backend):
"""
Gets a string of the tasks running on `backend`. This string will
either be an integer if the backend is up, or else 'down'.Raises
ValueError if `backend` is not registered with the client.
Example:
>>> frontend = Fron... | [
"def",
"get_tasks",
"(",
"self",
",",
"backend",
")",
":",
"try",
":",
"res",
"=",
"self",
".",
"send_signal",
"(",
"backend",
",",
"STATUS",
")",
"except",
"BackendNotAvailableError",
":",
"res",
"=",
"'down'",
"return",
"res"
] | Gets a string of the tasks running on `backend`. This string will
either be an integer if the backend is up, or else 'down'.Raises
ValueError if `backend` is not registered with the client.
Example:
>>> frontend = FrontEnd(['localhost', '****'])
>>> frontend.g... | [
"Gets",
"a",
"string",
"of",
"the",
"tasks",
"running",
"on",
"backend",
".",
"This",
"string",
"will",
"either",
"be",
"an",
"integer",
"if",
"the",
"backend",
"is",
"up",
"or",
"else",
"down",
".",
"Raises",
"ValueError",
"if",
"backend",
"is",
"not",
... | train | https://github.com/pydsigner/taskit/blob/3b228e2dbac16b3b84b2581f5b46e027d1d8fa7f/taskit/frontend.py#L211-L233 |
pydsigner/taskit | taskit/frontend.py | FrontEnd.add_backends | def add_backends(self, *backends):
"""
See the documentation for __init__() to see an explanation of the
*backends argument.
"""
for backend in backends:
full = self._expand_host(backend)
self.backends[full] = 0
self.task_counter[full] = 0 | python | def add_backends(self, *backends):
"""
See the documentation for __init__() to see an explanation of the
*backends argument.
"""
for backend in backends:
full = self._expand_host(backend)
self.backends[full] = 0
self.task_counter[full] = 0 | [
"def",
"add_backends",
"(",
"self",
",",
"*",
"backends",
")",
":",
"for",
"backend",
"in",
"backends",
":",
"full",
"=",
"self",
".",
"_expand_host",
"(",
"backend",
")",
"self",
".",
"backends",
"[",
"full",
"]",
"=",
"0",
"self",
".",
"task_counter"... | See the documentation for __init__() to see an explanation of the
*backends argument. | [
"See",
"the",
"documentation",
"for",
"__init__",
"()",
"to",
"see",
"an",
"explanation",
"of",
"the",
"*",
"backends",
"argument",
"."
] | train | https://github.com/pydsigner/taskit/blob/3b228e2dbac16b3b84b2581f5b46e027d1d8fa7f/taskit/frontend.py#L235-L243 |
pydsigner/taskit | taskit/frontend.py | FrontEnd.work | def work(self, task, *args, **kw):
"""
Handles pushing out the task and getting the response. Can be called
directly to wait for the response.
task -- the server-side identifier for the desired task
*args and **kw will be passed to the task on the server-side.
... | python | def work(self, task, *args, **kw):
"""
Handles pushing out the task and getting the response. Can be called
directly to wait for the response.
task -- the server-side identifier for the desired task
*args and **kw will be passed to the task on the server-side.
... | [
"def",
"work",
"(",
"self",
",",
"task",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"package",
"=",
"self",
".",
"_package",
"(",
"task",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
"backends",
"=",
"sorted",
"(",
"self",
".",
"backends",... | Handles pushing out the task and getting the response. Can be called
directly to wait for the response.
task -- the server-side identifier for the desired task
*args and **kw will be passed to the task on the server-side.
Return value is generally the same as on the se... | [
"Handles",
"pushing",
"out",
"the",
"task",
"and",
"getting",
"the",
"response",
".",
"Can",
"be",
"called",
"directly",
"to",
"wait",
"for",
"the",
"response",
".",
"task",
"--",
"the",
"server",
"-",
"side",
"identifier",
"for",
"the",
"desired",
"task",... | train | https://github.com/pydsigner/taskit/blob/3b228e2dbac16b3b84b2581f5b46e027d1d8fa7f/taskit/frontend.py#L245-L281 |
pydsigner/taskit | taskit/frontend.py | FrontEnd.callback | def callback(self, task, cb, error_cb, *args, **kw):
"""
Threads the task, then runs a callback on success or an error callback
on fail.
cb -- The function to be called with a successful result.
error_cb -- The function to be called when an error occurs.
... | python | def callback(self, task, cb, error_cb, *args, **kw):
"""
Threads the task, then runs a callback on success or an error callback
on fail.
cb -- The function to be called with a successful result.
error_cb -- The function to be called when an error occurs.
... | [
"def",
"callback",
"(",
"self",
",",
"task",
",",
"cb",
",",
"error_cb",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"threaded",
"(",
"self",
".",
"_do_cb",
",",
"(",
"task",
",",
"cb",
",",
"error_cb",
")",
"+",
"args",
",",
"kw",
")"
] | Threads the task, then runs a callback on success or an error callback
on fail.
cb -- The function to be called with a successful result.
error_cb -- The function to be called when an error occurs.
For information on `task`, *args, and **kw, see work(). | [
"Threads",
"the",
"task",
"then",
"runs",
"a",
"callback",
"on",
"success",
"or",
"an",
"error",
"callback",
"on",
"fail",
".",
"cb",
"--",
"The",
"function",
"to",
"be",
"called",
"with",
"a",
"successful",
"result",
".",
"error_cb",
"--",
"The",
"funct... | train | https://github.com/pydsigner/taskit/blob/3b228e2dbac16b3b84b2581f5b46e027d1d8fa7f/taskit/frontend.py#L283-L293 |
pydsigner/taskit | taskit/frontend.py | FrontEnd.ignore | def ignore(self, task, *args, **kw):
"""
Thread it and forget it.
For information on the arguments to this method, see work().
"""
# We want to silence errors
self.callback(task, null_cb, False, *args, **kw) | python | def ignore(self, task, *args, **kw):
"""
Thread it and forget it.
For information on the arguments to this method, see work().
"""
# We want to silence errors
self.callback(task, null_cb, False, *args, **kw) | [
"def",
"ignore",
"(",
"self",
",",
"task",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"# We want to silence errors",
"self",
".",
"callback",
"(",
"task",
",",
"null_cb",
",",
"False",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")"
] | Thread it and forget it.
For information on the arguments to this method, see work(). | [
"Thread",
"it",
"and",
"forget",
"it",
".",
"For",
"information",
"on",
"the",
"arguments",
"to",
"this",
"method",
"see",
"work",
"()",
"."
] | train | https://github.com/pydsigner/taskit/blob/3b228e2dbac16b3b84b2581f5b46e027d1d8fa7f/taskit/frontend.py#L295-L302 |
minhhoit/yacms | yacms/pages/context_processors.py | page | def page(request):
"""
Adds the current page to the template context and runs its
``set_helper`` method. This was previously part of
``PageMiddleware``, but moved to a context processor so that
we could assign these template context variables without
the middleware depending on Django's ``Templa... | python | def page(request):
"""
Adds the current page to the template context and runs its
``set_helper`` method. This was previously part of
``PageMiddleware``, but moved to a context processor so that
we could assign these template context variables without
the middleware depending on Django's ``Templa... | [
"def",
"page",
"(",
"request",
")",
":",
"context",
"=",
"{",
"}",
"page",
"=",
"getattr",
"(",
"request",
",",
"\"page\"",
",",
"None",
")",
"if",
"isinstance",
"(",
"page",
",",
"Page",
")",
":",
"# set_helpers has always expected the current template contex... | Adds the current page to the template context and runs its
``set_helper`` method. This was previously part of
``PageMiddleware``, but moved to a context processor so that
we could assign these template context variables without
the middleware depending on Django's ``TemplateResponse``. | [
"Adds",
"the",
"current",
"page",
"to",
"the",
"template",
"context",
"and",
"runs",
"its",
"set_helper",
"method",
".",
"This",
"was",
"previously",
"part",
"of",
"PageMiddleware",
"but",
"moved",
"to",
"a",
"context",
"processor",
"so",
"that",
"we",
"coul... | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/pages/context_processors.py#L4-L20 |
20c/xbahn | xbahn/connection/zmq.py | config_from_url | def config_from_url(u, **kwargs):
"""
Returns dict containing zmq configuration arguments
parsed from xbahn url
Arguments:
- u (urlparse.urlparse result)
Returns:
dict:
- id (str): connection index key
- typ_str (str): string representation of zmq socket ... | python | def config_from_url(u, **kwargs):
"""
Returns dict containing zmq configuration arguments
parsed from xbahn url
Arguments:
- u (urlparse.urlparse result)
Returns:
dict:
- id (str): connection index key
- typ_str (str): string representation of zmq socket ... | [
"def",
"config_from_url",
"(",
"u",
",",
"*",
"*",
"kwargs",
")",
":",
"path",
"=",
"u",
".",
"path",
".",
"lstrip",
"(",
"\"/\"",
")",
".",
"split",
"(",
"\"/\"",
")",
"if",
"len",
"(",
"path",
")",
">",
"2",
"or",
"not",
"path",
":",
"raise",... | Returns dict containing zmq configuration arguments
parsed from xbahn url
Arguments:
- u (urlparse.urlparse result)
Returns:
dict:
- id (str): connection index key
- typ_str (str): string representation of zmq socket type
- typ (int): zmq socket type (... | [
"Returns",
"dict",
"containing",
"zmq",
"configuration",
"arguments",
"parsed",
"from",
"xbahn",
"url"
] | train | https://github.com/20c/xbahn/blob/afb27b0576841338a366d7cac0200a782bd84be6/xbahn/connection/zmq.py#L30-L77 |
KnowledgeLinks/rdfframework | rdfframework/utilities/statistics.py | DictionaryCounter._record_blank | def _record_blank(self, current, dict_obj):
"""
records the dictionay in the the 'blank' attribute based on the
'list_blank' path
args:
-----
current: the current dictionay counts
dict_obj: the original dictionary object
"""
if not self.li... | python | def _record_blank(self, current, dict_obj):
"""
records the dictionay in the the 'blank' attribute based on the
'list_blank' path
args:
-----
current: the current dictionay counts
dict_obj: the original dictionary object
"""
if not self.li... | [
"def",
"_record_blank",
"(",
"self",
",",
"current",
",",
"dict_obj",
")",
":",
"if",
"not",
"self",
".",
"list_blank",
":",
"return",
"if",
"self",
".",
"list_blank",
"not",
"in",
"current",
":",
"self",
".",
"blank",
".",
"append",
"(",
"dict_obj",
"... | records the dictionay in the the 'blank' attribute based on the
'list_blank' path
args:
-----
current: the current dictionay counts
dict_obj: the original dictionary object | [
"records",
"the",
"dictionay",
"in",
"the",
"the",
"blank",
"attribute",
"based",
"on",
"the",
"list_blank",
"path"
] | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/statistics.py#L54-L67 |
KnowledgeLinks/rdfframework | rdfframework/utilities/statistics.py | DictionaryCounter._count_objs | def _count_objs(self, obj, path=None, **kwargs):
"""
cycles through the object and adds in count values
Args:
-----
obj: the object to parse
path: the current path
kwargs:
-------
current: a dictionary of counts for current call
... | python | def _count_objs(self, obj, path=None, **kwargs):
"""
cycles through the object and adds in count values
Args:
-----
obj: the object to parse
path: the current path
kwargs:
-------
current: a dictionary of counts for current call
... | [
"def",
"_count_objs",
"(",
"self",
",",
"obj",
",",
"path",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"sub_val",
"=",
"None",
"# pdb.set_trace()",
"if",
"isinstance",
"(",
"obj",
",",
"dict",
")",
":",
"for",
"key",
",",
"value",
"in",
"obj",
... | cycles through the object and adds in count values
Args:
-----
obj: the object to parse
path: the current path
kwargs:
-------
current: a dictionary of counts for current call
sub_val: the value to use for subtotal aggregation | [
"cycles",
"through",
"the",
"object",
"and",
"adds",
"in",
"count",
"values"
] | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/statistics.py#L69-L115 |
KnowledgeLinks/rdfframework | rdfframework/utilities/statistics.py | DictionaryCounter._increment_prop | def _increment_prop(self, prop, path=None, **kwargs):
"""
increments the property path count
args:
-----
prop: the key for the prop
path: the path to the prop
kwargs:
-------
current: dictionary count for the current dictionay
... | python | def _increment_prop(self, prop, path=None, **kwargs):
"""
increments the property path count
args:
-----
prop: the key for the prop
path: the path to the prop
kwargs:
-------
current: dictionary count for the current dictionay
... | [
"def",
"_increment_prop",
"(",
"self",
",",
"prop",
",",
"path",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"new_path",
"=",
"self",
".",
"make_path",
"(",
"prop",
",",
"path",
")",
"if",
"self",
".",
"method",
"==",
"'simple'",
":",
"counter",
... | increments the property path count
args:
-----
prop: the key for the prop
path: the path to the prop
kwargs:
-------
current: dictionary count for the current dictionay | [
"increments",
"the",
"property",
"path",
"count"
] | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/statistics.py#L120-L142 |
KnowledgeLinks/rdfframework | rdfframework/utilities/statistics.py | DictionaryCounter.update_counts | def update_counts(self, current):
"""
updates counts for the class instance based on the current dictionary
counts
args:
-----
current: current dictionary counts
"""
for item in current:
try:
self.counts[item] += 1
... | python | def update_counts(self, current):
"""
updates counts for the class instance based on the current dictionary
counts
args:
-----
current: current dictionary counts
"""
for item in current:
try:
self.counts[item] += 1
... | [
"def",
"update_counts",
"(",
"self",
",",
"current",
")",
":",
"for",
"item",
"in",
"current",
":",
"try",
":",
"self",
".",
"counts",
"[",
"item",
"]",
"+=",
"1",
"except",
"KeyError",
":",
"self",
".",
"counts",
"[",
"item",
"]",
"=",
"1"
] | updates counts for the class instance based on the current dictionary
counts
args:
-----
current: current dictionary counts | [
"updates",
"counts",
"for",
"the",
"class",
"instance",
"based",
"on",
"the",
"current",
"dictionary",
"counts"
] | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/statistics.py#L144-L157 |
KnowledgeLinks/rdfframework | rdfframework/utilities/statistics.py | DictionaryCounter.update_subtotals | def update_subtotals(self, current, sub_key):
"""
updates sub_total counts for the class instance based on the
current dictionary counts
args:
-----
current: current dictionary counts
sub_key: the key/value to use for the subtotals
"""
... | python | def update_subtotals(self, current, sub_key):
"""
updates sub_total counts for the class instance based on the
current dictionary counts
args:
-----
current: current dictionary counts
sub_key: the key/value to use for the subtotals
"""
... | [
"def",
"update_subtotals",
"(",
"self",
",",
"current",
",",
"sub_key",
")",
":",
"if",
"not",
"self",
".",
"sub_counts",
".",
"get",
"(",
"sub_key",
")",
":",
"self",
".",
"sub_counts",
"[",
"sub_key",
"]",
"=",
"{",
"}",
"for",
"item",
"in",
"curre... | updates sub_total counts for the class instance based on the
current dictionary counts
args:
-----
current: current dictionary counts
sub_key: the key/value to use for the subtotals | [
"updates",
"sub_total",
"counts",
"for",
"the",
"class",
"instance",
"based",
"on",
"the",
"current",
"dictionary",
"counts"
] | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/statistics.py#L159-L176 |
KnowledgeLinks/rdfframework | rdfframework/utilities/statistics.py | DictionaryCounter.print | def print(self):
"""
prints to terminal the summray statistics
"""
print("TOTALS -------------------------------------------")
print(json.dumps(self.counts, indent=4, sort_keys=True))
if self.sub_total:
print("\nSUB TOTALS --- based on '%s' ---------" % self.s... | python | def print(self):
"""
prints to terminal the summray statistics
"""
print("TOTALS -------------------------------------------")
print(json.dumps(self.counts, indent=4, sort_keys=True))
if self.sub_total:
print("\nSUB TOTALS --- based on '%s' ---------" % self.s... | [
"def",
"print",
"(",
"self",
")",
":",
"print",
"(",
"\"TOTALS -------------------------------------------\"",
")",
"print",
"(",
"json",
".",
"dumps",
"(",
"self",
".",
"counts",
",",
"indent",
"=",
"4",
",",
"sort_keys",
"=",
"True",
")",
")",
"if",
"sel... | prints to terminal the summray statistics | [
"prints",
"to",
"terminal",
"the",
"summray",
"statistics"
] | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/statistics.py#L178-L189 |
daknuett/py_register_machine2 | tools/assembler/assembler.py | Assembler.split_run | def split_run(self):
"""
.. _split_run:
Splits the assembly code into
* commands
* directives
* jump marks
"""
sp_run = []
for line in self.open_stream.read().split("\n"):
self.line_count += 1
if(self.iscomment(line)):
continue
if(line.isspace()):
continue
line = self.stripcomme... | python | def split_run(self):
"""
.. _split_run:
Splits the assembly code into
* commands
* directives
* jump marks
"""
sp_run = []
for line in self.open_stream.read().split("\n"):
self.line_count += 1
if(self.iscomment(line)):
continue
if(line.isspace()):
continue
line = self.stripcomme... | [
"def",
"split_run",
"(",
"self",
")",
":",
"sp_run",
"=",
"[",
"]",
"for",
"line",
"in",
"self",
".",
"open_stream",
".",
"read",
"(",
")",
".",
"split",
"(",
"\"\\n\"",
")",
":",
"self",
".",
"line_count",
"+=",
"1",
"if",
"(",
"self",
".",
"isc... | .. _split_run:
Splits the assembly code into
* commands
* directives
* jump marks | [
"..",
"_split_run",
":"
] | train | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/tools/assembler/assembler.py#L67-L114 |
daknuett/py_register_machine2 | tools/assembler/assembler.py | Assembler.add_ref | def add_ref(self, wordlist):
"""
Adds a reference.
"""
refname = wordlist[0][:-1]
if(refname in self.refs):
raise ReferenceError("[line {}]:{} already defined here (word) {} (line) {}".format(self.line_count,
refname, self.refs[refname][0], self.refs[refname][1]))
self.refs[refname] = (self.word_... | python | def add_ref(self, wordlist):
"""
Adds a reference.
"""
refname = wordlist[0][:-1]
if(refname in self.refs):
raise ReferenceError("[line {}]:{} already defined here (word) {} (line) {}".format(self.line_count,
refname, self.refs[refname][0], self.refs[refname][1]))
self.refs[refname] = (self.word_... | [
"def",
"add_ref",
"(",
"self",
",",
"wordlist",
")",
":",
"refname",
"=",
"wordlist",
"[",
"0",
"]",
"[",
":",
"-",
"1",
"]",
"if",
"(",
"refname",
"in",
"self",
".",
"refs",
")",
":",
"raise",
"ReferenceError",
"(",
"\"[line {}]:{} already defined here ... | Adds a reference. | [
"Adds",
"a",
"reference",
"."
] | train | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/tools/assembler/assembler.py#L117-L126 |
daknuett/py_register_machine2 | tools/assembler/assembler.py | Assembler.handle_directive | def handle_directive(self, words):
"""
handles directives: adds the reference and allocates space for the content
"""
refname = words[1]
logging.debug("Handling directive " + str(self.getdirective(words[0])))
logging.debug("First argument is " + str(words[1]))
if(self.getdirective(words[0]).isstatic()):... | python | def handle_directive(self, words):
"""
handles directives: adds the reference and allocates space for the content
"""
refname = words[1]
logging.debug("Handling directive " + str(self.getdirective(words[0])))
logging.debug("First argument is " + str(words[1]))
if(self.getdirective(words[0]).isstatic()):... | [
"def",
"handle_directive",
"(",
"self",
",",
"words",
")",
":",
"refname",
"=",
"words",
"[",
"1",
"]",
"logging",
".",
"debug",
"(",
"\"Handling directive \"",
"+",
"str",
"(",
"self",
".",
"getdirective",
"(",
"words",
"[",
"0",
"]",
")",
")",
")",
... | handles directives: adds the reference and allocates space for the content | [
"handles",
"directives",
":",
"adds",
"the",
"reference",
"and",
"allocates",
"space",
"for",
"the",
"content"
] | train | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/tools/assembler/assembler.py#L129-L150 |
daknuett/py_register_machine2 | tools/assembler/assembler.py | Assembler.argument_run | def argument_run(self, sp_r):
"""
.. _argument_run:
Converts Arguments according to ``to_int``
"""
arg_run = []
for line in sp_r:
logging.debug("argument run: handling: " + str(line))
if(line[1] == "data"):
arg_run.append( (line[0], line[1], line[2], line[2].get_words(line[3])))
continue
... | python | def argument_run(self, sp_r):
"""
.. _argument_run:
Converts Arguments according to ``to_int``
"""
arg_run = []
for line in sp_r:
logging.debug("argument run: handling: " + str(line))
if(line[1] == "data"):
arg_run.append( (line[0], line[1], line[2], line[2].get_words(line[3])))
continue
... | [
"def",
"argument_run",
"(",
"self",
",",
"sp_r",
")",
":",
"arg_run",
"=",
"[",
"]",
"for",
"line",
"in",
"sp_r",
":",
"logging",
".",
"debug",
"(",
"\"argument run: handling: \"",
"+",
"str",
"(",
"line",
")",
")",
"if",
"(",
"line",
"[",
"1",
"]",
... | .. _argument_run:
Converts Arguments according to ``to_int`` | [
"..",
"_argument_run",
":"
] | train | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/tools/assembler/assembler.py#L162-L178 |
daknuett/py_register_machine2 | tools/assembler/assembler.py | Assembler.checkargs | def checkargs(self, lineno, command, args):
"""
Check if the arguments fit the requirements of the command.
Raises ArgumentError_, if an argument does not fit.
"""
for wanted, arg in zip(command.argtypes(), args):
wanted = wanted.type_
if(wanted == "register" and (not arg in self.register)):
raise ... | python | def checkargs(self, lineno, command, args):
"""
Check if the arguments fit the requirements of the command.
Raises ArgumentError_, if an argument does not fit.
"""
for wanted, arg in zip(command.argtypes(), args):
wanted = wanted.type_
if(wanted == "register" and (not arg in self.register)):
raise ... | [
"def",
"checkargs",
"(",
"self",
",",
"lineno",
",",
"command",
",",
"args",
")",
":",
"for",
"wanted",
",",
"arg",
"in",
"zip",
"(",
"command",
".",
"argtypes",
"(",
")",
",",
"args",
")",
":",
"wanted",
"=",
"wanted",
".",
"type_",
"if",
"(",
"... | Check if the arguments fit the requirements of the command.
Raises ArgumentError_, if an argument does not fit. | [
"Check",
"if",
"the",
"arguments",
"fit",
"the",
"requirements",
"of",
"the",
"command",
"."
] | train | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/tools/assembler/assembler.py#L181-L192 |
daknuett/py_register_machine2 | tools/assembler/assembler.py | Assembler.convert_args | def convert_args(self, command, args):
"""
Converts ``str -> int`` or ``register -> int``.
"""
for wanted, arg in zip(command.argtypes(), args):
wanted = wanted.type_
if(wanted == "const"):
try:
yield to_int(arg)
except:
if(arg in self.processor.constants):
yield self.processor.co... | python | def convert_args(self, command, args):
"""
Converts ``str -> int`` or ``register -> int``.
"""
for wanted, arg in zip(command.argtypes(), args):
wanted = wanted.type_
if(wanted == "const"):
try:
yield to_int(arg)
except:
if(arg in self.processor.constants):
yield self.processor.co... | [
"def",
"convert_args",
"(",
"self",
",",
"command",
",",
"args",
")",
":",
"for",
"wanted",
",",
"arg",
"in",
"zip",
"(",
"command",
".",
"argtypes",
"(",
")",
",",
"args",
")",
":",
"wanted",
"=",
"wanted",
".",
"type_",
"if",
"(",
"wanted",
"==",... | Converts ``str -> int`` or ``register -> int``. | [
"Converts",
"str",
"-",
">",
"int",
"or",
"register",
"-",
">",
"int",
"."
] | train | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/tools/assembler/assembler.py#L194-L210 |
daknuett/py_register_machine2 | tools/assembler/assembler.py | Assembler.dereference_run | def dereference_run(self, arg_r):
"""
.. _dereference_run:
Converts the commands to opcodes and inserts the (relative or static) references.
"""
wc = 0
der_run = []
for line in arg_r:
args = []
for argument in line[3]:
logging.debug("dereference run: handling argument " + str(argument))
... | python | def dereference_run(self, arg_r):
"""
.. _dereference_run:
Converts the commands to opcodes and inserts the (relative or static) references.
"""
wc = 0
der_run = []
for line in arg_r:
args = []
for argument in line[3]:
logging.debug("dereference run: handling argument " + str(argument))
... | [
"def",
"dereference_run",
"(",
"self",
",",
"arg_r",
")",
":",
"wc",
"=",
"0",
"der_run",
"=",
"[",
"]",
"for",
"line",
"in",
"arg_r",
":",
"args",
"=",
"[",
"]",
"for",
"argument",
"in",
"line",
"[",
"3",
"]",
":",
"logging",
".",
"debug",
"(",
... | .. _dereference_run:
Converts the commands to opcodes and inserts the (relative or static) references. | [
"..",
"_dereference_run",
":"
] | train | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/tools/assembler/assembler.py#L212-L246 |
daknuett/py_register_machine2 | tools/assembler/assembler.py | Assembler.program_run | def program_run(self, der_r):
"""
.. _program_run:
Generates an iterable that can be programmed onto the register machine.
"""
program = []
for line in der_r:
program.extend(line[2])
return program | python | def program_run(self, der_r):
"""
.. _program_run:
Generates an iterable that can be programmed onto the register machine.
"""
program = []
for line in der_r:
program.extend(line[2])
return program | [
"def",
"program_run",
"(",
"self",
",",
"der_r",
")",
":",
"program",
"=",
"[",
"]",
"for",
"line",
"in",
"der_r",
":",
"program",
".",
"extend",
"(",
"line",
"[",
"2",
"]",
")",
"return",
"program"
] | .. _program_run:
Generates an iterable that can be programmed onto the register machine. | [
"..",
"_program_run",
":"
] | train | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/tools/assembler/assembler.py#L250-L260 |
daknuett/py_register_machine2 | tools/assembler/assembler.py | Assembler.assemble | def assemble(self):
"""
.. _assembler:
Chains split_run_, argument_run_, dereference_run_ and program_run_.
"""
sp_r = self.split_run()
ar_r = self.argument_run(sp_r)
de_r = self.dereference_run(ar_r)
program = self.program_run(de_r)
return program | python | def assemble(self):
"""
.. _assembler:
Chains split_run_, argument_run_, dereference_run_ and program_run_.
"""
sp_r = self.split_run()
ar_r = self.argument_run(sp_r)
de_r = self.dereference_run(ar_r)
program = self.program_run(de_r)
return program | [
"def",
"assemble",
"(",
"self",
")",
":",
"sp_r",
"=",
"self",
".",
"split_run",
"(",
")",
"ar_r",
"=",
"self",
".",
"argument_run",
"(",
"sp_r",
")",
"de_r",
"=",
"self",
".",
"dereference_run",
"(",
"ar_r",
")",
"program",
"=",
"self",
".",
"progra... | .. _assembler:
Chains split_run_, argument_run_, dereference_run_ and program_run_. | [
"..",
"_assembler",
":"
] | train | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/tools/assembler/assembler.py#L261-L272 |
minhhoit/yacms | yacms/utils/models.py | base_concrete_model | def base_concrete_model(abstract, model):
"""
Used in methods of abstract models to find the super-most concrete
(non abstract) model in the inheritance chain that inherits from the
given abstract model. This is so the methods in the abstract model can
query data consistently across the correct conc... | python | def base_concrete_model(abstract, model):
"""
Used in methods of abstract models to find the super-most concrete
(non abstract) model in the inheritance chain that inherits from the
given abstract model. This is so the methods in the abstract model can
query data consistently across the correct conc... | [
"def",
"base_concrete_model",
"(",
"abstract",
",",
"model",
")",
":",
"if",
"hasattr",
"(",
"model",
",",
"'objects'",
")",
":",
"# \"model\" is a model class",
"return",
"(",
"model",
"if",
"model",
".",
"_meta",
".",
"abstract",
"else",
"_base_concrete_model"... | Used in methods of abstract models to find the super-most concrete
(non abstract) model in the inheritance chain that inherits from the
given abstract model. This is so the methods in the abstract model can
query data consistently across the correct concrete model.
Consider the following::
cla... | [
"Used",
"in",
"methods",
"of",
"abstract",
"models",
"to",
"find",
"the",
"super",
"-",
"most",
"concrete",
"(",
"non",
"abstract",
")",
"model",
"in",
"the",
"inheritance",
"chain",
"that",
"inherits",
"from",
"the",
"given",
"abstract",
"model",
".",
"Th... | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/utils/models.py#L38-L78 |
minhhoit/yacms | yacms/utils/models.py | upload_to | def upload_to(field_path, default):
"""
Used as the ``upload_to`` arg for file fields - allows for custom
handlers to be implemented on a per field basis defined by the
``UPLOAD_TO_HANDLERS`` setting.
"""
from yacms.conf import settings
for k, v in settings.UPLOAD_TO_HANDLERS.items():
... | python | def upload_to(field_path, default):
"""
Used as the ``upload_to`` arg for file fields - allows for custom
handlers to be implemented on a per field basis defined by the
``UPLOAD_TO_HANDLERS`` setting.
"""
from yacms.conf import settings
for k, v in settings.UPLOAD_TO_HANDLERS.items():
... | [
"def",
"upload_to",
"(",
"field_path",
",",
"default",
")",
":",
"from",
"yacms",
".",
"conf",
"import",
"settings",
"for",
"k",
",",
"v",
"in",
"settings",
".",
"UPLOAD_TO_HANDLERS",
".",
"items",
"(",
")",
":",
"if",
"k",
".",
"lower",
"(",
")",
"=... | Used as the ``upload_to`` arg for file fields - allows for custom
handlers to be implemented on a per field basis defined by the
``UPLOAD_TO_HANDLERS`` setting. | [
"Used",
"as",
"the",
"upload_to",
"arg",
"for",
"file",
"fields",
"-",
"allows",
"for",
"custom",
"handlers",
"to",
"be",
"implemented",
"on",
"a",
"per",
"field",
"basis",
"defined",
"by",
"the",
"UPLOAD_TO_HANDLERS",
"setting",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/utils/models.py#L81-L91 |
daknuett/py_register_machine2 | core/register.py | OutputRegister.write | def write(self, word):
"""
.. _SOwrite:
Write the ``chr`` representation of ``word`` to the ``open_stream``.
If ``chr(word)`` fails due ``OverflowError``, a ``"?"`` will be written.
"""
self.repr_.setvalue(word)
try:
self.open_stream.write(chr(self.repr_.getvalue()))
except OverflowError:
sel... | python | def write(self, word):
"""
.. _SOwrite:
Write the ``chr`` representation of ``word`` to the ``open_stream``.
If ``chr(word)`` fails due ``OverflowError``, a ``"?"`` will be written.
"""
self.repr_.setvalue(word)
try:
self.open_stream.write(chr(self.repr_.getvalue()))
except OverflowError:
sel... | [
"def",
"write",
"(",
"self",
",",
"word",
")",
":",
"self",
".",
"repr_",
".",
"setvalue",
"(",
"word",
")",
"try",
":",
"self",
".",
"open_stream",
".",
"write",
"(",
"chr",
"(",
"self",
".",
"repr_",
".",
"getvalue",
"(",
")",
")",
")",
"except... | .. _SOwrite:
Write the ``chr`` representation of ``word`` to the ``open_stream``.
If ``chr(word)`` fails due ``OverflowError``, a ``"?"`` will be written. | [
"..",
"_SOwrite",
":"
] | train | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/core/register.py#L39-L51 |
daknuett/py_register_machine2 | core/register.py | StreamIORegister.read | def read(self):
"""
Read a ``str`` from ``open_stream_in`` and convert it to an integer
using ``ord``. The result will be truncated according to Integer_.
"""
self.repr_.setvalue(ord(self.open_stream_in.read(1)))
return self.value.getvalue() | python | def read(self):
"""
Read a ``str`` from ``open_stream_in`` and convert it to an integer
using ``ord``. The result will be truncated according to Integer_.
"""
self.repr_.setvalue(ord(self.open_stream_in.read(1)))
return self.value.getvalue() | [
"def",
"read",
"(",
"self",
")",
":",
"self",
".",
"repr_",
".",
"setvalue",
"(",
"ord",
"(",
"self",
".",
"open_stream_in",
".",
"read",
"(",
"1",
")",
")",
")",
"return",
"self",
".",
"value",
".",
"getvalue",
"(",
")"
] | Read a ``str`` from ``open_stream_in`` and convert it to an integer
using ``ord``. The result will be truncated according to Integer_. | [
"Read",
"a",
"str",
"from",
"open_stream_in",
"and",
"convert",
"it",
"to",
"an",
"integer",
"using",
"ord",
".",
"The",
"result",
"will",
"be",
"truncated",
"according",
"to",
"Integer_",
"."
] | train | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/core/register.py#L67-L73 |
daknuett/py_register_machine2 | core/register.py | BStreamIORegister.read | def read(self):
"""
Reads enough bytes from ``open_stream_in`` to fill the ``width``
(if available) and converts them to an ``int``. Returns this ``int``.
"""
int_ = bytes_to_int(self.open_stream_in.read(math.ceil(self.width / 8)), self.width)
self.repr_.setvalue(int_)
return self.value.getvalue() | python | def read(self):
"""
Reads enough bytes from ``open_stream_in`` to fill the ``width``
(if available) and converts them to an ``int``. Returns this ``int``.
"""
int_ = bytes_to_int(self.open_stream_in.read(math.ceil(self.width / 8)), self.width)
self.repr_.setvalue(int_)
return self.value.getvalue() | [
"def",
"read",
"(",
"self",
")",
":",
"int_",
"=",
"bytes_to_int",
"(",
"self",
".",
"open_stream_in",
".",
"read",
"(",
"math",
".",
"ceil",
"(",
"self",
".",
"width",
"/",
"8",
")",
")",
",",
"self",
".",
"width",
")",
"self",
".",
"repr_",
"."... | Reads enough bytes from ``open_stream_in`` to fill the ``width``
(if available) and converts them to an ``int``. Returns this ``int``. | [
"Reads",
"enough",
"bytes",
"from",
"open_stream_in",
"to",
"fill",
"the",
"width",
"(",
"if",
"available",
")",
"and",
"converts",
"them",
"to",
"an",
"int",
".",
"Returns",
"this",
"int",
"."
] | train | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/core/register.py#L100-L107 |
daknuett/py_register_machine2 | core/register.py | BStreamIORegister.write | def write(self, word):
"""
Converts the ``int`` ``word`` to a ``bytes`` object and writes them to
``open_stream_out``.
See ``int_to_bytes``.
"""
bytes_ = int_to_bytes(word, self.width)
self.open_stream_out.write(bytes_) | python | def write(self, word):
"""
Converts the ``int`` ``word`` to a ``bytes`` object and writes them to
``open_stream_out``.
See ``int_to_bytes``.
"""
bytes_ = int_to_bytes(word, self.width)
self.open_stream_out.write(bytes_) | [
"def",
"write",
"(",
"self",
",",
"word",
")",
":",
"bytes_",
"=",
"int_to_bytes",
"(",
"word",
",",
"self",
".",
"width",
")",
"self",
".",
"open_stream_out",
".",
"write",
"(",
"bytes_",
")"
] | Converts the ``int`` ``word`` to a ``bytes`` object and writes them to
``open_stream_out``.
See ``int_to_bytes``. | [
"Converts",
"the",
"int",
"word",
"to",
"a",
"bytes",
"object",
"and",
"writes",
"them",
"to",
"open_stream_out",
"."
] | train | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/core/register.py#L109-L117 |
jmatt/threepio | threepio/__init__.py | initialize | def initialize(logger_name=LOGGER_NAME,
log_filename=LOG_FILENAME,
app_logging_level=APP_LOGGING_LEVEL,
dep_logging_level=DEP_LOGGING_LEVEL,
format=None,
logger_class=None,
handlers=[],
global_logger=True):
"""
... | python | def initialize(logger_name=LOGGER_NAME,
log_filename=LOG_FILENAME,
app_logging_level=APP_LOGGING_LEVEL,
dep_logging_level=DEP_LOGGING_LEVEL,
format=None,
logger_class=None,
handlers=[],
global_logger=True):
"""
... | [
"def",
"initialize",
"(",
"logger_name",
"=",
"LOGGER_NAME",
",",
"log_filename",
"=",
"LOG_FILENAME",
",",
"app_logging_level",
"=",
"APP_LOGGING_LEVEL",
",",
"dep_logging_level",
"=",
"DEP_LOGGING_LEVEL",
",",
"format",
"=",
"None",
",",
"logger_class",
"=",
"None... | Constructs and initializes a `logging.Logger` object.
Returns :class:`logging.Logger` object.
:param logger_name: name of the new logger.
:param log_filename: The log file location :class:`str` or None.
:param app_logging_level: The logging level to use for the application.
:param dep_logging_leve... | [
"Constructs",
"and",
"initializes",
"a",
"logging",
".",
"Logger",
"object",
"."
] | train | https://github.com/jmatt/threepio/blob/91e2835c85c1618fcc4a1357dbb398353e662d1a/threepio/__init__.py#L32-L93 |
20tab/twentytab-tree | tree/utility.py | getUrlList | def getUrlList():
"""
This function get the Page List from the DB and return the tuple to
use in the urls.py, urlpatterns
"""
"""
IF YOU WANT REBUILD YOUR STRUCTURE UNCOMMENT THE FOLLOWING LINE
"""
#Node.rebuild()
set_to_return = []
set_url = []
roots = Node.objects.filter(... | python | def getUrlList():
"""
This function get the Page List from the DB and return the tuple to
use in the urls.py, urlpatterns
"""
"""
IF YOU WANT REBUILD YOUR STRUCTURE UNCOMMENT THE FOLLOWING LINE
"""
#Node.rebuild()
set_to_return = []
set_url = []
roots = Node.objects.filter(... | [
"def",
"getUrlList",
"(",
")",
":",
"\"\"\"\n IF YOU WANT REBUILD YOUR STRUCTURE UNCOMMENT THE FOLLOWING LINE\n \"\"\"",
"#Node.rebuild()",
"set_to_return",
"=",
"[",
"]",
"set_url",
"=",
"[",
"]",
"roots",
"=",
"Node",
".",
"objects",
".",
"filter",
"(",
"parent_... | This function get the Page List from the DB and return the tuple to
use in the urls.py, urlpatterns | [
"This",
"function",
"get",
"the",
"Page",
"List",
"from",
"the",
"DB",
"and",
"return",
"the",
"tuple",
"to",
"use",
"in",
"the",
"urls",
".",
"py",
"urlpatterns"
] | train | https://github.com/20tab/twentytab-tree/blob/f2c1ced33e6c211bb52a25a7d48155e39fbdc088/tree/utility.py#L9-L45 |
sternoru/goscalecms | goscale/utils/__init__.py | get_plugins | def get_plugins(sites=None):
"""
Returns all GoScale plugins
It ignored all other django-cms plugins
"""
plugins = []
# collect GoScale plugins
for plugin in CMSPlugin.objects.all():
if plugin:
cl = plugin.get_plugin_class().model
if 'posts' in cl._meta.get_a... | python | def get_plugins(sites=None):
"""
Returns all GoScale plugins
It ignored all other django-cms plugins
"""
plugins = []
# collect GoScale plugins
for plugin in CMSPlugin.objects.all():
if plugin:
cl = plugin.get_plugin_class().model
if 'posts' in cl._meta.get_a... | [
"def",
"get_plugins",
"(",
"sites",
"=",
"None",
")",
":",
"plugins",
"=",
"[",
"]",
"# collect GoScale plugins",
"for",
"plugin",
"in",
"CMSPlugin",
".",
"objects",
".",
"all",
"(",
")",
":",
"if",
"plugin",
":",
"cl",
"=",
"plugin",
".",
"get_plugin_cl... | Returns all GoScale plugins
It ignored all other django-cms plugins | [
"Returns",
"all",
"GoScale",
"plugins"
] | train | https://github.com/sternoru/goscalecms/blob/7eee50357c47ebdfe3e573a8b4be3b67892d229e/goscale/utils/__init__.py#L30-L54 |
sternoru/goscalecms | goscale/utils/__init__.py | update_plugin | def update_plugin(plugin_id):
"""
Updates a single plugin by ID
Returns a plugin instance and posts count
"""
try:
instance = CMSPlugin.objects.get(id=plugin_id).get_plugin_instance()[0]
instance.update()
except:
return None, 0
return instance, instance.posts.count() | python | def update_plugin(plugin_id):
"""
Updates a single plugin by ID
Returns a plugin instance and posts count
"""
try:
instance = CMSPlugin.objects.get(id=plugin_id).get_plugin_instance()[0]
instance.update()
except:
return None, 0
return instance, instance.posts.count() | [
"def",
"update_plugin",
"(",
"plugin_id",
")",
":",
"try",
":",
"instance",
"=",
"CMSPlugin",
".",
"objects",
".",
"get",
"(",
"id",
"=",
"plugin_id",
")",
".",
"get_plugin_instance",
"(",
")",
"[",
"0",
"]",
"instance",
".",
"update",
"(",
")",
"excep... | Updates a single plugin by ID
Returns a plugin instance and posts count | [
"Updates",
"a",
"single",
"plugin",
"by",
"ID"
] | train | https://github.com/sternoru/goscalecms/blob/7eee50357c47ebdfe3e573a8b4be3b67892d229e/goscale/utils/__init__.py#L56-L67 |
sternoru/goscalecms | goscale/utils/__init__.py | dict2obj | def dict2obj(d):
"""A helper function which convert a dict to an object.
"""
if isinstance(d, (list, tuple)):
d = [dict2obj(x) for x in d]
if not isinstance(d, dict):
return d
class ObjectFromDict(object):
pass
o = ObjectFromDict() #an object created from a dict
for k... | python | def dict2obj(d):
"""A helper function which convert a dict to an object.
"""
if isinstance(d, (list, tuple)):
d = [dict2obj(x) for x in d]
if not isinstance(d, dict):
return d
class ObjectFromDict(object):
pass
o = ObjectFromDict() #an object created from a dict
for k... | [
"def",
"dict2obj",
"(",
"d",
")",
":",
"if",
"isinstance",
"(",
"d",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"d",
"=",
"[",
"dict2obj",
"(",
"x",
")",
"for",
"x",
"in",
"d",
"]",
"if",
"not",
"isinstance",
"(",
"d",
",",
"dict",
")",
... | A helper function which convert a dict to an object. | [
"A",
"helper",
"function",
"which",
"convert",
"a",
"dict",
"to",
"an",
"object",
"."
] | train | https://github.com/sternoru/goscalecms/blob/7eee50357c47ebdfe3e573a8b4be3b67892d229e/goscale/utils/__init__.py#L601-L613 |
qzmfranklin/easyshell | easyshell/example_shell.py | MyShell.do_show | def do_show(self, cmd, args):
"""\
Display content of a file.
cat Display current working directory.
cat <file> Display content of a file.
"""
if not args:
self.stdout.write(os.getcwd())
self.stdout.write('\n')
... | python | def do_show(self, cmd, args):
"""\
Display content of a file.
cat Display current working directory.
cat <file> Display content of a file.
"""
if not args:
self.stdout.write(os.getcwd())
self.stdout.write('\n')
... | [
"def",
"do_show",
"(",
"self",
",",
"cmd",
",",
"args",
")",
":",
"if",
"not",
"args",
":",
"self",
".",
"stdout",
".",
"write",
"(",
"os",
".",
"getcwd",
"(",
")",
")",
"self",
".",
"stdout",
".",
"write",
"(",
"'\\n'",
")",
"return",
"fname",
... | \
Display content of a file.
cat Display current working directory.
cat <file> Display content of a file. | [
"\\",
"Display",
"content",
"of",
"a",
"file",
".",
"cat",
"Display",
"current",
"working",
"directory",
".",
"cat",
"<file",
">",
"Display",
"content",
"of",
"a",
"file",
"."
] | train | https://github.com/qzmfranklin/easyshell/blob/00c2e90e7767d32e7e127fc8c6875845aa308295/easyshell/example_shell.py#L129-L142 |
jmgilman/Neolib | neolib/http/browser/BrowserCookies.py | BrowserCookies.loadBrowsers | def loadBrowsers():
""" Loads all installed and supported browsers into BrowserCookies.browsers
Loops through all classes that subclass BrowserCookies and checks the installed
attribute. If the browser is installed, it's instance is loaded into
BrowserCookies.browsers in the for... | python | def loadBrowsers():
""" Loads all installed and supported browsers into BrowserCookies.browsers
Loops through all classes that subclass BrowserCookies and checks the installed
attribute. If the browser is installed, it's instance is loaded into
BrowserCookies.browsers in the for... | [
"def",
"loadBrowsers",
"(",
")",
":",
"for",
"browser",
"in",
"BrowserCookies",
".",
"__subclasses__",
"(",
")",
":",
"if",
"browser",
".",
"installed",
":",
"BrowserCookies",
".",
"browsers",
"[",
"browser",
".",
"name",
"]",
"=",
"browser"
] | Loads all installed and supported browsers into BrowserCookies.browsers
Loops through all classes that subclass BrowserCookies and checks the installed
attribute. If the browser is installed, it's instance is loaded into
BrowserCookies.browsers in the format of browsers[browser.name] = ... | [
"Loads",
"all",
"installed",
"and",
"supported",
"browsers",
"into",
"BrowserCookies",
".",
"browsers",
"Loops",
"through",
"all",
"classes",
"that",
"subclass",
"BrowserCookies",
"and",
"checks",
"the",
"installed",
"attribute",
".",
"If",
"the",
"browser",
"is",... | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/http/browser/BrowserCookies.py#L35-L44 |
jmgilman/Neolib | neolib/http/browser/BrowserCookies.py | BrowserCookies.setCookies | def setCookies(browser, domain, cookieJar):
""" Writes all given cookies to the given browser
Returns:
bool - True if successful, false otherwise
"""
return BrowserCookies.browsers[browser].writeCookies(domain, cookieJar) | python | def setCookies(browser, domain, cookieJar):
""" Writes all given cookies to the given browser
Returns:
bool - True if successful, false otherwise
"""
return BrowserCookies.browsers[browser].writeCookies(domain, cookieJar) | [
"def",
"setCookies",
"(",
"browser",
",",
"domain",
",",
"cookieJar",
")",
":",
"return",
"BrowserCookies",
".",
"browsers",
"[",
"browser",
"]",
".",
"writeCookies",
"(",
"domain",
",",
"cookieJar",
")"
] | Writes all given cookies to the given browser
Returns:
bool - True if successful, false otherwise | [
"Writes",
"all",
"given",
"cookies",
"to",
"the",
"given",
"browser",
"Returns",
":",
"bool",
"-",
"True",
"if",
"successful",
"false",
"otherwise"
] | train | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/http/browser/BrowserCookies.py#L56-L62 |
daknuett/py_register_machine2 | core/memory.py | ROM.program_word | def program_word(self, offset, word):
"""
.. _program_word:
Write the word ``word`` to the memory at offset ``offset``.
Used to write the boot code.
Might raise AddressError_, if the offset exceeds the address space.
"""
if(offset >= self.size):
raise AddressError("Offset({}) not in address space({... | python | def program_word(self, offset, word):
"""
.. _program_word:
Write the word ``word`` to the memory at offset ``offset``.
Used to write the boot code.
Might raise AddressError_, if the offset exceeds the address space.
"""
if(offset >= self.size):
raise AddressError("Offset({}) not in address space({... | [
"def",
"program_word",
"(",
"self",
",",
"offset",
",",
"word",
")",
":",
"if",
"(",
"offset",
">=",
"self",
".",
"size",
")",
":",
"raise",
"AddressError",
"(",
"\"Offset({}) not in address space({})\"",
".",
"format",
"(",
"offset",
",",
"self",
".",
"si... | .. _program_word:
Write the word ``word`` to the memory at offset ``offset``.
Used to write the boot code.
Might raise AddressError_, if the offset exceeds the address space. | [
"..",
"_program_word",
":"
] | train | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/core/memory.py#L38-L50 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.