repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
anthok/overwatch-api | overwatch_api/core.py | AsyncOWAPI._uses_aiohttp_session | def _uses_aiohttp_session(func):
"""This is a decorator that creates an async with statement around a function, and makes sure that a _session argument is always passed.
Only usable on async functions of course.
The _session argument is (supposed to be) an aiohttp.ClientSession instance in all f... | python | def _uses_aiohttp_session(func):
"""This is a decorator that creates an async with statement around a function, and makes sure that a _session argument is always passed.
Only usable on async functions of course.
The _session argument is (supposed to be) an aiohttp.ClientSession instance in all f... | [
"def",
"_uses_aiohttp_session",
"(",
"func",
")",
":",
"# The function the decorator returns",
"async",
"def",
"decorated_func",
"(",
"*",
"args",
",",
"session",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"session",
"is",
"not",
"None",
":",
"# T... | This is a decorator that creates an async with statement around a function, and makes sure that a _session argument is always passed.
Only usable on async functions of course.
The _session argument is (supposed to be) an aiohttp.ClientSession instance in all functions that this decorator has been used o... | [
"This",
"is",
"a",
"decorator",
"that",
"creates",
"an",
"async",
"with",
"statement",
"around",
"a",
"function",
"and",
"makes",
"sure",
"that",
"a",
"_session",
"argument",
"is",
"always",
"passed",
".",
"Only",
"usable",
"on",
"async",
"functions",
"of",
... | aba976a3c07c4932de13f4236d924b2901b149b9 | https://github.com/anthok/overwatch-api/blob/aba976a3c07c4932de13f4236d924b2901b149b9/overwatch_api/core.py#L46-L64 | train |
anthok/overwatch-api | overwatch_api/core.py | AsyncOWAPI._add_request_parameters | def _add_request_parameters(func):
"""Adds the ratelimit and request timeout parameters to a function."""
# The function the decorator returns
async def decorated_func(*args, handle_ratelimit=None, max_tries=None, request_timeout=None, **kwargs):
return await func(*args, handle_rate... | python | def _add_request_parameters(func):
"""Adds the ratelimit and request timeout parameters to a function."""
# The function the decorator returns
async def decorated_func(*args, handle_ratelimit=None, max_tries=None, request_timeout=None, **kwargs):
return await func(*args, handle_rate... | [
"def",
"_add_request_parameters",
"(",
"func",
")",
":",
"# The function the decorator returns",
"async",
"def",
"decorated_func",
"(",
"*",
"args",
",",
"handle_ratelimit",
"=",
"None",
",",
"max_tries",
"=",
"None",
",",
"request_timeout",
"=",
"None",
",",
"*",... | Adds the ratelimit and request timeout parameters to a function. | [
"Adds",
"the",
"ratelimit",
"and",
"request",
"timeout",
"parameters",
"to",
"a",
"function",
"."
] | aba976a3c07c4932de13f4236d924b2901b149b9 | https://github.com/anthok/overwatch-api/blob/aba976a3c07c4932de13f4236d924b2901b149b9/overwatch_api/core.py#L66-L75 | train |
anthok/overwatch-api | overwatch_api/core.py | AsyncOWAPI.get_stats | async def get_stats(self, battletag: str, regions=(EUROPE, KOREA, AMERICAS, CHINA, JAPAN, ANY),
platform=None, _session=None, handle_ratelimit=None, max_tries=None, request_timeout=None):
"""Returns the stats for the profiles on the specified regions and platform. The format for regions ... | python | async def get_stats(self, battletag: str, regions=(EUROPE, KOREA, AMERICAS, CHINA, JAPAN, ANY),
platform=None, _session=None, handle_ratelimit=None, max_tries=None, request_timeout=None):
"""Returns the stats for the profiles on the specified regions and platform. The format for regions ... | [
"async",
"def",
"get_stats",
"(",
"self",
",",
"battletag",
":",
"str",
",",
"regions",
"=",
"(",
"EUROPE",
",",
"KOREA",
",",
"AMERICAS",
",",
"CHINA",
",",
"JAPAN",
",",
"ANY",
")",
",",
"platform",
"=",
"None",
",",
"_session",
"=",
"None",
",",
... | Returns the stats for the profiles on the specified regions and platform. The format for regions without a matching user, the format is the same as get_profile.
The stats are returned in a dictionary with a similar format to what https://github.com/SunDwarf/OWAPI/blob/master/api.md#get-apiv3ubattletagstats spec... | [
"Returns",
"the",
"stats",
"for",
"the",
"profiles",
"on",
"the",
"specified",
"regions",
"and",
"platform",
".",
"The",
"format",
"for",
"regions",
"without",
"a",
"matching",
"user",
"the",
"format",
"is",
"the",
"same",
"as",
"get_profile",
".",
"The",
... | aba976a3c07c4932de13f4236d924b2901b149b9 | https://github.com/anthok/overwatch-api/blob/aba976a3c07c4932de13f4236d924b2901b149b9/overwatch_api/core.py#L98-L114 | train |
anthok/overwatch-api | overwatch_api/core.py | AsyncOWAPI._base_request | async def _base_request(self, battle_tag: str, endpoint_name: str, session: aiohttp.ClientSession, *, platform=None,
handle_ratelimit=None, max_tries=None, request_timeout=None):
"""Does a request to some endpoint. This is also where ratelimit logic is handled."""
# We check ... | python | async def _base_request(self, battle_tag: str, endpoint_name: str, session: aiohttp.ClientSession, *, platform=None,
handle_ratelimit=None, max_tries=None, request_timeout=None):
"""Does a request to some endpoint. This is also where ratelimit logic is handled."""
# We check ... | [
"async",
"def",
"_base_request",
"(",
"self",
",",
"battle_tag",
":",
"str",
",",
"endpoint_name",
":",
"str",
",",
"session",
":",
"aiohttp",
".",
"ClientSession",
",",
"*",
",",
"platform",
"=",
"None",
",",
"handle_ratelimit",
"=",
"None",
",",
"max_tri... | Does a request to some endpoint. This is also where ratelimit logic is handled. | [
"Does",
"a",
"request",
"to",
"some",
"endpoint",
".",
"This",
"is",
"also",
"where",
"ratelimit",
"logic",
"is",
"handled",
"."
] | aba976a3c07c4932de13f4236d924b2901b149b9 | https://github.com/anthok/overwatch-api/blob/aba976a3c07c4932de13f4236d924b2901b149b9/overwatch_api/core.py#L164-L224 | train |
anthok/overwatch-api | overwatch_api/core.py | AsyncOWAPI._async_get | async def _async_get(self, session: aiohttp.ClientSession, *args, _async_timeout_seconds: int = 5,
**kwargs):
"""Uses aiohttp to make a get request asynchronously.
Will raise asyncio.TimeoutError if the request could not be completed
within _async_timeout_seconds (defa... | python | async def _async_get(self, session: aiohttp.ClientSession, *args, _async_timeout_seconds: int = 5,
**kwargs):
"""Uses aiohttp to make a get request asynchronously.
Will raise asyncio.TimeoutError if the request could not be completed
within _async_timeout_seconds (defa... | [
"async",
"def",
"_async_get",
"(",
"self",
",",
"session",
":",
"aiohttp",
".",
"ClientSession",
",",
"*",
"args",
",",
"_async_timeout_seconds",
":",
"int",
"=",
"5",
",",
"*",
"*",
"kwargs",
")",
":",
"# Taken almost directly from the aiohttp tutorial",
"with"... | Uses aiohttp to make a get request asynchronously.
Will raise asyncio.TimeoutError if the request could not be completed
within _async_timeout_seconds (default 5) seconds. | [
"Uses",
"aiohttp",
"to",
"make",
"a",
"get",
"request",
"asynchronously",
".",
"Will",
"raise",
"asyncio",
".",
"TimeoutError",
"if",
"the",
"request",
"could",
"not",
"be",
"completed",
"within",
"_async_timeout_seconds",
"(",
"default",
"5",
")",
"seconds",
... | aba976a3c07c4932de13f4236d924b2901b149b9 | https://github.com/anthok/overwatch-api/blob/aba976a3c07c4932de13f4236d924b2901b149b9/overwatch_api/core.py#L226-L235 | train |
Xion/callee | callee/objects.py | is_method | def is_method(arg, min_arity=None, max_arity=None):
"""Check if argument is a method.
Optionally, we can also check if minimum or maximum arities
(number of accepted arguments) match given minimum and/or maximum.
"""
if not callable(arg):
return False
if not any(is_(arg) for is_ in (in... | python | def is_method(arg, min_arity=None, max_arity=None):
"""Check if argument is a method.
Optionally, we can also check if minimum or maximum arities
(number of accepted arguments) match given minimum and/or maximum.
"""
if not callable(arg):
return False
if not any(is_(arg) for is_ in (in... | [
"def",
"is_method",
"(",
"arg",
",",
"min_arity",
"=",
"None",
",",
"max_arity",
"=",
"None",
")",
":",
"if",
"not",
"callable",
"(",
"arg",
")",
":",
"return",
"False",
"if",
"not",
"any",
"(",
"is_",
"(",
"arg",
")",
"for",
"is_",
"in",
"(",
"i... | Check if argument is a method.
Optionally, we can also check if minimum or maximum arities
(number of accepted arguments) match given minimum and/or maximum. | [
"Check",
"if",
"argument",
"is",
"a",
"method",
"."
] | 58740f73ff9a76f5fe0075bf18d7345a0f9d961c | https://github.com/Xion/callee/blob/58740f73ff9a76f5fe0075bf18d7345a0f9d961c/callee/objects.py#L115-L154 | train |
Xion/callee | callee/objects.py | FileLike._is_readable | def _is_readable(self, obj):
"""Check if the argument is a readable file-like object."""
try:
read = getattr(obj, 'read')
except AttributeError:
return False
else:
return is_method(read, max_arity=1) | python | def _is_readable(self, obj):
"""Check if the argument is a readable file-like object."""
try:
read = getattr(obj, 'read')
except AttributeError:
return False
else:
return is_method(read, max_arity=1) | [
"def",
"_is_readable",
"(",
"self",
",",
"obj",
")",
":",
"try",
":",
"read",
"=",
"getattr",
"(",
"obj",
",",
"'read'",
")",
"except",
"AttributeError",
":",
"return",
"False",
"else",
":",
"return",
"is_method",
"(",
"read",
",",
"max_arity",
"=",
"1... | Check if the argument is a readable file-like object. | [
"Check",
"if",
"the",
"argument",
"is",
"a",
"readable",
"file",
"-",
"like",
"object",
"."
] | 58740f73ff9a76f5fe0075bf18d7345a0f9d961c | https://github.com/Xion/callee/blob/58740f73ff9a76f5fe0075bf18d7345a0f9d961c/callee/objects.py#L85-L92 | train |
Xion/callee | callee/objects.py | FileLike._is_writable | def _is_writable(self, obj):
"""Check if the argument is a writable file-like object."""
try:
write = getattr(obj, 'write')
except AttributeError:
return False
else:
return is_method(write, min_arity=1, max_arity=1) | python | def _is_writable(self, obj):
"""Check if the argument is a writable file-like object."""
try:
write = getattr(obj, 'write')
except AttributeError:
return False
else:
return is_method(write, min_arity=1, max_arity=1) | [
"def",
"_is_writable",
"(",
"self",
",",
"obj",
")",
":",
"try",
":",
"write",
"=",
"getattr",
"(",
"obj",
",",
"'write'",
")",
"except",
"AttributeError",
":",
"return",
"False",
"else",
":",
"return",
"is_method",
"(",
"write",
",",
"min_arity",
"=",
... | Check if the argument is a writable file-like object. | [
"Check",
"if",
"the",
"argument",
"is",
"a",
"writable",
"file",
"-",
"like",
"object",
"."
] | 58740f73ff9a76f5fe0075bf18d7345a0f9d961c | https://github.com/Xion/callee/blob/58740f73ff9a76f5fe0075bf18d7345a0f9d961c/callee/objects.py#L94-L101 | train |
scivision/msise00 | msise00/base.py | run | def run(time: datetime, altkm: float,
glat: Union[float, np.ndarray], glon: Union[float, np.ndarray], *,
f107a: float = None, f107: float = None, Ap: int = None) -> xarray.Dataset:
"""
loops the rungtd1d function below. Figure it's easier to troubleshoot in Python than Fortran.
"""
glat ... | python | def run(time: datetime, altkm: float,
glat: Union[float, np.ndarray], glon: Union[float, np.ndarray], *,
f107a: float = None, f107: float = None, Ap: int = None) -> xarray.Dataset:
"""
loops the rungtd1d function below. Figure it's easier to troubleshoot in Python than Fortran.
"""
glat ... | [
"def",
"run",
"(",
"time",
":",
"datetime",
",",
"altkm",
":",
"float",
",",
"glat",
":",
"Union",
"[",
"float",
",",
"np",
".",
"ndarray",
"]",
",",
"glon",
":",
"Union",
"[",
"float",
",",
"np",
".",
"ndarray",
"]",
",",
"*",
",",
"f107a",
":... | loops the rungtd1d function below. Figure it's easier to troubleshoot in Python than Fortran. | [
"loops",
"the",
"rungtd1d",
"function",
"below",
".",
"Figure",
"it",
"s",
"easier",
"to",
"troubleshoot",
"in",
"Python",
"than",
"Fortran",
"."
] | 13a283ec02679ab74672f284ba68a7a8f896dc6f | https://github.com/scivision/msise00/blob/13a283ec02679ab74672f284ba68a7a8f896dc6f/msise00/base.py#L34-L51 | train |
scivision/msise00 | msise00/base.py | loopalt_gtd | def loopalt_gtd(time: datetime,
glat: Union[float, np.ndarray], glon: Union[float, np.ndarray],
altkm: Union[float, List[float], np.ndarray], *,
f107a: float = None, f107: float = None, Ap: int = None) -> xarray.Dataset:
"""
loop over location and time
time: ... | python | def loopalt_gtd(time: datetime,
glat: Union[float, np.ndarray], glon: Union[float, np.ndarray],
altkm: Union[float, List[float], np.ndarray], *,
f107a: float = None, f107: float = None, Ap: int = None) -> xarray.Dataset:
"""
loop over location and time
time: ... | [
"def",
"loopalt_gtd",
"(",
"time",
":",
"datetime",
",",
"glat",
":",
"Union",
"[",
"float",
",",
"np",
".",
"ndarray",
"]",
",",
"glon",
":",
"Union",
"[",
"float",
",",
"np",
".",
"ndarray",
"]",
",",
"altkm",
":",
"Union",
"[",
"float",
",",
"... | loop over location and time
time: datetime or numpy.datetime64 or list of datetime or np.ndarray of datetime
glat: float or 2-D np.ndarray
glon: float or 2-D np.ndarray
altkm: float or list or 1-D np.ndarray | [
"loop",
"over",
"location",
"and",
"time"
] | 13a283ec02679ab74672f284ba68a7a8f896dc6f | https://github.com/scivision/msise00/blob/13a283ec02679ab74672f284ba68a7a8f896dc6f/msise00/base.py#L54-L87 | train |
scivision/msise00 | msise00/base.py | rungtd1d | def rungtd1d(time: datetime,
altkm: np.ndarray,
glat: float, glon: float, *,
f107a: float = None, f107: float = None, Ap: int = None) -> xarray.Dataset:
"""
This is the "atomic" function looped by other functions
"""
time = todatetime(time)
# %% get solar param... | python | def rungtd1d(time: datetime,
altkm: np.ndarray,
glat: float, glon: float, *,
f107a: float = None, f107: float = None, Ap: int = None) -> xarray.Dataset:
"""
This is the "atomic" function looped by other functions
"""
time = todatetime(time)
# %% get solar param... | [
"def",
"rungtd1d",
"(",
"time",
":",
"datetime",
",",
"altkm",
":",
"np",
".",
"ndarray",
",",
"glat",
":",
"float",
",",
"glon",
":",
"float",
",",
"*",
",",
"f107a",
":",
"float",
"=",
"None",
",",
"f107",
":",
"float",
"=",
"None",
",",
"Ap",
... | This is the "atomic" function looped by other functions | [
"This",
"is",
"the",
"atomic",
"function",
"looped",
"by",
"other",
"functions"
] | 13a283ec02679ab74672f284ba68a7a8f896dc6f | https://github.com/scivision/msise00/blob/13a283ec02679ab74672f284ba68a7a8f896dc6f/msise00/base.py#L90-L140 | train |
Xion/callee | callee/general.py | Matching._validate_desc | def _validate_desc(self, desc):
"""Validate the predicate description."""
if desc is None:
return desc
if not isinstance(desc, STRING_TYPES):
raise TypeError(
"predicate description for Matching must be a string, "
"got %r" % (type(desc),)... | python | def _validate_desc(self, desc):
"""Validate the predicate description."""
if desc is None:
return desc
if not isinstance(desc, STRING_TYPES):
raise TypeError(
"predicate description for Matching must be a string, "
"got %r" % (type(desc),)... | [
"def",
"_validate_desc",
"(",
"self",
",",
"desc",
")",
":",
"if",
"desc",
"is",
"None",
":",
"return",
"desc",
"if",
"not",
"isinstance",
"(",
"desc",
",",
"STRING_TYPES",
")",
":",
"raise",
"TypeError",
"(",
"\"predicate description for Matching must be a stri... | Validate the predicate description. | [
"Validate",
"the",
"predicate",
"description",
"."
] | 58740f73ff9a76f5fe0075bf18d7345a0f9d961c | https://github.com/Xion/callee/blob/58740f73ff9a76f5fe0075bf18d7345a0f9d961c/callee/general.py#L54-L74 | train |
Xion/callee | callee/operators.py | OperatorMatcher._get_placeholder_repr | def _get_placeholder_repr(self):
"""Return the placeholder part of matcher's ``__repr__``."""
placeholder = '...'
if self.TRANSFORM is not None:
placeholder = '%s(%s)' % (self.TRANSFORM.__name__, placeholder)
return placeholder | python | def _get_placeholder_repr(self):
"""Return the placeholder part of matcher's ``__repr__``."""
placeholder = '...'
if self.TRANSFORM is not None:
placeholder = '%s(%s)' % (self.TRANSFORM.__name__, placeholder)
return placeholder | [
"def",
"_get_placeholder_repr",
"(",
"self",
")",
":",
"placeholder",
"=",
"'...'",
"if",
"self",
".",
"TRANSFORM",
"is",
"not",
"None",
":",
"placeholder",
"=",
"'%s(%s)'",
"%",
"(",
"self",
".",
"TRANSFORM",
".",
"__name__",
",",
"placeholder",
")",
"ret... | Return the placeholder part of matcher's ``__repr__``. | [
"Return",
"the",
"placeholder",
"part",
"of",
"matcher",
"s",
"__repr__",
"."
] | 58740f73ff9a76f5fe0075bf18d7345a0f9d961c | https://github.com/Xion/callee/blob/58740f73ff9a76f5fe0075bf18d7345a0f9d961c/callee/operators.py#L104-L109 | train |
Xion/callee | callee/base.py | BaseMatcherMetaclass._validate_class_definition | def _validate_class_definition(meta, classname, bases, dict_):
"""Ensure the matcher class definition is acceptable.
:raise RuntimeError: If there is a problem
"""
# let the BaseMatcher class be created without hassle
if meta._is_base_matcher_class_definition(classname, dict_):
... | python | def _validate_class_definition(meta, classname, bases, dict_):
"""Ensure the matcher class definition is acceptable.
:raise RuntimeError: If there is a problem
"""
# let the BaseMatcher class be created without hassle
if meta._is_base_matcher_class_definition(classname, dict_):
... | [
"def",
"_validate_class_definition",
"(",
"meta",
",",
"classname",
",",
"bases",
",",
"dict_",
")",
":",
"# let the BaseMatcher class be created without hassle",
"if",
"meta",
".",
"_is_base_matcher_class_definition",
"(",
"classname",
",",
"dict_",
")",
":",
"return",... | Ensure the matcher class definition is acceptable.
:raise RuntimeError: If there is a problem | [
"Ensure",
"the",
"matcher",
"class",
"definition",
"is",
"acceptable",
".",
":",
"raise",
"RuntimeError",
":",
"If",
"there",
"is",
"a",
"problem"
] | 58740f73ff9a76f5fe0075bf18d7345a0f9d961c | https://github.com/Xion/callee/blob/58740f73ff9a76f5fe0075bf18d7345a0f9d961c/callee/base.py#L38-L71 | train |
Xion/callee | callee/base.py | BaseMatcherMetaclass._is_base_matcher_class_definition | def _is_base_matcher_class_definition(meta, classname, dict_):
"""Checks whether given class name and dictionary
define the :class:`BaseMatcher`.
"""
if classname != 'BaseMatcher':
return False
methods = list(filter(inspect.isfunction, dict_.values()))
return ... | python | def _is_base_matcher_class_definition(meta, classname, dict_):
"""Checks whether given class name and dictionary
define the :class:`BaseMatcher`.
"""
if classname != 'BaseMatcher':
return False
methods = list(filter(inspect.isfunction, dict_.values()))
return ... | [
"def",
"_is_base_matcher_class_definition",
"(",
"meta",
",",
"classname",
",",
"dict_",
")",
":",
"if",
"classname",
"!=",
"'BaseMatcher'",
":",
"return",
"False",
"methods",
"=",
"list",
"(",
"filter",
"(",
"inspect",
".",
"isfunction",
",",
"dict_",
".",
... | Checks whether given class name and dictionary
define the :class:`BaseMatcher`. | [
"Checks",
"whether",
"given",
"class",
"name",
"and",
"dictionary",
"define",
"the",
":",
"class",
":",
"BaseMatcher",
"."
] | 58740f73ff9a76f5fe0075bf18d7345a0f9d961c | https://github.com/Xion/callee/blob/58740f73ff9a76f5fe0075bf18d7345a0f9d961c/callee/base.py#L74-L81 | train |
Xion/callee | callee/base.py | BaseMatcherMetaclass._list_magic_methods | def _list_magic_methods(meta, class_):
"""Return names of magic methods defined by a class.
:return: Iterable of magic methods, each w/o the ``__`` prefix/suffix
"""
return [
name[2:-2] for name, member in class_.__dict__.items()
if len(name) > 4 and name.startswi... | python | def _list_magic_methods(meta, class_):
"""Return names of magic methods defined by a class.
:return: Iterable of magic methods, each w/o the ``__`` prefix/suffix
"""
return [
name[2:-2] for name, member in class_.__dict__.items()
if len(name) > 4 and name.startswi... | [
"def",
"_list_magic_methods",
"(",
"meta",
",",
"class_",
")",
":",
"return",
"[",
"name",
"[",
"2",
":",
"-",
"2",
"]",
"for",
"name",
",",
"member",
"in",
"class_",
".",
"__dict__",
".",
"items",
"(",
")",
"if",
"len",
"(",
"name",
")",
">",
"4... | Return names of magic methods defined by a class.
:return: Iterable of magic methods, each w/o the ``__`` prefix/suffix | [
"Return",
"names",
"of",
"magic",
"methods",
"defined",
"by",
"a",
"class",
".",
":",
"return",
":",
"Iterable",
"of",
"magic",
"methods",
"each",
"w",
"/",
"o",
"the",
"__",
"prefix",
"/",
"suffix"
] | 58740f73ff9a76f5fe0075bf18d7345a0f9d961c | https://github.com/Xion/callee/blob/58740f73ff9a76f5fe0075bf18d7345a0f9d961c/callee/base.py#L84-L92 | train |
podhmo/python-semver | semver/__init__.py | semver | def semver(version, loose):
if isinstance(version, SemVer):
if version.loose == loose:
return version
else:
version = version.version
elif not isinstance(version, str): # xxx:
raise InvalidTypeIncluded("must be str, but {!r}".format(version))
"""
if (!(t... | python | def semver(version, loose):
if isinstance(version, SemVer):
if version.loose == loose:
return version
else:
version = version.version
elif not isinstance(version, str): # xxx:
raise InvalidTypeIncluded("must be str, but {!r}".format(version))
"""
if (!(t... | [
"def",
"semver",
"(",
"version",
",",
"loose",
")",
":",
"if",
"isinstance",
"(",
"version",
",",
"SemVer",
")",
":",
"if",
"version",
".",
"loose",
"==",
"loose",
":",
"return",
"version",
"else",
":",
"version",
"=",
"version",
".",
"version",
"elif"... | if (!(this instanceof SemVer))
return new SemVer(version, loose); | [
"if",
"(",
"!",
"(",
"this",
"instanceof",
"SemVer",
"))",
"return",
"new",
"SemVer",
"(",
"version",
"loose",
")",
";"
] | 46d81c5d70ee716c48c7a8d44f9fefc6b86be33c | https://github.com/podhmo/python-semver/blob/46d81c5d70ee716c48c7a8d44f9fefc6b86be33c/semver/__init__.py#L288-L301 | train |
Xion/callee | docs/conf.py | autodoc_process_docstring | def autodoc_process_docstring(app, what, name, obj, options, lines):
"""Handler for the event emitted when autodoc processes a docstring.
See http://sphinx-doc.org/ext/autodoc.html#event-autodoc-process-docstring.
The TL;DR is that we can modify ``lines`` in-place to influence the output.
"""
# che... | python | def autodoc_process_docstring(app, what, name, obj, options, lines):
"""Handler for the event emitted when autodoc processes a docstring.
See http://sphinx-doc.org/ext/autodoc.html#event-autodoc-process-docstring.
The TL;DR is that we can modify ``lines`` in-place to influence the output.
"""
# che... | [
"def",
"autodoc_process_docstring",
"(",
"app",
",",
"what",
",",
"name",
",",
"obj",
",",
"options",
",",
"lines",
")",
":",
"# check that only symbols that can be directly imported from ``callee``",
"# package are being documented",
"_",
",",
"symbol",
"=",
"name",
".... | Handler for the event emitted when autodoc processes a docstring.
See http://sphinx-doc.org/ext/autodoc.html#event-autodoc-process-docstring.
The TL;DR is that we can modify ``lines`` in-place to influence the output. | [
"Handler",
"for",
"the",
"event",
"emitted",
"when",
"autodoc",
"processes",
"a",
"docstring",
".",
"See",
"http",
":",
"//",
"sphinx",
"-",
"doc",
".",
"org",
"/",
"ext",
"/",
"autodoc",
".",
"html#event",
"-",
"autodoc",
"-",
"process",
"-",
"docstring... | 58740f73ff9a76f5fe0075bf18d7345a0f9d961c | https://github.com/Xion/callee/blob/58740f73ff9a76f5fe0075bf18d7345a0f9d961c/docs/conf.py#L352-L374 | train |
WoLpH/mailjet | mailjet/contrib/django_mailjet/forms.py | SubscriptionForm.clean_email | def clean_email(self):
""" Raise ValidationError if the contact exists. """
contacts = self.api.lists.contacts(id=self.list_id)['result']
for contact in contacts:
if contact['email'] == self.cleaned_data['email']:
raise forms.ValidationError(
_(u'... | python | def clean_email(self):
""" Raise ValidationError if the contact exists. """
contacts = self.api.lists.contacts(id=self.list_id)['result']
for contact in contacts:
if contact['email'] == self.cleaned_data['email']:
raise forms.ValidationError(
_(u'... | [
"def",
"clean_email",
"(",
"self",
")",
":",
"contacts",
"=",
"self",
".",
"api",
".",
"lists",
".",
"contacts",
"(",
"id",
"=",
"self",
".",
"list_id",
")",
"[",
"'result'",
"]",
"for",
"contact",
"in",
"contacts",
":",
"if",
"contact",
"[",
"'email... | Raise ValidationError if the contact exists. | [
"Raise",
"ValidationError",
"if",
"the",
"contact",
"exists",
"."
] | f7f5102bf52be6a4a9c62afe474387481c806e27 | https://github.com/WoLpH/mailjet/blob/f7f5102bf52be6a4a9c62afe474387481c806e27/mailjet/contrib/django_mailjet/forms.py#L23-L32 | train |
WoLpH/mailjet | mailjet/contrib/django_mailjet/forms.py | SubscriptionForm.add_contact | def add_contact(self):
""" Create a contact with using the email on the list. """
self.api.lists.addcontact(
contact=self.cleaned_data['email'], id=self.list_id, method='POST') | python | def add_contact(self):
""" Create a contact with using the email on the list. """
self.api.lists.addcontact(
contact=self.cleaned_data['email'], id=self.list_id, method='POST') | [
"def",
"add_contact",
"(",
"self",
")",
":",
"self",
".",
"api",
".",
"lists",
".",
"addcontact",
"(",
"contact",
"=",
"self",
".",
"cleaned_data",
"[",
"'email'",
"]",
",",
"id",
"=",
"self",
".",
"list_id",
",",
"method",
"=",
"'POST'",
")"
] | Create a contact with using the email on the list. | [
"Create",
"a",
"contact",
"with",
"using",
"the",
"email",
"on",
"the",
"list",
"."
] | f7f5102bf52be6a4a9c62afe474387481c806e27 | https://github.com/WoLpH/mailjet/blob/f7f5102bf52be6a4a9c62afe474387481c806e27/mailjet/contrib/django_mailjet/forms.py#L38-L41 | train |
WoLpH/mailjet | mailjet/contrib/django_mailjet/forms.py | SubscriptionForm.api | def api(self):
""" Get or create an Api() instance using django settings. """
api = getattr(self, '_api', None)
if api is None:
self._api = mailjet.Api()
return self._api | python | def api(self):
""" Get or create an Api() instance using django settings. """
api = getattr(self, '_api', None)
if api is None:
self._api = mailjet.Api()
return self._api | [
"def",
"api",
"(",
"self",
")",
":",
"api",
"=",
"getattr",
"(",
"self",
",",
"'_api'",
",",
"None",
")",
"if",
"api",
"is",
"None",
":",
"self",
".",
"_api",
"=",
"mailjet",
".",
"Api",
"(",
")",
"return",
"self",
".",
"_api"
] | Get or create an Api() instance using django settings. | [
"Get",
"or",
"create",
"an",
"Api",
"()",
"instance",
"using",
"django",
"settings",
"."
] | f7f5102bf52be6a4a9c62afe474387481c806e27 | https://github.com/WoLpH/mailjet/blob/f7f5102bf52be6a4a9c62afe474387481c806e27/mailjet/contrib/django_mailjet/forms.py#L44-L51 | train |
WoLpH/mailjet | mailjet/contrib/django_mailjet/forms.py | SubscriptionForm.list_id | def list_id(self):
""" Get or create the list id. """
list_id = getattr(self, '_list_id', None)
if list_id is None:
for l in self.api.lists.all()['lists']:
if l['name'] == self.list_name:
self._list_id = l['id']
if not getattr(self, '... | python | def list_id(self):
""" Get or create the list id. """
list_id = getattr(self, '_list_id', None)
if list_id is None:
for l in self.api.lists.all()['lists']:
if l['name'] == self.list_name:
self._list_id = l['id']
if not getattr(self, '... | [
"def",
"list_id",
"(",
"self",
")",
":",
"list_id",
"=",
"getattr",
"(",
"self",
",",
"'_list_id'",
",",
"None",
")",
"if",
"list_id",
"is",
"None",
":",
"for",
"l",
"in",
"self",
".",
"api",
".",
"lists",
".",
"all",
"(",
")",
"[",
"'lists'",
"]... | Get or create the list id. | [
"Get",
"or",
"create",
"the",
"list",
"id",
"."
] | f7f5102bf52be6a4a9c62afe474387481c806e27 | https://github.com/WoLpH/mailjet/blob/f7f5102bf52be6a4a9c62afe474387481c806e27/mailjet/contrib/django_mailjet/forms.py#L54-L68 | train |
Xion/callee | callee/_compat.py | getargspec | def getargspec(obj):
"""Portable version of inspect.getargspec().
Necessary because the original is no longer available
starting from Python 3.6.
:return: 4-tuple of (argnames, varargname, kwargname, defaults)
Note that distinction between positional-or-keyword and keyword-only
parameters wil... | python | def getargspec(obj):
"""Portable version of inspect.getargspec().
Necessary because the original is no longer available
starting from Python 3.6.
:return: 4-tuple of (argnames, varargname, kwargname, defaults)
Note that distinction between positional-or-keyword and keyword-only
parameters wil... | [
"def",
"getargspec",
"(",
"obj",
")",
":",
"try",
":",
"return",
"inspect",
".",
"getargspec",
"(",
"obj",
")",
"except",
"AttributeError",
":",
"pass",
"# we let a TypeError through",
"# translate the signature object back into the 4-tuple",
"argnames",
"=",
"[",
"]"... | Portable version of inspect.getargspec().
Necessary because the original is no longer available
starting from Python 3.6.
:return: 4-tuple of (argnames, varargname, kwargname, defaults)
Note that distinction between positional-or-keyword and keyword-only
parameters will be lost, as the original g... | [
"Portable",
"version",
"of",
"inspect",
".",
"getargspec",
"()",
"."
] | 58740f73ff9a76f5fe0075bf18d7345a0f9d961c | https://github.com/Xion/callee/blob/58740f73ff9a76f5fe0075bf18d7345a0f9d961c/callee/_compat.py#L81-L112 | train |
Xion/callee | setup.py | read_tags | def read_tags(filename):
"""Reads values of "magic tags" defined in the given Python file.
:param filename: Python filename to read the tags from
:return: Dictionary of tags
"""
with open(filename) as f:
ast_tree = ast.parse(f.read(), filename)
res = {}
for node in ast.walk(ast_tre... | python | def read_tags(filename):
"""Reads values of "magic tags" defined in the given Python file.
:param filename: Python filename to read the tags from
:return: Dictionary of tags
"""
with open(filename) as f:
ast_tree = ast.parse(f.read(), filename)
res = {}
for node in ast.walk(ast_tre... | [
"def",
"read_tags",
"(",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
")",
"as",
"f",
":",
"ast_tree",
"=",
"ast",
".",
"parse",
"(",
"f",
".",
"read",
"(",
")",
",",
"filename",
")",
"res",
"=",
"{",
"}",
"for",
"node",
"in",
"ast",
... | Reads values of "magic tags" defined in the given Python file.
:param filename: Python filename to read the tags from
:return: Dictionary of tags | [
"Reads",
"values",
"of",
"magic",
"tags",
"defined",
"in",
"the",
"given",
"Python",
"file",
"."
] | 58740f73ff9a76f5fe0075bf18d7345a0f9d961c | https://github.com/Xion/callee/blob/58740f73ff9a76f5fe0075bf18d7345a0f9d961c/setup.py#L16-L39 | train |
MichaelAquilina/hashedindex | hashedindex/textparser.py | normalize_unicode | def normalize_unicode(text):
"""
Normalize any unicode characters to ascii equivalent
https://docs.python.org/2/library/unicodedata.html#unicodedata.normalize
"""
if isinstance(text, six.text_type):
return unicodedata.normalize('NFKD', text).encode('ascii', 'ignore').decode('utf8')
else:... | python | def normalize_unicode(text):
"""
Normalize any unicode characters to ascii equivalent
https://docs.python.org/2/library/unicodedata.html#unicodedata.normalize
"""
if isinstance(text, six.text_type):
return unicodedata.normalize('NFKD', text).encode('ascii', 'ignore').decode('utf8')
else:... | [
"def",
"normalize_unicode",
"(",
"text",
")",
":",
"if",
"isinstance",
"(",
"text",
",",
"six",
".",
"text_type",
")",
":",
"return",
"unicodedata",
".",
"normalize",
"(",
"'NFKD'",
",",
"text",
")",
".",
"encode",
"(",
"'ascii'",
",",
"'ignore'",
")",
... | Normalize any unicode characters to ascii equivalent
https://docs.python.org/2/library/unicodedata.html#unicodedata.normalize | [
"Normalize",
"any",
"unicode",
"characters",
"to",
"ascii",
"equivalent",
"https",
":",
"//",
"docs",
".",
"python",
".",
"org",
"/",
"2",
"/",
"library",
"/",
"unicodedata",
".",
"html#unicodedata",
".",
"normalize"
] | 5a84dcd6c697ea04162cf7b2683fa2723845b51c | https://github.com/MichaelAquilina/hashedindex/blob/5a84dcd6c697ea04162cf7b2683fa2723845b51c/hashedindex/textparser.py#L51-L59 | train |
MichaelAquilina/hashedindex | hashedindex/textparser.py | word_tokenize | def word_tokenize(text, stopwords=_stopwords, ngrams=None, min_length=0, ignore_numeric=True):
"""
Parses the given text and yields tokens which represent words within
the given text. Tokens are assumed to be divided by any form of
whitespace character.
"""
if ngrams is None:
ngrams = 1
... | python | def word_tokenize(text, stopwords=_stopwords, ngrams=None, min_length=0, ignore_numeric=True):
"""
Parses the given text and yields tokens which represent words within
the given text. Tokens are assumed to be divided by any form of
whitespace character.
"""
if ngrams is None:
ngrams = 1
... | [
"def",
"word_tokenize",
"(",
"text",
",",
"stopwords",
"=",
"_stopwords",
",",
"ngrams",
"=",
"None",
",",
"min_length",
"=",
"0",
",",
"ignore_numeric",
"=",
"True",
")",
":",
"if",
"ngrams",
"is",
"None",
":",
"ngrams",
"=",
"1",
"text",
"=",
"re",
... | Parses the given text and yields tokens which represent words within
the given text. Tokens are assumed to be divided by any form of
whitespace character. | [
"Parses",
"the",
"given",
"text",
"and",
"yields",
"tokens",
"which",
"represent",
"words",
"within",
"the",
"given",
"text",
".",
"Tokens",
"are",
"assumed",
"to",
"be",
"divided",
"by",
"any",
"form",
"of",
"whitespace",
"character",
"."
] | 5a84dcd6c697ea04162cf7b2683fa2723845b51c | https://github.com/MichaelAquilina/hashedindex/blob/5a84dcd6c697ea04162cf7b2683fa2723845b51c/hashedindex/textparser.py#L67-L89 | train |
scivision/msise00 | msise00/build.py | cmake_setup | def cmake_setup():
"""
attempt to build using CMake >= 3
"""
cmake_exe = shutil.which('cmake')
if not cmake_exe:
raise FileNotFoundError('CMake not available')
wopts = ['-G', 'MinGW Makefiles', '-DCMAKE_SH="CMAKE_SH-NOTFOUND'] if os.name == 'nt' else []
subprocess.check_call([cmake... | python | def cmake_setup():
"""
attempt to build using CMake >= 3
"""
cmake_exe = shutil.which('cmake')
if not cmake_exe:
raise FileNotFoundError('CMake not available')
wopts = ['-G', 'MinGW Makefiles', '-DCMAKE_SH="CMAKE_SH-NOTFOUND'] if os.name == 'nt' else []
subprocess.check_call([cmake... | [
"def",
"cmake_setup",
"(",
")",
":",
"cmake_exe",
"=",
"shutil",
".",
"which",
"(",
"'cmake'",
")",
"if",
"not",
"cmake_exe",
":",
"raise",
"FileNotFoundError",
"(",
"'CMake not available'",
")",
"wopts",
"=",
"[",
"'-G'",
",",
"'MinGW Makefiles'",
",",
"'-D... | attempt to build using CMake >= 3 | [
"attempt",
"to",
"build",
"using",
"CMake",
">",
"=",
"3"
] | 13a283ec02679ab74672f284ba68a7a8f896dc6f | https://github.com/scivision/msise00/blob/13a283ec02679ab74672f284ba68a7a8f896dc6f/msise00/build.py#L27-L44 | train |
scivision/msise00 | msise00/build.py | meson_setup | def meson_setup():
"""
attempt to build with Meson + Ninja
"""
meson_exe = shutil.which('meson')
ninja_exe = shutil.which('ninja')
if not meson_exe or not ninja_exe:
raise FileNotFoundError('Meson or Ninja not available')
if not (BINDIR / 'build.ninja').is_file():
subproces... | python | def meson_setup():
"""
attempt to build with Meson + Ninja
"""
meson_exe = shutil.which('meson')
ninja_exe = shutil.which('ninja')
if not meson_exe or not ninja_exe:
raise FileNotFoundError('Meson or Ninja not available')
if not (BINDIR / 'build.ninja').is_file():
subproces... | [
"def",
"meson_setup",
"(",
")",
":",
"meson_exe",
"=",
"shutil",
".",
"which",
"(",
"'meson'",
")",
"ninja_exe",
"=",
"shutil",
".",
"which",
"(",
"'ninja'",
")",
"if",
"not",
"meson_exe",
"or",
"not",
"ninja_exe",
":",
"raise",
"FileNotFoundError",
"(",
... | attempt to build with Meson + Ninja | [
"attempt",
"to",
"build",
"with",
"Meson",
"+",
"Ninja"
] | 13a283ec02679ab74672f284ba68a7a8f896dc6f | https://github.com/scivision/msise00/blob/13a283ec02679ab74672f284ba68a7a8f896dc6f/msise00/build.py#L47-L63 | train |
MichaelAquilina/hashedindex | hashedindex/__init__.py | HashedIndex.add_term_occurrence | def add_term_occurrence(self, term, document):
"""
Adds an occurrence of the term in the specified document.
"""
if document not in self._documents:
self._documents[document] = 0
if term not in self._terms:
if self._freeze:
return
... | python | def add_term_occurrence(self, term, document):
"""
Adds an occurrence of the term in the specified document.
"""
if document not in self._documents:
self._documents[document] = 0
if term not in self._terms:
if self._freeze:
return
... | [
"def",
"add_term_occurrence",
"(",
"self",
",",
"term",
",",
"document",
")",
":",
"if",
"document",
"not",
"in",
"self",
".",
"_documents",
":",
"self",
".",
"_documents",
"[",
"document",
"]",
"=",
"0",
"if",
"term",
"not",
"in",
"self",
".",
"_terms... | Adds an occurrence of the term in the specified document. | [
"Adds",
"an",
"occurrence",
"of",
"the",
"term",
"in",
"the",
"specified",
"document",
"."
] | 5a84dcd6c697ea04162cf7b2683fa2723845b51c | https://github.com/MichaelAquilina/hashedindex/blob/5a84dcd6c697ea04162cf7b2683fa2723845b51c/hashedindex/__init__.py#L69-L86 | train |
MichaelAquilina/hashedindex | hashedindex/__init__.py | HashedIndex.get_total_term_frequency | def get_total_term_frequency(self, term):
"""
Gets the frequency of the specified term in the entire corpus
added to the HashedIndex.
"""
if term not in self._terms:
raise IndexError(TERM_DOES_NOT_EXIST)
return sum(self._terms[term].values()) | python | def get_total_term_frequency(self, term):
"""
Gets the frequency of the specified term in the entire corpus
added to the HashedIndex.
"""
if term not in self._terms:
raise IndexError(TERM_DOES_NOT_EXIST)
return sum(self._terms[term].values()) | [
"def",
"get_total_term_frequency",
"(",
"self",
",",
"term",
")",
":",
"if",
"term",
"not",
"in",
"self",
".",
"_terms",
":",
"raise",
"IndexError",
"(",
"TERM_DOES_NOT_EXIST",
")",
"return",
"sum",
"(",
"self",
".",
"_terms",
"[",
"term",
"]",
".",
"val... | Gets the frequency of the specified term in the entire corpus
added to the HashedIndex. | [
"Gets",
"the",
"frequency",
"of",
"the",
"specified",
"term",
"in",
"the",
"entire",
"corpus",
"added",
"to",
"the",
"HashedIndex",
"."
] | 5a84dcd6c697ea04162cf7b2683fa2723845b51c | https://github.com/MichaelAquilina/hashedindex/blob/5a84dcd6c697ea04162cf7b2683fa2723845b51c/hashedindex/__init__.py#L88-L96 | train |
MichaelAquilina/hashedindex | hashedindex/__init__.py | HashedIndex.get_term_frequency | def get_term_frequency(self, term, document, normalized=False):
"""
Returns the frequency of the term specified in the document.
"""
if document not in self._documents:
raise IndexError(DOCUMENT_DOES_NOT_EXIST)
if term not in self._terms:
raise IndexError... | python | def get_term_frequency(self, term, document, normalized=False):
"""
Returns the frequency of the term specified in the document.
"""
if document not in self._documents:
raise IndexError(DOCUMENT_DOES_NOT_EXIST)
if term not in self._terms:
raise IndexError... | [
"def",
"get_term_frequency",
"(",
"self",
",",
"term",
",",
"document",
",",
"normalized",
"=",
"False",
")",
":",
"if",
"document",
"not",
"in",
"self",
".",
"_documents",
":",
"raise",
"IndexError",
"(",
"DOCUMENT_DOES_NOT_EXIST",
")",
"if",
"term",
"not",... | Returns the frequency of the term specified in the document. | [
"Returns",
"the",
"frequency",
"of",
"the",
"term",
"specified",
"in",
"the",
"document",
"."
] | 5a84dcd6c697ea04162cf7b2683fa2723845b51c | https://github.com/MichaelAquilina/hashedindex/blob/5a84dcd6c697ea04162cf7b2683fa2723845b51c/hashedindex/__init__.py#L98-L112 | train |
MichaelAquilina/hashedindex | hashedindex/__init__.py | HashedIndex.get_document_frequency | def get_document_frequency(self, term):
"""
Returns the number of documents the specified term appears in.
"""
if term not in self._terms:
raise IndexError(TERM_DOES_NOT_EXIST)
else:
return len(self._terms[term]) | python | def get_document_frequency(self, term):
"""
Returns the number of documents the specified term appears in.
"""
if term not in self._terms:
raise IndexError(TERM_DOES_NOT_EXIST)
else:
return len(self._terms[term]) | [
"def",
"get_document_frequency",
"(",
"self",
",",
"term",
")",
":",
"if",
"term",
"not",
"in",
"self",
".",
"_terms",
":",
"raise",
"IndexError",
"(",
"TERM_DOES_NOT_EXIST",
")",
"else",
":",
"return",
"len",
"(",
"self",
".",
"_terms",
"[",
"term",
"]"... | Returns the number of documents the specified term appears in. | [
"Returns",
"the",
"number",
"of",
"documents",
"the",
"specified",
"term",
"appears",
"in",
"."
] | 5a84dcd6c697ea04162cf7b2683fa2723845b51c | https://github.com/MichaelAquilina/hashedindex/blob/5a84dcd6c697ea04162cf7b2683fa2723845b51c/hashedindex/__init__.py#L114-L121 | train |
MichaelAquilina/hashedindex | hashedindex/__init__.py | HashedIndex.get_document_length | def get_document_length(self, document):
"""
Returns the number of terms found within the specified document.
"""
if document in self._documents:
return self._documents[document]
else:
raise IndexError(DOCUMENT_DOES_NOT_EXIST) | python | def get_document_length(self, document):
"""
Returns the number of terms found within the specified document.
"""
if document in self._documents:
return self._documents[document]
else:
raise IndexError(DOCUMENT_DOES_NOT_EXIST) | [
"def",
"get_document_length",
"(",
"self",
",",
"document",
")",
":",
"if",
"document",
"in",
"self",
".",
"_documents",
":",
"return",
"self",
".",
"_documents",
"[",
"document",
"]",
"else",
":",
"raise",
"IndexError",
"(",
"DOCUMENT_DOES_NOT_EXIST",
")"
] | Returns the number of terms found within the specified document. | [
"Returns",
"the",
"number",
"of",
"terms",
"found",
"within",
"the",
"specified",
"document",
"."
] | 5a84dcd6c697ea04162cf7b2683fa2723845b51c | https://github.com/MichaelAquilina/hashedindex/blob/5a84dcd6c697ea04162cf7b2683fa2723845b51c/hashedindex/__init__.py#L123-L130 | train |
MichaelAquilina/hashedindex | hashedindex/__init__.py | HashedIndex.get_documents | def get_documents(self, term):
"""
Returns all documents related to the specified term in the
form of a Counter object.
"""
if term not in self._terms:
raise IndexError(TERM_DOES_NOT_EXIST)
else:
return self._terms[term] | python | def get_documents(self, term):
"""
Returns all documents related to the specified term in the
form of a Counter object.
"""
if term not in self._terms:
raise IndexError(TERM_DOES_NOT_EXIST)
else:
return self._terms[term] | [
"def",
"get_documents",
"(",
"self",
",",
"term",
")",
":",
"if",
"term",
"not",
"in",
"self",
".",
"_terms",
":",
"raise",
"IndexError",
"(",
"TERM_DOES_NOT_EXIST",
")",
"else",
":",
"return",
"self",
".",
"_terms",
"[",
"term",
"]"
] | Returns all documents related to the specified term in the
form of a Counter object. | [
"Returns",
"all",
"documents",
"related",
"to",
"the",
"specified",
"term",
"in",
"the",
"form",
"of",
"a",
"Counter",
"object",
"."
] | 5a84dcd6c697ea04162cf7b2683fa2723845b51c | https://github.com/MichaelAquilina/hashedindex/blob/5a84dcd6c697ea04162cf7b2683fa2723845b51c/hashedindex/__init__.py#L132-L140 | train |
MichaelAquilina/hashedindex | hashedindex/__init__.py | HashedIndex.get_tfidf | def get_tfidf(self, term, document, normalized=False):
"""
Returns the Term-Frequency Inverse-Document-Frequency value for the given
term in the specified document. If normalized is True, term frequency will
be divided by the document length.
"""
tf = self.get_term_freque... | python | def get_tfidf(self, term, document, normalized=False):
"""
Returns the Term-Frequency Inverse-Document-Frequency value for the given
term in the specified document. If normalized is True, term frequency will
be divided by the document length.
"""
tf = self.get_term_freque... | [
"def",
"get_tfidf",
"(",
"self",
",",
"term",
",",
"document",
",",
"normalized",
"=",
"False",
")",
":",
"tf",
"=",
"self",
".",
"get_term_frequency",
"(",
"term",
",",
"document",
")",
"# Speeds up performance by avoiding extra calculations",
"if",
"tf",
"!=",... | Returns the Term-Frequency Inverse-Document-Frequency value for the given
term in the specified document. If normalized is True, term frequency will
be divided by the document length. | [
"Returns",
"the",
"Term",
"-",
"Frequency",
"Inverse",
"-",
"Document",
"-",
"Frequency",
"value",
"for",
"the",
"given",
"term",
"in",
"the",
"specified",
"document",
".",
"If",
"normalized",
"is",
"True",
"term",
"frequency",
"will",
"be",
"divided",
"by",... | 5a84dcd6c697ea04162cf7b2683fa2723845b51c | https://github.com/MichaelAquilina/hashedindex/blob/5a84dcd6c697ea04162cf7b2683fa2723845b51c/hashedindex/__init__.py#L151-L171 | train |
MichaelAquilina/hashedindex | hashedindex/__init__.py | HashedIndex.generate_document_vector | def generate_document_vector(self, doc, mode='tfidf'):
"""
Returns a representation of the specified document as a feature vector
weighted according the mode specified (by default tf-dif).
A custom weighting function can also be passed which receives the hashedindex
instance, th... | python | def generate_document_vector(self, doc, mode='tfidf'):
"""
Returns a representation of the specified document as a feature vector
weighted according the mode specified (by default tf-dif).
A custom weighting function can also be passed which receives the hashedindex
instance, th... | [
"def",
"generate_document_vector",
"(",
"self",
",",
"doc",
",",
"mode",
"=",
"'tfidf'",
")",
":",
"if",
"mode",
"==",
"'tfidf'",
":",
"selected_function",
"=",
"HashedIndex",
".",
"get_tfidf",
"elif",
"mode",
"==",
"'ntfidf'",
":",
"selected_function",
"=",
... | Returns a representation of the specified document as a feature vector
weighted according the mode specified (by default tf-dif).
A custom weighting function can also be passed which receives the hashedindex
instance, the selected term and document as parameters.
The result will be ret... | [
"Returns",
"a",
"representation",
"of",
"the",
"specified",
"document",
"as",
"a",
"feature",
"vector",
"weighted",
"according",
"the",
"mode",
"specified",
"(",
"by",
"default",
"tf",
"-",
"dif",
")",
"."
] | 5a84dcd6c697ea04162cf7b2683fa2723845b51c | https://github.com/MichaelAquilina/hashedindex/blob/5a84dcd6c697ea04162cf7b2683fa2723845b51c/hashedindex/__init__.py#L179-L212 | train |
MichaelAquilina/hashedindex | hashedindex/__init__.py | HashedIndex.generate_feature_matrix | def generate_feature_matrix(self, mode='tfidf'):
"""
Returns a feature matrix in the form of a list of lists which
represents the terms and documents in this Inverted Index using
the tf-idf weighting by default. The term counts in each
document can alternatively be used by specif... | python | def generate_feature_matrix(self, mode='tfidf'):
"""
Returns a feature matrix in the form of a list of lists which
represents the terms and documents in this Inverted Index using
the tf-idf weighting by default. The term counts in each
document can alternatively be used by specif... | [
"def",
"generate_feature_matrix",
"(",
"self",
",",
"mode",
"=",
"'tfidf'",
")",
":",
"result",
"=",
"[",
"]",
"for",
"doc",
"in",
"self",
".",
"_documents",
":",
"result",
".",
"append",
"(",
"self",
".",
"generate_document_vector",
"(",
"doc",
",",
"mo... | Returns a feature matrix in the form of a list of lists which
represents the terms and documents in this Inverted Index using
the tf-idf weighting by default. The term counts in each
document can alternatively be used by specifying scheme='count'.
A custom weighting function can also be... | [
"Returns",
"a",
"feature",
"matrix",
"in",
"the",
"form",
"of",
"a",
"list",
"of",
"lists",
"which",
"represents",
"the",
"terms",
"and",
"documents",
"in",
"this",
"Inverted",
"Index",
"using",
"the",
"tf",
"-",
"idf",
"weighting",
"by",
"default",
".",
... | 5a84dcd6c697ea04162cf7b2683fa2723845b51c | https://github.com/MichaelAquilina/hashedindex/blob/5a84dcd6c697ea04162cf7b2683fa2723845b51c/hashedindex/__init__.py#L214-L236 | train |
bkeating/python-payflowpro | payflowpro/client.py | find_class_in_list | def find_class_in_list(klass, lst):
"""
Returns the first occurrence of an instance of type `klass` in
the given list, or None if no such instance is present.
"""
filtered = list(filter(lambda x: x.__class__ == klass, lst))
if filtered:
return filtered[0]
return None | python | def find_class_in_list(klass, lst):
"""
Returns the first occurrence of an instance of type `klass` in
the given list, or None if no such instance is present.
"""
filtered = list(filter(lambda x: x.__class__ == klass, lst))
if filtered:
return filtered[0]
return None | [
"def",
"find_class_in_list",
"(",
"klass",
",",
"lst",
")",
":",
"filtered",
"=",
"list",
"(",
"filter",
"(",
"lambda",
"x",
":",
"x",
".",
"__class__",
"==",
"klass",
",",
"lst",
")",
")",
"if",
"filtered",
":",
"return",
"filtered",
"[",
"0",
"]",
... | Returns the first occurrence of an instance of type `klass` in
the given list, or None if no such instance is present. | [
"Returns",
"the",
"first",
"occurrence",
"of",
"an",
"instance",
"of",
"type",
"klass",
"in",
"the",
"given",
"list",
"or",
"None",
"if",
"no",
"such",
"instance",
"is",
"present",
"."
] | e74fc85135f171caa28277196fdcf7c7481ff298 | https://github.com/bkeating/python-payflowpro/blob/e74fc85135f171caa28277196fdcf7c7481ff298/payflowpro/client.py#L400-L408 | train |
bkeating/python-payflowpro | payflowpro/client.py | find_classes_in_list | def find_classes_in_list(klasses, lst):
"""
Returns a tuple containing an entry corresponding to each of
the requested class types, where the entry is either the first
object instance of that type or None of no such instances are
available.
Example Usage:
find_classes_in_list(
... | python | def find_classes_in_list(klasses, lst):
"""
Returns a tuple containing an entry corresponding to each of
the requested class types, where the entry is either the first
object instance of that type or None of no such instances are
available.
Example Usage:
find_classes_in_list(
... | [
"def",
"find_classes_in_list",
"(",
"klasses",
",",
"lst",
")",
":",
"if",
"not",
"isinstance",
"(",
"klasses",
",",
"list",
")",
":",
"klasses",
"=",
"[",
"klasses",
"]",
"return",
"tuple",
"(",
"map",
"(",
"lambda",
"klass",
":",
"find_class_in_list",
... | Returns a tuple containing an entry corresponding to each of
the requested class types, where the entry is either the first
object instance of that type or None of no such instances are
available.
Example Usage:
find_classes_in_list(
[Address, Response],
[<classes.Response.... | [
"Returns",
"a",
"tuple",
"containing",
"an",
"entry",
"corresponding",
"to",
"each",
"of",
"the",
"requested",
"class",
"types",
"where",
"the",
"entry",
"is",
"either",
"the",
"first",
"object",
"instance",
"of",
"that",
"type",
"or",
"None",
"of",
"no",
... | e74fc85135f171caa28277196fdcf7c7481ff298 | https://github.com/bkeating/python-payflowpro/blob/e74fc85135f171caa28277196fdcf7c7481ff298/payflowpro/client.py#L410-L427 | train |
bkeating/python-payflowpro | payflowpro/client.py | PayflowProClient._build_parmlist | def _build_parmlist(self, parameters):
"""
Converts a dictionary of name and value pairs into a
PARMLIST string value acceptable to the Payflow Pro API.
"""
args = []
for key, value in parameters.items():
if not value is None:
# We always us... | python | def _build_parmlist(self, parameters):
"""
Converts a dictionary of name and value pairs into a
PARMLIST string value acceptable to the Payflow Pro API.
"""
args = []
for key, value in parameters.items():
if not value is None:
# We always us... | [
"def",
"_build_parmlist",
"(",
"self",
",",
"parameters",
")",
":",
"args",
"=",
"[",
"]",
"for",
"key",
",",
"value",
"in",
"parameters",
".",
"items",
"(",
")",
":",
"if",
"not",
"value",
"is",
"None",
":",
"# We always use the explicit-length keyname form... | Converts a dictionary of name and value pairs into a
PARMLIST string value acceptable to the Payflow Pro API. | [
"Converts",
"a",
"dictionary",
"of",
"name",
"and",
"value",
"pairs",
"into",
"a",
"PARMLIST",
"string",
"value",
"acceptable",
"to",
"the",
"Payflow",
"Pro",
"API",
"."
] | e74fc85135f171caa28277196fdcf7c7481ff298 | https://github.com/bkeating/python-payflowpro/blob/e74fc85135f171caa28277196fdcf7c7481ff298/payflowpro/client.py#L106-L131 | train |
bkeating/python-payflowpro | payflowpro/client.py | PayflowProClient._parse_parmlist | def _parse_parmlist(self, parmlist):
"""
Parses a PARMLIST string into a dictionary of name and value
pairs. The parsing is complicated by the following:
- parameter keynames may or may not include a length
specification
- delimiter characters (=, &) may a... | python | def _parse_parmlist(self, parmlist):
"""
Parses a PARMLIST string into a dictionary of name and value
pairs. The parsing is complicated by the following:
- parameter keynames may or may not include a length
specification
- delimiter characters (=, &) may a... | [
"def",
"_parse_parmlist",
"(",
"self",
",",
"parmlist",
")",
":",
"parmlist",
"=",
"\"&\"",
"+",
"parmlist",
"name_re",
"=",
"re",
".",
"compile",
"(",
"r'\\&([A-Z0-9_]+)(\\[\\d+\\])?='",
")",
"results",
"=",
"{",
"}",
"offset",
"=",
"0",
"match",
"=",
"na... | Parses a PARMLIST string into a dictionary of name and value
pairs. The parsing is complicated by the following:
- parameter keynames may or may not include a length
specification
- delimiter characters (=, &) may appear inside parameter
values, provided the pa... | [
"Parses",
"a",
"PARMLIST",
"string",
"into",
"a",
"dictionary",
"of",
"name",
"and",
"value",
"pairs",
".",
"The",
"parsing",
"is",
"complicated",
"by",
"the",
"following",
":",
"-",
"parameter",
"keynames",
"may",
"or",
"may",
"not",
"include",
"a",
"leng... | e74fc85135f171caa28277196fdcf7c7481ff298 | https://github.com/bkeating/python-payflowpro/blob/e74fc85135f171caa28277196fdcf7c7481ff298/payflowpro/client.py#L133-L174 | train |
damianbraun/nominatim | nominatim/nominatim.py | NominatimRequest.request | def request(self, url):
"""
Send a http request to the given *url*, try to decode
the reply assuming it's JSON in UTF-8, and return the result
:returns: Decoded result, or None in case of an error
:rtype: mixed
"""
self.logger.debug('url:\n' + url)
try:
... | python | def request(self, url):
"""
Send a http request to the given *url*, try to decode
the reply assuming it's JSON in UTF-8, and return the result
:returns: Decoded result, or None in case of an error
:rtype: mixed
"""
self.logger.debug('url:\n' + url)
try:
... | [
"def",
"request",
"(",
"self",
",",
"url",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"'url:\\n'",
"+",
"url",
")",
"try",
":",
"response",
"=",
"urlopen",
"(",
"url",
")",
"return",
"json",
".",
"loads",
"(",
"response",
".",
"read",
"(",... | Send a http request to the given *url*, try to decode
the reply assuming it's JSON in UTF-8, and return the result
:returns: Decoded result, or None in case of an error
:rtype: mixed | [
"Send",
"a",
"http",
"request",
"to",
"the",
"given",
"*",
"url",
"*",
"try",
"to",
"decode",
"the",
"reply",
"assuming",
"it",
"s",
"JSON",
"in",
"UTF",
"-",
"8",
"and",
"return",
"the",
"result"
] | d3cc40e1d31755aabf7302a617ab6e982eeb9b4f | https://github.com/damianbraun/nominatim/blob/d3cc40e1d31755aabf7302a617ab6e982eeb9b4f/nominatim/nominatim.py#L58-L73 | train |
damianbraun/nominatim | nominatim/nominatim.py | Nominatim.query | def query(self, address, acceptlanguage=None, limit=20,
countrycodes=None):
"""
Issue a geocoding query for *address* to the
Nominatim instance and return the decoded results
:param address: a query string with an address
or presumed parts of an add... | python | def query(self, address, acceptlanguage=None, limit=20,
countrycodes=None):
"""
Issue a geocoding query for *address* to the
Nominatim instance and return the decoded results
:param address: a query string with an address
or presumed parts of an add... | [
"def",
"query",
"(",
"self",
",",
"address",
",",
"acceptlanguage",
"=",
"None",
",",
"limit",
"=",
"20",
",",
"countrycodes",
"=",
"None",
")",
":",
"url",
"=",
"self",
".",
"url",
"+",
"'&q='",
"+",
"quote_plus",
"(",
"address",
")",
"if",
"acceptl... | Issue a geocoding query for *address* to the
Nominatim instance and return the decoded results
:param address: a query string with an address
or presumed parts of an address
:type address: str or (if python2) unicode
:param acceptlanguage: rfc2616 language code
... | [
"Issue",
"a",
"geocoding",
"query",
"for",
"*",
"address",
"*",
"to",
"the",
"Nominatim",
"instance",
"and",
"return",
"the",
"decoded",
"results"
] | d3cc40e1d31755aabf7302a617ab6e982eeb9b4f | https://github.com/damianbraun/nominatim/blob/d3cc40e1d31755aabf7302a617ab6e982eeb9b4f/nominatim/nominatim.py#L92-L119 | train |
damianbraun/nominatim | nominatim/nominatim.py | NominatimReverse.query | def query(self, lat=None, lon=None, osm_id=None, osm_type=None,
acceptlanguage='', zoom=18):
"""
Issue a reverse geocoding query for a place given
by *lat* and *lon*, or by *osm_id* and *osm_type*
to the Nominatim instance and return the decoded results
:param lat:... | python | def query(self, lat=None, lon=None, osm_id=None, osm_type=None,
acceptlanguage='', zoom=18):
"""
Issue a reverse geocoding query for a place given
by *lat* and *lon*, or by *osm_id* and *osm_type*
to the Nominatim instance and return the decoded results
:param lat:... | [
"def",
"query",
"(",
"self",
",",
"lat",
"=",
"None",
",",
"lon",
"=",
"None",
",",
"osm_id",
"=",
"None",
",",
"osm_type",
"=",
"None",
",",
"acceptlanguage",
"=",
"''",
",",
"zoom",
"=",
"18",
")",
":",
"url",
"=",
"self",
".",
"url",
"if",
"... | Issue a reverse geocoding query for a place given
by *lat* and *lon*, or by *osm_id* and *osm_type*
to the Nominatim instance and return the decoded results
:param lat: the geograpical latitude of the place
:param lon: the geograpical longitude of the place
:param osm_id: openst... | [
"Issue",
"a",
"reverse",
"geocoding",
"query",
"for",
"a",
"place",
"given",
"by",
"*",
"lat",
"*",
"and",
"*",
"lon",
"*",
"or",
"by",
"*",
"osm_id",
"*",
"and",
"*",
"osm_type",
"*",
"to",
"the",
"Nominatim",
"instance",
"and",
"return",
"the",
"de... | d3cc40e1d31755aabf7302a617ab6e982eeb9b4f | https://github.com/damianbraun/nominatim/blob/d3cc40e1d31755aabf7302a617ab6e982eeb9b4f/nominatim/nominatim.py#L139-L180 | train |
darothen/xbpch | xbpch/grid.py | CTMGrid.from_model | def from_model(cls, model_name, **kwargs):
"""
Define a grid using the specifications of a given model.
Parameters
----------
model_name : string
Name the model (see :func:`get_supported_models` for available
model names).
Supports multiple fo... | python | def from_model(cls, model_name, **kwargs):
"""
Define a grid using the specifications of a given model.
Parameters
----------
model_name : string
Name the model (see :func:`get_supported_models` for available
model names).
Supports multiple fo... | [
"def",
"from_model",
"(",
"cls",
",",
"model_name",
",",
"*",
"*",
"kwargs",
")",
":",
"settings",
"=",
"_get_model_info",
"(",
"model_name",
")",
"model",
"=",
"settings",
".",
"pop",
"(",
"'model_name'",
")",
"for",
"k",
",",
"v",
"in",
"list",
"(",
... | Define a grid using the specifications of a given model.
Parameters
----------
model_name : string
Name the model (see :func:`get_supported_models` for available
model names).
Supports multiple formats (e.g., 'GEOS5', 'GEOS-5' or 'GEOS_5').
**kwargs :... | [
"Define",
"a",
"grid",
"using",
"the",
"specifications",
"of",
"a",
"given",
"model",
"."
] | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/grid.py#L143-L180 | train |
darothen/xbpch | xbpch/grid.py | CTMGrid.copy_from_model | def copy_from_model(cls, model_name, reference, **kwargs):
"""
Set-up a user-defined grid using specifications of a reference
grid model.
Parameters
----------
model_name : string
name of the user-defined grid model.
reference : string or :class:`CTMG... | python | def copy_from_model(cls, model_name, reference, **kwargs):
"""
Set-up a user-defined grid using specifications of a reference
grid model.
Parameters
----------
model_name : string
name of the user-defined grid model.
reference : string or :class:`CTMG... | [
"def",
"copy_from_model",
"(",
"cls",
",",
"model_name",
",",
"reference",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"reference",
",",
"cls",
")",
":",
"settings",
"=",
"reference",
".",
"__dict__",
".",
"copy",
"(",
")",
"settings",
... | Set-up a user-defined grid using specifications of a reference
grid model.
Parameters
----------
model_name : string
name of the user-defined grid model.
reference : string or :class:`CTMGrid` instance
Name of the reference model (see :func:`get_supported... | [
"Set",
"-",
"up",
"a",
"user",
"-",
"defined",
"grid",
"using",
"specifications",
"of",
"a",
"reference",
"grid",
"model",
"."
] | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/grid.py#L183-L214 | train |
darothen/xbpch | xbpch/grid.py | CTMGrid.get_layers | def get_layers(self, Psurf=1013.25, Ptop=0.01, **kwargs):
"""
Compute scalars or coordinates associated to the vertical layers.
Parameters
----------
grid_spec : CTMGrid object
CTMGrid containing the information necessary to re-construct grid
levels for a... | python | def get_layers(self, Psurf=1013.25, Ptop=0.01, **kwargs):
"""
Compute scalars or coordinates associated to the vertical layers.
Parameters
----------
grid_spec : CTMGrid object
CTMGrid containing the information necessary to re-construct grid
levels for a... | [
"def",
"get_layers",
"(",
"self",
",",
"Psurf",
"=",
"1013.25",
",",
"Ptop",
"=",
"0.01",
",",
"*",
"*",
"kwargs",
")",
":",
"Psurf",
"=",
"np",
".",
"asarray",
"(",
"Psurf",
")",
"output_ndims",
"=",
"Psurf",
".",
"ndim",
"+",
"1",
"if",
"output_n... | Compute scalars or coordinates associated to the vertical layers.
Parameters
----------
grid_spec : CTMGrid object
CTMGrid containing the information necessary to re-construct grid
levels for a given model coordinate system.
Returns
-------
dicti... | [
"Compute",
"scalars",
"or",
"coordinates",
"associated",
"to",
"the",
"vertical",
"layers",
"."
] | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/grid.py#L217-L324 | train |
darothen/xbpch | xbpch/grid.py | CTMGrid.get_lonlat | def get_lonlat(self):
"""
Calculate longitude-latitude grid for a specified resolution and
configuration / ordering.
Parameters
----------
rlon, rlat : float
Resolution (in degrees) of longitude and latitude grids.
halfpolar : bool (default=True)
... | python | def get_lonlat(self):
"""
Calculate longitude-latitude grid for a specified resolution and
configuration / ordering.
Parameters
----------
rlon, rlat : float
Resolution (in degrees) of longitude and latitude grids.
halfpolar : bool (default=True)
... | [
"def",
"get_lonlat",
"(",
"self",
")",
":",
"rlon",
",",
"rlat",
"=",
"self",
".",
"resolution",
"# Compute number of grid cells in each direction",
"Nlon",
"=",
"int",
"(",
"360.",
"/",
"rlon",
")",
"Nlat",
"=",
"int",
"(",
"180.",
"/",
"rlat",
")",
"+",
... | Calculate longitude-latitude grid for a specified resolution and
configuration / ordering.
Parameters
----------
rlon, rlat : float
Resolution (in degrees) of longitude and latitude grids.
halfpolar : bool (default=True)
Polar grid boxes span half of rlat... | [
"Calculate",
"longitude",
"-",
"latitude",
"grid",
"for",
"a",
"specified",
"resolution",
"and",
"configuration",
"/",
"ordering",
"."
] | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/grid.py#L327-L371 | train |
openSUSE/py2pack | py2pack/__init__.py | _get_template_dirs | def _get_template_dirs():
"""existing directories where to search for jinja2 templates. The order
is important. The first found template from the first found dir wins!"""
return filter(lambda x: os.path.exists(x), [
# user dir
os.path.join(os.path.expanduser('~'), '.py2pack', 'templates'),
... | python | def _get_template_dirs():
"""existing directories where to search for jinja2 templates. The order
is important. The first found template from the first found dir wins!"""
return filter(lambda x: os.path.exists(x), [
# user dir
os.path.join(os.path.expanduser('~'), '.py2pack', 'templates'),
... | [
"def",
"_get_template_dirs",
"(",
")",
":",
"return",
"filter",
"(",
"lambda",
"x",
":",
"os",
".",
"path",
".",
"exists",
"(",
"x",
")",
",",
"[",
"# user dir",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"expanduser",
"(",
"'~'",... | existing directories where to search for jinja2 templates. The order
is important. The first found template from the first found dir wins! | [
"existing",
"directories",
"where",
"to",
"search",
"for",
"jinja2",
"templates",
".",
"The",
"order",
"is",
"important",
".",
"The",
"first",
"found",
"template",
"from",
"the",
"first",
"found",
"dir",
"wins!"
] | 4ff689900dd2c1a390b5359ce1037c188b75fc65 | https://github.com/openSUSE/py2pack/blob/4ff689900dd2c1a390b5359ce1037c188b75fc65/py2pack/__init__.py#L53-L63 | train |
openSUSE/py2pack | py2pack/__init__.py | _license_from_classifiers | def _license_from_classifiers(data):
"""try to get a license from the classifiers"""
classifiers = data.get('classifiers', [])
found_license = None
for c in classifiers:
if c.startswith("License :: OSI Approved :: "):
found_license = c.replace("License :: OSI Approved :: ", "")
r... | python | def _license_from_classifiers(data):
"""try to get a license from the classifiers"""
classifiers = data.get('classifiers', [])
found_license = None
for c in classifiers:
if c.startswith("License :: OSI Approved :: "):
found_license = c.replace("License :: OSI Approved :: ", "")
r... | [
"def",
"_license_from_classifiers",
"(",
"data",
")",
":",
"classifiers",
"=",
"data",
".",
"get",
"(",
"'classifiers'",
",",
"[",
"]",
")",
"found_license",
"=",
"None",
"for",
"c",
"in",
"classifiers",
":",
"if",
"c",
".",
"startswith",
"(",
"\"License :... | try to get a license from the classifiers | [
"try",
"to",
"get",
"a",
"license",
"from",
"the",
"classifiers"
] | 4ff689900dd2c1a390b5359ce1037c188b75fc65 | https://github.com/openSUSE/py2pack/blob/4ff689900dd2c1a390b5359ce1037c188b75fc65/py2pack/__init__.py#L177-L184 | train |
openSUSE/py2pack | py2pack/__init__.py | _normalize_license | def _normalize_license(data):
"""try to get SDPX license"""
license = data.get('license', None)
if not license:
# try to get license from classifiers
license = _license_from_classifiers(data)
if license:
if license in SDPX_LICENSES.keys():
data['license'] = SDPX_LICEN... | python | def _normalize_license(data):
"""try to get SDPX license"""
license = data.get('license', None)
if not license:
# try to get license from classifiers
license = _license_from_classifiers(data)
if license:
if license in SDPX_LICENSES.keys():
data['license'] = SDPX_LICEN... | [
"def",
"_normalize_license",
"(",
"data",
")",
":",
"license",
"=",
"data",
".",
"get",
"(",
"'license'",
",",
"None",
")",
"if",
"not",
"license",
":",
"# try to get license from classifiers",
"license",
"=",
"_license_from_classifiers",
"(",
"data",
")",
"if",... | try to get SDPX license | [
"try",
"to",
"get",
"SDPX",
"license"
] | 4ff689900dd2c1a390b5359ce1037c188b75fc65 | https://github.com/openSUSE/py2pack/blob/4ff689900dd2c1a390b5359ce1037c188b75fc65/py2pack/__init__.py#L187-L199 | train |
asmeurer/iterm2-tools | iterm2_tools/ipython.py | wrap_prompts_class | def wrap_prompts_class(Klass):
"""
Wrap an IPython's Prompt class
This is needed in order for Prompt to inject the correct escape sequences
at the right positions for shell integrations.
"""
try:
from prompt_toolkit.token import ZeroWidthEscape
except ImportError:
return K... | python | def wrap_prompts_class(Klass):
"""
Wrap an IPython's Prompt class
This is needed in order for Prompt to inject the correct escape sequences
at the right positions for shell integrations.
"""
try:
from prompt_toolkit.token import ZeroWidthEscape
except ImportError:
return K... | [
"def",
"wrap_prompts_class",
"(",
"Klass",
")",
":",
"try",
":",
"from",
"prompt_toolkit",
".",
"token",
"import",
"ZeroWidthEscape",
"except",
"ImportError",
":",
"return",
"Klass",
"class",
"ITerm2IPythonPrompt",
"(",
"Klass",
")",
":",
"def",
"in_prompt_tokens"... | Wrap an IPython's Prompt class
This is needed in order for Prompt to inject the correct escape sequences
at the right positions for shell integrations. | [
"Wrap",
"an",
"IPython",
"s",
"Prompt",
"class"
] | 97b1b593bb02884521c2c05ed414f178de0b934e | https://github.com/asmeurer/iterm2-tools/blob/97b1b593bb02884521c2c05ed414f178de0b934e/iterm2_tools/ipython.py#L113-L137 | train |
blixt/py-starbound | starbound/btreedb5.py | BTreeDB5.get_all_keys | def get_all_keys(self, start=None):
"""
A generator which yields a list of all valid keys starting at the
given `start` offset. If `start` is `None`, we will start from
the root of the tree.
"""
s = self.stream
if not start:
start = HEADER_SIZE + self... | python | def get_all_keys(self, start=None):
"""
A generator which yields a list of all valid keys starting at the
given `start` offset. If `start` is `None`, we will start from
the root of the tree.
"""
s = self.stream
if not start:
start = HEADER_SIZE + self... | [
"def",
"get_all_keys",
"(",
"self",
",",
"start",
"=",
"None",
")",
":",
"s",
"=",
"self",
".",
"stream",
"if",
"not",
"start",
":",
"start",
"=",
"HEADER_SIZE",
"+",
"self",
".",
"block_size",
"*",
"self",
".",
"root_block",
"s",
".",
"seek",
"(",
... | A generator which yields a list of all valid keys starting at the
given `start` offset. If `start` is `None`, we will start from
the root of the tree. | [
"A",
"generator",
"which",
"yields",
"a",
"list",
"of",
"all",
"valid",
"keys",
"starting",
"at",
"the",
"given",
"start",
"offset",
".",
"If",
"start",
"is",
"None",
"we",
"will",
"start",
"from",
"the",
"root",
"of",
"the",
"tree",
"."
] | 68a2f6bfef73d8803191f937c69005a64eeae017 | https://github.com/blixt/py-starbound/blob/68a2f6bfef73d8803191f937c69005a64eeae017/starbound/btreedb5.py#L69-L107 | train |
darothen/xbpch | xbpch/uff.py | _replace_star | def _replace_star(fmt, size):
"""
Replace the `*` placeholder in a format string (fmt), so that
struct.calcsize(fmt) is equal to the given `size` using the format
following the placeholder.
Raises `ValueError` if number of `*` is larger than 1. If no `*`
in `fmt`, returns `fmt` without checking... | python | def _replace_star(fmt, size):
"""
Replace the `*` placeholder in a format string (fmt), so that
struct.calcsize(fmt) is equal to the given `size` using the format
following the placeholder.
Raises `ValueError` if number of `*` is larger than 1. If no `*`
in `fmt`, returns `fmt` without checking... | [
"def",
"_replace_star",
"(",
"fmt",
",",
"size",
")",
":",
"n_stars",
"=",
"fmt",
".",
"count",
"(",
"'*'",
")",
"if",
"n_stars",
">",
"1",
":",
"raise",
"ValueError",
"(",
"\"More than one `*` in format (%s).\"",
"%",
"fmt",
")",
"if",
"n_stars",
":",
"... | Replace the `*` placeholder in a format string (fmt), so that
struct.calcsize(fmt) is equal to the given `size` using the format
following the placeholder.
Raises `ValueError` if number of `*` is larger than 1. If no `*`
in `fmt`, returns `fmt` without checking its size!
Examples
--------
... | [
"Replace",
"the",
"*",
"placeholder",
"in",
"a",
"format",
"string",
"(",
"fmt",
")",
"so",
"that",
"struct",
".",
"calcsize",
"(",
"fmt",
")",
"is",
"equal",
"to",
"the",
"given",
"size",
"using",
"the",
"format",
"following",
"the",
"placeholder",
"."
... | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/uff.py#L160-L186 | train |
darothen/xbpch | xbpch/uff.py | FortranFile._fix | def _fix(self, fmt='i'):
"""
Read pre- or suffix of line at current position with given
format `fmt` (default 'i').
"""
fmt = self.endian + fmt
fix = self.read(struct.calcsize(fmt))
if fix:
return struct.unpack(fmt, fix)[0]
else:
ra... | python | def _fix(self, fmt='i'):
"""
Read pre- or suffix of line at current position with given
format `fmt` (default 'i').
"""
fmt = self.endian + fmt
fix = self.read(struct.calcsize(fmt))
if fix:
return struct.unpack(fmt, fix)[0]
else:
ra... | [
"def",
"_fix",
"(",
"self",
",",
"fmt",
"=",
"'i'",
")",
":",
"fmt",
"=",
"self",
".",
"endian",
"+",
"fmt",
"fix",
"=",
"self",
".",
"read",
"(",
"struct",
".",
"calcsize",
"(",
"fmt",
")",
")",
"if",
"fix",
":",
"return",
"struct",
".",
"unpa... | Read pre- or suffix of line at current position with given
format `fmt` (default 'i'). | [
"Read",
"pre",
"-",
"or",
"suffix",
"of",
"line",
"at",
"current",
"position",
"with",
"given",
"format",
"fmt",
"(",
"default",
"i",
")",
"."
] | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/uff.py#L67-L77 | train |
darothen/xbpch | xbpch/uff.py | FortranFile.readline | def readline(self, fmt=None):
"""
Return next unformatted "line". If format is given, unpack content,
otherwise return byte string.
"""
prefix_size = self._fix()
if fmt is None:
content = self.read(prefix_size)
else:
fmt = self.endian + fm... | python | def readline(self, fmt=None):
"""
Return next unformatted "line". If format is given, unpack content,
otherwise return byte string.
"""
prefix_size = self._fix()
if fmt is None:
content = self.read(prefix_size)
else:
fmt = self.endian + fm... | [
"def",
"readline",
"(",
"self",
",",
"fmt",
"=",
"None",
")",
":",
"prefix_size",
"=",
"self",
".",
"_fix",
"(",
")",
"if",
"fmt",
"is",
"None",
":",
"content",
"=",
"self",
".",
"read",
"(",
"prefix_size",
")",
"else",
":",
"fmt",
"=",
"self",
"... | Return next unformatted "line". If format is given, unpack content,
otherwise return byte string. | [
"Return",
"next",
"unformatted",
"line",
".",
"If",
"format",
"is",
"given",
"unpack",
"content",
"otherwise",
"return",
"byte",
"string",
"."
] | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/uff.py#L79-L102 | train |
darothen/xbpch | xbpch/uff.py | FortranFile.skipline | def skipline(self):
"""
Skip the next line and returns position and size of line.
Raises IOError if pre- and suffix of line do not match.
"""
position = self.tell()
prefix = self._fix()
self.seek(prefix, 1) # skip content
suffix = self._fix()
if ... | python | def skipline(self):
"""
Skip the next line and returns position and size of line.
Raises IOError if pre- and suffix of line do not match.
"""
position = self.tell()
prefix = self._fix()
self.seek(prefix, 1) # skip content
suffix = self._fix()
if ... | [
"def",
"skipline",
"(",
"self",
")",
":",
"position",
"=",
"self",
".",
"tell",
"(",
")",
"prefix",
"=",
"self",
".",
"_fix",
"(",
")",
"self",
".",
"seek",
"(",
"prefix",
",",
"1",
")",
"# skip content",
"suffix",
"=",
"self",
".",
"_fix",
"(",
... | Skip the next line and returns position and size of line.
Raises IOError if pre- and suffix of line do not match. | [
"Skip",
"the",
"next",
"line",
"and",
"returns",
"position",
"and",
"size",
"of",
"line",
".",
"Raises",
"IOError",
"if",
"pre",
"-",
"and",
"suffix",
"of",
"line",
"do",
"not",
"match",
"."
] | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/uff.py#L110-L123 | train |
darothen/xbpch | xbpch/uff.py | FortranFile.writeline | def writeline(self, fmt, *args):
"""
Write `line` (list of objects) with given `fmt` to file. The
`line` will be chained if object is iterable (except for
basestrings).
"""
fmt = self.endian + fmt
size = struct.calcsize(fmt)
fix = struct.pack(self.endian ... | python | def writeline(self, fmt, *args):
"""
Write `line` (list of objects) with given `fmt` to file. The
`line` will be chained if object is iterable (except for
basestrings).
"""
fmt = self.endian + fmt
size = struct.calcsize(fmt)
fix = struct.pack(self.endian ... | [
"def",
"writeline",
"(",
"self",
",",
"fmt",
",",
"*",
"args",
")",
":",
"fmt",
"=",
"self",
".",
"endian",
"+",
"fmt",
"size",
"=",
"struct",
".",
"calcsize",
"(",
"fmt",
")",
"fix",
"=",
"struct",
".",
"pack",
"(",
"self",
".",
"endian",
"+",
... | Write `line` (list of objects) with given `fmt` to file. The
`line` will be chained if object is iterable (except for
basestrings). | [
"Write",
"line",
"(",
"list",
"of",
"objects",
")",
"with",
"given",
"fmt",
"to",
"file",
".",
"The",
"line",
"will",
"be",
"chained",
"if",
"object",
"is",
"iterable",
"(",
"except",
"for",
"basestrings",
")",
"."
] | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/uff.py#L125-L139 | train |
darothen/xbpch | xbpch/uff.py | FortranFile.writelines | def writelines(self, lines, fmt):
"""
Write `lines` with given `format`.
"""
if isinstance(fmt, basestring):
fmt = [fmt] * len(lines)
for f, line in zip(fmt, lines):
self.writeline(f, line, self.endian) | python | def writelines(self, lines, fmt):
"""
Write `lines` with given `format`.
"""
if isinstance(fmt, basestring):
fmt = [fmt] * len(lines)
for f, line in zip(fmt, lines):
self.writeline(f, line, self.endian) | [
"def",
"writelines",
"(",
"self",
",",
"lines",
",",
"fmt",
")",
":",
"if",
"isinstance",
"(",
"fmt",
",",
"basestring",
")",
":",
"fmt",
"=",
"[",
"fmt",
"]",
"*",
"len",
"(",
"lines",
")",
"for",
"f",
",",
"line",
"in",
"zip",
"(",
"fmt",
","... | Write `lines` with given `format`. | [
"Write",
"lines",
"with",
"given",
"format",
"."
] | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/uff.py#L141-L148 | train |
blixt/py-starbound | starbound/sbon.py | read_varint | def read_varint(stream):
"""Read while the most significant bit is set, then put the 7 least
significant bits of all read bytes together to create a number.
"""
value = 0
while True:
byte = ord(stream.read(1))
if not byte & 0b10000000:
return value << 7 | byte
va... | python | def read_varint(stream):
"""Read while the most significant bit is set, then put the 7 least
significant bits of all read bytes together to create a number.
"""
value = 0
while True:
byte = ord(stream.read(1))
if not byte & 0b10000000:
return value << 7 | byte
va... | [
"def",
"read_varint",
"(",
"stream",
")",
":",
"value",
"=",
"0",
"while",
"True",
":",
"byte",
"=",
"ord",
"(",
"stream",
".",
"read",
"(",
"1",
")",
")",
"if",
"not",
"byte",
"&",
"0b10000000",
":",
"return",
"value",
"<<",
"7",
"|",
"byte",
"v... | Read while the most significant bit is set, then put the 7 least
significant bits of all read bytes together to create a number. | [
"Read",
"while",
"the",
"most",
"significant",
"bit",
"is",
"set",
"then",
"put",
"the",
"7",
"least",
"significant",
"bits",
"of",
"all",
"read",
"bytes",
"together",
"to",
"create",
"a",
"number",
"."
] | 68a2f6bfef73d8803191f937c69005a64eeae017 | https://github.com/blixt/py-starbound/blob/68a2f6bfef73d8803191f937c69005a64eeae017/starbound/sbon.py#L70-L80 | train |
darothen/xbpch | xbpch/core.py | open_bpchdataset | def open_bpchdataset(filename, fields=[], categories=[],
tracerinfo_file='tracerinfo.dat',
diaginfo_file='diaginfo.dat',
endian=">", decode_cf=True,
memmap=True, dask=True, return_store=False):
""" Open a GEOS-Chem BPCH file output ... | python | def open_bpchdataset(filename, fields=[], categories=[],
tracerinfo_file='tracerinfo.dat',
diaginfo_file='diaginfo.dat',
endian=">", decode_cf=True,
memmap=True, dask=True, return_store=False):
""" Open a GEOS-Chem BPCH file output ... | [
"def",
"open_bpchdataset",
"(",
"filename",
",",
"fields",
"=",
"[",
"]",
",",
"categories",
"=",
"[",
"]",
",",
"tracerinfo_file",
"=",
"'tracerinfo.dat'",
",",
"diaginfo_file",
"=",
"'diaginfo.dat'",
",",
"endian",
"=",
"\">\"",
",",
"decode_cf",
"=",
"Tru... | Open a GEOS-Chem BPCH file output as an xarray Dataset.
Parameters
----------
filename : string
Path to the output file to read in.
{tracerinfo,diaginfo}_file : string, optional
Path to the metadata "info" .dat files which are used to decipher
the metadata corresponding to each ... | [
"Open",
"a",
"GEOS",
"-",
"Chem",
"BPCH",
"file",
"output",
"as",
"an",
"xarray",
"Dataset",
"."
] | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/core.py#L26-L126 | train |
darothen/xbpch | xbpch/core.py | open_mfbpchdataset | def open_mfbpchdataset(paths, concat_dim='time', compat='no_conflicts',
preprocess=None, lock=None, **kwargs):
""" Open multiple bpch files as a single dataset.
You must have dask installed for this to work, as this greatly
simplifies issues relating to multi-file I/O.
Also, ple... | python | def open_mfbpchdataset(paths, concat_dim='time', compat='no_conflicts',
preprocess=None, lock=None, **kwargs):
""" Open multiple bpch files as a single dataset.
You must have dask installed for this to work, as this greatly
simplifies issues relating to multi-file I/O.
Also, ple... | [
"def",
"open_mfbpchdataset",
"(",
"paths",
",",
"concat_dim",
"=",
"'time'",
",",
"compat",
"=",
"'no_conflicts'",
",",
"preprocess",
"=",
"None",
",",
"lock",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"xarray",
".",
"backends",
".",
"api",... | Open multiple bpch files as a single dataset.
You must have dask installed for this to work, as this greatly
simplifies issues relating to multi-file I/O.
Also, please note that this is not a very performant routine. I/O is still
limited by the fact that we need to manually scan/read through each bpch... | [
"Open",
"multiple",
"bpch",
"files",
"as",
"a",
"single",
"dataset",
"."
] | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/core.py#L129-L215 | train |
bitlabstudio/django-multilingual-news | multilingual_news/south_migrations/0006_migrate_placeholder_fields.py | Migration.forwards | def forwards(self, orm):
"Write your forwards methods here."
# Note: Remember to use orm['appname.ModelName'] rather than "from appname.models..."
for entry in orm['multilingual_news.NewsEntry'].objects.all():
self.migrate_placeholder(
orm, entry, 'excerpt', 'multilin... | python | def forwards(self, orm):
"Write your forwards methods here."
# Note: Remember to use orm['appname.ModelName'] rather than "from appname.models..."
for entry in orm['multilingual_news.NewsEntry'].objects.all():
self.migrate_placeholder(
orm, entry, 'excerpt', 'multilin... | [
"def",
"forwards",
"(",
"self",
",",
"orm",
")",
":",
"# Note: Remember to use orm['appname.ModelName'] rather than \"from appname.models...\"",
"for",
"entry",
"in",
"orm",
"[",
"'multilingual_news.NewsEntry'",
"]",
".",
"objects",
".",
"all",
"(",
")",
":",
"self",
... | Write your forwards methods here. | [
"Write",
"your",
"forwards",
"methods",
"here",
"."
] | 2ddc076ce2002a9fa462dbba701441879b49a54d | https://github.com/bitlabstudio/django-multilingual-news/blob/2ddc076ce2002a9fa462dbba701441879b49a54d/multilingual_news/south_migrations/0006_migrate_placeholder_fields.py#L35-L42 | train |
asmeurer/iterm2-tools | iterm2_tools/images.py | image_bytes | def image_bytes(b, filename=None, inline=1, width='auto', height='auto',
preserve_aspect_ratio=None):
"""
Return a bytes string that displays image given by bytes b in the terminal
If filename=None, the filename defaults to "Unnamed file"
width and height are strings, following the format
... | python | def image_bytes(b, filename=None, inline=1, width='auto', height='auto',
preserve_aspect_ratio=None):
"""
Return a bytes string that displays image given by bytes b in the terminal
If filename=None, the filename defaults to "Unnamed file"
width and height are strings, following the format
... | [
"def",
"image_bytes",
"(",
"b",
",",
"filename",
"=",
"None",
",",
"inline",
"=",
"1",
",",
"width",
"=",
"'auto'",
",",
"height",
"=",
"'auto'",
",",
"preserve_aspect_ratio",
"=",
"None",
")",
":",
"if",
"preserve_aspect_ratio",
"is",
"None",
":",
"if",... | Return a bytes string that displays image given by bytes b in the terminal
If filename=None, the filename defaults to "Unnamed file"
width and height are strings, following the format
N: N character cells.
Npx: N pixels.
N%: N percent of the session's width or height.
'auto... | [
"Return",
"a",
"bytes",
"string",
"that",
"displays",
"image",
"given",
"by",
"bytes",
"b",
"in",
"the",
"terminal"
] | 97b1b593bb02884521c2c05ed414f178de0b934e | https://github.com/asmeurer/iterm2-tools/blob/97b1b593bb02884521c2c05ed414f178de0b934e/iterm2_tools/images.py#L15-L54 | train |
asmeurer/iterm2-tools | iterm2_tools/images.py | display_image_bytes | def display_image_bytes(b, filename=None, inline=1, width='auto',
height='auto', preserve_aspect_ratio=None):
"""
Display the image given by the bytes b in the terminal.
If filename=None the filename defaults to "Unnamed file".
width and height are strings, following the format
N: N chara... | python | def display_image_bytes(b, filename=None, inline=1, width='auto',
height='auto', preserve_aspect_ratio=None):
"""
Display the image given by the bytes b in the terminal.
If filename=None the filename defaults to "Unnamed file".
width and height are strings, following the format
N: N chara... | [
"def",
"display_image_bytes",
"(",
"b",
",",
"filename",
"=",
"None",
",",
"inline",
"=",
"1",
",",
"width",
"=",
"'auto'",
",",
"height",
"=",
"'auto'",
",",
"preserve_aspect_ratio",
"=",
"None",
")",
":",
"sys",
".",
"stdout",
".",
"buffer",
".",
"wr... | Display the image given by the bytes b in the terminal.
If filename=None the filename defaults to "Unnamed file".
width and height are strings, following the format
N: N character cells.
Npx: N pixels.
N%: N percent of the session's width or height.
'auto': The image's inhe... | [
"Display",
"the",
"image",
"given",
"by",
"the",
"bytes",
"b",
"in",
"the",
"terminal",
"."
] | 97b1b593bb02884521c2c05ed414f178de0b934e | https://github.com/asmeurer/iterm2-tools/blob/97b1b593bb02884521c2c05ed414f178de0b934e/iterm2_tools/images.py#L56-L83 | train |
asmeurer/iterm2-tools | iterm2_tools/images.py | display_image_file | def display_image_file(fn, width='auto', height='auto', preserve_aspect_ratio=None):
"""
Display an image in the terminal.
A newline is not printed.
width and height are strings, following the format
N: N character cells.
Npx: N pixels.
N%: N percent of the session's width o... | python | def display_image_file(fn, width='auto', height='auto', preserve_aspect_ratio=None):
"""
Display an image in the terminal.
A newline is not printed.
width and height are strings, following the format
N: N character cells.
Npx: N pixels.
N%: N percent of the session's width o... | [
"def",
"display_image_file",
"(",
"fn",
",",
"width",
"=",
"'auto'",
",",
"height",
"=",
"'auto'",
",",
"preserve_aspect_ratio",
"=",
"None",
")",
":",
"with",
"open",
"(",
"os",
".",
"path",
".",
"realpath",
"(",
"os",
".",
"path",
".",
"expanduser",
... | Display an image in the terminal.
A newline is not printed.
width and height are strings, following the format
N: N character cells.
Npx: N pixels.
N%: N percent of the session's width or height.
'auto': The image's inherent size will be used to determine an appropriate
... | [
"Display",
"an",
"image",
"in",
"the",
"terminal",
"."
] | 97b1b593bb02884521c2c05ed414f178de0b934e | https://github.com/asmeurer/iterm2-tools/blob/97b1b593bb02884521c2c05ed414f178de0b934e/iterm2_tools/images.py#L85-L112 | train |
xolox/python-qpass | setup.py | get_requirements | def get_requirements(*args):
"""Get requirements from pip requirement files."""
requirements = set()
contents = get_contents(*args)
for line in contents.splitlines():
# Strip comments.
line = re.sub(r'^#.*|\s#.*', '', line)
# Ignore empty lines
if line and not line.isspac... | python | def get_requirements(*args):
"""Get requirements from pip requirement files."""
requirements = set()
contents = get_contents(*args)
for line in contents.splitlines():
# Strip comments.
line = re.sub(r'^#.*|\s#.*', '', line)
# Ignore empty lines
if line and not line.isspac... | [
"def",
"get_requirements",
"(",
"*",
"args",
")",
":",
"requirements",
"=",
"set",
"(",
")",
"contents",
"=",
"get_contents",
"(",
"*",
"args",
")",
"for",
"line",
"in",
"contents",
".",
"splitlines",
"(",
")",
":",
"# Strip comments.",
"line",
"=",
"re"... | Get requirements from pip requirement files. | [
"Get",
"requirements",
"from",
"pip",
"requirement",
"files",
"."
] | 43ce447b0904ff42a54b8f1dd4d2479f950f258f | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/setup.py#L44-L54 | train |
ministryofjustice/govuk-bank-holidays | govuk_bank_holidays/bank_holidays.py | BankHolidays.get_holidays | def get_holidays(self, division=None, year=None):
"""
Gets a list of all known bank holidays, optionally filtered by division and/or year
:param division: see division constants; defaults to common holidays
:param year: defaults to all available years
:return: list of dicts with ... | python | def get_holidays(self, division=None, year=None):
"""
Gets a list of all known bank holidays, optionally filtered by division and/or year
:param division: see division constants; defaults to common holidays
:param year: defaults to all available years
:return: list of dicts with ... | [
"def",
"get_holidays",
"(",
"self",
",",
"division",
"=",
"None",
",",
"year",
"=",
"None",
")",
":",
"if",
"division",
":",
"holidays",
"=",
"self",
".",
"data",
"[",
"division",
"]",
"else",
":",
"holidays",
"=",
"self",
".",
"data",
"[",
"self",
... | Gets a list of all known bank holidays, optionally filtered by division and/or year
:param division: see division constants; defaults to common holidays
:param year: defaults to all available years
:return: list of dicts with titles, dates, etc | [
"Gets",
"a",
"list",
"of",
"all",
"known",
"bank",
"holidays",
"optionally",
"filtered",
"by",
"division",
"and",
"/",
"or",
"year",
":",
"param",
"division",
":",
"see",
"division",
"constants",
";",
"defaults",
"to",
"common",
"holidays",
":",
"param",
"... | 76c2f0e29890cee71f0ab99fe1a89cc92c7c4a67 | https://github.com/ministryofjustice/govuk-bank-holidays/blob/76c2f0e29890cee71f0ab99fe1a89cc92c7c4a67/govuk_bank_holidays/bank_holidays.py#L87-L106 | train |
ministryofjustice/govuk-bank-holidays | govuk_bank_holidays/bank_holidays.py | BankHolidays.get_next_holiday | def get_next_holiday(self, division=None, date=None):
"""
Returns the next known bank holiday
:param division: see division constants; defaults to common holidays
:param date: search starting from this date; defaults to today
:return: dict
"""
date = date or datet... | python | def get_next_holiday(self, division=None, date=None):
"""
Returns the next known bank holiday
:param division: see division constants; defaults to common holidays
:param date: search starting from this date; defaults to today
:return: dict
"""
date = date or datet... | [
"def",
"get_next_holiday",
"(",
"self",
",",
"division",
"=",
"None",
",",
"date",
"=",
"None",
")",
":",
"date",
"=",
"date",
"or",
"datetime",
".",
"date",
".",
"today",
"(",
")",
"for",
"holiday",
"in",
"self",
".",
"get_holidays",
"(",
"division",
... | Returns the next known bank holiday
:param division: see division constants; defaults to common holidays
:param date: search starting from this date; defaults to today
:return: dict | [
"Returns",
"the",
"next",
"known",
"bank",
"holiday",
":",
"param",
"division",
":",
"see",
"division",
"constants",
";",
"defaults",
"to",
"common",
"holidays",
":",
"param",
"date",
":",
"search",
"starting",
"from",
"this",
"date",
";",
"defaults",
"to",
... | 76c2f0e29890cee71f0ab99fe1a89cc92c7c4a67 | https://github.com/ministryofjustice/govuk-bank-holidays/blob/76c2f0e29890cee71f0ab99fe1a89cc92c7c4a67/govuk_bank_holidays/bank_holidays.py#L108-L118 | train |
ministryofjustice/govuk-bank-holidays | govuk_bank_holidays/bank_holidays.py | BankHolidays.is_holiday | def is_holiday(self, date, division=None):
"""
True if the date is a known bank holiday
:param date: the date to check
:param division: see division constants; defaults to common holidays
:return: bool
"""
return date in (holiday['date'] for holiday in self.get_ho... | python | def is_holiday(self, date, division=None):
"""
True if the date is a known bank holiday
:param date: the date to check
:param division: see division constants; defaults to common holidays
:return: bool
"""
return date in (holiday['date'] for holiday in self.get_ho... | [
"def",
"is_holiday",
"(",
"self",
",",
"date",
",",
"division",
"=",
"None",
")",
":",
"return",
"date",
"in",
"(",
"holiday",
"[",
"'date'",
"]",
"for",
"holiday",
"in",
"self",
".",
"get_holidays",
"(",
"division",
"=",
"division",
")",
")"
] | True if the date is a known bank holiday
:param date: the date to check
:param division: see division constants; defaults to common holidays
:return: bool | [
"True",
"if",
"the",
"date",
"is",
"a",
"known",
"bank",
"holiday",
":",
"param",
"date",
":",
"the",
"date",
"to",
"check",
":",
"param",
"division",
":",
"see",
"division",
"constants",
";",
"defaults",
"to",
"common",
"holidays",
":",
"return",
":",
... | 76c2f0e29890cee71f0ab99fe1a89cc92c7c4a67 | https://github.com/ministryofjustice/govuk-bank-holidays/blob/76c2f0e29890cee71f0ab99fe1a89cc92c7c4a67/govuk_bank_holidays/bank_holidays.py#L120-L127 | train |
ministryofjustice/govuk-bank-holidays | govuk_bank_holidays/bank_holidays.py | BankHolidays.get_next_work_day | def get_next_work_day(self, division=None, date=None):
"""
Returns the next work day, skipping weekends and bank holidays
:param division: see division constants; defaults to common holidays
:param date: search starting from this date; defaults to today
:return: datetime.date; NB... | python | def get_next_work_day(self, division=None, date=None):
"""
Returns the next work day, skipping weekends and bank holidays
:param division: see division constants; defaults to common holidays
:param date: search starting from this date; defaults to today
:return: datetime.date; NB... | [
"def",
"get_next_work_day",
"(",
"self",
",",
"division",
"=",
"None",
",",
"date",
"=",
"None",
")",
":",
"date",
"=",
"date",
"or",
"datetime",
".",
"date",
".",
"today",
"(",
")",
"one_day",
"=",
"datetime",
".",
"timedelta",
"(",
"days",
"=",
"1"... | Returns the next work day, skipping weekends and bank holidays
:param division: see division constants; defaults to common holidays
:param date: search starting from this date; defaults to today
:return: datetime.date; NB: get_next_holiday returns a dict | [
"Returns",
"the",
"next",
"work",
"day",
"skipping",
"weekends",
"and",
"bank",
"holidays",
":",
"param",
"division",
":",
"see",
"division",
"constants",
";",
"defaults",
"to",
"common",
"holidays",
":",
"param",
"date",
":",
"search",
"starting",
"from",
"... | 76c2f0e29890cee71f0ab99fe1a89cc92c7c4a67 | https://github.com/ministryofjustice/govuk-bank-holidays/blob/76c2f0e29890cee71f0ab99fe1a89cc92c7c4a67/govuk_bank_holidays/bank_holidays.py#L129-L142 | train |
ministryofjustice/govuk-bank-holidays | govuk_bank_holidays/bank_holidays.py | BankHolidays.is_work_day | def is_work_day(self, date, division=None):
"""
True if the date is not a weekend or a known bank holiday
:param date: the date to check
:param division: see division constants; defaults to common holidays
:return: bool
"""
return date.weekday() not in self.weeken... | python | def is_work_day(self, date, division=None):
"""
True if the date is not a weekend or a known bank holiday
:param date: the date to check
:param division: see division constants; defaults to common holidays
:return: bool
"""
return date.weekday() not in self.weeken... | [
"def",
"is_work_day",
"(",
"self",
",",
"date",
",",
"division",
"=",
"None",
")",
":",
"return",
"date",
".",
"weekday",
"(",
")",
"not",
"in",
"self",
".",
"weekend",
"and",
"date",
"not",
"in",
"(",
"holiday",
"[",
"'date'",
"]",
"for",
"holiday",... | True if the date is not a weekend or a known bank holiday
:param date: the date to check
:param division: see division constants; defaults to common holidays
:return: bool | [
"True",
"if",
"the",
"date",
"is",
"not",
"a",
"weekend",
"or",
"a",
"known",
"bank",
"holiday",
":",
"param",
"date",
":",
"the",
"date",
"to",
"check",
":",
"param",
"division",
":",
"see",
"division",
"constants",
";",
"defaults",
"to",
"common",
"h... | 76c2f0e29890cee71f0ab99fe1a89cc92c7c4a67 | https://github.com/ministryofjustice/govuk-bank-holidays/blob/76c2f0e29890cee71f0ab99fe1a89cc92c7c4a67/govuk_bank_holidays/bank_holidays.py#L144-L153 | train |
blixt/py-starbound | starbound/__init__.py | World.get_all_regions_with_tiles | def get_all_regions_with_tiles(self):
"""
Generator which yields a set of (rx, ry) tuples which describe
all regions for which the world has tile data
"""
for key in self.get_all_keys():
(layer, rx, ry) = struct.unpack('>BHH', key)
if layer == 1:
... | python | def get_all_regions_with_tiles(self):
"""
Generator which yields a set of (rx, ry) tuples which describe
all regions for which the world has tile data
"""
for key in self.get_all_keys():
(layer, rx, ry) = struct.unpack('>BHH', key)
if layer == 1:
... | [
"def",
"get_all_regions_with_tiles",
"(",
"self",
")",
":",
"for",
"key",
"in",
"self",
".",
"get_all_keys",
"(",
")",
":",
"(",
"layer",
",",
"rx",
",",
"ry",
")",
"=",
"struct",
".",
"unpack",
"(",
"'>BHH'",
",",
"key",
")",
"if",
"layer",
"==",
... | Generator which yields a set of (rx, ry) tuples which describe
all regions for which the world has tile data | [
"Generator",
"which",
"yields",
"a",
"set",
"of",
"(",
"rx",
"ry",
")",
"tuples",
"which",
"describe",
"all",
"regions",
"for",
"which",
"the",
"world",
"has",
"tile",
"data"
] | 68a2f6bfef73d8803191f937c69005a64eeae017 | https://github.com/blixt/py-starbound/blob/68a2f6bfef73d8803191f937c69005a64eeae017/starbound/__init__.py#L95-L103 | train |
blixt/py-starbound | starbound/__init__.py | World.get_entity_uuid_coords | def get_entity_uuid_coords(self, uuid):
"""
Returns the coordinates of the given entity UUID inside this world, or
`None` if the UUID is not found.
"""
if uuid in self._entity_to_region_map:
coords = self._entity_to_region_map[uuid]
entities = self.get_ent... | python | def get_entity_uuid_coords(self, uuid):
"""
Returns the coordinates of the given entity UUID inside this world, or
`None` if the UUID is not found.
"""
if uuid in self._entity_to_region_map:
coords = self._entity_to_region_map[uuid]
entities = self.get_ent... | [
"def",
"get_entity_uuid_coords",
"(",
"self",
",",
"uuid",
")",
":",
"if",
"uuid",
"in",
"self",
".",
"_entity_to_region_map",
":",
"coords",
"=",
"self",
".",
"_entity_to_region_map",
"[",
"uuid",
"]",
"entities",
"=",
"self",
".",
"get_entities",
"(",
"*",... | Returns the coordinates of the given entity UUID inside this world, or
`None` if the UUID is not found. | [
"Returns",
"the",
"coordinates",
"of",
"the",
"given",
"entity",
"UUID",
"inside",
"this",
"world",
"or",
"None",
"if",
"the",
"UUID",
"is",
"not",
"found",
"."
] | 68a2f6bfef73d8803191f937c69005a64eeae017 | https://github.com/blixt/py-starbound/blob/68a2f6bfef73d8803191f937c69005a64eeae017/starbound/__init__.py#L110-L121 | train |
blixt/py-starbound | starbound/__init__.py | World._entity_to_region_map | def _entity_to_region_map(self):
"""
A dict whose keys are the UUIDs (or just IDs, in some cases) of
entities, and whose values are the `(rx, ry)` coordinates in which that
entity can be found. This can be used to easily locate particular
entities inside the world.
"""
... | python | def _entity_to_region_map(self):
"""
A dict whose keys are the UUIDs (or just IDs, in some cases) of
entities, and whose values are the `(rx, ry)` coordinates in which that
entity can be found. This can be used to easily locate particular
entities inside the world.
"""
... | [
"def",
"_entity_to_region_map",
"(",
"self",
")",
":",
"entity_to_region",
"=",
"{",
"}",
"for",
"key",
"in",
"self",
".",
"get_all_keys",
"(",
")",
":",
"layer",
",",
"rx",
",",
"ry",
"=",
"struct",
".",
"unpack",
"(",
"'>BHH'",
",",
"key",
")",
"if... | A dict whose keys are the UUIDs (or just IDs, in some cases) of
entities, and whose values are the `(rx, ry)` coordinates in which that
entity can be found. This can be used to easily locate particular
entities inside the world. | [
"A",
"dict",
"whose",
"keys",
"are",
"the",
"UUIDs",
"(",
"or",
"just",
"IDs",
"in",
"some",
"cases",
")",
"of",
"entities",
"and",
"whose",
"values",
"are",
"the",
"(",
"rx",
"ry",
")",
"coordinates",
"in",
"which",
"that",
"entity",
"can",
"be",
"f... | 68a2f6bfef73d8803191f937c69005a64eeae017 | https://github.com/blixt/py-starbound/blob/68a2f6bfef73d8803191f937c69005a64eeae017/starbound/__init__.py#L149-L168 | train |
xolox/python-qpass | qpass/__init__.py | create_fuzzy_pattern | def create_fuzzy_pattern(pattern):
"""
Convert a string into a fuzzy regular expression pattern.
:param pattern: The input pattern (a string).
:returns: A compiled regular expression object.
This function works by adding ``.*`` between each of the characters in the
input pattern and compiling ... | python | def create_fuzzy_pattern(pattern):
"""
Convert a string into a fuzzy regular expression pattern.
:param pattern: The input pattern (a string).
:returns: A compiled regular expression object.
This function works by adding ``.*`` between each of the characters in the
input pattern and compiling ... | [
"def",
"create_fuzzy_pattern",
"(",
"pattern",
")",
":",
"return",
"re",
".",
"compile",
"(",
"\".*\"",
".",
"join",
"(",
"map",
"(",
"re",
".",
"escape",
",",
"pattern",
")",
")",
",",
"re",
".",
"IGNORECASE",
")"
] | Convert a string into a fuzzy regular expression pattern.
:param pattern: The input pattern (a string).
:returns: A compiled regular expression object.
This function works by adding ``.*`` between each of the characters in the
input pattern and compiling the resulting expression into a case
insens... | [
"Convert",
"a",
"string",
"into",
"a",
"fuzzy",
"regular",
"expression",
"pattern",
"."
] | 43ce447b0904ff42a54b8f1dd4d2479f950f258f | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/__init__.py#L431-L442 | train |
xolox/python-qpass | qpass/__init__.py | AbstractPasswordStore.filtered_entries | def filtered_entries(self):
"""A list of :class:`PasswordEntry` objects that don't match the exclude list."""
return [
e for e in self.entries if not any(fnmatch.fnmatch(e.name.lower(), p.lower()) for p in self.exclude_list)
] | python | def filtered_entries(self):
"""A list of :class:`PasswordEntry` objects that don't match the exclude list."""
return [
e for e in self.entries if not any(fnmatch.fnmatch(e.name.lower(), p.lower()) for p in self.exclude_list)
] | [
"def",
"filtered_entries",
"(",
"self",
")",
":",
"return",
"[",
"e",
"for",
"e",
"in",
"self",
".",
"entries",
"if",
"not",
"any",
"(",
"fnmatch",
".",
"fnmatch",
"(",
"e",
".",
"name",
".",
"lower",
"(",
")",
",",
"p",
".",
"lower",
"(",
")",
... | A list of :class:`PasswordEntry` objects that don't match the exclude list. | [
"A",
"list",
"of",
":",
"class",
":",
"PasswordEntry",
"objects",
"that",
"don",
"t",
"match",
"the",
"exclude",
"list",
"."
] | 43ce447b0904ff42a54b8f1dd4d2479f950f258f | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/__init__.py#L104-L108 | train |
xolox/python-qpass | qpass/__init__.py | AbstractPasswordStore.fuzzy_search | def fuzzy_search(self, *filters):
"""
Perform a "fuzzy" search that matches the given characters in the given order.
:param filters: The pattern(s) to search for.
:returns: The matched password names (a list of strings).
"""
matches = []
logger.verbose(
... | python | def fuzzy_search(self, *filters):
"""
Perform a "fuzzy" search that matches the given characters in the given order.
:param filters: The pattern(s) to search for.
:returns: The matched password names (a list of strings).
"""
matches = []
logger.verbose(
... | [
"def",
"fuzzy_search",
"(",
"self",
",",
"*",
"filters",
")",
":",
"matches",
"=",
"[",
"]",
"logger",
".",
"verbose",
"(",
"\"Performing fuzzy search on %s (%s) ..\"",
",",
"pluralize",
"(",
"len",
"(",
"filters",
")",
",",
"\"pattern\"",
")",
",",
"concate... | Perform a "fuzzy" search that matches the given characters in the given order.
:param filters: The pattern(s) to search for.
:returns: The matched password names (a list of strings). | [
"Perform",
"a",
"fuzzy",
"search",
"that",
"matches",
"the",
"given",
"characters",
"in",
"the",
"given",
"order",
"."
] | 43ce447b0904ff42a54b8f1dd4d2479f950f258f | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/__init__.py#L110-L130 | train |
xolox/python-qpass | qpass/__init__.py | AbstractPasswordStore.select_entry | def select_entry(self, *arguments):
"""
Select a password from the available choices.
:param arguments: Refer to :func:`smart_search()`.
:returns: The name of a password (a string) or :data:`None`
(when no password matched the given `arguments`).
"""
ma... | python | def select_entry(self, *arguments):
"""
Select a password from the available choices.
:param arguments: Refer to :func:`smart_search()`.
:returns: The name of a password (a string) or :data:`None`
(when no password matched the given `arguments`).
"""
ma... | [
"def",
"select_entry",
"(",
"self",
",",
"*",
"arguments",
")",
":",
"matches",
"=",
"self",
".",
"smart_search",
"(",
"*",
"arguments",
")",
"if",
"len",
"(",
"matches",
")",
">",
"1",
":",
"logger",
".",
"info",
"(",
"\"More than one match, prompting for... | Select a password from the available choices.
:param arguments: Refer to :func:`smart_search()`.
:returns: The name of a password (a string) or :data:`None`
(when no password matched the given `arguments`). | [
"Select",
"a",
"password",
"from",
"the",
"available",
"choices",
"."
] | 43ce447b0904ff42a54b8f1dd4d2479f950f258f | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/__init__.py#L132-L147 | train |
xolox/python-qpass | qpass/__init__.py | AbstractPasswordStore.simple_search | def simple_search(self, *keywords):
"""
Perform a simple search for case insensitive substring matches.
:param keywords: The string(s) to search for.
:returns: The matched password names (a generator of strings).
Only passwords whose names matches *all* of the given keywords a... | python | def simple_search(self, *keywords):
"""
Perform a simple search for case insensitive substring matches.
:param keywords: The string(s) to search for.
:returns: The matched password names (a generator of strings).
Only passwords whose names matches *all* of the given keywords a... | [
"def",
"simple_search",
"(",
"self",
",",
"*",
"keywords",
")",
":",
"matches",
"=",
"[",
"]",
"keywords",
"=",
"[",
"kw",
".",
"lower",
"(",
")",
"for",
"kw",
"in",
"keywords",
"]",
"logger",
".",
"verbose",
"(",
"\"Performing simple search on %s (%s) ..\... | Perform a simple search for case insensitive substring matches.
:param keywords: The string(s) to search for.
:returns: The matched password names (a generator of strings).
Only passwords whose names matches *all* of the given keywords are
returned. | [
"Perform",
"a",
"simple",
"search",
"for",
"case",
"insensitive",
"substring",
"matches",
"."
] | 43ce447b0904ff42a54b8f1dd4d2479f950f258f | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/__init__.py#L149-L175 | train |
xolox/python-qpass | qpass/__init__.py | AbstractPasswordStore.smart_search | def smart_search(self, *arguments):
"""
Perform a smart search on the given keywords or patterns.
:param arguments: The keywords or patterns to search for.
:returns: The matched password names (a list of strings).
:raises: The following exceptions can be raised:
... | python | def smart_search(self, *arguments):
"""
Perform a smart search on the given keywords or patterns.
:param arguments: The keywords or patterns to search for.
:returns: The matched password names (a list of strings).
:raises: The following exceptions can be raised:
... | [
"def",
"smart_search",
"(",
"self",
",",
"*",
"arguments",
")",
":",
"matches",
"=",
"self",
".",
"simple_search",
"(",
"*",
"arguments",
")",
"if",
"not",
"matches",
":",
"logger",
".",
"verbose",
"(",
"\"Falling back from substring search to fuzzy search ..\"",
... | Perform a smart search on the given keywords or patterns.
:param arguments: The keywords or patterns to search for.
:returns: The matched password names (a list of strings).
:raises: The following exceptions can be raised:
- :exc:`.NoMatchingPasswordError` when no matching pas... | [
"Perform",
"a",
"smart",
"search",
"on",
"the",
"given",
"keywords",
"or",
"patterns",
"."
] | 43ce447b0904ff42a54b8f1dd4d2479f950f258f | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/__init__.py#L177-L204 | train |
xolox/python-qpass | qpass/__init__.py | QuickPass.entries | def entries(self):
"""A list of :class:`PasswordEntry` objects."""
passwords = []
for store in self.stores:
passwords.extend(store.entries)
return natsort(passwords, key=lambda e: e.name) | python | def entries(self):
"""A list of :class:`PasswordEntry` objects."""
passwords = []
for store in self.stores:
passwords.extend(store.entries)
return natsort(passwords, key=lambda e: e.name) | [
"def",
"entries",
"(",
"self",
")",
":",
"passwords",
"=",
"[",
"]",
"for",
"store",
"in",
"self",
".",
"stores",
":",
"passwords",
".",
"extend",
"(",
"store",
".",
"entries",
")",
"return",
"natsort",
"(",
"passwords",
",",
"key",
"=",
"lambda",
"e... | A list of :class:`PasswordEntry` objects. | [
"A",
"list",
"of",
":",
"class",
":",
"PasswordEntry",
"objects",
"."
] | 43ce447b0904ff42a54b8f1dd4d2479f950f258f | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/__init__.py#L219-L224 | train |
xolox/python-qpass | qpass/__init__.py | PasswordStore.context | def context(self):
"""
An execution context created using :mod:`executor.contexts`.
The value of :attr:`context` defaults to a
:class:`~executor.contexts.LocalContext` object with the following
characteristics:
- The working directory of the execution context is set to ... | python | def context(self):
"""
An execution context created using :mod:`executor.contexts`.
The value of :attr:`context` defaults to a
:class:`~executor.contexts.LocalContext` object with the following
characteristics:
- The working directory of the execution context is set to ... | [
"def",
"context",
"(",
"self",
")",
":",
"# Make sure the directory exists.",
"self",
".",
"ensure_directory_exists",
"(",
")",
"# Prepare the environment variables.",
"environment",
"=",
"{",
"DIRECTORY_VARIABLE",
":",
"self",
".",
"directory",
"}",
"try",
":",
"# Tr... | An execution context created using :mod:`executor.contexts`.
The value of :attr:`context` defaults to a
:class:`~executor.contexts.LocalContext` object with the following
characteristics:
- The working directory of the execution context is set to the
value of :attr:`directory... | [
"An",
"execution",
"context",
"created",
"using",
":",
"mod",
":",
"executor",
".",
"contexts",
"."
] | 43ce447b0904ff42a54b8f1dd4d2479f950f258f | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/__init__.py#L244-L272 | train |
xolox/python-qpass | qpass/__init__.py | PasswordStore.directory | def directory(self, value):
"""Normalize the value of :attr:`directory` when it's set."""
# Normalize the value of `directory'.
set_property(self, "directory", parse_path(value))
# Clear the computed values of `context' and `entries'.
clear_property(self, "context")
clear... | python | def directory(self, value):
"""Normalize the value of :attr:`directory` when it's set."""
# Normalize the value of `directory'.
set_property(self, "directory", parse_path(value))
# Clear the computed values of `context' and `entries'.
clear_property(self, "context")
clear... | [
"def",
"directory",
"(",
"self",
",",
"value",
")",
":",
"# Normalize the value of `directory'.",
"set_property",
"(",
"self",
",",
"\"directory\"",
",",
"parse_path",
"(",
"value",
")",
")",
"# Clear the computed values of `context' and `entries'.",
"clear_property",
"("... | Normalize the value of :attr:`directory` when it's set. | [
"Normalize",
"the",
"value",
"of",
":",
"attr",
":",
"directory",
"when",
"it",
"s",
"set",
"."
] | 43ce447b0904ff42a54b8f1dd4d2479f950f258f | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/__init__.py#L292-L298 | train |
xolox/python-qpass | qpass/__init__.py | PasswordStore.entries | def entries(self):
"""A list of :class:`PasswordEntry` objects."""
timer = Timer()
passwords = []
logger.info("Scanning %s ..", format_path(self.directory))
listing = self.context.capture("find", "-type", "f", "-name", "*.gpg", "-print0")
for filename in split(listing, "\... | python | def entries(self):
"""A list of :class:`PasswordEntry` objects."""
timer = Timer()
passwords = []
logger.info("Scanning %s ..", format_path(self.directory))
listing = self.context.capture("find", "-type", "f", "-name", "*.gpg", "-print0")
for filename in split(listing, "\... | [
"def",
"entries",
"(",
"self",
")",
":",
"timer",
"=",
"Timer",
"(",
")",
"passwords",
"=",
"[",
"]",
"logger",
".",
"info",
"(",
"\"Scanning %s ..\"",
",",
"format_path",
"(",
"self",
".",
"directory",
")",
")",
"listing",
"=",
"self",
".",
"context",... | A list of :class:`PasswordEntry` objects. | [
"A",
"list",
"of",
":",
"class",
":",
"PasswordEntry",
"objects",
"."
] | 43ce447b0904ff42a54b8f1dd4d2479f950f258f | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/__init__.py#L301-L314 | train |
xolox/python-qpass | qpass/__init__.py | PasswordStore.ensure_directory_exists | def ensure_directory_exists(self):
"""
Make sure :attr:`directory` exists.
:raises: :exc:`.MissingPasswordStoreError` when the password storage
directory doesn't exist.
"""
if not os.path.isdir(self.directory):
msg = "The password storage directory d... | python | def ensure_directory_exists(self):
"""
Make sure :attr:`directory` exists.
:raises: :exc:`.MissingPasswordStoreError` when the password storage
directory doesn't exist.
"""
if not os.path.isdir(self.directory):
msg = "The password storage directory d... | [
"def",
"ensure_directory_exists",
"(",
"self",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"self",
".",
"directory",
")",
":",
"msg",
"=",
"\"The password storage directory doesn't exist! (%s)\"",
"raise",
"MissingPasswordStoreError",
"(",
"msg",
... | Make sure :attr:`directory` exists.
:raises: :exc:`.MissingPasswordStoreError` when the password storage
directory doesn't exist. | [
"Make",
"sure",
":",
"attr",
":",
"directory",
"exists",
"."
] | 43ce447b0904ff42a54b8f1dd4d2479f950f258f | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/__init__.py#L316-L325 | train |
xolox/python-qpass | qpass/__init__.py | PasswordEntry.format_text | def format_text(self, include_password=True, use_colors=None, padding=True, filters=()):
"""
Format :attr:`text` for viewing on a terminal.
:param include_password: :data:`True` to include the password in the
formatted text, :data:`False` to exclude the
... | python | def format_text(self, include_password=True, use_colors=None, padding=True, filters=()):
"""
Format :attr:`text` for viewing on a terminal.
:param include_password: :data:`True` to include the password in the
formatted text, :data:`False` to exclude the
... | [
"def",
"format_text",
"(",
"self",
",",
"include_password",
"=",
"True",
",",
"use_colors",
"=",
"None",
",",
"padding",
"=",
"True",
",",
"filters",
"=",
"(",
")",
")",
":",
"# Determine whether we can use ANSI escape sequences.",
"if",
"use_colors",
"is",
"Non... | Format :attr:`text` for viewing on a terminal.
:param include_password: :data:`True` to include the password in the
formatted text, :data:`False` to exclude the
password from the formatted text.
:param use_colors: :data:`True` to use ANS... | [
"Format",
":",
"attr",
":",
"text",
"for",
"viewing",
"on",
"a",
"terminal",
"."
] | 43ce447b0904ff42a54b8f1dd4d2479f950f258f | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/__init__.py#L362-L428 | train |
darothen/xbpch | xbpch/util/diaginfo.py | get_diaginfo | def get_diaginfo(diaginfo_file):
"""
Read an output's diaginfo.dat file and parse into a DataFrame for
use in selecting and parsing categories.
Parameters
----------
diaginfo_file : str
Path to diaginfo.dat
Returns
-------
DataFrame containing the category information.
... | python | def get_diaginfo(diaginfo_file):
"""
Read an output's diaginfo.dat file and parse into a DataFrame for
use in selecting and parsing categories.
Parameters
----------
diaginfo_file : str
Path to diaginfo.dat
Returns
-------
DataFrame containing the category information.
... | [
"def",
"get_diaginfo",
"(",
"diaginfo_file",
")",
":",
"widths",
"=",
"[",
"rec",
".",
"width",
"for",
"rec",
"in",
"diag_recs",
"]",
"col_names",
"=",
"[",
"rec",
".",
"name",
"for",
"rec",
"in",
"diag_recs",
"]",
"dtypes",
"=",
"[",
"rec",
".",
"ty... | Read an output's diaginfo.dat file and parse into a DataFrame for
use in selecting and parsing categories.
Parameters
----------
diaginfo_file : str
Path to diaginfo.dat
Returns
-------
DataFrame containing the category information. | [
"Read",
"an",
"output",
"s",
"diaginfo",
".",
"dat",
"file",
"and",
"parse",
"into",
"a",
"DataFrame",
"for",
"use",
"in",
"selecting",
"and",
"parsing",
"categories",
"."
] | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/util/diaginfo.py#L39-L66 | train |
darothen/xbpch | xbpch/util/diaginfo.py | get_tracerinfo | def get_tracerinfo(tracerinfo_file):
"""
Read an output's tracerinfo.dat file and parse into a DataFrame for
use in selecting and parsing categories.
Parameters
----------
tracerinfo_file : str
Path to tracerinfo.dat
Returns
-------
DataFrame containing the tracer informati... | python | def get_tracerinfo(tracerinfo_file):
"""
Read an output's tracerinfo.dat file and parse into a DataFrame for
use in selecting and parsing categories.
Parameters
----------
tracerinfo_file : str
Path to tracerinfo.dat
Returns
-------
DataFrame containing the tracer informati... | [
"def",
"get_tracerinfo",
"(",
"tracerinfo_file",
")",
":",
"widths",
"=",
"[",
"rec",
".",
"width",
"for",
"rec",
"in",
"tracer_recs",
"]",
"col_names",
"=",
"[",
"rec",
".",
"name",
"for",
"rec",
"in",
"tracer_recs",
"]",
"dtypes",
"=",
"[",
"rec",
".... | Read an output's tracerinfo.dat file and parse into a DataFrame for
use in selecting and parsing categories.
Parameters
----------
tracerinfo_file : str
Path to tracerinfo.dat
Returns
-------
DataFrame containing the tracer information. | [
"Read",
"an",
"output",
"s",
"tracerinfo",
".",
"dat",
"file",
"and",
"parse",
"into",
"a",
"DataFrame",
"for",
"use",
"in",
"selecting",
"and",
"parsing",
"categories",
"."
] | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/util/diaginfo.py#L69-L125 | train |
darothen/xbpch | xbpch/bpch.py | read_from_bpch | def read_from_bpch(filename, file_position, shape, dtype, endian,
use_mmap=False):
""" Read a chunk of data from a bpch output file.
Parameters
----------
filename : str
Path to file on disk containing the data
file_position : int
Position (bytes) where desired d... | python | def read_from_bpch(filename, file_position, shape, dtype, endian,
use_mmap=False):
""" Read a chunk of data from a bpch output file.
Parameters
----------
filename : str
Path to file on disk containing the data
file_position : int
Position (bytes) where desired d... | [
"def",
"read_from_bpch",
"(",
"filename",
",",
"file_position",
",",
"shape",
",",
"dtype",
",",
"endian",
",",
"use_mmap",
"=",
"False",
")",
":",
"offset",
"=",
"file_position",
"+",
"4",
"if",
"use_mmap",
":",
"d",
"=",
"np",
".",
"memmap",
"(",
"fi... | Read a chunk of data from a bpch output file.
Parameters
----------
filename : str
Path to file on disk containing the data
file_position : int
Position (bytes) where desired data chunk begins
shape : tuple of ints
Resultant (n-dimensional) shape of requested data; the chun... | [
"Read",
"a",
"chunk",
"of",
"data",
"from",
"a",
"bpch",
"output",
"file",
"."
] | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/bpch.py#L353-L398 | train |
darothen/xbpch | xbpch/bpch.py | BPCHDataBundle._read | def _read(self):
""" Helper function to load the data referenced by this bundle. """
if self._dask:
d = da.from_delayed(
delayed(read_from_bpch, )(
self.filename, self.file_position, self.shape,
self.dtype, self.endian, use_mmap=self._m... | python | def _read(self):
""" Helper function to load the data referenced by this bundle. """
if self._dask:
d = da.from_delayed(
delayed(read_from_bpch, )(
self.filename, self.file_position, self.shape,
self.dtype, self.endian, use_mmap=self._m... | [
"def",
"_read",
"(",
"self",
")",
":",
"if",
"self",
".",
"_dask",
":",
"d",
"=",
"da",
".",
"from_delayed",
"(",
"delayed",
"(",
"read_from_bpch",
",",
")",
"(",
"self",
".",
"filename",
",",
"self",
".",
"file_position",
",",
"self",
".",
"shape",
... | Helper function to load the data referenced by this bundle. | [
"Helper",
"function",
"to",
"load",
"the",
"data",
"referenced",
"by",
"this",
"bundle",
"."
] | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/bpch.py#L68-L84 | train |
darothen/xbpch | xbpch/bpch.py | BPCHFile.close | def close(self):
""" Close this bpch file.
"""
if not self.fp.closed:
for v in list(self.var_data):
del self.var_data[v]
self.fp.close() | python | def close(self):
""" Close this bpch file.
"""
if not self.fp.closed:
for v in list(self.var_data):
del self.var_data[v]
self.fp.close() | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"fp",
".",
"closed",
":",
"for",
"v",
"in",
"list",
"(",
"self",
".",
"var_data",
")",
":",
"del",
"self",
".",
"var_data",
"[",
"v",
"]",
"self",
".",
"fp",
".",
"close",
"(",
... | Close this bpch file. | [
"Close",
"this",
"bpch",
"file",
"."
] | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/bpch.py#L176-L185 | train |
darothen/xbpch | xbpch/bpch.py | BPCHFile._read_metadata | def _read_metadata(self):
""" Read the main metadata packaged within a bpch file, indicating
the output filetype and its title.
"""
filetype = self.fp.readline().strip()
filetitle = self.fp.readline().strip()
# Decode to UTF string, if possible
try:
... | python | def _read_metadata(self):
""" Read the main metadata packaged within a bpch file, indicating
the output filetype and its title.
"""
filetype = self.fp.readline().strip()
filetitle = self.fp.readline().strip()
# Decode to UTF string, if possible
try:
... | [
"def",
"_read_metadata",
"(",
"self",
")",
":",
"filetype",
"=",
"self",
".",
"fp",
".",
"readline",
"(",
")",
".",
"strip",
"(",
")",
"filetitle",
"=",
"self",
".",
"fp",
".",
"readline",
"(",
")",
".",
"strip",
"(",
")",
"# Decode to UTF string, if p... | Read the main metadata packaged within a bpch file, indicating
the output filetype and its title. | [
"Read",
"the",
"main",
"metadata",
"packaged",
"within",
"a",
"bpch",
"file",
"indicating",
"the",
"output",
"filetype",
"and",
"its",
"title",
"."
] | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/bpch.py#L203-L220 | train |
darothen/xbpch | xbpch/bpch.py | BPCHFile._read_header | def _read_header(self):
""" Process the header information (data model / grid spec) """
self._header_pos = self.fp.tell()
line = self.fp.readline('20sffii')
modelname, res0, res1, halfpolar, center180 = line
self._attributes.update({
"modelname": str(modelname, 'utf... | python | def _read_header(self):
""" Process the header information (data model / grid spec) """
self._header_pos = self.fp.tell()
line = self.fp.readline('20sffii')
modelname, res0, res1, halfpolar, center180 = line
self._attributes.update({
"modelname": str(modelname, 'utf... | [
"def",
"_read_header",
"(",
"self",
")",
":",
"self",
".",
"_header_pos",
"=",
"self",
".",
"fp",
".",
"tell",
"(",
")",
"line",
"=",
"self",
".",
"fp",
".",
"readline",
"(",
"'20sffii'",
")",
"modelname",
",",
"res0",
",",
"res1",
",",
"halfpolar",
... | Process the header information (data model / grid spec) | [
"Process",
"the",
"header",
"information",
"(",
"data",
"model",
"/",
"grid",
"spec",
")"
] | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/bpch.py#L222-L241 | train |
darothen/xbpch | xbpch/bpch.py | BPCHFile._read_var_data | def _read_var_data(self):
""" Iterate over the block of this bpch file and return handlers
in the form of `BPCHDataBundle`s for access to the data contained
therein.
"""
var_bundles = OrderedDict()
var_attrs = OrderedDict()
n_vars = 0
while self.fp.tel... | python | def _read_var_data(self):
""" Iterate over the block of this bpch file and return handlers
in the form of `BPCHDataBundle`s for access to the data contained
therein.
"""
var_bundles = OrderedDict()
var_attrs = OrderedDict()
n_vars = 0
while self.fp.tel... | [
"def",
"_read_var_data",
"(",
"self",
")",
":",
"var_bundles",
"=",
"OrderedDict",
"(",
")",
"var_attrs",
"=",
"OrderedDict",
"(",
")",
"n_vars",
"=",
"0",
"while",
"self",
".",
"fp",
".",
"tell",
"(",
")",
"<",
"self",
".",
"fsize",
":",
"var_attr",
... | Iterate over the block of this bpch file and return handlers
in the form of `BPCHDataBundle`s for access to the data contained
therein. | [
"Iterate",
"over",
"the",
"block",
"of",
"this",
"bpch",
"file",
"and",
"return",
"handlers",
"in",
"the",
"form",
"of",
"BPCHDataBundle",
"s",
"for",
"access",
"to",
"the",
"data",
"contained",
"therein",
"."
] | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/bpch.py#L244-L350 | train |
darothen/xbpch | xbpch/common.py | broadcast_1d_array | def broadcast_1d_array(arr, ndim, axis=1):
"""
Broadcast 1-d array `arr` to `ndim` dimensions on the first axis
(`axis`=0) or on the last axis (`axis`=1).
Useful for 'outer' calculations involving 1-d arrays that are related to
different axes on a multidimensional grid.
"""
ext_arr = arr
... | python | def broadcast_1d_array(arr, ndim, axis=1):
"""
Broadcast 1-d array `arr` to `ndim` dimensions on the first axis
(`axis`=0) or on the last axis (`axis`=1).
Useful for 'outer' calculations involving 1-d arrays that are related to
different axes on a multidimensional grid.
"""
ext_arr = arr
... | [
"def",
"broadcast_1d_array",
"(",
"arr",
",",
"ndim",
",",
"axis",
"=",
"1",
")",
":",
"ext_arr",
"=",
"arr",
"for",
"i",
"in",
"range",
"(",
"ndim",
"-",
"1",
")",
":",
"ext_arr",
"=",
"np",
".",
"expand_dims",
"(",
"ext_arr",
",",
"axis",
"=",
... | Broadcast 1-d array `arr` to `ndim` dimensions on the first axis
(`axis`=0) or on the last axis (`axis`=1).
Useful for 'outer' calculations involving 1-d arrays that are related to
different axes on a multidimensional grid. | [
"Broadcast",
"1",
"-",
"d",
"array",
"arr",
"to",
"ndim",
"dimensions",
"on",
"the",
"first",
"axis",
"(",
"axis",
"=",
"0",
")",
"or",
"on",
"the",
"last",
"axis",
"(",
"axis",
"=",
"1",
")",
"."
] | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/common.py#L9-L20 | train |
darothen/xbpch | xbpch/common.py | get_timestamp | def get_timestamp(time=True, date=True, fmt=None):
""" Return the current timestamp in machine local time.
Parameters:
-----------
time, date : Boolean
Flag to include the time or date components, respectively,
in the output.
fmt : str, optional
If passed, will override the ... | python | def get_timestamp(time=True, date=True, fmt=None):
""" Return the current timestamp in machine local time.
Parameters:
-----------
time, date : Boolean
Flag to include the time or date components, respectively,
in the output.
fmt : str, optional
If passed, will override the ... | [
"def",
"get_timestamp",
"(",
"time",
"=",
"True",
",",
"date",
"=",
"True",
",",
"fmt",
"=",
"None",
")",
":",
"time_format",
"=",
"\"%H:%M:%S\"",
"date_format",
"=",
"\"%m-%d-%Y\"",
"if",
"fmt",
"is",
"None",
":",
"if",
"time",
"and",
"date",
":",
"fm... | Return the current timestamp in machine local time.
Parameters:
-----------
time, date : Boolean
Flag to include the time or date components, respectively,
in the output.
fmt : str, optional
If passed, will override the time/date choice and use as
the format string passe... | [
"Return",
"the",
"current",
"timestamp",
"in",
"machine",
"local",
"time",
"."
] | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/common.py#L23-L49 | train |
darothen/xbpch | xbpch/common.py | fix_attr_encoding | def fix_attr_encoding(ds):
""" This is a temporary hot-fix to handle the way metadata is encoded
when we read data directly from bpch files. It removes the 'scale_factor'
and 'units' attributes we encode with the data we ingest, converts the
'hydrocarbon' and 'chemical' attribute to a binary integer ins... | python | def fix_attr_encoding(ds):
""" This is a temporary hot-fix to handle the way metadata is encoded
when we read data directly from bpch files. It removes the 'scale_factor'
and 'units' attributes we encode with the data we ingest, converts the
'hydrocarbon' and 'chemical' attribute to a binary integer ins... | [
"def",
"fix_attr_encoding",
"(",
"ds",
")",
":",
"def",
"_maybe_del_attr",
"(",
"da",
",",
"attr",
")",
":",
"\"\"\" Possibly delete an attribute on a DataArray if it's present \"\"\"",
"if",
"attr",
"in",
"da",
".",
"attrs",
":",
"del",
"da",
".",
"attrs",
"[",
... | This is a temporary hot-fix to handle the way metadata is encoded
when we read data directly from bpch files. It removes the 'scale_factor'
and 'units' attributes we encode with the data we ingest, converts the
'hydrocarbon' and 'chemical' attribute to a binary integer instead of a
boolean, and removes ... | [
"This",
"is",
"a",
"temporary",
"hot",
"-",
"fix",
"to",
"handle",
"the",
"way",
"metadata",
"is",
"encoded",
"when",
"we",
"read",
"data",
"directly",
"from",
"bpch",
"files",
".",
"It",
"removes",
"the",
"scale_factor",
"and",
"units",
"attributes",
"we"... | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/common.py#L52-L92 | train |
asmeurer/iterm2-tools | iterm2_tools/shell_integration.py | after_output | def after_output(command_status):
"""
Shell sequence to be run after the command output.
The ``command_status`` should be in the range 0-255.
"""
if command_status not in range(256):
raise ValueError("command_status must be an integer in the range 0-255")
sys.stdout.write(AFTER_OUTPUT.f... | python | def after_output(command_status):
"""
Shell sequence to be run after the command output.
The ``command_status`` should be in the range 0-255.
"""
if command_status not in range(256):
raise ValueError("command_status must be an integer in the range 0-255")
sys.stdout.write(AFTER_OUTPUT.f... | [
"def",
"after_output",
"(",
"command_status",
")",
":",
"if",
"command_status",
"not",
"in",
"range",
"(",
"256",
")",
":",
"raise",
"ValueError",
"(",
"\"command_status must be an integer in the range 0-255\"",
")",
"sys",
".",
"stdout",
".",
"write",
"(",
"AFTER... | Shell sequence to be run after the command output.
The ``command_status`` should be in the range 0-255. | [
"Shell",
"sequence",
"to",
"be",
"run",
"after",
"the",
"command",
"output",
"."
] | 97b1b593bb02884521c2c05ed414f178de0b934e | https://github.com/asmeurer/iterm2-tools/blob/97b1b593bb02884521c2c05ed414f178de0b934e/iterm2_tools/shell_integration.py#L153-L164 | train |
bitlabstudio/django-multilingual-news | multilingual_news/south_migrations/0009_migrate_i18n_fields.py | Migration.forwards | def forwards(self, orm):
"Write your forwards methods here."
# Note: Remember to use orm['appname.ModelName'] rather than "from appname.models..."
for entry_title in orm.NewsEntryTitle.objects.all():
entry = NewsEntry.objects.get(pk=entry_title.entry.pk)
entry.translate(e... | python | def forwards(self, orm):
"Write your forwards methods here."
# Note: Remember to use orm['appname.ModelName'] rather than "from appname.models..."
for entry_title in orm.NewsEntryTitle.objects.all():
entry = NewsEntry.objects.get(pk=entry_title.entry.pk)
entry.translate(e... | [
"def",
"forwards",
"(",
"self",
",",
"orm",
")",
":",
"# Note: Remember to use orm['appname.ModelName'] rather than \"from appname.models...\"",
"for",
"entry_title",
"in",
"orm",
".",
"NewsEntryTitle",
".",
"objects",
".",
"all",
"(",
")",
":",
"entry",
"=",
"NewsEnt... | Write your forwards methods here. | [
"Write",
"your",
"forwards",
"methods",
"here",
"."
] | 2ddc076ce2002a9fa462dbba701441879b49a54d | https://github.com/bitlabstudio/django-multilingual-news/blob/2ddc076ce2002a9fa462dbba701441879b49a54d/multilingual_news/south_migrations/0009_migrate_i18n_fields.py#L11-L20 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.