repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
thiagopbueno/pyrddl | pyrddl/rddl.py | RDDL.interm_fluent_variables | def interm_fluent_variables(self) -> FluentParamsList:
'''Returns the instantiated intermediate fluents in canonical order.
Returns:
Sequence[Tuple[str, List[str]]]: A tuple of pairs of fluent name
and a list of instantiated fluents represented as strings.
'''
fl... | python | def interm_fluent_variables(self) -> FluentParamsList:
'''Returns the instantiated intermediate fluents in canonical order.
Returns:
Sequence[Tuple[str, List[str]]]: A tuple of pairs of fluent name
and a list of instantiated fluents represented as strings.
'''
fl... | [
"def",
"interm_fluent_variables",
"(",
"self",
")",
"->",
"FluentParamsList",
":",
"fluents",
"=",
"self",
".",
"domain",
".",
"intermediate_fluents",
"ordering",
"=",
"self",
".",
"domain",
".",
"interm_fluent_ordering",
"return",
"self",
".",
"_fluent_params",
"... | Returns the instantiated intermediate fluents in canonical order.
Returns:
Sequence[Tuple[str, List[str]]]: A tuple of pairs of fluent name
and a list of instantiated fluents represented as strings. | [
"Returns",
"the",
"instantiated",
"intermediate",
"fluents",
"in",
"canonical",
"order",
"."
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/rddl.py#L118-L127 |
thiagopbueno/pyrddl | pyrddl/rddl.py | RDDL.action_fluent_variables | def action_fluent_variables(self) -> FluentParamsList:
'''Returns the instantiated action fluents in canonical order.
Returns:
Sequence[Tuple[str, List[str]]]: A tuple of pairs of fluent name
and a list of instantiated fluents represented as strings.
'''
fluents ... | python | def action_fluent_variables(self) -> FluentParamsList:
'''Returns the instantiated action fluents in canonical order.
Returns:
Sequence[Tuple[str, List[str]]]: A tuple of pairs of fluent name
and a list of instantiated fluents represented as strings.
'''
fluents ... | [
"def",
"action_fluent_variables",
"(",
"self",
")",
"->",
"FluentParamsList",
":",
"fluents",
"=",
"self",
".",
"domain",
".",
"action_fluents",
"ordering",
"=",
"self",
".",
"domain",
".",
"action_fluent_ordering",
"return",
"self",
".",
"_fluent_params",
"(",
... | Returns the instantiated action fluents in canonical order.
Returns:
Sequence[Tuple[str, List[str]]]: A tuple of pairs of fluent name
and a list of instantiated fluents represented as strings. | [
"Returns",
"the",
"instantiated",
"action",
"fluents",
"in",
"canonical",
"order",
"."
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/rddl.py#L130-L139 |
thiagopbueno/pyrddl | pyrddl/rddl.py | RDDL.non_fluent_size | def non_fluent_size(self) -> Sequence[Sequence[int]]:
'''The size of each non-fluent in canonical order.
Returns:
Sequence[Sequence[int]]: A tuple of tuple of integers
representing the shape and size of each non-fluent.
'''
fluents = self.domain.non_fluents
... | python | def non_fluent_size(self) -> Sequence[Sequence[int]]:
'''The size of each non-fluent in canonical order.
Returns:
Sequence[Sequence[int]]: A tuple of tuple of integers
representing the shape and size of each non-fluent.
'''
fluents = self.domain.non_fluents
... | [
"def",
"non_fluent_size",
"(",
"self",
")",
"->",
"Sequence",
"[",
"Sequence",
"[",
"int",
"]",
"]",
":",
"fluents",
"=",
"self",
".",
"domain",
".",
"non_fluents",
"ordering",
"=",
"self",
".",
"domain",
".",
"non_fluent_ordering",
"return",
"self",
".",
... | The size of each non-fluent in canonical order.
Returns:
Sequence[Sequence[int]]: A tuple of tuple of integers
representing the shape and size of each non-fluent. | [
"The",
"size",
"of",
"each",
"non",
"-",
"fluent",
"in",
"canonical",
"order",
"."
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/rddl.py#L142-L151 |
thiagopbueno/pyrddl | pyrddl/rddl.py | RDDL.state_size | def state_size(self) -> Sequence[Sequence[int]]:
'''The size of each state fluent in canonical order.
Returns:
Sequence[Sequence[int]]: A tuple of tuple of integers
representing the shape and size of each fluent.
'''
fluents = self.domain.state_fluents
or... | python | def state_size(self) -> Sequence[Sequence[int]]:
'''The size of each state fluent in canonical order.
Returns:
Sequence[Sequence[int]]: A tuple of tuple of integers
representing the shape and size of each fluent.
'''
fluents = self.domain.state_fluents
or... | [
"def",
"state_size",
"(",
"self",
")",
"->",
"Sequence",
"[",
"Sequence",
"[",
"int",
"]",
"]",
":",
"fluents",
"=",
"self",
".",
"domain",
".",
"state_fluents",
"ordering",
"=",
"self",
".",
"domain",
".",
"state_fluent_ordering",
"return",
"self",
".",
... | The size of each state fluent in canonical order.
Returns:
Sequence[Sequence[int]]: A tuple of tuple of integers
representing the shape and size of each fluent. | [
"The",
"size",
"of",
"each",
"state",
"fluent",
"in",
"canonical",
"order",
"."
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/rddl.py#L154-L163 |
thiagopbueno/pyrddl | pyrddl/rddl.py | RDDL.action_size | def action_size(self) -> Sequence[Sequence[int]]:
'''The size of each action fluent in canonical order.
Returns:
Sequence[Sequence[int]]: A tuple of tuple of integers
representing the shape and size of each fluent.
'''
fluents = self.domain.action_fluents
... | python | def action_size(self) -> Sequence[Sequence[int]]:
'''The size of each action fluent in canonical order.
Returns:
Sequence[Sequence[int]]: A tuple of tuple of integers
representing the shape and size of each fluent.
'''
fluents = self.domain.action_fluents
... | [
"def",
"action_size",
"(",
"self",
")",
"->",
"Sequence",
"[",
"Sequence",
"[",
"int",
"]",
"]",
":",
"fluents",
"=",
"self",
".",
"domain",
".",
"action_fluents",
"ordering",
"=",
"self",
".",
"domain",
".",
"action_fluent_ordering",
"return",
"self",
"."... | The size of each action fluent in canonical order.
Returns:
Sequence[Sequence[int]]: A tuple of tuple of integers
representing the shape and size of each fluent. | [
"The",
"size",
"of",
"each",
"action",
"fluent",
"in",
"canonical",
"order",
"."
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/rddl.py#L166-L175 |
thiagopbueno/pyrddl | pyrddl/rddl.py | RDDL.interm_size | def interm_size(self)-> Sequence[Sequence[int]]:
'''The size of each intermediate fluent in canonical order.
Returns:
Sequence[Sequence[int]]: A tuple of tuple of integers
representing the shape and size of each fluent.
'''
fluents = self.domain.intermediate_flue... | python | def interm_size(self)-> Sequence[Sequence[int]]:
'''The size of each intermediate fluent in canonical order.
Returns:
Sequence[Sequence[int]]: A tuple of tuple of integers
representing the shape and size of each fluent.
'''
fluents = self.domain.intermediate_flue... | [
"def",
"interm_size",
"(",
"self",
")",
"->",
"Sequence",
"[",
"Sequence",
"[",
"int",
"]",
"]",
":",
"fluents",
"=",
"self",
".",
"domain",
".",
"intermediate_fluents",
"ordering",
"=",
"self",
".",
"domain",
".",
"interm_fluent_ordering",
"return",
"self",... | The size of each intermediate fluent in canonical order.
Returns:
Sequence[Sequence[int]]: A tuple of tuple of integers
representing the shape and size of each fluent. | [
"The",
"size",
"of",
"each",
"intermediate",
"fluent",
"in",
"canonical",
"order",
"."
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/rddl.py#L178-L187 |
thiagopbueno/pyrddl | pyrddl/rddl.py | RDDL.state_range_type | def state_range_type(self) -> Sequence[str]:
'''The range type of each state fluent in canonical order.
Returns:
Sequence[str]: A tuple of range types representing
the range of each fluent.
'''
fluents = self.domain.state_fluents
ordering = self.domain.st... | python | def state_range_type(self) -> Sequence[str]:
'''The range type of each state fluent in canonical order.
Returns:
Sequence[str]: A tuple of range types representing
the range of each fluent.
'''
fluents = self.domain.state_fluents
ordering = self.domain.st... | [
"def",
"state_range_type",
"(",
"self",
")",
"->",
"Sequence",
"[",
"str",
"]",
":",
"fluents",
"=",
"self",
".",
"domain",
".",
"state_fluents",
"ordering",
"=",
"self",
".",
"domain",
".",
"state_fluent_ordering",
"return",
"self",
".",
"_fluent_range_type",... | The range type of each state fluent in canonical order.
Returns:
Sequence[str]: A tuple of range types representing
the range of each fluent. | [
"The",
"range",
"type",
"of",
"each",
"state",
"fluent",
"in",
"canonical",
"order",
"."
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/rddl.py#L190-L199 |
thiagopbueno/pyrddl | pyrddl/rddl.py | RDDL.action_range_type | def action_range_type(self) -> Sequence[str]:
'''The range type of each action fluent in canonical order.
Returns:
Sequence[str]: A tuple of range types representing
the range of each fluent.
'''
fluents = self.domain.action_fluents
ordering = self.domain... | python | def action_range_type(self) -> Sequence[str]:
'''The range type of each action fluent in canonical order.
Returns:
Sequence[str]: A tuple of range types representing
the range of each fluent.
'''
fluents = self.domain.action_fluents
ordering = self.domain... | [
"def",
"action_range_type",
"(",
"self",
")",
"->",
"Sequence",
"[",
"str",
"]",
":",
"fluents",
"=",
"self",
".",
"domain",
".",
"action_fluents",
"ordering",
"=",
"self",
".",
"domain",
".",
"action_fluent_ordering",
"return",
"self",
".",
"_fluent_range_typ... | The range type of each action fluent in canonical order.
Returns:
Sequence[str]: A tuple of range types representing
the range of each fluent. | [
"The",
"range",
"type",
"of",
"each",
"action",
"fluent",
"in",
"canonical",
"order",
"."
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/rddl.py#L202-L211 |
thiagopbueno/pyrddl | pyrddl/rddl.py | RDDL.interm_range_type | def interm_range_type(self) -> Sequence[str]:
'''The range type of each intermediate fluent in canonical order.
Returns:
Sequence[str]: A tuple of range types representing
the range of each fluent.
'''
fluents = self.domain.intermediate_fluents
ordering =... | python | def interm_range_type(self) -> Sequence[str]:
'''The range type of each intermediate fluent in canonical order.
Returns:
Sequence[str]: A tuple of range types representing
the range of each fluent.
'''
fluents = self.domain.intermediate_fluents
ordering =... | [
"def",
"interm_range_type",
"(",
"self",
")",
"->",
"Sequence",
"[",
"str",
"]",
":",
"fluents",
"=",
"self",
".",
"domain",
".",
"intermediate_fluents",
"ordering",
"=",
"self",
".",
"domain",
".",
"interm_fluent_ordering",
"return",
"self",
".",
"_fluent_ran... | The range type of each intermediate fluent in canonical order.
Returns:
Sequence[str]: A tuple of range types representing
the range of each fluent. | [
"The",
"range",
"type",
"of",
"each",
"intermediate",
"fluent",
"in",
"canonical",
"order",
"."
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/rddl.py#L214-L223 |
thiagopbueno/pyrddl | pyrddl/rddl.py | RDDL._fluent_range_type | def _fluent_range_type(cls, fluents, ordering) -> Sequence[str]:
'''Returns the range types of `fluents` following the given `ordering`.
Returns:
Sequence[str]: A tuple of range types representing
the range of each fluent.
'''
range_types = []
for name in... | python | def _fluent_range_type(cls, fluents, ordering) -> Sequence[str]:
'''Returns the range types of `fluents` following the given `ordering`.
Returns:
Sequence[str]: A tuple of range types representing
the range of each fluent.
'''
range_types = []
for name in... | [
"def",
"_fluent_range_type",
"(",
"cls",
",",
"fluents",
",",
"ordering",
")",
"->",
"Sequence",
"[",
"str",
"]",
":",
"range_types",
"=",
"[",
"]",
"for",
"name",
"in",
"ordering",
":",
"fluent",
"=",
"fluents",
"[",
"name",
"]",
"range_type",
"=",
"f... | Returns the range types of `fluents` following the given `ordering`.
Returns:
Sequence[str]: A tuple of range types representing
the range of each fluent. | [
"Returns",
"the",
"range",
"types",
"of",
"fluents",
"following",
"the",
"given",
"ordering",
"."
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/rddl.py#L226-L238 |
thiagopbueno/pyrddl | pyrddl/rddl.py | RDDL._fluent_params | def _fluent_params(self, fluents, ordering) -> FluentParamsList:
'''Returns the instantiated `fluents` for the given `ordering`.
For each fluent in `fluents`, it instantiates each parameter
type w.r.t. the contents of the object table.
Returns:
Sequence[Tuple[str, List[str]... | python | def _fluent_params(self, fluents, ordering) -> FluentParamsList:
'''Returns the instantiated `fluents` for the given `ordering`.
For each fluent in `fluents`, it instantiates each parameter
type w.r.t. the contents of the object table.
Returns:
Sequence[Tuple[str, List[str]... | [
"def",
"_fluent_params",
"(",
"self",
",",
"fluents",
",",
"ordering",
")",
"->",
"FluentParamsList",
":",
"variables",
"=",
"[",
"]",
"for",
"fluent_id",
"in",
"ordering",
":",
"fluent",
"=",
"fluents",
"[",
"fluent_id",
"]",
"param_types",
"=",
"fluent",
... | Returns the instantiated `fluents` for the given `ordering`.
For each fluent in `fluents`, it instantiates each parameter
type w.r.t. the contents of the object table.
Returns:
Sequence[Tuple[str, List[str]]]: A tuple of pairs of fluent name
and a list of instantiated f... | [
"Returns",
"the",
"instantiated",
"fluents",
"for",
"the",
"given",
"ordering",
"."
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/rddl.py#L240-L265 |
thiagopbueno/pyrddl | pyrddl/rddl.py | RDDL._fluent_size | def _fluent_size(self, fluents, ordering) -> Sequence[Sequence[int]]:
'''Returns the sizes of `fluents` following the given `ordering`.
Returns:
Sequence[Sequence[int]]: A tuple of tuple of integers
representing the shape and size of each fluent.
'''
shapes = []
... | python | def _fluent_size(self, fluents, ordering) -> Sequence[Sequence[int]]:
'''Returns the sizes of `fluents` following the given `ordering`.
Returns:
Sequence[Sequence[int]]: A tuple of tuple of integers
representing the shape and size of each fluent.
'''
shapes = []
... | [
"def",
"_fluent_size",
"(",
"self",
",",
"fluents",
",",
"ordering",
")",
"->",
"Sequence",
"[",
"Sequence",
"[",
"int",
"]",
"]",
":",
"shapes",
"=",
"[",
"]",
"for",
"name",
"in",
"ordering",
":",
"fluent",
"=",
"fluents",
"[",
"name",
"]",
"shape"... | Returns the sizes of `fluents` following the given `ordering`.
Returns:
Sequence[Sequence[int]]: A tuple of tuple of integers
representing the shape and size of each fluent. | [
"Returns",
"the",
"sizes",
"of",
"fluents",
"following",
"the",
"given",
"ordering",
"."
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/rddl.py#L267-L279 |
thiagopbueno/pyrddl | pyrddl/rddl.py | RDDL._param_types_to_shape | def _param_types_to_shape(self, param_types: Optional[str]) -> Sequence[int]:
'''Returns the fluent shape given its `param_types`.'''
param_types = [] if param_types is None else param_types
shape = tuple(self.object_table[ptype]['size'] for ptype in param_types)
return shape | python | def _param_types_to_shape(self, param_types: Optional[str]) -> Sequence[int]:
'''Returns the fluent shape given its `param_types`.'''
param_types = [] if param_types is None else param_types
shape = tuple(self.object_table[ptype]['size'] for ptype in param_types)
return shape | [
"def",
"_param_types_to_shape",
"(",
"self",
",",
"param_types",
":",
"Optional",
"[",
"str",
"]",
")",
"->",
"Sequence",
"[",
"int",
"]",
":",
"param_types",
"=",
"[",
"]",
"if",
"param_types",
"is",
"None",
"else",
"param_types",
"shape",
"=",
"tuple",
... | Returns the fluent shape given its `param_types`. | [
"Returns",
"the",
"fluent",
"shape",
"given",
"its",
"param_types",
"."
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/rddl.py#L281-L285 |
mpasternak/django-dsl | django_dsl/lexer.py | t_DATE | def t_DATE(t):
r'(?P<year>\d{4})-(?P<month>\d{1,2})-(?P<day>\d{1,2})'
day = int(t.lexer.lexmatch.group('day'))
month = int(t.lexer.lexmatch.group('month'))
year = int(t.lexer.lexmatch.group('year'))
t.value = date(year, month, day)
return t | python | def t_DATE(t):
r'(?P<year>\d{4})-(?P<month>\d{1,2})-(?P<day>\d{1,2})'
day = int(t.lexer.lexmatch.group('day'))
month = int(t.lexer.lexmatch.group('month'))
year = int(t.lexer.lexmatch.group('year'))
t.value = date(year, month, day)
return t | [
"def",
"t_DATE",
"(",
"t",
")",
":",
"day",
"=",
"int",
"(",
"t",
".",
"lexer",
".",
"lexmatch",
".",
"group",
"(",
"'day'",
")",
")",
"month",
"=",
"int",
"(",
"t",
".",
"lexer",
".",
"lexmatch",
".",
"group",
"(",
"'month'",
")",
")",
"year",... | r'(?P<year>\d{4})-(?P<month>\d{1,2})-(?P<day>\d{1,2}) | [
"r",
"(",
"?P<year",
">",
"\\",
"d",
"{",
"4",
"}",
")",
"-",
"(",
"?P<month",
">",
"\\",
"d",
"{",
"1",
"2",
"}",
")",
"-",
"(",
"?P<day",
">",
"\\",
"d",
"{",
"1",
"2",
"}",
")"
] | train | https://github.com/mpasternak/django-dsl/blob/da1fe4da92503841a4ba5ae9db100248cf98437d/django_dsl/lexer.py#L22-L28 |
mpasternak/django-dsl | django_dsl/lexer.py | t_FIELD | def t_FIELD(t):
r'[A-Za-z_][\w_]*'
if t.value in u_ops:
t.type = 'U_OP'
elif t.value in b_ops:
t.type = 'B_OP'
return t | python | def t_FIELD(t):
r'[A-Za-z_][\w_]*'
if t.value in u_ops:
t.type = 'U_OP'
elif t.value in b_ops:
t.type = 'B_OP'
return t | [
"def",
"t_FIELD",
"(",
"t",
")",
":",
"if",
"t",
".",
"value",
"in",
"u_ops",
":",
"t",
".",
"type",
"=",
"'U_OP'",
"elif",
"t",
".",
"value",
"in",
"b_ops",
":",
"t",
".",
"type",
"=",
"'B_OP'",
"return",
"t"
] | r'[A-Za-z_][\w_]* | [
"r",
"[",
"A",
"-",
"Za",
"-",
"z_",
"]",
"[",
"\\",
"w_",
"]",
"*"
] | train | https://github.com/mpasternak/django-dsl/blob/da1fe4da92503841a4ba5ae9db100248cf98437d/django_dsl/lexer.py#L49-L55 |
gasparka/pyhacores | pyhacores/radio/quadrature_demodulator.py | QuadratureDemodulator.main | def main(self, c):
"""
:type c: Complex
:rtype: Sfix
"""
conj = self.conjugate.main(c)
mult = self.complex_mult.main(c, conj)
angle = self.angle.main(mult)
self.y = self.GAIN_SFIX * angle
return self.y | python | def main(self, c):
"""
:type c: Complex
:rtype: Sfix
"""
conj = self.conjugate.main(c)
mult = self.complex_mult.main(c, conj)
angle = self.angle.main(mult)
self.y = self.GAIN_SFIX * angle
return self.y | [
"def",
"main",
"(",
"self",
",",
"c",
")",
":",
"conj",
"=",
"self",
".",
"conjugate",
".",
"main",
"(",
"c",
")",
"mult",
"=",
"self",
".",
"complex_mult",
".",
"main",
"(",
"c",
",",
"conj",
")",
"angle",
"=",
"self",
".",
"angle",
".",
"main... | :type c: Complex
:rtype: Sfix | [
":",
"type",
"c",
":",
"Complex",
":",
"rtype",
":",
"Sfix"
] | train | https://github.com/gasparka/pyhacores/blob/16c186fbbf90385f2ba3498395123e79b6fcf340/pyhacores/radio/quadrature_demodulator.py#L36-L46 |
b3j0f/aop | b3j0f/aop/joinpoint/core.py | find_ctx | def find_ctx(elt):
"""Find a Pointcut ctx which is a class/instance related to input
function/method.
:param elt: elt from where find a ctx.
:return: elt ctx. None if no ctx available or if elt is a None method.
"""
result = None
if ismethod(elt):
result = elt.__self__
i... | python | def find_ctx(elt):
"""Find a Pointcut ctx which is a class/instance related to input
function/method.
:param elt: elt from where find a ctx.
:return: elt ctx. None if no ctx available or if elt is a None method.
"""
result = None
if ismethod(elt):
result = elt.__self__
i... | [
"def",
"find_ctx",
"(",
"elt",
")",
":",
"result",
"=",
"None",
"if",
"ismethod",
"(",
"elt",
")",
":",
"result",
"=",
"elt",
".",
"__self__",
"if",
"result",
"is",
"None",
"and",
"PY2",
":",
"result",
"=",
"elt",
".",
"im_class",
"elif",
"isclass",
... | Find a Pointcut ctx which is a class/instance related to input
function/method.
:param elt: elt from where find a ctx.
:return: elt ctx. None if no ctx available or if elt is a None method. | [
"Find",
"a",
"Pointcut",
"ctx",
"which",
"is",
"a",
"class",
"/",
"instance",
"related",
"to",
"input",
"function",
"/",
"method",
"."
] | train | https://github.com/b3j0f/aop/blob/22b9ba335d103edd929c25eb6dbb94037d3615bc/b3j0f/aop/joinpoint/core.py#L74-L94 |
b3j0f/aop | b3j0f/aop/joinpoint/core.py | base_ctx | def base_ctx(ctx):
"""Get base ctx.
:param ctx: initial ctx.
:return: base ctx."""
result = None
if isclass(ctx):
result = getattr(ctx, '__base__', None)
if result is None:
mro = getmro(ctx)
if len(mro) > 1:
result = mro[1]
else:
... | python | def base_ctx(ctx):
"""Get base ctx.
:param ctx: initial ctx.
:return: base ctx."""
result = None
if isclass(ctx):
result = getattr(ctx, '__base__', None)
if result is None:
mro = getmro(ctx)
if len(mro) > 1:
result = mro[1]
else:
... | [
"def",
"base_ctx",
"(",
"ctx",
")",
":",
"result",
"=",
"None",
"if",
"isclass",
"(",
"ctx",
")",
":",
"result",
"=",
"getattr",
"(",
"ctx",
",",
"'__base__'",
",",
"None",
")",
"if",
"result",
"is",
"None",
":",
"mro",
"=",
"getmro",
"(",
"ctx",
... | Get base ctx.
:param ctx: initial ctx.
:return: base ctx. | [
"Get",
"base",
"ctx",
"."
] | train | https://github.com/b3j0f/aop/blob/22b9ba335d103edd929c25eb6dbb94037d3615bc/b3j0f/aop/joinpoint/core.py#L97-L114 |
b3j0f/aop | b3j0f/aop/joinpoint/core.py | super_method | def super_method(name, ctx):
"""Get super ctx method and ctx where name matches with input name.
:param name: method name to find in super ctx.
:param ctx: initial method ctx.
:return: method in super ctx and super ctx.
:rtype: tuple"""
result = None, None
# get class ctx
if isclass(c... | python | def super_method(name, ctx):
"""Get super ctx method and ctx where name matches with input name.
:param name: method name to find in super ctx.
:param ctx: initial method ctx.
:return: method in super ctx and super ctx.
:rtype: tuple"""
result = None, None
# get class ctx
if isclass(c... | [
"def",
"super_method",
"(",
"name",
",",
"ctx",
")",
":",
"result",
"=",
"None",
",",
"None",
"# get class ctx",
"if",
"isclass",
"(",
"ctx",
")",
":",
"_ctx",
"=",
"ctx",
"first_mro",
"=",
"1",
"else",
":",
"_ctx",
"=",
"ctx",
".",
"__class__",
"fir... | Get super ctx method and ctx where name matches with input name.
:param name: method name to find in super ctx.
:param ctx: initial method ctx.
:return: method in super ctx and super ctx.
:rtype: tuple | [
"Get",
"super",
"ctx",
"method",
"and",
"ctx",
"where",
"name",
"matches",
"with",
"input",
"name",
"."
] | train | https://github.com/b3j0f/aop/blob/22b9ba335d103edd929c25eb6dbb94037d3615bc/b3j0f/aop/joinpoint/core.py#L117-L141 |
b3j0f/aop | b3j0f/aop/joinpoint/core.py | _apply_interception | def _apply_interception(
target, interception_fn, ctx=None, _globals=None
):
"""Apply interception on input target and return the final target.
:param Callable target: target on applying the interception_fn.
:param function interception_fn: interception function to apply on
target
:para... | python | def _apply_interception(
target, interception_fn, ctx=None, _globals=None
):
"""Apply interception on input target and return the final target.
:param Callable target: target on applying the interception_fn.
:param function interception_fn: interception function to apply on
target
:para... | [
"def",
"_apply_interception",
"(",
"target",
",",
"interception_fn",
",",
"ctx",
"=",
"None",
",",
"_globals",
"=",
"None",
")",
":",
"if",
"not",
"callable",
"(",
"target",
")",
":",
"raise",
"TypeError",
"(",
"'target {0} is not callable.'",
".",
"format",
... | Apply interception on input target and return the final target.
:param Callable target: target on applying the interception_fn.
:param function interception_fn: interception function to apply on
target
:param ctx: target ctx (instance or class) if not None.
:return: both interception and inter... | [
"Apply",
"interception",
"on",
"input",
"target",
"and",
"return",
"the",
"final",
"target",
"."
] | train | https://github.com/b3j0f/aop/blob/22b9ba335d103edd929c25eb6dbb94037d3615bc/b3j0f/aop/joinpoint/core.py#L573-L673 |
b3j0f/aop | b3j0f/aop/joinpoint/core.py | _unapply_interception | def _unapply_interception(target, ctx=None):
"""Unapply interception on input target in cleaning it.
:param routine target: target from where removing an interception
function. is_joinpoint(target) must be True.
:param ctx: target ctx.
"""
# try to get the right ctx
if ctx is None:
... | python | def _unapply_interception(target, ctx=None):
"""Unapply interception on input target in cleaning it.
:param routine target: target from where removing an interception
function. is_joinpoint(target) must be True.
:param ctx: target ctx.
"""
# try to get the right ctx
if ctx is None:
... | [
"def",
"_unapply_interception",
"(",
"target",
",",
"ctx",
"=",
"None",
")",
":",
"# try to get the right ctx",
"if",
"ctx",
"is",
"None",
":",
"ctx",
"=",
"find_ctx",
"(",
"elt",
"=",
"target",
")",
"# get previous target",
"intercepted",
",",
"old_ctx",
"=",... | Unapply interception on input target in cleaning it.
:param routine target: target from where removing an interception
function. is_joinpoint(target) must be True.
:param ctx: target ctx. | [
"Unapply",
"interception",
"on",
"input",
"target",
"in",
"cleaning",
"it",
"."
] | train | https://github.com/b3j0f/aop/blob/22b9ba335d103edd929c25eb6dbb94037d3615bc/b3j0f/aop/joinpoint/core.py#L676-L784 |
b3j0f/aop | b3j0f/aop/joinpoint/core.py | is_intercepted | def is_intercepted(target):
"""True iif input target is intercepted.
:param target: target to check such as an intercepted target.
:return: True iif input target is intercepted.
:rtype: bool
"""
result = False
# get interception function from input target
function = _get_function(tar... | python | def is_intercepted(target):
"""True iif input target is intercepted.
:param target: target to check such as an intercepted target.
:return: True iif input target is intercepted.
:rtype: bool
"""
result = False
# get interception function from input target
function = _get_function(tar... | [
"def",
"is_intercepted",
"(",
"target",
")",
":",
"result",
"=",
"False",
"# get interception function from input target",
"function",
"=",
"_get_function",
"(",
"target",
")",
"result",
"=",
"hasattr",
"(",
"function",
",",
"_INTERCEPTED",
")",
"return",
"result"
] | True iif input target is intercepted.
:param target: target to check such as an intercepted target.
:return: True iif input target is intercepted.
:rtype: bool | [
"True",
"iif",
"input",
"target",
"is",
"intercepted",
"."
] | train | https://github.com/b3j0f/aop/blob/22b9ba335d103edd929c25eb6dbb94037d3615bc/b3j0f/aop/joinpoint/core.py#L787-L803 |
b3j0f/aop | b3j0f/aop/joinpoint/core.py | get_intercepted | def get_intercepted(target):
"""Get intercepted function and ctx from input target.
:param target: target from where getting the intercepted function and ctx.
:return: target intercepted function and ctx.
(None, None) if no intercepted function exist.
(fn, None) if not ctx exists.
:rty... | python | def get_intercepted(target):
"""Get intercepted function and ctx from input target.
:param target: target from where getting the intercepted function and ctx.
:return: target intercepted function and ctx.
(None, None) if no intercepted function exist.
(fn, None) if not ctx exists.
:rty... | [
"def",
"get_intercepted",
"(",
"target",
")",
":",
"function",
"=",
"_get_function",
"(",
"target",
")",
"intercepted",
"=",
"getattr",
"(",
"function",
",",
"_INTERCEPTED",
",",
"None",
")",
"ctx",
"=",
"getattr",
"(",
"function",
",",
"_INTERCEPTED_CTX",
"... | Get intercepted function and ctx from input target.
:param target: target from where getting the intercepted function and ctx.
:return: target intercepted function and ctx.
(None, None) if no intercepted function exist.
(fn, None) if not ctx exists.
:rtype: tuple | [
"Get",
"intercepted",
"function",
"and",
"ctx",
"from",
"input",
"target",
"."
] | train | https://github.com/b3j0f/aop/blob/22b9ba335d103edd929c25eb6dbb94037d3615bc/b3j0f/aop/joinpoint/core.py#L806-L822 |
b3j0f/aop | b3j0f/aop/joinpoint/core.py | _get_function | def _get_function(target):
"""Get target function.
:param callable target: target from where get function.
:return: depending on target type::
- class: constructor.
- method: method function.
- function: function.
- else: __call__ method.
:raises: TypeError if target ... | python | def _get_function(target):
"""Get target function.
:param callable target: target from where get function.
:return: depending on target type::
- class: constructor.
- method: method function.
- function: function.
- else: __call__ method.
:raises: TypeError if target ... | [
"def",
"_get_function",
"(",
"target",
")",
":",
"result",
"=",
"None",
"# raise TypeError if target is not callable",
"if",
"not",
"callable",
"(",
"target",
")",
":",
"raise",
"TypeError",
"(",
"'target {0} must be callable'",
".",
"format",
"(",
"target",
")",
... | Get target function.
:param callable target: target from where get function.
:return: depending on target type::
- class: constructor.
- method: method function.
- function: function.
- else: __call__ method.
:raises: TypeError if target is not callable or is a class with... | [
"Get",
"target",
"function",
"."
] | train | https://github.com/b3j0f/aop/blob/22b9ba335d103edd929c25eb6dbb94037d3615bc/b3j0f/aop/joinpoint/core.py#L825-L885 |
b3j0f/aop | b3j0f/aop/joinpoint/core.py | Joinpoint.set_target | def set_target(self, target, ctx=None):
"""Set target.
:param target: new target to use.
:param target ctx: target ctx if target is an class/instance attribute.
"""
if target is not None:
# check if target is already intercepted
if is_intercepted(target)... | python | def set_target(self, target, ctx=None):
"""Set target.
:param target: new target to use.
:param target ctx: target ctx if target is an class/instance attribute.
"""
if target is not None:
# check if target is already intercepted
if is_intercepted(target)... | [
"def",
"set_target",
"(",
"self",
",",
"target",
",",
"ctx",
"=",
"None",
")",
":",
"if",
"target",
"is",
"not",
"None",
":",
"# check if target is already intercepted",
"if",
"is_intercepted",
"(",
"target",
")",
":",
"# set self interception last target reference"... | Set target.
:param target: new target to use.
:param target ctx: target ctx if target is an class/instance attribute. | [
"Set",
"target",
"."
] | train | https://github.com/b3j0f/aop/blob/22b9ba335d103edd929c25eb6dbb94037d3615bc/b3j0f/aop/joinpoint/core.py#L253-L269 |
b3j0f/aop | b3j0f/aop/joinpoint/core.py | Joinpoint.start | def start(
self, target=None, args=None, kwargs=None, advices=None,
exec_ctx=None, ctx=None
):
""" Start to proceed this Joinpoint in initializing target, its
arguments and advices. Call self.proceed at the end.
:param callable target: new target to use in proceeding... | python | def start(
self, target=None, args=None, kwargs=None, advices=None,
exec_ctx=None, ctx=None
):
""" Start to proceed this Joinpoint in initializing target, its
arguments and advices. Call self.proceed at the end.
:param callable target: new target to use in proceeding... | [
"def",
"start",
"(",
"self",
",",
"target",
"=",
"None",
",",
"args",
"=",
"None",
",",
"kwargs",
"=",
"None",
",",
"advices",
"=",
"None",
",",
"exec_ctx",
"=",
"None",
",",
"ctx",
"=",
"None",
")",
":",
"# init target and _interception if not None as set... | Start to proceed this Joinpoint in initializing target, its
arguments and advices. Call self.proceed at the end.
:param callable target: new target to use in proceeding. self.target by
default.
:param tuple args: new target args to use in proceeding. self.args by
default... | [
"Start",
"to",
"proceed",
"this",
"Joinpoint",
"in",
"initializing",
"target",
"its",
"arguments",
"and",
"advices",
".",
"Call",
"self",
".",
"proceed",
"at",
"the",
"end",
"."
] | train | https://github.com/b3j0f/aop/blob/22b9ba335d103edd929c25eb6dbb94037d3615bc/b3j0f/aop/joinpoint/core.py#L271-L321 |
b3j0f/aop | b3j0f/aop/joinpoint/core.py | Joinpoint.proceed | def proceed(self):
"""Proceed this Joinpoint in calling all advices with this joinpoint
as the only one parameter, and call at the end the target.
"""
try:
# get next advice
advice = next(self._advices_iterator)
except StopIteration: # if no advice can ... | python | def proceed(self):
"""Proceed this Joinpoint in calling all advices with this joinpoint
as the only one parameter, and call at the end the target.
"""
try:
# get next advice
advice = next(self._advices_iterator)
except StopIteration: # if no advice can ... | [
"def",
"proceed",
"(",
"self",
")",
":",
"try",
":",
"# get next advice",
"advice",
"=",
"next",
"(",
"self",
".",
"_advices_iterator",
")",
"except",
"StopIteration",
":",
"# if no advice can be applied",
"# call target",
"result",
"=",
"self",
".",
"target",
"... | Proceed this Joinpoint in calling all advices with this joinpoint
as the only one parameter, and call at the end the target. | [
"Proceed",
"this",
"Joinpoint",
"in",
"calling",
"all",
"advices",
"with",
"this",
"joinpoint",
"as",
"the",
"only",
"one",
"parameter",
"and",
"call",
"at",
"the",
"end",
"the",
"target",
"."
] | train | https://github.com/b3j0f/aop/blob/22b9ba335d103edd929c25eb6dbb94037d3615bc/b3j0f/aop/joinpoint/core.py#L323-L340 |
b3j0f/aop | b3j0f/aop/joinpoint/core.py | Joinpoint.apply_pointcut | def apply_pointcut(self, target, function=None, ctx=None):
"""Apply pointcut on input target and returns final interception.
The poincut respects all meta properties such as:
- function signature,
- module path,
- file path,
- __dict__ reference.
"""
try... | python | def apply_pointcut(self, target, function=None, ctx=None):
"""Apply pointcut on input target and returns final interception.
The poincut respects all meta properties such as:
- function signature,
- module path,
- file path,
- __dict__ reference.
"""
try... | [
"def",
"apply_pointcut",
"(",
"self",
",",
"target",
",",
"function",
"=",
"None",
",",
"ctx",
"=",
"None",
")",
":",
"try",
":",
"__file__",
"=",
"getfile",
"(",
"target",
")",
"except",
"TypeError",
":",
"__file__",
"=",
"'<string>'",
"if",
"function",... | Apply pointcut on input target and returns final interception.
The poincut respects all meta properties such as:
- function signature,
- module path,
- file path,
- __dict__ reference. | [
"Apply",
"pointcut",
"on",
"input",
"target",
"and",
"returns",
"final",
"interception",
"."
] | train | https://github.com/b3j0f/aop/blob/22b9ba335d103edd929c25eb6dbb94037d3615bc/b3j0f/aop/joinpoint/core.py#L342-L562 |
amreuland/PyVDF | PyVDF/__init__.py | PyVDF.read | def read(f):
"""
Parse a String and return the data
:param f: The file to read
:type f: file/str
:returns: A dictionary object containing the parsed data from f
:raises: SyntaxError - An error occured reading the data.
"""
try:
return PyVDF.reads(f.read())
except AttributeErro... | python | def read(f):
"""
Parse a String and return the data
:param f: The file to read
:type f: file/str
:returns: A dictionary object containing the parsed data from f
:raises: SyntaxError - An error occured reading the data.
"""
try:
return PyVDF.reads(f.read())
except AttributeErro... | [
"def",
"read",
"(",
"f",
")",
":",
"try",
":",
"return",
"PyVDF",
".",
"reads",
"(",
"f",
".",
"read",
"(",
")",
")",
"except",
"AttributeError",
":",
"pass",
"try",
":",
"with",
"open",
"(",
"f",
",",
"'r'",
")",
"as",
"filec",
":",
"data",
"=... | Parse a String and return the data
:param f: The file to read
:type f: file/str
:returns: A dictionary object containing the parsed data from f
:raises: SyntaxError - An error occured reading the data. | [
"Parse",
"a",
"String",
"and",
"return",
"the",
"data"
] | train | https://github.com/amreuland/PyVDF/blob/3d546178153204a1286c61be8f641b59f6c2750e/PyVDF/__init__.py#L96-L119 |
amreuland/PyVDF | PyVDF/__init__.py | PyVDF.reads | def reads(s):
"""
Parse a String and return the data
:param s: The string to read
:type s: :py:obj:`str`
:returns: A dict object containing the data from s
:raises: SyntaxError - An error occured reading the data.
"""
_dict = PyVDF.__UseDict
_len = len
_whitespace = frozenset('\... | python | def reads(s):
"""
Parse a String and return the data
:param s: The string to read
:type s: :py:obj:`str`
:returns: A dict object containing the data from s
:raises: SyntaxError - An error occured reading the data.
"""
_dict = PyVDF.__UseDict
_len = len
_whitespace = frozenset('\... | [
"def",
"reads",
"(",
"s",
")",
":",
"_dict",
"=",
"PyVDF",
".",
"__UseDict",
"_len",
"=",
"len",
"_whitespace",
"=",
"frozenset",
"(",
"'\\t '",
")",
"_newline",
"=",
"frozenset",
"(",
"'\\n\\r'",
")",
"_quote_match",
"=",
"PyVDF",
".",
"__RE_Token_Quoted"... | Parse a String and return the data
:param s: The string to read
:type s: :py:obj:`str`
:returns: A dict object containing the data from s
:raises: SyntaxError - An error occured reading the data. | [
"Parse",
"a",
"String",
"and",
"return",
"the",
"data"
] | train | https://github.com/amreuland/PyVDF/blob/3d546178153204a1286c61be8f641b59f6c2750e/PyVDF/__init__.py#L122-L230 |
amreuland/PyVDF | PyVDF/__init__.py | PyVDF.formatData | def formatData(data):
"""
Format a dictionary object to look like a VDF file
:param data: Data
:type data: :py:obj:`dict`
:returns: A vdf string representation of data
"""
condensed = PyVDF.__CondensedOutput
indentation = PyVDF.__OutputIndentation
spacing = PyVDF.__OutputSpacing
... | python | def formatData(data):
"""
Format a dictionary object to look like a VDF file
:param data: Data
:type data: :py:obj:`dict`
:returns: A vdf string representation of data
"""
condensed = PyVDF.__CondensedOutput
indentation = PyVDF.__OutputIndentation
spacing = PyVDF.__OutputSpacing
... | [
"def",
"formatData",
"(",
"data",
")",
":",
"condensed",
"=",
"PyVDF",
".",
"__CondensedOutput",
"indentation",
"=",
"PyVDF",
".",
"__OutputIndentation",
"spacing",
"=",
"PyVDF",
".",
"__OutputSpacing",
"def",
"loop",
"(",
"array",
",",
"tab",
"=",
"''",
")"... | Format a dictionary object to look like a VDF file
:param data: Data
:type data: :py:obj:`dict`
:returns: A vdf string representation of data | [
"Format",
"a",
"dictionary",
"object",
"to",
"look",
"like",
"a",
"VDF",
"file"
] | train | https://github.com/amreuland/PyVDF/blob/3d546178153204a1286c61be8f641b59f6c2750e/PyVDF/__init__.py#L234-L258 |
amreuland/PyVDF | PyVDF/__init__.py | PyVDF.writeData | def writeData(f, data):
"""
Write a dictionary object to a file
:param f: The file to write to
:type f: file/string
:param data: The data to write to the file
:type data: dict
"""
if not isinstance(data, dict):
raise Exception(PyVDF.__ERR_NotDict.format(repr(data)))
data = PyV... | python | def writeData(f, data):
"""
Write a dictionary object to a file
:param f: The file to write to
:type f: file/string
:param data: The data to write to the file
:type data: dict
"""
if not isinstance(data, dict):
raise Exception(PyVDF.__ERR_NotDict.format(repr(data)))
data = PyV... | [
"def",
"writeData",
"(",
"f",
",",
"data",
")",
":",
"if",
"not",
"isinstance",
"(",
"data",
",",
"dict",
")",
":",
"raise",
"Exception",
"(",
"PyVDF",
".",
"__ERR_NotDict",
".",
"format",
"(",
"repr",
"(",
"data",
")",
")",
")",
"data",
"=",
"PyVD... | Write a dictionary object to a file
:param f: The file to write to
:type f: file/string
:param data: The data to write to the file
:type data: dict | [
"Write",
"a",
"dictionary",
"object",
"to",
"a",
"file"
] | train | https://github.com/amreuland/PyVDF/blob/3d546178153204a1286c61be8f641b59f6c2750e/PyVDF/__init__.py#L261-L284 |
amreuland/PyVDF | PyVDF/__init__.py | PyVDF.find | def find(self, path):
"""
Find a value
:param path: The Key path to search for
:type path: :py:obj:`str`
:returns: The found value or an empty string if not found.
"""
p = [re.sub('[\[\]]', '', w) for w in PyVDF.__RE_Path_Seperator.findall(path)]
array = self.getData()
for c in p:
... | python | def find(self, path):
"""
Find a value
:param path: The Key path to search for
:type path: :py:obj:`str`
:returns: The found value or an empty string if not found.
"""
p = [re.sub('[\[\]]', '', w) for w in PyVDF.__RE_Path_Seperator.findall(path)]
array = self.getData()
for c in p:
... | [
"def",
"find",
"(",
"self",
",",
"path",
")",
":",
"p",
"=",
"[",
"re",
".",
"sub",
"(",
"'[\\[\\]]'",
",",
"''",
",",
"w",
")",
"for",
"w",
"in",
"PyVDF",
".",
"__RE_Path_Seperator",
".",
"findall",
"(",
"path",
")",
"]",
"array",
"=",
"self",
... | Find a value
:param path: The Key path to search for
:type path: :py:obj:`str`
:returns: The found value or an empty string if not found. | [
"Find",
"a",
"value"
] | train | https://github.com/amreuland/PyVDF/blob/3d546178153204a1286c61be8f641b59f6c2750e/PyVDF/__init__.py#L326-L341 |
amreuland/PyVDF | PyVDF/__init__.py | PyVDF.edit | def edit(self, path, value):
"""
Edit a key value
:param path: The path key for the value
:type path: :py:obj:`str`
:param value: The value to be set
:type value: :py:obj:`str`
"""
_dict = PyVDF.__UseDict
p = [re.sub('[\[\]]', '', w) for w in PyVDF.__RE_Path_Seperator.findall(path)]... | python | def edit(self, path, value):
"""
Edit a key value
:param path: The path key for the value
:type path: :py:obj:`str`
:param value: The value to be set
:type value: :py:obj:`str`
"""
_dict = PyVDF.__UseDict
p = [re.sub('[\[\]]', '', w) for w in PyVDF.__RE_Path_Seperator.findall(path)]... | [
"def",
"edit",
"(",
"self",
",",
"path",
",",
"value",
")",
":",
"_dict",
"=",
"PyVDF",
".",
"__UseDict",
"p",
"=",
"[",
"re",
".",
"sub",
"(",
"'[\\[\\]]'",
",",
"''",
",",
"w",
")",
"for",
"w",
"in",
"PyVDF",
".",
"__RE_Path_Seperator",
".",
"f... | Edit a key value
:param path: The path key for the value
:type path: :py:obj:`str`
:param value: The value to be set
:type value: :py:obj:`str` | [
"Edit",
"a",
"key",
"value"
] | train | https://github.com/amreuland/PyVDF/blob/3d546178153204a1286c61be8f641b59f6c2750e/PyVDF/__init__.py#L343-L367 |
tek/proteome | proteome/components/config.py | Config._runtime | def _runtime(self, project, base):
''' first runtimes all project type files, like `project/type.vim`, then the specific project file, like
`project/type/name.vim`.
'''
def run(path_suf):
path = '{}/{}'.format(base, path_suf)
err = 'error sourcing {}.vim: {{}}'.fo... | python | def _runtime(self, project, base):
''' first runtimes all project type files, like `project/type.vim`, then the specific project file, like
`project/type/name.vim`.
'''
def run(path_suf):
path = '{}/{}'.format(base, path_suf)
err = 'error sourcing {}.vim: {{}}'.fo... | [
"def",
"_runtime",
"(",
"self",
",",
"project",
",",
"base",
")",
":",
"def",
"run",
"(",
"path_suf",
")",
":",
"path",
"=",
"'{}/{}'",
".",
"format",
"(",
"base",
",",
"path_suf",
")",
"err",
"=",
"'error sourcing {}.vim: {{}}'",
".",
"format",
"(",
"... | first runtimes all project type files, like `project/type.vim`, then the specific project file, like
`project/type/name.vim`. | [
"first",
"runtimes",
"all",
"project",
"type",
"files",
"like",
"project",
"/",
"type",
".",
"vim",
"then",
"the",
"specific",
"project",
"file",
"like",
"project",
"/",
"type",
"/",
"name",
".",
"vim",
"."
] | train | https://github.com/tek/proteome/blob/b4fea6ca633a5b9ff56eaaf2507028fc6ff078b9/proteome/components/config.py#L20-L35 |
david-caro/python-autosemver | autosemver/git.py | split_line | def split_line(what, indent='', cols=79):
"""Split a line on the closest space, or break the last word with '-'.
Args:
what(str): text to spli one line of.
indent(str): will prepend this indent to the split line, taking it into
account in the column count.
cols(int): maximum len... | python | def split_line(what, indent='', cols=79):
"""Split a line on the closest space, or break the last word with '-'.
Args:
what(str): text to spli one line of.
indent(str): will prepend this indent to the split line, taking it into
account in the column count.
cols(int): maximum len... | [
"def",
"split_line",
"(",
"what",
",",
"indent",
"=",
"''",
",",
"cols",
"=",
"79",
")",
":",
"if",
"len",
"(",
"indent",
")",
">",
"cols",
":",
"raise",
"ValueError",
"(",
"\"The indent can't be longer than cols.\"",
")",
"if",
"cols",
"<",
"2",
":",
... | Split a line on the closest space, or break the last word with '-'.
Args:
what(str): text to spli one line of.
indent(str): will prepend this indent to the split line, taking it into
account in the column count.
cols(int): maximum length of the split line.
Returns:
tupl... | [
"Split",
"a",
"line",
"on",
"the",
"closest",
"space",
"or",
"break",
"the",
"last",
"word",
"with",
"-",
"."
] | train | https://github.com/david-caro/python-autosemver/blob/3bc0adb70c33e4bd3623ae4c1944d5ee37f4303d/autosemver/git.py#L107-L154 |
david-caro/python-autosemver | autosemver/git.py | fit_to_cols | def fit_to_cols(what, indent='', cols=79):
"""Wrap the given text to the columns, prepending the indent to each line.
Args:
what(str): text to wrap.
indent(str): indentation to use.
cols(int): colt to wrap to.
Returns:
str: Wrapped text
"""
lines = []
while what... | python | def fit_to_cols(what, indent='', cols=79):
"""Wrap the given text to the columns, prepending the indent to each line.
Args:
what(str): text to wrap.
indent(str): indentation to use.
cols(int): colt to wrap to.
Returns:
str: Wrapped text
"""
lines = []
while what... | [
"def",
"fit_to_cols",
"(",
"what",
",",
"indent",
"=",
"''",
",",
"cols",
"=",
"79",
")",
":",
"lines",
"=",
"[",
"]",
"while",
"what",
":",
"what",
",",
"next_line",
"=",
"split_line",
"(",
"what",
"=",
"what",
",",
"cols",
"=",
"cols",
",",
"in... | Wrap the given text to the columns, prepending the indent to each line.
Args:
what(str): text to wrap.
indent(str): indentation to use.
cols(int): colt to wrap to.
Returns:
str: Wrapped text | [
"Wrap",
"the",
"given",
"text",
"to",
"the",
"columns",
"prepending",
"the",
"indent",
"to",
"each",
"line",
"."
] | train | https://github.com/david-caro/python-autosemver/blob/3bc0adb70c33e4bd3623ae4c1944d5ee37f4303d/autosemver/git.py#L157-L177 |
Kromey/django-simplecaptcha | simplecaptcha/fields.py | CaptchaField.compress | def compress(self, data_list):
"""Validates the captcha answer and returns the result
If no data is provided, this method will simply return None. Otherwise,
it will validate that the provided answer and timestamp hash to the
supplied hash value, and that the timestamp is within the con... | python | def compress(self, data_list):
"""Validates the captcha answer and returns the result
If no data is provided, this method will simply return None. Otherwise,
it will validate that the provided answer and timestamp hash to the
supplied hash value, and that the timestamp is within the con... | [
"def",
"compress",
"(",
"self",
",",
"data_list",
")",
":",
"if",
"data_list",
":",
"# Calculate the hash of the supplied values",
"hashed",
"=",
"self",
".",
"widget",
".",
"hash_answer",
"(",
"answer",
"=",
"data_list",
"[",
"0",
"]",
",",
"timestamp",
"=",
... | Validates the captcha answer and returns the result
If no data is provided, this method will simply return None. Otherwise,
it will validate that the provided answer and timestamp hash to the
supplied hash value, and that the timestamp is within the configured
time that captchas are con... | [
"Validates",
"the",
"captcha",
"answer",
"and",
"returns",
"the",
"result"
] | train | https://github.com/Kromey/django-simplecaptcha/blob/16dd401e3317daf78143e9250f98b48c22cabd2d/simplecaptcha/fields.py#L34-L56 |
gasparka/pyhacores | pyhacores/packet/header_correlator.py | HeaderCorrelator.main | def main(self, din):
"""
:param din: bit in
:return: True if 100% correlation
"""
self.shr = self.shr[1:] + [din]
if self.cooldown > 0:
self.cooldown = self.cooldown - 1
return False
if self.shr != self.HEADER:
return False
... | python | def main(self, din):
"""
:param din: bit in
:return: True if 100% correlation
"""
self.shr = self.shr[1:] + [din]
if self.cooldown > 0:
self.cooldown = self.cooldown - 1
return False
if self.shr != self.HEADER:
return False
... | [
"def",
"main",
"(",
"self",
",",
"din",
")",
":",
"self",
".",
"shr",
"=",
"self",
".",
"shr",
"[",
"1",
":",
"]",
"+",
"[",
"din",
"]",
"if",
"self",
".",
"cooldown",
">",
"0",
":",
"self",
".",
"cooldown",
"=",
"self",
".",
"cooldown",
"-",... | :param din: bit in
:return: True if 100% correlation | [
":",
"param",
"din",
":",
"bit",
"in",
":",
"return",
":",
"True",
"if",
"100%",
"correlation"
] | train | https://github.com/gasparka/pyhacores/blob/16c186fbbf90385f2ba3498395123e79b6fcf340/pyhacores/packet/header_correlator.py#L24-L39 |
photo/openphoto-python | trovebox/api/api_photo.py | ApiPhotos.list | def list(self, options=None, **kwds):
"""
Endpoint: /photos[/<options>]/list.json
Returns a list of Photo objects.
The options parameter can be used to narrow down the list.
Eg: options={"album": <album_id>}
"""
option_string = self._build_option_string(options)
... | python | def list(self, options=None, **kwds):
"""
Endpoint: /photos[/<options>]/list.json
Returns a list of Photo objects.
The options parameter can be used to narrow down the list.
Eg: options={"album": <album_id>}
"""
option_string = self._build_option_string(options)
... | [
"def",
"list",
"(",
"self",
",",
"options",
"=",
"None",
",",
"*",
"*",
"kwds",
")",
":",
"option_string",
"=",
"self",
".",
"_build_option_string",
"(",
"options",
")",
"photos",
"=",
"self",
".",
"_client",
".",
"get",
"(",
"\"/photos%s/list.json\"",
"... | Endpoint: /photos[/<options>]/list.json
Returns a list of Photo objects.
The options parameter can be used to narrow down the list.
Eg: options={"album": <album_id>} | [
"Endpoint",
":",
"/",
"photos",
"[",
"/",
"<options",
">",
"]",
"/",
"list",
".",
"json"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/api/api_photo.py#L11-L23 |
photo/openphoto-python | trovebox/api/api_photo.py | ApiPhotos.share | def share(self, options=None, **kwds):
"""
Endpoint: /photos[/<options>/share.json
Not currently implemented.
"""
option_string = self._build_option_string(options)
return self._client.post("/photos%s/share.json" % option_string,
**kwds)[... | python | def share(self, options=None, **kwds):
"""
Endpoint: /photos[/<options>/share.json
Not currently implemented.
"""
option_string = self._build_option_string(options)
return self._client.post("/photos%s/share.json" % option_string,
**kwds)[... | [
"def",
"share",
"(",
"self",
",",
"options",
"=",
"None",
",",
"*",
"*",
"kwds",
")",
":",
"option_string",
"=",
"self",
".",
"_build_option_string",
"(",
"options",
")",
"return",
"self",
".",
"_client",
".",
"post",
"(",
"\"/photos%s/share.json\"",
"%",
... | Endpoint: /photos[/<options>/share.json
Not currently implemented. | [
"Endpoint",
":",
"/",
"photos",
"[",
"/",
"<options",
">",
"/",
"share",
".",
"json"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/api/api_photo.py#L25-L33 |
photo/openphoto-python | trovebox/api/api_photo.py | ApiPhotos.update | def update(self, photos, **kwds):
"""
Endpoint: /photos/<id>/update.json
Updates a list of photos with the specified parameters.
Returns True if successful.
Raises TroveboxError if not.
"""
ids = [self._extract_id(photo) for photo in photos]
return self._... | python | def update(self, photos, **kwds):
"""
Endpoint: /photos/<id>/update.json
Updates a list of photos with the specified parameters.
Returns True if successful.
Raises TroveboxError if not.
"""
ids = [self._extract_id(photo) for photo in photos]
return self._... | [
"def",
"update",
"(",
"self",
",",
"photos",
",",
"*",
"*",
"kwds",
")",
":",
"ids",
"=",
"[",
"self",
".",
"_extract_id",
"(",
"photo",
")",
"for",
"photo",
"in",
"photos",
"]",
"return",
"self",
".",
"_client",
".",
"post",
"(",
"\"/photos/update.j... | Endpoint: /photos/<id>/update.json
Updates a list of photos with the specified parameters.
Returns True if successful.
Raises TroveboxError if not. | [
"Endpoint",
":",
"/",
"photos",
"/",
"<id",
">",
"/",
"update",
".",
"json"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/api/api_photo.py#L47-L57 |
photo/openphoto-python | trovebox/api/api_photo.py | ApiPhoto.delete | def delete(self, photo, **kwds):
"""
Endpoint: /photo/<id>/delete.json
Deletes a photo.
Returns True if successful.
Raises a TroveboxError if not.
"""
return self._client.post("/photo/%s/delete.json" %
self._extract_id(photo),
... | python | def delete(self, photo, **kwds):
"""
Endpoint: /photo/<id>/delete.json
Deletes a photo.
Returns True if successful.
Raises a TroveboxError if not.
"""
return self._client.post("/photo/%s/delete.json" %
self._extract_id(photo),
... | [
"def",
"delete",
"(",
"self",
",",
"photo",
",",
"*",
"*",
"kwds",
")",
":",
"return",
"self",
".",
"_client",
".",
"post",
"(",
"\"/photo/%s/delete.json\"",
"%",
"self",
".",
"_extract_id",
"(",
"photo",
")",
",",
"*",
"*",
"kwds",
")",
"[",
"\"resu... | Endpoint: /photo/<id>/delete.json
Deletes a photo.
Returns True if successful.
Raises a TroveboxError if not. | [
"Endpoint",
":",
"/",
"photo",
"/",
"<id",
">",
"/",
"delete",
".",
"json"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/api/api_photo.py#L61-L71 |
photo/openphoto-python | trovebox/api/api_photo.py | ApiPhoto.delete_source | def delete_source(self, photo, **kwds):
"""
Endpoint: /photo/<id>/source/delete.json
Delete the source files of a photo.
Returns True if successful.
Raises a TroveboxError if not.
"""
return self._client.post("/photo/%s/source/delete.json" %
... | python | def delete_source(self, photo, **kwds):
"""
Endpoint: /photo/<id>/source/delete.json
Delete the source files of a photo.
Returns True if successful.
Raises a TroveboxError if not.
"""
return self._client.post("/photo/%s/source/delete.json" %
... | [
"def",
"delete_source",
"(",
"self",
",",
"photo",
",",
"*",
"*",
"kwds",
")",
":",
"return",
"self",
".",
"_client",
".",
"post",
"(",
"\"/photo/%s/source/delete.json\"",
"%",
"self",
".",
"_extract_id",
"(",
"photo",
")",
",",
"*",
"*",
"kwds",
")",
... | Endpoint: /photo/<id>/source/delete.json
Delete the source files of a photo.
Returns True if successful.
Raises a TroveboxError if not. | [
"Endpoint",
":",
"/",
"photo",
"/",
"<id",
">",
"/",
"source",
"/",
"delete",
".",
"json"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/api/api_photo.py#L73-L83 |
photo/openphoto-python | trovebox/api/api_photo.py | ApiPhoto.replace | def replace(self, photo, photo_file, **kwds):
"""
Endpoint: /photo/<id>/replace.json
Uploads the specified photo file to replace an existing photo.
"""
with open(photo_file, 'rb') as in_file:
result = self._client.post("/photo/%s/replace.json" %
... | python | def replace(self, photo, photo_file, **kwds):
"""
Endpoint: /photo/<id>/replace.json
Uploads the specified photo file to replace an existing photo.
"""
with open(photo_file, 'rb') as in_file:
result = self._client.post("/photo/%s/replace.json" %
... | [
"def",
"replace",
"(",
"self",
",",
"photo",
",",
"photo_file",
",",
"*",
"*",
"kwds",
")",
":",
"with",
"open",
"(",
"photo_file",
",",
"'rb'",
")",
"as",
"in_file",
":",
"result",
"=",
"self",
".",
"_client",
".",
"post",
"(",
"\"/photo/%s/replace.js... | Endpoint: /photo/<id>/replace.json
Uploads the specified photo file to replace an existing photo. | [
"Endpoint",
":",
"/",
"photo",
"/",
"<id",
">",
"/",
"replace",
".",
"json"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/api/api_photo.py#L85-L96 |
photo/openphoto-python | trovebox/api/api_photo.py | ApiPhoto.replace_from_url | def replace_from_url(self, photo, url, **kwds):
"""
Endpoint: /photo/<id>replace.json
Import a photo from the specified URL to replace an existing
photo.
"""
result = self._client.post("/photo/%s/replace.json" %
self._extract_id(photo),... | python | def replace_from_url(self, photo, url, **kwds):
"""
Endpoint: /photo/<id>replace.json
Import a photo from the specified URL to replace an existing
photo.
"""
result = self._client.post("/photo/%s/replace.json" %
self._extract_id(photo),... | [
"def",
"replace_from_url",
"(",
"self",
",",
"photo",
",",
"url",
",",
"*",
"*",
"kwds",
")",
":",
"result",
"=",
"self",
".",
"_client",
".",
"post",
"(",
"\"/photo/%s/replace.json\"",
"%",
"self",
".",
"_extract_id",
"(",
"photo",
")",
",",
"photo",
... | Endpoint: /photo/<id>replace.json
Import a photo from the specified URL to replace an existing
photo. | [
"Endpoint",
":",
"/",
"photo",
"/",
"<id",
">",
"replace",
".",
"json"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/api/api_photo.py#L113-L124 |
photo/openphoto-python | trovebox/api/api_photo.py | ApiPhoto.update | def update(self, photo, **kwds):
"""
Endpoint: /photo/<id>/update.json
Updates a photo with the specified parameters.
Returns the updated photo object.
"""
result = self._client.post("/photo/%s/update.json" %
self._extract_id(photo),
... | python | def update(self, photo, **kwds):
"""
Endpoint: /photo/<id>/update.json
Updates a photo with the specified parameters.
Returns the updated photo object.
"""
result = self._client.post("/photo/%s/update.json" %
self._extract_id(photo),
... | [
"def",
"update",
"(",
"self",
",",
"photo",
",",
"*",
"*",
"kwds",
")",
":",
"result",
"=",
"self",
".",
"_client",
".",
"post",
"(",
"\"/photo/%s/update.json\"",
"%",
"self",
".",
"_extract_id",
"(",
"photo",
")",
",",
"*",
"*",
"kwds",
")",
"[",
... | Endpoint: /photo/<id>/update.json
Updates a photo with the specified parameters.
Returns the updated photo object. | [
"Endpoint",
":",
"/",
"photo",
"/",
"<id",
">",
"/",
"update",
".",
"json"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/api/api_photo.py#L127-L137 |
photo/openphoto-python | trovebox/api/api_photo.py | ApiPhoto.view | def view(self, photo, options=None, **kwds):
"""
Endpoint: /photo/<id>[/<options>]/view.json
Requests all properties of a photo.
Can be used to obtain URLs for the photo at a particular size,
by using the "returnSizes" parameter.
Returns the requested photo object.
... | python | def view(self, photo, options=None, **kwds):
"""
Endpoint: /photo/<id>[/<options>]/view.json
Requests all properties of a photo.
Can be used to obtain URLs for the photo at a particular size,
by using the "returnSizes" parameter.
Returns the requested photo object.
... | [
"def",
"view",
"(",
"self",
",",
"photo",
",",
"options",
"=",
"None",
",",
"*",
"*",
"kwds",
")",
":",
"option_string",
"=",
"self",
".",
"_build_option_string",
"(",
"options",
")",
"result",
"=",
"self",
".",
"_client",
".",
"get",
"(",
"\"/photo/%s... | Endpoint: /photo/<id>[/<options>]/view.json
Requests all properties of a photo.
Can be used to obtain URLs for the photo at a particular size,
by using the "returnSizes" parameter.
Returns the requested photo object.
The options parameter can be used to pass in additional opti... | [
"Endpoint",
":",
"/",
"photo",
"/",
"<id",
">",
"[",
"/",
"<options",
">",
"]",
"/",
"view",
".",
"json"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/api/api_photo.py#L139-L154 |
photo/openphoto-python | trovebox/api/api_photo.py | ApiPhoto.upload | def upload(self, photo_file, **kwds):
"""
Endpoint: /photo/upload.json
Uploads the specified photo filename.
"""
with open(photo_file, 'rb') as in_file:
result = self._client.post("/photo/upload.json",
files={'photo': in_file},
... | python | def upload(self, photo_file, **kwds):
"""
Endpoint: /photo/upload.json
Uploads the specified photo filename.
"""
with open(photo_file, 'rb') as in_file:
result = self._client.post("/photo/upload.json",
files={'photo': in_file},
... | [
"def",
"upload",
"(",
"self",
",",
"photo_file",
",",
"*",
"*",
"kwds",
")",
":",
"with",
"open",
"(",
"photo_file",
",",
"'rb'",
")",
"as",
"in_file",
":",
"result",
"=",
"self",
".",
"_client",
".",
"post",
"(",
"\"/photo/upload.json\"",
",",
"files"... | Endpoint: /photo/upload.json
Uploads the specified photo filename. | [
"Endpoint",
":",
"/",
"photo",
"/",
"upload",
".",
"json"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/api/api_photo.py#L156-L166 |
photo/openphoto-python | trovebox/api/api_photo.py | ApiPhoto.upload_encoded | def upload_encoded(self, photo_file, **kwds):
"""
Endpoint: /photo/upload.json
Base64-encodes and uploads the specified photo filename.
"""
with open(photo_file, "rb") as in_file:
encoded_photo = base64.b64encode(in_file.read())
result = self._client.post("/p... | python | def upload_encoded(self, photo_file, **kwds):
"""
Endpoint: /photo/upload.json
Base64-encodes and uploads the specified photo filename.
"""
with open(photo_file, "rb") as in_file:
encoded_photo = base64.b64encode(in_file.read())
result = self._client.post("/p... | [
"def",
"upload_encoded",
"(",
"self",
",",
"photo_file",
",",
"*",
"*",
"kwds",
")",
":",
"with",
"open",
"(",
"photo_file",
",",
"\"rb\"",
")",
"as",
"in_file",
":",
"encoded_photo",
"=",
"base64",
".",
"b64encode",
"(",
"in_file",
".",
"read",
"(",
"... | Endpoint: /photo/upload.json
Base64-encodes and uploads the specified photo filename. | [
"Endpoint",
":",
"/",
"photo",
"/",
"upload",
".",
"json"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/api/api_photo.py#L168-L178 |
photo/openphoto-python | trovebox/api/api_photo.py | ApiPhoto.upload_from_url | def upload_from_url(self, url, **kwds):
"""
Endpoint: /photo/upload.json
Import a photo from the specified URL
"""
result = self._client.post("/photo/upload.json", photo=url,
**kwds)["result"]
return Photo(self._client, result) | python | def upload_from_url(self, url, **kwds):
"""
Endpoint: /photo/upload.json
Import a photo from the specified URL
"""
result = self._client.post("/photo/upload.json", photo=url,
**kwds)["result"]
return Photo(self._client, result) | [
"def",
"upload_from_url",
"(",
"self",
",",
"url",
",",
"*",
"*",
"kwds",
")",
":",
"result",
"=",
"self",
".",
"_client",
".",
"post",
"(",
"\"/photo/upload.json\"",
",",
"photo",
"=",
"url",
",",
"*",
"*",
"kwds",
")",
"[",
"\"result\"",
"]",
"retu... | Endpoint: /photo/upload.json
Import a photo from the specified URL | [
"Endpoint",
":",
"/",
"photo",
"/",
"upload",
".",
"json"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/api/api_photo.py#L180-L188 |
photo/openphoto-python | trovebox/api/api_photo.py | ApiPhoto.next_previous | def next_previous(self, photo, options=None, **kwds):
"""
Endpoint: /photo/<id>/nextprevious[/<options>].json
Returns a dict containing the next and previous photo lists
(there may be more than one next/previous photo returned).
The options parameter can be used to narrow down t... | python | def next_previous(self, photo, options=None, **kwds):
"""
Endpoint: /photo/<id>/nextprevious[/<options>].json
Returns a dict containing the next and previous photo lists
(there may be more than one next/previous photo returned).
The options parameter can be used to narrow down t... | [
"def",
"next_previous",
"(",
"self",
",",
"photo",
",",
"options",
"=",
"None",
",",
"*",
"*",
"kwds",
")",
":",
"option_string",
"=",
"self",
".",
"_build_option_string",
"(",
"options",
")",
"result",
"=",
"self",
".",
"_client",
".",
"get",
"(",
"\"... | Endpoint: /photo/<id>/nextprevious[/<options>].json
Returns a dict containing the next and previous photo lists
(there may be more than one next/previous photo returned).
The options parameter can be used to narrow down the photos
Eg: options={"album": <album_id>} | [
"Endpoint",
":",
"/",
"photo",
"/",
"<id",
">",
"/",
"nextprevious",
"[",
"/",
"<options",
">",
"]",
".",
"json"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/api/api_photo.py#L190-L222 |
photo/openphoto-python | trovebox/api/api_photo.py | ApiPhoto.transform | def transform(self, photo, **kwds):
"""
Endpoint: /photo/<id>/transform.json
Performs the specified transformations.
eg. transform(photo, rotate=90)
Returns the transformed photo.
"""
result = self._client.post("/photo/%s/transform.json" %
... | python | def transform(self, photo, **kwds):
"""
Endpoint: /photo/<id>/transform.json
Performs the specified transformations.
eg. transform(photo, rotate=90)
Returns the transformed photo.
"""
result = self._client.post("/photo/%s/transform.json" %
... | [
"def",
"transform",
"(",
"self",
",",
"photo",
",",
"*",
"*",
"kwds",
")",
":",
"result",
"=",
"self",
".",
"_client",
".",
"post",
"(",
"\"/photo/%s/transform.json\"",
"%",
"self",
".",
"_extract_id",
"(",
"photo",
")",
",",
"*",
"*",
"kwds",
")",
"... | Endpoint: /photo/<id>/transform.json
Performs the specified transformations.
eg. transform(photo, rotate=90)
Returns the transformed photo. | [
"Endpoint",
":",
"/",
"photo",
"/",
"<id",
">",
"/",
"transform",
".",
"json"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/api/api_photo.py#L224-L241 |
kissmetrics/py-KISSmetrics | KISSmetrics/query_string.py | create_query | def create_query(key, person, event=None, timestamp=None,
identity=None, properties=None):
"""Build and encode query string.
:param key: API key for product, found on the
"KISSmetrics Settings".
:param person: individual performing `event`
:param event: event name that ... | python | def create_query(key, person, event=None, timestamp=None,
identity=None, properties=None):
"""Build and encode query string.
:param key: API key for product, found on the
"KISSmetrics Settings".
:param person: individual performing `event`
:param event: event name that ... | [
"def",
"create_query",
"(",
"key",
",",
"person",
",",
"event",
"=",
"None",
",",
"timestamp",
"=",
"None",
",",
"identity",
"=",
"None",
",",
"properties",
"=",
"None",
")",
":",
"if",
"properties",
"is",
"None",
":",
"properties",
"=",
"{",
"}",
"q... | Build and encode query string.
:param key: API key for product, found on the
"KISSmetrics Settings".
:param person: individual performing `event`
:param event: event name that was performed
:param timestamp: when `event` was performed; optional for
back-dating
... | [
"Build",
"and",
"encode",
"query",
"string",
"."
] | train | https://github.com/kissmetrics/py-KISSmetrics/blob/705bf3fe26dd440abdf37bf213396b68af385523/KISSmetrics/query_string.py#L17-L52 |
williamjameshandley/fgivenx | fgivenx/io.py | Cache.check | def check(self, *args):
""" Check that the arguments haven't changed since the last call.
Parameters
----------
*args:
All but the last argument are inputs to the cached function. The
last is the actual value of the function.
Returns
-------
... | python | def check(self, *args):
""" Check that the arguments haven't changed since the last call.
Parameters
----------
*args:
All but the last argument are inputs to the cached function. The
last is the actual value of the function.
Returns
-------
... | [
"def",
"check",
"(",
"self",
",",
"*",
"args",
")",
":",
"data",
"=",
"self",
".",
"load",
"(",
")",
"if",
"len",
"(",
"data",
")",
"-",
"1",
"!=",
"len",
"(",
"args",
")",
":",
"raise",
"ValueError",
"(",
"\"Wrong number of arguments passed to Cache.c... | Check that the arguments haven't changed since the last call.
Parameters
----------
*args:
All but the last argument are inputs to the cached function. The
last is the actual value of the function.
Returns
-------
If arguments unchanged:
... | [
"Check",
"that",
"the",
"arguments",
"haven",
"t",
"changed",
"since",
"the",
"last",
"call",
"."
] | train | https://github.com/williamjameshandley/fgivenx/blob/a16790652a3cef3cfacd4b97da62786cb66fec13/fgivenx/io.py#L54-L96 |
williamjameshandley/fgivenx | fgivenx/io.py | Cache.load | def load(self):
""" Load cache from file using pickle. """
try:
with open(self.file_root + '.pkl', "rb") as f:
return pickle.load(f)
except IOError:
raise CacheMissing(self.file_root) | python | def load(self):
""" Load cache from file using pickle. """
try:
with open(self.file_root + '.pkl', "rb") as f:
return pickle.load(f)
except IOError:
raise CacheMissing(self.file_root) | [
"def",
"load",
"(",
"self",
")",
":",
"try",
":",
"with",
"open",
"(",
"self",
".",
"file_root",
"+",
"'.pkl'",
",",
"\"rb\"",
")",
"as",
"f",
":",
"return",
"pickle",
".",
"load",
"(",
"f",
")",
"except",
"IOError",
":",
"raise",
"CacheMissing",
"... | Load cache from file using pickle. | [
"Load",
"cache",
"from",
"file",
"using",
"pickle",
"."
] | train | https://github.com/williamjameshandley/fgivenx/blob/a16790652a3cef3cfacd4b97da62786cb66fec13/fgivenx/io.py#L98-L104 |
williamjameshandley/fgivenx | fgivenx/io.py | Cache.save | def save(self, *args):
""" Save cache to file using pickle.
Parameters
----------
*args:
All but the last argument are inputs to the cached function. The
last is the actual value of the function.
"""
with open(self.file_root + '.pkl', "wb") as f:
... | python | def save(self, *args):
""" Save cache to file using pickle.
Parameters
----------
*args:
All but the last argument are inputs to the cached function. The
last is the actual value of the function.
"""
with open(self.file_root + '.pkl', "wb") as f:
... | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
")",
":",
"with",
"open",
"(",
"self",
".",
"file_root",
"+",
"'.pkl'",
",",
"\"wb\"",
")",
"as",
"f",
":",
"pickle",
".",
"dump",
"(",
"args",
",",
"f",
",",
"protocol",
"=",
"pickle",
".",
"HIGHEST_... | Save cache to file using pickle.
Parameters
----------
*args:
All but the last argument are inputs to the cached function. The
last is the actual value of the function. | [
"Save",
"cache",
"to",
"file",
"using",
"pickle",
"."
] | train | https://github.com/williamjameshandley/fgivenx/blob/a16790652a3cef3cfacd4b97da62786cb66fec13/fgivenx/io.py#L106-L116 |
OTL/jps | jps/queue.py | main | def main(req_port=None, res_port=None, use_security=False):
'''main of queue
:param req_port: port for clients
:param res_port: port for servers
'''
if req_port is None:
req_port = env.get_req_port()
if res_port is None:
res_port = env.get_res_port()
auth = None
try:
... | python | def main(req_port=None, res_port=None, use_security=False):
'''main of queue
:param req_port: port for clients
:param res_port: port for servers
'''
if req_port is None:
req_port = env.get_req_port()
if res_port is None:
res_port = env.get_res_port()
auth = None
try:
... | [
"def",
"main",
"(",
"req_port",
"=",
"None",
",",
"res_port",
"=",
"None",
",",
"use_security",
"=",
"False",
")",
":",
"if",
"req_port",
"is",
"None",
":",
"req_port",
"=",
"env",
".",
"get_req_port",
"(",
")",
"if",
"res_port",
"is",
"None",
":",
"... | main of queue
:param req_port: port for clients
:param res_port: port for servers | [
"main",
"of",
"queue"
] | train | https://github.com/OTL/jps/blob/2c5a438d59611fffca6853072c822ef22665ed87/jps/queue.py#L18-L51 |
winkidney/cmdtree | src/cmdtree/registry.py | ENV.tree | def tree(self):
"""
:rtype: cmdtree.tree.CmdTree
"""
from cmdtree.tree import CmdTree
if self._tree is None:
self._tree = CmdTree()
return self._tree | python | def tree(self):
"""
:rtype: cmdtree.tree.CmdTree
"""
from cmdtree.tree import CmdTree
if self._tree is None:
self._tree = CmdTree()
return self._tree | [
"def",
"tree",
"(",
"self",
")",
":",
"from",
"cmdtree",
".",
"tree",
"import",
"CmdTree",
"if",
"self",
".",
"_tree",
"is",
"None",
":",
"self",
".",
"_tree",
"=",
"CmdTree",
"(",
")",
"return",
"self",
".",
"_tree"
] | :rtype: cmdtree.tree.CmdTree | [
":",
"rtype",
":",
"cmdtree",
".",
"tree",
".",
"CmdTree"
] | train | https://github.com/winkidney/cmdtree/blob/8558be856f4c3044cf13d2d07a86b69877bb6491/src/cmdtree/registry.py#L19-L26 |
photo/openphoto-python | trovebox/objects/trovebox_object.py | TroveboxObject._set_fields | def _set_fields(self, json_dict):
""" Set this object's attributes specified in json_dict """
for key, value in json_dict.items():
if not key.startswith("_"):
setattr(self, key, value) | python | def _set_fields(self, json_dict):
""" Set this object's attributes specified in json_dict """
for key, value in json_dict.items():
if not key.startswith("_"):
setattr(self, key, value) | [
"def",
"_set_fields",
"(",
"self",
",",
"json_dict",
")",
":",
"for",
"key",
",",
"value",
"in",
"json_dict",
".",
"items",
"(",
")",
":",
"if",
"not",
"key",
".",
"startswith",
"(",
"\"_\"",
")",
":",
"setattr",
"(",
"self",
",",
"key",
",",
"valu... | Set this object's attributes specified in json_dict | [
"Set",
"this",
"object",
"s",
"attributes",
"specified",
"in",
"json_dict"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/objects/trovebox_object.py#L18-L22 |
photo/openphoto-python | trovebox/objects/trovebox_object.py | TroveboxObject._replace_fields | def _replace_fields(self, json_dict):
"""
Delete this object's attributes, and replace with
those in json_dict.
"""
for key in self._json_dict.keys():
if not key.startswith("_"):
delattr(self, key)
self._json_dict = json_dict
self._set_... | python | def _replace_fields(self, json_dict):
"""
Delete this object's attributes, and replace with
those in json_dict.
"""
for key in self._json_dict.keys():
if not key.startswith("_"):
delattr(self, key)
self._json_dict = json_dict
self._set_... | [
"def",
"_replace_fields",
"(",
"self",
",",
"json_dict",
")",
":",
"for",
"key",
"in",
"self",
".",
"_json_dict",
".",
"keys",
"(",
")",
":",
"if",
"not",
"key",
".",
"startswith",
"(",
"\"_\"",
")",
":",
"delattr",
"(",
"self",
",",
"key",
")",
"s... | Delete this object's attributes, and replace with
those in json_dict. | [
"Delete",
"this",
"object",
"s",
"attributes",
"and",
"replace",
"with",
"those",
"in",
"json_dict",
"."
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/objects/trovebox_object.py#L24-L33 |
photo/openphoto-python | trovebox/objects/trovebox_object.py | TroveboxObject._delete_fields | def _delete_fields(self):
"""
Delete this object's attributes, including name and id
"""
for key in self._json_dict.keys():
if not key.startswith("_"):
delattr(self, key)
self._json_dict = {}
self.id = None
self.name = None | python | def _delete_fields(self):
"""
Delete this object's attributes, including name and id
"""
for key in self._json_dict.keys():
if not key.startswith("_"):
delattr(self, key)
self._json_dict = {}
self.id = None
self.name = None | [
"def",
"_delete_fields",
"(",
"self",
")",
":",
"for",
"key",
"in",
"self",
".",
"_json_dict",
".",
"keys",
"(",
")",
":",
"if",
"not",
"key",
".",
"startswith",
"(",
"\"_\"",
")",
":",
"delattr",
"(",
"self",
",",
"key",
")",
"self",
".",
"_json_d... | Delete this object's attributes, including name and id | [
"Delete",
"this",
"object",
"s",
"attributes",
"including",
"name",
"and",
"id"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/objects/trovebox_object.py#L35-L44 |
ryanpetrello/cleaver | cleaver/compat/abc.py | ABCMeta.register | def register(cls, subclass):
"""Register a virtual subclass of an ABC."""
if not isinstance(cls, type):
raise TypeError("Can only register classes")
if issubclass(subclass, cls):
return # Already a subclass
# Subtle: test for cycles *after* testing for "already a... | python | def register(cls, subclass):
"""Register a virtual subclass of an ABC."""
if not isinstance(cls, type):
raise TypeError("Can only register classes")
if issubclass(subclass, cls):
return # Already a subclass
# Subtle: test for cycles *after* testing for "already a... | [
"def",
"register",
"(",
"cls",
",",
"subclass",
")",
":",
"if",
"not",
"isinstance",
"(",
"cls",
",",
"type",
")",
":",
"raise",
"TypeError",
"(",
"\"Can only register classes\"",
")",
"if",
"issubclass",
"(",
"subclass",
",",
"cls",
")",
":",
"return",
... | Register a virtual subclass of an ABC. | [
"Register",
"a",
"virtual",
"subclass",
"of",
"an",
"ABC",
"."
] | train | https://github.com/ryanpetrello/cleaver/blob/0ef266e1a0603c6d414df4b9926ce2a59844db35/cleaver/compat/abc.py#L102-L114 |
OTL/jps | jps/forwarder.py | main | def main(pub_port=None, sub_port=None):
'''main of forwarder
:param sub_port: port for subscribers
:param pub_port: port for publishers
'''
try:
if sub_port is None:
sub_port = get_sub_port()
if pub_port is None:
pub_port = get_pub_port()
context = zm... | python | def main(pub_port=None, sub_port=None):
'''main of forwarder
:param sub_port: port for subscribers
:param pub_port: port for publishers
'''
try:
if sub_port is None:
sub_port = get_sub_port()
if pub_port is None:
pub_port = get_pub_port()
context = zm... | [
"def",
"main",
"(",
"pub_port",
"=",
"None",
",",
"sub_port",
"=",
"None",
")",
":",
"try",
":",
"if",
"sub_port",
"is",
"None",
":",
"sub_port",
"=",
"get_sub_port",
"(",
")",
"if",
"pub_port",
"is",
"None",
":",
"pub_port",
"=",
"get_pub_port",
"(",
... | main of forwarder
:param sub_port: port for subscribers
:param pub_port: port for publishers | [
"main",
"of",
"forwarder"
] | train | https://github.com/OTL/jps/blob/2c5a438d59611fffca6853072c822ef22665ed87/jps/forwarder.py#L13-L37 |
w1ll1am23/pytrackr | src/pytrackr/api.py | trackrApiInterface.update_state_from_api | def update_state_from_api(self):
"""
Pull and update the current state from the API.
"""
if self.last_api_call is not None:
difference = (datetime.datetime.now() - self.last_api_call).seconds
else:
# This is the first run, so we need to get the lastest sta... | python | def update_state_from_api(self):
"""
Pull and update the current state from the API.
"""
if self.last_api_call is not None:
difference = (datetime.datetime.now() - self.last_api_call).seconds
else:
# This is the first run, so we need to get the lastest sta... | [
"def",
"update_state_from_api",
"(",
"self",
")",
":",
"if",
"self",
".",
"last_api_call",
"is",
"not",
"None",
":",
"difference",
"=",
"(",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
"-",
"self",
".",
"last_api_call",
")",
".",
"seconds",
"else"... | Pull and update the current state from the API. | [
"Pull",
"and",
"update",
"the",
"current",
"state",
"from",
"the",
"API",
"."
] | train | https://github.com/w1ll1am23/pytrackr/blob/86ea4e414dc8a62dc0a0eb95dc57a40e2e3741de/src/pytrackr/api.py#L34-L60 |
w1ll1am23/pytrackr | src/pytrackr/api.py | trackrApiInterface.authenticate | def authenticate(self, reauth=False):
"""
Authenticate with the API and return an authentication token.
"""
auth_url = BASE_URL + "/rest/user"
payload = {'email': self.email, 'password': self.password}
arequest = requests.get(auth_url, params=payload)
status = are... | python | def authenticate(self, reauth=False):
"""
Authenticate with the API and return an authentication token.
"""
auth_url = BASE_URL + "/rest/user"
payload = {'email': self.email, 'password': self.password}
arequest = requests.get(auth_url, params=payload)
status = are... | [
"def",
"authenticate",
"(",
"self",
",",
"reauth",
"=",
"False",
")",
":",
"auth_url",
"=",
"BASE_URL",
"+",
"\"/rest/user\"",
"payload",
"=",
"{",
"'email'",
":",
"self",
".",
"email",
",",
"'password'",
":",
"self",
".",
"password",
"}",
"arequest",
"=... | Authenticate with the API and return an authentication token. | [
"Authenticate",
"with",
"the",
"API",
"and",
"return",
"an",
"authentication",
"token",
"."
] | train | https://github.com/w1ll1am23/pytrackr/blob/86ea4e414dc8a62dc0a0eb95dc57a40e2e3741de/src/pytrackr/api.py#L62-L79 |
w1ll1am23/pytrackr | src/pytrackr/api.py | trackrApiInterface.get_trackrs | def get_trackrs(self):
"""
Extract each Trackr device from the trackrApiInterface state.
return a list of all Trackr objects from account.
"""
trackrs = []
for trackr in self.state:
trackrs.append(trackrDevice(trackr, self))
return trackrs | python | def get_trackrs(self):
"""
Extract each Trackr device from the trackrApiInterface state.
return a list of all Trackr objects from account.
"""
trackrs = []
for trackr in self.state:
trackrs.append(trackrDevice(trackr, self))
return trackrs | [
"def",
"get_trackrs",
"(",
"self",
")",
":",
"trackrs",
"=",
"[",
"]",
"for",
"trackr",
"in",
"self",
".",
"state",
":",
"trackrs",
".",
"append",
"(",
"trackrDevice",
"(",
"trackr",
",",
"self",
")",
")",
"return",
"trackrs"
] | Extract each Trackr device from the trackrApiInterface state.
return a list of all Trackr objects from account. | [
"Extract",
"each",
"Trackr",
"device",
"from",
"the",
"trackrApiInterface",
"state",
".",
"return",
"a",
"list",
"of",
"all",
"Trackr",
"objects",
"from",
"account",
"."
] | train | https://github.com/w1ll1am23/pytrackr/blob/86ea4e414dc8a62dc0a0eb95dc57a40e2e3741de/src/pytrackr/api.py#L81-L89 |
lemieuxl/pyGenClean | setup.py | check_python_version | def check_python_version():
"""Checks the python version, exists if != 2.7."""
python_major, python_minor = sys.version_info[:2]
if python_major != 2 or python_minor != 7:
sys.stderr.write("pyGenClean requires python 2.7")
sys.exit(1) | python | def check_python_version():
"""Checks the python version, exists if != 2.7."""
python_major, python_minor = sys.version_info[:2]
if python_major != 2 or python_minor != 7:
sys.stderr.write("pyGenClean requires python 2.7")
sys.exit(1) | [
"def",
"check_python_version",
"(",
")",
":",
"python_major",
",",
"python_minor",
"=",
"sys",
".",
"version_info",
"[",
":",
"2",
"]",
"if",
"python_major",
"!=",
"2",
"or",
"python_minor",
"!=",
"7",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"\"pyG... | Checks the python version, exists if != 2.7. | [
"Checks",
"the",
"python",
"version",
"exists",
"if",
"!",
"=",
"2",
".",
"7",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/setup.py#L26-L32 |
iDigBio/idigbio-python-client | idigbio/pandas_client.py | iDbApiPandas.search_records | def search_records(self, **kwargs):
"""
rq Search Query in iDigBio Query Format, using Record Query Fields
sort field to sort on, pick from Record Query Fields
fields a list of fields to return, specified using the fieldName parameter from Fields with type records
... | python | def search_records(self, **kwargs):
"""
rq Search Query in iDigBio Query Format, using Record Query Fields
sort field to sort on, pick from Record Query Fields
fields a list of fields to return, specified using the fieldName parameter from Fields with type records
... | [
"def",
"search_records",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"__search_base",
"(",
"apifn",
"=",
"self",
".",
"__api",
".",
"search_records",
",",
"*",
"*",
"kwargs",
")"
] | rq Search Query in iDigBio Query Format, using Record Query Fields
sort field to sort on, pick from Record Query Fields
fields a list of fields to return, specified using the fieldName parameter from Fields with type records
fields_exclude a list of fields to exclude, specified... | [
"rq",
"Search",
"Query",
"in",
"iDigBio",
"Query",
"Format",
"using",
"Record",
"Query",
"Fields",
"sort",
"field",
"to",
"sort",
"on",
"pick",
"from",
"Record",
"Query",
"Fields",
"fields",
"a",
"list",
"of",
"fields",
"to",
"return",
"specified",
"using",
... | train | https://github.com/iDigBio/idigbio-python-client/blob/e896075b9fed297fc420caf303b3bb5a2298d969/idigbio/pandas_client.py#L51-L63 |
iDigBio/idigbio-python-client | idigbio/pandas_client.py | iDbApiPandas.search_media | def search_media(self,**kwargs):
"""
mq Search Query in iDigBio Query Format, using Media Query Fields
rq Search Query in iDigBio Query Format, using Record Query Fields
sort field to sort on, pick from Media Query Fields
fields a list of fields to return, s... | python | def search_media(self,**kwargs):
"""
mq Search Query in iDigBio Query Format, using Media Query Fields
rq Search Query in iDigBio Query Format, using Record Query Fields
sort field to sort on, pick from Media Query Fields
fields a list of fields to return, s... | [
"def",
"search_media",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"__search_base",
"(",
"apifn",
"=",
"self",
".",
"__api",
".",
"search_media",
",",
"*",
"*",
"kwargs",
")"
] | mq Search Query in iDigBio Query Format, using Media Query Fields
rq Search Query in iDigBio Query Format, using Record Query Fields
sort field to sort on, pick from Media Query Fields
fields a list of fields to return, specified using the fieldName parameter from Fields with t... | [
"mq",
"Search",
"Query",
"in",
"iDigBio",
"Query",
"Format",
"using",
"Media",
"Query",
"Fields",
"rq",
"Search",
"Query",
"in",
"iDigBio",
"Query",
"Format",
"using",
"Record",
"Query",
"Fields",
"sort",
"field",
"to",
"sort",
"on",
"pick",
"from",
"Media",... | train | https://github.com/iDigBio/idigbio-python-client/blob/e896075b9fed297fc420caf303b3bb5a2298d969/idigbio/pandas_client.py#L65-L77 |
coins13/twins | twins/twins.py | Twins.get_timetable_html | def get_timetable_html (self, module):
""" TWINSの表に教室情報を追加したHTMLを返す。"""
if not module.startswith("春") and \
not module.startswith("秋"):
raise RequestError()
module_code, gakkiKbnCode = {
"春A": (1, "A"),
... | python | def get_timetable_html (self, module):
""" TWINSの表に教室情報を追加したHTMLを返す。"""
if not module.startswith("春") and \
not module.startswith("秋"):
raise RequestError()
module_code, gakkiKbnCode = {
"春A": (1, "A"),
... | [
"def",
"get_timetable_html",
"(",
"self",
",",
"module",
")",
":",
"if",
"not",
"module",
".",
"startswith",
"(",
"\"春\") ",
"a",
"d \\",
"not",
"module",
".",
"startswith",
"(",
"\"秋\"):",
"",
"",
"raise",
"RequestError",
"(",
")",
"module_code",
",",
"... | TWINSの表に教室情報を追加したHTMLを返す。 | [
"TWINSの表に教室情報を追加したHTMLを返す。"
] | train | https://github.com/coins13/twins/blob/d66cc850007a25f01812a9d8c7e3efe64a631ca2/twins/twins.py#L100-L154 |
coins13/twins | twins/twins.py | Twins.register_course | def register_course (self, course_id):
""" 履修申請する """
# 何モジュール開講か取得
kdb = twins.kdb.Kdb()
first_module = kdb.get_course_info(course_id)["modules"][:2]
if not first_module.startswith("春") and \
not first_module.startswith("秋"):
raise RequestError()
... | python | def register_course (self, course_id):
""" 履修申請する """
# 何モジュール開講か取得
kdb = twins.kdb.Kdb()
first_module = kdb.get_course_info(course_id)["modules"][:2]
if not first_module.startswith("春") and \
not first_module.startswith("秋"):
raise RequestError()
... | [
"def",
"register_course",
"(",
"self",
",",
"course_id",
")",
":",
"# 何モジュール開講か取得",
"kdb",
"=",
"twins",
".",
"kdb",
".",
"Kdb",
"(",
")",
"first_module",
"=",
"kdb",
".",
"get_course_info",
"(",
"course_id",
")",
"[",
"\"modules\"",
"]",
"[",
":",
"2",
... | 履修申請する | [
"履修申請する"
] | train | https://github.com/coins13/twins/blob/d66cc850007a25f01812a9d8c7e3efe64a631ca2/twins/twins.py#L156-L195 |
coins13/twins | twins/twins.py | Twins.unregister_course | def unregister_course (self, course_id):
""" 履修申請を取り消す """
course_id = course_id.upper()
# 何モジュール開講か取得
kdb = twins.kdb.Kdb()
first_module = kdb.get_course_info(course_id)["modules"][:2]
if not first_module.startswith("春") and \
not first_module.startswith("秋")... | python | def unregister_course (self, course_id):
""" 履修申請を取り消す """
course_id = course_id.upper()
# 何モジュール開講か取得
kdb = twins.kdb.Kdb()
first_module = kdb.get_course_info(course_id)["modules"][:2]
if not first_module.startswith("春") and \
not first_module.startswith("秋")... | [
"def",
"unregister_course",
"(",
"self",
",",
"course_id",
")",
":",
"course_id",
"=",
"course_id",
".",
"upper",
"(",
")",
"# 何モジュール開講か取得",
"kdb",
"=",
"twins",
".",
"kdb",
".",
"Kdb",
"(",
")",
"first_module",
"=",
"kdb",
".",
"get_course_info",
"(",
"... | 履修申請を取り消す | [
"履修申請を取り消す"
] | train | https://github.com/coins13/twins/blob/d66cc850007a25f01812a9d8c7e3efe64a631ca2/twins/twins.py#L197-L253 |
coins13/twins | twins/twins.py | Twins.get_registered_credits | def get_registered_credits (self):
""" 登録単位数合計の取得 """
self.req("RSW0001000-flow")
r = self.get({
"_eventId": "search",
"moduleCode": 1,
"gakkiKbnCode": "A"
})
html = r.text
# XXX
... | python | def get_registered_credits (self):
""" 登録単位数合計の取得 """
self.req("RSW0001000-flow")
r = self.get({
"_eventId": "search",
"moduleCode": 1,
"gakkiKbnCode": "A"
})
html = r.text
# XXX
... | [
"def",
"get_registered_credits",
"(",
"self",
")",
":",
"self",
".",
"req",
"(",
"\"RSW0001000-flow\"",
")",
"r",
"=",
"self",
".",
"get",
"(",
"{",
"\"_eventId\"",
":",
"\"search\"",
",",
"\"moduleCode\"",
":",
"1",
",",
"\"gakkiKbnCode\"",
":",
"\"A\"",
... | 登録単位数合計の取得 | [
"登録単位数合計の取得"
] | train | https://github.com/coins13/twins/blob/d66cc850007a25f01812a9d8c7e3efe64a631ca2/twins/twins.py#L255-L272 |
coins13/twins | twins/twins.py | Twins.get_registered_courses | def get_registered_courses (self):
""" 履修登録済み授業を取得 """
kdb = twins.kdb.Kdb()
_reged = []
for x in ((1, "A"), (2, "A"), (3, "A"), (4, "B"), (5, "B"), (6, "B")):
self.req("RSW0001000-flow")
self.get({
"_eventId": "search",
... | python | def get_registered_courses (self):
""" 履修登録済み授業を取得 """
kdb = twins.kdb.Kdb()
_reged = []
for x in ((1, "A"), (2, "A"), (3, "A"), (4, "B"), (5, "B"), (6, "B")):
self.req("RSW0001000-flow")
self.get({
"_eventId": "search",
... | [
"def",
"get_registered_courses",
"(",
"self",
")",
":",
"kdb",
"=",
"twins",
".",
"kdb",
".",
"Kdb",
"(",
")",
"_reged",
"=",
"[",
"]",
"for",
"x",
"in",
"(",
"(",
"1",
",",
"\"A\"",
")",
",",
"(",
"2",
",",
"\"A\"",
")",
",",
"(",
"3",
",",
... | 履修登録済み授業を取得 | [
"履修登録済み授業を取得"
] | train | https://github.com/coins13/twins/blob/d66cc850007a25f01812a9d8c7e3efe64a631ca2/twins/twins.py#L274-L306 |
coins13/twins | twins/twins.py | Twins.get_achievements_summary | def get_achievements_summary (self):
""" 履修成績要約の取得 (累計)"""
r = self.req("SIW0001200-flow")
# XXX
ret = {}
k = ""
for d in pq(r.text)("td"):
if d.text is None:
continue
if k != "":
# 全角英字ダメゼッタイ
if k =... | python | def get_achievements_summary (self):
""" 履修成績要約の取得 (累計)"""
r = self.req("SIW0001200-flow")
# XXX
ret = {}
k = ""
for d in pq(r.text)("td"):
if d.text is None:
continue
if k != "":
# 全角英字ダメゼッタイ
if k =... | [
"def",
"get_achievements_summary",
"(",
"self",
")",
":",
"r",
"=",
"self",
".",
"req",
"(",
"\"SIW0001200-flow\"",
")",
"# XXX",
"ret",
"=",
"{",
"}",
"k",
"=",
"\"\"",
"for",
"d",
"in",
"pq",
"(",
"r",
".",
"text",
")",
"(",
"\"td\"",
")",
":",
... | 履修成績要約の取得 (累計) | [
"履修成績要約の取得",
"(",
"累計",
")"
] | train | https://github.com/coins13/twins/blob/d66cc850007a25f01812a9d8c7e3efe64a631ca2/twins/twins.py#L308-L331 |
radujica/baloo | baloo/core/indexes/multi.py | MultiIndex.evaluate | def evaluate(self, verbose=False, decode=True, passes=None, num_threads=1, apply_experimental=True):
"""Evaluates by creating a MultiIndex containing evaluated data and index.
See `LazyResult`
Returns
-------
MultiIndex
MultiIndex with evaluated data.
"""
... | python | def evaluate(self, verbose=False, decode=True, passes=None, num_threads=1, apply_experimental=True):
"""Evaluates by creating a MultiIndex containing evaluated data and index.
See `LazyResult`
Returns
-------
MultiIndex
MultiIndex with evaluated data.
"""
... | [
"def",
"evaluate",
"(",
"self",
",",
"verbose",
"=",
"False",
",",
"decode",
"=",
"True",
",",
"passes",
"=",
"None",
",",
"num_threads",
"=",
"1",
",",
"apply_experimental",
"=",
"True",
")",
":",
"evaluated_data",
"=",
"[",
"v",
".",
"evaluate",
"(",... | Evaluates by creating a MultiIndex containing evaluated data and index.
See `LazyResult`
Returns
-------
MultiIndex
MultiIndex with evaluated data. | [
"Evaluates",
"by",
"creating",
"a",
"MultiIndex",
"containing",
"evaluated",
"data",
"and",
"index",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/core/indexes/multi.py#L120-L133 |
radujica/baloo | baloo/core/indexes/multi.py | MultiIndex.tail | def tail(self, n=5):
"""Return MultiIndex with the last n values in each column.
Parameters
----------
n : int
Number of values.
Returns
-------
MultiIndex
MultiIndex containing the last n values in each column.
"""
# not... | python | def tail(self, n=5):
"""Return MultiIndex with the last n values in each column.
Parameters
----------
n : int
Number of values.
Returns
-------
MultiIndex
MultiIndex containing the last n values in each column.
"""
# not... | [
"def",
"tail",
"(",
"self",
",",
"n",
"=",
"5",
")",
":",
"# not computing slice here to use with __getitem__ because we'd need to use len which is eager",
"return",
"MultiIndex",
"(",
"[",
"v",
".",
"tail",
"(",
"n",
")",
"for",
"v",
"in",
"self",
".",
"values",
... | Return MultiIndex with the last n values in each column.
Parameters
----------
n : int
Number of values.
Returns
-------
MultiIndex
MultiIndex containing the last n values in each column. | [
"Return",
"MultiIndex",
"with",
"the",
"last",
"n",
"values",
"in",
"each",
"column",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/core/indexes/multi.py#L196-L211 |
radujica/baloo | baloo/core/indexes/multi.py | MultiIndex.dropna | def dropna(self):
"""Returns MultiIndex without any rows containing null values according to Baloo's convention.
Returns
-------
MultiIndex
MultiIndex with no null values.
"""
not_nas = [v.notna() for v in self.values]
and_filter = reduce(lambda x, y... | python | def dropna(self):
"""Returns MultiIndex without any rows containing null values according to Baloo's convention.
Returns
-------
MultiIndex
MultiIndex with no null values.
"""
not_nas = [v.notna() for v in self.values]
and_filter = reduce(lambda x, y... | [
"def",
"dropna",
"(",
"self",
")",
":",
"not_nas",
"=",
"[",
"v",
".",
"notna",
"(",
")",
"for",
"v",
"in",
"self",
".",
"values",
"]",
"and_filter",
"=",
"reduce",
"(",
"lambda",
"x",
",",
"y",
":",
"x",
"&",
"y",
",",
"not_nas",
")",
"return"... | Returns MultiIndex without any rows containing null values according to Baloo's convention.
Returns
-------
MultiIndex
MultiIndex with no null values. | [
"Returns",
"MultiIndex",
"without",
"any",
"rows",
"containing",
"null",
"values",
"according",
"to",
"Baloo",
"s",
"convention",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/core/indexes/multi.py#L213-L225 |
radujica/baloo | baloo/core/indexes/multi.py | MultiIndex.from_pandas | def from_pandas(cls, index):
"""Create baloo MultiIndex from pandas MultiIndex.
Parameters
----------
index : pandas.multi.MultiIndex
Returns
-------
MultiIndex
"""
from pandas import MultiIndex as PandasMultiIndex
check_type(index, Pand... | python | def from_pandas(cls, index):
"""Create baloo MultiIndex from pandas MultiIndex.
Parameters
----------
index : pandas.multi.MultiIndex
Returns
-------
MultiIndex
"""
from pandas import MultiIndex as PandasMultiIndex
check_type(index, Pand... | [
"def",
"from_pandas",
"(",
"cls",
",",
"index",
")",
":",
"from",
"pandas",
"import",
"MultiIndex",
"as",
"PandasMultiIndex",
"check_type",
"(",
"index",
",",
"PandasMultiIndex",
")",
"baloo_level_values",
"=",
"[",
"Index",
".",
"from_pandas",
"(",
"index",
"... | Create baloo MultiIndex from pandas MultiIndex.
Parameters
----------
index : pandas.multi.MultiIndex
Returns
-------
MultiIndex | [
"Create",
"baloo",
"MultiIndex",
"from",
"pandas",
"MultiIndex",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/core/indexes/multi.py#L228-L246 |
radujica/baloo | baloo/core/indexes/multi.py | MultiIndex.to_pandas | def to_pandas(self):
"""Convert to pandas MultiIndex.
Returns
-------
pandas.base.MultiIndex
"""
if not all(ind.is_raw() for ind in self.values):
raise ValueError('Cannot convert to pandas MultiIndex if not evaluated.')
from pandas import MultiIndex... | python | def to_pandas(self):
"""Convert to pandas MultiIndex.
Returns
-------
pandas.base.MultiIndex
"""
if not all(ind.is_raw() for ind in self.values):
raise ValueError('Cannot convert to pandas MultiIndex if not evaluated.')
from pandas import MultiIndex... | [
"def",
"to_pandas",
"(",
"self",
")",
":",
"if",
"not",
"all",
"(",
"ind",
".",
"is_raw",
"(",
")",
"for",
"ind",
"in",
"self",
".",
"values",
")",
":",
"raise",
"ValueError",
"(",
"'Cannot convert to pandas MultiIndex if not evaluated.'",
")",
"from",
"pand... | Convert to pandas MultiIndex.
Returns
-------
pandas.base.MultiIndex | [
"Convert",
"to",
"pandas",
"MultiIndex",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/core/indexes/multi.py#L248-L263 |
lemieuxl/pyGenClean | pyGenClean/PlinkUtils/plot_MDS_standalone.py | main | def main():
"""The main function of the module.
These are the steps:
1. Reads the population file (:py:func:`readPopulations`).
2. Extracts the MDS values (:py:func:`extractData`).
3. Plots the MDS values (:py:func:`plotMDS`).
"""
# Getting and checking the options
args = parseArgs()
... | python | def main():
"""The main function of the module.
These are the steps:
1. Reads the population file (:py:func:`readPopulations`).
2. Extracts the MDS values (:py:func:`extractData`).
3. Plots the MDS values (:py:func:`plotMDS`).
"""
# Getting and checking the options
args = parseArgs()
... | [
"def",
"main",
"(",
")",
":",
"# Getting and checking the options",
"args",
"=",
"parseArgs",
"(",
")",
"checkArgs",
"(",
"args",
")",
"# Reads the population file",
"populations",
"=",
"readPopulations",
"(",
"args",
".",
"population_file",
",",
"args",
".",
"pop... | The main function of the module.
These are the steps:
1. Reads the population file (:py:func:`readPopulations`).
2. Extracts the MDS values (:py:func:`extractData`).
3. Plots the MDS values (:py:func:`plotMDS`). | [
"The",
"main",
"function",
"of",
"the",
"module",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/PlinkUtils/plot_MDS_standalone.py#L32-L57 |
lemieuxl/pyGenClean | pyGenClean/PlinkUtils/plot_MDS_standalone.py | readPopulations | def readPopulations(inputFileName, requiredPopulation):
"""Reads a population file.
:param inputFileName: the name of the population file.
:param requiredPopulation: the required population.
:type inputFileName: str
:type requiredPopulation: list
:returns: a :py:class:`dict` containing the po... | python | def readPopulations(inputFileName, requiredPopulation):
"""Reads a population file.
:param inputFileName: the name of the population file.
:param requiredPopulation: the required population.
:type inputFileName: str
:type requiredPopulation: list
:returns: a :py:class:`dict` containing the po... | [
"def",
"readPopulations",
"(",
"inputFileName",
",",
"requiredPopulation",
")",
":",
"populations",
"=",
"{",
"}",
"requiredPopulation",
"=",
"set",
"(",
"requiredPopulation",
")",
"with",
"open",
"(",
"inputFileName",
",",
"\"r\"",
")",
"as",
"inputFile",
":",
... | Reads a population file.
:param inputFileName: the name of the population file.
:param requiredPopulation: the required population.
:type inputFileName: str
:type requiredPopulation: list
:returns: a :py:class:`dict` containing the population of each samples. | [
"Reads",
"a",
"population",
"file",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/PlinkUtils/plot_MDS_standalone.py#L60-L102 |
lemieuxl/pyGenClean | pyGenClean/PlinkUtils/plot_MDS_standalone.py | plotMDS | def plotMDS(data, theOrders, theLabels, theColors, theAlphas, theSizes,
theMarkers, options):
"""Plot the MDS data.
:param data: the data to plot (MDS values).
:param theOrders: the order of the populations to plot.
:param theLabels: the names of the populations to plot.
:param theColor... | python | def plotMDS(data, theOrders, theLabels, theColors, theAlphas, theSizes,
theMarkers, options):
"""Plot the MDS data.
:param data: the data to plot (MDS values).
:param theOrders: the order of the populations to plot.
:param theLabels: the names of the populations to plot.
:param theColor... | [
"def",
"plotMDS",
"(",
"data",
",",
"theOrders",
",",
"theLabels",
",",
"theColors",
",",
"theAlphas",
",",
"theSizes",
",",
"theMarkers",
",",
"options",
")",
":",
"# Do the import",
"import",
"matplotlib",
"as",
"mpl",
"if",
"options",
".",
"format",
"!=",... | Plot the MDS data.
:param data: the data to plot (MDS values).
:param theOrders: the order of the populations to plot.
:param theLabels: the names of the populations to plot.
:param theColors: the colors of the populations to plot.
:param theAlphas: the alpha value for the populations to plot.
... | [
"Plot",
"the",
"MDS",
"data",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/PlinkUtils/plot_MDS_standalone.py#L105-L203 |
lemieuxl/pyGenClean | pyGenClean/PlinkUtils/plot_MDS_standalone.py | checkArgs | def checkArgs(args):
"""Checks the arguments and options.
:param args: an object containing the options of the program.
:type args: argparse.Namespace
:returns: ``True`` if everything was OK.
If there is a problem with an option, an exception is raised using the
:py:class:`ProgramError` class... | python | def checkArgs(args):
"""Checks the arguments and options.
:param args: an object containing the options of the program.
:type args: argparse.Namespace
:returns: ``True`` if everything was OK.
If there is a problem with an option, an exception is raised using the
:py:class:`ProgramError` class... | [
"def",
"checkArgs",
"(",
"args",
")",
":",
"# Check in input file",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"args",
".",
"file",
")",
":",
"msg",
"=",
"\"%s: no such file\"",
"%",
"args",
".",
"file",
"raise",
"ProgramError",
"(",
"msg",
")",... | Checks the arguments and options.
:param args: an object containing the options of the program.
:type args: argparse.Namespace
:returns: ``True`` if everything was OK.
If there is a problem with an option, an exception is raised using the
:py:class:`ProgramError` class, a message is printed to th... | [
"Checks",
"the",
"arguments",
"and",
"options",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/PlinkUtils/plot_MDS_standalone.py#L273-L347 |
williamjameshandley/fgivenx | fgivenx/parallel.py | parallel_apply | def parallel_apply(f, array, **kwargs):
""" Apply a function to an array with openmp parallelisation.
Equivalent to `[f(x) for x in array]`, but parallelised if required.
Parameters
----------
f: function
Univariate function to apply to each element of array
array: array-like
... | python | def parallel_apply(f, array, **kwargs):
""" Apply a function to an array with openmp parallelisation.
Equivalent to `[f(x) for x in array]`, but parallelised if required.
Parameters
----------
f: function
Univariate function to apply to each element of array
array: array-like
... | [
"def",
"parallel_apply",
"(",
"f",
",",
"array",
",",
"*",
"*",
"kwargs",
")",
":",
"precurry",
"=",
"tuple",
"(",
"kwargs",
".",
"pop",
"(",
"'precurry'",
",",
"(",
")",
")",
")",
"postcurry",
"=",
"tuple",
"(",
"kwargs",
".",
"pop",
"(",
"'postcu... | Apply a function to an array with openmp parallelisation.
Equivalent to `[f(x) for x in array]`, but parallelised if required.
Parameters
----------
f: function
Univariate function to apply to each element of array
array: array-like
Array to apply f to
parallel: int or bool, ... | [
"Apply",
"a",
"function",
"to",
"an",
"array",
"with",
"openmp",
"parallelisation",
"."
] | train | https://github.com/williamjameshandley/fgivenx/blob/a16790652a3cef3cfacd4b97da62786cb66fec13/fgivenx/parallel.py#L26-L94 |
OTL/jps | jps/service.py | ServiceServer.spin | def spin(self, use_thread=False):
'''call callback for all data forever (until \C-c)
:param use_thread: use thread for spin (do not block)
'''
if use_thread:
if self._thread is not None:
raise 'spin called twice'
self._thread = threading.Thread(ta... | python | def spin(self, use_thread=False):
'''call callback for all data forever (until \C-c)
:param use_thread: use thread for spin (do not block)
'''
if use_thread:
if self._thread is not None:
raise 'spin called twice'
self._thread = threading.Thread(ta... | [
"def",
"spin",
"(",
"self",
",",
"use_thread",
"=",
"False",
")",
":",
"if",
"use_thread",
":",
"if",
"self",
".",
"_thread",
"is",
"not",
"None",
":",
"raise",
"'spin called twice'",
"self",
".",
"_thread",
"=",
"threading",
".",
"Thread",
"(",
"target"... | call callback for all data forever (until \C-c)
:param use_thread: use thread for spin (do not block) | [
"call",
"callback",
"for",
"all",
"data",
"forever",
"(",
"until",
"\\",
"C",
"-",
"c",
")"
] | train | https://github.com/OTL/jps/blob/2c5a438d59611fffca6853072c822ef22665ed87/jps/service.py#L40-L52 |
winkidney/cmdtree | src/cmdtree/parser.py | vars_ | def vars_(object=None):
"""
Clean all of the property starts with "_" then
return result of vars(object).
"""
filtered_vars = {}
vars_dict = vars(object)
for key, value in six.iteritems(vars_dict):
if key.startswith("_"):
continue
filtered_vars[_normalize_arg_name... | python | def vars_(object=None):
"""
Clean all of the property starts with "_" then
return result of vars(object).
"""
filtered_vars = {}
vars_dict = vars(object)
for key, value in six.iteritems(vars_dict):
if key.startswith("_"):
continue
filtered_vars[_normalize_arg_name... | [
"def",
"vars_",
"(",
"object",
"=",
"None",
")",
":",
"filtered_vars",
"=",
"{",
"}",
"vars_dict",
"=",
"vars",
"(",
"object",
")",
"for",
"key",
",",
"value",
"in",
"six",
".",
"iteritems",
"(",
"vars_dict",
")",
":",
"if",
"key",
".",
"startswith",... | Clean all of the property starts with "_" then
return result of vars(object). | [
"Clean",
"all",
"of",
"the",
"property",
"starts",
"with",
"_",
"then",
"return",
"result",
"of",
"vars",
"(",
"object",
")",
"."
] | train | https://github.com/winkidney/cmdtree/blob/8558be856f4c3044cf13d2d07a86b69877bb6491/src/cmdtree/parser.py#L14-L25 |
winkidney/cmdtree | src/cmdtree/parser.py | AParser.add_cmd | def add_cmd(self, name, help=None, func=None):
"""
If func is None, this is regarded as a sub-parser which can contains
sub-command.
Else, this is a leaf node in cmd tree which can not add sub-command.
:rtype: AParser
"""
if self.subparsers is None:
se... | python | def add_cmd(self, name, help=None, func=None):
"""
If func is None, this is regarded as a sub-parser which can contains
sub-command.
Else, this is a leaf node in cmd tree which can not add sub-command.
:rtype: AParser
"""
if self.subparsers is None:
se... | [
"def",
"add_cmd",
"(",
"self",
",",
"name",
",",
"help",
"=",
"None",
",",
"func",
"=",
"None",
")",
":",
"if",
"self",
".",
"subparsers",
"is",
"None",
":",
"self",
".",
"subparsers",
"=",
"self",
".",
"add_subparsers",
"(",
"title",
"=",
"\"sub-com... | If func is None, this is regarded as a sub-parser which can contains
sub-command.
Else, this is a leaf node in cmd tree which can not add sub-command.
:rtype: AParser | [
"If",
"func",
"is",
"None",
"this",
"is",
"regarded",
"as",
"a",
"sub",
"-",
"parser",
"which",
"can",
"contains",
"sub",
"-",
"command",
".",
"Else",
"this",
"is",
"a",
"leaf",
"node",
"in",
"cmd",
"tree",
"which",
"can",
"not",
"add",
"sub",
"-",
... | train | https://github.com/winkidney/cmdtree/blob/8558be856f4c3044cf13d2d07a86b69877bb6491/src/cmdtree/parser.py#L36-L55 |
photo/openphoto-python | trovebox/objects/photo.py | Photo.delete | def delete(self, **kwds):
"""
Endpoint: /photo/<id>/delete.json
Deletes this photo.
Returns True if successful.
Raises a TroveboxError if not.
"""
result = self._client.photo.delete(self, **kwds)
self._delete_fields()
return result | python | def delete(self, **kwds):
"""
Endpoint: /photo/<id>/delete.json
Deletes this photo.
Returns True if successful.
Raises a TroveboxError if not.
"""
result = self._client.photo.delete(self, **kwds)
self._delete_fields()
return result | [
"def",
"delete",
"(",
"self",
",",
"*",
"*",
"kwds",
")",
":",
"result",
"=",
"self",
".",
"_client",
".",
"photo",
".",
"delete",
"(",
"self",
",",
"*",
"*",
"kwds",
")",
"self",
".",
"_delete_fields",
"(",
")",
"return",
"result"
] | Endpoint: /photo/<id>/delete.json
Deletes this photo.
Returns True if successful.
Raises a TroveboxError if not. | [
"Endpoint",
":",
"/",
"photo",
"/",
"<id",
">",
"/",
"delete",
".",
"json"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/objects/photo.py#L10-L20 |
photo/openphoto-python | trovebox/objects/photo.py | Photo.replace | def replace(self, photo_file, **kwds):
"""
Endpoint: /photo/<id>/replace.json
Uploads the specified photo file to replace this photo.
"""
result = self._client.photo.replace(self, photo_file, **kwds)
self._replace_fields(result.get_fields()) | python | def replace(self, photo_file, **kwds):
"""
Endpoint: /photo/<id>/replace.json
Uploads the specified photo file to replace this photo.
"""
result = self._client.photo.replace(self, photo_file, **kwds)
self._replace_fields(result.get_fields()) | [
"def",
"replace",
"(",
"self",
",",
"photo_file",
",",
"*",
"*",
"kwds",
")",
":",
"result",
"=",
"self",
".",
"_client",
".",
"photo",
".",
"replace",
"(",
"self",
",",
"photo_file",
",",
"*",
"*",
"kwds",
")",
"self",
".",
"_replace_fields",
"(",
... | Endpoint: /photo/<id>/replace.json
Uploads the specified photo file to replace this photo. | [
"Endpoint",
":",
"/",
"photo",
"/",
"<id",
">",
"/",
"replace",
".",
"json"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/objects/photo.py#L32-L39 |
photo/openphoto-python | trovebox/objects/photo.py | Photo.replace_from_url | def replace_from_url(self, url, **kwds):
"""
Endpoint: /photo/<id>replace.json
Import a photo from the specified URL to replace this photo.
"""
result = self._client.photo.replace_from_url(self, url, **kwds)
self._replace_fields(result.get_fields()) | python | def replace_from_url(self, url, **kwds):
"""
Endpoint: /photo/<id>replace.json
Import a photo from the specified URL to replace this photo.
"""
result = self._client.photo.replace_from_url(self, url, **kwds)
self._replace_fields(result.get_fields()) | [
"def",
"replace_from_url",
"(",
"self",
",",
"url",
",",
"*",
"*",
"kwds",
")",
":",
"result",
"=",
"self",
".",
"_client",
".",
"photo",
".",
"replace_from_url",
"(",
"self",
",",
"url",
",",
"*",
"*",
"kwds",
")",
"self",
".",
"_replace_fields",
"(... | Endpoint: /photo/<id>replace.json
Import a photo from the specified URL to replace this photo. | [
"Endpoint",
":",
"/",
"photo",
"/",
"<id",
">",
"replace",
".",
"json"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/objects/photo.py#L52-L59 |
photo/openphoto-python | trovebox/objects/photo.py | Photo.update | def update(self, **kwds):
"""
Endpoint: /photo/<id>/update.json
Updates this photo with the specified parameters.
"""
result = self._client.photo.update(self, **kwds)
self._replace_fields(result.get_fields()) | python | def update(self, **kwds):
"""
Endpoint: /photo/<id>/update.json
Updates this photo with the specified parameters.
"""
result = self._client.photo.update(self, **kwds)
self._replace_fields(result.get_fields()) | [
"def",
"update",
"(",
"self",
",",
"*",
"*",
"kwds",
")",
":",
"result",
"=",
"self",
".",
"_client",
".",
"photo",
".",
"update",
"(",
"self",
",",
"*",
"*",
"kwds",
")",
"self",
".",
"_replace_fields",
"(",
"result",
".",
"get_fields",
"(",
")",
... | Endpoint: /photo/<id>/update.json
Updates this photo with the specified parameters. | [
"Endpoint",
":",
"/",
"photo",
"/",
"<id",
">",
"/",
"update",
".",
"json"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/objects/photo.py#L61-L68 |
photo/openphoto-python | trovebox/objects/photo.py | Photo.view | def view(self, options=None, **kwds):
"""
Endpoint: /photo/<id>[/<options>]/view.json
Requests all properties of this photo.
Can be used to obtain URLs for the photo at a particular size,
by using the "returnSizes" parameter.
Updates the photo's fields with the respons... | python | def view(self, options=None, **kwds):
"""
Endpoint: /photo/<id>[/<options>]/view.json
Requests all properties of this photo.
Can be used to obtain URLs for the photo at a particular size,
by using the "returnSizes" parameter.
Updates the photo's fields with the respons... | [
"def",
"view",
"(",
"self",
",",
"options",
"=",
"None",
",",
"*",
"*",
"kwds",
")",
":",
"result",
"=",
"self",
".",
"_client",
".",
"photo",
".",
"view",
"(",
"self",
",",
"options",
",",
"*",
"*",
"kwds",
")",
"self",
".",
"_replace_fields",
"... | Endpoint: /photo/<id>[/<options>]/view.json
Requests all properties of this photo.
Can be used to obtain URLs for the photo at a particular size,
by using the "returnSizes" parameter.
Updates the photo's fields with the response.
The options parameter can be used to pass in ad... | [
"Endpoint",
":",
"/",
"photo",
"/",
"<id",
">",
"[",
"/",
"<options",
">",
"]",
"/",
"view",
".",
"json"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/objects/photo.py#L70-L82 |
photo/openphoto-python | trovebox/objects/photo.py | Photo.next_previous | def next_previous(self, options=None, **kwds):
"""
Endpoint: /photo/<id>/nextprevious[/<options>].json
Returns a dict containing the next and previous photo lists
(there may be more than one next/previous photo returned).
"""
return self._client.photo.next_previous(self,... | python | def next_previous(self, options=None, **kwds):
"""
Endpoint: /photo/<id>/nextprevious[/<options>].json
Returns a dict containing the next and previous photo lists
(there may be more than one next/previous photo returned).
"""
return self._client.photo.next_previous(self,... | [
"def",
"next_previous",
"(",
"self",
",",
"options",
"=",
"None",
",",
"*",
"*",
"kwds",
")",
":",
"return",
"self",
".",
"_client",
".",
"photo",
".",
"next_previous",
"(",
"self",
",",
"options",
",",
"*",
"*",
"kwds",
")"
] | Endpoint: /photo/<id>/nextprevious[/<options>].json
Returns a dict containing the next and previous photo lists
(there may be more than one next/previous photo returned). | [
"Endpoint",
":",
"/",
"photo",
"/",
"<id",
">",
"/",
"nextprevious",
"[",
"/",
"<options",
">",
"]",
".",
"json"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/objects/photo.py#L84-L91 |
photo/openphoto-python | trovebox/objects/photo.py | Photo.transform | def transform(self, **kwds):
"""
Endpoint: /photo/<id>/transform.json
Performs the specified transformations.
eg. transform(photo, rotate=90)
Updates the photo's fields with the response.
"""
result = self._client.photo.transform(self, **kwds)
self._rep... | python | def transform(self, **kwds):
"""
Endpoint: /photo/<id>/transform.json
Performs the specified transformations.
eg. transform(photo, rotate=90)
Updates the photo's fields with the response.
"""
result = self._client.photo.transform(self, **kwds)
self._rep... | [
"def",
"transform",
"(",
"self",
",",
"*",
"*",
"kwds",
")",
":",
"result",
"=",
"self",
".",
"_client",
".",
"photo",
".",
"transform",
"(",
"self",
",",
"*",
"*",
"kwds",
")",
"self",
".",
"_replace_fields",
"(",
"result",
".",
"get_fields",
"(",
... | Endpoint: /photo/<id>/transform.json
Performs the specified transformations.
eg. transform(photo, rotate=90)
Updates the photo's fields with the response. | [
"Endpoint",
":",
"/",
"photo",
"/",
"<id",
">",
"/",
"transform",
".",
"json"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/objects/photo.py#L93-L102 |
ryanpetrello/cleaver | cleaver/middleware.py | SplitMiddleware._copy_body_to_tempfile | def _copy_body_to_tempfile(cls, environ):
"""
Copy wsgi.input to a tempfile so it can be reused.
"""
try:
length = int(environ.get('CONTENT_LENGTH', 0))
except ValueError:
length = 0
try:
fileobj = tempfile.SpooledTemporaryFile(1024*10... | python | def _copy_body_to_tempfile(cls, environ):
"""
Copy wsgi.input to a tempfile so it can be reused.
"""
try:
length = int(environ.get('CONTENT_LENGTH', 0))
except ValueError:
length = 0
try:
fileobj = tempfile.SpooledTemporaryFile(1024*10... | [
"def",
"_copy_body_to_tempfile",
"(",
"cls",
",",
"environ",
")",
":",
"try",
":",
"length",
"=",
"int",
"(",
"environ",
".",
"get",
"(",
"'CONTENT_LENGTH'",
",",
"0",
")",
")",
"except",
"ValueError",
":",
"length",
"=",
"0",
"try",
":",
"fileobj",
"=... | Copy wsgi.input to a tempfile so it can be reused. | [
"Copy",
"wsgi",
".",
"input",
"to",
"a",
"tempfile",
"so",
"it",
"can",
"be",
"reused",
"."
] | train | https://github.com/ryanpetrello/cleaver/blob/0ef266e1a0603c6d414df4b9926ce2a59844db35/cleaver/middleware.py#L161-L188 |
brantai/python-rightscale | rightscale/util.py | get_rc_creds | def get_rc_creds():
"""
Reads ~/.rightscalerc and returns API endpoint and refresh token.
Always returns a tuple of strings even if the file is empty - in which
case, returns ``('', '')``.
"""
config = get_config()
try:
return (
config.get(CFG_SECTION_OAUTH, CFG_OPTI... | python | def get_rc_creds():
"""
Reads ~/.rightscalerc and returns API endpoint and refresh token.
Always returns a tuple of strings even if the file is empty - in which
case, returns ``('', '')``.
"""
config = get_config()
try:
return (
config.get(CFG_SECTION_OAUTH, CFG_OPTI... | [
"def",
"get_rc_creds",
"(",
")",
":",
"config",
"=",
"get_config",
"(",
")",
"try",
":",
"return",
"(",
"config",
".",
"get",
"(",
"CFG_SECTION_OAUTH",
",",
"CFG_OPTION_ENDPOINT",
")",
",",
"config",
".",
"get",
"(",
"CFG_SECTION_OAUTH",
",",
"CFG_OPTION_REF... | Reads ~/.rightscalerc and returns API endpoint and refresh token.
Always returns a tuple of strings even if the file is empty - in which
case, returns ``('', '')``. | [
"Reads",
"~",
"/",
".",
"rightscalerc",
"and",
"returns",
"API",
"endpoint",
"and",
"refresh",
"token",
"."
] | train | https://github.com/brantai/python-rightscale/blob/5fbf4089922917247be712d58645a7b1504f0944/rightscale/util.py#L40-L54 |
brantai/python-rightscale | rightscale/util.py | find_by_name | def find_by_name(collection, name, exact=True):
"""
Searches collection by resource name.
:param rightscale.ResourceCollection collection: The collection in which to
look for :attr:`name`.
:param str name: The name to look for in collection.
:param bool exact: A RightScale ``index`` searc... | python | def find_by_name(collection, name, exact=True):
"""
Searches collection by resource name.
:param rightscale.ResourceCollection collection: The collection in which to
look for :attr:`name`.
:param str name: The name to look for in collection.
:param bool exact: A RightScale ``index`` searc... | [
"def",
"find_by_name",
"(",
"collection",
",",
"name",
",",
"exact",
"=",
"True",
")",
":",
"params",
"=",
"{",
"'filter[]'",
":",
"[",
"'name==%s'",
"%",
"name",
"]",
"}",
"found",
"=",
"collection",
".",
"index",
"(",
"params",
"=",
"params",
")",
... | Searches collection by resource name.
:param rightscale.ResourceCollection collection: The collection in which to
look for :attr:`name`.
:param str name: The name to look for in collection.
:param bool exact: A RightScale ``index`` search with a :attr:`name` filter
can return multiple res... | [
"Searches",
"collection",
"by",
"resource",
"name",
"."
] | train | https://github.com/brantai/python-rightscale/blob/5fbf4089922917247be712d58645a7b1504f0944/rightscale/util.py#L57-L83 |
bede/tictax | tictax/tictax.py | kmer_lca_records | def kmer_lca_records(seqs_path,
one_codex_api_key: 'One Codex API key' = None,
fastq: 'input is fastq; disable autodetection' = False,
progress: 'show progress bar (sent to stderr)' = False):
'''
Parallel lowest common ancestor sequence classificati... | python | def kmer_lca_records(seqs_path,
one_codex_api_key: 'One Codex API key' = None,
fastq: 'input is fastq; disable autodetection' = False,
progress: 'show progress bar (sent to stderr)' = False):
'''
Parallel lowest common ancestor sequence classificati... | [
"def",
"kmer_lca_records",
"(",
"seqs_path",
",",
"one_codex_api_key",
":",
"'One Codex API key'",
"=",
"None",
",",
"fastq",
":",
"'input is fastq; disable autodetection'",
"=",
"False",
",",
"progress",
":",
"'show progress bar (sent to stderr)'",
"=",
"False",
")",
"... | Parallel lowest common ancestor sequence classification of fasta/q using the One Codex API.
Returns Biopython SeqRecords with tictax annotations as the `description` attribute.
LCAs are assigned using an LCA index of 31mers from the One Codex database. | [
"Parallel",
"lowest",
"common",
"ancestor",
"sequence",
"classification",
"of",
"fasta",
"/",
"q",
"using",
"the",
"One",
"Codex",
"API",
".",
"Returns",
"Biopython",
"SeqRecords",
"with",
"tictax",
"annotations",
"as",
"the",
"description",
"attribute",
".",
"L... | train | https://github.com/bede/tictax/blob/acc9811be3a8b5ad905daf4b5d413f2c5e6ad06c/tictax/tictax.py#L133-L149 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.