id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
251,500 | EventTeam/beliefs | src/beliefs/cells/dicts.py | DictCell.to_dict | def to_dict(self):
"""
This method converts the DictCell into a python `dict`. This is useful
for JSON serialization.
"""
output = {}
for key, value in self.__dict__['p'].iteritems():
if value is None or isinstance(value, SIMPLE_TYPES):
output... | python | def to_dict(self):
"""
This method converts the DictCell into a python `dict`. This is useful
for JSON serialization.
"""
output = {}
for key, value in self.__dict__['p'].iteritems():
if value is None or isinstance(value, SIMPLE_TYPES):
output... | [
"def",
"to_dict",
"(",
"self",
")",
":",
"output",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"self",
".",
"__dict__",
"[",
"'p'",
"]",
".",
"iteritems",
"(",
")",
":",
"if",
"value",
"is",
"None",
"or",
"isinstance",
"(",
"value",
",",
"SI... | This method converts the DictCell into a python `dict`. This is useful
for JSON serialization. | [
"This",
"method",
"converts",
"the",
"DictCell",
"into",
"a",
"python",
"dict",
".",
"This",
"is",
"useful",
"for",
"JSON",
"serialization",
"."
] | c07d22b61bebeede74a72800030dde770bf64208 | https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/cells/dicts.py#L209-L232 |
251,501 | EventTeam/beliefs | src/beliefs/cells/dicts.py | DictCell.to_latex | def to_latex(self):
""" Returns a LaTeX representation of an attribute-value matrix """
latex = r"[{} "
for attribute, value in self:
if attribute in ['speaker_model', 'is_in_commonground']: continue
value_l = value.to_latex()
if value_l == "": continue
... | python | def to_latex(self):
""" Returns a LaTeX representation of an attribute-value matrix """
latex = r"[{} "
for attribute, value in self:
if attribute in ['speaker_model', 'is_in_commonground']: continue
value_l = value.to_latex()
if value_l == "": continue
... | [
"def",
"to_latex",
"(",
"self",
")",
":",
"latex",
"=",
"r\"[{} \"",
"for",
"attribute",
",",
"value",
"in",
"self",
":",
"if",
"attribute",
"in",
"[",
"'speaker_model'",
",",
"'is_in_commonground'",
"]",
":",
"continue",
"value_l",
"=",
"value",
".",
"to_... | Returns a LaTeX representation of an attribute-value matrix | [
"Returns",
"a",
"LaTeX",
"representation",
"of",
"an",
"attribute",
"-",
"value",
"matrix"
] | c07d22b61bebeede74a72800030dde770bf64208 | https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/cells/dicts.py#L234-L243 |
251,502 | alexhayes/django-toolkit | django_toolkit/date_util.py | business_days | def business_days(start, stop):
"""
Return business days between two inclusive dates - ignoring public holidays.
Note that start must be less than stop or else 0 is returned.
@param start: Start date
@param stop: Stop date
@return int
"""
dates=rrule.rruleset()
# Get dates ... | python | def business_days(start, stop):
"""
Return business days between two inclusive dates - ignoring public holidays.
Note that start must be less than stop or else 0 is returned.
@param start: Start date
@param stop: Stop date
@return int
"""
dates=rrule.rruleset()
# Get dates ... | [
"def",
"business_days",
"(",
"start",
",",
"stop",
")",
":",
"dates",
"=",
"rrule",
".",
"rruleset",
"(",
")",
"# Get dates between start/stop (which are inclusive)",
"dates",
".",
"rrule",
"(",
"rrule",
".",
"rrule",
"(",
"rrule",
".",
"DAILY",
",",
"dtstart"... | Return business days between two inclusive dates - ignoring public holidays.
Note that start must be less than stop or else 0 is returned.
@param start: Start date
@param stop: Stop date
@return int | [
"Return",
"business",
"days",
"between",
"two",
"inclusive",
"dates",
"-",
"ignoring",
"public",
"holidays",
".",
"Note",
"that",
"start",
"must",
"be",
"less",
"than",
"stop",
"or",
"else",
"0",
"is",
"returned",
"."
] | b64106392fad596defc915b8235fe6e1d0013b5b | https://github.com/alexhayes/django-toolkit/blob/b64106392fad596defc915b8235fe6e1d0013b5b/django_toolkit/date_util.py#L33-L48 |
251,503 | alexhayes/django-toolkit | django_toolkit/date_util.py | get_anniversary_periods | def get_anniversary_periods(start, finish, anniversary=1):
"""
Return a list of anniversaries periods between start and finish.
"""
import sys
current = start
periods = []
while current <= finish:
(period_start, period_finish) = date_period(DATE_FREQUENCY_MONTHLY, anniversary, curre... | python | def get_anniversary_periods(start, finish, anniversary=1):
"""
Return a list of anniversaries periods between start and finish.
"""
import sys
current = start
periods = []
while current <= finish:
(period_start, period_finish) = date_period(DATE_FREQUENCY_MONTHLY, anniversary, curre... | [
"def",
"get_anniversary_periods",
"(",
"start",
",",
"finish",
",",
"anniversary",
"=",
"1",
")",
":",
"import",
"sys",
"current",
"=",
"start",
"periods",
"=",
"[",
"]",
"while",
"current",
"<=",
"finish",
":",
"(",
"period_start",
",",
"period_finish",
"... | Return a list of anniversaries periods between start and finish. | [
"Return",
"a",
"list",
"of",
"anniversaries",
"periods",
"between",
"start",
"and",
"finish",
"."
] | b64106392fad596defc915b8235fe6e1d0013b5b | https://github.com/alexhayes/django-toolkit/blob/b64106392fad596defc915b8235fe6e1d0013b5b/django_toolkit/date_util.py#L68-L81 |
251,504 | alexhayes/django-toolkit | django_toolkit/date_util.py | previous_quarter | def previous_quarter(d):
"""
Retrieve the previous quarter for dt
"""
from django_toolkit.datetime_util import quarter as datetime_quarter
return quarter( (datetime_quarter(datetime(d.year, d.month, d.day))[0] + timedelta(days=-1)).date() ) | python | def previous_quarter(d):
"""
Retrieve the previous quarter for dt
"""
from django_toolkit.datetime_util import quarter as datetime_quarter
return quarter( (datetime_quarter(datetime(d.year, d.month, d.day))[0] + timedelta(days=-1)).date() ) | [
"def",
"previous_quarter",
"(",
"d",
")",
":",
"from",
"django_toolkit",
".",
"datetime_util",
"import",
"quarter",
"as",
"datetime_quarter",
"return",
"quarter",
"(",
"(",
"datetime_quarter",
"(",
"datetime",
"(",
"d",
".",
"year",
",",
"d",
".",
"month",
"... | Retrieve the previous quarter for dt | [
"Retrieve",
"the",
"previous",
"quarter",
"for",
"dt"
] | b64106392fad596defc915b8235fe6e1d0013b5b | https://github.com/alexhayes/django-toolkit/blob/b64106392fad596defc915b8235fe6e1d0013b5b/django_toolkit/date_util.py#L174-L179 |
251,505 | knagra/farnsworth | workshift/signals.py | _check_field_changed | def _check_field_changed(instance, old_instance, field_name, update_fields=None):
"""
Examines update_fields and an attribute of an instance to determine if
that attribute has changed prior to the instance being saved.
Parameters
----------
field_name : str
instance : object
old_instanc... | python | def _check_field_changed(instance, old_instance, field_name, update_fields=None):
"""
Examines update_fields and an attribute of an instance to determine if
that attribute has changed prior to the instance being saved.
Parameters
----------
field_name : str
instance : object
old_instanc... | [
"def",
"_check_field_changed",
"(",
"instance",
",",
"old_instance",
",",
"field_name",
",",
"update_fields",
"=",
"None",
")",
":",
"if",
"update_fields",
"is",
"not",
"None",
"and",
"field_name",
"not",
"in",
"update_fields",
":",
"return",
"False",
"return",
... | Examines update_fields and an attribute of an instance to determine if
that attribute has changed prior to the instance being saved.
Parameters
----------
field_name : str
instance : object
old_instance : object
update_fields : list of str, optional | [
"Examines",
"update_fields",
"and",
"an",
"attribute",
"of",
"an",
"instance",
"to",
"determine",
"if",
"that",
"attribute",
"has",
"changed",
"prior",
"to",
"the",
"instance",
"being",
"saved",
"."
] | 1b6589f0d9fea154f0a1e2231ed906764ed26d26 | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/workshift/signals.py#L116-L131 |
251,506 | happy5214/competitions-match | competitions/match/default/SimpleMatch.py | SimpleMatch.play | def play(self):
"""Play the match.
This match simulator iterates through two lists of random numbers
25 times, one for each team, comparing the numbers and awarding a point
to the team with the higher number. The team with more points at the
end of the lists wins and is recorded... | python | def play(self):
"""Play the match.
This match simulator iterates through two lists of random numbers
25 times, one for each team, comparing the numbers and awarding a point
to the team with the higher number. The team with more points at the
end of the lists wins and is recorded... | [
"def",
"play",
"(",
"self",
")",
":",
"score1",
"=",
"0",
"score2",
"=",
"0",
"for",
"__",
"in",
"range",
"(",
"25",
")",
":",
"num1",
"=",
"random",
".",
"randint",
"(",
"0",
",",
"100",
")",
"num2",
"=",
"random",
".",
"randint",
"(",
"0",
... | Play the match.
This match simulator iterates through two lists of random numbers
25 times, one for each team, comparing the numbers and awarding a point
to the team with the higher number. The team with more points at the
end of the lists wins and is recorded in the winner field. If th... | [
"Play",
"the",
"match",
"."
] | 0eb77af258d9207c9c3b952e49ce70c856e15588 | https://github.com/happy5214/competitions-match/blob/0eb77af258d9207c9c3b952e49ce70c856e15588/competitions/match/default/SimpleMatch.py#L72-L107 |
251,507 | erbriones/shapeshift | shapeshift/generic.py | create_logger | def create_logger(name, formatter=None, handler=None, level=None):
"""
Returns a new logger for the specified name.
"""
logger = logging.getLogger(name)
#: remove existing handlers
logger.handlers = []
#: use a standard out handler
if handler is None:
handler = logging.StreamHa... | python | def create_logger(name, formatter=None, handler=None, level=None):
"""
Returns a new logger for the specified name.
"""
logger = logging.getLogger(name)
#: remove existing handlers
logger.handlers = []
#: use a standard out handler
if handler is None:
handler = logging.StreamHa... | [
"def",
"create_logger",
"(",
"name",
",",
"formatter",
"=",
"None",
",",
"handler",
"=",
"None",
",",
"level",
"=",
"None",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"name",
")",
"#: remove existing handlers",
"logger",
".",
"handlers",
"=... | Returns a new logger for the specified name. | [
"Returns",
"a",
"new",
"logger",
"for",
"the",
"specified",
"name",
"."
] | f930cdc0d520b08238e0fc2c582458f341b87775 | https://github.com/erbriones/shapeshift/blob/f930cdc0d520b08238e0fc2c582458f341b87775/shapeshift/generic.py#L10-L34 |
251,508 | abe-winter/pg13-py | pg13/diff.py | splitstatus | def splitstatus(a,statusfn):
'split sequence into subsequences based on binary condition statusfn. a is a list, returns list of lists'
groups=[]; mode=None
for elt,status in zip(a,map(statusfn,a)):
assert isinstance(status,bool)
if status!=mode: mode=status; group=[mode]; groups.append(group)
gr... | python | def splitstatus(a,statusfn):
'split sequence into subsequences based on binary condition statusfn. a is a list, returns list of lists'
groups=[]; mode=None
for elt,status in zip(a,map(statusfn,a)):
assert isinstance(status,bool)
if status!=mode: mode=status; group=[mode]; groups.append(group)
gr... | [
"def",
"splitstatus",
"(",
"a",
",",
"statusfn",
")",
":",
"groups",
"=",
"[",
"]",
"mode",
"=",
"None",
"for",
"elt",
",",
"status",
"in",
"zip",
"(",
"a",
",",
"map",
"(",
"statusfn",
",",
"a",
")",
")",
":",
"assert",
"isinstance",
"(",
"statu... | split sequence into subsequences based on binary condition statusfn. a is a list, returns list of lists | [
"split",
"sequence",
"into",
"subsequences",
"based",
"on",
"binary",
"condition",
"statusfn",
".",
"a",
"is",
"a",
"list",
"returns",
"list",
"of",
"lists"
] | c78806f99f35541a8756987e86edca3438aa97f5 | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/diff.py#L28-L35 |
251,509 | abe-winter/pg13-py | pg13/diff.py | ungroupslice | def ungroupslice(groups,gslice):
'this is a helper for contigsub.'
'coordinate transform: takes a match from seqingroups() and transforms to ungrouped coordinates'
eltsbefore=0
for i in range(gslice[0]): eltsbefore+=len(groups[i])-1
x=eltsbefore+gslice[1]; return [x-1,x+gslice[2]-1] | python | def ungroupslice(groups,gslice):
'this is a helper for contigsub.'
'coordinate transform: takes a match from seqingroups() and transforms to ungrouped coordinates'
eltsbefore=0
for i in range(gslice[0]): eltsbefore+=len(groups[i])-1
x=eltsbefore+gslice[1]; return [x-1,x+gslice[2]-1] | [
"def",
"ungroupslice",
"(",
"groups",
",",
"gslice",
")",
":",
"'coordinate transform: takes a match from seqingroups() and transforms to ungrouped coordinates'",
"eltsbefore",
"=",
"0",
"for",
"i",
"in",
"range",
"(",
"gslice",
"[",
"0",
"]",
")",
":",
"eltsbefore",
... | this is a helper for contigsub. | [
"this",
"is",
"a",
"helper",
"for",
"contigsub",
"."
] | c78806f99f35541a8756987e86edca3438aa97f5 | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/diff.py#L63-L68 |
251,510 | abe-winter/pg13-py | pg13/diff.py | translate_diff | def translate_diff(origtext,deltas):
'take diff run on separated words and convert the deltas to character offsets'
lens=[0]+cumsum(map(len,splitpreserve(origtext))) # [0] at the head for like 'length before'
return [Delta(lens[a],lens[b],''.join(replace)) for a,b,replace in deltas] | python | def translate_diff(origtext,deltas):
'take diff run on separated words and convert the deltas to character offsets'
lens=[0]+cumsum(map(len,splitpreserve(origtext))) # [0] at the head for like 'length before'
return [Delta(lens[a],lens[b],''.join(replace)) for a,b,replace in deltas] | [
"def",
"translate_diff",
"(",
"origtext",
",",
"deltas",
")",
":",
"lens",
"=",
"[",
"0",
"]",
"+",
"cumsum",
"(",
"map",
"(",
"len",
",",
"splitpreserve",
"(",
"origtext",
")",
")",
")",
"# [0] at the head for like 'length before'\r",
"return",
"[",
"Delta"... | take diff run on separated words and convert the deltas to character offsets | [
"take",
"diff",
"run",
"on",
"separated",
"words",
"and",
"convert",
"the",
"deltas",
"to",
"character",
"offsets"
] | c78806f99f35541a8756987e86edca3438aa97f5 | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/diff.py#L115-L118 |
251,511 | abe-winter/pg13-py | pg13/diff.py | word_diff | def word_diff(a,b):
'do diff on words but return character offsets'
return translate_diff(a,rediff(splitpreserve(a),splitpreserve(b))) | python | def word_diff(a,b):
'do diff on words but return character offsets'
return translate_diff(a,rediff(splitpreserve(a),splitpreserve(b))) | [
"def",
"word_diff",
"(",
"a",
",",
"b",
")",
":",
"return",
"translate_diff",
"(",
"a",
",",
"rediff",
"(",
"splitpreserve",
"(",
"a",
")",
",",
"splitpreserve",
"(",
"b",
")",
")",
")"
] | do diff on words but return character offsets | [
"do",
"diff",
"on",
"words",
"but",
"return",
"character",
"offsets"
] | c78806f99f35541a8756987e86edca3438aa97f5 | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/diff.py#L120-L122 |
251,512 | abe-winter/pg13-py | pg13/diff.py | checkdiff | def checkdiff(a,b,sp=True):
'take diff of a to b, apply to a, return the applied diff so external code can check it against b'
if sp: a=splitpreserve(a); b=splitpreserve(b)
res=applydiff(a,rediff(a,b))
if sp: res=''.join(res)
return res | python | def checkdiff(a,b,sp=True):
'take diff of a to b, apply to a, return the applied diff so external code can check it against b'
if sp: a=splitpreserve(a); b=splitpreserve(b)
res=applydiff(a,rediff(a,b))
if sp: res=''.join(res)
return res | [
"def",
"checkdiff",
"(",
"a",
",",
"b",
",",
"sp",
"=",
"True",
")",
":",
"if",
"sp",
":",
"a",
"=",
"splitpreserve",
"(",
"a",
")",
"b",
"=",
"splitpreserve",
"(",
"b",
")",
"res",
"=",
"applydiff",
"(",
"a",
",",
"rediff",
"(",
"a",
",",
"b... | take diff of a to b, apply to a, return the applied diff so external code can check it against b | [
"take",
"diff",
"of",
"a",
"to",
"b",
"apply",
"to",
"a",
"return",
"the",
"applied",
"diff",
"so",
"external",
"code",
"can",
"check",
"it",
"against",
"b"
] | c78806f99f35541a8756987e86edca3438aa97f5 | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/diff.py#L124-L129 |
251,513 | treycucco/bidon | bidon/db/model/foreign_model_wrapper.py | ForeignModelWrapper.create | def create(cls, source, *, transform_args=None):
"""Create an instance of the class from the source. By default cls.transform_args is used, but
can be overridden by passing in transform_args.
"""
if transform_args is None:
transform_args = cls.transform_args
return cls(get_obj(source, *transf... | python | def create(cls, source, *, transform_args=None):
"""Create an instance of the class from the source. By default cls.transform_args is used, but
can be overridden by passing in transform_args.
"""
if transform_args is None:
transform_args = cls.transform_args
return cls(get_obj(source, *transf... | [
"def",
"create",
"(",
"cls",
",",
"source",
",",
"*",
",",
"transform_args",
"=",
"None",
")",
":",
"if",
"transform_args",
"is",
"None",
":",
"transform_args",
"=",
"cls",
".",
"transform_args",
"return",
"cls",
"(",
"get_obj",
"(",
"source",
",",
"*",
... | Create an instance of the class from the source. By default cls.transform_args is used, but
can be overridden by passing in transform_args. | [
"Create",
"an",
"instance",
"of",
"the",
"class",
"from",
"the",
"source",
".",
"By",
"default",
"cls",
".",
"transform_args",
"is",
"used",
"but",
"can",
"be",
"overridden",
"by",
"passing",
"in",
"transform_args",
"."
] | d9f24596841d0e69e8ac70a1d1a1deecea95e340 | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/model/foreign_model_wrapper.py#L20-L27 |
251,514 | treycucco/bidon | bidon/db/model/foreign_model_wrapper.py | ForeignModelWrapper.map | def map(cls, sources, *, transform_args=None):
"""Generates instances from the sources using either cls.transform_args or transform_args
argument if present.
"""
for idx, source in enumerate(sources):
try:
yield cls.create(source, transform_args=transform_args)
except Exception as ex... | python | def map(cls, sources, *, transform_args=None):
"""Generates instances from the sources using either cls.transform_args or transform_args
argument if present.
"""
for idx, source in enumerate(sources):
try:
yield cls.create(source, transform_args=transform_args)
except Exception as ex... | [
"def",
"map",
"(",
"cls",
",",
"sources",
",",
"*",
",",
"transform_args",
"=",
"None",
")",
":",
"for",
"idx",
",",
"source",
"in",
"enumerate",
"(",
"sources",
")",
":",
"try",
":",
"yield",
"cls",
".",
"create",
"(",
"source",
",",
"transform_args... | Generates instances from the sources using either cls.transform_args or transform_args
argument if present. | [
"Generates",
"instances",
"from",
"the",
"sources",
"using",
"either",
"cls",
".",
"transform_args",
"or",
"transform_args",
"argument",
"if",
"present",
"."
] | d9f24596841d0e69e8ac70a1d1a1deecea95e340 | https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/model/foreign_model_wrapper.py#L30-L38 |
251,515 | minhhoit/yacms | yacms/generic/models.py | ThreadedComment.save | def save(self, *args, **kwargs):
"""
Set the current site ID, and ``is_public`` based on the setting
``COMMENTS_DEFAULT_APPROVED``.
"""
if not self.id:
self.is_public = settings.COMMENTS_DEFAULT_APPROVED
self.site_id = current_site_id()
super(Threa... | python | def save(self, *args, **kwargs):
"""
Set the current site ID, and ``is_public`` based on the setting
``COMMENTS_DEFAULT_APPROVED``.
"""
if not self.id:
self.is_public = settings.COMMENTS_DEFAULT_APPROVED
self.site_id = current_site_id()
super(Threa... | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"id",
":",
"self",
".",
"is_public",
"=",
"settings",
".",
"COMMENTS_DEFAULT_APPROVED",
"self",
".",
"site_id",
"=",
"current_site_id",
"(",
")",... | Set the current site ID, and ``is_public`` based on the setting
``COMMENTS_DEFAULT_APPROVED``. | [
"Set",
"the",
"current",
"site",
"ID",
"and",
"is_public",
"based",
"on",
"the",
"setting",
"COMMENTS_DEFAULT_APPROVED",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/generic/models.py#L50-L58 |
251,516 | minhhoit/yacms | yacms/generic/models.py | Rating.save | def save(self, *args, **kwargs):
"""
Validate that the rating falls between the min and max values.
"""
valid = map(str, settings.RATINGS_RANGE)
if str(self.value) not in valid:
raise ValueError("Invalid rating. %s is not in %s" % (self.value,
", ".joi... | python | def save(self, *args, **kwargs):
"""
Validate that the rating falls between the min and max values.
"""
valid = map(str, settings.RATINGS_RANGE)
if str(self.value) not in valid:
raise ValueError("Invalid rating. %s is not in %s" % (self.value,
", ".joi... | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"valid",
"=",
"map",
"(",
"str",
",",
"settings",
".",
"RATINGS_RANGE",
")",
"if",
"str",
"(",
"self",
".",
"value",
")",
"not",
"in",
"valid",
":",
"raise",
"ValueE... | Validate that the rating falls between the min and max values. | [
"Validate",
"that",
"the",
"rating",
"falls",
"between",
"the",
"min",
"and",
"max",
"values",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/generic/models.py#L140-L148 |
251,517 | kaniblu/pyaap | yaap/__init__.py | ArgParser.add_mutex_switch | def add_mutex_switch(parser, dest, arguments=set(), default=None,
single_arg=False, required=False):
"""Adds mutually exclusive switch arguments.
Args:
arguments: a dictionary that maps switch name to helper text. Use
sets to skip help texts.
... | python | def add_mutex_switch(parser, dest, arguments=set(), default=None,
single_arg=False, required=False):
"""Adds mutually exclusive switch arguments.
Args:
arguments: a dictionary that maps switch name to helper text. Use
sets to skip help texts.
... | [
"def",
"add_mutex_switch",
"(",
"parser",
",",
"dest",
",",
"arguments",
"=",
"set",
"(",
")",
",",
"default",
"=",
"None",
",",
"single_arg",
"=",
"False",
",",
"required",
"=",
"False",
")",
":",
"if",
"default",
"is",
"not",
"None",
":",
"assert",
... | Adds mutually exclusive switch arguments.
Args:
arguments: a dictionary that maps switch name to helper text. Use
sets to skip help texts. | [
"Adds",
"mutually",
"exclusive",
"switch",
"arguments",
"."
] | fbf8370a49f86b160009ddf30f30f22bb4aba9b9 | https://github.com/kaniblu/pyaap/blob/fbf8370a49f86b160009ddf30f30f22bb4aba9b9/yaap/__init__.py#L68-L110 |
251,518 | sci-bots/mpm | mpm/api.py | _save_action | def _save_action(extra_context=None):
'''
Save list of revisions revisions for active Conda environment.
.. versionchanged:: 0.18
Compress action revision files using ``bz2`` to save disk space.
Parameters
----------
extra_context : dict, optional
Extra content to store in stor... | python | def _save_action(extra_context=None):
'''
Save list of revisions revisions for active Conda environment.
.. versionchanged:: 0.18
Compress action revision files using ``bz2`` to save disk space.
Parameters
----------
extra_context : dict, optional
Extra content to store in stor... | [
"def",
"_save_action",
"(",
"extra_context",
"=",
"None",
")",
":",
"# Get list of revisions to Conda environment since creation.",
"revisions_js",
"=",
"ch",
".",
"conda_exec",
"(",
"'list'",
",",
"'--revisions'",
",",
"'--json'",
",",
"verbose",
"=",
"False",
")",
... | Save list of revisions revisions for active Conda environment.
.. versionchanged:: 0.18
Compress action revision files using ``bz2`` to save disk space.
Parameters
----------
extra_context : dict, optional
Extra content to store in stored action revision.
Returns
-------
p... | [
"Save",
"list",
"of",
"revisions",
"revisions",
"for",
"active",
"Conda",
"environment",
"."
] | a69651cda4b37ee6b17df4fe0809249e7f4dc536 | https://github.com/sci-bots/mpm/blob/a69651cda4b37ee6b17df4fe0809249e7f4dc536/mpm/api.py#L57-L91 |
251,519 | sci-bots/mpm | mpm/api.py | available_packages | def available_packages(*args, **kwargs):
'''
Query available plugin packages based on specified Conda channels.
Parameters
----------
*args
Extra arguments to pass to Conda ``search`` command.
Returns
-------
dict
.. versionchanged:: 0.24
All Conda packages ... | python | def available_packages(*args, **kwargs):
'''
Query available plugin packages based on specified Conda channels.
Parameters
----------
*args
Extra arguments to pass to Conda ``search`` command.
Returns
-------
dict
.. versionchanged:: 0.24
All Conda packages ... | [
"def",
"available_packages",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Get list of available MicroDrop plugins, i.e., Conda packages that start",
"# with the prefix `microdrop.`.",
"try",
":",
"plugin_packages_info_json",
"=",
"ch",
".",
"conda_exec",
"(",
"'s... | Query available plugin packages based on specified Conda channels.
Parameters
----------
*args
Extra arguments to pass to Conda ``search`` command.
Returns
-------
dict
.. versionchanged:: 0.24
All Conda packages beginning with ``microdrop.`` prefix from all
... | [
"Query",
"available",
"plugin",
"packages",
"based",
"on",
"specified",
"Conda",
"channels",
"."
] | a69651cda4b37ee6b17df4fe0809249e7f4dc536 | https://github.com/sci-bots/mpm/blob/a69651cda4b37ee6b17df4fe0809249e7f4dc536/mpm/api.py#L136-L192 |
251,520 | sci-bots/mpm | mpm/api.py | install | def install(plugin_name, *args, **kwargs):
'''
Install plugin packages based on specified Conda channels.
.. versionchanged:: 0.19.1
Do not save rollback info on dry-run.
.. versionchanged:: 0.24
Remove channels argument. Use Conda channels as configured in Conda
environment.
... | python | def install(plugin_name, *args, **kwargs):
'''
Install plugin packages based on specified Conda channels.
.. versionchanged:: 0.19.1
Do not save rollback info on dry-run.
.. versionchanged:: 0.24
Remove channels argument. Use Conda channels as configured in Conda
environment.
... | [
"def",
"install",
"(",
"plugin_name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"plugin_name",
",",
"types",
".",
"StringTypes",
")",
":",
"plugin_name",
"=",
"[",
"plugin_name",
"]",
"# Perform installation",
"conda_args"... | Install plugin packages based on specified Conda channels.
.. versionchanged:: 0.19.1
Do not save rollback info on dry-run.
.. versionchanged:: 0.24
Remove channels argument. Use Conda channels as configured in Conda
environment.
Note that channels can still be explicitly set... | [
"Install",
"plugin",
"packages",
"based",
"on",
"specified",
"Conda",
"channels",
"."
] | a69651cda4b37ee6b17df4fe0809249e7f4dc536 | https://github.com/sci-bots/mpm/blob/a69651cda4b37ee6b17df4fe0809249e7f4dc536/mpm/api.py#L196-L234 |
251,521 | sci-bots/mpm | mpm/api.py | uninstall | def uninstall(plugin_name, *args):
'''
Uninstall plugin packages.
Plugin packages must have a directory with the same name as the package in
the following directory:
<conda prefix>/share/microdrop/plugins/available/
Parameters
----------
plugin_name : str or list
Plugin pa... | python | def uninstall(plugin_name, *args):
'''
Uninstall plugin packages.
Plugin packages must have a directory with the same name as the package in
the following directory:
<conda prefix>/share/microdrop/plugins/available/
Parameters
----------
plugin_name : str or list
Plugin pa... | [
"def",
"uninstall",
"(",
"plugin_name",
",",
"*",
"args",
")",
":",
"if",
"isinstance",
"(",
"plugin_name",
",",
"types",
".",
"StringTypes",
")",
":",
"plugin_name",
"=",
"[",
"plugin_name",
"]",
"available_path",
"=",
"MICRODROP_CONDA_SHARE",
".",
"joinpath"... | Uninstall plugin packages.
Plugin packages must have a directory with the same name as the package in
the following directory:
<conda prefix>/share/microdrop/plugins/available/
Parameters
----------
plugin_name : str or list
Plugin package(s) to uninstall.
*args
Extra ... | [
"Uninstall",
"plugin",
"packages",
"."
] | a69651cda4b37ee6b17df4fe0809249e7f4dc536 | https://github.com/sci-bots/mpm/blob/a69651cda4b37ee6b17df4fe0809249e7f4dc536/mpm/api.py#L304-L345 |
251,522 | sci-bots/mpm | mpm/api.py | import_plugin | def import_plugin(package_name, include_available=False):
'''
Import MicroDrop plugin.
Parameters
----------
package_name : str
Name of MicroDrop plugin Conda package.
include_available : bool, optional
If ``True``, import from all available plugins (not just **enabled**
... | python | def import_plugin(package_name, include_available=False):
'''
Import MicroDrop plugin.
Parameters
----------
package_name : str
Name of MicroDrop plugin Conda package.
include_available : bool, optional
If ``True``, import from all available plugins (not just **enabled**
... | [
"def",
"import_plugin",
"(",
"package_name",
",",
"include_available",
"=",
"False",
")",
":",
"available_plugins_dir",
"=",
"MICRODROP_CONDA_SHARE",
".",
"joinpath",
"(",
"'plugins'",
",",
"'available'",
")",
"enabled_plugins_dir",
"=",
"MICRODROP_CONDA_ETC",
".",
"j... | Import MicroDrop plugin.
Parameters
----------
package_name : str
Name of MicroDrop plugin Conda package.
include_available : bool, optional
If ``True``, import from all available plugins (not just **enabled**
ones).
By default, only the ``<conda>/etc/microdrop/plugins/... | [
"Import",
"MicroDrop",
"plugin",
"."
] | a69651cda4b37ee6b17df4fe0809249e7f4dc536 | https://github.com/sci-bots/mpm/blob/a69651cda4b37ee6b17df4fe0809249e7f4dc536/mpm/api.py#L542-L575 |
251,523 | alexhayes/django-toolkit | django_toolkit/email.py | EmailMultiRelated.attach_related | def attach_related(self, filename=None, content=None, mimetype=None):
"""
Attaches a file with the given filename and content. The filename can
be omitted and the mimetype is guessed, if not provided.
If the first parameter is a MIMEBase subclass it is inserted directly
into the... | python | def attach_related(self, filename=None, content=None, mimetype=None):
"""
Attaches a file with the given filename and content. The filename can
be omitted and the mimetype is guessed, if not provided.
If the first parameter is a MIMEBase subclass it is inserted directly
into the... | [
"def",
"attach_related",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"content",
"=",
"None",
",",
"mimetype",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"filename",
",",
"MIMEBase",
")",
":",
"assert",
"content",
"==",
"mimetype",
"==",
"None",
... | Attaches a file with the given filename and content. The filename can
be omitted and the mimetype is guessed, if not provided.
If the first parameter is a MIMEBase subclass it is inserted directly
into the resulting message attachments. | [
"Attaches",
"a",
"file",
"with",
"the",
"given",
"filename",
"and",
"content",
".",
"The",
"filename",
"can",
"be",
"omitted",
"and",
"the",
"mimetype",
"is",
"guessed",
"if",
"not",
"provided",
"."
] | b64106392fad596defc915b8235fe6e1d0013b5b | https://github.com/alexhayes/django-toolkit/blob/b64106392fad596defc915b8235fe6e1d0013b5b/django_toolkit/email.py#L24-L37 |
251,524 | alexhayes/django-toolkit | django_toolkit/email.py | EmailMultiRelated.attach_related_file | def attach_related_file(self, path, mimetype=None):
"""Attaches a file from the filesystem."""
filename = os.path.basename(path)
content = open(path, 'rb').read()
self.attach_related(filename, content, mimetype) | python | def attach_related_file(self, path, mimetype=None):
"""Attaches a file from the filesystem."""
filename = os.path.basename(path)
content = open(path, 'rb').read()
self.attach_related(filename, content, mimetype) | [
"def",
"attach_related_file",
"(",
"self",
",",
"path",
",",
"mimetype",
"=",
"None",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"path",
")",
"content",
"=",
"open",
"(",
"path",
",",
"'rb'",
")",
".",
"read",
"(",
")",
"se... | Attaches a file from the filesystem. | [
"Attaches",
"a",
"file",
"from",
"the",
"filesystem",
"."
] | b64106392fad596defc915b8235fe6e1d0013b5b | https://github.com/alexhayes/django-toolkit/blob/b64106392fad596defc915b8235fe6e1d0013b5b/django_toolkit/email.py#L39-L43 |
251,525 | calvinku96/labreporthelper | labreporthelper/datafile.py | CustomDataFile.create_dat_file | def create_dat_file(self):
"""
Create and write empty data file in the data directory
"""
output = "## {}\n".format(self.name)
try:
kwargs_items = self.kwargs.iteritems()
except AttributeError:
kwargs_items = self.kwargs.items()
for key, va... | python | def create_dat_file(self):
"""
Create and write empty data file in the data directory
"""
output = "## {}\n".format(self.name)
try:
kwargs_items = self.kwargs.iteritems()
except AttributeError:
kwargs_items = self.kwargs.items()
for key, va... | [
"def",
"create_dat_file",
"(",
"self",
")",
":",
"output",
"=",
"\"## {}\\n\"",
".",
"format",
"(",
"self",
".",
"name",
")",
"try",
":",
"kwargs_items",
"=",
"self",
".",
"kwargs",
".",
"iteritems",
"(",
")",
"except",
"AttributeError",
":",
"kwargs_items... | Create and write empty data file in the data directory | [
"Create",
"and",
"write",
"empty",
"data",
"file",
"in",
"the",
"data",
"directory"
] | 4d436241f389c02eb188c313190df62ab28c3763 | https://github.com/calvinku96/labreporthelper/blob/4d436241f389c02eb188c313190df62ab28c3763/labreporthelper/datafile.py#L66-L95 |
251,526 | calvinku96/labreporthelper | labreporthelper/datafile.py | MCADataFile.parse_data_to_internal | def parse_data_to_internal(self, data=None):
"""parse to internal
"""
if data is None:
f = open(self.location_dat, "rb")
data = {
"PMCA SPECTRUM": {},
"DATA": [],
"DP5 CONFIGURATION": {},
"DPP STATUS": {}
... | python | def parse_data_to_internal(self, data=None):
"""parse to internal
"""
if data is None:
f = open(self.location_dat, "rb")
data = {
"PMCA SPECTRUM": {},
"DATA": [],
"DP5 CONFIGURATION": {},
"DPP STATUS": {}
... | [
"def",
"parse_data_to_internal",
"(",
"self",
",",
"data",
"=",
"None",
")",
":",
"if",
"data",
"is",
"None",
":",
"f",
"=",
"open",
"(",
"self",
".",
"location_dat",
",",
"\"rb\"",
")",
"data",
"=",
"{",
"\"PMCA SPECTRUM\"",
":",
"{",
"}",
",",
"\"D... | parse to internal | [
"parse",
"to",
"internal"
] | 4d436241f389c02eb188c313190df62ab28c3763 | https://github.com/calvinku96/labreporthelper/blob/4d436241f389c02eb188c313190df62ab28c3763/labreporthelper/datafile.py#L157-L204 |
251,527 | calvinku96/labreporthelper | labreporthelper/datafile.py | DataFile.parse_data_to_internal | def parse_data_to_internal(self, data=None):
"""Use numpy loadtxt
"""
if data is None:
kwargs = self.kwargs
data = np.loadtxt(
open(self.location_dat, "rb"), **kwargs
)
if self.filetype is "pickle":
pickle.dump(data, open(se... | python | def parse_data_to_internal(self, data=None):
"""Use numpy loadtxt
"""
if data is None:
kwargs = self.kwargs
data = np.loadtxt(
open(self.location_dat, "rb"), **kwargs
)
if self.filetype is "pickle":
pickle.dump(data, open(se... | [
"def",
"parse_data_to_internal",
"(",
"self",
",",
"data",
"=",
"None",
")",
":",
"if",
"data",
"is",
"None",
":",
"kwargs",
"=",
"self",
".",
"kwargs",
"data",
"=",
"np",
".",
"loadtxt",
"(",
"open",
"(",
"self",
".",
"location_dat",
",",
"\"rb\"",
... | Use numpy loadtxt | [
"Use",
"numpy",
"loadtxt"
] | 4d436241f389c02eb188c313190df62ab28c3763 | https://github.com/calvinku96/labreporthelper/blob/4d436241f389c02eb188c313190df62ab28c3763/labreporthelper/datafile.py#L216-L234 |
251,528 | klen/muffin-jade | muffin_jade.py | Plugin.ctx_provider | def ctx_provider(self, func):
""" Decorator for adding a context provider.
::
@jade.ctx_provider
def my_context():
return {...}
"""
func = to_coroutine(func)
self.providers.append(func)
return func | python | def ctx_provider(self, func):
""" Decorator for adding a context provider.
::
@jade.ctx_provider
def my_context():
return {...}
"""
func = to_coroutine(func)
self.providers.append(func)
return func | [
"def",
"ctx_provider",
"(",
"self",
",",
"func",
")",
":",
"func",
"=",
"to_coroutine",
"(",
"func",
")",
"self",
".",
"providers",
".",
"append",
"(",
"func",
")",
"return",
"func"
] | Decorator for adding a context provider.
::
@jade.ctx_provider
def my_context():
return {...} | [
"Decorator",
"for",
"adding",
"a",
"context",
"provider",
"."
] | 3ddd6bf27fac03edc0bef3b0840bcd2e278babb3 | https://github.com/klen/muffin-jade/blob/3ddd6bf27fac03edc0bef3b0840bcd2e278babb3/muffin_jade.py#L59-L69 |
251,529 | klen/muffin-jade | muffin_jade.py | Plugin.register | def register(self, func):
""" Register function to templates. """
if callable(func):
self.functions[func.__name__] = func
return func | python | def register(self, func):
""" Register function to templates. """
if callable(func):
self.functions[func.__name__] = func
return func | [
"def",
"register",
"(",
"self",
",",
"func",
")",
":",
"if",
"callable",
"(",
"func",
")",
":",
"self",
".",
"functions",
"[",
"func",
".",
"__name__",
"]",
"=",
"func",
"return",
"func"
] | Register function to templates. | [
"Register",
"function",
"to",
"templates",
"."
] | 3ddd6bf27fac03edc0bef3b0840bcd2e278babb3 | https://github.com/klen/muffin-jade/blob/3ddd6bf27fac03edc0bef3b0840bcd2e278babb3/muffin_jade.py#L71-L75 |
251,530 | klen/muffin-jade | muffin_jade.py | Plugin.render | def render(self, path, **context):
""" Render a template with context. """
funcs = self.functions
ctx = dict(self.functions, jdebug=lambda: dict(
(k, v) for k, v in ctx.items() if k not in funcs and k != 'jdebug'))
for provider in self.providers:
_ctx = yield from... | python | def render(self, path, **context):
""" Render a template with context. """
funcs = self.functions
ctx = dict(self.functions, jdebug=lambda: dict(
(k, v) for k, v in ctx.items() if k not in funcs and k != 'jdebug'))
for provider in self.providers:
_ctx = yield from... | [
"def",
"render",
"(",
"self",
",",
"path",
",",
"*",
"*",
"context",
")",
":",
"funcs",
"=",
"self",
".",
"functions",
"ctx",
"=",
"dict",
"(",
"self",
".",
"functions",
",",
"jdebug",
"=",
"lambda",
":",
"dict",
"(",
"(",
"k",
",",
"v",
")",
"... | Render a template with context. | [
"Render",
"a",
"template",
"with",
"context",
"."
] | 3ddd6bf27fac03edc0bef3b0840bcd2e278babb3 | https://github.com/klen/muffin-jade/blob/3ddd6bf27fac03edc0bef3b0840bcd2e278babb3/muffin_jade.py#L78-L88 |
251,531 | klen/muffin-jade | muffin_jade.py | Environment.load_template | def load_template(self, path):
""" Load and compile a template. """
if not path.startswith('/'):
for folder in self.options['template_folders']:
fullpath = op.join(folder, path)
if op.exists(fullpath):
path = fullpath
br... | python | def load_template(self, path):
""" Load and compile a template. """
if not path.startswith('/'):
for folder in self.options['template_folders']:
fullpath = op.join(folder, path)
if op.exists(fullpath):
path = fullpath
br... | [
"def",
"load_template",
"(",
"self",
",",
"path",
")",
":",
"if",
"not",
"path",
".",
"startswith",
"(",
"'/'",
")",
":",
"for",
"folder",
"in",
"self",
".",
"options",
"[",
"'template_folders'",
"]",
":",
"fullpath",
"=",
"op",
".",
"join",
"(",
"fo... | Load and compile a template. | [
"Load",
"and",
"compile",
"a",
"template",
"."
] | 3ddd6bf27fac03edc0bef3b0840bcd2e278babb3 | https://github.com/klen/muffin-jade/blob/3ddd6bf27fac03edc0bef3b0840bcd2e278babb3/muffin_jade.py#L142-L159 |
251,532 | pydsigner/taskit | taskit/common.py | FirstBytesProtocol.set_size | def set_size(self, data_size):
"""
Set the data slice size.
"""
if len(str(data_size)) > self.first:
raise ValueError(
'Send size is too large for message size-field width!')
self.data_size = data_size | python | def set_size(self, data_size):
"""
Set the data slice size.
"""
if len(str(data_size)) > self.first:
raise ValueError(
'Send size is too large for message size-field width!')
self.data_size = data_size | [
"def",
"set_size",
"(",
"self",
",",
"data_size",
")",
":",
"if",
"len",
"(",
"str",
"(",
"data_size",
")",
")",
">",
"self",
".",
"first",
":",
"raise",
"ValueError",
"(",
"'Send size is too large for message size-field width!'",
")",
"self",
".",
"data_size"... | Set the data slice size. | [
"Set",
"the",
"data",
"slice",
"size",
"."
] | 3b228e2dbac16b3b84b2581f5b46e027d1d8fa7f | https://github.com/pydsigner/taskit/blob/3b228e2dbac16b3b84b2581f5b46e027d1d8fa7f/taskit/common.py#L81-L89 |
251,533 | jldantas/libmft | parallel.py | MFT._is_related | def _is_related(parent_entry, child_entry):
'''This function checks if a child entry is related to the parent entry.
This is done by comparing the reference and sequence numbers.'''
if parent_entry.header.mft_record == child_entry.header.base_record_ref and \
parent_entry.header.seq_n... | python | def _is_related(parent_entry, child_entry):
'''This function checks if a child entry is related to the parent entry.
This is done by comparing the reference and sequence numbers.'''
if parent_entry.header.mft_record == child_entry.header.base_record_ref and \
parent_entry.header.seq_n... | [
"def",
"_is_related",
"(",
"parent_entry",
",",
"child_entry",
")",
":",
"if",
"parent_entry",
".",
"header",
".",
"mft_record",
"==",
"child_entry",
".",
"header",
".",
"base_record_ref",
"and",
"parent_entry",
".",
"header",
".",
"seq_number",
"==",
"child_ent... | This function checks if a child entry is related to the parent entry.
This is done by comparing the reference and sequence numbers. | [
"This",
"function",
"checks",
"if",
"a",
"child",
"entry",
"is",
"related",
"to",
"the",
"parent",
"entry",
".",
"This",
"is",
"done",
"by",
"comparing",
"the",
"reference",
"and",
"sequence",
"numbers",
"."
] | 65a988605fe7663b788bd81dcb52c0a4eaad1549 | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/parallel.py#L132-L139 |
251,534 | jldantas/libmft | parallel.py | MFT.load_mp | def load_mp(cls, file_pointer, _mft_config=None):
'''The initialization process takes a file like object "file_pointer"
and loads it in the internal structures. "use_cores" can be definied
if multiple cores are to be used. The "size" argument is the size
of the MFT entries. If not provid... | python | def load_mp(cls, file_pointer, _mft_config=None):
'''The initialization process takes a file like object "file_pointer"
and loads it in the internal structures. "use_cores" can be definied
if multiple cores are to be used. The "size" argument is the size
of the MFT entries. If not provid... | [
"def",
"load_mp",
"(",
"cls",
",",
"file_pointer",
",",
"_mft_config",
"=",
"None",
")",
":",
"import",
"multiprocessing",
"import",
"queue",
"mft_config",
"=",
"_mft_config",
"if",
"_mft_config",
"is",
"not",
"None",
"else",
"MFT",
".",
"mft_config",
"mft_ent... | The initialization process takes a file like object "file_pointer"
and loads it in the internal structures. "use_cores" can be definied
if multiple cores are to be used. The "size" argument is the size
of the MFT entries. If not provided, the class will try to auto detect
it. | [
"The",
"initialization",
"process",
"takes",
"a",
"file",
"like",
"object",
"file_pointer",
"and",
"loads",
"it",
"in",
"the",
"internal",
"structures",
".",
"use_cores",
"can",
"be",
"definied",
"if",
"multiple",
"cores",
"are",
"to",
"be",
"used",
".",
"Th... | 65a988605fe7663b788bd81dcb52c0a4eaad1549 | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/parallel.py#L142-L202 |
251,535 | ryanjdillon/pyotelem | pyotelem/dives.py | finddives2 | def finddives2(depths, min_dive_thresh=10):
'''Find dives in depth data below a minimum dive threshold
Args
----
depths: ndarray
Datalogger depth measurements
min_dive_thresh: float
Minimum depth threshold for which to classify a dive
Returns
-------
dives: ndarray
... | python | def finddives2(depths, min_dive_thresh=10):
'''Find dives in depth data below a minimum dive threshold
Args
----
depths: ndarray
Datalogger depth measurements
min_dive_thresh: float
Minimum depth threshold for which to classify a dive
Returns
-------
dives: ndarray
... | [
"def",
"finddives2",
"(",
"depths",
",",
"min_dive_thresh",
"=",
"10",
")",
":",
"import",
"numpy",
"import",
"pandas",
"from",
".",
"import",
"utils",
"# Get start and stop indices for each dive above `min_dive_thresh`",
"condition",
"=",
"depths",
">",
"min_dive_thres... | Find dives in depth data below a minimum dive threshold
Args
----
depths: ndarray
Datalogger depth measurements
min_dive_thresh: float
Minimum depth threshold for which to classify a dive
Returns
-------
dives: ndarray
Dive summary information in a numpy record arra... | [
"Find",
"dives",
"in",
"depth",
"data",
"below",
"a",
"minimum",
"dive",
"threshold"
] | 816563a9c3feb3fa416f1c2921c6b75db34111ad | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/dives.py#L2-L81 |
251,536 | ryanjdillon/pyotelem | pyotelem/dives.py | get_des_asc2 | def get_des_asc2(depths, dive_mask, pitch, cutoff, fs, order=5):
'''Get boolean masks of descents and ascents in the depth data
Args
----
dive_mask: ndarray
Boolean mask array over depth data. Cells with `True` are dives and
cells with `False` are not.
pitch: ndarray
Pitch a... | python | def get_des_asc2(depths, dive_mask, pitch, cutoff, fs, order=5):
'''Get boolean masks of descents and ascents in the depth data
Args
----
dive_mask: ndarray
Boolean mask array over depth data. Cells with `True` are dives and
cells with `False` are not.
pitch: ndarray
Pitch a... | [
"def",
"get_des_asc2",
"(",
"depths",
",",
"dive_mask",
",",
"pitch",
",",
"cutoff",
",",
"fs",
",",
"order",
"=",
"5",
")",
":",
"import",
"numpy",
"from",
".",
"import",
"dsp",
"asc_mask",
"=",
"numpy",
".",
"zeros",
"(",
"len",
"(",
"depths",
")",... | Get boolean masks of descents and ascents in the depth data
Args
----
dive_mask: ndarray
Boolean mask array over depth data. Cells with `True` are dives and
cells with `False` are not.
pitch: ndarray
Pitch angle in radians
cutoff: float
Cutoff frequency at which sign... | [
"Get",
"boolean",
"masks",
"of",
"descents",
"and",
"ascents",
"in",
"the",
"depth",
"data"
] | 816563a9c3feb3fa416f1c2921c6b75db34111ad | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/dives.py#L84-L126 |
251,537 | ryanjdillon/pyotelem | pyotelem/dives.py | rm_incomplete_des_asc | def rm_incomplete_des_asc(des_mask, asc_mask):
'''Remove descents-ascents that have no corresponding ascent-descent
Args
----
des_mask: ndarray
Boolean mask of descents in the depth data
asc_mask: ndarray
Boolean mask of ascents in the depth data
Returns
-------
des_mas... | python | def rm_incomplete_des_asc(des_mask, asc_mask):
'''Remove descents-ascents that have no corresponding ascent-descent
Args
----
des_mask: ndarray
Boolean mask of descents in the depth data
asc_mask: ndarray
Boolean mask of ascents in the depth data
Returns
-------
des_mas... | [
"def",
"rm_incomplete_des_asc",
"(",
"des_mask",
",",
"asc_mask",
")",
":",
"from",
".",
"import",
"utils",
"# Get start/stop indices for descents and ascents",
"des_start",
",",
"des_stop",
"=",
"utils",
".",
"contiguous_regions",
"(",
"des_mask",
")",
"asc_start",
"... | Remove descents-ascents that have no corresponding ascent-descent
Args
----
des_mask: ndarray
Boolean mask of descents in the depth data
asc_mask: ndarray
Boolean mask of ascents in the depth data
Returns
-------
des_mask: ndarray
Boolean mask of descents with erron... | [
"Remove",
"descents",
"-",
"ascents",
"that",
"have",
"no",
"corresponding",
"ascent",
"-",
"descent"
] | 816563a9c3feb3fa416f1c2921c6b75db34111ad | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/dives.py#L129-L155 |
251,538 | ryanjdillon/pyotelem | pyotelem/dives.py | get_bottom | def get_bottom(depths, des_mask, asc_mask):
'''Get boolean mask of regions in depths the animal is at the bottom
Args
----
des_mask: ndarray
Boolean mask of descents in the depth data
asc_mask: ndarray
Boolean mask of ascents in the depth data
Returns
-------
BOTTOM: nd... | python | def get_bottom(depths, des_mask, asc_mask):
'''Get boolean mask of regions in depths the animal is at the bottom
Args
----
des_mask: ndarray
Boolean mask of descents in the depth data
asc_mask: ndarray
Boolean mask of ascents in the depth data
Returns
-------
BOTTOM: nd... | [
"def",
"get_bottom",
"(",
"depths",
",",
"des_mask",
",",
"asc_mask",
")",
":",
"import",
"numpy",
"from",
".",
"import",
"utils",
"# Get start/stop indices for descents and ascents",
"des_start",
",",
"des_stop",
"=",
"utils",
".",
"contiguous_regions",
"(",
"des_m... | Get boolean mask of regions in depths the animal is at the bottom
Args
----
des_mask: ndarray
Boolean mask of descents in the depth data
asc_mask: ndarray
Boolean mask of ascents in the depth data
Returns
-------
BOTTOM: ndarray (n,4)
Indices and depths for when the... | [
"Get",
"boolean",
"mask",
"of",
"regions",
"in",
"depths",
"the",
"animal",
"is",
"at",
"the",
"bottom"
] | 816563a9c3feb3fa416f1c2921c6b75db34111ad | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/dives.py#L158-L207 |
251,539 | ryanjdillon/pyotelem | pyotelem/dives.py | get_phase | def get_phase(n_samples, des_mask, asc_mask):
'''Get the directional phase sign for each sample in depths
Args
----
n_samples: int
Length of output phase array
des_mask: numpy.ndarray, shape (n,)
Boolean mask of values where animal is descending
asc_mask: numpy.ndarray, shape(n,... | python | def get_phase(n_samples, des_mask, asc_mask):
'''Get the directional phase sign for each sample in depths
Args
----
n_samples: int
Length of output phase array
des_mask: numpy.ndarray, shape (n,)
Boolean mask of values where animal is descending
asc_mask: numpy.ndarray, shape(n,... | [
"def",
"get_phase",
"(",
"n_samples",
",",
"des_mask",
",",
"asc_mask",
")",
":",
"import",
"numpy",
"phase",
"=",
"numpy",
".",
"zeros",
"(",
"n_samples",
",",
"dtype",
"=",
"int",
")",
"phase",
"[",
"asc_mask",
"]",
"=",
"1",
"phase",
"[",
"des_mask"... | Get the directional phase sign for each sample in depths
Args
----
n_samples: int
Length of output phase array
des_mask: numpy.ndarray, shape (n,)
Boolean mask of values where animal is descending
asc_mask: numpy.ndarray, shape(n,)
Boolean mask of values where animal is asce... | [
"Get",
"the",
"directional",
"phase",
"sign",
"for",
"each",
"sample",
"in",
"depths"
] | 816563a9c3feb3fa416f1c2921c6b75db34111ad | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/dives.py#L210-L239 |
251,540 | alexhayes/django-toolkit | django_toolkit/file.py | tempfilename | def tempfilename(**kwargs):
"""
Reserve a temporary file for future use.
This is useful if you want to get a temporary file name, write to it in the
future and ensure that if an exception is thrown the temporary file is removed.
"""
kwargs.update(delete=False)
try:
f = NamedTemporar... | python | def tempfilename(**kwargs):
"""
Reserve a temporary file for future use.
This is useful if you want to get a temporary file name, write to it in the
future and ensure that if an exception is thrown the temporary file is removed.
"""
kwargs.update(delete=False)
try:
f = NamedTemporar... | [
"def",
"tempfilename",
"(",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"update",
"(",
"delete",
"=",
"False",
")",
"try",
":",
"f",
"=",
"NamedTemporaryFile",
"(",
"*",
"*",
"kwargs",
")",
"f",
".",
"close",
"(",
")",
"yield",
"f",
".",
"name",
... | Reserve a temporary file for future use.
This is useful if you want to get a temporary file name, write to it in the
future and ensure that if an exception is thrown the temporary file is removed. | [
"Reserve",
"a",
"temporary",
"file",
"for",
"future",
"use",
"."
] | b64106392fad596defc915b8235fe6e1d0013b5b | https://github.com/alexhayes/django-toolkit/blob/b64106392fad596defc915b8235fe6e1d0013b5b/django_toolkit/file.py#L37-L53 |
251,541 | alexhayes/django-toolkit | django_toolkit/file.py | makedirs | def makedirs(p):
"""
A makedirs that avoids a race conditions for multiple processes attempting to create the same directory.
"""
try:
os.makedirs(p, settings.FILE_UPLOAD_PERMISSIONS)
except OSError:
# Perhaps someone beat us to the punch?
if not os.path.isdir(p):
... | python | def makedirs(p):
"""
A makedirs that avoids a race conditions for multiple processes attempting to create the same directory.
"""
try:
os.makedirs(p, settings.FILE_UPLOAD_PERMISSIONS)
except OSError:
# Perhaps someone beat us to the punch?
if not os.path.isdir(p):
... | [
"def",
"makedirs",
"(",
"p",
")",
":",
"try",
":",
"os",
".",
"makedirs",
"(",
"p",
",",
"settings",
".",
"FILE_UPLOAD_PERMISSIONS",
")",
"except",
"OSError",
":",
"# Perhaps someone beat us to the punch?",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
... | A makedirs that avoids a race conditions for multiple processes attempting to create the same directory. | [
"A",
"makedirs",
"that",
"avoids",
"a",
"race",
"conditions",
"for",
"multiple",
"processes",
"attempting",
"to",
"create",
"the",
"same",
"directory",
"."
] | b64106392fad596defc915b8235fe6e1d0013b5b | https://github.com/alexhayes/django-toolkit/blob/b64106392fad596defc915b8235fe6e1d0013b5b/django_toolkit/file.py#L80-L90 |
251,542 | rorr73/LifeSOSpy | lifesospy/device.py | SpecialDevice.control_high_limit | def control_high_limit(self) -> Optional[Union[int, float]]:
"""
Control high limit setting for a special sensor.
For LS-10/LS-20 base units only.
"""
return self._get_field_value(SpecialDevice.PROP_CONTROL_HIGH_LIMIT) | python | def control_high_limit(self) -> Optional[Union[int, float]]:
"""
Control high limit setting for a special sensor.
For LS-10/LS-20 base units only.
"""
return self._get_field_value(SpecialDevice.PROP_CONTROL_HIGH_LIMIT) | [
"def",
"control_high_limit",
"(",
"self",
")",
"->",
"Optional",
"[",
"Union",
"[",
"int",
",",
"float",
"]",
"]",
":",
"return",
"self",
".",
"_get_field_value",
"(",
"SpecialDevice",
".",
"PROP_CONTROL_HIGH_LIMIT",
")"
] | Control high limit setting for a special sensor.
For LS-10/LS-20 base units only. | [
"Control",
"high",
"limit",
"setting",
"for",
"a",
"special",
"sensor",
"."
] | 62360fbab2e90bf04d52b547093bdab2d4e389b4 | https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/device.py#L344-L350 |
251,543 | rorr73/LifeSOSpy | lifesospy/device.py | SpecialDevice.control_low_limit | def control_low_limit(self) -> Optional[Union[int, float]]:
"""
Control low limit setting for a special sensor.
For LS-10/LS-20 base units only.
"""
return self._get_field_value(SpecialDevice.PROP_CONTROL_LOW_LIMIT) | python | def control_low_limit(self) -> Optional[Union[int, float]]:
"""
Control low limit setting for a special sensor.
For LS-10/LS-20 base units only.
"""
return self._get_field_value(SpecialDevice.PROP_CONTROL_LOW_LIMIT) | [
"def",
"control_low_limit",
"(",
"self",
")",
"->",
"Optional",
"[",
"Union",
"[",
"int",
",",
"float",
"]",
"]",
":",
"return",
"self",
".",
"_get_field_value",
"(",
"SpecialDevice",
".",
"PROP_CONTROL_LOW_LIMIT",
")"
] | Control low limit setting for a special sensor.
For LS-10/LS-20 base units only. | [
"Control",
"low",
"limit",
"setting",
"for",
"a",
"special",
"sensor",
"."
] | 62360fbab2e90bf04d52b547093bdab2d4e389b4 | https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/device.py#L365-L371 |
251,544 | rorr73/LifeSOSpy | lifesospy/device.py | SpecialDevice.current_reading | def current_reading(self) -> Optional[Union[int, float]]:
"""Current reading for a special sensor."""
return self._get_field_value(SpecialDevice.PROP_CURRENT_READING) | python | def current_reading(self) -> Optional[Union[int, float]]:
"""Current reading for a special sensor."""
return self._get_field_value(SpecialDevice.PROP_CURRENT_READING) | [
"def",
"current_reading",
"(",
"self",
")",
"->",
"Optional",
"[",
"Union",
"[",
"int",
",",
"float",
"]",
"]",
":",
"return",
"self",
".",
"_get_field_value",
"(",
"SpecialDevice",
".",
"PROP_CURRENT_READING",
")"
] | Current reading for a special sensor. | [
"Current",
"reading",
"for",
"a",
"special",
"sensor",
"."
] | 62360fbab2e90bf04d52b547093bdab2d4e389b4 | https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/device.py#L374-L376 |
251,545 | rorr73/LifeSOSpy | lifesospy/device.py | SpecialDevice.high_limit | def high_limit(self) -> Optional[Union[int, float]]:
"""
High limit setting for a special sensor.
For LS-10/LS-20 base units this is the alarm high limit.
For LS-30 base units, this is either alarm OR control high limit,
as indicated by special_status ControlAlarm bit flag.
... | python | def high_limit(self) -> Optional[Union[int, float]]:
"""
High limit setting for a special sensor.
For LS-10/LS-20 base units this is the alarm high limit.
For LS-30 base units, this is either alarm OR control high limit,
as indicated by special_status ControlAlarm bit flag.
... | [
"def",
"high_limit",
"(",
"self",
")",
"->",
"Optional",
"[",
"Union",
"[",
"int",
",",
"float",
"]",
"]",
":",
"return",
"self",
".",
"_get_field_value",
"(",
"SpecialDevice",
".",
"PROP_HIGH_LIMIT",
")"
] | High limit setting for a special sensor.
For LS-10/LS-20 base units this is the alarm high limit.
For LS-30 base units, this is either alarm OR control high limit,
as indicated by special_status ControlAlarm bit flag. | [
"High",
"limit",
"setting",
"for",
"a",
"special",
"sensor",
"."
] | 62360fbab2e90bf04d52b547093bdab2d4e389b4 | https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/device.py#L379-L387 |
251,546 | rorr73/LifeSOSpy | lifesospy/device.py | SpecialDevice.low_limit | def low_limit(self) -> Optional[Union[int, float]]:
"""
Low limit setting for a special sensor.
For LS-10/LS-20 base units this is the alarm low limit.
For LS-30 base units, this is either alarm OR control low limit,
as indicated by special_status ControlAlarm bit flag.
... | python | def low_limit(self) -> Optional[Union[int, float]]:
"""
Low limit setting for a special sensor.
For LS-10/LS-20 base units this is the alarm low limit.
For LS-30 base units, this is either alarm OR control low limit,
as indicated by special_status ControlAlarm bit flag.
... | [
"def",
"low_limit",
"(",
"self",
")",
"->",
"Optional",
"[",
"Union",
"[",
"int",
",",
"float",
"]",
"]",
":",
"return",
"self",
".",
"_get_field_value",
"(",
"SpecialDevice",
".",
"PROP_LOW_LIMIT",
")"
] | Low limit setting for a special sensor.
For LS-10/LS-20 base units this is the alarm low limit.
For LS-30 base units, this is either alarm OR control low limit,
as indicated by special_status ControlAlarm bit flag. | [
"Low",
"limit",
"setting",
"for",
"a",
"special",
"sensor",
"."
] | 62360fbab2e90bf04d52b547093bdab2d4e389b4 | https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/device.py#L390-L398 |
251,547 | rorr73/LifeSOSpy | lifesospy/device.py | DeviceCollection.get | def get(self, device_id: int) -> Optional[Device]:
"""Get device using the specified ID, or None if not found."""
return self._devices.get(device_id) | python | def get(self, device_id: int) -> Optional[Device]:
"""Get device using the specified ID, or None if not found."""
return self._devices.get(device_id) | [
"def",
"get",
"(",
"self",
",",
"device_id",
":",
"int",
")",
"->",
"Optional",
"[",
"Device",
"]",
":",
"return",
"self",
".",
"_devices",
".",
"get",
"(",
"device_id",
")"
] | Get device using the specified ID, or None if not found. | [
"Get",
"device",
"using",
"the",
"specified",
"ID",
"or",
"None",
"if",
"not",
"found",
"."
] | 62360fbab2e90bf04d52b547093bdab2d4e389b4 | https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/device.py#L511-L513 |
251,548 | coopie/ttv | ttv.py | make_ttv_yaml | def make_ttv_yaml(corpora, path_to_ttv_file, ttv_ratio=DEFAULT_TTV_RATIO, deterministic=False):
""" Create a test, train, validation from the corpora given and saves it as a YAML filename.
Each set will be subject independent, meaning that no one subject can have data in more than one
set
# Ar... | python | def make_ttv_yaml(corpora, path_to_ttv_file, ttv_ratio=DEFAULT_TTV_RATIO, deterministic=False):
""" Create a test, train, validation from the corpora given and saves it as a YAML filename.
Each set will be subject independent, meaning that no one subject can have data in more than one
set
# Ar... | [
"def",
"make_ttv_yaml",
"(",
"corpora",
",",
"path_to_ttv_file",
",",
"ttv_ratio",
"=",
"DEFAULT_TTV_RATIO",
",",
"deterministic",
"=",
"False",
")",
":",
"dataset",
"=",
"get_dataset",
"(",
"corpora",
")",
"data_sets",
"=",
"make_ttv",
"(",
"dataset",
",",
"t... | Create a test, train, validation from the corpora given and saves it as a YAML filename.
Each set will be subject independent, meaning that no one subject can have data in more than one
set
# Arguments;
corpora: a list of the paths to corpora used (these have to be formatted accoring to no... | [
"Create",
"a",
"test",
"train",
"validation",
"from",
"the",
"corpora",
"given",
"and",
"saves",
"it",
"as",
"a",
"YAML",
"filename",
"."
] | 43e2bcddf58945f27665d4db1362473842eb26f3 | https://github.com/coopie/ttv/blob/43e2bcddf58945f27665d4db1362473842eb26f3/ttv.py#L28-L65 |
251,549 | naphatkrit/easyci | easyci/user_config.py | load_user_config | def load_user_config(vcs):
"""Load the user config
Args:
vcs (easyci.vcs.base.Vcs) - the vcs object for the current project
Returns:
dict - the config
Raises:
ConfigFormatError
ConfigNotFoundError
"""
config_path = os.path.join(vcs.path, 'eci.yaml')
if not ... | python | def load_user_config(vcs):
"""Load the user config
Args:
vcs (easyci.vcs.base.Vcs) - the vcs object for the current project
Returns:
dict - the config
Raises:
ConfigFormatError
ConfigNotFoundError
"""
config_path = os.path.join(vcs.path, 'eci.yaml')
if not ... | [
"def",
"load_user_config",
"(",
"vcs",
")",
":",
"config_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"vcs",
".",
"path",
",",
"'eci.yaml'",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"config_path",
")",
":",
"raise",
"ConfigNotFoundE... | Load the user config
Args:
vcs (easyci.vcs.base.Vcs) - the vcs object for the current project
Returns:
dict - the config
Raises:
ConfigFormatError
ConfigNotFoundError | [
"Load",
"the",
"user",
"config"
] | 7aee8d7694fe4e2da42ce35b0f700bc840c8b95f | https://github.com/naphatkrit/easyci/blob/7aee8d7694fe4e2da42ce35b0f700bc840c8b95f/easyci/user_config.py#L27-L55 |
251,550 | jmgilman/Neolib | neolib/pyamf/remoting/gateway/__init__.py | expose_request | def expose_request(func):
"""
A decorator that adds an expose_request flag to the underlying callable.
@raise TypeError: C{func} must be callable.
"""
if not python.callable(func):
raise TypeError("func must be callable")
if isinstance(func, types.UnboundMethodType):
setattr(fu... | python | def expose_request(func):
"""
A decorator that adds an expose_request flag to the underlying callable.
@raise TypeError: C{func} must be callable.
"""
if not python.callable(func):
raise TypeError("func must be callable")
if isinstance(func, types.UnboundMethodType):
setattr(fu... | [
"def",
"expose_request",
"(",
"func",
")",
":",
"if",
"not",
"python",
".",
"callable",
"(",
"func",
")",
":",
"raise",
"TypeError",
"(",
"\"func must be callable\"",
")",
"if",
"isinstance",
"(",
"func",
",",
"types",
".",
"UnboundMethodType",
")",
":",
"... | A decorator that adds an expose_request flag to the underlying callable.
@raise TypeError: C{func} must be callable. | [
"A",
"decorator",
"that",
"adds",
"an",
"expose_request",
"flag",
"to",
"the",
"underlying",
"callable",
"."
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/gateway/__init__.py#L545-L559 |
251,551 | jmgilman/Neolib | neolib/pyamf/remoting/gateway/__init__.py | BaseGateway.addService | def addService(self, service, name=None, description=None,
authenticator=None, expose_request=None, preprocessor=None):
"""
Adds a service to the gateway.
@param service: The service to add to the gateway.
@type service: C{callable}, class instance, or a module
@param na... | python | def addService(self, service, name=None, description=None,
authenticator=None, expose_request=None, preprocessor=None):
"""
Adds a service to the gateway.
@param service: The service to add to the gateway.
@type service: C{callable}, class instance, or a module
@param na... | [
"def",
"addService",
"(",
"self",
",",
"service",
",",
"name",
"=",
"None",
",",
"description",
"=",
"None",
",",
"authenticator",
"=",
"None",
",",
"expose_request",
"=",
"None",
",",
"preprocessor",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"serv... | Adds a service to the gateway.
@param service: The service to add to the gateway.
@type service: C{callable}, class instance, or a module
@param name: The name of the service.
@type name: C{str}
@raise pyamf.remoting.RemotingError: Service already exists.
@raise TypeErro... | [
"Adds",
"a",
"service",
"to",
"the",
"gateway",
"."
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/gateway/__init__.py#L298-L335 |
251,552 | jmgilman/Neolib | neolib/pyamf/remoting/gateway/__init__.py | BaseGateway.removeService | def removeService(self, service):
"""
Removes a service from the gateway.
@param service: Either the name or t of the service to remove from the
gateway, or .
@type service: C{callable} or a class instance
@raise NameError: Service not found.
"""
... | python | def removeService(self, service):
"""
Removes a service from the gateway.
@param service: Either the name or t of the service to remove from the
gateway, or .
@type service: C{callable} or a class instance
@raise NameError: Service not found.
"""
... | [
"def",
"removeService",
"(",
"self",
",",
"service",
")",
":",
"for",
"name",
",",
"wrapper",
"in",
"self",
".",
"services",
".",
"iteritems",
"(",
")",
":",
"if",
"service",
"in",
"(",
"name",
",",
"wrapper",
".",
"service",
")",
":",
"del",
"self",... | Removes a service from the gateway.
@param service: Either the name or t of the service to remove from the
gateway, or .
@type service: C{callable} or a class instance
@raise NameError: Service not found. | [
"Removes",
"a",
"service",
"from",
"the",
"gateway",
"."
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/gateway/__init__.py#L346-L360 |
251,553 | jmgilman/Neolib | neolib/pyamf/remoting/gateway/__init__.py | BaseGateway.getServiceRequest | def getServiceRequest(self, request, target):
"""
Returns a service based on the message.
@raise UnknownServiceError: Unknown service.
@param request: The AMF request.
@type request: L{Request<pyamf.remoting.Request>}
@rtype: L{ServiceRequest}
"""
try:
... | python | def getServiceRequest(self, request, target):
"""
Returns a service based on the message.
@raise UnknownServiceError: Unknown service.
@param request: The AMF request.
@type request: L{Request<pyamf.remoting.Request>}
@rtype: L{ServiceRequest}
"""
try:
... | [
"def",
"getServiceRequest",
"(",
"self",
",",
"request",
",",
"target",
")",
":",
"try",
":",
"return",
"self",
".",
"_request_class",
"(",
"request",
".",
"envelope",
",",
"self",
".",
"services",
"[",
"target",
"]",
",",
"None",
")",
"except",
"KeyErro... | Returns a service based on the message.
@raise UnknownServiceError: Unknown service.
@param request: The AMF request.
@type request: L{Request<pyamf.remoting.Request>}
@rtype: L{ServiceRequest} | [
"Returns",
"a",
"service",
"based",
"on",
"the",
"message",
"."
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/gateway/__init__.py#L362-L386 |
251,554 | jmgilman/Neolib | neolib/pyamf/remoting/gateway/__init__.py | BaseGateway.getProcessor | def getProcessor(self, request):
"""
Returns request processor.
@param request: The AMF message.
@type request: L{Request<remoting.Request>}
"""
if request.target == 'null' or not request.target:
from pyamf.remoting import amf3
return amf3.Reques... | python | def getProcessor(self, request):
"""
Returns request processor.
@param request: The AMF message.
@type request: L{Request<remoting.Request>}
"""
if request.target == 'null' or not request.target:
from pyamf.remoting import amf3
return amf3.Reques... | [
"def",
"getProcessor",
"(",
"self",
",",
"request",
")",
":",
"if",
"request",
".",
"target",
"==",
"'null'",
"or",
"not",
"request",
".",
"target",
":",
"from",
"pyamf",
".",
"remoting",
"import",
"amf3",
"return",
"amf3",
".",
"RequestProcessor",
"(",
... | Returns request processor.
@param request: The AMF message.
@type request: L{Request<remoting.Request>} | [
"Returns",
"request",
"processor",
"."
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/gateway/__init__.py#L388-L402 |
251,555 | jmgilman/Neolib | neolib/pyamf/remoting/gateway/__init__.py | BaseGateway.mustExposeRequest | def mustExposeRequest(self, service_request):
"""
Decides whether the underlying http request should be exposed as the
first argument to the method call. This is granular, looking at the
service method first, then at the service level and finally checking
the gateway.
@r... | python | def mustExposeRequest(self, service_request):
"""
Decides whether the underlying http request should be exposed as the
first argument to the method call. This is granular, looking at the
service method first, then at the service level and finally checking
the gateway.
@r... | [
"def",
"mustExposeRequest",
"(",
"self",
",",
"service_request",
")",
":",
"expose_request",
"=",
"service_request",
".",
"service",
".",
"mustExposeRequest",
"(",
"service_request",
")",
"if",
"expose_request",
"is",
"None",
":",
"if",
"self",
".",
"expose_reques... | Decides whether the underlying http request should be exposed as the
first argument to the method call. This is granular, looking at the
service method first, then at the service level and finally checking
the gateway.
@rtype: C{bool} | [
"Decides",
"whether",
"the",
"underlying",
"http",
"request",
"should",
"be",
"exposed",
"as",
"the",
"first",
"argument",
"to",
"the",
"method",
"call",
".",
"This",
"is",
"granular",
"looking",
"at",
"the",
"service",
"method",
"first",
"then",
"at",
"the"... | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/gateway/__init__.py#L418-L435 |
251,556 | jmgilman/Neolib | neolib/pyamf/remoting/gateway/__init__.py | BaseGateway.callServiceRequest | def callServiceRequest(self, service_request, *args, **kwargs):
"""
Executes the service_request call
"""
if self.mustExposeRequest(service_request):
http_request = kwargs.get('http_request', None)
args = (http_request,) + args
return service_request(*arg... | python | def callServiceRequest(self, service_request, *args, **kwargs):
"""
Executes the service_request call
"""
if self.mustExposeRequest(service_request):
http_request = kwargs.get('http_request', None)
args = (http_request,) + args
return service_request(*arg... | [
"def",
"callServiceRequest",
"(",
"self",
",",
"service_request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"mustExposeRequest",
"(",
"service_request",
")",
":",
"http_request",
"=",
"kwargs",
".",
"get",
"(",
"'http_request'",... | Executes the service_request call | [
"Executes",
"the",
"service_request",
"call"
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/gateway/__init__.py#L505-L513 |
251,557 | jkenlooper/chill | src/chill/operate.py | node_input | def node_input():
"""
Get a valid node id from the user.
Return -1 if invalid
"""
try:
node = int(raw_input("Node id: "))
except ValueError:
node = INVALID_NODE
print 'invalid node id: %s' % node
return node | python | def node_input():
"""
Get a valid node id from the user.
Return -1 if invalid
"""
try:
node = int(raw_input("Node id: "))
except ValueError:
node = INVALID_NODE
print 'invalid node id: %s' % node
return node | [
"def",
"node_input",
"(",
")",
":",
"try",
":",
"node",
"=",
"int",
"(",
"raw_input",
"(",
"\"Node id: \"",
")",
")",
"except",
"ValueError",
":",
"node",
"=",
"INVALID_NODE",
"print",
"'invalid node id: %s'",
"%",
"node",
"return",
"node"
] | Get a valid node id from the user.
Return -1 if invalid | [
"Get",
"a",
"valid",
"node",
"id",
"from",
"the",
"user",
"."
] | 35360c17c2a3b769ecb5406c6dabcf4cc70bd76f | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/operate.py#L38-L49 |
251,558 | jkenlooper/chill | src/chill/operate.py | existing_node_input | def existing_node_input():
"""
Get an existing node id by name or id.
Return -1 if invalid
"""
input_from_user = raw_input("Existing node name or id: ")
node_id = INVALID_NODE
if not input_from_user:
return node_id
# int or str?
try:
parsed_input = int(input_from_u... | python | def existing_node_input():
"""
Get an existing node id by name or id.
Return -1 if invalid
"""
input_from_user = raw_input("Existing node name or id: ")
node_id = INVALID_NODE
if not input_from_user:
return node_id
# int or str?
try:
parsed_input = int(input_from_u... | [
"def",
"existing_node_input",
"(",
")",
":",
"input_from_user",
"=",
"raw_input",
"(",
"\"Existing node name or id: \"",
")",
"node_id",
"=",
"INVALID_NODE",
"if",
"not",
"input_from_user",
":",
"return",
"node_id",
"# int or str?",
"try",
":",
"parsed_input",
"=",
... | Get an existing node id by name or id.
Return -1 if invalid | [
"Get",
"an",
"existing",
"node",
"id",
"by",
"name",
"or",
"id",
"."
] | 35360c17c2a3b769ecb5406c6dabcf4cc70bd76f | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/operate.py#L51-L107 |
251,559 | jkenlooper/chill | src/chill/operate.py | render_value_for_node | def render_value_for_node(node_id):
"""
Wrap render_node for usage in operate scripts. Returns without template
rendered.
"""
value = None
result = []
try:
result = db.execute(text(fetch_query_string('select_node_from_id.sql')), node_id=node_id).fetchall()
except DatabaseError a... | python | def render_value_for_node(node_id):
"""
Wrap render_node for usage in operate scripts. Returns without template
rendered.
"""
value = None
result = []
try:
result = db.execute(text(fetch_query_string('select_node_from_id.sql')), node_id=node_id).fetchall()
except DatabaseError a... | [
"def",
"render_value_for_node",
"(",
"node_id",
")",
":",
"value",
"=",
"None",
"result",
"=",
"[",
"]",
"try",
":",
"result",
"=",
"db",
".",
"execute",
"(",
"text",
"(",
"fetch_query_string",
"(",
"'select_node_from_id.sql'",
")",
")",
",",
"node_id",
"=... | Wrap render_node for usage in operate scripts. Returns without template
rendered. | [
"Wrap",
"render_node",
"for",
"usage",
"in",
"operate",
"scripts",
".",
"Returns",
"without",
"template",
"rendered",
"."
] | 35360c17c2a3b769ecb5406c6dabcf4cc70bd76f | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/operate.py#L109-L125 |
251,560 | jkenlooper/chill | src/chill/operate.py | purge_collection | def purge_collection(keys):
"Recursive purge of nodes with name and id"
for key in keys:
m = re.match(r'(.*) \((\d+)\)', key)
name = m.group(1)
node_id = m.group(2)
value = render_value_for_node(node_id)
print 'remove node with name:{0} and id:{1}'.format(name, node_id)
... | python | def purge_collection(keys):
"Recursive purge of nodes with name and id"
for key in keys:
m = re.match(r'(.*) \((\d+)\)', key)
name = m.group(1)
node_id = m.group(2)
value = render_value_for_node(node_id)
print 'remove node with name:{0} and id:{1}'.format(name, node_id)
... | [
"def",
"purge_collection",
"(",
"keys",
")",
":",
"for",
"key",
"in",
"keys",
":",
"m",
"=",
"re",
".",
"match",
"(",
"r'(.*) \\((\\d+)\\)'",
",",
"key",
")",
"name",
"=",
"m",
".",
"group",
"(",
"1",
")",
"node_id",
"=",
"m",
".",
"group",
"(",
... | Recursive purge of nodes with name and id | [
"Recursive",
"purge",
"of",
"nodes",
"with",
"name",
"and",
"id"
] | 35360c17c2a3b769ecb5406c6dabcf4cc70bd76f | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/operate.py#L144-L155 |
251,561 | jkenlooper/chill | src/chill/operate.py | mode_new_collection | def mode_new_collection():
"""
Create a new collection of items with common attributes.
"""
print globals()['mode_new_collection'].__doc__
collection_name = raw_input("Collection name: ")
item_attr_list = []
collection_node_id = None
if collection_name:
collection_node_id = inse... | python | def mode_new_collection():
"""
Create a new collection of items with common attributes.
"""
print globals()['mode_new_collection'].__doc__
collection_name = raw_input("Collection name: ")
item_attr_list = []
collection_node_id = None
if collection_name:
collection_node_id = inse... | [
"def",
"mode_new_collection",
"(",
")",
":",
"print",
"globals",
"(",
")",
"[",
"'mode_new_collection'",
"]",
".",
"__doc__",
"collection_name",
"=",
"raw_input",
"(",
"\"Collection name: \"",
")",
"item_attr_list",
"=",
"[",
"]",
"collection_node_id",
"=",
"None"... | Create a new collection of items with common attributes. | [
"Create",
"a",
"new",
"collection",
"of",
"items",
"with",
"common",
"attributes",
"."
] | 35360c17c2a3b769ecb5406c6dabcf4cc70bd76f | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/operate.py#L259-L292 |
251,562 | jkenlooper/chill | src/chill/operate.py | mode_database_functions | def mode_database_functions():
"Select a function to perform from chill.database"
print globals()['mode_database_functions'].__doc__
selection = True
database_functions = [
'init_db',
'insert_node',
'insert_node_node',
'delete_node',
'select_n... | python | def mode_database_functions():
"Select a function to perform from chill.database"
print globals()['mode_database_functions'].__doc__
selection = True
database_functions = [
'init_db',
'insert_node',
'insert_node_node',
'delete_node',
'select_n... | [
"def",
"mode_database_functions",
"(",
")",
":",
"print",
"globals",
"(",
")",
"[",
"'mode_database_functions'",
"]",
".",
"__doc__",
"selection",
"=",
"True",
"database_functions",
"=",
"[",
"'init_db'",
",",
"'insert_node'",
",",
"'insert_node_node'",
",",
"'del... | Select a function to perform from chill.database | [
"Select",
"a",
"function",
"to",
"perform",
"from",
"chill",
".",
"database"
] | 35360c17c2a3b769ecb5406c6dabcf4cc70bd76f | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/operate.py#L295-L389 |
251,563 | jkenlooper/chill | src/chill/operate.py | operate_menu | def operate_menu():
"Select between these operations on the database"
selection = True
while selection:
print globals()['operate_menu'].__doc__
selection = select([
'chill.database functions',
'execute sql file',
'render_node',
'New collectio... | python | def operate_menu():
"Select between these operations on the database"
selection = True
while selection:
print globals()['operate_menu'].__doc__
selection = select([
'chill.database functions',
'execute sql file',
'render_node',
'New collectio... | [
"def",
"operate_menu",
"(",
")",
":",
"selection",
"=",
"True",
"while",
"selection",
":",
"print",
"globals",
"(",
")",
"[",
"'operate_menu'",
"]",
".",
"__doc__",
"selection",
"=",
"select",
"(",
"[",
"'chill.database functions'",
",",
"'execute sql file'",
... | Select between these operations on the database | [
"Select",
"between",
"these",
"operations",
"on",
"the",
"database"
] | 35360c17c2a3b769ecb5406c6dabcf4cc70bd76f | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/operate.py#L391-L481 |
251,564 | dossier/dossier.web | dossier/web/config.py | thread_local_property | def thread_local_property(name):
'''Creates a thread local ``property``.'''
name = '_thread_local_' + name
def fget(self):
try:
return getattr(self, name).value
except AttributeError:
return None
def fset(self, value):
getattr(self, name).value = value
... | python | def thread_local_property(name):
'''Creates a thread local ``property``.'''
name = '_thread_local_' + name
def fget(self):
try:
return getattr(self, name).value
except AttributeError:
return None
def fset(self, value):
getattr(self, name).value = value
... | [
"def",
"thread_local_property",
"(",
"name",
")",
":",
"name",
"=",
"'_thread_local_'",
"+",
"name",
"def",
"fget",
"(",
"self",
")",
":",
"try",
":",
"return",
"getattr",
"(",
"self",
",",
"name",
")",
".",
"value",
"except",
"AttributeError",
":",
"ret... | Creates a thread local ``property``. | [
"Creates",
"a",
"thread",
"local",
"property",
"."
] | 1cad1cce3c37d3a4e956abc710a2bc1afe16a092 | https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/web/config.py#L46-L59 |
251,565 | dossier/dossier.web | dossier/web/config.py | Config.kvlclient | def kvlclient(self):
'''Return a thread local ``kvlayer`` client.'''
if self._kvlclient is None:
self._kvlclient = kvlayer.client()
return self._kvlclient | python | def kvlclient(self):
'''Return a thread local ``kvlayer`` client.'''
if self._kvlclient is None:
self._kvlclient = kvlayer.client()
return self._kvlclient | [
"def",
"kvlclient",
"(",
"self",
")",
":",
"if",
"self",
".",
"_kvlclient",
"is",
"None",
":",
"self",
".",
"_kvlclient",
"=",
"kvlayer",
".",
"client",
"(",
")",
"return",
"self",
".",
"_kvlclient"
] | Return a thread local ``kvlayer`` client. | [
"Return",
"a",
"thread",
"local",
"kvlayer",
"client",
"."
] | 1cad1cce3c37d3a4e956abc710a2bc1afe16a092 | https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/web/config.py#L132-L136 |
251,566 | alexgorin/pymar | pymar/producer.py | Producer.divide | def divide(self, data_source_factory):
"""Divides the task according to the number of workers."""
data_length = data_source_factory.length()
data_interval_length = data_length / self.workers_number() + 1
current_index = 0
self.responses = []
while current_index < data_le... | python | def divide(self, data_source_factory):
"""Divides the task according to the number of workers."""
data_length = data_source_factory.length()
data_interval_length = data_length / self.workers_number() + 1
current_index = 0
self.responses = []
while current_index < data_le... | [
"def",
"divide",
"(",
"self",
",",
"data_source_factory",
")",
":",
"data_length",
"=",
"data_source_factory",
".",
"length",
"(",
")",
"data_interval_length",
"=",
"data_length",
"/",
"self",
".",
"workers_number",
"(",
")",
"+",
"1",
"current_index",
"=",
"0... | Divides the task according to the number of workers. | [
"Divides",
"the",
"task",
"according",
"to",
"the",
"number",
"of",
"workers",
"."
] | 39cd029ea6ff135a6400af2114658166dd6f4ae6 | https://github.com/alexgorin/pymar/blob/39cd029ea6ff135a6400af2114658166dd6f4ae6/pymar/producer.py#L89-L101 |
251,567 | alexgorin/pymar | pymar/producer.py | Producer.map | def map(self, data_source_factory, timeout=0, on_timeout="local_mode"):
"""Sends tasks to workers and awaits the responses.
When all the responses are received, reduces them and returns the result.
If timeout is set greater than 0, producer will quit waiting for workers when time has passed.
... | python | def map(self, data_source_factory, timeout=0, on_timeout="local_mode"):
"""Sends tasks to workers and awaits the responses.
When all the responses are received, reduces them and returns the result.
If timeout is set greater than 0, producer will quit waiting for workers when time has passed.
... | [
"def",
"map",
"(",
"self",
",",
"data_source_factory",
",",
"timeout",
"=",
"0",
",",
"on_timeout",
"=",
"\"local_mode\"",
")",
":",
"def",
"local_launch",
"(",
")",
":",
"print",
"\"Local launch\"",
"return",
"self",
".",
"reduce_fn",
"(",
"self",
".",
"m... | Sends tasks to workers and awaits the responses.
When all the responses are received, reduces them and returns the result.
If timeout is set greater than 0, producer will quit waiting for workers when time has passed.
If on_timeout is set to "local_mode", after the time limit producer will run ... | [
"Sends",
"tasks",
"to",
"workers",
"and",
"awaits",
"the",
"responses",
".",
"When",
"all",
"the",
"responses",
"are",
"received",
"reduces",
"them",
"and",
"returns",
"the",
"result",
"."
] | 39cd029ea6ff135a6400af2114658166dd6f4ae6 | https://github.com/alexgorin/pymar/blob/39cd029ea6ff135a6400af2114658166dd6f4ae6/pymar/producer.py#L103-L156 |
251,568 | corydodt/Crosscap | crosscap/openapi.py | _orderedCleanDict | def _orderedCleanDict(attrsObj):
"""
-> dict with false-values removed
Also evaluates attr-instances for false-ness by looking at the values of their properties
"""
def _filt(k, v):
if attr.has(v):
return not not any(attr.astuple(v))
return not not v
return attr.asd... | python | def _orderedCleanDict(attrsObj):
"""
-> dict with false-values removed
Also evaluates attr-instances for false-ness by looking at the values of their properties
"""
def _filt(k, v):
if attr.has(v):
return not not any(attr.astuple(v))
return not not v
return attr.asd... | [
"def",
"_orderedCleanDict",
"(",
"attrsObj",
")",
":",
"def",
"_filt",
"(",
"k",
",",
"v",
")",
":",
"if",
"attr",
".",
"has",
"(",
"v",
")",
":",
"return",
"not",
"not",
"any",
"(",
"attr",
".",
"astuple",
"(",
"v",
")",
")",
"return",
"not",
... | -> dict with false-values removed
Also evaluates attr-instances for false-ness by looking at the values of their properties | [
"-",
">",
"dict",
"with",
"false",
"-",
"values",
"removed"
] | 388a2ec36b8aa85e8f1ed692bb6e43474ba76c8e | https://github.com/corydodt/Crosscap/blob/388a2ec36b8aa85e8f1ed692bb6e43474ba76c8e/crosscap/openapi.py#L124-L138 |
251,569 | corydodt/Crosscap | crosscap/openapi.py | representCleanOpenAPIOperation | def representCleanOpenAPIOperation(dumper, data):
"""
Unpack nonstandard attributes while representing an OpenAPIOperation
"""
dct = _orderedCleanDict(data)
if '_extended' in dct:
for k, ext in list(data._extended.items()):
dct[k] = ext
del dct['_extended']
return du... | python | def representCleanOpenAPIOperation(dumper, data):
"""
Unpack nonstandard attributes while representing an OpenAPIOperation
"""
dct = _orderedCleanDict(data)
if '_extended' in dct:
for k, ext in list(data._extended.items()):
dct[k] = ext
del dct['_extended']
return du... | [
"def",
"representCleanOpenAPIOperation",
"(",
"dumper",
",",
"data",
")",
":",
"dct",
"=",
"_orderedCleanDict",
"(",
"data",
")",
"if",
"'_extended'",
"in",
"dct",
":",
"for",
"k",
",",
"ext",
"in",
"list",
"(",
"data",
".",
"_extended",
".",
"items",
"(... | Unpack nonstandard attributes while representing an OpenAPIOperation | [
"Unpack",
"nonstandard",
"attributes",
"while",
"representing",
"an",
"OpenAPIOperation"
] | 388a2ec36b8aa85e8f1ed692bb6e43474ba76c8e | https://github.com/corydodt/Crosscap/blob/388a2ec36b8aa85e8f1ed692bb6e43474ba76c8e/crosscap/openapi.py#L141-L151 |
251,570 | corydodt/Crosscap | crosscap/openapi.py | representCleanOpenAPIParameter | def representCleanOpenAPIParameter(dumper, data):
"""
Rename python reserved keyword fields before representing an OpenAPIParameter
"""
dct = _orderedCleanDict(data)
# We are using "in_" as a key for the "in" parameter, since in is a Python keyword.
# To represent it correctly, we then have to s... | python | def representCleanOpenAPIParameter(dumper, data):
"""
Rename python reserved keyword fields before representing an OpenAPIParameter
"""
dct = _orderedCleanDict(data)
# We are using "in_" as a key for the "in" parameter, since in is a Python keyword.
# To represent it correctly, we then have to s... | [
"def",
"representCleanOpenAPIParameter",
"(",
"dumper",
",",
"data",
")",
":",
"dct",
"=",
"_orderedCleanDict",
"(",
"data",
")",
"# We are using \"in_\" as a key for the \"in\" parameter, since in is a Python keyword.",
"# To represent it correctly, we then have to swap \"in_\" for \"... | Rename python reserved keyword fields before representing an OpenAPIParameter | [
"Rename",
"python",
"reserved",
"keyword",
"fields",
"before",
"representing",
"an",
"OpenAPIParameter"
] | 388a2ec36b8aa85e8f1ed692bb6e43474ba76c8e | https://github.com/corydodt/Crosscap/blob/388a2ec36b8aa85e8f1ed692bb6e43474ba76c8e/crosscap/openapi.py#L168-L184 |
251,571 | corydodt/Crosscap | crosscap/openapi.py | representCleanOpenAPIObjects | def representCleanOpenAPIObjects(dumper, data):
"""
Produce a representation of an OpenAPI object, removing empty attributes
"""
dct = _orderedCleanDict(data)
return dumper.yaml_representers[type(dct)](dumper, dct) | python | def representCleanOpenAPIObjects(dumper, data):
"""
Produce a representation of an OpenAPI object, removing empty attributes
"""
dct = _orderedCleanDict(data)
return dumper.yaml_representers[type(dct)](dumper, dct) | [
"def",
"representCleanOpenAPIObjects",
"(",
"dumper",
",",
"data",
")",
":",
"dct",
"=",
"_orderedCleanDict",
"(",
"data",
")",
"return",
"dumper",
".",
"yaml_representers",
"[",
"type",
"(",
"dct",
")",
"]",
"(",
"dumper",
",",
"dct",
")"
] | Produce a representation of an OpenAPI object, removing empty attributes | [
"Produce",
"a",
"representation",
"of",
"an",
"OpenAPI",
"object",
"removing",
"empty",
"attributes"
] | 388a2ec36b8aa85e8f1ed692bb6e43474ba76c8e | https://github.com/corydodt/Crosscap/blob/388a2ec36b8aa85e8f1ed692bb6e43474ba76c8e/crosscap/openapi.py#L187-L193 |
251,572 | corydodt/Crosscap | crosscap/openapi.py | mediaTypeHelper | def mediaTypeHelper(mediaType):
"""
Return a function that creates a Responses object;
"""
def _innerHelper(data=None):
"""
Create a Responses object that contains a MediaType entry of the specified mediaType
Convenience function for the most common cases where you need an insta... | python | def mediaTypeHelper(mediaType):
"""
Return a function that creates a Responses object;
"""
def _innerHelper(data=None):
"""
Create a Responses object that contains a MediaType entry of the specified mediaType
Convenience function for the most common cases where you need an insta... | [
"def",
"mediaTypeHelper",
"(",
"mediaType",
")",
":",
"def",
"_innerHelper",
"(",
"data",
"=",
"None",
")",
":",
"\"\"\"\n Create a Responses object that contains a MediaType entry of the specified mediaType\n\n Convenience function for the most common cases where you need ... | Return a function that creates a Responses object; | [
"Return",
"a",
"function",
"that",
"creates",
"a",
"Responses",
"object",
";"
] | 388a2ec36b8aa85e8f1ed692bb6e43474ba76c8e | https://github.com/corydodt/Crosscap/blob/388a2ec36b8aa85e8f1ed692bb6e43474ba76c8e/crosscap/openapi.py#L196-L211 |
251,573 | etcher-be/elib_config | elib_config/_file/_config_file.py | _ensure_config_file_exists | def _ensure_config_file_exists():
"""
Makes sure the config file exists.
:raises: :class:`epab.core.new_config.exc.ConfigFileNotFoundError`
"""
config_file = Path(ELIBConfig.config_file_path).absolute()
if not config_file.exists():
raise ConfigFileNotFoundError(ELIBConfig.config_file_pa... | python | def _ensure_config_file_exists():
"""
Makes sure the config file exists.
:raises: :class:`epab.core.new_config.exc.ConfigFileNotFoundError`
"""
config_file = Path(ELIBConfig.config_file_path).absolute()
if not config_file.exists():
raise ConfigFileNotFoundError(ELIBConfig.config_file_pa... | [
"def",
"_ensure_config_file_exists",
"(",
")",
":",
"config_file",
"=",
"Path",
"(",
"ELIBConfig",
".",
"config_file_path",
")",
".",
"absolute",
"(",
")",
"if",
"not",
"config_file",
".",
"exists",
"(",
")",
":",
"raise",
"ConfigFileNotFoundError",
"(",
"ELIB... | Makes sure the config file exists.
:raises: :class:`epab.core.new_config.exc.ConfigFileNotFoundError` | [
"Makes",
"sure",
"the",
"config",
"file",
"exists",
"."
] | 5d8c839e84d70126620ab0186dc1f717e5868bd0 | https://github.com/etcher-be/elib_config/blob/5d8c839e84d70126620ab0186dc1f717e5868bd0/elib_config/_file/_config_file.py#L21-L29 |
251,574 | jenanwise/codequality | codequality/main.py | CodeQuality._relevant_checkers | def _relevant_checkers(self, path):
"""
Get set of checkers for the given path.
TODO: currently this is based off the file extension. We would like to
honor magic bits as well, so that python binaries, shell scripts, etc
but we're not guaranteed that `path` currently exists on ... | python | def _relevant_checkers(self, path):
"""
Get set of checkers for the given path.
TODO: currently this is based off the file extension. We would like to
honor magic bits as well, so that python binaries, shell scripts, etc
but we're not guaranteed that `path` currently exists on ... | [
"def",
"_relevant_checkers",
"(",
"self",
",",
"path",
")",
":",
"_",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"path",
")",
"ext",
"=",
"ext",
".",
"lstrip",
"(",
"'.'",
")",
"return",
"checkers",
".",
"checkers",
".",
"get",
"(",
... | Get set of checkers for the given path.
TODO: currently this is based off the file extension. We would like to
honor magic bits as well, so that python binaries, shell scripts, etc
but we're not guaranteed that `path` currently exists on the filesystem
-- e.g. when version control for ... | [
"Get",
"set",
"of",
"checkers",
"for",
"the",
"given",
"path",
"."
] | 8a2bd767fd73091c49a5318fdbfb2b4fff77533d | https://github.com/jenanwise/codequality/blob/8a2bd767fd73091c49a5318fdbfb2b4fff77533d/codequality/main.py#L139-L150 |
251,575 | jenanwise/codequality | codequality/main.py | CodeQuality._list_checkers | def _list_checkers(self):
"""
Print information about checkers and their external tools.
Currently only works properly on systems with the `which` tool
available.
"""
classes = set()
for checker_group in checkers.checkers.itervalues():
for checker in ... | python | def _list_checkers(self):
"""
Print information about checkers and their external tools.
Currently only works properly on systems with the `which` tool
available.
"""
classes = set()
for checker_group in checkers.checkers.itervalues():
for checker in ... | [
"def",
"_list_checkers",
"(",
"self",
")",
":",
"classes",
"=",
"set",
"(",
")",
"for",
"checker_group",
"in",
"checkers",
".",
"checkers",
".",
"itervalues",
"(",
")",
":",
"for",
"checker",
"in",
"checker_group",
":",
"classes",
".",
"add",
"(",
"check... | Print information about checkers and their external tools.
Currently only works properly on systems with the `which` tool
available. | [
"Print",
"information",
"about",
"checkers",
"and",
"their",
"external",
"tools",
"."
] | 8a2bd767fd73091c49a5318fdbfb2b4fff77533d | https://github.com/jenanwise/codequality/blob/8a2bd767fd73091c49a5318fdbfb2b4fff77533d/codequality/main.py#L176-L201 |
251,576 | jenanwise/codequality | codequality/main.py | CodeQuality._should_ignore | def _should_ignore(self, path):
"""
Return True iff path should be ignored.
"""
for ignore in self.options.ignores:
if fnmatch.fnmatch(path, ignore):
return True
return False | python | def _should_ignore(self, path):
"""
Return True iff path should be ignored.
"""
for ignore in self.options.ignores:
if fnmatch.fnmatch(path, ignore):
return True
return False | [
"def",
"_should_ignore",
"(",
"self",
",",
"path",
")",
":",
"for",
"ignore",
"in",
"self",
".",
"options",
".",
"ignores",
":",
"if",
"fnmatch",
".",
"fnmatch",
"(",
"path",
",",
"ignore",
")",
":",
"return",
"True",
"return",
"False"
] | Return True iff path should be ignored. | [
"Return",
"True",
"iff",
"path",
"should",
"be",
"ignored",
"."
] | 8a2bd767fd73091c49a5318fdbfb2b4fff77533d | https://github.com/jenanwise/codequality/blob/8a2bd767fd73091c49a5318fdbfb2b4fff77533d/codequality/main.py#L203-L210 |
251,577 | knagra/farnsworth | legacy/views.py | legacy_notes_view | def legacy_notes_view(request):
"""
View to see legacy notes.
"""
notes = TeacherNote.objects.all()
note_count = notes.count()
paginator = Paginator(notes, 100)
page = request.GET.get('page')
try:
notes = paginator.page(page)
except PageNotAnInteger:
notes = paginato... | python | def legacy_notes_view(request):
"""
View to see legacy notes.
"""
notes = TeacherNote.objects.all()
note_count = notes.count()
paginator = Paginator(notes, 100)
page = request.GET.get('page')
try:
notes = paginator.page(page)
except PageNotAnInteger:
notes = paginato... | [
"def",
"legacy_notes_view",
"(",
"request",
")",
":",
"notes",
"=",
"TeacherNote",
".",
"objects",
".",
"all",
"(",
")",
"note_count",
"=",
"notes",
".",
"count",
"(",
")",
"paginator",
"=",
"Paginator",
"(",
"notes",
",",
"100",
")",
"page",
"=",
"req... | View to see legacy notes. | [
"View",
"to",
"see",
"legacy",
"notes",
"."
] | 1b6589f0d9fea154f0a1e2231ed906764ed26d26 | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/legacy/views.py#L69-L90 |
251,578 | knagra/farnsworth | legacy/views.py | legacy_events_view | def legacy_events_view(request):
"""
View to see legacy events.
"""
events = TeacherEvent.objects.all()
event_count = events.count()
paginator = Paginator(events, 100)
page = request.GET.get('page')
try:
events = paginator.page(page)
except PageNotAnInteger:
events =... | python | def legacy_events_view(request):
"""
View to see legacy events.
"""
events = TeacherEvent.objects.all()
event_count = events.count()
paginator = Paginator(events, 100)
page = request.GET.get('page')
try:
events = paginator.page(page)
except PageNotAnInteger:
events =... | [
"def",
"legacy_events_view",
"(",
"request",
")",
":",
"events",
"=",
"TeacherEvent",
".",
"objects",
".",
"all",
"(",
")",
"event_count",
"=",
"events",
".",
"count",
"(",
")",
"paginator",
"=",
"Paginator",
"(",
"events",
",",
"100",
")",
"page",
"=",
... | View to see legacy events. | [
"View",
"to",
"see",
"legacy",
"events",
"."
] | 1b6589f0d9fea154f0a1e2231ed906764ed26d26 | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/legacy/views.py#L93-L114 |
251,579 | knagra/farnsworth | legacy/views.py | legacy_requests_view | def legacy_requests_view(request, rtype):
"""
View to see legacy requests of rtype request type, which should be either
'food' or 'maintenance'.
"""
if not rtype in ['food', 'maintenance']:
raise Http404
requests_dict = [] # [(req, [req_responses]), (req2, [req2_responses]), ...]
req... | python | def legacy_requests_view(request, rtype):
"""
View to see legacy requests of rtype request type, which should be either
'food' or 'maintenance'.
"""
if not rtype in ['food', 'maintenance']:
raise Http404
requests_dict = [] # [(req, [req_responses]), (req2, [req2_responses]), ...]
req... | [
"def",
"legacy_requests_view",
"(",
"request",
",",
"rtype",
")",
":",
"if",
"not",
"rtype",
"in",
"[",
"'food'",
",",
"'maintenance'",
"]",
":",
"raise",
"Http404",
"requests_dict",
"=",
"[",
"]",
"# [(req, [req_responses]), (req2, [req2_responses]), ...]",
"reques... | View to see legacy requests of rtype request type, which should be either
'food' or 'maintenance'. | [
"View",
"to",
"see",
"legacy",
"requests",
"of",
"rtype",
"request",
"type",
"which",
"should",
"be",
"either",
"food",
"or",
"maintenance",
"."
] | 1b6589f0d9fea154f0a1e2231ed906764ed26d26 | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/legacy/views.py#L117-L148 |
251,580 | fstab50/metal | metal/bash_init.py | run_command_orig | def run_command_orig(cmd):
""" No idea how th f to get this to work """
process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = process.communicate()
if process.returncode == 0:
os.killpg(os.getpgid(pro.pid), signal.SIGTERM)
else:
... | python | def run_command_orig(cmd):
""" No idea how th f to get this to work """
process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = process.communicate()
if process.returncode == 0:
os.killpg(os.getpgid(pro.pid), signal.SIGTERM)
else:
... | [
"def",
"run_command_orig",
"(",
"cmd",
")",
":",
"process",
"=",
"subprocess",
".",
"Popen",
"(",
"cmd",
",",
"shell",
"=",
"True",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
",",
"stderr",
"=",
"subprocess",
".",
"PIPE",
")",
"stdout",
",",
"stder... | No idea how th f to get this to work | [
"No",
"idea",
"how",
"th",
"f",
"to",
"get",
"this",
"to",
"work"
] | 0488bbdd516a508909267cc44191f632e21156ba | https://github.com/fstab50/metal/blob/0488bbdd516a508909267cc44191f632e21156ba/metal/bash_init.py#L12-L20 |
251,581 | tBaxter/django-fretboard | fretboard/models.py | Topic.page_count | def page_count(self):
"""
Get count of total pages
"""
postcount = self.post_set.count()
max_pages = (postcount / get_paginate_by())
if postcount % get_paginate_by() != 0:
max_pages += 1
return max_pages | python | def page_count(self):
"""
Get count of total pages
"""
postcount = self.post_set.count()
max_pages = (postcount / get_paginate_by())
if postcount % get_paginate_by() != 0:
max_pages += 1
return max_pages | [
"def",
"page_count",
"(",
"self",
")",
":",
"postcount",
"=",
"self",
".",
"post_set",
".",
"count",
"(",
")",
"max_pages",
"=",
"(",
"postcount",
"/",
"get_paginate_by",
"(",
")",
")",
"if",
"postcount",
"%",
"get_paginate_by",
"(",
")",
"!=",
"0",
":... | Get count of total pages | [
"Get",
"count",
"of",
"total",
"pages"
] | 3c3f9557089821283f315a07f3e5a57a2725ab3b | https://github.com/tBaxter/django-fretboard/blob/3c3f9557089821283f315a07f3e5a57a2725ab3b/fretboard/models.py#L167-L175 |
251,582 | tBaxter/django-fretboard | fretboard/models.py | Topic.get_image | def get_image(self):
"""
Gets first image from post set.
"""
posts_with_images = self.post_set.filter(image__gt='')
if posts_with_images:
return posts_with_images[0].image | python | def get_image(self):
"""
Gets first image from post set.
"""
posts_with_images = self.post_set.filter(image__gt='')
if posts_with_images:
return posts_with_images[0].image | [
"def",
"get_image",
"(",
"self",
")",
":",
"posts_with_images",
"=",
"self",
".",
"post_set",
".",
"filter",
"(",
"image__gt",
"=",
"''",
")",
"if",
"posts_with_images",
":",
"return",
"posts_with_images",
"[",
"0",
"]",
".",
"image"
] | Gets first image from post set. | [
"Gets",
"first",
"image",
"from",
"post",
"set",
"."
] | 3c3f9557089821283f315a07f3e5a57a2725ab3b | https://github.com/tBaxter/django-fretboard/blob/3c3f9557089821283f315a07f3e5a57a2725ab3b/fretboard/models.py#L192-L198 |
251,583 | tBaxter/django-fretboard | fretboard/models.py | Post.post_url | def post_url(self):
"""
Determine which page this post lives on within the topic
and return link to anchor within that page
"""
topic = self.topic
topic_page = topic.post_set.filter(id__lt=self.id).count() / get_paginate_by() + 1
return "{0}page{1}/#post-{2... | python | def post_url(self):
"""
Determine which page this post lives on within the topic
and return link to anchor within that page
"""
topic = self.topic
topic_page = topic.post_set.filter(id__lt=self.id).count() / get_paginate_by() + 1
return "{0}page{1}/#post-{2... | [
"def",
"post_url",
"(",
"self",
")",
":",
"topic",
"=",
"self",
".",
"topic",
"topic_page",
"=",
"topic",
".",
"post_set",
".",
"filter",
"(",
"id__lt",
"=",
"self",
".",
"id",
")",
".",
"count",
"(",
")",
"/",
"get_paginate_by",
"(",
")",
"+",
"1"... | Determine which page this post lives on within the topic
and return link to anchor within that page | [
"Determine",
"which",
"page",
"this",
"post",
"lives",
"on",
"within",
"the",
"topic",
"and",
"return",
"link",
"to",
"anchor",
"within",
"that",
"page"
] | 3c3f9557089821283f315a07f3e5a57a2725ab3b | https://github.com/tBaxter/django-fretboard/blob/3c3f9557089821283f315a07f3e5a57a2725ab3b/fretboard/models.py#L232-L239 |
251,584 | laysakura/relshell | relshell/record.py | Record.next | def next(self):
"""Return a column one by one
:raises: StopIteration
"""
if self._cur_col >= len(self._rec):
self._cur_col = 0
raise StopIteration
col = self._rec[self._cur_col]
self._cur_col += 1
return col | python | def next(self):
"""Return a column one by one
:raises: StopIteration
"""
if self._cur_col >= len(self._rec):
self._cur_col = 0
raise StopIteration
col = self._rec[self._cur_col]
self._cur_col += 1
return col | [
"def",
"next",
"(",
"self",
")",
":",
"if",
"self",
".",
"_cur_col",
">=",
"len",
"(",
"self",
".",
"_rec",
")",
":",
"self",
".",
"_cur_col",
"=",
"0",
"raise",
"StopIteration",
"col",
"=",
"self",
".",
"_rec",
"[",
"self",
".",
"_cur_col",
"]",
... | Return a column one by one
:raises: StopIteration | [
"Return",
"a",
"column",
"one",
"by",
"one"
] | 9ca5c03a34c11cb763a4a75595f18bf4383aa8cc | https://github.com/laysakura/relshell/blob/9ca5c03a34c11cb763a4a75595f18bf4383aa8cc/relshell/record.py#L42-L52 |
251,585 | edeposit/edeposit.amqp.aleph | src/edeposit/amqp/aleph/datastructures/semanticinfo.py | _parse_summaryRecordSysNumber | def _parse_summaryRecordSysNumber(summaryRecordSysNumber):
"""
Try to parse vague, not likely machine-readable description and return
first token, which contains enough numbers in it.
"""
def number_of_digits(token):
digits = filter(lambda x: x.isdigit(), token)
return len(digits)
... | python | def _parse_summaryRecordSysNumber(summaryRecordSysNumber):
"""
Try to parse vague, not likely machine-readable description and return
first token, which contains enough numbers in it.
"""
def number_of_digits(token):
digits = filter(lambda x: x.isdigit(), token)
return len(digits)
... | [
"def",
"_parse_summaryRecordSysNumber",
"(",
"summaryRecordSysNumber",
")",
":",
"def",
"number_of_digits",
"(",
"token",
")",
":",
"digits",
"=",
"filter",
"(",
"lambda",
"x",
":",
"x",
".",
"isdigit",
"(",
")",
",",
"token",
")",
"return",
"len",
"(",
"d... | Try to parse vague, not likely machine-readable description and return
first token, which contains enough numbers in it. | [
"Try",
"to",
"parse",
"vague",
"not",
"likely",
"machine",
"-",
"readable",
"description",
"and",
"return",
"first",
"token",
"which",
"contains",
"enough",
"numbers",
"in",
"it",
"."
] | 360342c0504d5daa2344e864762cdf938d4149c7 | https://github.com/edeposit/edeposit.amqp.aleph/blob/360342c0504d5daa2344e864762cdf938d4149c7/src/edeposit/amqp/aleph/datastructures/semanticinfo.py#L19-L39 |
251,586 | markmuetz/commandify | commandify/commandify.py | commandify | def commandify(use_argcomplete=False, exit=True, *args, **kwargs):
'''Turns decorated functions into command line args
Finds the main_command and all commands and generates command line args
from these.'''
parser = CommandifyArgumentParser(*args, **kwargs)
parser.setup_arguments()
if use_argcom... | python | def commandify(use_argcomplete=False, exit=True, *args, **kwargs):
'''Turns decorated functions into command line args
Finds the main_command and all commands and generates command line args
from these.'''
parser = CommandifyArgumentParser(*args, **kwargs)
parser.setup_arguments()
if use_argcom... | [
"def",
"commandify",
"(",
"use_argcomplete",
"=",
"False",
",",
"exit",
"=",
"True",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"parser",
"=",
"CommandifyArgumentParser",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"parser",
".",
"setup_a... | Turns decorated functions into command line args
Finds the main_command and all commands and generates command line args
from these. | [
"Turns",
"decorated",
"functions",
"into",
"command",
"line",
"args"
] | 2f836caca06fbee80a43ca1ceee22376f63ec4d1 | https://github.com/markmuetz/commandify/blob/2f836caca06fbee80a43ca1ceee22376f63ec4d1/commandify/commandify.py#L245-L265 |
251,587 | markmuetz/commandify | commandify/commandify.py | CommandifyArgumentParser._get_command_args | def _get_command_args(self, command, args):
'''Work out the command arguments for a given command'''
command_args = {}
command_argument_names =\
command.__code__.co_varnames[:command.__code__.co_argcount]
for varname in command_argument_names:
if varname == 'args... | python | def _get_command_args(self, command, args):
'''Work out the command arguments for a given command'''
command_args = {}
command_argument_names =\
command.__code__.co_varnames[:command.__code__.co_argcount]
for varname in command_argument_names:
if varname == 'args... | [
"def",
"_get_command_args",
"(",
"self",
",",
"command",
",",
"args",
")",
":",
"command_args",
"=",
"{",
"}",
"command_argument_names",
"=",
"command",
".",
"__code__",
".",
"co_varnames",
"[",
":",
"command",
".",
"__code__",
".",
"co_argcount",
"]",
"for"... | Work out the command arguments for a given command | [
"Work",
"out",
"the",
"command",
"arguments",
"for",
"a",
"given",
"command"
] | 2f836caca06fbee80a43ca1ceee22376f63ec4d1 | https://github.com/markmuetz/commandify/blob/2f836caca06fbee80a43ca1ceee22376f63ec4d1/commandify/commandify.py#L229-L242 |
251,588 | b3j0f/annotation | b3j0f/annotation/call.py | types | def types(*args, **kwargs):
"""Quick alias for the Types Annotation with only args and kwargs
parameters.
:param tuple args: may contain rtype.
:param dict kwargs: may contain ptypes.
"""
rtype = first(args)
return Types(rtype=rtype, ptypes=kwargs) | python | def types(*args, **kwargs):
"""Quick alias for the Types Annotation with only args and kwargs
parameters.
:param tuple args: may contain rtype.
:param dict kwargs: may contain ptypes.
"""
rtype = first(args)
return Types(rtype=rtype, ptypes=kwargs) | [
"def",
"types",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"rtype",
"=",
"first",
"(",
"args",
")",
"return",
"Types",
"(",
"rtype",
"=",
"rtype",
",",
"ptypes",
"=",
"kwargs",
")"
] | Quick alias for the Types Annotation with only args and kwargs
parameters.
:param tuple args: may contain rtype.
:param dict kwargs: may contain ptypes. | [
"Quick",
"alias",
"for",
"the",
"Types",
"Annotation",
"with",
"only",
"args",
"and",
"kwargs",
"parameters",
"."
] | 738035a974e4092696d9dc1bbd149faa21c8c51f | https://github.com/b3j0f/annotation/blob/738035a974e4092696d9dc1bbd149faa21c8c51f/b3j0f/annotation/call.py#L251-L261 |
251,589 | b3j0f/annotation | b3j0f/annotation/call.py | Retries._checkretry | def _checkretry(self, mydelay, condition, tries_remaining, data):
"""Check if input parameters allow to retries function execution.
:param float mydelay: waiting delay between two execution.
:param int condition: condition to check with this condition.
:param int tries_remaining: tries ... | python | def _checkretry(self, mydelay, condition, tries_remaining, data):
"""Check if input parameters allow to retries function execution.
:param float mydelay: waiting delay between two execution.
:param int condition: condition to check with this condition.
:param int tries_remaining: tries ... | [
"def",
"_checkretry",
"(",
"self",
",",
"mydelay",
",",
"condition",
",",
"tries_remaining",
",",
"data",
")",
":",
"result",
"=",
"mydelay",
"if",
"self",
".",
"condition",
"&",
"condition",
"and",
"tries_remaining",
">",
"0",
":",
"# hook data with tries_rem... | Check if input parameters allow to retries function execution.
:param float mydelay: waiting delay between two execution.
:param int condition: condition to check with this condition.
:param int tries_remaining: tries remaining.
:param data: data to hook. | [
"Check",
"if",
"input",
"parameters",
"allow",
"to",
"retries",
"function",
"execution",
"."
] | 738035a974e4092696d9dc1bbd149faa21c8c51f | https://github.com/b3j0f/annotation/blob/738035a974e4092696d9dc1bbd149faa21c8c51f/b3j0f/annotation/call.py#L465-L491 |
251,590 | b3j0f/annotation | b3j0f/annotation/call.py | Memoize._getkey | def _getkey(self, args, kwargs):
"""Get hash key from args and kwargs.
args and kwargs must be hashable.
:param tuple args: called vargs.
:param dict kwargs: called keywords.
:return: hash(tuple(args) + tuple((key, val) for key in sorted(kwargs)).
:rtype: int."""
... | python | def _getkey(self, args, kwargs):
"""Get hash key from args and kwargs.
args and kwargs must be hashable.
:param tuple args: called vargs.
:param dict kwargs: called keywords.
:return: hash(tuple(args) + tuple((key, val) for key in sorted(kwargs)).
:rtype: int."""
... | [
"def",
"_getkey",
"(",
"self",
",",
"args",
",",
"kwargs",
")",
":",
"values",
"=",
"list",
"(",
"args",
")",
"keys",
"=",
"sorted",
"(",
"list",
"(",
"kwargs",
")",
")",
"for",
"key",
"in",
"keys",
":",
"values",
".",
"append",
"(",
"(",
"key",
... | Get hash key from args and kwargs.
args and kwargs must be hashable.
:param tuple args: called vargs.
:param dict kwargs: called keywords.
:return: hash(tuple(args) + tuple((key, val) for key in sorted(kwargs)).
:rtype: int. | [
"Get",
"hash",
"key",
"from",
"args",
"and",
"kwargs",
"."
] | 738035a974e4092696d9dc1bbd149faa21c8c51f | https://github.com/b3j0f/annotation/blob/738035a974e4092696d9dc1bbd149faa21c8c51f/b3j0f/annotation/call.py#L513-L532 |
251,591 | b3j0f/annotation | b3j0f/annotation/call.py | Memoize.getparams | def getparams(self, result):
"""Get result parameters.
:param result: cached result.
:raises: ValueError if result is not cached.
:return: args and kwargs registered with input result.
:rtype: tuple"""
for key in self._cache:
if self._cache[key][2] == result... | python | def getparams(self, result):
"""Get result parameters.
:param result: cached result.
:raises: ValueError if result is not cached.
:return: args and kwargs registered with input result.
:rtype: tuple"""
for key in self._cache:
if self._cache[key][2] == result... | [
"def",
"getparams",
"(",
"self",
",",
"result",
")",
":",
"for",
"key",
"in",
"self",
".",
"_cache",
":",
"if",
"self",
".",
"_cache",
"[",
"key",
"]",
"[",
"2",
"]",
"==",
"result",
":",
"args",
",",
"kwargs",
",",
"_",
"=",
"self",
".",
"_cac... | Get result parameters.
:param result: cached result.
:raises: ValueError if result is not cached.
:return: args and kwargs registered with input result.
:rtype: tuple | [
"Get",
"result",
"parameters",
"."
] | 738035a974e4092696d9dc1bbd149faa21c8c51f | https://github.com/b3j0f/annotation/blob/738035a974e4092696d9dc1bbd149faa21c8c51f/b3j0f/annotation/call.py#L555-L569 |
251,592 | EventTeam/beliefs | src/beliefs/cells/bools.py | BoolCell.is_entailed_by | def is_entailed_by(self, other):
""" If the other is as or more specific than self"""
other = BoolCell.coerce(other)
if self.value == U or other.value == self.value:
return True
return False | python | def is_entailed_by(self, other):
""" If the other is as or more specific than self"""
other = BoolCell.coerce(other)
if self.value == U or other.value == self.value:
return True
return False | [
"def",
"is_entailed_by",
"(",
"self",
",",
"other",
")",
":",
"other",
"=",
"BoolCell",
".",
"coerce",
"(",
"other",
")",
"if",
"self",
".",
"value",
"==",
"U",
"or",
"other",
".",
"value",
"==",
"self",
".",
"value",
":",
"return",
"True",
"return",... | If the other is as or more specific than self | [
"If",
"the",
"other",
"is",
"as",
"or",
"more",
"specific",
"than",
"self"
] | c07d22b61bebeede74a72800030dde770bf64208 | https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/cells/bools.py#L44-L49 |
251,593 | EventTeam/beliefs | src/beliefs/cells/bools.py | BoolCell.merge | def merge(self, other):
"""
Merges two BoolCells
"""
other = BoolCell.coerce(other)
if self.is_equal(other):
# pick among dependencies
return self
elif other.is_entailed_by(self):
return self
elif self.is_entailed_by(other):
... | python | def merge(self, other):
"""
Merges two BoolCells
"""
other = BoolCell.coerce(other)
if self.is_equal(other):
# pick among dependencies
return self
elif other.is_entailed_by(self):
return self
elif self.is_entailed_by(other):
... | [
"def",
"merge",
"(",
"self",
",",
"other",
")",
":",
"other",
"=",
"BoolCell",
".",
"coerce",
"(",
"other",
")",
"if",
"self",
".",
"is_equal",
"(",
"other",
")",
":",
"# pick among dependencies",
"return",
"self",
"elif",
"other",
".",
"is_entailed_by",
... | Merges two BoolCells | [
"Merges",
"two",
"BoolCells"
] | c07d22b61bebeede74a72800030dde770bf64208 | https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/cells/bools.py#L82-L98 |
251,594 | BenjaminSchubert/NitPycker | nitpycker/runner.py | ParallelRunner._makeResult | def _makeResult(self):
""" instantiates the result class reporters """
return [reporter(self.stream, self.descriptions, self.verbosity) for reporter in self.resultclass] | python | def _makeResult(self):
""" instantiates the result class reporters """
return [reporter(self.stream, self.descriptions, self.verbosity) for reporter in self.resultclass] | [
"def",
"_makeResult",
"(",
"self",
")",
":",
"return",
"[",
"reporter",
"(",
"self",
".",
"stream",
",",
"self",
".",
"descriptions",
",",
"self",
".",
"verbosity",
")",
"for",
"reporter",
"in",
"self",
".",
"resultclass",
"]"
] | instantiates the result class reporters | [
"instantiates",
"the",
"result",
"class",
"reporters"
] | 3ac2b3bf06f1d704b4853167a967311b0465a76f | https://github.com/BenjaminSchubert/NitPycker/blob/3ac2b3bf06f1d704b4853167a967311b0465a76f/nitpycker/runner.py#L108-L110 |
251,595 | BenjaminSchubert/NitPycker | nitpycker/runner.py | ParallelRunner.module_can_run_parallel | def module_can_run_parallel(test_module: unittest.TestSuite) -> bool:
"""
Checks if a given module of tests can be run in parallel or not
:param test_module: the module to run
:return: True if the module can be run on parallel, False otherwise
"""
for test_class in test_... | python | def module_can_run_parallel(test_module: unittest.TestSuite) -> bool:
"""
Checks if a given module of tests can be run in parallel or not
:param test_module: the module to run
:return: True if the module can be run on parallel, False otherwise
"""
for test_class in test_... | [
"def",
"module_can_run_parallel",
"(",
"test_module",
":",
"unittest",
".",
"TestSuite",
")",
"->",
"bool",
":",
"for",
"test_class",
"in",
"test_module",
":",
"# if the test is already failed, we just don't filter it",
"# and let the test runner deal with it later.",
"if",
"... | Checks if a given module of tests can be run in parallel or not
:param test_module: the module to run
:return: True if the module can be run on parallel, False otherwise | [
"Checks",
"if",
"a",
"given",
"module",
"of",
"tests",
"can",
"be",
"run",
"in",
"parallel",
"or",
"not"
] | 3ac2b3bf06f1d704b4853167a967311b0465a76f | https://github.com/BenjaminSchubert/NitPycker/blob/3ac2b3bf06f1d704b4853167a967311b0465a76f/nitpycker/runner.py#L113-L135 |
251,596 | BenjaminSchubert/NitPycker | nitpycker/runner.py | ParallelRunner.class_can_run_parallel | def class_can_run_parallel(test_class: unittest.TestSuite) -> bool:
"""
Checks if a given class of tests can be run in parallel or not
:param test_class: the class to run
:return: True if te class can be run in parallel, False otherwise
"""
for test_case in test_class:
... | python | def class_can_run_parallel(test_class: unittest.TestSuite) -> bool:
"""
Checks if a given class of tests can be run in parallel or not
:param test_class: the class to run
:return: True if te class can be run in parallel, False otherwise
"""
for test_case in test_class:
... | [
"def",
"class_can_run_parallel",
"(",
"test_class",
":",
"unittest",
".",
"TestSuite",
")",
"->",
"bool",
":",
"for",
"test_case",
"in",
"test_class",
":",
"return",
"not",
"getattr",
"(",
"test_case",
",",
"\"__no_parallel__\"",
",",
"False",
")"
] | Checks if a given class of tests can be run in parallel or not
:param test_class: the class to run
:return: True if te class can be run in parallel, False otherwise | [
"Checks",
"if",
"a",
"given",
"class",
"of",
"tests",
"can",
"be",
"run",
"in",
"parallel",
"or",
"not"
] | 3ac2b3bf06f1d704b4853167a967311b0465a76f | https://github.com/BenjaminSchubert/NitPycker/blob/3ac2b3bf06f1d704b4853167a967311b0465a76f/nitpycker/runner.py#L138-L146 |
251,597 | BenjaminSchubert/NitPycker | nitpycker/runner.py | ParallelRunner.print_summary | def print_summary(self, result, time_taken):
"""
Prints the test summary, how many tests failed, how long it took, etc
:param result: result class to use to print summary
:param time_taken: the time all tests took to run
"""
if hasattr(result, "separator2"):
... | python | def print_summary(self, result, time_taken):
"""
Prints the test summary, how many tests failed, how long it took, etc
:param result: result class to use to print summary
:param time_taken: the time all tests took to run
"""
if hasattr(result, "separator2"):
... | [
"def",
"print_summary",
"(",
"self",
",",
"result",
",",
"time_taken",
")",
":",
"if",
"hasattr",
"(",
"result",
",",
"\"separator2\"",
")",
":",
"self",
".",
"stream",
".",
"writeln",
"(",
"result",
".",
"separator2",
")",
"self",
".",
"stream",
".",
... | Prints the test summary, how many tests failed, how long it took, etc
:param result: result class to use to print summary
:param time_taken: the time all tests took to run | [
"Prints",
"the",
"test",
"summary",
"how",
"many",
"tests",
"failed",
"how",
"long",
"it",
"took",
"etc"
] | 3ac2b3bf06f1d704b4853167a967311b0465a76f | https://github.com/BenjaminSchubert/NitPycker/blob/3ac2b3bf06f1d704b4853167a967311b0465a76f/nitpycker/runner.py#L182-L217 |
251,598 | BenjaminSchubert/NitPycker | nitpycker/runner.py | ParallelRunner.run | def run(self, test: unittest.TestSuite):
"""
Given a TestSuite, will create one process per test case whenever possible and run them concurrently.
Will then wait for the result and return them
:param test: the TestSuite to run
:return: a summary of the test run
"""
... | python | def run(self, test: unittest.TestSuite):
"""
Given a TestSuite, will create one process per test case whenever possible and run them concurrently.
Will then wait for the result and return them
:param test: the TestSuite to run
:return: a summary of the test run
"""
... | [
"def",
"run",
"(",
"self",
",",
"test",
":",
"unittest",
".",
"TestSuite",
")",
":",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"process",
"=",
"[",
"]",
"resource_manager",
"=",
"multiprocessing",
".",
"Manager",
"(",
")",
"results_queue",
"=",
... | Given a TestSuite, will create one process per test case whenever possible and run them concurrently.
Will then wait for the result and return them
:param test: the TestSuite to run
:return: a summary of the test run | [
"Given",
"a",
"TestSuite",
"will",
"create",
"one",
"process",
"per",
"test",
"case",
"whenever",
"possible",
"and",
"run",
"them",
"concurrently",
".",
"Will",
"then",
"wait",
"for",
"the",
"result",
"and",
"return",
"them"
] | 3ac2b3bf06f1d704b4853167a967311b0465a76f | https://github.com/BenjaminSchubert/NitPycker/blob/3ac2b3bf06f1d704b4853167a967311b0465a76f/nitpycker/runner.py#L219-L261 |
251,599 | foliant-docs/foliantcontrib.init | setup.py | get_templates | def get_templates(path: Path) -> List[str]:
'''List all files in ``templates`` directory, including all subdirectories.
The resulting list contains UNIX-like relative paths starting with ``templates``.
'''
result = []
for item in path.glob('**/*'):
if item.is_file() and not item.name.star... | python | def get_templates(path: Path) -> List[str]:
'''List all files in ``templates`` directory, including all subdirectories.
The resulting list contains UNIX-like relative paths starting with ``templates``.
'''
result = []
for item in path.glob('**/*'):
if item.is_file() and not item.name.star... | [
"def",
"get_templates",
"(",
"path",
":",
"Path",
")",
"->",
"List",
"[",
"str",
"]",
":",
"result",
"=",
"[",
"]",
"for",
"item",
"in",
"path",
".",
"glob",
"(",
"'**/*'",
")",
":",
"if",
"item",
".",
"is_file",
"(",
")",
"and",
"not",
"item",
... | List all files in ``templates`` directory, including all subdirectories.
The resulting list contains UNIX-like relative paths starting with ``templates``. | [
"List",
"all",
"files",
"in",
"templates",
"directory",
"including",
"all",
"subdirectories",
"."
] | 39aa38949b6270a750c800b79b4e71dd827f28d8 | https://github.com/foliant-docs/foliantcontrib.init/blob/39aa38949b6270a750c800b79b4e71dd827f28d8/setup.py#L14-L26 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.