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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
limodou/uliweb | uliweb/core/html.py | to_attrs | def to_attrs(args, nocreate_if_none=['id', 'for', 'class']):
"""
Make python dict to k="v" format
"""
if not args:
return ''
s = ['']
for k, v in sorted(args.items()):
k = u_str(k)
v = u_str(v)
if k.startswith('_'):
k = k[1:]
if v is None:
... | python | def to_attrs(args, nocreate_if_none=['id', 'for', 'class']):
"""
Make python dict to k="v" format
"""
if not args:
return ''
s = ['']
for k, v in sorted(args.items()):
k = u_str(k)
v = u_str(v)
if k.startswith('_'):
k = k[1:]
if v is None:
... | [
"def",
"to_attrs",
"(",
"args",
",",
"nocreate_if_none",
"=",
"[",
"'id'",
",",
"'for'",
",",
"'class'",
"]",
")",
":",
"if",
"not",
"args",
":",
"return",
"''",
"s",
"=",
"[",
"''",
"]",
"for",
"k",
",",
"v",
"in",
"sorted",
"(",
"args",
".",
... | Make python dict to k="v" format | [
"Make",
"python",
"dict",
"to",
"k",
"=",
"v",
"format"
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/core/html.py#L24-L46 | train |
limodou/uliweb | uliweb/i18n/pygettext.py | _get_modpkg_path | def _get_modpkg_path(dotted_name, pathlist=None):
"""Get the filesystem path for a module or a package.
Return the file system path to a file for a module, and to a directory for
a package. Return None if the name is not found, or is a builtin or
extension module.
"""
# split off top-most name
... | python | def _get_modpkg_path(dotted_name, pathlist=None):
"""Get the filesystem path for a module or a package.
Return the file system path to a file for a module, and to a directory for
a package. Return None if the name is not found, or is a builtin or
extension module.
"""
# split off top-most name
... | [
"def",
"_get_modpkg_path",
"(",
"dotted_name",
",",
"pathlist",
"=",
"None",
")",
":",
"# split off top-most name",
"parts",
"=",
"dotted_name",
".",
"split",
"(",
"'.'",
",",
"1",
")",
"if",
"len",
"(",
"parts",
")",
">",
"1",
":",
"# we have a dotted path,... | Get the filesystem path for a module or a package.
Return the file system path to a file for a module, and to a directory for
a package. Return None if the name is not found, or is a builtin or
extension module. | [
"Get",
"the",
"filesystem",
"path",
"for",
"a",
"module",
"or",
"a",
"package",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/i18n/pygettext.py#L314-L350 | train |
limodou/uliweb | uliweb/i18n/pygettext.py | getFilesForName | def getFilesForName(name):
"""Get a list of module files for a filename, a module or package name,
or a directory.
"""
if not os.path.exists(name):
# check for glob chars
if containsAny(name, "*?[]"):
files = glob.glob(name)
list = []
for file in files... | python | def getFilesForName(name):
"""Get a list of module files for a filename, a module or package name,
or a directory.
"""
if not os.path.exists(name):
# check for glob chars
if containsAny(name, "*?[]"):
files = glob.glob(name)
list = []
for file in files... | [
"def",
"getFilesForName",
"(",
"name",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"name",
")",
":",
"# check for glob chars",
"if",
"containsAny",
"(",
"name",
",",
"\"*?[]\"",
")",
":",
"files",
"=",
"glob",
".",
"glob",
"(",
"name"... | Get a list of module files for a filename, a module or package name,
or a directory. | [
"Get",
"a",
"list",
"of",
"module",
"files",
"for",
"a",
"filename",
"a",
"module",
"or",
"package",
"name",
"or",
"a",
"directory",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/i18n/pygettext.py#L353-L380 | train |
limodou/uliweb | uliweb/lib/werkzeug/utils.py | unescape | def unescape(s):
"""The reverse function of `escape`. This unescapes all the HTML
entities, not only the XML entities inserted by `escape`.
:param s: the string to unescape.
"""
def handle_match(m):
name = m.group(1)
if name in HTMLBuilder._entities:
return unichr(HTMLB... | python | def unescape(s):
"""The reverse function of `escape`. This unescapes all the HTML
entities, not only the XML entities inserted by `escape`.
:param s: the string to unescape.
"""
def handle_match(m):
name = m.group(1)
if name in HTMLBuilder._entities:
return unichr(HTMLB... | [
"def",
"unescape",
"(",
"s",
")",
":",
"def",
"handle_match",
"(",
"m",
")",
":",
"name",
"=",
"m",
".",
"group",
"(",
"1",
")",
"if",
"name",
"in",
"HTMLBuilder",
".",
"_entities",
":",
"return",
"unichr",
"(",
"HTMLBuilder",
".",
"_entities",
"[",
... | The reverse function of `escape`. This unescapes all the HTML
entities, not only the XML entities inserted by `escape`.
:param s: the string to unescape. | [
"The",
"reverse",
"function",
"of",
"escape",
".",
"This",
"unescapes",
"all",
"the",
"HTML",
"entities",
"not",
"only",
"the",
"XML",
"entities",
"inserted",
"by",
"escape",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/utils.py#L317-L335 | train |
limodou/uliweb | uliweb/lib/werkzeug/utils.py | append_slash_redirect | def append_slash_redirect(environ, code=301):
"""Redirect to the same URL but with a slash appended. The behavior
of this function is undefined if the path ends with a slash already.
:param environ: the WSGI environment for the request that triggers
the redirect.
:param code: the s... | python | def append_slash_redirect(environ, code=301):
"""Redirect to the same URL but with a slash appended. The behavior
of this function is undefined if the path ends with a slash already.
:param environ: the WSGI environment for the request that triggers
the redirect.
:param code: the s... | [
"def",
"append_slash_redirect",
"(",
"environ",
",",
"code",
"=",
"301",
")",
":",
"new_path",
"=",
"environ",
"[",
"'PATH_INFO'",
"]",
".",
"strip",
"(",
"'/'",
")",
"+",
"'/'",
"query_string",
"=",
"environ",
".",
"get",
"(",
"'QUERY_STRING'",
")",
"if... | Redirect to the same URL but with a slash appended. The behavior
of this function is undefined if the path ends with a slash already.
:param environ: the WSGI environment for the request that triggers
the redirect.
:param code: the status code for the redirect. | [
"Redirect",
"to",
"the",
"same",
"URL",
"but",
"with",
"a",
"slash",
"appended",
".",
"The",
"behavior",
"of",
"this",
"function",
"is",
"undefined",
"if",
"the",
"path",
"ends",
"with",
"a",
"slash",
"already",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/utils.py#L368-L380 | train |
limodou/uliweb | uliweb/i18n/po_merge.py | parse_translation | def parse_translation(f, lineno):
"""Read a single translation entry from the file F and return a
tuple with the comments, msgid and msgstr. The comments is returned
as a list of lines which do not end in new-lines. The msgid and
msgstr are strings, possibly with embedded newlines"""
line = f... | python | def parse_translation(f, lineno):
"""Read a single translation entry from the file F and return a
tuple with the comments, msgid and msgstr. The comments is returned
as a list of lines which do not end in new-lines. The msgid and
msgstr are strings, possibly with embedded newlines"""
line = f... | [
"def",
"parse_translation",
"(",
"f",
",",
"lineno",
")",
":",
"line",
"=",
"f",
".",
"readline",
"(",
")",
"def",
"get_line",
"(",
"f",
",",
"line",
",",
"need_keys",
",",
"lineno",
",",
"default",
"=",
"'\"\"'",
")",
":",
"line",
"=",
"line",
"."... | Read a single translation entry from the file F and return a
tuple with the comments, msgid and msgstr. The comments is returned
as a list of lines which do not end in new-lines. The msgid and
msgstr are strings, possibly with embedded newlines | [
"Read",
"a",
"single",
"translation",
"entry",
"from",
"the",
"file",
"F",
"and",
"return",
"a",
"tuple",
"with",
"the",
"comments",
"msgid",
"and",
"msgstr",
".",
"The",
"comments",
"is",
"returned",
"as",
"a",
"list",
"of",
"lines",
"which",
"do",
"not... | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/i18n/po_merge.py#L5-L59 | train |
limodou/uliweb | uliweb/contrib/form/__init__.py | get_form | def get_form(formcls):
"""
get form class according form class path or form class object
"""
from uliweb.form import Form
import inspect
if inspect.isclass(formcls) and issubclass(formcls, Form):
return formcls
elif isinstance(formcls, (str, unicode)):
path = settings.FO... | python | def get_form(formcls):
"""
get form class according form class path or form class object
"""
from uliweb.form import Form
import inspect
if inspect.isclass(formcls) and issubclass(formcls, Form):
return formcls
elif isinstance(formcls, (str, unicode)):
path = settings.FO... | [
"def",
"get_form",
"(",
"formcls",
")",
":",
"from",
"uliweb",
".",
"form",
"import",
"Form",
"import",
"inspect",
"if",
"inspect",
".",
"isclass",
"(",
"formcls",
")",
"and",
"issubclass",
"(",
"formcls",
",",
"Form",
")",
":",
"return",
"formcls",
"eli... | get form class according form class path or form class object | [
"get",
"form",
"class",
"according",
"form",
"class",
"path",
"or",
"form",
"class",
"object"
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/contrib/form/__init__.py#L6-L23 | train |
limodou/uliweb | uliweb/lib/werkzeug/script.py | run | def run(namespace=None, action_prefix='action_', args=None):
"""Run the script. Participating actions are looked up in the caller's
namespace if no namespace is given, otherwise in the dict provided.
Only items that start with action_prefix are processed as actions. If
you want to use all items in the... | python | def run(namespace=None, action_prefix='action_', args=None):
"""Run the script. Participating actions are looked up in the caller's
namespace if no namespace is given, otherwise in the dict provided.
Only items that start with action_prefix are processed as actions. If
you want to use all items in the... | [
"def",
"run",
"(",
"namespace",
"=",
"None",
",",
"action_prefix",
"=",
"'action_'",
",",
"args",
"=",
"None",
")",
":",
"if",
"namespace",
"is",
"None",
":",
"namespace",
"=",
"sys",
".",
"_getframe",
"(",
"1",
")",
".",
"f_locals",
"actions",
"=",
... | Run the script. Participating actions are looked up in the caller's
namespace if no namespace is given, otherwise in the dict provided.
Only items that start with action_prefix are processed as actions. If
you want to use all items in the namespace provided as actions set
action_prefix to an empty str... | [
"Run",
"the",
"script",
".",
"Participating",
"actions",
"are",
"looked",
"up",
"in",
"the",
"caller",
"s",
"namespace",
"if",
"no",
"namespace",
"is",
"given",
"otherwise",
"in",
"the",
"dict",
"provided",
".",
"Only",
"items",
"that",
"start",
"with",
"a... | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/script.py#L98-L177 | train |
limodou/uliweb | uliweb/lib/werkzeug/script.py | fail | def fail(message, code=-1):
"""Fail with an error."""
print('Error: %s' % message, file=sys.stderr)
sys.exit(code) | python | def fail(message, code=-1):
"""Fail with an error."""
print('Error: %s' % message, file=sys.stderr)
sys.exit(code) | [
"def",
"fail",
"(",
"message",
",",
"code",
"=",
"-",
"1",
")",
":",
"print",
"(",
"'Error: %s'",
"%",
"message",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"sys",
".",
"exit",
"(",
"code",
")"
] | Fail with an error. | [
"Fail",
"with",
"an",
"error",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/script.py#L180-L183 | train |
limodou/uliweb | uliweb/lib/werkzeug/script.py | find_actions | def find_actions(namespace, action_prefix):
"""Find all the actions in the namespace."""
actions = {}
for key, value in iteritems(namespace):
if key.startswith(action_prefix):
actions[key[len(action_prefix):]] = analyse_action(value)
return actions | python | def find_actions(namespace, action_prefix):
"""Find all the actions in the namespace."""
actions = {}
for key, value in iteritems(namespace):
if key.startswith(action_prefix):
actions[key[len(action_prefix):]] = analyse_action(value)
return actions | [
"def",
"find_actions",
"(",
"namespace",
",",
"action_prefix",
")",
":",
"actions",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"iteritems",
"(",
"namespace",
")",
":",
"if",
"key",
".",
"startswith",
"(",
"action_prefix",
")",
":",
"actions",
"[",
... | Find all the actions in the namespace. | [
"Find",
"all",
"the",
"actions",
"in",
"the",
"namespace",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/script.py#L186-L192 | train |
limodou/uliweb | uliweb/lib/werkzeug/script.py | analyse_action | def analyse_action(func):
"""Analyse a function."""
description = inspect.getdoc(func) or 'undocumented action'
arguments = []
args, varargs, kwargs, defaults = inspect.getargspec(func)
if varargs or kwargs:
raise TypeError('variable length arguments for action not allowed.')
if len(args... | python | def analyse_action(func):
"""Analyse a function."""
description = inspect.getdoc(func) or 'undocumented action'
arguments = []
args, varargs, kwargs, defaults = inspect.getargspec(func)
if varargs or kwargs:
raise TypeError('variable length arguments for action not allowed.')
if len(args... | [
"def",
"analyse_action",
"(",
"func",
")",
":",
"description",
"=",
"inspect",
".",
"getdoc",
"(",
"func",
")",
"or",
"'undocumented action'",
"arguments",
"=",
"[",
"]",
"args",
",",
"varargs",
",",
"kwargs",
",",
"defaults",
"=",
"inspect",
".",
"getargs... | Analyse a function. | [
"Analyse",
"a",
"function",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/script.py#L222-L245 | train |
limodou/uliweb | uliweb/lib/werkzeug/script.py | make_shell | def make_shell(init_func=None, banner=None, use_ipython=True):
"""Returns an action callback that spawns a new interactive
python shell.
:param init_func: an optional initialization function that is
called before the shell is started. The return
value of this fu... | python | def make_shell(init_func=None, banner=None, use_ipython=True):
"""Returns an action callback that spawns a new interactive
python shell.
:param init_func: an optional initialization function that is
called before the shell is started. The return
value of this fu... | [
"def",
"make_shell",
"(",
"init_func",
"=",
"None",
",",
"banner",
"=",
"None",
",",
"use_ipython",
"=",
"True",
")",
":",
"if",
"banner",
"is",
"None",
":",
"banner",
"=",
"'Interactive Werkzeug Shell'",
"if",
"init_func",
"is",
"None",
":",
"init_func",
... | Returns an action callback that spawns a new interactive
python shell.
:param init_func: an optional initialization function that is
called before the shell is started. The return
value of this function is the initial namespace.
:param banner: the banner that is... | [
"Returns",
"an",
"action",
"callback",
"that",
"spawns",
"a",
"new",
"interactive",
"python",
"shell",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/script.py#L248-L281 | train |
limodou/uliweb | uliweb/lib/werkzeug/script.py | make_runserver | def make_runserver(app_factory, hostname='localhost', port=5000,
use_reloader=False, use_debugger=False, use_evalex=True,
threaded=False, processes=1, static_files=None,
extra_files=None, ssl_context=None):
"""Returns an action callback that spawns a new deve... | python | def make_runserver(app_factory, hostname='localhost', port=5000,
use_reloader=False, use_debugger=False, use_evalex=True,
threaded=False, processes=1, static_files=None,
extra_files=None, ssl_context=None):
"""Returns an action callback that spawns a new deve... | [
"def",
"make_runserver",
"(",
"app_factory",
",",
"hostname",
"=",
"'localhost'",
",",
"port",
"=",
"5000",
",",
"use_reloader",
"=",
"False",
",",
"use_debugger",
"=",
"False",
",",
"use_evalex",
"=",
"True",
",",
"threaded",
"=",
"False",
",",
"processes",... | Returns an action callback that spawns a new development server.
.. versionadded:: 0.5
`static_files` and `extra_files` was added.
..versionadded:: 0.6.1
`ssl_context` was added.
:param app_factory: a function that returns a new WSGI application.
:param hostname: the default hostname th... | [
"Returns",
"an",
"action",
"callback",
"that",
"spawns",
"a",
"new",
"development",
"server",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/script.py#L284-L316 | train |
limodou/uliweb | uliweb/core/dispatch.py | unbind | def unbind(topic, func):
"""
Remove receiver function
"""
if topic in _receivers:
receivers = _receivers[topic]
for i in range(len(receivers)-1, -1, -1):
nice, f = receivers[i]
if (callable(func) and f['func'] == func) or (f['func_name'] == func):
... | python | def unbind(topic, func):
"""
Remove receiver function
"""
if topic in _receivers:
receivers = _receivers[topic]
for i in range(len(receivers)-1, -1, -1):
nice, f = receivers[i]
if (callable(func) and f['func'] == func) or (f['func_name'] == func):
... | [
"def",
"unbind",
"(",
"topic",
",",
"func",
")",
":",
"if",
"topic",
"in",
"_receivers",
":",
"receivers",
"=",
"_receivers",
"[",
"topic",
"]",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"receivers",
")",
"-",
"1",
",",
"-",
"1",
",",
"-",
"1",... | Remove receiver function | [
"Remove",
"receiver",
"function"
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/core/dispatch.py#L54-L64 | train |
limodou/uliweb | uliweb/core/dispatch.py | call | def call(sender, topic, *args, **kwargs):
"""
Invoke receiver functions according topic, it'll invoke receiver functions one by one,
and it'll not return anything, so if you want to return a value, you should
use get function.
"""
if not topic in _receivers:
return
items = _r... | python | def call(sender, topic, *args, **kwargs):
"""
Invoke receiver functions according topic, it'll invoke receiver functions one by one,
and it'll not return anything, so if you want to return a value, you should
use get function.
"""
if not topic in _receivers:
return
items = _r... | [
"def",
"call",
"(",
"sender",
",",
"topic",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"topic",
"in",
"_receivers",
":",
"return",
"items",
"=",
"_receivers",
"[",
"topic",
"]",
"def",
"_cmp",
"(",
"x",
",",
"y",
")",
":",
... | Invoke receiver functions according topic, it'll invoke receiver functions one by one,
and it'll not return anything, so if you want to return a value, you should
use get function. | [
"Invoke",
"receiver",
"functions",
"according",
"topic",
"it",
"ll",
"invoke",
"receiver",
"functions",
"one",
"by",
"one",
"and",
"it",
"ll",
"not",
"return",
"anything",
"so",
"if",
"you",
"want",
"to",
"return",
"a",
"value",
"you",
"should",
"use",
"ge... | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/core/dispatch.py#L82-L118 | train |
limodou/uliweb | uliweb/core/dispatch.py | get | def get(sender, topic, *args, **kwargs):
"""
Invoke receiver functions according topic, it'll invoke receiver functions one by one,
and if one receiver function return non-None value, it'll return it and break
the loop.
"""
if not topic in _receivers:
return
items = _receiver... | python | def get(sender, topic, *args, **kwargs):
"""
Invoke receiver functions according topic, it'll invoke receiver functions one by one,
and if one receiver function return non-None value, it'll return it and break
the loop.
"""
if not topic in _receivers:
return
items = _receiver... | [
"def",
"get",
"(",
"sender",
",",
"topic",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"topic",
"in",
"_receivers",
":",
"return",
"items",
"=",
"_receivers",
"[",
"topic",
"]",
"def",
"_cmp",
"(",
"x",
",",
"y",
")",
":",
... | Invoke receiver functions according topic, it'll invoke receiver functions one by one,
and if one receiver function return non-None value, it'll return it and break
the loop. | [
"Invoke",
"receiver",
"functions",
"according",
"topic",
"it",
"ll",
"invoke",
"receiver",
"functions",
"one",
"by",
"one",
"and",
"if",
"one",
"receiver",
"function",
"return",
"non",
"-",
"None",
"value",
"it",
"ll",
"return",
"it",
"and",
"break",
"the",
... | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/core/dispatch.py#L128-L163 | train |
limodou/uliweb | uliweb/utils/pyini.py | Ini.__read_line | def __read_line(self, f):
"""
Get logic line according the syntax not the physical line
It'll return the line text and if there is identifier existed
return line, bool
"""
g = tokenize.generate_tokens(f.readline)
buf = []
time =... | python | def __read_line(self, f):
"""
Get logic line according the syntax not the physical line
It'll return the line text and if there is identifier existed
return line, bool
"""
g = tokenize.generate_tokens(f.readline)
buf = []
time =... | [
"def",
"__read_line",
"(",
"self",
",",
"f",
")",
":",
"g",
"=",
"tokenize",
".",
"generate_tokens",
"(",
"f",
".",
"readline",
")",
"buf",
"=",
"[",
"]",
"time",
"=",
"0",
"iden_existed",
"=",
"False",
"while",
"1",
":",
"v",
"=",
"g",
".",
"nex... | Get logic line according the syntax not the physical line
It'll return the line text and if there is identifier existed
return line, bool | [
"Get",
"logic",
"line",
"according",
"the",
"syntax",
"not",
"the",
"physical",
"line",
"It",
"ll",
"return",
"the",
"line",
"text",
"and",
"if",
"there",
"is",
"identifier",
"existed",
"return",
"line",
"bool"
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/utils/pyini.py#L611-L638 | train |
limodou/uliweb | uliweb/utils/pyini.py | Ini.freeze | def freeze(self):
"""
Process all EvalValue to real value
"""
self._lazy = False
for k, v in self.items():
if k in self._env:
continue
for _k, _v in v.items():
if isinstance(_v, Lazy):
if self.w... | python | def freeze(self):
"""
Process all EvalValue to real value
"""
self._lazy = False
for k, v in self.items():
if k in self._env:
continue
for _k, _v in v.items():
if isinstance(_v, Lazy):
if self.w... | [
"def",
"freeze",
"(",
"self",
")",
":",
"self",
".",
"_lazy",
"=",
"False",
"for",
"k",
",",
"v",
"in",
"self",
".",
"items",
"(",
")",
":",
"if",
"k",
"in",
"self",
".",
"_env",
":",
"continue",
"for",
"_k",
",",
"_v",
"in",
"v",
".",
"items... | Process all EvalValue to real value | [
"Process",
"all",
"EvalValue",
"to",
"real",
"value"
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/utils/pyini.py#L708-L727 | train |
limodou/uliweb | uliweb/lib/werkzeug/contrib/securecookie.py | SecureCookie.serialize | def serialize(self, expires=None):
"""Serialize the secure cookie into a string.
If expires is provided, the session will be automatically invalidated
after expiration when you unseralize it. This provides better
protection against session cookie theft.
:param expires: an optio... | python | def serialize(self, expires=None):
"""Serialize the secure cookie into a string.
If expires is provided, the session will be automatically invalidated
after expiration when you unseralize it. This provides better
protection against session cookie theft.
:param expires: an optio... | [
"def",
"serialize",
"(",
"self",
",",
"expires",
"=",
"None",
")",
":",
"if",
"self",
".",
"secret_key",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"'no secret key defined'",
")",
"if",
"expires",
":",
"self",
"[",
"'_expires'",
"]",
"=",
"_date_to_u... | Serialize the secure cookie into a string.
If expires is provided, the session will be automatically invalidated
after expiration when you unseralize it. This provides better
protection against session cookie theft.
:param expires: an optional expiration date for the cookie (a
... | [
"Serialize",
"the",
"secure",
"cookie",
"into",
"a",
"string",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/contrib/securecookie.py#L203-L228 | train |
limodou/uliweb | uliweb/lib/werkzeug/contrib/securecookie.py | SecureCookie.unserialize | def unserialize(cls, string, secret_key):
"""Load the secure cookie from a serialized string.
:param string: the cookie value to unserialize.
:param secret_key: the secret key used to serialize the cookie.
:return: a new :class:`SecureCookie`.
"""
if isinstance(string, t... | python | def unserialize(cls, string, secret_key):
"""Load the secure cookie from a serialized string.
:param string: the cookie value to unserialize.
:param secret_key: the secret key used to serialize the cookie.
:return: a new :class:`SecureCookie`.
"""
if isinstance(string, t... | [
"def",
"unserialize",
"(",
"cls",
",",
"string",
",",
"secret_key",
")",
":",
"if",
"isinstance",
"(",
"string",
",",
"text_type",
")",
":",
"string",
"=",
"string",
".",
"encode",
"(",
"'utf-8'",
",",
"'replace'",
")",
"if",
"isinstance",
"(",
"secret_k... | Load the secure cookie from a serialized string.
:param string: the cookie value to unserialize.
:param secret_key: the secret key used to serialize the cookie.
:return: a new :class:`SecureCookie`. | [
"Load",
"the",
"secure",
"cookie",
"from",
"a",
"serialized",
"string",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/contrib/securecookie.py#L231-L283 | train |
limodou/uliweb | uliweb/contrib/model_config/__init__.py | find_model | def find_model(sender, model_name):
"""
Register new model to ORM
"""
MC = get_mc()
model = MC.get((MC.c.model_name==model_name) & (MC.c.uuid!=''))
if model:
model_inst = model.get_instance()
orm.set_model(model_name, model_inst.table_name, appname=__name__, model_path='')
... | python | def find_model(sender, model_name):
"""
Register new model to ORM
"""
MC = get_mc()
model = MC.get((MC.c.model_name==model_name) & (MC.c.uuid!=''))
if model:
model_inst = model.get_instance()
orm.set_model(model_name, model_inst.table_name, appname=__name__, model_path='')
... | [
"def",
"find_model",
"(",
"sender",
",",
"model_name",
")",
":",
"MC",
"=",
"get_mc",
"(",
")",
"model",
"=",
"MC",
".",
"get",
"(",
"(",
"MC",
".",
"c",
".",
"model_name",
"==",
"model_name",
")",
"&",
"(",
"MC",
".",
"c",
".",
"uuid",
"!=",
"... | Register new model to ORM | [
"Register",
"new",
"model",
"to",
"ORM"
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/contrib/model_config/__init__.py#L20-L29 | train |
limodou/uliweb | uliweb/contrib/model_config/__init__.py | get_model_fields | def get_model_fields(model, add_reserver_flag=True):
"""
Creating fields suit for model_config , id will be skipped.
"""
import uliweb.orm as orm
fields = []
m = {'type':'type_name', 'hint':'hint',
'default':'default', 'required':'required'}
m1 = {'index':'index', 'unique':'unique'... | python | def get_model_fields(model, add_reserver_flag=True):
"""
Creating fields suit for model_config , id will be skipped.
"""
import uliweb.orm as orm
fields = []
m = {'type':'type_name', 'hint':'hint',
'default':'default', 'required':'required'}
m1 = {'index':'index', 'unique':'unique'... | [
"def",
"get_model_fields",
"(",
"model",
",",
"add_reserver_flag",
"=",
"True",
")",
":",
"import",
"uliweb",
".",
"orm",
"as",
"orm",
"fields",
"=",
"[",
"]",
"m",
"=",
"{",
"'type'",
":",
"'type_name'",
",",
"'hint'",
":",
"'hint'",
",",
"'default'",
... | Creating fields suit for model_config , id will be skipped. | [
"Creating",
"fields",
"suit",
"for",
"model_config",
"id",
"will",
"be",
"skipped",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/contrib/model_config/__init__.py#L69-L100 | train |
limodou/uliweb | uliweb/contrib/model_config/__init__.py | get_model_indexes | def get_model_indexes(model, add_reserver_flag=True):
"""
Creating indexes suit for model_config.
"""
import uliweb.orm as orm
from sqlalchemy.engine.reflection import Inspector
indexes = []
engine = model.get_engine().engine
insp = Inspector.from_engine(engine)
for index in insp.ge... | python | def get_model_indexes(model, add_reserver_flag=True):
"""
Creating indexes suit for model_config.
"""
import uliweb.orm as orm
from sqlalchemy.engine.reflection import Inspector
indexes = []
engine = model.get_engine().engine
insp = Inspector.from_engine(engine)
for index in insp.ge... | [
"def",
"get_model_indexes",
"(",
"model",
",",
"add_reserver_flag",
"=",
"True",
")",
":",
"import",
"uliweb",
".",
"orm",
"as",
"orm",
"from",
"sqlalchemy",
".",
"engine",
".",
"reflection",
"import",
"Inspector",
"indexes",
"=",
"[",
"]",
"engine",
"=",
... | Creating indexes suit for model_config. | [
"Creating",
"indexes",
"suit",
"for",
"model_config",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/contrib/model_config/__init__.py#L102-L121 | train |
limodou/uliweb | uliweb/utils/timeit.py | timeit | def timeit(output):
"""
If output is string, then print the string and also time used
"""
b = time.time()
yield
print output, 'time used: %.3fs' % (time.time()-b) | python | def timeit(output):
"""
If output is string, then print the string and also time used
"""
b = time.time()
yield
print output, 'time used: %.3fs' % (time.time()-b) | [
"def",
"timeit",
"(",
"output",
")",
":",
"b",
"=",
"time",
".",
"time",
"(",
")",
"yield",
"print",
"output",
",",
"'time used: %.3fs'",
"%",
"(",
"time",
".",
"time",
"(",
")",
"-",
"b",
")"
] | If output is string, then print the string and also time used | [
"If",
"output",
"is",
"string",
"then",
"print",
"the",
"string",
"and",
"also",
"time",
"used"
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/utils/timeit.py#L5-L11 | train |
limodou/uliweb | uliweb/lib/werkzeug/wsgi.py | host_is_trusted | def host_is_trusted(hostname, trusted_list):
"""Checks if a host is trusted against a list. This also takes care
of port normalization.
.. versionadded:: 0.9
:param hostname: the hostname to check
:param trusted_list: a list of hostnames to check against. If a
hostname s... | python | def host_is_trusted(hostname, trusted_list):
"""Checks if a host is trusted against a list. This also takes care
of port normalization.
.. versionadded:: 0.9
:param hostname: the hostname to check
:param trusted_list: a list of hostnames to check against. If a
hostname s... | [
"def",
"host_is_trusted",
"(",
"hostname",
",",
"trusted_list",
")",
":",
"if",
"not",
"hostname",
":",
"return",
"False",
"if",
"isinstance",
"(",
"trusted_list",
",",
"string_types",
")",
":",
"trusted_list",
"=",
"[",
"trusted_list",
"]",
"def",
"_normalize... | Checks if a host is trusted against a list. This also takes care
of port normalization.
.. versionadded:: 0.9
:param hostname: the hostname to check
:param trusted_list: a list of hostnames to check against. If a
hostname starts with a dot it will match against
... | [
"Checks",
"if",
"a",
"host",
"is",
"trusted",
"against",
"a",
"list",
".",
"This",
"also",
"takes",
"care",
"of",
"port",
"normalization",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/wsgi.py#L85-L119 | train |
limodou/uliweb | uliweb/lib/werkzeug/wsgi.py | get_content_length | def get_content_length(environ):
"""Returns the content length from the WSGI environment as
integer. If it's not available `None` is returned.
.. versionadded:: 0.9
:param environ: the WSGI environ to fetch the content length from.
"""
content_length = environ.get('CONTENT_LENGTH')
if con... | python | def get_content_length(environ):
"""Returns the content length from the WSGI environment as
integer. If it's not available `None` is returned.
.. versionadded:: 0.9
:param environ: the WSGI environ to fetch the content length from.
"""
content_length = environ.get('CONTENT_LENGTH')
if con... | [
"def",
"get_content_length",
"(",
"environ",
")",
":",
"content_length",
"=",
"environ",
".",
"get",
"(",
"'CONTENT_LENGTH'",
")",
"if",
"content_length",
"is",
"not",
"None",
":",
"try",
":",
"return",
"max",
"(",
"0",
",",
"int",
"(",
"content_length",
"... | Returns the content length from the WSGI environment as
integer. If it's not available `None` is returned.
.. versionadded:: 0.9
:param environ: the WSGI environ to fetch the content length from. | [
"Returns",
"the",
"content",
"length",
"from",
"the",
"WSGI",
"environment",
"as",
"integer",
".",
"If",
"it",
"s",
"not",
"available",
"None",
"is",
"returned",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/wsgi.py#L148-L161 | train |
limodou/uliweb | uliweb/lib/werkzeug/wsgi.py | get_input_stream | def get_input_stream(environ, safe_fallback=True):
"""Returns the input stream from the WSGI environment and wraps it
in the most sensible way possible. The stream returned is not the
raw WSGI stream in most cases but one that is safe to read from
without taking into account the content length.
..... | python | def get_input_stream(environ, safe_fallback=True):
"""Returns the input stream from the WSGI environment and wraps it
in the most sensible way possible. The stream returned is not the
raw WSGI stream in most cases but one that is safe to read from
without taking into account the content length.
..... | [
"def",
"get_input_stream",
"(",
"environ",
",",
"safe_fallback",
"=",
"True",
")",
":",
"stream",
"=",
"environ",
"[",
"'wsgi.input'",
"]",
"content_length",
"=",
"get_content_length",
"(",
"environ",
")",
"# A wsgi extension that tells us if the input is terminated. In"... | Returns the input stream from the WSGI environment and wraps it
in the most sensible way possible. The stream returned is not the
raw WSGI stream in most cases but one that is safe to read from
without taking into account the content length.
.. versionadded:: 0.9
:param environ: the WSGI environ ... | [
"Returns",
"the",
"input",
"stream",
"from",
"the",
"WSGI",
"environment",
"and",
"wraps",
"it",
"in",
"the",
"most",
"sensible",
"way",
"possible",
".",
"The",
"stream",
"returned",
"is",
"not",
"the",
"raw",
"WSGI",
"stream",
"in",
"most",
"cases",
"but"... | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/wsgi.py#L164-L195 | train |
limodou/uliweb | uliweb/lib/werkzeug/wsgi.py | get_path_info | def get_path_info(environ, charset='utf-8', errors='replace'):
"""Returns the `PATH_INFO` from the WSGI environment and properly
decodes it. This also takes care about the WSGI decoding dance
on Python 3 environments. if the `charset` is set to `None` a
bytestring is returned.
.. versionadded:: 0... | python | def get_path_info(environ, charset='utf-8', errors='replace'):
"""Returns the `PATH_INFO` from the WSGI environment and properly
decodes it. This also takes care about the WSGI decoding dance
on Python 3 environments. if the `charset` is set to `None` a
bytestring is returned.
.. versionadded:: 0... | [
"def",
"get_path_info",
"(",
"environ",
",",
"charset",
"=",
"'utf-8'",
",",
"errors",
"=",
"'replace'",
")",
":",
"path",
"=",
"wsgi_get_bytes",
"(",
"environ",
".",
"get",
"(",
"'PATH_INFO'",
",",
"''",
")",
")",
"return",
"to_unicode",
"(",
"path",
",... | Returns the `PATH_INFO` from the WSGI environment and properly
decodes it. This also takes care about the WSGI decoding dance
on Python 3 environments. if the `charset` is set to `None` a
bytestring is returned.
.. versionadded:: 0.9
:param environ: the WSGI environment object to get the path fr... | [
"Returns",
"the",
"PATH_INFO",
"from",
"the",
"WSGI",
"environment",
"and",
"properly",
"decodes",
"it",
".",
"This",
"also",
"takes",
"care",
"about",
"the",
"WSGI",
"decoding",
"dance",
"on",
"Python",
"3",
"environments",
".",
"if",
"the",
"charset",
"is"... | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/wsgi.py#L215-L229 | train |
limodou/uliweb | uliweb/lib/werkzeug/wsgi.py | pop_path_info | def pop_path_info(environ, charset='utf-8', errors='replace'):
"""Removes and returns the next segment of `PATH_INFO`, pushing it onto
`SCRIPT_NAME`. Returns `None` if there is nothing left on `PATH_INFO`.
If the `charset` is set to `None` a bytestring is returned.
If there are empty segments (``'/fo... | python | def pop_path_info(environ, charset='utf-8', errors='replace'):
"""Removes and returns the next segment of `PATH_INFO`, pushing it onto
`SCRIPT_NAME`. Returns `None` if there is nothing left on `PATH_INFO`.
If the `charset` is set to `None` a bytestring is returned.
If there are empty segments (``'/fo... | [
"def",
"pop_path_info",
"(",
"environ",
",",
"charset",
"=",
"'utf-8'",
",",
"errors",
"=",
"'replace'",
")",
":",
"path",
"=",
"environ",
".",
"get",
"(",
"'PATH_INFO'",
")",
"if",
"not",
"path",
":",
"return",
"None",
"script_name",
"=",
"environ",
"."... | Removes and returns the next segment of `PATH_INFO`, pushing it onto
`SCRIPT_NAME`. Returns `None` if there is nothing left on `PATH_INFO`.
If the `charset` is set to `None` a bytestring is returned.
If there are empty segments (``'/foo//bar``) these are ignored but
properly pushed to the `SCRIPT_NAM... | [
"Removes",
"and",
"returns",
"the",
"next",
"segment",
"of",
"PATH_INFO",
"pushing",
"it",
"onto",
"SCRIPT_NAME",
".",
"Returns",
"None",
"if",
"there",
"is",
"nothing",
"left",
"on",
"PATH_INFO",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/wsgi.py#L249-L298 | train |
limodou/uliweb | uliweb/lib/werkzeug/wsgi.py | _make_chunk_iter | def _make_chunk_iter(stream, limit, buffer_size):
"""Helper for the line and chunk iter functions."""
if isinstance(stream, (bytes, bytearray, text_type)):
raise TypeError('Passed a string or byte object instead of '
'true iterator or stream.')
if not hasattr(stream, 'read'):... | python | def _make_chunk_iter(stream, limit, buffer_size):
"""Helper for the line and chunk iter functions."""
if isinstance(stream, (bytes, bytearray, text_type)):
raise TypeError('Passed a string or byte object instead of '
'true iterator or stream.')
if not hasattr(stream, 'read'):... | [
"def",
"_make_chunk_iter",
"(",
"stream",
",",
"limit",
",",
"buffer_size",
")",
":",
"if",
"isinstance",
"(",
"stream",
",",
"(",
"bytes",
",",
"bytearray",
",",
"text_type",
")",
")",
":",
"raise",
"TypeError",
"(",
"'Passed a string or byte object instead of ... | Helper for the line and chunk iter functions. | [
"Helper",
"for",
"the",
"line",
"and",
"chunk",
"iter",
"functions",
"."
] | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/wsgi.py#L745-L762 | train |
limodou/uliweb | uliweb/contrib/soap/__init__.py | soap | def soap(func=None, name=None, returns=None, args=None, doc=None, target='SOAP'):
"""
soap supports multiple SOAP function collections, it'll save functions to
target dict, and you can give other target, but it should be keep up with
SoapView.target definition.
"""
global __soap_functions__
... | python | def soap(func=None, name=None, returns=None, args=None, doc=None, target='SOAP'):
"""
soap supports multiple SOAP function collections, it'll save functions to
target dict, and you can give other target, but it should be keep up with
SoapView.target definition.
"""
global __soap_functions__
... | [
"def",
"soap",
"(",
"func",
"=",
"None",
",",
"name",
"=",
"None",
",",
"returns",
"=",
"None",
",",
"args",
"=",
"None",
",",
"doc",
"=",
"None",
",",
"target",
"=",
"'SOAP'",
")",
":",
"global",
"__soap_functions__",
"returns",
"=",
"_fix_soap_kwargs... | soap supports multiple SOAP function collections, it'll save functions to
target dict, and you can give other target, but it should be keep up with
SoapView.target definition. | [
"soap",
"supports",
"multiple",
"SOAP",
"function",
"collections",
"it",
"ll",
"save",
"functions",
"to",
"target",
"dict",
"and",
"you",
"can",
"give",
"other",
"target",
"but",
"it",
"should",
"be",
"keep",
"up",
"with",
"SoapView",
".",
"target",
"definit... | 34472f25e4bc0b954a35346672f94e84ef18b076 | https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/contrib/soap/__init__.py#L27-L68 | train |
adamhajari/spyre | spyre/server.py | App.getJsonData | def getJsonData(self, params):
"""turns the DataFrame returned by getData into a dictionary
arguments:
the params passed used for table or d3 outputs are forwarded on to getData
"""
try:
return eval("self." + str(params['output_id']) + "(params)")
except Attr... | python | def getJsonData(self, params):
"""turns the DataFrame returned by getData into a dictionary
arguments:
the params passed used for table or d3 outputs are forwarded on to getData
"""
try:
return eval("self." + str(params['output_id']) + "(params)")
except Attr... | [
"def",
"getJsonData",
"(",
"self",
",",
"params",
")",
":",
"try",
":",
"return",
"eval",
"(",
"\"self.\"",
"+",
"str",
"(",
"params",
"[",
"'output_id'",
"]",
")",
"+",
"\"(params)\"",
")",
"except",
"AttributeError",
":",
"df",
"=",
"self",
".",
"get... | turns the DataFrame returned by getData into a dictionary
arguments:
the params passed used for table or d3 outputs are forwarded on to getData | [
"turns",
"the",
"DataFrame",
"returned",
"by",
"getData",
"into",
"a",
"dictionary"
] | 5dd9f6de072e99af636ab7e7393d249761c56e69 | https://github.com/adamhajari/spyre/blob/5dd9f6de072e99af636ab7e7393d249761c56e69/spyre/server.py#L330-L342 | train |
adamhajari/spyre | spyre/server.py | App.launch_in_notebook | def launch_in_notebook(self, port=9095, width=900, height=600):
"""launch the app within an iframe in ipython notebook"""
from IPython.lib import backgroundjobs as bg
from IPython.display import HTML
jobs = bg.BackgroundJobManager()
jobs.new(self.launch, kw=dict(port=port))
... | python | def launch_in_notebook(self, port=9095, width=900, height=600):
"""launch the app within an iframe in ipython notebook"""
from IPython.lib import backgroundjobs as bg
from IPython.display import HTML
jobs = bg.BackgroundJobManager()
jobs.new(self.launch, kw=dict(port=port))
... | [
"def",
"launch_in_notebook",
"(",
"self",
",",
"port",
"=",
"9095",
",",
"width",
"=",
"900",
",",
"height",
"=",
"600",
")",
":",
"from",
"IPython",
".",
"lib",
"import",
"backgroundjobs",
"as",
"bg",
"from",
"IPython",
".",
"display",
"import",
"HTML",... | launch the app within an iframe in ipython notebook | [
"launch",
"the",
"app",
"within",
"an",
"iframe",
"in",
"ipython",
"notebook"
] | 5dd9f6de072e99af636ab7e7393d249761c56e69 | https://github.com/adamhajari/spyre/blob/5dd9f6de072e99af636ab7e7393d249761c56e69/spyre/server.py#L469-L480 | train |
adamhajari/spyre | spyre/server.py | Site.launch | def launch(self, host="local", port=8080):
"""Calling the Launch method on a Site object will serve the top
node of the cherrypy Root object tree"""
# Need to add in the appbar if many apps
self.root.templateVars['app_bar'] = self.site_app_bar
for fullRoute, _ in self.site_a... | python | def launch(self, host="local", port=8080):
"""Calling the Launch method on a Site object will serve the top
node of the cherrypy Root object tree"""
# Need to add in the appbar if many apps
self.root.templateVars['app_bar'] = self.site_app_bar
for fullRoute, _ in self.site_a... | [
"def",
"launch",
"(",
"self",
",",
"host",
"=",
"\"local\"",
",",
"port",
"=",
"8080",
")",
":",
"# Need to add in the appbar if many apps",
"self",
".",
"root",
".",
"templateVars",
"[",
"'app_bar'",
"]",
"=",
"self",
".",
"site_app_bar",
"for",
"fullRoute",
... | Calling the Launch method on a Site object will serve the top
node of the cherrypy Root object tree | [
"Calling",
"the",
"Launch",
"method",
"on",
"a",
"Site",
"object",
"will",
"serve",
"the",
"top",
"node",
"of",
"the",
"cherrypy",
"Root",
"object",
"tree"
] | 5dd9f6de072e99af636ab7e7393d249761c56e69 | https://github.com/adamhajari/spyre/blob/5dd9f6de072e99af636ab7e7393d249761c56e69/spyre/server.py#L552-L565 | train |
googlefonts/fontmake | Lib/fontmake/__main__.py | exclude_args | def exclude_args(parser, args, excluded_args, target):
"""Delete options that are not appropriate for a following code path; exit
with an error if excluded options were passed in by the user.
argparse generates a namespace with all options it knows, but not every
attribute should be passed to all code ... | python | def exclude_args(parser, args, excluded_args, target):
"""Delete options that are not appropriate for a following code path; exit
with an error if excluded options were passed in by the user.
argparse generates a namespace with all options it knows, but not every
attribute should be passed to all code ... | [
"def",
"exclude_args",
"(",
"parser",
",",
"args",
",",
"excluded_args",
",",
"target",
")",
":",
"msg",
"=",
"'\"%s\" option invalid for %s'",
"for",
"argname",
"in",
"excluded_args",
":",
"if",
"argname",
"not",
"in",
"args",
":",
"continue",
"if",
"args",
... | Delete options that are not appropriate for a following code path; exit
with an error if excluded options were passed in by the user.
argparse generates a namespace with all options it knows, but not every
attribute should be passed to all code paths (i.e. options about
interpolation should not reach `... | [
"Delete",
"options",
"that",
"are",
"not",
"appropriate",
"for",
"a",
"following",
"code",
"path",
";",
"exit",
"with",
"an",
"error",
"if",
"excluded",
"options",
"were",
"passed",
"in",
"by",
"the",
"user",
"."
] | b611baf49929575c2a30fd18662055365219ce2d | https://github.com/googlefonts/fontmake/blob/b611baf49929575c2a30fd18662055365219ce2d/Lib/fontmake/__main__.py#L42-L60 | train |
googlefonts/fontmake | Lib/fontmake/font_project.py | _varLib_finder | def _varLib_finder(source, directory="", ext="ttf"):
"""Finder function to be used with varLib.build to find master TTFs given
the filename of the source UFO master as specified in the designspace.
It replaces the UFO directory with the one specified in 'directory'
argument, and replaces the file extens... | python | def _varLib_finder(source, directory="", ext="ttf"):
"""Finder function to be used with varLib.build to find master TTFs given
the filename of the source UFO master as specified in the designspace.
It replaces the UFO directory with the one specified in 'directory'
argument, and replaces the file extens... | [
"def",
"_varLib_finder",
"(",
"source",
",",
"directory",
"=",
"\"\"",
",",
"ext",
"=",
"\"ttf\"",
")",
":",
"fname",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"os",
".",
"path",
".",
"basename",
"(",
"source",
")",
")",
"[",
"0",
"]",
"+",
"... | Finder function to be used with varLib.build to find master TTFs given
the filename of the source UFO master as specified in the designspace.
It replaces the UFO directory with the one specified in 'directory'
argument, and replaces the file extension with 'ext'. | [
"Finder",
"function",
"to",
"be",
"used",
"with",
"varLib",
".",
"build",
"to",
"find",
"master",
"TTFs",
"given",
"the",
"filename",
"of",
"the",
"source",
"UFO",
"master",
"as",
"specified",
"in",
"the",
"designspace",
".",
"It",
"replaces",
"the",
"UFO"... | b611baf49929575c2a30fd18662055365219ce2d | https://github.com/googlefonts/fontmake/blob/b611baf49929575c2a30fd18662055365219ce2d/Lib/fontmake/font_project.py#L1158-L1165 | train |
googlefonts/fontmake | Lib/fontmake/font_project.py | FontProject.build_master_ufos | def build_master_ufos(
self,
glyphs_path,
designspace_path=None,
master_dir=None,
instance_dir=None,
family_name=None,
mti_source=None,
):
"""Build UFOs and MutatorMath designspace from Glyphs source."""
import glyphsLib
if master_dir ... | python | def build_master_ufos(
self,
glyphs_path,
designspace_path=None,
master_dir=None,
instance_dir=None,
family_name=None,
mti_source=None,
):
"""Build UFOs and MutatorMath designspace from Glyphs source."""
import glyphsLib
if master_dir ... | [
"def",
"build_master_ufos",
"(",
"self",
",",
"glyphs_path",
",",
"designspace_path",
"=",
"None",
",",
"master_dir",
"=",
"None",
",",
"instance_dir",
"=",
"None",
",",
"family_name",
"=",
"None",
",",
"mti_source",
"=",
"None",
",",
")",
":",
"import",
"... | Build UFOs and MutatorMath designspace from Glyphs source. | [
"Build",
"UFOs",
"and",
"MutatorMath",
"designspace",
"from",
"Glyphs",
"source",
"."
] | b611baf49929575c2a30fd18662055365219ce2d | https://github.com/googlefonts/fontmake/blob/b611baf49929575c2a30fd18662055365219ce2d/Lib/fontmake/font_project.py#L110-L163 | train |
googlefonts/fontmake | Lib/fontmake/font_project.py | FontProject.remove_overlaps | def remove_overlaps(self, ufos, glyph_filter=lambda g: len(g)):
"""Remove overlaps in UFOs' glyphs' contours."""
from booleanOperations import union, BooleanOperationsError
for ufo in ufos:
font_name = self._font_name(ufo)
logger.info("Removing overlaps for " + font_name... | python | def remove_overlaps(self, ufos, glyph_filter=lambda g: len(g)):
"""Remove overlaps in UFOs' glyphs' contours."""
from booleanOperations import union, BooleanOperationsError
for ufo in ufos:
font_name = self._font_name(ufo)
logger.info("Removing overlaps for " + font_name... | [
"def",
"remove_overlaps",
"(",
"self",
",",
"ufos",
",",
"glyph_filter",
"=",
"lambda",
"g",
":",
"len",
"(",
"g",
")",
")",
":",
"from",
"booleanOperations",
"import",
"union",
",",
"BooleanOperationsError",
"for",
"ufo",
"in",
"ufos",
":",
"font_name",
"... | Remove overlaps in UFOs' glyphs' contours. | [
"Remove",
"overlaps",
"in",
"UFOs",
"glyphs",
"contours",
"."
] | b611baf49929575c2a30fd18662055365219ce2d | https://github.com/googlefonts/fontmake/blob/b611baf49929575c2a30fd18662055365219ce2d/Lib/fontmake/font_project.py#L187-L205 | train |
googlefonts/fontmake | Lib/fontmake/font_project.py | FontProject.decompose_glyphs | def decompose_glyphs(self, ufos, glyph_filter=lambda g: True):
"""Move components of UFOs' glyphs to their outlines."""
for ufo in ufos:
logger.info("Decomposing glyphs for " + self._font_name(ufo))
for glyph in ufo:
if not glyph.components or not glyph_filter(gl... | python | def decompose_glyphs(self, ufos, glyph_filter=lambda g: True):
"""Move components of UFOs' glyphs to their outlines."""
for ufo in ufos:
logger.info("Decomposing glyphs for " + self._font_name(ufo))
for glyph in ufo:
if not glyph.components or not glyph_filter(gl... | [
"def",
"decompose_glyphs",
"(",
"self",
",",
"ufos",
",",
"glyph_filter",
"=",
"lambda",
"g",
":",
"True",
")",
":",
"for",
"ufo",
"in",
"ufos",
":",
"logger",
".",
"info",
"(",
"\"Decomposing glyphs for \"",
"+",
"self",
".",
"_font_name",
"(",
"ufo",
"... | Move components of UFOs' glyphs to their outlines. | [
"Move",
"components",
"of",
"UFOs",
"glyphs",
"to",
"their",
"outlines",
"."
] | b611baf49929575c2a30fd18662055365219ce2d | https://github.com/googlefonts/fontmake/blob/b611baf49929575c2a30fd18662055365219ce2d/Lib/fontmake/font_project.py#L209-L218 | train |
googlefonts/fontmake | Lib/fontmake/font_project.py | FontProject.build_ttfs | def build_ttfs(self, ufos, **kwargs):
"""Build OpenType binaries with TrueType outlines."""
self.save_otfs(ufos, ttf=True, **kwargs) | python | def build_ttfs(self, ufos, **kwargs):
"""Build OpenType binaries with TrueType outlines."""
self.save_otfs(ufos, ttf=True, **kwargs) | [
"def",
"build_ttfs",
"(",
"self",
",",
"ufos",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"save_otfs",
"(",
"ufos",
",",
"ttf",
"=",
"True",
",",
"*",
"*",
"kwargs",
")"
] | Build OpenType binaries with TrueType outlines. | [
"Build",
"OpenType",
"binaries",
"with",
"TrueType",
"outlines",
"."
] | b611baf49929575c2a30fd18662055365219ce2d | https://github.com/googlefonts/fontmake/blob/b611baf49929575c2a30fd18662055365219ce2d/Lib/fontmake/font_project.py#L271-L273 | train |
googlefonts/fontmake | Lib/fontmake/font_project.py | FontProject.build_variable_font | def build_variable_font(
self,
designspace,
output_path=None,
output_dir=None,
master_bin_dir=None,
ttf=True,
):
"""Build OpenType variable font from masters in a designspace."""
assert not (output_path and output_dir), "mutually exclusive args"
... | python | def build_variable_font(
self,
designspace,
output_path=None,
output_dir=None,
master_bin_dir=None,
ttf=True,
):
"""Build OpenType variable font from masters in a designspace."""
assert not (output_path and output_dir), "mutually exclusive args"
... | [
"def",
"build_variable_font",
"(",
"self",
",",
"designspace",
",",
"output_path",
"=",
"None",
",",
"output_dir",
"=",
"None",
",",
"master_bin_dir",
"=",
"None",
",",
"ttf",
"=",
"True",
",",
")",
":",
"assert",
"not",
"(",
"output_path",
"and",
"output_... | Build OpenType variable font from masters in a designspace. | [
"Build",
"OpenType",
"variable",
"font",
"from",
"masters",
"in",
"a",
"designspace",
"."
] | b611baf49929575c2a30fd18662055365219ce2d | https://github.com/googlefonts/fontmake/blob/b611baf49929575c2a30fd18662055365219ce2d/Lib/fontmake/font_project.py#L341-L377 | train |
googlefonts/fontmake | Lib/fontmake/font_project.py | FontProject.subset_otf_from_ufo | def subset_otf_from_ufo(self, otf_path, ufo):
"""Subset a font using export flags set by glyphsLib.
There are two more settings that can change export behavior:
"Export Glyphs" and "Remove Glyphs", which are currently not supported
for complexity reasons. See
https://github.com/... | python | def subset_otf_from_ufo(self, otf_path, ufo):
"""Subset a font using export flags set by glyphsLib.
There are two more settings that can change export behavior:
"Export Glyphs" and "Remove Glyphs", which are currently not supported
for complexity reasons. See
https://github.com/... | [
"def",
"subset_otf_from_ufo",
"(",
"self",
",",
"otf_path",
",",
"ufo",
")",
":",
"from",
"fontTools",
"import",
"subset",
"# ufo2ft always inserts a \".notdef\" glyph as the first glyph",
"ufo_order",
"=",
"makeOfficialGlyphOrder",
"(",
"ufo",
")",
"if",
"\".notdef\"",
... | Subset a font using export flags set by glyphsLib.
There are two more settings that can change export behavior:
"Export Glyphs" and "Remove Glyphs", which are currently not supported
for complexity reasons. See
https://github.com/googlei18n/glyphsLib/issues/295. | [
"Subset",
"a",
"font",
"using",
"export",
"flags",
"set",
"by",
"glyphsLib",
"."
] | b611baf49929575c2a30fd18662055365219ce2d | https://github.com/googlefonts/fontmake/blob/b611baf49929575c2a30fd18662055365219ce2d/Lib/fontmake/font_project.py#L625-L680 | train |
googlefonts/fontmake | Lib/fontmake/font_project.py | FontProject.run_from_glyphs | def run_from_glyphs(
self,
glyphs_path,
designspace_path=None,
master_dir=None,
instance_dir=None,
family_name=None,
mti_source=None,
**kwargs
):
"""Run toolchain from Glyphs source.
Args:
glyphs_path: Path to source file.
... | python | def run_from_glyphs(
self,
glyphs_path,
designspace_path=None,
master_dir=None,
instance_dir=None,
family_name=None,
mti_source=None,
**kwargs
):
"""Run toolchain from Glyphs source.
Args:
glyphs_path: Path to source file.
... | [
"def",
"run_from_glyphs",
"(",
"self",
",",
"glyphs_path",
",",
"designspace_path",
"=",
"None",
",",
"master_dir",
"=",
"None",
",",
"instance_dir",
"=",
"None",
",",
"family_name",
"=",
"None",
",",
"mti_source",
"=",
"None",
",",
"*",
"*",
"kwargs",
")"... | Run toolchain from Glyphs source.
Args:
glyphs_path: Path to source file.
designspace_path: Output path of generated designspace document.
By default it's "<family_name>[-<base_style>].designspace".
master_dir: Directory where to save UFO masters (default:
... | [
"Run",
"toolchain",
"from",
"Glyphs",
"source",
"."
] | b611baf49929575c2a30fd18662055365219ce2d | https://github.com/googlefonts/fontmake/blob/b611baf49929575c2a30fd18662055365219ce2d/Lib/fontmake/font_project.py#L682-L719 | train |
googlefonts/fontmake | Lib/fontmake/font_project.py | FontProject.interpolate_instance_ufos | def interpolate_instance_ufos(
self,
designspace,
include=None,
round_instances=False,
expand_features_to_instances=False,
):
"""Interpolate master UFOs with MutatorMath and return instance UFOs.
Args:
designspace: a DesignSpaceDocument object con... | python | def interpolate_instance_ufos(
self,
designspace,
include=None,
round_instances=False,
expand_features_to_instances=False,
):
"""Interpolate master UFOs with MutatorMath and return instance UFOs.
Args:
designspace: a DesignSpaceDocument object con... | [
"def",
"interpolate_instance_ufos",
"(",
"self",
",",
"designspace",
",",
"include",
"=",
"None",
",",
"round_instances",
"=",
"False",
",",
"expand_features_to_instances",
"=",
"False",
",",
")",
":",
"from",
"glyphsLib",
".",
"interpolation",
"import",
"apply_in... | Interpolate master UFOs with MutatorMath and return instance UFOs.
Args:
designspace: a DesignSpaceDocument object containing sources and
instances.
include (str): optional regular expression pattern to match the
DS instance 'name' attribute and only inte... | [
"Interpolate",
"master",
"UFOs",
"with",
"MutatorMath",
"and",
"return",
"instance",
"UFOs",
"."
] | b611baf49929575c2a30fd18662055365219ce2d | https://github.com/googlefonts/fontmake/blob/b611baf49929575c2a30fd18662055365219ce2d/Lib/fontmake/font_project.py#L721-L789 | train |
googlefonts/fontmake | Lib/fontmake/font_project.py | FontProject.run_from_ufos | def run_from_ufos(self, ufos, output=(), **kwargs):
"""Run toolchain from UFO sources.
Args:
ufos: List of UFO sources, as either paths or opened objects.
output: List of output formats to generate.
kwargs: Arguments passed along to save_otfs.
"""
if... | python | def run_from_ufos(self, ufos, output=(), **kwargs):
"""Run toolchain from UFO sources.
Args:
ufos: List of UFO sources, as either paths or opened objects.
output: List of output formats to generate.
kwargs: Arguments passed along to save_otfs.
"""
if... | [
"def",
"run_from_ufos",
"(",
"self",
",",
"ufos",
",",
"output",
"=",
"(",
")",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"set",
"(",
"output",
")",
"==",
"{",
"\"ufo\"",
"}",
":",
"return",
"# the `ufos` parameter can be a list of UFO objects",
"# or it can ... | Run toolchain from UFO sources.
Args:
ufos: List of UFO sources, as either paths or opened objects.
output: List of output formats to generate.
kwargs: Arguments passed along to save_otfs. | [
"Run",
"toolchain",
"from",
"UFO",
"sources",
"."
] | b611baf49929575c2a30fd18662055365219ce2d | https://github.com/googlefonts/fontmake/blob/b611baf49929575c2a30fd18662055365219ce2d/Lib/fontmake/font_project.py#L943-L981 | train |
googlefonts/fontmake | Lib/fontmake/font_project.py | FontProject._font_name | def _font_name(self, ufo):
"""Generate a postscript-style font name."""
family_name = (
ufo.info.familyName.replace(" ", "")
if ufo.info.familyName is not None
else "None"
)
style_name = (
ufo.info.styleName.replace(" ", "")
if ... | python | def _font_name(self, ufo):
"""Generate a postscript-style font name."""
family_name = (
ufo.info.familyName.replace(" ", "")
if ufo.info.familyName is not None
else "None"
)
style_name = (
ufo.info.styleName.replace(" ", "")
if ... | [
"def",
"_font_name",
"(",
"self",
",",
"ufo",
")",
":",
"family_name",
"=",
"(",
"ufo",
".",
"info",
".",
"familyName",
".",
"replace",
"(",
"\" \"",
",",
"\"\"",
")",
"if",
"ufo",
".",
"info",
".",
"familyName",
"is",
"not",
"None",
"else",
"\"None\... | Generate a postscript-style font name. | [
"Generate",
"a",
"postscript",
"-",
"style",
"font",
"name",
"."
] | b611baf49929575c2a30fd18662055365219ce2d | https://github.com/googlefonts/fontmake/blob/b611baf49929575c2a30fd18662055365219ce2d/Lib/fontmake/font_project.py#L994-L1006 | train |
googlefonts/fontmake | Lib/fontmake/font_project.py | FontProject._output_dir | def _output_dir(
self,
ext,
is_instance=False,
interpolatable=False,
autohinted=False,
is_variable=False,
):
"""Generate an output directory.
Args:
ext: extension string.
is_instance: The output is instance font or ... | python | def _output_dir(
self,
ext,
is_instance=False,
interpolatable=False,
autohinted=False,
is_variable=False,
):
"""Generate an output directory.
Args:
ext: extension string.
is_instance: The output is instance font or ... | [
"def",
"_output_dir",
"(",
"self",
",",
"ext",
",",
"is_instance",
"=",
"False",
",",
"interpolatable",
"=",
"False",
",",
"autohinted",
"=",
"False",
",",
"is_variable",
"=",
"False",
",",
")",
":",
"assert",
"not",
"(",
"is_variable",
"and",
"any",
"("... | Generate an output directory.
Args:
ext: extension string.
is_instance: The output is instance font or not.
interpolatable: The output is interpolatable or not.
autohinted: The output is autohinted or not.
is_variable: The outp... | [
"Generate",
"an",
"output",
"directory",
"."
] | b611baf49929575c2a30fd18662055365219ce2d | https://github.com/googlefonts/fontmake/blob/b611baf49929575c2a30fd18662055365219ce2d/Lib/fontmake/font_project.py#L1008-L1040 | train |
googlefonts/fontmake | Lib/fontmake/font_project.py | FontProject._output_path | def _output_path(
self,
ufo_or_font_name,
ext,
is_instance=False,
interpolatable=False,
autohinted=False,
is_variable=False,
output_dir=None,
suffix=None,
):
"""Generate output path for a font file with given extension."""
if i... | python | def _output_path(
self,
ufo_or_font_name,
ext,
is_instance=False,
interpolatable=False,
autohinted=False,
is_variable=False,
output_dir=None,
suffix=None,
):
"""Generate output path for a font file with given extension."""
if i... | [
"def",
"_output_path",
"(",
"self",
",",
"ufo_or_font_name",
",",
"ext",
",",
"is_instance",
"=",
"False",
",",
"interpolatable",
"=",
"False",
",",
"autohinted",
"=",
"False",
",",
"is_variable",
"=",
"False",
",",
"output_dir",
"=",
"None",
",",
"suffix",
... | Generate output path for a font file with given extension. | [
"Generate",
"output",
"path",
"for",
"a",
"font",
"file",
"with",
"given",
"extension",
"."
] | b611baf49929575c2a30fd18662055365219ce2d | https://github.com/googlefonts/fontmake/blob/b611baf49929575c2a30fd18662055365219ce2d/Lib/fontmake/font_project.py#L1042-L1074 | train |
googlefonts/fontmake | Lib/fontmake/font_project.py | FontProject._designspace_locations | def _designspace_locations(self, designspace):
"""Map font filenames to their locations in a designspace."""
maps = []
for elements in (designspace.sources, designspace.instances):
location_map = {}
for element in elements:
path = _normpath(element.path)
... | python | def _designspace_locations(self, designspace):
"""Map font filenames to their locations in a designspace."""
maps = []
for elements in (designspace.sources, designspace.instances):
location_map = {}
for element in elements:
path = _normpath(element.path)
... | [
"def",
"_designspace_locations",
"(",
"self",
",",
"designspace",
")",
":",
"maps",
"=",
"[",
"]",
"for",
"elements",
"in",
"(",
"designspace",
".",
"sources",
",",
"designspace",
".",
"instances",
")",
":",
"location_map",
"=",
"{",
"}",
"for",
"element",... | Map font filenames to their locations in a designspace. | [
"Map",
"font",
"filenames",
"to",
"their",
"locations",
"in",
"a",
"designspace",
"."
] | b611baf49929575c2a30fd18662055365219ce2d | https://github.com/googlefonts/fontmake/blob/b611baf49929575c2a30fd18662055365219ce2d/Lib/fontmake/font_project.py#L1076-L1086 | train |
googlefonts/fontmake | Lib/fontmake/font_project.py | FontProject._closest_location | def _closest_location(self, location_map, target):
"""Return path of font whose location is closest to target."""
def dist(a, b):
return math.sqrt(sum((a[k] - b[k]) ** 2 for k in a.keys()))
paths = iter(location_map.keys())
closest = next(paths)
closest_dist = dist(... | python | def _closest_location(self, location_map, target):
"""Return path of font whose location is closest to target."""
def dist(a, b):
return math.sqrt(sum((a[k] - b[k]) ** 2 for k in a.keys()))
paths = iter(location_map.keys())
closest = next(paths)
closest_dist = dist(... | [
"def",
"_closest_location",
"(",
"self",
",",
"location_map",
",",
"target",
")",
":",
"def",
"dist",
"(",
"a",
",",
"b",
")",
":",
"return",
"math",
".",
"sqrt",
"(",
"sum",
"(",
"(",
"a",
"[",
"k",
"]",
"-",
"b",
"[",
"k",
"]",
")",
"**",
"... | Return path of font whose location is closest to target. | [
"Return",
"path",
"of",
"font",
"whose",
"location",
"is",
"closest",
"to",
"target",
"."
] | b611baf49929575c2a30fd18662055365219ce2d | https://github.com/googlefonts/fontmake/blob/b611baf49929575c2a30fd18662055365219ce2d/Lib/fontmake/font_project.py#L1088-L1102 | train |
googlefonts/fontmake | Lib/fontmake/ttfautohint.py | ttfautohint | def ttfautohint(in_file, out_file, args=None, **kwargs):
"""Thin wrapper around the ttfautohint command line tool.
Can take in command line arguments directly as a string, or spelled out as
Python keyword arguments.
"""
arg_list = ["ttfautohint"]
file_args = [in_file, out_file]
if args is... | python | def ttfautohint(in_file, out_file, args=None, **kwargs):
"""Thin wrapper around the ttfautohint command line tool.
Can take in command line arguments directly as a string, or spelled out as
Python keyword arguments.
"""
arg_list = ["ttfautohint"]
file_args = [in_file, out_file]
if args is... | [
"def",
"ttfautohint",
"(",
"in_file",
",",
"out_file",
",",
"args",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"arg_list",
"=",
"[",
"\"ttfautohint\"",
"]",
"file_args",
"=",
"[",
"in_file",
",",
"out_file",
"]",
"if",
"args",
"is",
"not",
"None",... | Thin wrapper around the ttfautohint command line tool.
Can take in command line arguments directly as a string, or spelled out as
Python keyword arguments. | [
"Thin",
"wrapper",
"around",
"the",
"ttfautohint",
"command",
"line",
"tool",
"."
] | b611baf49929575c2a30fd18662055365219ce2d | https://github.com/googlefonts/fontmake/blob/b611baf49929575c2a30fd18662055365219ce2d/Lib/fontmake/ttfautohint.py#L21-L82 | train |
ulule/python-logstash-formatter | logstash_formatter/__init__.py | _default_json_default | def _default_json_default(obj):
"""
Coerce everything to strings.
All objects representing time get output as ISO8601.
"""
if isinstance(obj, (datetime.datetime, datetime.date, datetime.time)):
return obj.isoformat()
else:
return str(obj) | python | def _default_json_default(obj):
"""
Coerce everything to strings.
All objects representing time get output as ISO8601.
"""
if isinstance(obj, (datetime.datetime, datetime.date, datetime.time)):
return obj.isoformat()
else:
return str(obj) | [
"def",
"_default_json_default",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"(",
"datetime",
".",
"datetime",
",",
"datetime",
".",
"date",
",",
"datetime",
".",
"time",
")",
")",
":",
"return",
"obj",
".",
"isoformat",
"(",
")",
"else",... | Coerce everything to strings.
All objects representing time get output as ISO8601. | [
"Coerce",
"everything",
"to",
"strings",
".",
"All",
"objects",
"representing",
"time",
"get",
"output",
"as",
"ISO8601",
"."
] | a29f7c8f5faec9467aaedfb74d5f40eacb2b50ea | https://github.com/ulule/python-logstash-formatter/blob/a29f7c8f5faec9467aaedfb74d5f40eacb2b50ea/logstash_formatter/__init__.py#L13-L21 | train |
ulule/python-logstash-formatter | logstash_formatter/__init__.py | LogstashFormatter.format | def format(self, record):
"""
Format a log record to JSON, if the message is a dict
assume an empty message and use the dict as additional
fields.
"""
fields = record.__dict__.copy()
if isinstance(record.msg, dict):
fields.update(record.msg)
... | python | def format(self, record):
"""
Format a log record to JSON, if the message is a dict
assume an empty message and use the dict as additional
fields.
"""
fields = record.__dict__.copy()
if isinstance(record.msg, dict):
fields.update(record.msg)
... | [
"def",
"format",
"(",
"self",
",",
"record",
")",
":",
"fields",
"=",
"record",
".",
"__dict__",
".",
"copy",
"(",
")",
"if",
"isinstance",
"(",
"record",
".",
"msg",
",",
"dict",
")",
":",
"fields",
".",
"update",
"(",
"record",
".",
"msg",
")",
... | Format a log record to JSON, if the message is a dict
assume an empty message and use the dict as additional
fields. | [
"Format",
"a",
"log",
"record",
"to",
"JSON",
"if",
"the",
"message",
"is",
"a",
"dict",
"assume",
"an",
"empty",
"message",
"and",
"use",
"the",
"dict",
"as",
"additional",
"fields",
"."
] | a29f7c8f5faec9467aaedfb74d5f40eacb2b50ea | https://github.com/ulule/python-logstash-formatter/blob/a29f7c8f5faec9467aaedfb74d5f40eacb2b50ea/logstash_formatter/__init__.py#L65-L108 | train |
ulule/python-logstash-formatter | logstash_formatter/__init__.py | LogstashFormatter._build_fields | def _build_fields(self, defaults, fields):
"""Return provided fields including any in defaults
>>> f = LogstashFormatter()
# Verify that ``fields`` is used
>>> f._build_fields({}, {'foo': 'one'}) == \
{'foo': 'one'}
True
# Verify that ``@fields`` in ``def... | python | def _build_fields(self, defaults, fields):
"""Return provided fields including any in defaults
>>> f = LogstashFormatter()
# Verify that ``fields`` is used
>>> f._build_fields({}, {'foo': 'one'}) == \
{'foo': 'one'}
True
# Verify that ``@fields`` in ``def... | [
"def",
"_build_fields",
"(",
"self",
",",
"defaults",
",",
"fields",
")",
":",
"return",
"dict",
"(",
"list",
"(",
"defaults",
".",
"get",
"(",
"'@fields'",
",",
"{",
"}",
")",
".",
"items",
"(",
")",
")",
"+",
"list",
"(",
"fields",
".",
"items",
... | Return provided fields including any in defaults
>>> f = LogstashFormatter()
# Verify that ``fields`` is used
>>> f._build_fields({}, {'foo': 'one'}) == \
{'foo': 'one'}
True
# Verify that ``@fields`` in ``defaults`` is used
>>> f._build_fields({'@fields'... | [
"Return",
"provided",
"fields",
"including",
"any",
"in",
"defaults"
] | a29f7c8f5faec9467aaedfb74d5f40eacb2b50ea | https://github.com/ulule/python-logstash-formatter/blob/a29f7c8f5faec9467aaedfb74d5f40eacb2b50ea/logstash_formatter/__init__.py#L110-L127 | train |
tchellomello/python-arlo | pyarlo/__init__.py | PyArlo._authenticate | def _authenticate(self):
"""Authenticate user and generate token."""
self.cleanup_headers()
url = LOGIN_ENDPOINT
data = self.query(
url,
method='POST',
extra_params={
'email': self.__username,
'password': self.__password... | python | def _authenticate(self):
"""Authenticate user and generate token."""
self.cleanup_headers()
url = LOGIN_ENDPOINT
data = self.query(
url,
method='POST',
extra_params={
'email': self.__username,
'password': self.__password... | [
"def",
"_authenticate",
"(",
"self",
")",
":",
"self",
".",
"cleanup_headers",
"(",
")",
"url",
"=",
"LOGIN_ENDPOINT",
"data",
"=",
"self",
".",
"query",
"(",
"url",
",",
"method",
"=",
"'POST'",
",",
"extra_params",
"=",
"{",
"'email'",
":",
"self",
"... | Authenticate user and generate token. | [
"Authenticate",
"user",
"and",
"generate",
"token",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/__init__.py#L63-L84 | train |
tchellomello/python-arlo | pyarlo/__init__.py | PyArlo.cleanup_headers | def cleanup_headers(self):
"""Reset the headers and params."""
headers = {'Content-Type': 'application/json'}
headers['Authorization'] = self.__token
self.__headers = headers
self.__params = {} | python | def cleanup_headers(self):
"""Reset the headers and params."""
headers = {'Content-Type': 'application/json'}
headers['Authorization'] = self.__token
self.__headers = headers
self.__params = {} | [
"def",
"cleanup_headers",
"(",
"self",
")",
":",
"headers",
"=",
"{",
"'Content-Type'",
":",
"'application/json'",
"}",
"headers",
"[",
"'Authorization'",
"]",
"=",
"self",
".",
"__token",
"self",
".",
"__headers",
"=",
"headers",
"self",
".",
"__params",
"=... | Reset the headers and params. | [
"Reset",
"the",
"headers",
"and",
"params",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/__init__.py#L86-L91 | train |
tchellomello/python-arlo | pyarlo/__init__.py | PyArlo.query | def query(self,
url,
method='GET',
extra_params=None,
extra_headers=None,
retry=3,
raw=False,
stream=False):
"""
Return a JSON object or raw session.
:param url: Arlo API URL
:param method... | python | def query(self,
url,
method='GET',
extra_params=None,
extra_headers=None,
retry=3,
raw=False,
stream=False):
"""
Return a JSON object or raw session.
:param url: Arlo API URL
:param method... | [
"def",
"query",
"(",
"self",
",",
"url",
",",
"method",
"=",
"'GET'",
",",
"extra_params",
"=",
"None",
",",
"extra_headers",
"=",
"None",
",",
"retry",
"=",
"3",
",",
"raw",
"=",
"False",
",",
"stream",
"=",
"False",
")",
":",
"response",
"=",
"No... | Return a JSON object or raw session.
:param url: Arlo API URL
:param method: Specify the method GET, POST or PUT. Default is GET.
:param extra_params: Dictionary to be appended on request.body
:param extra_headers: Dictionary to be apppended on request.headers
:param retry: Att... | [
"Return",
"a",
"JSON",
"object",
"or",
"raw",
"session",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/__init__.py#L93-L158 | train |
tchellomello/python-arlo | pyarlo/__init__.py | PyArlo.devices | def devices(self):
"""Return all devices on Arlo account."""
if self._all_devices:
return self._all_devices
self._all_devices = {}
self._all_devices['cameras'] = []
self._all_devices['base_station'] = []
url = DEVICES_ENDPOINT
data = self.query(url)
... | python | def devices(self):
"""Return all devices on Arlo account."""
if self._all_devices:
return self._all_devices
self._all_devices = {}
self._all_devices['cameras'] = []
self._all_devices['base_station'] = []
url = DEVICES_ENDPOINT
data = self.query(url)
... | [
"def",
"devices",
"(",
"self",
")",
":",
"if",
"self",
".",
"_all_devices",
":",
"return",
"self",
".",
"_all_devices",
"self",
".",
"_all_devices",
"=",
"{",
"}",
"self",
".",
"_all_devices",
"[",
"'cameras'",
"]",
"=",
"[",
"]",
"self",
".",
"_all_de... | Return all devices on Arlo account. | [
"Return",
"all",
"devices",
"on",
"Arlo",
"account",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/__init__.py#L171-L198 | train |
tchellomello/python-arlo | pyarlo/__init__.py | PyArlo.lookup_camera_by_id | def lookup_camera_by_id(self, device_id):
"""Return camera object by device_id."""
camera = list(filter(
lambda cam: cam.device_id == device_id, self.cameras))[0]
if camera:
return camera
return None | python | def lookup_camera_by_id(self, device_id):
"""Return camera object by device_id."""
camera = list(filter(
lambda cam: cam.device_id == device_id, self.cameras))[0]
if camera:
return camera
return None | [
"def",
"lookup_camera_by_id",
"(",
"self",
",",
"device_id",
")",
":",
"camera",
"=",
"list",
"(",
"filter",
"(",
"lambda",
"cam",
":",
"cam",
".",
"device_id",
"==",
"device_id",
",",
"self",
".",
"cameras",
")",
")",
"[",
"0",
"]",
"if",
"camera",
... | Return camera object by device_id. | [
"Return",
"camera",
"object",
"by",
"device_id",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/__init__.py#L200-L206 | train |
tchellomello/python-arlo | pyarlo/__init__.py | PyArlo.refresh_attributes | def refresh_attributes(self, name):
"""Refresh attributes from a given Arlo object."""
url = DEVICES_ENDPOINT
response = self.query(url)
if not response or not isinstance(response, dict):
return None
for device in response.get('data'):
if device.get('dev... | python | def refresh_attributes(self, name):
"""Refresh attributes from a given Arlo object."""
url = DEVICES_ENDPOINT
response = self.query(url)
if not response or not isinstance(response, dict):
return None
for device in response.get('data'):
if device.get('dev... | [
"def",
"refresh_attributes",
"(",
"self",
",",
"name",
")",
":",
"url",
"=",
"DEVICES_ENDPOINT",
"response",
"=",
"self",
".",
"query",
"(",
"url",
")",
"if",
"not",
"response",
"or",
"not",
"isinstance",
"(",
"response",
",",
"dict",
")",
":",
"return",... | Refresh attributes from a given Arlo object. | [
"Refresh",
"attributes",
"from",
"a",
"given",
"Arlo",
"object",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/__init__.py#L208-L219 | train |
tchellomello/python-arlo | pyarlo/__init__.py | PyArlo.update | def update(self, update_cameras=False, update_base_station=False):
"""Refresh object."""
self._authenticate()
# update attributes in all cameras to avoid duped queries
if update_cameras:
url = DEVICES_ENDPOINT
response = self.query(url)
if not respons... | python | def update(self, update_cameras=False, update_base_station=False):
"""Refresh object."""
self._authenticate()
# update attributes in all cameras to avoid duped queries
if update_cameras:
url = DEVICES_ENDPOINT
response = self.query(url)
if not respons... | [
"def",
"update",
"(",
"self",
",",
"update_cameras",
"=",
"False",
",",
"update_base_station",
"=",
"False",
")",
":",
"self",
".",
"_authenticate",
"(",
")",
"# update attributes in all cameras to avoid duped queries",
"if",
"update_cameras",
":",
"url",
"=",
"DEVI... | Refresh object. | [
"Refresh",
"object",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/__init__.py#L249-L274 | train |
tchellomello/python-arlo | pyarlo/media.py | ArloMediaLibrary.load | def load(self, days=PRELOAD_DAYS, only_cameras=None,
date_from=None, date_to=None, limit=None):
"""Load Arlo videos from the given criteria
:param days: number of days to retrieve
:param only_cameras: retrieve only <ArloCamera> on that list
:param date_from: refine from in... | python | def load(self, days=PRELOAD_DAYS, only_cameras=None,
date_from=None, date_to=None, limit=None):
"""Load Arlo videos from the given criteria
:param days: number of days to retrieve
:param only_cameras: retrieve only <ArloCamera> on that list
:param date_from: refine from in... | [
"def",
"load",
"(",
"self",
",",
"days",
"=",
"PRELOAD_DAYS",
",",
"only_cameras",
"=",
"None",
",",
"date_from",
"=",
"None",
",",
"date_to",
"=",
"None",
",",
"limit",
"=",
"None",
")",
":",
"videos",
"=",
"[",
"]",
"url",
"=",
"LIBRARY_ENDPOINT",
... | Load Arlo videos from the given criteria
:param days: number of days to retrieve
:param only_cameras: retrieve only <ArloCamera> on that list
:param date_from: refine from initial date
:param date_to: refine final date
:param limit: define number of objects to return | [
"Load",
"Arlo",
"videos",
"from",
"the",
"given",
"criteria"
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/media.py#L38-L87 | train |
tchellomello/python-arlo | pyarlo/media.py | ArloVideo._name | def _name(self):
"""Define object name."""
return "{0} {1} {2}".format(
self._camera.name,
pretty_timestamp(self.created_at),
self._attrs.get('mediaDuration')) | python | def _name(self):
"""Define object name."""
return "{0} {1} {2}".format(
self._camera.name,
pretty_timestamp(self.created_at),
self._attrs.get('mediaDuration')) | [
"def",
"_name",
"(",
"self",
")",
":",
"return",
"\"{0} {1} {2}\"",
".",
"format",
"(",
"self",
".",
"_camera",
".",
"name",
",",
"pretty_timestamp",
"(",
"self",
".",
"created_at",
")",
",",
"self",
".",
"_attrs",
".",
"get",
"(",
"'mediaDuration'",
")"... | Define object name. | [
"Define",
"object",
"name",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/media.py#L110-L115 | train |
tchellomello/python-arlo | pyarlo/media.py | ArloVideo.created_at_pretty | def created_at_pretty(self, date_format=None):
"""Return pretty timestamp."""
if date_format:
return pretty_timestamp(self.created_at, date_format=date_format)
return pretty_timestamp(self.created_at) | python | def created_at_pretty(self, date_format=None):
"""Return pretty timestamp."""
if date_format:
return pretty_timestamp(self.created_at, date_format=date_format)
return pretty_timestamp(self.created_at) | [
"def",
"created_at_pretty",
"(",
"self",
",",
"date_format",
"=",
"None",
")",
":",
"if",
"date_format",
":",
"return",
"pretty_timestamp",
"(",
"self",
".",
"created_at",
",",
"date_format",
"=",
"date_format",
")",
"return",
"pretty_timestamp",
"(",
"self",
... | Return pretty timestamp. | [
"Return",
"pretty",
"timestamp",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/media.py#L132-L136 | train |
tchellomello/python-arlo | pyarlo/media.py | ArloVideo.created_today | def created_today(self):
"""Return True if created today."""
if self.datetime.date() == datetime.today().date():
return True
return False | python | def created_today(self):
"""Return True if created today."""
if self.datetime.date() == datetime.today().date():
return True
return False | [
"def",
"created_today",
"(",
"self",
")",
":",
"if",
"self",
".",
"datetime",
".",
"date",
"(",
")",
"==",
"datetime",
".",
"today",
"(",
")",
".",
"date",
"(",
")",
":",
"return",
"True",
"return",
"False"
] | Return True if created today. | [
"Return",
"True",
"if",
"created",
"today",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/media.py#L139-L143 | train |
tchellomello/python-arlo | pyarlo/utils.py | to_datetime | def to_datetime(timestamp):
"""Return datetime object from timestamp."""
return dt.fromtimestamp(time.mktime(
time.localtime(int(str(timestamp)[:10])))) | python | def to_datetime(timestamp):
"""Return datetime object from timestamp."""
return dt.fromtimestamp(time.mktime(
time.localtime(int(str(timestamp)[:10])))) | [
"def",
"to_datetime",
"(",
"timestamp",
")",
":",
"return",
"dt",
".",
"fromtimestamp",
"(",
"time",
".",
"mktime",
"(",
"time",
".",
"localtime",
"(",
"int",
"(",
"str",
"(",
"timestamp",
")",
"[",
":",
"10",
"]",
")",
")",
")",
")"
] | Return datetime object from timestamp. | [
"Return",
"datetime",
"object",
"from",
"timestamp",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/utils.py#L11-L14 | train |
tchellomello/python-arlo | pyarlo/utils.py | pretty_timestamp | def pretty_timestamp(timestamp, date_format='%a-%m_%d_%y:%H:%M:%S'):
"""Huminize timestamp."""
return time.strftime(date_format,
time.localtime(int(str(timestamp)[:10]))) | python | def pretty_timestamp(timestamp, date_format='%a-%m_%d_%y:%H:%M:%S'):
"""Huminize timestamp."""
return time.strftime(date_format,
time.localtime(int(str(timestamp)[:10]))) | [
"def",
"pretty_timestamp",
"(",
"timestamp",
",",
"date_format",
"=",
"'%a-%m_%d_%y:%H:%M:%S'",
")",
":",
"return",
"time",
".",
"strftime",
"(",
"date_format",
",",
"time",
".",
"localtime",
"(",
"int",
"(",
"str",
"(",
"timestamp",
")",
"[",
":",
"10",
"... | Huminize timestamp. | [
"Huminize",
"timestamp",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/utils.py#L17-L20 | train |
tchellomello/python-arlo | pyarlo/utils.py | http_get | def http_get(url, filename=None):
"""Download HTTP data."""
try:
ret = requests.get(url)
except requests.exceptions.SSLError as error:
_LOGGER.error(error)
return False
if ret.status_code != 200:
return False
if filename is None:
return ret.content
with... | python | def http_get(url, filename=None):
"""Download HTTP data."""
try:
ret = requests.get(url)
except requests.exceptions.SSLError as error:
_LOGGER.error(error)
return False
if ret.status_code != 200:
return False
if filename is None:
return ret.content
with... | [
"def",
"http_get",
"(",
"url",
",",
"filename",
"=",
"None",
")",
":",
"try",
":",
"ret",
"=",
"requests",
".",
"get",
"(",
"url",
")",
"except",
"requests",
".",
"exceptions",
".",
"SSLError",
"as",
"error",
":",
"_LOGGER",
".",
"error",
"(",
"error... | Download HTTP data. | [
"Download",
"HTTP",
"data",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/utils.py#L23-L39 | train |
tchellomello/python-arlo | pyarlo/utils.py | http_stream | def http_stream(url, chunk=4096):
"""Generate stream for a given record video.
:param chunk: chunk bytes to read per time
:returns generator object
"""
ret = requests.get(url, stream=True)
ret.raise_for_status()
for data in ret.iter_content(chunk):
yield data | python | def http_stream(url, chunk=4096):
"""Generate stream for a given record video.
:param chunk: chunk bytes to read per time
:returns generator object
"""
ret = requests.get(url, stream=True)
ret.raise_for_status()
for data in ret.iter_content(chunk):
yield data | [
"def",
"http_stream",
"(",
"url",
",",
"chunk",
"=",
"4096",
")",
":",
"ret",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"stream",
"=",
"True",
")",
"ret",
".",
"raise_for_status",
"(",
")",
"for",
"data",
"in",
"ret",
".",
"iter_content",
"(",
... | Generate stream for a given record video.
:param chunk: chunk bytes to read per time
:returns generator object | [
"Generate",
"stream",
"for",
"a",
"given",
"record",
"video",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/utils.py#L42-L51 | train |
tchellomello/python-arlo | pyarlo/camera.py | ArloCamera.unseen_videos_reset | def unseen_videos_reset(self):
"""Reset the unseen videos counter."""
url = RESET_CAM_ENDPOINT.format(self.unique_id)
ret = self._session.query(url).get('success')
return ret | python | def unseen_videos_reset(self):
"""Reset the unseen videos counter."""
url = RESET_CAM_ENDPOINT.format(self.unique_id)
ret = self._session.query(url).get('success')
return ret | [
"def",
"unseen_videos_reset",
"(",
"self",
")",
":",
"url",
"=",
"RESET_CAM_ENDPOINT",
".",
"format",
"(",
"self",
".",
"unique_id",
")",
"ret",
"=",
"self",
".",
"_session",
".",
"query",
"(",
"url",
")",
".",
"get",
"(",
"'success'",
")",
"return",
"... | Reset the unseen videos counter. | [
"Reset",
"the",
"unseen",
"videos",
"counter",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/camera.py#L128-L132 | train |
tchellomello/python-arlo | pyarlo/camera.py | ArloCamera.make_video_cache | def make_video_cache(self, days=None):
"""Save videos on _cache_videos to avoid dups."""
if days is None:
days = self._min_days_vdo_cache
self._cached_videos = self.videos(days) | python | def make_video_cache(self, days=None):
"""Save videos on _cache_videos to avoid dups."""
if days is None:
days = self._min_days_vdo_cache
self._cached_videos = self.videos(days) | [
"def",
"make_video_cache",
"(",
"self",
",",
"days",
"=",
"None",
")",
":",
"if",
"days",
"is",
"None",
":",
"days",
"=",
"self",
".",
"_min_days_vdo_cache",
"self",
".",
"_cached_videos",
"=",
"self",
".",
"videos",
"(",
"days",
")"
] | Save videos on _cache_videos to avoid dups. | [
"Save",
"videos",
"on",
"_cache_videos",
"to",
"avoid",
"dups",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/camera.py#L171-L175 | train |
tchellomello/python-arlo | pyarlo/camera.py | ArloCamera.base_station | def base_station(self):
"""Return the base_station assigned for the given camera."""
try:
return list(filter(lambda x: x.device_id == self.parent_id,
self._session.base_stations))[0]
except (IndexError, AttributeError):
return None | python | def base_station(self):
"""Return the base_station assigned for the given camera."""
try:
return list(filter(lambda x: x.device_id == self.parent_id,
self._session.base_stations))[0]
except (IndexError, AttributeError):
return None | [
"def",
"base_station",
"(",
"self",
")",
":",
"try",
":",
"return",
"list",
"(",
"filter",
"(",
"lambda",
"x",
":",
"x",
".",
"device_id",
"==",
"self",
".",
"parent_id",
",",
"self",
".",
"_session",
".",
"base_stations",
")",
")",
"[",
"0",
"]",
... | Return the base_station assigned for the given camera. | [
"Return",
"the",
"base_station",
"assigned",
"for",
"the",
"given",
"camera",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/camera.py#L216-L222 | train |
tchellomello/python-arlo | pyarlo/camera.py | ArloCamera._get_camera_properties | def _get_camera_properties(self):
"""Lookup camera properties from base station."""
if self.base_station and self.base_station.camera_properties:
for cam in self.base_station.camera_properties:
if cam["serialNumber"] == self.device_id:
return cam
r... | python | def _get_camera_properties(self):
"""Lookup camera properties from base station."""
if self.base_station and self.base_station.camera_properties:
for cam in self.base_station.camera_properties:
if cam["serialNumber"] == self.device_id:
return cam
r... | [
"def",
"_get_camera_properties",
"(",
"self",
")",
":",
"if",
"self",
".",
"base_station",
"and",
"self",
".",
"base_station",
".",
"camera_properties",
":",
"for",
"cam",
"in",
"self",
".",
"base_station",
".",
"camera_properties",
":",
"if",
"cam",
"[",
"\... | Lookup camera properties from base station. | [
"Lookup",
"camera",
"properties",
"from",
"base",
"station",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/camera.py#L224-L230 | train |
tchellomello/python-arlo | pyarlo/camera.py | ArloCamera.triggers | def triggers(self):
"""Get a camera's triggers."""
capabilities = self.capabilities
if not capabilities:
return None
for capability in capabilities:
if not isinstance(capability, dict):
continue
triggers = capability.get("Triggers")
... | python | def triggers(self):
"""Get a camera's triggers."""
capabilities = self.capabilities
if not capabilities:
return None
for capability in capabilities:
if not isinstance(capability, dict):
continue
triggers = capability.get("Triggers")
... | [
"def",
"triggers",
"(",
"self",
")",
":",
"capabilities",
"=",
"self",
".",
"capabilities",
"if",
"not",
"capabilities",
":",
"return",
"None",
"for",
"capability",
"in",
"capabilities",
":",
"if",
"not",
"isinstance",
"(",
"capability",
",",
"dict",
")",
... | Get a camera's triggers. | [
"Get",
"a",
"camera",
"s",
"triggers",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/camera.py#L244-L258 | train |
tchellomello/python-arlo | pyarlo/camera.py | ArloCamera.motion_detection_sensitivity | def motion_detection_sensitivity(self):
"""Sensitivity level of Camera motion detection."""
if not self.triggers:
return None
for trigger in self.triggers:
if trigger.get("type") != "pirMotionActive":
continue
sensitivity = trigger.get("sensi... | python | def motion_detection_sensitivity(self):
"""Sensitivity level of Camera motion detection."""
if not self.triggers:
return None
for trigger in self.triggers:
if trigger.get("type") != "pirMotionActive":
continue
sensitivity = trigger.get("sensi... | [
"def",
"motion_detection_sensitivity",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"triggers",
":",
"return",
"None",
"for",
"trigger",
"in",
"self",
".",
"triggers",
":",
"if",
"trigger",
".",
"get",
"(",
"\"type\"",
")",
"!=",
"\"pirMotionActive\"",
... | Sensitivity level of Camera motion detection. | [
"Sensitivity",
"level",
"of",
"Camera",
"motion",
"detection",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/camera.py#L304-L317 | train |
tchellomello/python-arlo | pyarlo/camera.py | ArloCamera.audio_detection_sensitivity | def audio_detection_sensitivity(self):
"""Sensitivity level of Camera audio detection."""
if not self.triggers:
return None
for trigger in self.triggers:
if trigger.get("type") != "audioAmplitude":
continue
sensitivity = trigger.get("sensitiv... | python | def audio_detection_sensitivity(self):
"""Sensitivity level of Camera audio detection."""
if not self.triggers:
return None
for trigger in self.triggers:
if trigger.get("type") != "audioAmplitude":
continue
sensitivity = trigger.get("sensitiv... | [
"def",
"audio_detection_sensitivity",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"triggers",
":",
"return",
"None",
"for",
"trigger",
"in",
"self",
".",
"triggers",
":",
"if",
"trigger",
".",
"get",
"(",
"\"type\"",
")",
"!=",
"\"audioAmplitude\"",
"... | Sensitivity level of Camera audio detection. | [
"Sensitivity",
"level",
"of",
"Camera",
"audio",
"detection",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/camera.py#L320-L333 | train |
tchellomello/python-arlo | pyarlo/camera.py | ArloCamera.live_streaming | def live_streaming(self):
"""Return live streaming generator."""
url = STREAM_ENDPOINT
# override params
params = STREAMING_BODY
params['from'] = "{0}_web".format(self.user_id)
params['to'] = self.device_id
params['resource'] = "cameras/{0}".format(self.device_id... | python | def live_streaming(self):
"""Return live streaming generator."""
url = STREAM_ENDPOINT
# override params
params = STREAMING_BODY
params['from'] = "{0}_web".format(self.user_id)
params['to'] = self.device_id
params['resource'] = "cameras/{0}".format(self.device_id... | [
"def",
"live_streaming",
"(",
"self",
")",
":",
"url",
"=",
"STREAM_ENDPOINT",
"# override params",
"params",
"=",
"STREAMING_BODY",
"params",
"[",
"'from'",
"]",
"=",
"\"{0}_web\"",
".",
"format",
"(",
"self",
".",
"user_id",
")",
"params",
"[",
"'to'",
"]"... | Return live streaming generator. | [
"Return",
"live",
"streaming",
"generator",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/camera.py#L335-L361 | train |
tchellomello/python-arlo | pyarlo/camera.py | ArloCamera.schedule_snapshot | def schedule_snapshot(self):
"""Trigger snapshot to be uploaded to AWS.
Return success state."""
# Notes:
# - Snapshots are not immediate.
# - Snapshots will be cached for predefined amount
# of time.
# - Snapshots are not balanced. To get a better
#... | python | def schedule_snapshot(self):
"""Trigger snapshot to be uploaded to AWS.
Return success state."""
# Notes:
# - Snapshots are not immediate.
# - Snapshots will be cached for predefined amount
# of time.
# - Snapshots are not balanced. To get a better
#... | [
"def",
"schedule_snapshot",
"(",
"self",
")",
":",
"# Notes:",
"# - Snapshots are not immediate.",
"# - Snapshots will be cached for predefined amount",
"# of time.",
"# - Snapshots are not balanced. To get a better",
"# image, it must be taken from the stream, a few",
"# seconds... | Trigger snapshot to be uploaded to AWS.
Return success state. | [
"Trigger",
"snapshot",
"to",
"be",
"uploaded",
"to",
"AWS",
".",
"Return",
"success",
"state",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/camera.py#L374-L405 | train |
tchellomello/python-arlo | pyarlo/base_station.py | ArloBaseStation.thread_function | def thread_function(self):
"""Thread function."""
self.__subscribed = True
url = SUBSCRIBE_ENDPOINT + "?token=" + self._session_token
data = self._session.query(url, method='GET', raw=True, stream=True)
if not data or not data.ok:
_LOGGER.debug("Did not receive a va... | python | def thread_function(self):
"""Thread function."""
self.__subscribed = True
url = SUBSCRIBE_ENDPOINT + "?token=" + self._session_token
data = self._session.query(url, method='GET', raw=True, stream=True)
if not data or not data.ok:
_LOGGER.debug("Did not receive a va... | [
"def",
"thread_function",
"(",
"self",
")",
":",
"self",
".",
"__subscribed",
"=",
"True",
"url",
"=",
"SUBSCRIBE_ENDPOINT",
"+",
"\"?token=\"",
"+",
"self",
".",
"_session_token",
"data",
"=",
"self",
".",
"_session",
".",
"query",
"(",
"url",
",",
"metho... | Thread function. | [
"Thread",
"function",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/base_station.py#L55-L90 | train |
tchellomello/python-arlo | pyarlo/base_station.py | ArloBaseStation._get_event_stream | def _get_event_stream(self):
"""Spawn a thread and monitor the Arlo Event Stream."""
self.__event_handle = threading.Event()
event_thread = threading.Thread(target=self.thread_function)
event_thread.start() | python | def _get_event_stream(self):
"""Spawn a thread and monitor the Arlo Event Stream."""
self.__event_handle = threading.Event()
event_thread = threading.Thread(target=self.thread_function)
event_thread.start() | [
"def",
"_get_event_stream",
"(",
"self",
")",
":",
"self",
".",
"__event_handle",
"=",
"threading",
".",
"Event",
"(",
")",
"event_thread",
"=",
"threading",
".",
"Thread",
"(",
"target",
"=",
"self",
".",
"thread_function",
")",
"event_thread",
".",
"start"... | Spawn a thread and monitor the Arlo Event Stream. | [
"Spawn",
"a",
"thread",
"and",
"monitor",
"the",
"Arlo",
"Event",
"Stream",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/base_station.py#L92-L96 | train |
tchellomello/python-arlo | pyarlo/base_station.py | ArloBaseStation._unsubscribe_myself | def _unsubscribe_myself(self):
"""Unsubscribe this base station for all events."""
url = UNSUBSCRIBE_ENDPOINT
return self._session.query(url, method='GET', raw=True, stream=False) | python | def _unsubscribe_myself(self):
"""Unsubscribe this base station for all events."""
url = UNSUBSCRIBE_ENDPOINT
return self._session.query(url, method='GET', raw=True, stream=False) | [
"def",
"_unsubscribe_myself",
"(",
"self",
")",
":",
"url",
"=",
"UNSUBSCRIBE_ENDPOINT",
"return",
"self",
".",
"_session",
".",
"query",
"(",
"url",
",",
"method",
"=",
"'GET'",
",",
"raw",
"=",
"True",
",",
"stream",
"=",
"False",
")"
] | Unsubscribe this base station for all events. | [
"Unsubscribe",
"this",
"base",
"station",
"for",
"all",
"events",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/base_station.py#L106-L109 | train |
tchellomello/python-arlo | pyarlo/base_station.py | ArloBaseStation._close_event_stream | def _close_event_stream(self):
"""Stop the Event stream thread."""
self.__subscribed = False
del self.__events[:]
self.__event_handle.clear() | python | def _close_event_stream(self):
"""Stop the Event stream thread."""
self.__subscribed = False
del self.__events[:]
self.__event_handle.clear() | [
"def",
"_close_event_stream",
"(",
"self",
")",
":",
"self",
".",
"__subscribed",
"=",
"False",
"del",
"self",
".",
"__events",
"[",
":",
"]",
"self",
".",
"__event_handle",
".",
"clear",
"(",
")"
] | Stop the Event stream thread. | [
"Stop",
"the",
"Event",
"stream",
"thread",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/base_station.py#L111-L115 | train |
tchellomello/python-arlo | pyarlo/base_station.py | ArloBaseStation.publish_and_get_event | def publish_and_get_event(self, resource):
"""Publish and get the event from base station."""
l_subscribed = False
this_event = None
if not self.__subscribed:
self._get_event_stream()
self._subscribe_myself()
l_subscribed = True
status = self... | python | def publish_and_get_event(self, resource):
"""Publish and get the event from base station."""
l_subscribed = False
this_event = None
if not self.__subscribed:
self._get_event_stream()
self._subscribe_myself()
l_subscribed = True
status = self... | [
"def",
"publish_and_get_event",
"(",
"self",
",",
"resource",
")",
":",
"l_subscribed",
"=",
"False",
"this_event",
"=",
"None",
"if",
"not",
"self",
".",
"__subscribed",
":",
"self",
".",
"_get_event_stream",
"(",
")",
"self",
".",
"_subscribe_myself",
"(",
... | Publish and get the event from base station. | [
"Publish",
"and",
"get",
"the",
"event",
"from",
"base",
"station",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/base_station.py#L117-L151 | train |
tchellomello/python-arlo | pyarlo/base_station.py | ArloBaseStation.publish | def publish(
self,
action='get',
resource=None,
camera_id=None,
mode=None,
publish_response=None,
properties=None):
"""Run action.
:param method: Specify the method GET, POST or PUT. Default is GET.
:param resou... | python | def publish(
self,
action='get',
resource=None,
camera_id=None,
mode=None,
publish_response=None,
properties=None):
"""Run action.
:param method: Specify the method GET, POST or PUT. Default is GET.
:param resou... | [
"def",
"publish",
"(",
"self",
",",
"action",
"=",
"'get'",
",",
"resource",
"=",
"None",
",",
"camera_id",
"=",
"None",
",",
"mode",
"=",
"None",
",",
"publish_response",
"=",
"None",
",",
"properties",
"=",
"None",
")",
":",
"url",
"=",
"NOTIFY_ENDPO... | Run action.
:param method: Specify the method GET, POST or PUT. Default is GET.
:param resource: Specify one of the resources to fetch from arlo.
:param camera_id: Specify the camera ID involved with this action
:param mode: Specify the mode to set, else None for GET operations
... | [
"Run",
"action",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/base_station.py#L153-L215 | train |
tchellomello/python-arlo | pyarlo/base_station.py | ArloBaseStation.refresh_rate | def refresh_rate(self, value):
"""Override the refresh_rate attribute."""
if isinstance(value, (int, float)):
self._refresh_rate = value | python | def refresh_rate(self, value):
"""Override the refresh_rate attribute."""
if isinstance(value, (int, float)):
self._refresh_rate = value | [
"def",
"refresh_rate",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"(",
"int",
",",
"float",
")",
")",
":",
"self",
".",
"_refresh_rate",
"=",
"value"
] | Override the refresh_rate attribute. | [
"Override",
"the",
"refresh_rate",
"attribute",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/base_station.py#L299-L302 | train |
tchellomello/python-arlo | pyarlo/base_station.py | ArloBaseStation.available_modes | def available_modes(self):
"""Return list of available mode names."""
if not self._available_modes:
modes = self.available_modes_with_ids
if not modes:
return None
self._available_modes = list(modes.keys())
return self._available_modes | python | def available_modes(self):
"""Return list of available mode names."""
if not self._available_modes:
modes = self.available_modes_with_ids
if not modes:
return None
self._available_modes = list(modes.keys())
return self._available_modes | [
"def",
"available_modes",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_available_modes",
":",
"modes",
"=",
"self",
".",
"available_modes_with_ids",
"if",
"not",
"modes",
":",
"return",
"None",
"self",
".",
"_available_modes",
"=",
"list",
"(",
"modes"... | Return list of available mode names. | [
"Return",
"list",
"of",
"available",
"mode",
"names",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/base_station.py#L305-L312 | train |
tchellomello/python-arlo | pyarlo/base_station.py | ArloBaseStation.available_modes_with_ids | def available_modes_with_ids(self):
"""Return list of objects containing available mode name and id."""
if not self._available_mode_ids:
all_modes = FIXED_MODES.copy()
self._available_mode_ids = all_modes
modes = self.get_available_modes()
try:
... | python | def available_modes_with_ids(self):
"""Return list of objects containing available mode name and id."""
if not self._available_mode_ids:
all_modes = FIXED_MODES.copy()
self._available_mode_ids = all_modes
modes = self.get_available_modes()
try:
... | [
"def",
"available_modes_with_ids",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_available_mode_ids",
":",
"all_modes",
"=",
"FIXED_MODES",
".",
"copy",
"(",
")",
"self",
".",
"_available_mode_ids",
"=",
"all_modes",
"modes",
"=",
"self",
".",
"get_availa... | Return list of objects containing available mode name and id. | [
"Return",
"list",
"of",
"objects",
"containing",
"available",
"mode",
"name",
"and",
"id",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/base_station.py#L315-L332 | train |
tchellomello/python-arlo | pyarlo/base_station.py | ArloBaseStation.mode | def mode(self):
"""Return current mode key."""
if self.is_in_schedule_mode:
return "schedule"
resource = "modes"
mode_event = self.publish_and_get_event(resource)
if mode_event:
properties = mode_event.get('properties')
active_mode = properti... | python | def mode(self):
"""Return current mode key."""
if self.is_in_schedule_mode:
return "schedule"
resource = "modes"
mode_event = self.publish_and_get_event(resource)
if mode_event:
properties = mode_event.get('properties')
active_mode = properti... | [
"def",
"mode",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_in_schedule_mode",
":",
"return",
"\"schedule\"",
"resource",
"=",
"\"modes\"",
"mode_event",
"=",
"self",
".",
"publish_and_get_event",
"(",
"resource",
")",
"if",
"mode_event",
":",
"properties",
"... | Return current mode key. | [
"Return",
"current",
"mode",
"key",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/base_station.py#L340-L359 | train |
tchellomello/python-arlo | pyarlo/base_station.py | ArloBaseStation.is_in_schedule_mode | def is_in_schedule_mode(self):
"""Returns True if base_station is currently on a scheduled mode."""
resource = "schedule"
mode_event = self.publish_and_get_event(resource)
if mode_event and mode_event.get("resource", None) == "schedule":
properties = mode_event.get('propertie... | python | def is_in_schedule_mode(self):
"""Returns True if base_station is currently on a scheduled mode."""
resource = "schedule"
mode_event = self.publish_and_get_event(resource)
if mode_event and mode_event.get("resource", None) == "schedule":
properties = mode_event.get('propertie... | [
"def",
"is_in_schedule_mode",
"(",
"self",
")",
":",
"resource",
"=",
"\"schedule\"",
"mode_event",
"=",
"self",
".",
"publish_and_get_event",
"(",
"resource",
")",
"if",
"mode_event",
"and",
"mode_event",
".",
"get",
"(",
"\"resource\"",
",",
"None",
")",
"==... | Returns True if base_station is currently on a scheduled mode. | [
"Returns",
"True",
"if",
"base_station",
"is",
"currently",
"on",
"a",
"scheduled",
"mode",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/base_station.py#L362-L369 | train |
tchellomello/python-arlo | pyarlo/base_station.py | ArloBaseStation.get_available_modes | def get_available_modes(self):
"""Return a list of available mode objects for an Arlo user."""
resource = "modes"
resource_event = self.publish_and_get_event(resource)
if resource_event:
properties = resource_event.get("properties")
return properties.get("modes")
... | python | def get_available_modes(self):
"""Return a list of available mode objects for an Arlo user."""
resource = "modes"
resource_event = self.publish_and_get_event(resource)
if resource_event:
properties = resource_event.get("properties")
return properties.get("modes")
... | [
"def",
"get_available_modes",
"(",
"self",
")",
":",
"resource",
"=",
"\"modes\"",
"resource_event",
"=",
"self",
".",
"publish_and_get_event",
"(",
"resource",
")",
"if",
"resource_event",
":",
"properties",
"=",
"resource_event",
".",
"get",
"(",
"\"properties\"... | Return a list of available mode objects for an Arlo user. | [
"Return",
"a",
"list",
"of",
"available",
"mode",
"objects",
"for",
"an",
"Arlo",
"user",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/base_station.py#L371-L379 | train |
tchellomello/python-arlo | pyarlo/base_station.py | ArloBaseStation.get_cameras_properties | def get_cameras_properties(self):
"""Return camera properties."""
resource = "cameras"
resource_event = self.publish_and_get_event(resource)
if resource_event:
self._last_refresh = int(time.time())
self._camera_properties = resource_event.get('properties') | python | def get_cameras_properties(self):
"""Return camera properties."""
resource = "cameras"
resource_event = self.publish_and_get_event(resource)
if resource_event:
self._last_refresh = int(time.time())
self._camera_properties = resource_event.get('properties') | [
"def",
"get_cameras_properties",
"(",
"self",
")",
":",
"resource",
"=",
"\"cameras\"",
"resource_event",
"=",
"self",
".",
"publish_and_get_event",
"(",
"resource",
")",
"if",
"resource_event",
":",
"self",
".",
"_last_refresh",
"=",
"int",
"(",
"time",
".",
... | Return camera properties. | [
"Return",
"camera",
"properties",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/base_station.py#L388-L394 | train |
tchellomello/python-arlo | pyarlo/base_station.py | ArloBaseStation.get_cameras_battery_level | def get_cameras_battery_level(self):
"""Return a list of battery levels of all cameras."""
battery_levels = {}
if not self.camera_properties:
return None
for camera in self.camera_properties:
serialnum = camera.get('serialNumber')
cam_battery = camera... | python | def get_cameras_battery_level(self):
"""Return a list of battery levels of all cameras."""
battery_levels = {}
if not self.camera_properties:
return None
for camera in self.camera_properties:
serialnum = camera.get('serialNumber')
cam_battery = camera... | [
"def",
"get_cameras_battery_level",
"(",
"self",
")",
":",
"battery_levels",
"=",
"{",
"}",
"if",
"not",
"self",
".",
"camera_properties",
":",
"return",
"None",
"for",
"camera",
"in",
"self",
".",
"camera_properties",
":",
"serialnum",
"=",
"camera",
".",
"... | Return a list of battery levels of all cameras. | [
"Return",
"a",
"list",
"of",
"battery",
"levels",
"of",
"all",
"cameras",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/base_station.py#L396-L406 | train |
tchellomello/python-arlo | pyarlo/base_station.py | ArloBaseStation.get_cameras_signal_strength | def get_cameras_signal_strength(self):
"""Return a list of signal strength of all cameras."""
signal_strength = {}
if not self.camera_properties:
return None
for camera in self.camera_properties:
serialnum = camera.get('serialNumber')
cam_strength = c... | python | def get_cameras_signal_strength(self):
"""Return a list of signal strength of all cameras."""
signal_strength = {}
if not self.camera_properties:
return None
for camera in self.camera_properties:
serialnum = camera.get('serialNumber')
cam_strength = c... | [
"def",
"get_cameras_signal_strength",
"(",
"self",
")",
":",
"signal_strength",
"=",
"{",
"}",
"if",
"not",
"self",
".",
"camera_properties",
":",
"return",
"None",
"for",
"camera",
"in",
"self",
".",
"camera_properties",
":",
"serialnum",
"=",
"camera",
".",
... | Return a list of signal strength of all cameras. | [
"Return",
"a",
"list",
"of",
"signal",
"strength",
"of",
"all",
"cameras",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/base_station.py#L408-L418 | train |
tchellomello/python-arlo | pyarlo/base_station.py | ArloBaseStation.get_camera_extended_properties | def get_camera_extended_properties(self):
"""Return camera extended properties."""
resource = 'cameras/{}'.format(self.device_id)
resource_event = self.publish_and_get_event(resource)
if resource_event is None:
return None
self._camera_extended_properties = resource... | python | def get_camera_extended_properties(self):
"""Return camera extended properties."""
resource = 'cameras/{}'.format(self.device_id)
resource_event = self.publish_and_get_event(resource)
if resource_event is None:
return None
self._camera_extended_properties = resource... | [
"def",
"get_camera_extended_properties",
"(",
"self",
")",
":",
"resource",
"=",
"'cameras/{}'",
".",
"format",
"(",
"self",
".",
"device_id",
")",
"resource_event",
"=",
"self",
".",
"publish_and_get_event",
"(",
"resource",
")",
"if",
"resource_event",
"is",
"... | Return camera extended properties. | [
"Return",
"camera",
"extended",
"properties",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/base_station.py#L427-L436 | train |
tchellomello/python-arlo | pyarlo/base_station.py | ArloBaseStation.get_speaker_muted | def get_speaker_muted(self):
"""Return whether or not the speaker is muted."""
if not self.camera_extended_properties:
return None
speaker = self.camera_extended_properties.get('speaker')
if not speaker:
return None
return speaker.get('mute') | python | def get_speaker_muted(self):
"""Return whether or not the speaker is muted."""
if not self.camera_extended_properties:
return None
speaker = self.camera_extended_properties.get('speaker')
if not speaker:
return None
return speaker.get('mute') | [
"def",
"get_speaker_muted",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"camera_extended_properties",
":",
"return",
"None",
"speaker",
"=",
"self",
".",
"camera_extended_properties",
".",
"get",
"(",
"'speaker'",
")",
"if",
"not",
"speaker",
":",
"return... | Return whether or not the speaker is muted. | [
"Return",
"whether",
"or",
"not",
"the",
"speaker",
"is",
"muted",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/base_station.py#L438-L447 | train |
tchellomello/python-arlo | pyarlo/base_station.py | ArloBaseStation.get_speaker_volume | def get_speaker_volume(self):
"""Return the volume setting of the speaker."""
if not self.camera_extended_properties:
return None
speaker = self.camera_extended_properties.get('speaker')
if not speaker:
return None
return speaker.get('volume') | python | def get_speaker_volume(self):
"""Return the volume setting of the speaker."""
if not self.camera_extended_properties:
return None
speaker = self.camera_extended_properties.get('speaker')
if not speaker:
return None
return speaker.get('volume') | [
"def",
"get_speaker_volume",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"camera_extended_properties",
":",
"return",
"None",
"speaker",
"=",
"self",
".",
"camera_extended_properties",
".",
"get",
"(",
"'speaker'",
")",
"if",
"not",
"speaker",
":",
"retur... | Return the volume setting of the speaker. | [
"Return",
"the",
"volume",
"setting",
"of",
"the",
"speaker",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/base_station.py#L449-L458 | train |
tchellomello/python-arlo | pyarlo/base_station.py | ArloBaseStation.properties | def properties(self):
"""Return the base station info."""
resource = "basestation"
basestn_event = self.publish_and_get_event(resource)
if basestn_event:
return basestn_event.get('properties')
return None | python | def properties(self):
"""Return the base station info."""
resource = "basestation"
basestn_event = self.publish_and_get_event(resource)
if basestn_event:
return basestn_event.get('properties')
return None | [
"def",
"properties",
"(",
"self",
")",
":",
"resource",
"=",
"\"basestation\"",
"basestn_event",
"=",
"self",
".",
"publish_and_get_event",
"(",
"resource",
")",
"if",
"basestn_event",
":",
"return",
"basestn_event",
".",
"get",
"(",
"'properties'",
")",
"return... | Return the base station info. | [
"Return",
"the",
"base",
"station",
"info",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/base_station.py#L486-L493 | train |
tchellomello/python-arlo | pyarlo/base_station.py | ArloBaseStation.get_cameras_rules | def get_cameras_rules(self):
"""Return the camera rules."""
resource = "rules"
rules_event = self.publish_and_get_event(resource)
if rules_event:
return rules_event.get('properties')
return None | python | def get_cameras_rules(self):
"""Return the camera rules."""
resource = "rules"
rules_event = self.publish_and_get_event(resource)
if rules_event:
return rules_event.get('properties')
return None | [
"def",
"get_cameras_rules",
"(",
"self",
")",
":",
"resource",
"=",
"\"rules\"",
"rules_event",
"=",
"self",
".",
"publish_and_get_event",
"(",
"resource",
")",
"if",
"rules_event",
":",
"return",
"rules_event",
".",
"get",
"(",
"'properties'",
")",
"return",
... | Return the camera rules. | [
"Return",
"the",
"camera",
"rules",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/base_station.py#L495-L502 | train |
tchellomello/python-arlo | pyarlo/base_station.py | ArloBaseStation.get_cameras_schedule | def get_cameras_schedule(self):
"""Return the schedule set for cameras."""
resource = "schedule"
schedule_event = self.publish_and_get_event(resource)
if schedule_event:
return schedule_event.get('properties')
return None | python | def get_cameras_schedule(self):
"""Return the schedule set for cameras."""
resource = "schedule"
schedule_event = self.publish_and_get_event(resource)
if schedule_event:
return schedule_event.get('properties')
return None | [
"def",
"get_cameras_schedule",
"(",
"self",
")",
":",
"resource",
"=",
"\"schedule\"",
"schedule_event",
"=",
"self",
".",
"publish_and_get_event",
"(",
"resource",
")",
"if",
"schedule_event",
":",
"return",
"schedule_event",
".",
"get",
"(",
"'properties'",
")",... | Return the schedule set for cameras. | [
"Return",
"the",
"schedule",
"set",
"for",
"cameras",
"."
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/base_station.py#L504-L511 | train |
tchellomello/python-arlo | pyarlo/base_station.py | ArloBaseStation.get_ambient_sensor_data | def get_ambient_sensor_data(self):
"""Refresh ambient sensor history"""
resource = 'cameras/{}/ambientSensors/history'.format(self.device_id)
history_event = self.publish_and_get_event(resource)
if history_event is None:
return None
properties = history_event.get('p... | python | def get_ambient_sensor_data(self):
"""Refresh ambient sensor history"""
resource = 'cameras/{}/ambientSensors/history'.format(self.device_id)
history_event = self.publish_and_get_event(resource)
if history_event is None:
return None
properties = history_event.get('p... | [
"def",
"get_ambient_sensor_data",
"(",
"self",
")",
":",
"resource",
"=",
"'cameras/{}/ambientSensors/history'",
".",
"format",
"(",
"self",
".",
"device_id",
")",
"history_event",
"=",
"self",
".",
"publish_and_get_event",
"(",
"resource",
")",
"if",
"history_event... | Refresh ambient sensor history | [
"Refresh",
"ambient",
"sensor",
"history"
] | db70aeb81705309c56ad32bbab1094f6cd146524 | https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/base_station.py#L543-L556 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.