repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
bram85/topydo | topydo/lib/TodoListBase.py | TodoListBase.todo | def todo(self, p_identifier):
"""
The _todos list has the same order as in the backend store (usually
a todo.txt file. The user refers to the first task as number 1, so use
index 0, etc.
Alternative ways to identify a todo is using a hashed version based on
the todo's te... | python | def todo(self, p_identifier):
"""
The _todos list has the same order as in the backend store (usually
a todo.txt file. The user refers to the first task as number 1, so use
index 0, etc.
Alternative ways to identify a todo is using a hashed version based on
the todo's te... | [
"def",
"todo",
"(",
"self",
",",
"p_identifier",
")",
":",
"result",
"=",
"None",
"def",
"todo_by_uid",
"(",
"p_identifier",
")",
":",
"\"\"\" Returns the todo that corresponds to the unique ID. \"\"\"",
"result",
"=",
"None",
"if",
"config",
"(",
")",
".",
"ident... | The _todos list has the same order as in the backend store (usually
a todo.txt file. The user refers to the first task as number 1, so use
index 0, etc.
Alternative ways to identify a todo is using a hashed version based on
the todo's text, or a regexp that matches the todo's source. Th... | [
"The",
"_todos",
"list",
"has",
"the",
"same",
"order",
"as",
"in",
"the",
"backend",
"store",
"(",
"usually",
"a",
"todo",
".",
"txt",
"file",
".",
"The",
"user",
"refers",
"to",
"the",
"first",
"task",
"as",
"number",
"1",
"so",
"use",
"index",
"0"... | b59fcfca5361869a6b78d4c9808c7c6cd0a18b58 | https://github.com/bram85/topydo/blob/b59fcfca5361869a6b78d4c9808c7c6cd0a18b58/topydo/lib/TodoListBase.py#L64-L138 | train |
bram85/topydo | topydo/lib/TodoListBase.py | TodoListBase.add | def add(self, p_src):
"""
Given a todo string, parse it and put it to the end of the list.
"""
todos = self.add_list([p_src])
return todos[0] if len(todos) else None | python | def add(self, p_src):
"""
Given a todo string, parse it and put it to the end of the list.
"""
todos = self.add_list([p_src])
return todos[0] if len(todos) else None | [
"def",
"add",
"(",
"self",
",",
"p_src",
")",
":",
"todos",
"=",
"self",
".",
"add_list",
"(",
"[",
"p_src",
"]",
")",
"return",
"todos",
"[",
"0",
"]",
"if",
"len",
"(",
"todos",
")",
"else",
"None"
] | Given a todo string, parse it and put it to the end of the list. | [
"Given",
"a",
"todo",
"string",
"parse",
"it",
"and",
"put",
"it",
"to",
"the",
"end",
"of",
"the",
"list",
"."
] | b59fcfca5361869a6b78d4c9808c7c6cd0a18b58 | https://github.com/bram85/topydo/blob/b59fcfca5361869a6b78d4c9808c7c6cd0a18b58/topydo/lib/TodoListBase.py#L140-L146 | train |
bram85/topydo | topydo/lib/TodoListBase.py | TodoListBase.replace | def replace(self, p_todos):
""" Replaces whole todolist with todo objects supplied as p_todos. """
self.erase()
self.add_todos(p_todos)
self.dirty = True | python | def replace(self, p_todos):
""" Replaces whole todolist with todo objects supplied as p_todos. """
self.erase()
self.add_todos(p_todos)
self.dirty = True | [
"def",
"replace",
"(",
"self",
",",
"p_todos",
")",
":",
"self",
".",
"erase",
"(",
")",
"self",
".",
"add_todos",
"(",
"p_todos",
")",
"self",
".",
"dirty",
"=",
"True"
] | Replaces whole todolist with todo objects supplied as p_todos. | [
"Replaces",
"whole",
"todolist",
"with",
"todo",
"objects",
"supplied",
"as",
"p_todos",
"."
] | b59fcfca5361869a6b78d4c9808c7c6cd0a18b58 | https://github.com/bram85/topydo/blob/b59fcfca5361869a6b78d4c9808c7c6cd0a18b58/topydo/lib/TodoListBase.py#L181-L185 | train |
bram85/topydo | topydo/lib/TodoListBase.py | TodoListBase.append | def append(self, p_todo, p_string):
"""
Appends a text to the todo, specified by its number.
The todo will be parsed again, such that tags and projects in de
appended string are processed.
"""
if len(p_string) > 0:
new_text = p_todo.source() + ' ' + p_string
... | python | def append(self, p_todo, p_string):
"""
Appends a text to the todo, specified by its number.
The todo will be parsed again, such that tags and projects in de
appended string are processed.
"""
if len(p_string) > 0:
new_text = p_todo.source() + ' ' + p_string
... | [
"def",
"append",
"(",
"self",
",",
"p_todo",
",",
"p_string",
")",
":",
"if",
"len",
"(",
"p_string",
")",
">",
"0",
":",
"new_text",
"=",
"p_todo",
".",
"source",
"(",
")",
"+",
"' '",
"+",
"p_string",
"p_todo",
".",
"set_source_text",
"(",
"new_tex... | Appends a text to the todo, specified by its number.
The todo will be parsed again, such that tags and projects in de
appended string are processed. | [
"Appends",
"a",
"text",
"to",
"the",
"todo",
"specified",
"by",
"its",
"number",
".",
"The",
"todo",
"will",
"be",
"parsed",
"again",
"such",
"that",
"tags",
"and",
"projects",
"in",
"de",
"appended",
"string",
"are",
"processed",
"."
] | b59fcfca5361869a6b78d4c9808c7c6cd0a18b58 | https://github.com/bram85/topydo/blob/b59fcfca5361869a6b78d4c9808c7c6cd0a18b58/topydo/lib/TodoListBase.py#L191-L201 | train |
bram85/topydo | topydo/lib/TodoListBase.py | TodoListBase.projects | def projects(self):
""" Returns a set of all projects in this list. """
result = set()
for todo in self._todos:
projects = todo.projects()
result = result.union(projects)
return result | python | def projects(self):
""" Returns a set of all projects in this list. """
result = set()
for todo in self._todos:
projects = todo.projects()
result = result.union(projects)
return result | [
"def",
"projects",
"(",
"self",
")",
":",
"result",
"=",
"set",
"(",
")",
"for",
"todo",
"in",
"self",
".",
"_todos",
":",
"projects",
"=",
"todo",
".",
"projects",
"(",
")",
"result",
"=",
"result",
".",
"union",
"(",
"projects",
")",
"return",
"r... | Returns a set of all projects in this list. | [
"Returns",
"a",
"set",
"of",
"all",
"projects",
"in",
"this",
"list",
"."
] | b59fcfca5361869a6b78d4c9808c7c6cd0a18b58 | https://github.com/bram85/topydo/blob/b59fcfca5361869a6b78d4c9808c7c6cd0a18b58/topydo/lib/TodoListBase.py#L203-L210 | train |
bram85/topydo | topydo/lib/TodoListBase.py | TodoListBase.contexts | def contexts(self):
""" Returns a set of all contexts in this list. """
result = set()
for todo in self._todos:
contexts = todo.contexts()
result = result.union(contexts)
return result | python | def contexts(self):
""" Returns a set of all contexts in this list. """
result = set()
for todo in self._todos:
contexts = todo.contexts()
result = result.union(contexts)
return result | [
"def",
"contexts",
"(",
"self",
")",
":",
"result",
"=",
"set",
"(",
")",
"for",
"todo",
"in",
"self",
".",
"_todos",
":",
"contexts",
"=",
"todo",
".",
"contexts",
"(",
")",
"result",
"=",
"result",
".",
"union",
"(",
"contexts",
")",
"return",
"r... | Returns a set of all contexts in this list. | [
"Returns",
"a",
"set",
"of",
"all",
"contexts",
"in",
"this",
"list",
"."
] | b59fcfca5361869a6b78d4c9808c7c6cd0a18b58 | https://github.com/bram85/topydo/blob/b59fcfca5361869a6b78d4c9808c7c6cd0a18b58/topydo/lib/TodoListBase.py#L212-L219 | train |
bram85/topydo | topydo/lib/TodoListBase.py | TodoListBase.linenumber | def linenumber(self, p_todo):
"""
Returns the line number of the todo item.
"""
try:
return self._todos.index(p_todo) + 1
except ValueError as ex:
raise InvalidTodoException from ex | python | def linenumber(self, p_todo):
"""
Returns the line number of the todo item.
"""
try:
return self._todos.index(p_todo) + 1
except ValueError as ex:
raise InvalidTodoException from ex | [
"def",
"linenumber",
"(",
"self",
",",
"p_todo",
")",
":",
"try",
":",
"return",
"self",
".",
"_todos",
".",
"index",
"(",
"p_todo",
")",
"+",
"1",
"except",
"ValueError",
"as",
"ex",
":",
"raise",
"InvalidTodoException",
"from",
"ex"
] | Returns the line number of the todo item. | [
"Returns",
"the",
"line",
"number",
"of",
"the",
"todo",
"item",
"."
] | b59fcfca5361869a6b78d4c9808c7c6cd0a18b58 | https://github.com/bram85/topydo/blob/b59fcfca5361869a6b78d4c9808c7c6cd0a18b58/topydo/lib/TodoListBase.py#L251-L258 | train |
bram85/topydo | topydo/lib/TodoListBase.py | TodoListBase.uid | def uid(self, p_todo):
"""
Returns the unique text-based ID for a todo item.
"""
try:
return self._todo_id_map[p_todo]
except KeyError as ex:
raise InvalidTodoException from ex | python | def uid(self, p_todo):
"""
Returns the unique text-based ID for a todo item.
"""
try:
return self._todo_id_map[p_todo]
except KeyError as ex:
raise InvalidTodoException from ex | [
"def",
"uid",
"(",
"self",
",",
"p_todo",
")",
":",
"try",
":",
"return",
"self",
".",
"_todo_id_map",
"[",
"p_todo",
"]",
"except",
"KeyError",
"as",
"ex",
":",
"raise",
"InvalidTodoException",
"from",
"ex"
] | Returns the unique text-based ID for a todo item. | [
"Returns",
"the",
"unique",
"text",
"-",
"based",
"ID",
"for",
"a",
"todo",
"item",
"."
] | b59fcfca5361869a6b78d4c9808c7c6cd0a18b58 | https://github.com/bram85/topydo/blob/b59fcfca5361869a6b78d4c9808c7c6cd0a18b58/topydo/lib/TodoListBase.py#L260-L267 | train |
bram85/topydo | topydo/lib/TodoListBase.py | TodoListBase.number | def number(self, p_todo):
"""
Returns the line number or text ID of a todo (depends on the
configuration.
"""
if config().identifiers() == "text":
return self.uid(p_todo)
else:
return self.linenumber(p_todo) | python | def number(self, p_todo):
"""
Returns the line number or text ID of a todo (depends on the
configuration.
"""
if config().identifiers() == "text":
return self.uid(p_todo)
else:
return self.linenumber(p_todo) | [
"def",
"number",
"(",
"self",
",",
"p_todo",
")",
":",
"if",
"config",
"(",
")",
".",
"identifiers",
"(",
")",
"==",
"\"text\"",
":",
"return",
"self",
".",
"uid",
"(",
"p_todo",
")",
"else",
":",
"return",
"self",
".",
"linenumber",
"(",
"p_todo",
... | Returns the line number or text ID of a todo (depends on the
configuration. | [
"Returns",
"the",
"line",
"number",
"or",
"text",
"ID",
"of",
"a",
"todo",
"(",
"depends",
"on",
"the",
"configuration",
"."
] | b59fcfca5361869a6b78d4c9808c7c6cd0a18b58 | https://github.com/bram85/topydo/blob/b59fcfca5361869a6b78d4c9808c7c6cd0a18b58/topydo/lib/TodoListBase.py#L269-L277 | train |
bram85/topydo | topydo/lib/TodoListBase.py | TodoListBase.max_id_length | def max_id_length(self):
"""
Returns the maximum length of a todo ID, used for formatting purposes.
"""
if config().identifiers() == "text":
return max_id_length(len(self._todos))
else:
try:
return math.ceil(math.log(len(self._todos), 10))
... | python | def max_id_length(self):
"""
Returns the maximum length of a todo ID, used for formatting purposes.
"""
if config().identifiers() == "text":
return max_id_length(len(self._todos))
else:
try:
return math.ceil(math.log(len(self._todos), 10))
... | [
"def",
"max_id_length",
"(",
"self",
")",
":",
"if",
"config",
"(",
")",
".",
"identifiers",
"(",
")",
"==",
"\"text\"",
":",
"return",
"max_id_length",
"(",
"len",
"(",
"self",
".",
"_todos",
")",
")",
"else",
":",
"try",
":",
"return",
"math",
".",... | Returns the maximum length of a todo ID, used for formatting purposes. | [
"Returns",
"the",
"maximum",
"length",
"of",
"a",
"todo",
"ID",
"used",
"for",
"formatting",
"purposes",
"."
] | b59fcfca5361869a6b78d4c9808c7c6cd0a18b58 | https://github.com/bram85/topydo/blob/b59fcfca5361869a6b78d4c9808c7c6cd0a18b58/topydo/lib/TodoListBase.py#L279-L289 | train |
bram85/topydo | topydo/lib/TodoListBase.py | TodoListBase.ids | def ids(self):
""" Returns set with all todo IDs. """
if config().identifiers() == 'text':
ids = self._id_todo_map.keys()
else:
ids = [str(i + 1) for i in range(self.count())]
return set(ids) | python | def ids(self):
""" Returns set with all todo IDs. """
if config().identifiers() == 'text':
ids = self._id_todo_map.keys()
else:
ids = [str(i + 1) for i in range(self.count())]
return set(ids) | [
"def",
"ids",
"(",
"self",
")",
":",
"if",
"config",
"(",
")",
".",
"identifiers",
"(",
")",
"==",
"'text'",
":",
"ids",
"=",
"self",
".",
"_id_todo_map",
".",
"keys",
"(",
")",
"else",
":",
"ids",
"=",
"[",
"str",
"(",
"i",
"+",
"1",
")",
"f... | Returns set with all todo IDs. | [
"Returns",
"set",
"with",
"all",
"todo",
"IDs",
"."
] | b59fcfca5361869a6b78d4c9808c7c6cd0a18b58 | https://github.com/bram85/topydo/blob/b59fcfca5361869a6b78d4c9808c7c6cd0a18b58/topydo/lib/TodoListBase.py#L313-L319 | train |
bram85/topydo | topydo/ui/columns/Transaction.py | Transaction.prepare | def prepare(self, p_args):
"""
Prepares list of operations to execute based on p_args, list of
todo items contained in _todo_ids attribute and _subcommand
attribute.
"""
if self._todo_ids:
id_position = p_args.index('{}')
# Not using MultiCommand ... | python | def prepare(self, p_args):
"""
Prepares list of operations to execute based on p_args, list of
todo items contained in _todo_ids attribute and _subcommand
attribute.
"""
if self._todo_ids:
id_position = p_args.index('{}')
# Not using MultiCommand ... | [
"def",
"prepare",
"(",
"self",
",",
"p_args",
")",
":",
"if",
"self",
".",
"_todo_ids",
":",
"id_position",
"=",
"p_args",
".",
"index",
"(",
"'{}'",
")",
"# Not using MultiCommand abilities would make EditCommand awkward",
"if",
"self",
".",
"_multi",
":",
"p_a... | Prepares list of operations to execute based on p_args, list of
todo items contained in _todo_ids attribute and _subcommand
attribute. | [
"Prepares",
"list",
"of",
"operations",
"to",
"execute",
"based",
"on",
"p_args",
"list",
"of",
"todo",
"items",
"contained",
"in",
"_todo_ids",
"attribute",
"and",
"_subcommand",
"attribute",
"."
] | b59fcfca5361869a6b78d4c9808c7c6cd0a18b58 | https://github.com/bram85/topydo/blob/b59fcfca5361869a6b78d4c9808c7c6cd0a18b58/topydo/ui/columns/Transaction.py#L34-L55 | train |
bram85/topydo | topydo/ui/columns/Transaction.py | Transaction.execute | def execute(self):
"""
Executes each operation from _operations attribute.
"""
last_operation = len(self._operations) - 1
for i, operation in enumerate(self._operations):
command = self._cmd(operation)
if command.execute() is False:
return... | python | def execute(self):
"""
Executes each operation from _operations attribute.
"""
last_operation = len(self._operations) - 1
for i, operation in enumerate(self._operations):
command = self._cmd(operation)
if command.execute() is False:
return... | [
"def",
"execute",
"(",
"self",
")",
":",
"last_operation",
"=",
"len",
"(",
"self",
".",
"_operations",
")",
"-",
"1",
"for",
"i",
",",
"operation",
"in",
"enumerate",
"(",
"self",
".",
"_operations",
")",
":",
"command",
"=",
"self",
".",
"_cmd",
"(... | Executes each operation from _operations attribute. | [
"Executes",
"each",
"operation",
"from",
"_operations",
"attribute",
"."
] | b59fcfca5361869a6b78d4c9808c7c6cd0a18b58 | https://github.com/bram85/topydo/blob/b59fcfca5361869a6b78d4c9808c7c6cd0a18b58/topydo/ui/columns/Transaction.py#L66-L81 | train |
bram85/topydo | topydo/lib/RelativeDate.py | _add_months | def _add_months(p_sourcedate, p_months):
"""
Adds a number of months to the source date.
Takes into account shorter months and leap years and such.
https://stackoverflow.com/questions/4130922/how-to-increment-datetime-month-in-python
"""
month = p_sourcedate.month - 1 + p_months
year = p_s... | python | def _add_months(p_sourcedate, p_months):
"""
Adds a number of months to the source date.
Takes into account shorter months and leap years and such.
https://stackoverflow.com/questions/4130922/how-to-increment-datetime-month-in-python
"""
month = p_sourcedate.month - 1 + p_months
year = p_s... | [
"def",
"_add_months",
"(",
"p_sourcedate",
",",
"p_months",
")",
":",
"month",
"=",
"p_sourcedate",
".",
"month",
"-",
"1",
"+",
"p_months",
"year",
"=",
"p_sourcedate",
".",
"year",
"+",
"month",
"//",
"12",
"month",
"=",
"month",
"%",
"12",
"+",
"1",... | Adds a number of months to the source date.
Takes into account shorter months and leap years and such.
https://stackoverflow.com/questions/4130922/how-to-increment-datetime-month-in-python | [
"Adds",
"a",
"number",
"of",
"months",
"to",
"the",
"source",
"date",
"."
] | b59fcfca5361869a6b78d4c9808c7c6cd0a18b58 | https://github.com/bram85/topydo/blob/b59fcfca5361869a6b78d4c9808c7c6cd0a18b58/topydo/lib/RelativeDate.py#L24-L37 | train |
bram85/topydo | topydo/lib/RelativeDate.py | _add_business_days | def _add_business_days(p_sourcedate, p_bdays):
""" Adds a number of business days to the source date. """
result = p_sourcedate
delta = 1 if p_bdays > 0 else -1
while abs(p_bdays) > 0:
result += timedelta(delta)
weekday = result.weekday()
if weekday >= 5:
continue
... | python | def _add_business_days(p_sourcedate, p_bdays):
""" Adds a number of business days to the source date. """
result = p_sourcedate
delta = 1 if p_bdays > 0 else -1
while abs(p_bdays) > 0:
result += timedelta(delta)
weekday = result.weekday()
if weekday >= 5:
continue
... | [
"def",
"_add_business_days",
"(",
"p_sourcedate",
",",
"p_bdays",
")",
":",
"result",
"=",
"p_sourcedate",
"delta",
"=",
"1",
"if",
"p_bdays",
">",
"0",
"else",
"-",
"1",
"while",
"abs",
"(",
"p_bdays",
")",
">",
"0",
":",
"result",
"+=",
"timedelta",
... | Adds a number of business days to the source date. | [
"Adds",
"a",
"number",
"of",
"business",
"days",
"to",
"the",
"source",
"date",
"."
] | b59fcfca5361869a6b78d4c9808c7c6cd0a18b58 | https://github.com/bram85/topydo/blob/b59fcfca5361869a6b78d4c9808c7c6cd0a18b58/topydo/lib/RelativeDate.py#L40-L54 | train |
bram85/topydo | topydo/lib/RelativeDate.py | _convert_weekday_pattern | def _convert_weekday_pattern(p_weekday):
"""
Converts a weekday name to an absolute date.
When today's day of the week is entered, it will return next week's date.
"""
day_value = {
'mo': 0,
'tu': 1,
'we': 2,
'th': 3,
'fr': 4,
'sa': 5,
'su': 6... | python | def _convert_weekday_pattern(p_weekday):
"""
Converts a weekday name to an absolute date.
When today's day of the week is entered, it will return next week's date.
"""
day_value = {
'mo': 0,
'tu': 1,
'we': 2,
'th': 3,
'fr': 4,
'sa': 5,
'su': 6... | [
"def",
"_convert_weekday_pattern",
"(",
"p_weekday",
")",
":",
"day_value",
"=",
"{",
"'mo'",
":",
"0",
",",
"'tu'",
":",
"1",
",",
"'we'",
":",
"2",
",",
"'th'",
":",
"3",
",",
"'fr'",
":",
"4",
",",
"'sa'",
":",
"5",
",",
"'su'",
":",
"6",
"}... | Converts a weekday name to an absolute date.
When today's day of the week is entered, it will return next week's date. | [
"Converts",
"a",
"weekday",
"name",
"to",
"an",
"absolute",
"date",
"."
] | b59fcfca5361869a6b78d4c9808c7c6cd0a18b58 | https://github.com/bram85/topydo/blob/b59fcfca5361869a6b78d4c9808c7c6cd0a18b58/topydo/lib/RelativeDate.py#L81-L103 | train |
bram85/topydo | topydo/lib/RelativeDate.py | relative_date_to_date | def relative_date_to_date(p_date, p_offset=None):
"""
Transforms a relative date into a date object.
The following formats are understood:
* [0-9][dwmy]
* 'yesterday', 'today' or 'tomorrow'
* days of the week (in full or abbreviated)
"""
result = None
p_date = p_date.lower()
p_... | python | def relative_date_to_date(p_date, p_offset=None):
"""
Transforms a relative date into a date object.
The following formats are understood:
* [0-9][dwmy]
* 'yesterday', 'today' or 'tomorrow'
* days of the week (in full or abbreviated)
"""
result = None
p_date = p_date.lower()
p_... | [
"def",
"relative_date_to_date",
"(",
"p_date",
",",
"p_offset",
"=",
"None",
")",
":",
"result",
"=",
"None",
"p_date",
"=",
"p_date",
".",
"lower",
"(",
")",
"p_offset",
"=",
"p_offset",
"or",
"date",
".",
"today",
"(",
")",
"relative",
"=",
"re",
"."... | Transforms a relative date into a date object.
The following formats are understood:
* [0-9][dwmy]
* 'yesterday', 'today' or 'tomorrow'
* days of the week (in full or abbreviated) | [
"Transforms",
"a",
"relative",
"date",
"into",
"a",
"date",
"object",
"."
] | b59fcfca5361869a6b78d4c9808c7c6cd0a18b58 | https://github.com/bram85/topydo/blob/b59fcfca5361869a6b78d4c9808c7c6cd0a18b58/topydo/lib/RelativeDate.py#L106-L152 | train |
bram85/topydo | topydo/lib/prettyprinters/Numbers.py | PrettyPrinterNumbers.filter | def filter(self, p_todo_str, p_todo):
""" Prepends the number to the todo string. """
return "|{:>3}| {}".format(self.todolist.number(p_todo), p_todo_str) | python | def filter(self, p_todo_str, p_todo):
""" Prepends the number to the todo string. """
return "|{:>3}| {}".format(self.todolist.number(p_todo), p_todo_str) | [
"def",
"filter",
"(",
"self",
",",
"p_todo_str",
",",
"p_todo",
")",
":",
"return",
"\"|{:>3}| {}\"",
".",
"format",
"(",
"self",
".",
"todolist",
".",
"number",
"(",
"p_todo",
")",
",",
"p_todo_str",
")"
] | Prepends the number to the todo string. | [
"Prepends",
"the",
"number",
"to",
"the",
"todo",
"string",
"."
] | b59fcfca5361869a6b78d4c9808c7c6cd0a18b58 | https://github.com/bram85/topydo/blob/b59fcfca5361869a6b78d4c9808c7c6cd0a18b58/topydo/lib/prettyprinters/Numbers.py#L29-L31 | train |
bram85/topydo | topydo/lib/WriteCommand.py | WriteCommand.postprocess_input_todo | def postprocess_input_todo(self, p_todo):
"""
Post-processes a parsed todo when adding it to the list.
* It converts relative dates to absolute ones.
* Automatically inserts a creation date if not present.
* Handles more user-friendly dependencies with before:, partof: and
... | python | def postprocess_input_todo(self, p_todo):
"""
Post-processes a parsed todo when adding it to the list.
* It converts relative dates to absolute ones.
* Automatically inserts a creation date if not present.
* Handles more user-friendly dependencies with before:, partof: and
... | [
"def",
"postprocess_input_todo",
"(",
"self",
",",
"p_todo",
")",
":",
"def",
"convert_date",
"(",
"p_tag",
")",
":",
"value",
"=",
"p_todo",
".",
"tag_value",
"(",
"p_tag",
")",
"if",
"value",
":",
"dateobj",
"=",
"relative_date_to_date",
"(",
"value",
")... | Post-processes a parsed todo when adding it to the list.
* It converts relative dates to absolute ones.
* Automatically inserts a creation date if not present.
* Handles more user-friendly dependencies with before:, partof: and
after: tags | [
"Post",
"-",
"processes",
"a",
"parsed",
"todo",
"when",
"adding",
"it",
"to",
"the",
"list",
"."
] | b59fcfca5361869a6b78d4c9808c7c6cd0a18b58 | https://github.com/bram85/topydo/blob/b59fcfca5361869a6b78d4c9808c7c6cd0a18b58/topydo/lib/WriteCommand.py#L22-L77 | train |
bram85/topydo | topydo/ui/columns/ColumnLayout.py | columns | def columns(p_alt_layout_path=None):
"""
Returns list with complete column configuration dicts.
"""
def _get_column_dict(p_cp, p_column):
column_dict = dict()
filterexpr = p_cp.get(p_column, 'filterexpr')
try:
title = p_cp.get(p_column, 'title')
except NoOpt... | python | def columns(p_alt_layout_path=None):
"""
Returns list with complete column configuration dicts.
"""
def _get_column_dict(p_cp, p_column):
column_dict = dict()
filterexpr = p_cp.get(p_column, 'filterexpr')
try:
title = p_cp.get(p_column, 'title')
except NoOpt... | [
"def",
"columns",
"(",
"p_alt_layout_path",
"=",
"None",
")",
":",
"def",
"_get_column_dict",
"(",
"p_cp",
",",
"p_column",
")",
":",
"column_dict",
"=",
"dict",
"(",
")",
"filterexpr",
"=",
"p_cp",
".",
"get",
"(",
"p_column",
",",
"'filterexpr'",
")",
... | Returns list with complete column configuration dicts. | [
"Returns",
"list",
"with",
"complete",
"column",
"configuration",
"dicts",
"."
] | b59fcfca5361869a6b78d4c9808c7c6cd0a18b58 | https://github.com/bram85/topydo/blob/b59fcfca5361869a6b78d4c9808c7c6cd0a18b58/topydo/ui/columns/ColumnLayout.py#L23-L73 | train |
bram85/topydo | topydo/lib/DCommand.py | DCommand._active_todos | def _active_todos(self):
"""
Returns a list of active todos, taking uncompleted subtodos into
account.
The stored length of the todolist is taken into account, to prevent new
todos created by recurrence to pop up as newly activated tasks.
Since these todos pop up at the ... | python | def _active_todos(self):
"""
Returns a list of active todos, taking uncompleted subtodos into
account.
The stored length of the todolist is taken into account, to prevent new
todos created by recurrence to pop up as newly activated tasks.
Since these todos pop up at the ... | [
"def",
"_active_todos",
"(",
"self",
")",
":",
"return",
"[",
"todo",
"for",
"todo",
"in",
"self",
".",
"todolist",
".",
"todos",
"(",
")",
"if",
"not",
"self",
".",
"_uncompleted_children",
"(",
"todo",
")",
"and",
"todo",
".",
"is_active",
"(",
")",
... | Returns a list of active todos, taking uncompleted subtodos into
account.
The stored length of the todolist is taken into account, to prevent new
todos created by recurrence to pop up as newly activated tasks.
Since these todos pop up at the end of the list, we cut off the list
... | [
"Returns",
"a",
"list",
"of",
"active",
"todos",
"taking",
"uncompleted",
"subtodos",
"into",
"account",
"."
] | b59fcfca5361869a6b78d4c9808c7c6cd0a18b58 | https://github.com/bram85/topydo/blob/b59fcfca5361869a6b78d4c9808c7c6cd0a18b58/topydo/lib/DCommand.py#L84-L95 | train |
indygreg/python-zstandard | zstandard/cffi.py | ZstdDecompressionReader._decompress_into_buffer | def _decompress_into_buffer(self, out_buffer):
"""Decompress available input into an output buffer.
Returns True if data in output buffer should be emitted.
"""
zresult = lib.ZSTD_decompressStream(self._decompressor._dctx,
out_buffer, self._in... | python | def _decompress_into_buffer(self, out_buffer):
"""Decompress available input into an output buffer.
Returns True if data in output buffer should be emitted.
"""
zresult = lib.ZSTD_decompressStream(self._decompressor._dctx,
out_buffer, self._in... | [
"def",
"_decompress_into_buffer",
"(",
"self",
",",
"out_buffer",
")",
":",
"zresult",
"=",
"lib",
".",
"ZSTD_decompressStream",
"(",
"self",
".",
"_decompressor",
".",
"_dctx",
",",
"out_buffer",
",",
"self",
".",
"_in_buffer",
")",
"if",
"self",
".",
"_in_... | Decompress available input into an output buffer.
Returns True if data in output buffer should be emitted. | [
"Decompress",
"available",
"input",
"into",
"an",
"output",
"buffer",
"."
] | 74fa5904c3e7df67a4260344bf919356a181487e | https://github.com/indygreg/python-zstandard/blob/74fa5904c3e7df67a4260344bf919356a181487e/zstandard/cffi.py#L1864-L1890 | train |
indygreg/python-zstandard | setup_zstd.py | get_c_extension | def get_c_extension(support_legacy=False, system_zstd=False, name='zstd',
warnings_as_errors=False, root=None):
"""Obtain a distutils.extension.Extension for the C extension.
``support_legacy`` controls whether to compile in legacy zstd format support.
``system_zstd`` controls whether ... | python | def get_c_extension(support_legacy=False, system_zstd=False, name='zstd',
warnings_as_errors=False, root=None):
"""Obtain a distutils.extension.Extension for the C extension.
``support_legacy`` controls whether to compile in legacy zstd format support.
``system_zstd`` controls whether ... | [
"def",
"get_c_extension",
"(",
"support_legacy",
"=",
"False",
",",
"system_zstd",
"=",
"False",
",",
"name",
"=",
"'zstd'",
",",
"warnings_as_errors",
"=",
"False",
",",
"root",
"=",
"None",
")",
":",
"actual_root",
"=",
"os",
".",
"path",
".",
"abspath",... | Obtain a distutils.extension.Extension for the C extension.
``support_legacy`` controls whether to compile in legacy zstd format support.
``system_zstd`` controls whether to compile against the system zstd library.
For this to work, the system zstd library and headers must match what
python-zstandard ... | [
"Obtain",
"a",
"distutils",
".",
"extension",
".",
"Extension",
"for",
"the",
"C",
"extension",
"."
] | 74fa5904c3e7df67a4260344bf919356a181487e | https://github.com/indygreg/python-zstandard/blob/74fa5904c3e7df67a4260344bf919356a181487e/setup_zstd.py#L100-L190 | train |
sffjunkie/astral | src/astral.py | Location.timezone | def timezone(self):
"""The name of the time zone for the location.
A list of time zone names can be obtained from pytz. For example.
>>> from pytz import all_timezones
>>> for timezone in all_timezones:
... print(timezone)
"""
if not self._timezone_group an... | python | def timezone(self):
"""The name of the time zone for the location.
A list of time zone names can be obtained from pytz. For example.
>>> from pytz import all_timezones
>>> for timezone in all_timezones:
... print(timezone)
"""
if not self._timezone_group an... | [
"def",
"timezone",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_timezone_group",
"and",
"not",
"self",
".",
"_timezone_location",
":",
"return",
"None",
"if",
"self",
".",
"_timezone_location",
"!=",
"\"\"",
":",
"return",
"\"%s/%s\"",
"%",
"(",
"sel... | The name of the time zone for the location.
A list of time zone names can be obtained from pytz. For example.
>>> from pytz import all_timezones
>>> for timezone in all_timezones:
... print(timezone) | [
"The",
"name",
"of",
"the",
"time",
"zone",
"for",
"the",
"location",
"."
] | b0aa63fce692357cd33c2bf36c69ed5b6582440c | https://github.com/sffjunkie/astral/blob/b0aa63fce692357cd33c2bf36c69ed5b6582440c/src/astral.py#L681-L697 | train |
sffjunkie/astral | src/astral.py | Location.tz | def tz(self):
"""Time zone information."""
if self.timezone is None:
return None
try:
tz = pytz.timezone(self.timezone)
return tz
except pytz.UnknownTimeZoneError:
raise AstralError("Unknown timezone '%s'" % self.timezone) | python | def tz(self):
"""Time zone information."""
if self.timezone is None:
return None
try:
tz = pytz.timezone(self.timezone)
return tz
except pytz.UnknownTimeZoneError:
raise AstralError("Unknown timezone '%s'" % self.timezone) | [
"def",
"tz",
"(",
"self",
")",
":",
"if",
"self",
".",
"timezone",
"is",
"None",
":",
"return",
"None",
"try",
":",
"tz",
"=",
"pytz",
".",
"timezone",
"(",
"self",
".",
"timezone",
")",
"return",
"tz",
"except",
"pytz",
".",
"UnknownTimeZoneError",
... | Time zone information. | [
"Time",
"zone",
"information",
"."
] | b0aa63fce692357cd33c2bf36c69ed5b6582440c | https://github.com/sffjunkie/astral/blob/b0aa63fce692357cd33c2bf36c69ed5b6582440c/src/astral.py#L716-L726 | train |
sffjunkie/astral | src/astral.py | Location.sun | def sun(self, date=None, local=True, use_elevation=True):
"""Returns dawn, sunrise, noon, sunset and dusk as a dictionary.
:param date: The date for which to calculate the times.
If no date is specified then the current date will be used.
:type date: :class:`~datetime.date... | python | def sun(self, date=None, local=True, use_elevation=True):
"""Returns dawn, sunrise, noon, sunset and dusk as a dictionary.
:param date: The date for which to calculate the times.
If no date is specified then the current date will be used.
:type date: :class:`~datetime.date... | [
"def",
"sun",
"(",
"self",
",",
"date",
"=",
"None",
",",
"local",
"=",
"True",
",",
"use_elevation",
"=",
"True",
")",
":",
"if",
"local",
"and",
"self",
".",
"timezone",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"Local time requested but Location ... | Returns dawn, sunrise, noon, sunset and dusk as a dictionary.
:param date: The date for which to calculate the times.
If no date is specified then the current date will be used.
:type date: :class:`~datetime.date`
:param local: True = Time to be returned in location's ti... | [
"Returns",
"dawn",
"sunrise",
"noon",
"sunset",
"and",
"dusk",
"as",
"a",
"dictionary",
"."
] | b0aa63fce692357cd33c2bf36c69ed5b6582440c | https://github.com/sffjunkie/astral/blob/b0aa63fce692357cd33c2bf36c69ed5b6582440c/src/astral.py#L756-L795 | train |
sffjunkie/astral | src/astral.py | Location.sunrise | def sunrise(self, date=None, local=True, use_elevation=True):
"""Return sunrise time.
Calculates the time in the morning when the sun is a 0.833 degrees
below the horizon. This is to account for refraction.
:param date: The date for which to calculate the sunrise time.
... | python | def sunrise(self, date=None, local=True, use_elevation=True):
"""Return sunrise time.
Calculates the time in the morning when the sun is a 0.833 degrees
below the horizon. This is to account for refraction.
:param date: The date for which to calculate the sunrise time.
... | [
"def",
"sunrise",
"(",
"self",
",",
"date",
"=",
"None",
",",
"local",
"=",
"True",
",",
"use_elevation",
"=",
"True",
")",
":",
"if",
"local",
"and",
"self",
".",
"timezone",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"Local time requested but Locat... | Return sunrise time.
Calculates the time in the morning when the sun is a 0.833 degrees
below the horizon. This is to account for refraction.
:param date: The date for which to calculate the sunrise time.
If no date is specified then the current date will be used.
... | [
"Return",
"sunrise",
"time",
"."
] | b0aa63fce692357cd33c2bf36c69ed5b6582440c | https://github.com/sffjunkie/astral/blob/b0aa63fce692357cd33c2bf36c69ed5b6582440c/src/astral.py#L837-L876 | train |
sffjunkie/astral | src/astral.py | Location.time_at_elevation | def time_at_elevation(self, elevation, direction=SUN_RISING, date=None, local=True):
"""Calculate the time when the sun is at the specified elevation.
Note:
This method uses positive elevations for those above the horizon.
Elevations greater than 90 degrees are converted to a s... | python | def time_at_elevation(self, elevation, direction=SUN_RISING, date=None, local=True):
"""Calculate the time when the sun is at the specified elevation.
Note:
This method uses positive elevations for those above the horizon.
Elevations greater than 90 degrees are converted to a s... | [
"def",
"time_at_elevation",
"(",
"self",
",",
"elevation",
",",
"direction",
"=",
"SUN_RISING",
",",
"date",
"=",
"None",
",",
"local",
"=",
"True",
")",
":",
"if",
"local",
"and",
"self",
".",
"timezone",
"is",
"None",
":",
"raise",
"ValueError",
"(",
... | Calculate the time when the sun is at the specified elevation.
Note:
This method uses positive elevations for those above the horizon.
Elevations greater than 90 degrees are converted to a setting sun
i.e. an elevation of 110 will calculate a setting sun at 70 degrees.
... | [
"Calculate",
"the",
"time",
"when",
"the",
"sun",
"is",
"at",
"the",
"specified",
"elevation",
"."
] | b0aa63fce692357cd33c2bf36c69ed5b6582440c | https://github.com/sffjunkie/astral/blob/b0aa63fce692357cd33c2bf36c69ed5b6582440c/src/astral.py#L1145-L1194 | train |
sffjunkie/astral | src/astral.py | Location.blue_hour | def blue_hour(self, direction=SUN_RISING, date=None, local=True, use_elevation=True):
"""Returns the start and end times of the Blue Hour when the sun is traversing
in the specified direction.
This method uses the definition from PhotoPills i.e. the
blue hour is when the sun is between ... | python | def blue_hour(self, direction=SUN_RISING, date=None, local=True, use_elevation=True):
"""Returns the start and end times of the Blue Hour when the sun is traversing
in the specified direction.
This method uses the definition from PhotoPills i.e. the
blue hour is when the sun is between ... | [
"def",
"blue_hour",
"(",
"self",
",",
"direction",
"=",
"SUN_RISING",
",",
"date",
"=",
"None",
",",
"local",
"=",
"True",
",",
"use_elevation",
"=",
"True",
")",
":",
"if",
"local",
"and",
"self",
".",
"timezone",
"is",
"None",
":",
"raise",
"ValueErr... | Returns the start and end times of the Blue Hour when the sun is traversing
in the specified direction.
This method uses the definition from PhotoPills i.e. the
blue hour is when the sun is between 6 and 4 degrees below the horizon.
:param direction: Determines whether the time is for... | [
"Returns",
"the",
"start",
"and",
"end",
"times",
"of",
"the",
"Blue",
"Hour",
"when",
"the",
"sun",
"is",
"traversing",
"in",
"the",
"specified",
"direction",
"."
] | b0aa63fce692357cd33c2bf36c69ed5b6582440c | https://github.com/sffjunkie/astral/blob/b0aa63fce692357cd33c2bf36c69ed5b6582440c/src/astral.py#L1285-L1332 | train |
sffjunkie/astral | src/astral.py | Location.moon_phase | def moon_phase(self, date=None, rtype=int):
"""Calculates the moon phase for a specific date.
:param date: The date to calculate the phase for.
If ommitted the current date is used.
:type date: :class:`datetime.date`
:returns:
A number designating the p... | python | def moon_phase(self, date=None, rtype=int):
"""Calculates the moon phase for a specific date.
:param date: The date to calculate the phase for.
If ommitted the current date is used.
:type date: :class:`datetime.date`
:returns:
A number designating the p... | [
"def",
"moon_phase",
"(",
"self",
",",
"date",
"=",
"None",
",",
"rtype",
"=",
"int",
")",
":",
"if",
"self",
".",
"astral",
"is",
"None",
":",
"self",
".",
"astral",
"=",
"Astral",
"(",
")",
"if",
"date",
"is",
"None",
":",
"date",
"=",
"datetim... | Calculates the moon phase for a specific date.
:param date: The date to calculate the phase for.
If ommitted the current date is used.
:type date: :class:`datetime.date`
:returns:
A number designating the phase
| 0 = New moon
|... | [
"Calculates",
"the",
"moon",
"phase",
"for",
"a",
"specific",
"date",
"."
] | b0aa63fce692357cd33c2bf36c69ed5b6582440c | https://github.com/sffjunkie/astral/blob/b0aa63fce692357cd33c2bf36c69ed5b6582440c/src/astral.py#L1390-L1412 | train |
sffjunkie/astral | src/astral.py | AstralGeocoder.add_locations | def add_locations(self, locations):
"""Add extra locations to AstralGeocoder.
Extra locations can be
* A single string containing one or more locations separated by a newline.
* A list of strings
* A list of lists/tuples that are passed to a :class:`Location` constructor
... | python | def add_locations(self, locations):
"""Add extra locations to AstralGeocoder.
Extra locations can be
* A single string containing one or more locations separated by a newline.
* A list of strings
* A list of lists/tuples that are passed to a :class:`Location` constructor
... | [
"def",
"add_locations",
"(",
"self",
",",
"locations",
")",
":",
"if",
"isinstance",
"(",
"locations",
",",
"(",
"str",
",",
"ustr",
")",
")",
":",
"self",
".",
"_add_from_str",
"(",
"locations",
")",
"elif",
"isinstance",
"(",
"locations",
",",
"(",
"... | Add extra locations to AstralGeocoder.
Extra locations can be
* A single string containing one or more locations separated by a newline.
* A list of strings
* A list of lists/tuples that are passed to a :class:`Location` constructor | [
"Add",
"extra",
"locations",
"to",
"AstralGeocoder",
"."
] | b0aa63fce692357cd33c2bf36c69ed5b6582440c | https://github.com/sffjunkie/astral/blob/b0aa63fce692357cd33c2bf36c69ed5b6582440c/src/astral.py#L1512-L1525 | train |
sffjunkie/astral | src/astral.py | AstralGeocoder._add_from_str | def _add_from_str(self, s):
"""Add locations from a string"""
if sys.version_info[0] < 3 and isinstance(s, str):
s = s.decode('utf-8')
for line in s.split("\n"):
self._parse_line(line) | python | def _add_from_str(self, s):
"""Add locations from a string"""
if sys.version_info[0] < 3 and isinstance(s, str):
s = s.decode('utf-8')
for line in s.split("\n"):
self._parse_line(line) | [
"def",
"_add_from_str",
"(",
"self",
",",
"s",
")",
":",
"if",
"sys",
".",
"version_info",
"[",
"0",
"]",
"<",
"3",
"and",
"isinstance",
"(",
"s",
",",
"str",
")",
":",
"s",
"=",
"s",
".",
"decode",
"(",
"'utf-8'",
")",
"for",
"line",
"in",
"s"... | Add locations from a string | [
"Add",
"locations",
"from",
"a",
"string"
] | b0aa63fce692357cd33c2bf36c69ed5b6582440c | https://github.com/sffjunkie/astral/blob/b0aa63fce692357cd33c2bf36c69ed5b6582440c/src/astral.py#L1527-L1534 | train |
sffjunkie/astral | src/astral.py | AstralGeocoder._add_from_list | def _add_from_list(self, l):
"""Add locations from a list of either strings or lists or tuples.
Lists of lists and tuples are passed to the Location constructor
"""
for item in l:
if isinstance(item, (str, ustr)):
self._add_from_str(item)
elif is... | python | def _add_from_list(self, l):
"""Add locations from a list of either strings or lists or tuples.
Lists of lists and tuples are passed to the Location constructor
"""
for item in l:
if isinstance(item, (str, ustr)):
self._add_from_str(item)
elif is... | [
"def",
"_add_from_list",
"(",
"self",
",",
"l",
")",
":",
"for",
"item",
"in",
"l",
":",
"if",
"isinstance",
"(",
"item",
",",
"(",
"str",
",",
"ustr",
")",
")",
":",
"self",
".",
"_add_from_str",
"(",
"item",
")",
"elif",
"isinstance",
"(",
"item"... | Add locations from a list of either strings or lists or tuples.
Lists of lists and tuples are passed to the Location constructor | [
"Add",
"locations",
"from",
"a",
"list",
"of",
"either",
"strings",
"or",
"lists",
"or",
"tuples",
"."
] | b0aa63fce692357cd33c2bf36c69ed5b6582440c | https://github.com/sffjunkie/astral/blob/b0aa63fce692357cd33c2bf36c69ed5b6582440c/src/astral.py#L1536-L1547 | train |
sffjunkie/astral | src/astral.py | GoogleGeocoder._get_geocoding | def _get_geocoding(self, key, location):
"""Lookup the Google geocoding API information for `key`"""
url = self._location_query_base % quote_plus(key)
if self.api_key:
url += "&key=%s" % self.api_key
data = self._read_from_url(url)
response = json.loads(data)
... | python | def _get_geocoding(self, key, location):
"""Lookup the Google geocoding API information for `key`"""
url = self._location_query_base % quote_plus(key)
if self.api_key:
url += "&key=%s" % self.api_key
data = self._read_from_url(url)
response = json.loads(data)
... | [
"def",
"_get_geocoding",
"(",
"self",
",",
"key",
",",
"location",
")",
":",
"url",
"=",
"self",
".",
"_location_query_base",
"%",
"quote_plus",
"(",
"key",
")",
"if",
"self",
".",
"api_key",
":",
"url",
"+=",
"\"&key=%s\"",
"%",
"self",
".",
"api_key",
... | Lookup the Google geocoding API information for `key` | [
"Lookup",
"the",
"Google",
"geocoding",
"API",
"information",
"for",
"key"
] | b0aa63fce692357cd33c2bf36c69ed5b6582440c | https://github.com/sffjunkie/astral/blob/b0aa63fce692357cd33c2bf36c69ed5b6582440c/src/astral.py#L1684-L1707 | train |
sffjunkie/astral | src/astral.py | GoogleGeocoder._get_timezone | def _get_timezone(self, location):
"""Query the timezone information with the latitude and longitude of
the specified `location`.
This function assumes the timezone of the location has always been
the same as it is now by using time() in the query string.
"""
url = self... | python | def _get_timezone(self, location):
"""Query the timezone information with the latitude and longitude of
the specified `location`.
This function assumes the timezone of the location has always been
the same as it is now by using time() in the query string.
"""
url = self... | [
"def",
"_get_timezone",
"(",
"self",
",",
"location",
")",
":",
"url",
"=",
"self",
".",
"_timezone_query_base",
"%",
"(",
"location",
".",
"latitude",
",",
"location",
".",
"longitude",
",",
"int",
"(",
"time",
"(",
")",
")",
",",
")",
"if",
"self",
... | Query the timezone information with the latitude and longitude of
the specified `location`.
This function assumes the timezone of the location has always been
the same as it is now by using time() in the query string. | [
"Query",
"the",
"timezone",
"information",
"with",
"the",
"latitude",
"and",
"longitude",
"of",
"the",
"specified",
"location",
"."
] | b0aa63fce692357cd33c2bf36c69ed5b6582440c | https://github.com/sffjunkie/astral/blob/b0aa63fce692357cd33c2bf36c69ed5b6582440c/src/astral.py#L1709-L1729 | train |
sffjunkie/astral | src/astral.py | GoogleGeocoder._get_elevation | def _get_elevation(self, location):
"""Query the elevation information with the latitude and longitude of
the specified `location`.
"""
url = self._elevation_query_base % (location.latitude, location.longitude)
if self.api_key != "":
url += "&key=%s" % self.api_key
... | python | def _get_elevation(self, location):
"""Query the elevation information with the latitude and longitude of
the specified `location`.
"""
url = self._elevation_query_base % (location.latitude, location.longitude)
if self.api_key != "":
url += "&key=%s" % self.api_key
... | [
"def",
"_get_elevation",
"(",
"self",
",",
"location",
")",
":",
"url",
"=",
"self",
".",
"_elevation_query_base",
"%",
"(",
"location",
".",
"latitude",
",",
"location",
".",
"longitude",
")",
"if",
"self",
".",
"api_key",
"!=",
"\"\"",
":",
"url",
"+="... | Query the elevation information with the latitude and longitude of
the specified `location`. | [
"Query",
"the",
"elevation",
"information",
"with",
"the",
"latitude",
"and",
"longitude",
"of",
"the",
"specified",
"location",
"."
] | b0aa63fce692357cd33c2bf36c69ed5b6582440c | https://github.com/sffjunkie/astral/blob/b0aa63fce692357cd33c2bf36c69ed5b6582440c/src/astral.py#L1731-L1744 | train |
sffjunkie/astral | src/astral.py | Astral.sun_utc | def sun_utc(self, date, latitude, longitude, observer_elevation=0):
"""Calculate all the info for the sun at once.
All times are returned in the UTC timezone.
:param date: Date to calculate for.
:type date: :class:`datetime.date`
:param latitude: Latitude - Northe... | python | def sun_utc(self, date, latitude, longitude, observer_elevation=0):
"""Calculate all the info for the sun at once.
All times are returned in the UTC timezone.
:param date: Date to calculate for.
:type date: :class:`datetime.date`
:param latitude: Latitude - Northe... | [
"def",
"sun_utc",
"(",
"self",
",",
"date",
",",
"latitude",
",",
"longitude",
",",
"observer_elevation",
"=",
"0",
")",
":",
"dawn",
"=",
"self",
".",
"dawn_utc",
"(",
"date",
",",
"latitude",
",",
"longitude",
",",
"observer_elevation",
"=",
"observer_el... | Calculate all the info for the sun at once.
All times are returned in the UTC timezone.
:param date: Date to calculate for.
:type date: :class:`datetime.date`
:param latitude: Latitude - Northern latitudes should be positive
:type latitude: float
:param... | [
"Calculate",
"all",
"the",
"info",
"for",
"the",
"sun",
"at",
"once",
".",
"All",
"times",
"are",
"returned",
"in",
"the",
"UTC",
"timezone",
"."
] | b0aa63fce692357cd33c2bf36c69ed5b6582440c | https://github.com/sffjunkie/astral/blob/b0aa63fce692357cd33c2bf36c69ed5b6582440c/src/astral.py#L1805-L1836 | train |
sffjunkie/astral | src/astral.py | Astral.dawn_utc | def dawn_utc(self, date, latitude, longitude, depression=0, observer_elevation=0):
"""Calculate dawn time in the UTC timezone.
:param date: Date to calculate for.
:type date: :class:`datetime.date`
:param latitude: Latitude - Northern latitudes should be positive
... | python | def dawn_utc(self, date, latitude, longitude, depression=0, observer_elevation=0):
"""Calculate dawn time in the UTC timezone.
:param date: Date to calculate for.
:type date: :class:`datetime.date`
:param latitude: Latitude - Northern latitudes should be positive
... | [
"def",
"dawn_utc",
"(",
"self",
",",
"date",
",",
"latitude",
",",
"longitude",
",",
"depression",
"=",
"0",
",",
"observer_elevation",
"=",
"0",
")",
":",
"if",
"depression",
"==",
"0",
":",
"depression",
"=",
"self",
".",
"_depression",
"depression",
"... | Calculate dawn time in the UTC timezone.
:param date: Date to calculate for.
:type date: :class:`datetime.date`
:param latitude: Latitude - Northern latitudes should be positive
:type latitude: float
:param longitude: Longitude - Eastern longitudes should be p... | [
"Calculate",
"dawn",
"time",
"in",
"the",
"UTC",
"timezone",
"."
] | b0aa63fce692357cd33c2bf36c69ed5b6582440c | https://github.com/sffjunkie/astral/blob/b0aa63fce692357cd33c2bf36c69ed5b6582440c/src/astral.py#L1838-L1872 | train |
sffjunkie/astral | src/astral.py | Astral.sunrise_utc | def sunrise_utc(self, date, latitude, longitude, observer_elevation=0):
"""Calculate sunrise time in the UTC timezone.
:param date: Date to calculate for.
:type date: :class:`datetime.date`
:param latitude: Latitude - Northern latitudes should be positive
:type la... | python | def sunrise_utc(self, date, latitude, longitude, observer_elevation=0):
"""Calculate sunrise time in the UTC timezone.
:param date: Date to calculate for.
:type date: :class:`datetime.date`
:param latitude: Latitude - Northern latitudes should be positive
:type la... | [
"def",
"sunrise_utc",
"(",
"self",
",",
"date",
",",
"latitude",
",",
"longitude",
",",
"observer_elevation",
"=",
"0",
")",
":",
"try",
":",
"return",
"self",
".",
"_calc_time",
"(",
"90",
"+",
"0.833",
",",
"SUN_RISING",
",",
"date",
",",
"latitude",
... | Calculate sunrise time in the UTC timezone.
:param date: Date to calculate for.
:type date: :class:`datetime.date`
:param latitude: Latitude - Northern latitudes should be positive
:type latitude: float
:param longitude: Longitude - Eastern longitudes should b... | [
"Calculate",
"sunrise",
"time",
"in",
"the",
"UTC",
"timezone",
"."
] | b0aa63fce692357cd33c2bf36c69ed5b6582440c | https://github.com/sffjunkie/astral/blob/b0aa63fce692357cd33c2bf36c69ed5b6582440c/src/astral.py#L1874-L1898 | train |
sffjunkie/astral | src/astral.py | Astral.solar_noon_utc | def solar_noon_utc(self, date, longitude):
"""Calculate solar noon time in the UTC timezone.
:param date: Date to calculate for.
:type date: :class:`datetime.date`
:param longitude: Longitude - Eastern longitudes should be positive
:type longitude: float
... | python | def solar_noon_utc(self, date, longitude):
"""Calculate solar noon time in the UTC timezone.
:param date: Date to calculate for.
:type date: :class:`datetime.date`
:param longitude: Longitude - Eastern longitudes should be positive
:type longitude: float
... | [
"def",
"solar_noon_utc",
"(",
"self",
",",
"date",
",",
"longitude",
")",
":",
"jc",
"=",
"self",
".",
"_jday_to_jcentury",
"(",
"self",
".",
"_julianday",
"(",
"date",
")",
")",
"eqtime",
"=",
"self",
".",
"_eq_of_time",
"(",
"jc",
")",
"timeUTC",
"="... | Calculate solar noon time in the UTC timezone.
:param date: Date to calculate for.
:type date: :class:`datetime.date`
:param longitude: Longitude - Eastern longitudes should be positive
:type longitude: float
:return: The UTC date and time at which noon occurs.
... | [
"Calculate",
"solar",
"noon",
"time",
"in",
"the",
"UTC",
"timezone",
"."
] | b0aa63fce692357cd33c2bf36c69ed5b6582440c | https://github.com/sffjunkie/astral/blob/b0aa63fce692357cd33c2bf36c69ed5b6582440c/src/astral.py#L1900-L1944 | train |
sffjunkie/astral | src/astral.py | Astral.sunset_utc | def sunset_utc(self, date, latitude, longitude, observer_elevation=0):
"""Calculate sunset time in the UTC timezone.
:param date: Date to calculate for.
:type date: :class:`datetime.date`
:param latitude: Latitude - Northern latitudes should be positive
:type lati... | python | def sunset_utc(self, date, latitude, longitude, observer_elevation=0):
"""Calculate sunset time in the UTC timezone.
:param date: Date to calculate for.
:type date: :class:`datetime.date`
:param latitude: Latitude - Northern latitudes should be positive
:type lati... | [
"def",
"sunset_utc",
"(",
"self",
",",
"date",
",",
"latitude",
",",
"longitude",
",",
"observer_elevation",
"=",
"0",
")",
":",
"try",
":",
"return",
"self",
".",
"_calc_time",
"(",
"90",
"+",
"0.833",
",",
"SUN_SETTING",
",",
"date",
",",
"latitude",
... | Calculate sunset time in the UTC timezone.
:param date: Date to calculate for.
:type date: :class:`datetime.date`
:param latitude: Latitude - Northern latitudes should be positive
:type latitude: float
:param longitude: Longitude - Eastern longitudes should be... | [
"Calculate",
"sunset",
"time",
"in",
"the",
"UTC",
"timezone",
"."
] | b0aa63fce692357cd33c2bf36c69ed5b6582440c | https://github.com/sffjunkie/astral/blob/b0aa63fce692357cd33c2bf36c69ed5b6582440c/src/astral.py#L1946-L1970 | train |
sffjunkie/astral | src/astral.py | Astral.dusk_utc | def dusk_utc(self, date, latitude, longitude, depression=0, observer_elevation=0):
"""Calculate dusk time in the UTC timezone.
:param date: Date to calculate for.
:type date: :class:`datetime.date`
:param latitude: Latitude - Northern latitudes should be positive
... | python | def dusk_utc(self, date, latitude, longitude, depression=0, observer_elevation=0):
"""Calculate dusk time in the UTC timezone.
:param date: Date to calculate for.
:type date: :class:`datetime.date`
:param latitude: Latitude - Northern latitudes should be positive
... | [
"def",
"dusk_utc",
"(",
"self",
",",
"date",
",",
"latitude",
",",
"longitude",
",",
"depression",
"=",
"0",
",",
"observer_elevation",
"=",
"0",
")",
":",
"if",
"depression",
"==",
"0",
":",
"depression",
"=",
"self",
".",
"_depression",
"depression",
"... | Calculate dusk time in the UTC timezone.
:param date: Date to calculate for.
:type date: :class:`datetime.date`
:param latitude: Latitude - Northern latitudes should be positive
:type latitude: float
:param longitude: Longitude - Eastern longitudes should be p... | [
"Calculate",
"dusk",
"time",
"in",
"the",
"UTC",
"timezone",
"."
] | b0aa63fce692357cd33c2bf36c69ed5b6582440c | https://github.com/sffjunkie/astral/blob/b0aa63fce692357cd33c2bf36c69ed5b6582440c/src/astral.py#L1972-L2006 | train |
sffjunkie/astral | src/astral.py | Astral.solar_midnight_utc | def solar_midnight_utc(self, date, longitude):
"""Calculate solar midnight time in the UTC timezone.
Note that this claculates the solar midgnight that is closest
to 00:00:00 of the specified date i.e. it may return a time that is on
the previous day.
:param date: Date to... | python | def solar_midnight_utc(self, date, longitude):
"""Calculate solar midnight time in the UTC timezone.
Note that this claculates the solar midgnight that is closest
to 00:00:00 of the specified date i.e. it may return a time that is on
the previous day.
:param date: Date to... | [
"def",
"solar_midnight_utc",
"(",
"self",
",",
"date",
",",
"longitude",
")",
":",
"julianday",
"=",
"self",
".",
"_julianday",
"(",
"date",
")",
"newt",
"=",
"self",
".",
"_jday_to_jcentury",
"(",
"julianday",
"+",
"0.5",
"+",
"-",
"longitude",
"/",
"36... | Calculate solar midnight time in the UTC timezone.
Note that this claculates the solar midgnight that is closest
to 00:00:00 of the specified date i.e. it may return a time that is on
the previous day.
:param date: Date to calculate for.
:type date: :class:`datetim... | [
"Calculate",
"solar",
"midnight",
"time",
"in",
"the",
"UTC",
"timezone",
"."
] | b0aa63fce692357cd33c2bf36c69ed5b6582440c | https://github.com/sffjunkie/astral/blob/b0aa63fce692357cd33c2bf36c69ed5b6582440c/src/astral.py#L2008-L2059 | train |
sffjunkie/astral | src/astral.py | Astral.daylight_utc | def daylight_utc(self, date, latitude, longitude, observer_elevation=0):
"""Calculate daylight start and end times in the UTC timezone.
:param date: Date to calculate for.
:type date: :class:`datetime.date`
:param latitude: Latitude - Northern latitudes should be positive... | python | def daylight_utc(self, date, latitude, longitude, observer_elevation=0):
"""Calculate daylight start and end times in the UTC timezone.
:param date: Date to calculate for.
:type date: :class:`datetime.date`
:param latitude: Latitude - Northern latitudes should be positive... | [
"def",
"daylight_utc",
"(",
"self",
",",
"date",
",",
"latitude",
",",
"longitude",
",",
"observer_elevation",
"=",
"0",
")",
":",
"start",
"=",
"self",
".",
"sunrise_utc",
"(",
"date",
",",
"latitude",
",",
"longitude",
",",
"observer_elevation",
")",
"en... | Calculate daylight start and end times in the UTC timezone.
:param date: Date to calculate for.
:type date: :class:`datetime.date`
:param latitude: Latitude - Northern latitudes should be positive
:type latitude: float
:param longitude: Longitude - Eastern lon... | [
"Calculate",
"daylight",
"start",
"and",
"end",
"times",
"in",
"the",
"UTC",
"timezone",
"."
] | b0aa63fce692357cd33c2bf36c69ed5b6582440c | https://github.com/sffjunkie/astral/blob/b0aa63fce692357cd33c2bf36c69ed5b6582440c/src/astral.py#L2061-L2080 | train |
sffjunkie/astral | src/astral.py | Astral.night_utc | def night_utc(self, date, latitude, longitude, observer_elevation=0):
"""Calculate night start and end times in the UTC timezone.
Night is calculated to be between astronomical dusk on the
date specified and astronomical dawn of the next day.
:param date: Date to calculate for.
... | python | def night_utc(self, date, latitude, longitude, observer_elevation=0):
"""Calculate night start and end times in the UTC timezone.
Night is calculated to be between astronomical dusk on the
date specified and astronomical dawn of the next day.
:param date: Date to calculate for.
... | [
"def",
"night_utc",
"(",
"self",
",",
"date",
",",
"latitude",
",",
"longitude",
",",
"observer_elevation",
"=",
"0",
")",
":",
"start",
"=",
"self",
".",
"dusk_utc",
"(",
"date",
",",
"latitude",
",",
"longitude",
",",
"18",
",",
"observer_elevation",
"... | Calculate night start and end times in the UTC timezone.
Night is calculated to be between astronomical dusk on the
date specified and astronomical dawn of the next day.
:param date: Date to calculate for.
:type date: :class:`datetime.date`
:param latitude: Latit... | [
"Calculate",
"night",
"start",
"and",
"end",
"times",
"in",
"the",
"UTC",
"timezone",
"."
] | b0aa63fce692357cd33c2bf36c69ed5b6582440c | https://github.com/sffjunkie/astral/blob/b0aa63fce692357cd33c2bf36c69ed5b6582440c/src/astral.py#L2082-L2105 | train |
sffjunkie/astral | src/astral.py | Astral.blue_hour_utc | def blue_hour_utc(self, direction, date, latitude, longitude, observer_elevation=0):
"""Returns the start and end times of the Blue Hour in the UTC timezone
when the sun is traversing in the specified direction.
This method uses the definition from PhotoPills i.e. the
blue hour is when ... | python | def blue_hour_utc(self, direction, date, latitude, longitude, observer_elevation=0):
"""Returns the start and end times of the Blue Hour in the UTC timezone
when the sun is traversing in the specified direction.
This method uses the definition from PhotoPills i.e. the
blue hour is when ... | [
"def",
"blue_hour_utc",
"(",
"self",
",",
"direction",
",",
"date",
",",
"latitude",
",",
"longitude",
",",
"observer_elevation",
"=",
"0",
")",
":",
"if",
"date",
"is",
"None",
":",
"date",
"=",
"datetime",
".",
"date",
".",
"today",
"(",
")",
"start"... | Returns the start and end times of the Blue Hour in the UTC timezone
when the sun is traversing in the specified direction.
This method uses the definition from PhotoPills i.e. the
blue hour is when the sun is between 6 and 4 degrees below the horizon.
:param direction: Determines whe... | [
"Returns",
"the",
"start",
"and",
"end",
"times",
"of",
"the",
"Blue",
"Hour",
"in",
"the",
"UTC",
"timezone",
"when",
"the",
"sun",
"is",
"traversing",
"in",
"the",
"specified",
"direction",
"."
] | b0aa63fce692357cd33c2bf36c69ed5b6582440c | https://github.com/sffjunkie/astral/blob/b0aa63fce692357cd33c2bf36c69ed5b6582440c/src/astral.py#L2179-L2211 | train |
sffjunkie/astral | src/astral.py | Astral.time_at_elevation_utc | def time_at_elevation_utc(self, elevation, direction, date, latitude, longitude, observer_elevation=0):
"""Calculate the time in the UTC timezone when the sun is at
the specified elevation on the specified date.
Note: This method uses positive elevations for those above the horizon.
:p... | python | def time_at_elevation_utc(self, elevation, direction, date, latitude, longitude, observer_elevation=0):
"""Calculate the time in the UTC timezone when the sun is at
the specified elevation on the specified date.
Note: This method uses positive elevations for those above the horizon.
:p... | [
"def",
"time_at_elevation_utc",
"(",
"self",
",",
"elevation",
",",
"direction",
",",
"date",
",",
"latitude",
",",
"longitude",
",",
"observer_elevation",
"=",
"0",
")",
":",
"if",
"elevation",
">",
"90.0",
":",
"elevation",
"=",
"180.0",
"-",
"elevation",
... | Calculate the time in the UTC timezone when the sun is at
the specified elevation on the specified date.
Note: This method uses positive elevations for those above the horizon.
:param elevation: Elevation in degrees above the horizon to calculate for.
:type elevation: float
... | [
"Calculate",
"the",
"time",
"in",
"the",
"UTC",
"timezone",
"when",
"the",
"sun",
"is",
"at",
"the",
"specified",
"elevation",
"on",
"the",
"specified",
"date",
"."
] | b0aa63fce692357cd33c2bf36c69ed5b6582440c | https://github.com/sffjunkie/astral/blob/b0aa63fce692357cd33c2bf36c69ed5b6582440c/src/astral.py#L2213-L2252 | train |
sffjunkie/astral | src/astral.py | Astral.solar_azimuth | def solar_azimuth(self, dateandtime, latitude, longitude):
"""Calculate the azimuth angle of the sun.
:param dateandtime: The date and time for which to calculate
the angle.
:type dateandtime: :class:`~datetime.datetime`
:param latitude: Latitude - Norther... | python | def solar_azimuth(self, dateandtime, latitude, longitude):
"""Calculate the azimuth angle of the sun.
:param dateandtime: The date and time for which to calculate
the angle.
:type dateandtime: :class:`~datetime.datetime`
:param latitude: Latitude - Norther... | [
"def",
"solar_azimuth",
"(",
"self",
",",
"dateandtime",
",",
"latitude",
",",
"longitude",
")",
":",
"if",
"latitude",
">",
"89.8",
":",
"latitude",
"=",
"89.8",
"if",
"latitude",
"<",
"-",
"89.8",
":",
"latitude",
"=",
"-",
"89.8",
"if",
"dateandtime",... | Calculate the azimuth angle of the sun.
:param dateandtime: The date and time for which to calculate
the angle.
:type dateandtime: :class:`~datetime.datetime`
:param latitude: Latitude - Northern latitudes should be positive
:type latitude: float
... | [
"Calculate",
"the",
"azimuth",
"angle",
"of",
"the",
"sun",
"."
] | b0aa63fce692357cd33c2bf36c69ed5b6582440c | https://github.com/sffjunkie/astral/blob/b0aa63fce692357cd33c2bf36c69ed5b6582440c/src/astral.py#L2254-L2353 | train |
sffjunkie/astral | src/astral.py | Astral.solar_zenith | def solar_zenith(self, dateandtime, latitude, longitude):
"""Calculates the solar zenith angle.
:param dateandtime: The date and time for which to calculate
the angle.
:type dateandtime: :class:`~datetime.datetime`
:param latitude: Latitude - Northern latit... | python | def solar_zenith(self, dateandtime, latitude, longitude):
"""Calculates the solar zenith angle.
:param dateandtime: The date and time for which to calculate
the angle.
:type dateandtime: :class:`~datetime.datetime`
:param latitude: Latitude - Northern latit... | [
"def",
"solar_zenith",
"(",
"self",
",",
"dateandtime",
",",
"latitude",
",",
"longitude",
")",
":",
"return",
"90.0",
"-",
"self",
".",
"solar_elevation",
"(",
"dateandtime",
",",
"latitude",
",",
"longitude",
")"
] | Calculates the solar zenith angle.
:param dateandtime: The date and time for which to calculate
the angle.
:type dateandtime: :class:`~datetime.datetime`
:param latitude: Latitude - Northern latitudes should be positive
:type latitude: float
:par... | [
"Calculates",
"the",
"solar",
"zenith",
"angle",
"."
] | b0aa63fce692357cd33c2bf36c69ed5b6582440c | https://github.com/sffjunkie/astral/blob/b0aa63fce692357cd33c2bf36c69ed5b6582440c/src/astral.py#L2482-L2500 | train |
sffjunkie/astral | src/astral.py | Astral.moon_phase | def moon_phase(self, date, rtype=int):
"""Calculates the phase of the moon on the specified date.
:param date: The date to calculate the phase for.
:type date: :class:`datetime.date`
:param rtype: The type to return either int (default) or float.
:return:
A number d... | python | def moon_phase(self, date, rtype=int):
"""Calculates the phase of the moon on the specified date.
:param date: The date to calculate the phase for.
:type date: :class:`datetime.date`
:param rtype: The type to return either int (default) or float.
:return:
A number d... | [
"def",
"moon_phase",
"(",
"self",
",",
"date",
",",
"rtype",
"=",
"int",
")",
":",
"if",
"rtype",
"!=",
"float",
"and",
"rtype",
"!=",
"int",
":",
"rtype",
"=",
"int",
"moon",
"=",
"self",
".",
"_moon_phase_asfloat",
"(",
"date",
")",
"if",
"moon",
... | Calculates the phase of the moon on the specified date.
:param date: The date to calculate the phase for.
:type date: :class:`datetime.date`
:param rtype: The type to return either int (default) or float.
:return:
A number designating the phase.
| 0 = New ... | [
"Calculates",
"the",
"phase",
"of",
"the",
"moon",
"on",
"the",
"specified",
"date",
"."
] | b0aa63fce692357cd33c2bf36c69ed5b6582440c | https://github.com/sffjunkie/astral/blob/b0aa63fce692357cd33c2bf36c69ed5b6582440c/src/astral.py#L2502-L2526 | train |
sffjunkie/astral | src/astral.py | Astral.rahukaalam_utc | def rahukaalam_utc(self, date, latitude, longitude, observer_elevation=0):
"""Calculate ruhakaalam times in the UTC timezone.
:param date: Date to calculate for.
:type date: :class:`datetime.date`
:param latitude: Latitude - Northern latitudes should be positive
:... | python | def rahukaalam_utc(self, date, latitude, longitude, observer_elevation=0):
"""Calculate ruhakaalam times in the UTC timezone.
:param date: Date to calculate for.
:type date: :class:`datetime.date`
:param latitude: Latitude - Northern latitudes should be positive
:... | [
"def",
"rahukaalam_utc",
"(",
"self",
",",
"date",
",",
"latitude",
",",
"longitude",
",",
"observer_elevation",
"=",
"0",
")",
":",
"if",
"date",
"is",
"None",
":",
"date",
"=",
"datetime",
".",
"date",
".",
"today",
"(",
")",
"sunrise",
"=",
"self",
... | Calculate ruhakaalam times in the UTC timezone.
:param date: Date to calculate for.
:type date: :class:`datetime.date`
:param latitude: Latitude - Northern latitudes should be positive
:type latitude: float
:param longitude: Longitude - Eastern longitudes shou... | [
"Calculate",
"ruhakaalam",
"times",
"in",
"the",
"UTC",
"timezone",
"."
] | b0aa63fce692357cd33c2bf36c69ed5b6582440c | https://github.com/sffjunkie/astral/blob/b0aa63fce692357cd33c2bf36c69ed5b6582440c/src/astral.py#L2528-L2561 | train |
sffjunkie/astral | src/astral.py | Astral._depression_adjustment | def _depression_adjustment(self, elevation):
"""Calculate the extra degrees of depression due to the increase in elevation.
:param elevation: Elevation above the earth in metres
:type elevation: float
"""
if elevation <= 0:
return 0
r = 6356900 # radius of... | python | def _depression_adjustment(self, elevation):
"""Calculate the extra degrees of depression due to the increase in elevation.
:param elevation: Elevation above the earth in metres
:type elevation: float
"""
if elevation <= 0:
return 0
r = 6356900 # radius of... | [
"def",
"_depression_adjustment",
"(",
"self",
",",
"elevation",
")",
":",
"if",
"elevation",
"<=",
"0",
":",
"return",
"0",
"r",
"=",
"6356900",
"# radius of the earth",
"a1",
"=",
"r",
"h1",
"=",
"r",
"+",
"elevation",
"theta1",
"=",
"acos",
"(",
"a1",
... | Calculate the extra degrees of depression due to the increase in elevation.
:param elevation: Elevation above the earth in metres
:type elevation: float | [
"Calculate",
"the",
"extra",
"degrees",
"of",
"depression",
"due",
"to",
"the",
"increase",
"in",
"elevation",
"."
] | b0aa63fce692357cd33c2bf36c69ed5b6582440c | https://github.com/sffjunkie/astral/blob/b0aa63fce692357cd33c2bf36c69ed5b6582440c/src/astral.py#L2807-L2827 | train |
joowani/kq | example/worker-cli.py | callback | def callback(status, message, job, result, exception, stacktrace):
"""Example callback function.
:param status: Job status. Possible values are "invalid" (job could not be
deserialized or was malformed), "failure" (job raised an exception),
"timeout" (job timed out), or "success" (job finished ... | python | def callback(status, message, job, result, exception, stacktrace):
"""Example callback function.
:param status: Job status. Possible values are "invalid" (job could not be
deserialized or was malformed), "failure" (job raised an exception),
"timeout" (job timed out), or "success" (job finished ... | [
"def",
"callback",
"(",
"status",
",",
"message",
",",
"job",
",",
"result",
",",
"exception",
",",
"stacktrace",
")",
":",
"assert",
"status",
"in",
"[",
"'invalid'",
",",
"'success'",
",",
"'timeout'",
",",
"'failure'",
"]",
"assert",
"isinstance",
"(",
... | Example callback function.
:param status: Job status. Possible values are "invalid" (job could not be
deserialized or was malformed), "failure" (job raised an exception),
"timeout" (job timed out), or "success" (job finished successfully and
returned a result).
:type status: str
:pa... | [
"Example",
"callback",
"function",
"."
] | f5ff3f1828cc1d9de668f82b2d18a98026ce4281 | https://github.com/joowani/kq/blob/f5ff3f1828cc1d9de668f82b2d18a98026ce4281/example/worker-cli.py#L19-L62 | train |
joowani/kq | kq/worker.py | Worker._execute_callback | def _execute_callback(self, status, message, job, res, err, stacktrace):
"""Execute the callback.
:param status: Job status. Possible values are "invalid" (job could not
be deserialized or was malformed), "failure" (job raised an error),
"timeout" (job timed out), or "success" (... | python | def _execute_callback(self, status, message, job, res, err, stacktrace):
"""Execute the callback.
:param status: Job status. Possible values are "invalid" (job could not
be deserialized or was malformed), "failure" (job raised an error),
"timeout" (job timed out), or "success" (... | [
"def",
"_execute_callback",
"(",
"self",
",",
"status",
",",
"message",
",",
"job",
",",
"res",
",",
"err",
",",
"stacktrace",
")",
":",
"if",
"self",
".",
"_callback",
"is",
"not",
"None",
":",
"try",
":",
"self",
".",
"_logger",
".",
"info",
"(",
... | Execute the callback.
:param status: Job status. Possible values are "invalid" (job could not
be deserialized or was malformed), "failure" (job raised an error),
"timeout" (job timed out), or "success" (job finished successfully
and returned a result).
:type status: ... | [
"Execute",
"the",
"callback",
"."
] | f5ff3f1828cc1d9de668f82b2d18a98026ce4281 | https://github.com/joowani/kq/blob/f5ff3f1828cc1d9de668f82b2d18a98026ce4281/kq/worker.py#L106-L131 | train |
joowani/kq | kq/worker.py | Worker._process_message | def _process_message(self, msg):
"""De-serialize the message and execute the job.
:param msg: Kafka message.
:type msg: :doc:`kq.Message <message>`
"""
self._logger.info(
'Processing Message(topic={}, partition={}, offset={}) ...'
.format(msg.topic, msg.p... | python | def _process_message(self, msg):
"""De-serialize the message and execute the job.
:param msg: Kafka message.
:type msg: :doc:`kq.Message <message>`
"""
self._logger.info(
'Processing Message(topic={}, partition={}, offset={}) ...'
.format(msg.topic, msg.p... | [
"def",
"_process_message",
"(",
"self",
",",
"msg",
")",
":",
"self",
".",
"_logger",
".",
"info",
"(",
"'Processing Message(topic={}, partition={}, offset={}) ...'",
".",
"format",
"(",
"msg",
".",
"topic",
",",
"msg",
".",
"partition",
",",
"msg",
".",
"offs... | De-serialize the message and execute the job.
:param msg: Kafka message.
:type msg: :doc:`kq.Message <message>` | [
"De",
"-",
"serialize",
"the",
"message",
"and",
"execute",
"the",
"job",
"."
] | f5ff3f1828cc1d9de668f82b2d18a98026ce4281 | https://github.com/joowani/kq/blob/f5ff3f1828cc1d9de668f82b2d18a98026ce4281/kq/worker.py#L133-L173 | train |
joowani/kq | kq/worker.py | Worker.start | def start(self, max_messages=math.inf, commit_offsets=True):
"""Start processing Kafka messages and executing jobs.
:param max_messages: Maximum number of Kafka messages to process before
stopping. If not set, worker runs until interrupted.
:type max_messages: int
:param com... | python | def start(self, max_messages=math.inf, commit_offsets=True):
"""Start processing Kafka messages and executing jobs.
:param max_messages: Maximum number of Kafka messages to process before
stopping. If not set, worker runs until interrupted.
:type max_messages: int
:param com... | [
"def",
"start",
"(",
"self",
",",
"max_messages",
"=",
"math",
".",
"inf",
",",
"commit_offsets",
"=",
"True",
")",
":",
"self",
".",
"_logger",
".",
"info",
"(",
"'Starting {} ...'",
".",
"format",
"(",
"self",
")",
")",
"self",
".",
"_consumer",
".",... | Start processing Kafka messages and executing jobs.
:param max_messages: Maximum number of Kafka messages to process before
stopping. If not set, worker runs until interrupted.
:type max_messages: int
:param commit_offsets: If set to True, consumer offsets are committed
... | [
"Start",
"processing",
"Kafka",
"messages",
"and",
"executing",
"jobs",
"."
] | f5ff3f1828cc1d9de668f82b2d18a98026ce4281 | https://github.com/joowani/kq/blob/f5ff3f1828cc1d9de668f82b2d18a98026ce4281/kq/worker.py#L229-L264 | train |
joowani/kq | kq/utils.py | get_call_repr | def get_call_repr(func, *args, **kwargs):
"""Return the string representation of the function call.
:param func: A callable (e.g. function, method).
:type func: callable
:param args: Positional arguments for the callable.
:param kwargs: Keyword arguments for the callable.
:return: String repres... | python | def get_call_repr(func, *args, **kwargs):
"""Return the string representation of the function call.
:param func: A callable (e.g. function, method).
:type func: callable
:param args: Positional arguments for the callable.
:param kwargs: Keyword arguments for the callable.
:return: String repres... | [
"def",
"get_call_repr",
"(",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Functions, builtins and methods",
"if",
"ismethod",
"(",
"func",
")",
"or",
"isfunction",
"(",
"func",
")",
"or",
"isbuiltin",
"(",
"func",
")",
":",
"func_repr",
... | Return the string representation of the function call.
:param func: A callable (e.g. function, method).
:type func: callable
:param args: Positional arguments for the callable.
:param kwargs: Keyword arguments for the callable.
:return: String representation of the function call.
:rtype: str | [
"Return",
"the",
"string",
"representation",
"of",
"the",
"function",
"call",
"."
] | f5ff3f1828cc1d9de668f82b2d18a98026ce4281 | https://github.com/joowani/kq/blob/f5ff3f1828cc1d9de668f82b2d18a98026ce4281/kq/utils.py#L5-L26 | train |
joowani/kq | kq/queue.py | Queue.using | def using(self, timeout=None, key=None, partition=None):
"""Set enqueue specifications such as timeout, key and partition.
:param timeout: Job timeout threshold in seconds. If not set, default
timeout (specified during queue initialization) is used instead.
:type timeout: int | floa... | python | def using(self, timeout=None, key=None, partition=None):
"""Set enqueue specifications such as timeout, key and partition.
:param timeout: Job timeout threshold in seconds. If not set, default
timeout (specified during queue initialization) is used instead.
:type timeout: int | floa... | [
"def",
"using",
"(",
"self",
",",
"timeout",
"=",
"None",
",",
"key",
"=",
"None",
",",
"partition",
"=",
"None",
")",
":",
"return",
"EnqueueSpec",
"(",
"topic",
"=",
"self",
".",
"_topic",
",",
"producer",
"=",
"self",
".",
"_producer",
",",
"seria... | Set enqueue specifications such as timeout, key and partition.
:param timeout: Job timeout threshold in seconds. If not set, default
timeout (specified during queue initialization) is used instead.
:type timeout: int | float
:param key: Kafka message key. Jobs with the same keys are... | [
"Set",
"enqueue",
"specifications",
"such",
"as",
"timeout",
"key",
"and",
"partition",
"."
] | f5ff3f1828cc1d9de668f82b2d18a98026ce4281 | https://github.com/joowani/kq/blob/f5ff3f1828cc1d9de668f82b2d18a98026ce4281/kq/queue.py#L207-L263 | train |
pklaus/brother_ql | brother_ql/backends/helpers.py | send | def send(instructions, printer_identifier=None, backend_identifier=None, blocking=True):
"""
Send instruction bytes to a printer.
:param bytes instructions: The instructions to be sent to the printer.
:param str printer_identifier: Identifier for the printer.
:param str backend_identifier: Can enfo... | python | def send(instructions, printer_identifier=None, backend_identifier=None, blocking=True):
"""
Send instruction bytes to a printer.
:param bytes instructions: The instructions to be sent to the printer.
:param str printer_identifier: Identifier for the printer.
:param str backend_identifier: Can enfo... | [
"def",
"send",
"(",
"instructions",
",",
"printer_identifier",
"=",
"None",
",",
"backend_identifier",
"=",
"None",
",",
"blocking",
"=",
"True",
")",
":",
"status",
"=",
"{",
"'instructions_sent'",
":",
"True",
",",
"# The instructions were sent to the printer.",
... | Send instruction bytes to a printer.
:param bytes instructions: The instructions to be sent to the printer.
:param str printer_identifier: Identifier for the printer.
:param str backend_identifier: Can enforce the use of a specific backend.
:param bool blocking: Indicates whether the function call shou... | [
"Send",
"instruction",
"bytes",
"to",
"a",
"printer",
"."
] | b551b1fc944873f3a2ead7032d144dfd81011e79 | https://github.com/pklaus/brother_ql/blob/b551b1fc944873f3a2ead7032d144dfd81011e79/brother_ql/backends/helpers.py#L26-L103 | train |
pklaus/brother_ql | brother_ql/reader.py | merge_specific_instructions | def merge_specific_instructions(chunks, join_preamble=True, join_raster=True):
"""
Process a list of instructions by merging subsequent instuctions with
identical opcodes into "large instructions".
"""
new_instructions = []
last_opcode = None
instruction_buffer = b''
for instruction in c... | python | def merge_specific_instructions(chunks, join_preamble=True, join_raster=True):
"""
Process a list of instructions by merging subsequent instuctions with
identical opcodes into "large instructions".
"""
new_instructions = []
last_opcode = None
instruction_buffer = b''
for instruction in c... | [
"def",
"merge_specific_instructions",
"(",
"chunks",
",",
"join_preamble",
"=",
"True",
",",
"join_raster",
"=",
"True",
")",
":",
"new_instructions",
"=",
"[",
"]",
"last_opcode",
"=",
"None",
"instruction_buffer",
"=",
"b''",
"for",
"instruction",
"in",
"chunk... | Process a list of instructions by merging subsequent instuctions with
identical opcodes into "large instructions". | [
"Process",
"a",
"list",
"of",
"instructions",
"by",
"merging",
"subsequent",
"instuctions",
"with",
"identical",
"opcodes",
"into",
"large",
"instructions",
"."
] | b551b1fc944873f3a2ead7032d144dfd81011e79 | https://github.com/pklaus/brother_ql/blob/b551b1fc944873f3a2ead7032d144dfd81011e79/brother_ql/reader.py#L209-L230 | train |
pklaus/brother_ql | brother_ql/cli.py | cli | def cli(ctx, *args, **kwargs):
""" Command line interface for the brother_ql Python package. """
backend = kwargs.get('backend', None)
model = kwargs.get('model', None)
printer = kwargs.get('printer', None)
debug = kwargs.get('debug')
# Store the general CLI options in the context meta diction... | python | def cli(ctx, *args, **kwargs):
""" Command line interface for the brother_ql Python package. """
backend = kwargs.get('backend', None)
model = kwargs.get('model', None)
printer = kwargs.get('printer', None)
debug = kwargs.get('debug')
# Store the general CLI options in the context meta diction... | [
"def",
"cli",
"(",
"ctx",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"backend",
"=",
"kwargs",
".",
"get",
"(",
"'backend'",
",",
"None",
")",
"model",
"=",
"kwargs",
".",
"get",
"(",
"'model'",
",",
"None",
")",
"printer",
"=",
"kwargs... | Command line interface for the brother_ql Python package. | [
"Command",
"line",
"interface",
"for",
"the",
"brother_ql",
"Python",
"package",
"."
] | b551b1fc944873f3a2ead7032d144dfd81011e79 | https://github.com/pklaus/brother_ql/blob/b551b1fc944873f3a2ead7032d144dfd81011e79/brother_ql/cli.py#L26-L40 | train |
pklaus/brother_ql | brother_ql/cli.py | env | def env(ctx, *args, **kwargs):
"""
print debug info about running environment
"""
import sys, platform, os, shutil
from pkg_resources import get_distribution, working_set
print("\n##################\n")
print("Information about the running environment of brother_ql.")
print("(Please prov... | python | def env(ctx, *args, **kwargs):
"""
print debug info about running environment
"""
import sys, platform, os, shutil
from pkg_resources import get_distribution, working_set
print("\n##################\n")
print("Information about the running environment of brother_ql.")
print("(Please prov... | [
"def",
"env",
"(",
"ctx",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"sys",
",",
"platform",
",",
"os",
",",
"shutil",
"from",
"pkg_resources",
"import",
"get_distribution",
",",
"working_set",
"print",
"(",
"\"\\n##################\\n\""... | print debug info about running environment | [
"print",
"debug",
"info",
"about",
"running",
"environment"
] | b551b1fc944873f3a2ead7032d144dfd81011e79 | https://github.com/pklaus/brother_ql/blob/b551b1fc944873f3a2ead7032d144dfd81011e79/brother_ql/cli.py#L81-L120 | train |
pklaus/brother_ql | brother_ql/cli.py | print_cmd | def print_cmd(ctx, *args, **kwargs):
""" Print a label of the provided IMAGE. """
backend = ctx.meta.get('BACKEND', 'pyusb')
model = ctx.meta.get('MODEL')
printer = ctx.meta.get('PRINTER')
from brother_ql.conversion import convert
from brother_ql.backends.helpers import send
from brother_ql.... | python | def print_cmd(ctx, *args, **kwargs):
""" Print a label of the provided IMAGE. """
backend = ctx.meta.get('BACKEND', 'pyusb')
model = ctx.meta.get('MODEL')
printer = ctx.meta.get('PRINTER')
from brother_ql.conversion import convert
from brother_ql.backends.helpers import send
from brother_ql.... | [
"def",
"print_cmd",
"(",
"ctx",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"backend",
"=",
"ctx",
".",
"meta",
".",
"get",
"(",
"'BACKEND'",
",",
"'pyusb'",
")",
"model",
"=",
"ctx",
".",
"meta",
".",
"get",
"(",
"'MODEL'",
")",
"printe... | Print a label of the provided IMAGE. | [
"Print",
"a",
"label",
"of",
"the",
"provided",
"IMAGE",
"."
] | b551b1fc944873f3a2ead7032d144dfd81011e79 | https://github.com/pklaus/brother_ql/blob/b551b1fc944873f3a2ead7032d144dfd81011e79/brother_ql/cli.py#L134-L147 | train |
pklaus/brother_ql | brother_ql/backends/pyusb.py | list_available_devices | def list_available_devices():
"""
List all available devices for the respective backend
returns: devices: a list of dictionaries with the keys 'identifier' and 'instance': \
[ {'identifier': 'usb://0x04f9:0x2015/C5Z315686', 'instance': pyusb.core.Device()}, ]
The 'identifier' is of the form... | python | def list_available_devices():
"""
List all available devices for the respective backend
returns: devices: a list of dictionaries with the keys 'identifier' and 'instance': \
[ {'identifier': 'usb://0x04f9:0x2015/C5Z315686', 'instance': pyusb.core.Device()}, ]
The 'identifier' is of the form... | [
"def",
"list_available_devices",
"(",
")",
":",
"class",
"find_class",
"(",
"object",
")",
":",
"def",
"__init__",
"(",
"self",
",",
"class_",
")",
":",
"self",
".",
"_class",
"=",
"class_",
"def",
"__call__",
"(",
"self",
",",
"device",
")",
":",
"# f... | List all available devices for the respective backend
returns: devices: a list of dictionaries with the keys 'identifier' and 'instance': \
[ {'identifier': 'usb://0x04f9:0x2015/C5Z315686', 'instance': pyusb.core.Device()}, ]
The 'identifier' is of the format idVendor:idProduct_iSerialNumber. | [
"List",
"all",
"available",
"devices",
"for",
"the",
"respective",
"backend"
] | b551b1fc944873f3a2ead7032d144dfd81011e79 | https://github.com/pklaus/brother_ql/blob/b551b1fc944873f3a2ead7032d144dfd81011e79/brother_ql/backends/pyusb.py#L21-L55 | train |
pklaus/brother_ql | brother_ql/devicedependent.py | _populate_label_legacy_structures | def _populate_label_legacy_structures():
"""
We contain this code inside a function so that the imports
we do in here are not visible at the module level.
"""
global DIE_CUT_LABEL, ENDLESS_LABEL, ROUND_DIE_CUT_LABEL
global label_sizes, label_type_specs
from brother_ql.labels import FormFact... | python | def _populate_label_legacy_structures():
"""
We contain this code inside a function so that the imports
we do in here are not visible at the module level.
"""
global DIE_CUT_LABEL, ENDLESS_LABEL, ROUND_DIE_CUT_LABEL
global label_sizes, label_type_specs
from brother_ql.labels import FormFact... | [
"def",
"_populate_label_legacy_structures",
"(",
")",
":",
"global",
"DIE_CUT_LABEL",
",",
"ENDLESS_LABEL",
",",
"ROUND_DIE_CUT_LABEL",
"global",
"label_sizes",
",",
"label_type_specs",
"from",
"brother_ql",
".",
"labels",
"import",
"FormFactor",
"DIE_CUT_LABEL",
"=",
"... | We contain this code inside a function so that the imports
we do in here are not visible at the module level. | [
"We",
"contain",
"this",
"code",
"inside",
"a",
"function",
"so",
"that",
"the",
"imports",
"we",
"do",
"in",
"here",
"are",
"not",
"visible",
"at",
"the",
"module",
"level",
"."
] | b551b1fc944873f3a2ead7032d144dfd81011e79 | https://github.com/pklaus/brother_ql/blob/b551b1fc944873f3a2ead7032d144dfd81011e79/brother_ql/devicedependent.py#L59-L86 | train |
pklaus/brother_ql | brother_ql/backends/__init__.py | guess_backend | def guess_backend(identifier):
""" guess the backend from a given identifier string for the device """
if identifier.startswith('usb://') or identifier.startswith('0x'):
return 'pyusb'
elif identifier.startswith('file://') or identifier.startswith('/dev/usb/') or identifier.startswith('lp'):
... | python | def guess_backend(identifier):
""" guess the backend from a given identifier string for the device """
if identifier.startswith('usb://') or identifier.startswith('0x'):
return 'pyusb'
elif identifier.startswith('file://') or identifier.startswith('/dev/usb/') or identifier.startswith('lp'):
... | [
"def",
"guess_backend",
"(",
"identifier",
")",
":",
"if",
"identifier",
".",
"startswith",
"(",
"'usb://'",
")",
"or",
"identifier",
".",
"startswith",
"(",
"'0x'",
")",
":",
"return",
"'pyusb'",
"elif",
"identifier",
".",
"startswith",
"(",
"'file://'",
")... | guess the backend from a given identifier string for the device | [
"guess",
"the",
"backend",
"from",
"a",
"given",
"identifier",
"string",
"for",
"the",
"device"
] | b551b1fc944873f3a2ead7032d144dfd81011e79 | https://github.com/pklaus/brother_ql/blob/b551b1fc944873f3a2ead7032d144dfd81011e79/brother_ql/backends/__init__.py#L11-L20 | train |
gfairchild/yelpapi | yelpapi/yelpapi.py | YelpAPI.featured_event_query | def featured_event_query(self, **kwargs):
"""
Query the Yelp Featured Event API.
documentation: https://www.yelp.com/developers/documentation/v3/featured_event
required parameters:
* one of either:
* location - text specifying a location ... | python | def featured_event_query(self, **kwargs):
"""
Query the Yelp Featured Event API.
documentation: https://www.yelp.com/developers/documentation/v3/featured_event
required parameters:
* one of either:
* location - text specifying a location ... | [
"def",
"featured_event_query",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"kwargs",
".",
"get",
"(",
"'location'",
")",
"and",
"(",
"not",
"kwargs",
".",
"get",
"(",
"'latitude'",
")",
"or",
"not",
"kwargs",
".",
"get",
"(",
"'longi... | Query the Yelp Featured Event API.
documentation: https://www.yelp.com/developers/documentation/v3/featured_event
required parameters:
* one of either:
* location - text specifying a location to search for
* latitude and longitude | [
"Query",
"the",
"Yelp",
"Featured",
"Event",
"API",
"."
] | 51e35fbe44ac131630ce5e2f1b6f53711846e2a7 | https://github.com/gfairchild/yelpapi/blob/51e35fbe44ac131630ce5e2f1b6f53711846e2a7/yelpapi/yelpapi.py#L174-L189 | train |
gfairchild/yelpapi | yelpapi/yelpapi.py | YelpAPI._get_clean_parameters | def _get_clean_parameters(kwargs):
"""
Clean the parameters by filtering out any parameters that have a None value.
"""
return dict((k, v) for k, v in kwargs.items() if v is not None) | python | def _get_clean_parameters(kwargs):
"""
Clean the parameters by filtering out any parameters that have a None value.
"""
return dict((k, v) for k, v in kwargs.items() if v is not None) | [
"def",
"_get_clean_parameters",
"(",
"kwargs",
")",
":",
"return",
"dict",
"(",
"(",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"kwargs",
".",
"items",
"(",
")",
"if",
"v",
"is",
"not",
"None",
")"
] | Clean the parameters by filtering out any parameters that have a None value. | [
"Clean",
"the",
"parameters",
"by",
"filtering",
"out",
"any",
"parameters",
"that",
"have",
"a",
"None",
"value",
"."
] | 51e35fbe44ac131630ce5e2f1b6f53711846e2a7 | https://github.com/gfairchild/yelpapi/blob/51e35fbe44ac131630ce5e2f1b6f53711846e2a7/yelpapi/yelpapi.py#L258-L262 | train |
gfairchild/yelpapi | yelpapi/yelpapi.py | YelpAPI._query | def _query(self, url, **kwargs):
"""
All query methods have the same logic, so don't repeat it! Query the URL, parse the response as JSON,
and check for errors. If all goes well, return the parsed JSON.
"""
parameters = YelpAPI._get_clean_parameters(kwargs)
respon... | python | def _query(self, url, **kwargs):
"""
All query methods have the same logic, so don't repeat it! Query the URL, parse the response as JSON,
and check for errors. If all goes well, return the parsed JSON.
"""
parameters = YelpAPI._get_clean_parameters(kwargs)
respon... | [
"def",
"_query",
"(",
"self",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"parameters",
"=",
"YelpAPI",
".",
"_get_clean_parameters",
"(",
"kwargs",
")",
"response",
"=",
"self",
".",
"_yelp_session",
".",
"get",
"(",
"url",
",",
"headers",
"=",
"se... | All query methods have the same logic, so don't repeat it! Query the URL, parse the response as JSON,
and check for errors. If all goes well, return the parsed JSON. | [
"All",
"query",
"methods",
"have",
"the",
"same",
"logic",
"so",
"don",
"t",
"repeat",
"it!",
"Query",
"the",
"URL",
"parse",
"the",
"response",
"as",
"JSON",
"and",
"check",
"for",
"errors",
".",
"If",
"all",
"goes",
"well",
"return",
"the",
"parsed",
... | 51e35fbe44ac131630ce5e2f1b6f53711846e2a7 | https://github.com/gfairchild/yelpapi/blob/51e35fbe44ac131630ce5e2f1b6f53711846e2a7/yelpapi/yelpapi.py#L264-L286 | train |
samgiles/slumber | slumber/utils.py | url_join | def url_join(base, *args):
"""
Helper function to join an arbitrary number of url segments together.
"""
scheme, netloc, path, query, fragment = urlsplit(base)
path = path if len(path) else "/"
path = posixpath.join(path, *[('%s' % x) for x in args])
return urlunsplit([scheme, netloc, path, ... | python | def url_join(base, *args):
"""
Helper function to join an arbitrary number of url segments together.
"""
scheme, netloc, path, query, fragment = urlsplit(base)
path = path if len(path) else "/"
path = posixpath.join(path, *[('%s' % x) for x in args])
return urlunsplit([scheme, netloc, path, ... | [
"def",
"url_join",
"(",
"base",
",",
"*",
"args",
")",
":",
"scheme",
",",
"netloc",
",",
"path",
",",
"query",
",",
"fragment",
"=",
"urlsplit",
"(",
"base",
")",
"path",
"=",
"path",
"if",
"len",
"(",
"path",
")",
"else",
"\"/\"",
"path",
"=",
... | Helper function to join an arbitrary number of url segments together. | [
"Helper",
"function",
"to",
"join",
"an",
"arbitrary",
"number",
"of",
"url",
"segments",
"together",
"."
] | af0f9ef7bd8df8bde6b47088630786c737869bce | https://github.com/samgiles/slumber/blob/af0f9ef7bd8df8bde6b47088630786c737869bce/slumber/utils.py#L9-L16 | train |
20c/vaping | vaping/plugins/vodka.py | probe_to_graphsrv | def probe_to_graphsrv(probe):
"""
takes a probe instance and generates
a graphsrv data group for it using the
probe's config
"""
config = probe.config
# manual group set up via `group` config key
if "group" in config:
source, group = config["group"].split(".")
group_fi... | python | def probe_to_graphsrv(probe):
"""
takes a probe instance and generates
a graphsrv data group for it using the
probe's config
"""
config = probe.config
# manual group set up via `group` config key
if "group" in config:
source, group = config["group"].split(".")
group_fi... | [
"def",
"probe_to_graphsrv",
"(",
"probe",
")",
":",
"config",
"=",
"probe",
".",
"config",
"# manual group set up via `group` config key",
"if",
"\"group\"",
"in",
"config",
":",
"source",
",",
"group",
"=",
"config",
"[",
"\"group\"",
"]",
".",
"split",
"(",
... | takes a probe instance and generates
a graphsrv data group for it using the
probe's config | [
"takes",
"a",
"probe",
"instance",
"and",
"generates",
"a",
"graphsrv",
"data",
"group",
"for",
"it",
"using",
"the",
"probe",
"s",
"config"
] | c51f00586c99edb3d51e4abdbdfe3174755533ee | https://github.com/20c/vaping/blob/c51f00586c99edb3d51e4abdbdfe3174755533ee/vaping/plugins/vodka.py#L20-L49 | train |
20c/vaping | vaping/plugins/__init__.py | PluginBase.new_message | def new_message(self):
"""
creates a new message, setting `type`, `source`, `ts`, `data`
- `data` is initialized to an empty array
"""
msg = {}
msg['data'] = []
msg['type'] = self.plugin_type
msg['source'] = self.name
msg['ts'] = (datetime.datetime... | python | def new_message(self):
"""
creates a new message, setting `type`, `source`, `ts`, `data`
- `data` is initialized to an empty array
"""
msg = {}
msg['data'] = []
msg['type'] = self.plugin_type
msg['source'] = self.name
msg['ts'] = (datetime.datetime... | [
"def",
"new_message",
"(",
"self",
")",
":",
"msg",
"=",
"{",
"}",
"msg",
"[",
"'data'",
"]",
"=",
"[",
"]",
"msg",
"[",
"'type'",
"]",
"=",
"self",
".",
"plugin_type",
"msg",
"[",
"'source'",
"]",
"=",
"self",
".",
"name",
"msg",
"[",
"'ts'",
... | creates a new message, setting `type`, `source`, `ts`, `data`
- `data` is initialized to an empty array | [
"creates",
"a",
"new",
"message",
"setting",
"type",
"source",
"ts",
"data",
"-",
"data",
"is",
"initialized",
"to",
"an",
"empty",
"array"
] | c51f00586c99edb3d51e4abdbdfe3174755533ee | https://github.com/20c/vaping/blob/c51f00586c99edb3d51e4abdbdfe3174755533ee/vaping/plugins/__init__.py#L51-L61 | train |
20c/vaping | vaping/plugins/__init__.py | PluginBase.popen | def popen(self, args, **kwargs):
"""
creates a subprocess with passed args
"""
self.log.debug("popen %s", ' '.join(args))
return vaping.io.subprocess.Popen(args, **kwargs) | python | def popen(self, args, **kwargs):
"""
creates a subprocess with passed args
"""
self.log.debug("popen %s", ' '.join(args))
return vaping.io.subprocess.Popen(args, **kwargs) | [
"def",
"popen",
"(",
"self",
",",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"popen %s\"",
",",
"' '",
".",
"join",
"(",
"args",
")",
")",
"return",
"vaping",
".",
"io",
".",
"subprocess",
".",
"Popen",
"(... | creates a subprocess with passed args | [
"creates",
"a",
"subprocess",
"with",
"passed",
"args"
] | c51f00586c99edb3d51e4abdbdfe3174755533ee | https://github.com/20c/vaping/blob/c51f00586c99edb3d51e4abdbdfe3174755533ee/vaping/plugins/__init__.py#L63-L68 | train |
20c/vaping | vaping/plugins/__init__.py | ProbeBase.queue_emission | def queue_emission(self, msg):
"""
queue an emission of a message for all output plugins
"""
if not msg:
return
for _emitter in self._emit:
if not hasattr(_emitter, 'emit'):
continue
def emit(emitter=_emitter):
s... | python | def queue_emission(self, msg):
"""
queue an emission of a message for all output plugins
"""
if not msg:
return
for _emitter in self._emit:
if not hasattr(_emitter, 'emit'):
continue
def emit(emitter=_emitter):
s... | [
"def",
"queue_emission",
"(",
"self",
",",
"msg",
")",
":",
"if",
"not",
"msg",
":",
"return",
"for",
"_emitter",
"in",
"self",
".",
"_emit",
":",
"if",
"not",
"hasattr",
"(",
"_emitter",
",",
"'emit'",
")",
":",
"continue",
"def",
"emit",
"(",
"emit... | queue an emission of a message for all output plugins | [
"queue",
"an",
"emission",
"of",
"a",
"message",
"for",
"all",
"output",
"plugins"
] | c51f00586c99edb3d51e4abdbdfe3174755533ee | https://github.com/20c/vaping/blob/c51f00586c99edb3d51e4abdbdfe3174755533ee/vaping/plugins/__init__.py#L131-L145 | train |
20c/vaping | vaping/plugins/__init__.py | ProbeBase.send_emission | def send_emission(self):
"""
emit and remove the first emission in the queue
"""
if self._emit_queue.empty():
return
emit = self._emit_queue.get()
emit() | python | def send_emission(self):
"""
emit and remove the first emission in the queue
"""
if self._emit_queue.empty():
return
emit = self._emit_queue.get()
emit() | [
"def",
"send_emission",
"(",
"self",
")",
":",
"if",
"self",
".",
"_emit_queue",
".",
"empty",
"(",
")",
":",
"return",
"emit",
"=",
"self",
".",
"_emit_queue",
".",
"get",
"(",
")",
"emit",
"(",
")"
] | emit and remove the first emission in the queue | [
"emit",
"and",
"remove",
"the",
"first",
"emission",
"in",
"the",
"queue"
] | c51f00586c99edb3d51e4abdbdfe3174755533ee | https://github.com/20c/vaping/blob/c51f00586c99edb3d51e4abdbdfe3174755533ee/vaping/plugins/__init__.py#L147-L154 | train |
20c/vaping | vaping/plugins/__init__.py | FileProbe.validate_file_handler | def validate_file_handler(self):
"""
Here we validate that our filehandler is pointing
to an existing file.
If it doesnt, because file has been deleted, we close
the filehander and try to reopen
"""
if self.fh.closed:
try:
self.fh = op... | python | def validate_file_handler(self):
"""
Here we validate that our filehandler is pointing
to an existing file.
If it doesnt, because file has been deleted, we close
the filehander and try to reopen
"""
if self.fh.closed:
try:
self.fh = op... | [
"def",
"validate_file_handler",
"(",
"self",
")",
":",
"if",
"self",
".",
"fh",
".",
"closed",
":",
"try",
":",
"self",
".",
"fh",
"=",
"open",
"(",
"self",
".",
"path",
",",
"\"r\"",
")",
"self",
".",
"fh",
".",
"seek",
"(",
"0",
",",
"2",
")"... | Here we validate that our filehandler is pointing
to an existing file.
If it doesnt, because file has been deleted, we close
the filehander and try to reopen | [
"Here",
"we",
"validate",
"that",
"our",
"filehandler",
"is",
"pointing",
"to",
"an",
"existing",
"file",
"."
] | c51f00586c99edb3d51e4abdbdfe3174755533ee | https://github.com/20c/vaping/blob/c51f00586c99edb3d51e4abdbdfe3174755533ee/vaping/plugins/__init__.py#L245-L273 | train |
20c/vaping | vaping/plugins/__init__.py | FileProbe.probe | def probe(self):
"""
Probe the file for new lines
"""
# make sure the filehandler is still valid
# (e.g. file stat hasnt changed, file exists etc.)
if not self.validate_file_handler():
return []
messages = []
# read any new lines and push th... | python | def probe(self):
"""
Probe the file for new lines
"""
# make sure the filehandler is still valid
# (e.g. file stat hasnt changed, file exists etc.)
if not self.validate_file_handler():
return []
messages = []
# read any new lines and push th... | [
"def",
"probe",
"(",
"self",
")",
":",
"# make sure the filehandler is still valid",
"# (e.g. file stat hasnt changed, file exists etc.)",
"if",
"not",
"self",
".",
"validate_file_handler",
"(",
")",
":",
"return",
"[",
"]",
"messages",
"=",
"[",
"]",
"# read any new li... | Probe the file for new lines | [
"Probe",
"the",
"file",
"for",
"new",
"lines"
] | c51f00586c99edb3d51e4abdbdfe3174755533ee | https://github.com/20c/vaping/blob/c51f00586c99edb3d51e4abdbdfe3174755533ee/vaping/plugins/__init__.py#L276-L310 | train |
20c/vaping | vaping/plugins/__init__.py | TimeSeriesDB.filename_formatters | def filename_formatters(self, data, row):
"""
Returns a dict containing the various filename formatter values
Values are gotten from the vaping data message as well as the
currently processed row in the message
- `data`: vaping message
- `row`: vaping message data row
... | python | def filename_formatters(self, data, row):
"""
Returns a dict containing the various filename formatter values
Values are gotten from the vaping data message as well as the
currently processed row in the message
- `data`: vaping message
- `row`: vaping message data row
... | [
"def",
"filename_formatters",
"(",
"self",
",",
"data",
",",
"row",
")",
":",
"r",
"=",
"{",
"\"source\"",
":",
"data",
".",
"get",
"(",
"\"source\"",
")",
",",
"\"field\"",
":",
"self",
".",
"field",
",",
"\"type\"",
":",
"data",
".",
"get",
"(",
... | Returns a dict containing the various filename formatter values
Values are gotten from the vaping data message as well as the
currently processed row in the message
- `data`: vaping message
- `row`: vaping message data row | [
"Returns",
"a",
"dict",
"containing",
"the",
"various",
"filename",
"formatter",
"values"
] | c51f00586c99edb3d51e4abdbdfe3174755533ee | https://github.com/20c/vaping/blob/c51f00586c99edb3d51e4abdbdfe3174755533ee/vaping/plugins/__init__.py#L394-L411 | train |
20c/vaping | vaping/plugins/__init__.py | TimeSeriesDB.format_filename | def format_filename(self, data, row):
"""
Returns a formatted filename using the template stored
in self.filename
- `data`: vaping message
- `row`: vaping message data row
"""
return self.filename.format(**self.filename_formatters(data, row)) | python | def format_filename(self, data, row):
"""
Returns a formatted filename using the template stored
in self.filename
- `data`: vaping message
- `row`: vaping message data row
"""
return self.filename.format(**self.filename_formatters(data, row)) | [
"def",
"format_filename",
"(",
"self",
",",
"data",
",",
"row",
")",
":",
"return",
"self",
".",
"filename",
".",
"format",
"(",
"*",
"*",
"self",
".",
"filename_formatters",
"(",
"data",
",",
"row",
")",
")"
] | Returns a formatted filename using the template stored
in self.filename
- `data`: vaping message
- `row`: vaping message data row | [
"Returns",
"a",
"formatted",
"filename",
"using",
"the",
"template",
"stored",
"in",
"self",
".",
"filename"
] | c51f00586c99edb3d51e4abdbdfe3174755533ee | https://github.com/20c/vaping/blob/c51f00586c99edb3d51e4abdbdfe3174755533ee/vaping/plugins/__init__.py#L413-L421 | train |
20c/vaping | vaping/plugins/__init__.py | TimeSeriesDB.emit | def emit(self, message):
"""
emit to database
"""
# handle vaping data that arrives in a list
if isinstance(message.get("data"), list):
for row in message.get("data"):
# format filename from data
filename = self.format_filename(messag... | python | def emit(self, message):
"""
emit to database
"""
# handle vaping data that arrives in a list
if isinstance(message.get("data"), list):
for row in message.get("data"):
# format filename from data
filename = self.format_filename(messag... | [
"def",
"emit",
"(",
"self",
",",
"message",
")",
":",
"# handle vaping data that arrives in a list",
"if",
"isinstance",
"(",
"message",
".",
"get",
"(",
"\"data\"",
")",
",",
"list",
")",
":",
"for",
"row",
"in",
"message",
".",
"get",
"(",
"\"data\"",
")... | emit to database | [
"emit",
"to",
"database"
] | c51f00586c99edb3d51e4abdbdfe3174755533ee | https://github.com/20c/vaping/blob/c51f00586c99edb3d51e4abdbdfe3174755533ee/vaping/plugins/__init__.py#L423-L442 | train |
20c/vaping | vaping/config.py | parse_interval | def parse_interval(val):
"""
converts a string to float of seconds
.5 = 500ms
90 = 1m30s
"""
re_intv = re.compile(r"([\d\.]+)([a-zA-Z]+)")
val = val.strip()
total = 0.0
for match in re_intv.findall(val):
unit = match[1]
count = float(match[0])
if unit... | python | def parse_interval(val):
"""
converts a string to float of seconds
.5 = 500ms
90 = 1m30s
"""
re_intv = re.compile(r"([\d\.]+)([a-zA-Z]+)")
val = val.strip()
total = 0.0
for match in re_intv.findall(val):
unit = match[1]
count = float(match[0])
if unit... | [
"def",
"parse_interval",
"(",
"val",
")",
":",
"re_intv",
"=",
"re",
".",
"compile",
"(",
"r\"([\\d\\.]+)([a-zA-Z]+)\"",
")",
"val",
"=",
"val",
".",
"strip",
"(",
")",
"total",
"=",
"0.0",
"for",
"match",
"in",
"re_intv",
".",
"findall",
"(",
"val",
"... | converts a string to float of seconds
.5 = 500ms
90 = 1m30s | [
"converts",
"a",
"string",
"to",
"float",
"of",
"seconds",
".",
"5",
"=",
"500ms",
"90",
"=",
"1m30s"
] | c51f00586c99edb3d51e4abdbdfe3174755533ee | https://github.com/20c/vaping/blob/c51f00586c99edb3d51e4abdbdfe3174755533ee/vaping/config.py#L8-L33 | train |
20c/vaping | vaping/plugins/fping.py | FPingBase.hosts_args | def hosts_args(self):
"""
hosts list can contain strings specifying a host directly
or dicts containing a "host" key to specify the host
this way we can allow passing further config details (color, name etc.)
with each host as well as simply dropping in addresses for quick
... | python | def hosts_args(self):
"""
hosts list can contain strings specifying a host directly
or dicts containing a "host" key to specify the host
this way we can allow passing further config details (color, name etc.)
with each host as well as simply dropping in addresses for quick
... | [
"def",
"hosts_args",
"(",
"self",
")",
":",
"host_args",
"=",
"[",
"]",
"for",
"row",
"in",
"self",
".",
"hosts",
":",
"if",
"isinstance",
"(",
"row",
",",
"dict",
")",
":",
"host_args",
".",
"append",
"(",
"row",
"[",
"\"host\"",
"]",
")",
"else",... | hosts list can contain strings specifying a host directly
or dicts containing a "host" key to specify the host
this way we can allow passing further config details (color, name etc.)
with each host as well as simply dropping in addresses for quick
setup depending on the user's needs | [
"hosts",
"list",
"can",
"contain",
"strings",
"specifying",
"a",
"host",
"directly",
"or",
"dicts",
"containing",
"a",
"host",
"key",
"to",
"specify",
"the",
"host"
] | c51f00586c99edb3d51e4abdbdfe3174755533ee | https://github.com/20c/vaping/blob/c51f00586c99edb3d51e4abdbdfe3174755533ee/vaping/plugins/fping.py#L39-L61 | train |
20c/vaping | vaping/plugins/fping.py | FPingBase.parse_verbose | def parse_verbose(self, line):
"""
parse output from verbose format
"""
try:
logging.debug(line)
(host, pings) = line.split(' : ')
cnt = 0
lost = 0
times = []
pings = pings.strip().split(' ')
cnt = len(pi... | python | def parse_verbose(self, line):
"""
parse output from verbose format
"""
try:
logging.debug(line)
(host, pings) = line.split(' : ')
cnt = 0
lost = 0
times = []
pings = pings.strip().split(' ')
cnt = len(pi... | [
"def",
"parse_verbose",
"(",
"self",
",",
"line",
")",
":",
"try",
":",
"logging",
".",
"debug",
"(",
"line",
")",
"(",
"host",
",",
"pings",
")",
"=",
"line",
".",
"split",
"(",
"' : '",
")",
"cnt",
"=",
"0",
"lost",
"=",
"0",
"times",
"=",
"[... | parse output from verbose format | [
"parse",
"output",
"from",
"verbose",
"format"
] | c51f00586c99edb3d51e4abdbdfe3174755533ee | https://github.com/20c/vaping/blob/c51f00586c99edb3d51e4abdbdfe3174755533ee/vaping/plugins/fping.py#L63-L100 | train |
20c/vaping | vaping/cli.py | start | def start(ctx, **kwargs):
"""
start a vaping process
"""
update_context(ctx, kwargs)
daemon = mk_daemon(ctx)
if ctx.debug or kwargs['no_fork']:
daemon.run()
else:
daemon.start() | python | def start(ctx, **kwargs):
"""
start a vaping process
"""
update_context(ctx, kwargs)
daemon = mk_daemon(ctx)
if ctx.debug or kwargs['no_fork']:
daemon.run()
else:
daemon.start() | [
"def",
"start",
"(",
"ctx",
",",
"*",
"*",
"kwargs",
")",
":",
"update_context",
"(",
"ctx",
",",
"kwargs",
")",
"daemon",
"=",
"mk_daemon",
"(",
"ctx",
")",
"if",
"ctx",
".",
"debug",
"or",
"kwargs",
"[",
"'no_fork'",
"]",
":",
"daemon",
".",
"run... | start a vaping process | [
"start",
"a",
"vaping",
"process"
] | c51f00586c99edb3d51e4abdbdfe3174755533ee | https://github.com/20c/vaping/blob/c51f00586c99edb3d51e4abdbdfe3174755533ee/vaping/cli.py#L52-L63 | train |
20c/vaping | vaping/cli.py | stop | def stop(ctx, **kwargs):
"""
stop a vaping process
"""
update_context(ctx, kwargs)
daemon = mk_daemon(ctx)
daemon.stop() | python | def stop(ctx, **kwargs):
"""
stop a vaping process
"""
update_context(ctx, kwargs)
daemon = mk_daemon(ctx)
daemon.stop() | [
"def",
"stop",
"(",
"ctx",
",",
"*",
"*",
"kwargs",
")",
":",
"update_context",
"(",
"ctx",
",",
"kwargs",
")",
"daemon",
"=",
"mk_daemon",
"(",
"ctx",
")",
"daemon",
".",
"stop",
"(",
")"
] | stop a vaping process | [
"stop",
"a",
"vaping",
"process"
] | c51f00586c99edb3d51e4abdbdfe3174755533ee | https://github.com/20c/vaping/blob/c51f00586c99edb3d51e4abdbdfe3174755533ee/vaping/cli.py#L70-L77 | train |
20c/vaping | vaping/cli.py | restart | def restart(ctx, **kwargs):
"""
restart a vaping process
"""
update_context(ctx, kwargs)
daemon = mk_daemon(ctx)
daemon.stop()
daemon.start() | python | def restart(ctx, **kwargs):
"""
restart a vaping process
"""
update_context(ctx, kwargs)
daemon = mk_daemon(ctx)
daemon.stop()
daemon.start() | [
"def",
"restart",
"(",
"ctx",
",",
"*",
"*",
"kwargs",
")",
":",
"update_context",
"(",
"ctx",
",",
"kwargs",
")",
"daemon",
"=",
"mk_daemon",
"(",
"ctx",
")",
"daemon",
".",
"stop",
"(",
")",
"daemon",
".",
"start",
"(",
")"
] | restart a vaping process | [
"restart",
"a",
"vaping",
"process"
] | c51f00586c99edb3d51e4abdbdfe3174755533ee | https://github.com/20c/vaping/blob/c51f00586c99edb3d51e4abdbdfe3174755533ee/vaping/cli.py#L84-L92 | train |
aio-libs/aiohttp-debugtoolbar | aiohttp_debugtoolbar/panels/base.py | DebugPanel.render_content | def render_content(self, request):
"""Return a string containing the HTML to be rendered for the panel.
By default this will render the template defined by the
:attr:`.template` attribute with a rendering context defined by
:attr:`.data` combined with the ``dict`` returned from
... | python | def render_content(self, request):
"""Return a string containing the HTML to be rendered for the panel.
By default this will render the template defined by the
:attr:`.template` attribute with a rendering context defined by
:attr:`.data` combined with the ``dict`` returned from
... | [
"def",
"render_content",
"(",
"self",
",",
"request",
")",
":",
"context",
"=",
"self",
".",
"data",
".",
"copy",
"(",
")",
"context",
".",
"update",
"(",
"self",
".",
"render_vars",
"(",
"request",
")",
")",
"return",
"render",
"(",
"self",
".",
"te... | Return a string containing the HTML to be rendered for the panel.
By default this will render the template defined by the
:attr:`.template` attribute with a rendering context defined by
:attr:`.data` combined with the ``dict`` returned from
:meth:`.render_vars`.
The ``request``... | [
"Return",
"a",
"string",
"containing",
"the",
"HTML",
"to",
"be",
"rendered",
"for",
"the",
"panel",
"."
] | a1c3fb2b487bcaaf23eb71ee4c9c3cfc9cb94322 | https://github.com/aio-libs/aiohttp-debugtoolbar/blob/a1c3fb2b487bcaaf23eb71ee4c9c3cfc9cb94322/aiohttp_debugtoolbar/panels/base.py#L82-L95 | train |
aio-libs/aiohttp-debugtoolbar | aiohttp_debugtoolbar/toolbar.py | DebugToolbar.inject | def inject(self, request, response):
"""
Inject the debug toolbar iframe into an HTML response.
"""
# called in host app
if not isinstance(response, Response):
return
settings = request.app[APP_KEY]['settings']
response_html = response.body
rou... | python | def inject(self, request, response):
"""
Inject the debug toolbar iframe into an HTML response.
"""
# called in host app
if not isinstance(response, Response):
return
settings = request.app[APP_KEY]['settings']
response_html = response.body
rou... | [
"def",
"inject",
"(",
"self",
",",
"request",
",",
"response",
")",
":",
"# called in host app",
"if",
"not",
"isinstance",
"(",
"response",
",",
"Response",
")",
":",
"return",
"settings",
"=",
"request",
".",
"app",
"[",
"APP_KEY",
"]",
"[",
"'settings'"... | Inject the debug toolbar iframe into an HTML response. | [
"Inject",
"the",
"debug",
"toolbar",
"iframe",
"into",
"an",
"HTML",
"response",
"."
] | a1c3fb2b487bcaaf23eb71ee4c9c3cfc9cb94322 | https://github.com/aio-libs/aiohttp-debugtoolbar/blob/a1c3fb2b487bcaaf23eb71ee4c9c3cfc9cb94322/aiohttp_debugtoolbar/toolbar.py#L52-L81 | train |
aio-libs/aiohttp-debugtoolbar | aiohttp_debugtoolbar/utils.py | common_segment_count | def common_segment_count(path, value):
"""Return the number of path segments common to both"""
i = 0
if len(path) <= len(value):
for x1, x2 in zip(path, value):
if x1 == x2:
i += 1
else:
return 0
return i | python | def common_segment_count(path, value):
"""Return the number of path segments common to both"""
i = 0
if len(path) <= len(value):
for x1, x2 in zip(path, value):
if x1 == x2:
i += 1
else:
return 0
return i | [
"def",
"common_segment_count",
"(",
"path",
",",
"value",
")",
":",
"i",
"=",
"0",
"if",
"len",
"(",
"path",
")",
"<=",
"len",
"(",
"value",
")",
":",
"for",
"x1",
",",
"x2",
"in",
"zip",
"(",
"path",
",",
"value",
")",
":",
"if",
"x1",
"==",
... | Return the number of path segments common to both | [
"Return",
"the",
"number",
"of",
"path",
"segments",
"common",
"to",
"both"
] | a1c3fb2b487bcaaf23eb71ee4c9c3cfc9cb94322 | https://github.com/aio-libs/aiohttp-debugtoolbar/blob/a1c3fb2b487bcaaf23eb71ee4c9c3cfc9cb94322/aiohttp_debugtoolbar/utils.py#L83-L92 | train |
jsocol/pystatsd | statsd/client/base.py | StatsClientBase.timing | def timing(self, stat, delta, rate=1):
"""
Send new timing information.
`delta` can be either a number of milliseconds or a timedelta.
"""
if isinstance(delta, timedelta):
# Convert timedelta to number of milliseconds.
delta = delta.total_seconds() * 1000... | python | def timing(self, stat, delta, rate=1):
"""
Send new timing information.
`delta` can be either a number of milliseconds or a timedelta.
"""
if isinstance(delta, timedelta):
# Convert timedelta to number of milliseconds.
delta = delta.total_seconds() * 1000... | [
"def",
"timing",
"(",
"self",
",",
"stat",
",",
"delta",
",",
"rate",
"=",
"1",
")",
":",
"if",
"isinstance",
"(",
"delta",
",",
"timedelta",
")",
":",
"# Convert timedelta to number of milliseconds.",
"delta",
"=",
"delta",
".",
"total_seconds",
"(",
")",
... | Send new timing information.
`delta` can be either a number of milliseconds or a timedelta. | [
"Send",
"new",
"timing",
"information",
"."
] | 006a86394c44ff71e6e8e52529daa3c0fdcc93fb | https://github.com/jsocol/pystatsd/blob/006a86394c44ff71e6e8e52529daa3c0fdcc93fb/statsd/client/base.py#L22-L31 | train |
jsocol/pystatsd | statsd/client/base.py | StatsClientBase.decr | def decr(self, stat, count=1, rate=1):
"""Decrement a stat by `count`."""
self.incr(stat, -count, rate) | python | def decr(self, stat, count=1, rate=1):
"""Decrement a stat by `count`."""
self.incr(stat, -count, rate) | [
"def",
"decr",
"(",
"self",
",",
"stat",
",",
"count",
"=",
"1",
",",
"rate",
"=",
"1",
")",
":",
"self",
".",
"incr",
"(",
"stat",
",",
"-",
"count",
",",
"rate",
")"
] | Decrement a stat by `count`. | [
"Decrement",
"a",
"stat",
"by",
"count",
"."
] | 006a86394c44ff71e6e8e52529daa3c0fdcc93fb | https://github.com/jsocol/pystatsd/blob/006a86394c44ff71e6e8e52529daa3c0fdcc93fb/statsd/client/base.py#L37-L39 | train |
jsocol/pystatsd | statsd/client/base.py | StatsClientBase.gauge | def gauge(self, stat, value, rate=1, delta=False):
"""Set a gauge value."""
if value < 0 and not delta:
if rate < 1:
if random.random() > rate:
return
with self.pipeline() as pipe:
pipe._send_stat(stat, '0|g', 1)
... | python | def gauge(self, stat, value, rate=1, delta=False):
"""Set a gauge value."""
if value < 0 and not delta:
if rate < 1:
if random.random() > rate:
return
with self.pipeline() as pipe:
pipe._send_stat(stat, '0|g', 1)
... | [
"def",
"gauge",
"(",
"self",
",",
"stat",
",",
"value",
",",
"rate",
"=",
"1",
",",
"delta",
"=",
"False",
")",
":",
"if",
"value",
"<",
"0",
"and",
"not",
"delta",
":",
"if",
"rate",
"<",
"1",
":",
"if",
"random",
".",
"random",
"(",
")",
">... | Set a gauge value. | [
"Set",
"a",
"gauge",
"value",
"."
] | 006a86394c44ff71e6e8e52529daa3c0fdcc93fb | https://github.com/jsocol/pystatsd/blob/006a86394c44ff71e6e8e52529daa3c0fdcc93fb/statsd/client/base.py#L41-L52 | train |
jsocol/pystatsd | statsd/client/base.py | StatsClientBase.set | def set(self, stat, value, rate=1):
"""Set a set value."""
self._send_stat(stat, '%s|s' % value, rate) | python | def set(self, stat, value, rate=1):
"""Set a set value."""
self._send_stat(stat, '%s|s' % value, rate) | [
"def",
"set",
"(",
"self",
",",
"stat",
",",
"value",
",",
"rate",
"=",
"1",
")",
":",
"self",
".",
"_send_stat",
"(",
"stat",
",",
"'%s|s'",
"%",
"value",
",",
"rate",
")"
] | Set a set value. | [
"Set",
"a",
"set",
"value",
"."
] | 006a86394c44ff71e6e8e52529daa3c0fdcc93fb | https://github.com/jsocol/pystatsd/blob/006a86394c44ff71e6e8e52529daa3c0fdcc93fb/statsd/client/base.py#L54-L56 | train |
jsocol/pystatsd | statsd/client/timer.py | safe_wraps | def safe_wraps(wrapper, *args, **kwargs):
"""Safely wraps partial functions."""
while isinstance(wrapper, functools.partial):
wrapper = wrapper.func
return functools.wraps(wrapper, *args, **kwargs) | python | def safe_wraps(wrapper, *args, **kwargs):
"""Safely wraps partial functions."""
while isinstance(wrapper, functools.partial):
wrapper = wrapper.func
return functools.wraps(wrapper, *args, **kwargs) | [
"def",
"safe_wraps",
"(",
"wrapper",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"while",
"isinstance",
"(",
"wrapper",
",",
"functools",
".",
"partial",
")",
":",
"wrapper",
"=",
"wrapper",
".",
"func",
"return",
"functools",
".",
"wraps",
"(... | Safely wraps partial functions. | [
"Safely",
"wraps",
"partial",
"functions",
"."
] | 006a86394c44ff71e6e8e52529daa3c0fdcc93fb | https://github.com/jsocol/pystatsd/blob/006a86394c44ff71e6e8e52529daa3c0fdcc93fb/statsd/client/timer.py#L14-L18 | train |
jorisroovers/gitlint | gitlint/user_rules.py | find_rule_classes | def find_rule_classes(extra_path):
"""
Searches a given directory or python module for rule classes. This is done by
adding the directory path to the python path, importing the modules and then finding
any Rule class in those modules.
:param extra_path: absolute directory or file path to search for... | python | def find_rule_classes(extra_path):
"""
Searches a given directory or python module for rule classes. This is done by
adding the directory path to the python path, importing the modules and then finding
any Rule class in those modules.
:param extra_path: absolute directory or file path to search for... | [
"def",
"find_rule_classes",
"(",
"extra_path",
")",
":",
"files",
"=",
"[",
"]",
"modules",
"=",
"[",
"]",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"extra_path",
")",
":",
"files",
"=",
"[",
"os",
".",
"path",
".",
"basename",
"(",
"extra_path",
... | Searches a given directory or python module for rule classes. This is done by
adding the directory path to the python path, importing the modules and then finding
any Rule class in those modules.
:param extra_path: absolute directory or file path to search for rule classes
:return: The list of rule cla... | [
"Searches",
"a",
"given",
"directory",
"or",
"python",
"module",
"for",
"rule",
"classes",
".",
"This",
"is",
"done",
"by",
"adding",
"the",
"directory",
"path",
"to",
"the",
"python",
"path",
"importing",
"the",
"modules",
"and",
"then",
"finding",
"any",
... | 6248bd6cbc20c1be3bb6d196a5ec0425af99733b | https://github.com/jorisroovers/gitlint/blob/6248bd6cbc20c1be3bb6d196a5ec0425af99733b/gitlint/user_rules.py#L16-L73 | train |
jorisroovers/gitlint | qa/base.py | ustr | def ustr(obj):
""" Python 2 and 3 utility method that converts an obj to unicode in python 2 and to a str object in python 3"""
if sys.version_info[0] == 2:
# If we are getting a string, then do an explicit decode
# else, just call the unicode method of the object
if type(obj) in [str, b... | python | def ustr(obj):
""" Python 2 and 3 utility method that converts an obj to unicode in python 2 and to a str object in python 3"""
if sys.version_info[0] == 2:
# If we are getting a string, then do an explicit decode
# else, just call the unicode method of the object
if type(obj) in [str, b... | [
"def",
"ustr",
"(",
"obj",
")",
":",
"if",
"sys",
".",
"version_info",
"[",
"0",
"]",
"==",
"2",
":",
"# If we are getting a string, then do an explicit decode",
"# else, just call the unicode method of the object",
"if",
"type",
"(",
"obj",
")",
"in",
"[",
"str",
... | Python 2 and 3 utility method that converts an obj to unicode in python 2 and to a str object in python 3 | [
"Python",
"2",
"and",
"3",
"utility",
"method",
"that",
"converts",
"an",
"obj",
"to",
"unicode",
"in",
"python",
"2",
"and",
"to",
"a",
"str",
"object",
"in",
"python",
"3"
] | 6248bd6cbc20c1be3bb6d196a5ec0425af99733b | https://github.com/jorisroovers/gitlint/blob/6248bd6cbc20c1be3bb6d196a5ec0425af99733b/qa/base.py#L21-L34 | train |
jorisroovers/gitlint | gitlint/config.py | LintConfig.get_rule_option | def get_rule_option(self, rule_name_or_id, option_name):
""" Returns the value of a given option for a given rule. LintConfigErrors will be raised if the
rule or option don't exist. """
option = self._get_option(rule_name_or_id, option_name)
return option.value | python | def get_rule_option(self, rule_name_or_id, option_name):
""" Returns the value of a given option for a given rule. LintConfigErrors will be raised if the
rule or option don't exist. """
option = self._get_option(rule_name_or_id, option_name)
return option.value | [
"def",
"get_rule_option",
"(",
"self",
",",
"rule_name_or_id",
",",
"option_name",
")",
":",
"option",
"=",
"self",
".",
"_get_option",
"(",
"rule_name_or_id",
",",
"option_name",
")",
"return",
"option",
".",
"value"
] | Returns the value of a given option for a given rule. LintConfigErrors will be raised if the
rule or option don't exist. | [
"Returns",
"the",
"value",
"of",
"a",
"given",
"option",
"for",
"a",
"given",
"rule",
".",
"LintConfigErrors",
"will",
"be",
"raised",
"if",
"the",
"rule",
"or",
"option",
"don",
"t",
"exist",
"."
] | 6248bd6cbc20c1be3bb6d196a5ec0425af99733b | https://github.com/jorisroovers/gitlint/blob/6248bd6cbc20c1be3bb6d196a5ec0425af99733b/gitlint/config.py#L207-L211 | train |
jorisroovers/gitlint | gitlint/config.py | LintConfig.set_rule_option | def set_rule_option(self, rule_name_or_id, option_name, option_value):
""" Attempts to set a given value for a given option for a given rule.
LintConfigErrors will be raised if the rule or option don't exist or if the value is invalid. """
option = self._get_option(rule_name_or_id, option_na... | python | def set_rule_option(self, rule_name_or_id, option_name, option_value):
""" Attempts to set a given value for a given option for a given rule.
LintConfigErrors will be raised if the rule or option don't exist or if the value is invalid. """
option = self._get_option(rule_name_or_id, option_na... | [
"def",
"set_rule_option",
"(",
"self",
",",
"rule_name_or_id",
",",
"option_name",
",",
"option_value",
")",
":",
"option",
"=",
"self",
".",
"_get_option",
"(",
"rule_name_or_id",
",",
"option_name",
")",
"try",
":",
"option",
".",
"set",
"(",
"option_value",... | Attempts to set a given value for a given option for a given rule.
LintConfigErrors will be raised if the rule or option don't exist or if the value is invalid. | [
"Attempts",
"to",
"set",
"a",
"given",
"value",
"for",
"a",
"given",
"option",
"for",
"a",
"given",
"rule",
".",
"LintConfigErrors",
"will",
"be",
"raised",
"if",
"the",
"rule",
"or",
"option",
"don",
"t",
"exist",
"or",
"if",
"the",
"value",
"is",
"in... | 6248bd6cbc20c1be3bb6d196a5ec0425af99733b | https://github.com/jorisroovers/gitlint/blob/6248bd6cbc20c1be3bb6d196a5ec0425af99733b/gitlint/config.py#L213-L221 | train |
jorisroovers/gitlint | gitlint/config.py | LintConfigBuilder.set_from_config_file | def set_from_config_file(self, filename):
""" Loads lint config from a ini-style config file """
if not os.path.exists(filename):
raise LintConfigError(u"Invalid file path: {0}".format(filename))
self._config_path = os.path.abspath(filename)
try:
parser = ConfigPa... | python | def set_from_config_file(self, filename):
""" Loads lint config from a ini-style config file """
if not os.path.exists(filename):
raise LintConfigError(u"Invalid file path: {0}".format(filename))
self._config_path = os.path.abspath(filename)
try:
parser = ConfigPa... | [
"def",
"set_from_config_file",
"(",
"self",
",",
"filename",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"filename",
")",
":",
"raise",
"LintConfigError",
"(",
"u\"Invalid file path: {0}\"",
".",
"format",
"(",
"filename",
")",
")",
"self",... | Loads lint config from a ini-style config file | [
"Loads",
"lint",
"config",
"from",
"a",
"ini",
"-",
"style",
"config",
"file"
] | 6248bd6cbc20c1be3bb6d196a5ec0425af99733b | https://github.com/jorisroovers/gitlint/blob/6248bd6cbc20c1be3bb6d196a5ec0425af99733b/gitlint/config.py#L310-L324 | train |
jorisroovers/gitlint | gitlint/config.py | LintConfigBuilder.build | def build(self, config=None):
""" Build a real LintConfig object by normalizing and validating the options that were previously set on this
factory. """
# If we are passed a config object, then rebuild that object instead of building a new lintconfig object from
# scratch
if not... | python | def build(self, config=None):
""" Build a real LintConfig object by normalizing and validating the options that were previously set on this
factory. """
# If we are passed a config object, then rebuild that object instead of building a new lintconfig object from
# scratch
if not... | [
"def",
"build",
"(",
"self",
",",
"config",
"=",
"None",
")",
":",
"# If we are passed a config object, then rebuild that object instead of building a new lintconfig object from",
"# scratch",
"if",
"not",
"config",
":",
"config",
"=",
"LintConfig",
"(",
")",
"config",
".... | Build a real LintConfig object by normalizing and validating the options that were previously set on this
factory. | [
"Build",
"a",
"real",
"LintConfig",
"object",
"by",
"normalizing",
"and",
"validating",
"the",
"options",
"that",
"were",
"previously",
"set",
"on",
"this",
"factory",
"."
] | 6248bd6cbc20c1be3bb6d196a5ec0425af99733b | https://github.com/jorisroovers/gitlint/blob/6248bd6cbc20c1be3bb6d196a5ec0425af99733b/gitlint/config.py#L326-L349 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.