repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
Hackerfleet/hfos | hfos/misc/__init__.py | i18n | def i18n(msg, event=None, lang='en', domain='backend'):
"""Gettext function wrapper to return a message in a specified language by domain
To use internationalization (i18n) on your messages, import it as '_' and use as usual.
Do not forget to supply the client's language setting."""
if event is not No... | python | def i18n(msg, event=None, lang='en', domain='backend'):
"""Gettext function wrapper to return a message in a specified language by domain
To use internationalization (i18n) on your messages, import it as '_' and use as usual.
Do not forget to supply the client's language setting."""
if event is not No... | [
"def",
"i18n",
"(",
"msg",
",",
"event",
"=",
"None",
",",
"lang",
"=",
"'en'",
",",
"domain",
"=",
"'backend'",
")",
":",
"if",
"event",
"is",
"not",
"None",
":",
"language",
"=",
"event",
".",
"client",
".",
"language",
"else",
":",
"language",
"... | Gettext function wrapper to return a message in a specified language by domain
To use internationalization (i18n) on your messages, import it as '_' and use as usual.
Do not forget to supply the client's language setting. | [
"Gettext",
"function",
"wrapper",
"to",
"return",
"a",
"message",
"in",
"a",
"specified",
"language",
"by",
"domain"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/misc/__init__.py#L92-L104 | train |
Hackerfleet/hfos | hfos/misc/__init__.py | std_hash | def std_hash(word, salt):
"""Generates a cryptographically strong (sha512) hash with this nodes
salt added."""
try:
password = word.encode('utf-8')
except UnicodeDecodeError:
password = word
word_hash = sha512(password)
word_hash.update(salt)
hex_hash = word_hash.hexdigest(... | python | def std_hash(word, salt):
"""Generates a cryptographically strong (sha512) hash with this nodes
salt added."""
try:
password = word.encode('utf-8')
except UnicodeDecodeError:
password = word
word_hash = sha512(password)
word_hash.update(salt)
hex_hash = word_hash.hexdigest(... | [
"def",
"std_hash",
"(",
"word",
",",
"salt",
")",
":",
"try",
":",
"password",
"=",
"word",
".",
"encode",
"(",
"'utf-8'",
")",
"except",
"UnicodeDecodeError",
":",
"password",
"=",
"word",
"word_hash",
"=",
"sha512",
"(",
"password",
")",
"word_hash",
"... | Generates a cryptographically strong (sha512) hash with this nodes
salt added. | [
"Generates",
"a",
"cryptographically",
"strong",
"(",
"sha512",
")",
"hash",
"with",
"this",
"nodes",
"salt",
"added",
"."
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/misc/__init__.py#L107-L120 | train |
Hackerfleet/hfos | hfos/misc/__init__.py | std_human_uid | def std_human_uid(kind=None):
"""Return a random generated human-friendly phrase as low-probability unique id"""
kind_list = alphabet
if kind == 'animal':
kind_list = animals
elif kind == 'place':
kind_list = places
name = "{color} {adjective} {kind} of {attribute}".format(
... | python | def std_human_uid(kind=None):
"""Return a random generated human-friendly phrase as low-probability unique id"""
kind_list = alphabet
if kind == 'animal':
kind_list = animals
elif kind == 'place':
kind_list = places
name = "{color} {adjective} {kind} of {attribute}".format(
... | [
"def",
"std_human_uid",
"(",
"kind",
"=",
"None",
")",
":",
"kind_list",
"=",
"alphabet",
"if",
"kind",
"==",
"'animal'",
":",
"kind_list",
"=",
"animals",
"elif",
"kind",
"==",
"'place'",
":",
"kind_list",
"=",
"places",
"name",
"=",
"\"{color} {adjective} ... | Return a random generated human-friendly phrase as low-probability unique id | [
"Return",
"a",
"random",
"generated",
"human",
"-",
"friendly",
"phrase",
"as",
"low",
"-",
"probability",
"unique",
"id"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/misc/__init__.py#L242-L259 | train |
Hackerfleet/hfos | hfos/misc/__init__.py | std_table | def std_table(rows):
"""Return a formatted table of given rows"""
result = ""
if len(rows) > 1:
headers = rows[0]._fields
lens = []
for i in range(len(rows[0])):
lens.append(len(max([x[i] for x in rows] + [headers[i]],
key=lambda x: len(st... | python | def std_table(rows):
"""Return a formatted table of given rows"""
result = ""
if len(rows) > 1:
headers = rows[0]._fields
lens = []
for i in range(len(rows[0])):
lens.append(len(max([x[i] for x in rows] + [headers[i]],
key=lambda x: len(st... | [
"def",
"std_table",
"(",
"rows",
")",
":",
"result",
"=",
"\"\"",
"if",
"len",
"(",
"rows",
")",
">",
"1",
":",
"headers",
"=",
"rows",
"[",
"0",
"]",
".",
"_fields",
"lens",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"rows",
... | Return a formatted table of given rows | [
"Return",
"a",
"formatted",
"table",
"of",
"given",
"rows"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/misc/__init__.py#L262-L294 | train |
Hackerfleet/hfos | hfos/misc/__init__.py | std_salt | def std_salt(length=16, lowercase=True):
"""Generates a cryptographically sane salt of 'length' (default: 16) alphanumeric
characters
"""
alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
if lowercase is True:
alphabet += "abcdefghijklmnopqrstuvwxyz"
chars = []
for i in range(lengt... | python | def std_salt(length=16, lowercase=True):
"""Generates a cryptographically sane salt of 'length' (default: 16) alphanumeric
characters
"""
alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
if lowercase is True:
alphabet += "abcdefghijklmnopqrstuvwxyz"
chars = []
for i in range(lengt... | [
"def",
"std_salt",
"(",
"length",
"=",
"16",
",",
"lowercase",
"=",
"True",
")",
":",
"alphabet",
"=",
"\"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\"",
"if",
"lowercase",
"is",
"True",
":",
"alphabet",
"+=",
"\"abcdefghijklmnopqrstuvwxyz\"",
"chars",
"=",
"[",
"]",
"... | Generates a cryptographically sane salt of 'length' (default: 16) alphanumeric
characters | [
"Generates",
"a",
"cryptographically",
"sane",
"salt",
"of",
"length",
"(",
"default",
":",
"16",
")",
"alphanumeric",
"characters"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/misc/__init__.py#L297-L310 | train |
Hackerfleet/hfos | hfos/misc/__init__.py | Domain._get_translation | def _get_translation(self, lang):
"""Add a new translation language to the live gettext translator"""
try:
return self._translations[lang]
except KeyError:
# The fact that `fallback=True` is not the default is a serious design flaw.
rv = self._translations[la... | python | def _get_translation(self, lang):
"""Add a new translation language to the live gettext translator"""
try:
return self._translations[lang]
except KeyError:
# The fact that `fallback=True` is not the default is a serious design flaw.
rv = self._translations[la... | [
"def",
"_get_translation",
"(",
"self",
",",
"lang",
")",
":",
"try",
":",
"return",
"self",
".",
"_translations",
"[",
"lang",
"]",
"except",
"KeyError",
":",
"# The fact that `fallback=True` is not the default is a serious design flaw.",
"rv",
"=",
"self",
".",
"_... | Add a new translation language to the live gettext translator | [
"Add",
"a",
"new",
"translation",
"language",
"to",
"the",
"live",
"gettext",
"translator"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/misc/__init__.py#L67-L76 | train |
Hackerfleet/hfos | hfos/component.py | handler | def handler(*names, **kwargs):
"""Creates an Event Handler
This decorator can be applied to methods of classes derived from
:class:`circuits.core.components.BaseComponent`. It marks the method as a
handler for the events passed as arguments to the ``@handler`` decorator.
The events are specified by... | python | def handler(*names, **kwargs):
"""Creates an Event Handler
This decorator can be applied to methods of classes derived from
:class:`circuits.core.components.BaseComponent`. It marks the method as a
handler for the events passed as arguments to the ``@handler`` decorator.
The events are specified by... | [
"def",
"handler",
"(",
"*",
"names",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"wrapper",
"(",
"f",
")",
":",
"if",
"names",
"and",
"isinstance",
"(",
"names",
"[",
"0",
"]",
",",
"bool",
")",
"and",
"not",
"names",
"[",
"0",
"]",
":",
"f",
"... | Creates an Event Handler
This decorator can be applied to methods of classes derived from
:class:`circuits.core.components.BaseComponent`. It marks the method as a
handler for the events passed as arguments to the ``@handler`` decorator.
The events are specified by their name.
The decorated method... | [
"Creates",
"an",
"Event",
"Handler"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/component.py#L64-L145 | train |
Hackerfleet/hfos | hfos/component.py | LoggingMeta.log | def log(self, *args, **kwargs):
"""Log a statement from this component"""
func = inspect.currentframe().f_back.f_code
# Dump the message + the name of this function to the log.
if 'exc' in kwargs and kwargs['exc'] is True:
exc_type, exc_obj, exc_tb = exc_info()
... | python | def log(self, *args, **kwargs):
"""Log a statement from this component"""
func = inspect.currentframe().f_back.f_code
# Dump the message + the name of this function to the log.
if 'exc' in kwargs and kwargs['exc'] is True:
exc_type, exc_obj, exc_tb = exc_info()
... | [
"def",
"log",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"func",
"=",
"inspect",
".",
"currentframe",
"(",
")",
".",
"f_back",
".",
"f_code",
"# Dump the message + the name of this function to the log.",
"if",
"'exc'",
"in",
"kwargs",
... | Log a statement from this component | [
"Log",
"a",
"statement",
"from",
"this",
"component"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/component.py#L175-L194 | train |
Hackerfleet/hfos | hfos/component.py | ConfigurableMeta.register | def register(self, *args):
"""Register a configurable component in the configuration schema
store"""
super(ConfigurableMeta, self).register(*args)
from hfos.database import configschemastore
# self.log('ADDING SCHEMA:')
# pprint(self.configschema)
configschemasto... | python | def register(self, *args):
"""Register a configurable component in the configuration schema
store"""
super(ConfigurableMeta, self).register(*args)
from hfos.database import configschemastore
# self.log('ADDING SCHEMA:')
# pprint(self.configschema)
configschemasto... | [
"def",
"register",
"(",
"self",
",",
"*",
"args",
")",
":",
"super",
"(",
"ConfigurableMeta",
",",
"self",
")",
".",
"register",
"(",
"*",
"args",
")",
"from",
"hfos",
".",
"database",
"import",
"configschemastore",
"# self.log('ADDING SCHEMA:')",
"# pprint(se... | Register a configurable component in the configuration schema
store | [
"Register",
"a",
"configurable",
"component",
"in",
"the",
"configuration",
"schema",
"store"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/component.py#L240-L248 | train |
Hackerfleet/hfos | hfos/component.py | ConfigurableMeta.unregister | def unregister(self):
"""Removes the unique name from the systems unique name list"""
self.names.remove(self.uniquename)
super(ConfigurableMeta, self).unregister() | python | def unregister(self):
"""Removes the unique name from the systems unique name list"""
self.names.remove(self.uniquename)
super(ConfigurableMeta, self).unregister() | [
"def",
"unregister",
"(",
"self",
")",
":",
"self",
".",
"names",
".",
"remove",
"(",
"self",
".",
"uniquename",
")",
"super",
"(",
"ConfigurableMeta",
",",
"self",
")",
".",
"unregister",
"(",
")"
] | Removes the unique name from the systems unique name list | [
"Removes",
"the",
"unique",
"name",
"from",
"the",
"systems",
"unique",
"name",
"list"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/component.py#L250-L253 | train |
Hackerfleet/hfos | hfos/component.py | ConfigurableMeta._read_config | def _read_config(self):
"""Read this component's configuration from the database"""
try:
self.config = self.componentmodel.find_one(
{'name': self.uniquename})
except ServerSelectionTimeoutError: # pragma: no cover
self.log("No database access! Check if ... | python | def _read_config(self):
"""Read this component's configuration from the database"""
try:
self.config = self.componentmodel.find_one(
{'name': self.uniquename})
except ServerSelectionTimeoutError: # pragma: no cover
self.log("No database access! Check if ... | [
"def",
"_read_config",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"config",
"=",
"self",
".",
"componentmodel",
".",
"find_one",
"(",
"{",
"'name'",
":",
"self",
".",
"uniquename",
"}",
")",
"except",
"ServerSelectionTimeoutError",
":",
"# pragma: no co... | Read this component's configuration from the database | [
"Read",
"this",
"component",
"s",
"configuration",
"from",
"the",
"database"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/component.py#L255-L267 | train |
Hackerfleet/hfos | hfos/component.py | ConfigurableMeta._write_config | def _write_config(self):
"""Write this component's configuration back to the database"""
if not self.config:
self.log("Unable to write non existing configuration", lvl=error)
return
self.config.save()
self.log("Configuration stored.") | python | def _write_config(self):
"""Write this component's configuration back to the database"""
if not self.config:
self.log("Unable to write non existing configuration", lvl=error)
return
self.config.save()
self.log("Configuration stored.") | [
"def",
"_write_config",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"config",
":",
"self",
".",
"log",
"(",
"\"Unable to write non existing configuration\"",
",",
"lvl",
"=",
"error",
")",
"return",
"self",
".",
"config",
".",
"save",
"(",
")",
"self"... | Write this component's configuration back to the database | [
"Write",
"this",
"component",
"s",
"configuration",
"back",
"to",
"the",
"database"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/component.py#L270-L278 | train |
Hackerfleet/hfos | hfos/component.py | ConfigurableMeta._set_config | def _set_config(self, config=None):
"""Set this component's initial configuration"""
if not config:
config = {}
try:
# pprint(self.configschema)
self.config = self.componentmodel(config)
# self.log("Config schema:", lvl=critical)
# ppr... | python | def _set_config(self, config=None):
"""Set this component's initial configuration"""
if not config:
config = {}
try:
# pprint(self.configschema)
self.config = self.componentmodel(config)
# self.log("Config schema:", lvl=critical)
# ppr... | [
"def",
"_set_config",
"(",
"self",
",",
"config",
"=",
"None",
")",
":",
"if",
"not",
"config",
":",
"config",
"=",
"{",
"}",
"try",
":",
"# pprint(self.configschema)",
"self",
".",
"config",
"=",
"self",
".",
"componentmodel",
"(",
"config",
")",
"# sel... | Set this component's initial configuration | [
"Set",
"this",
"component",
"s",
"initial",
"configuration"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/component.py#L280-L336 | train |
Hackerfleet/hfos | hfos/component.py | ConfigurableMeta.reload_configuration | def reload_configuration(self, event):
"""Event triggered configuration reload"""
if event.target == self.uniquename:
self.log('Reloading configuration')
self._read_config() | python | def reload_configuration(self, event):
"""Event triggered configuration reload"""
if event.target == self.uniquename:
self.log('Reloading configuration')
self._read_config() | [
"def",
"reload_configuration",
"(",
"self",
",",
"event",
")",
":",
"if",
"event",
".",
"target",
"==",
"self",
".",
"uniquename",
":",
"self",
".",
"log",
"(",
"'Reloading configuration'",
")",
"self",
".",
"_read_config",
"(",
")"
] | Event triggered configuration reload | [
"Event",
"triggered",
"configuration",
"reload"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/component.py#L341-L346 | train |
Hackerfleet/hfos | hfos/tool/create_module.py | _augment_info | def _augment_info(info):
"""Fill out the template information"""
info['description_header'] = "=" * len(info['description'])
info['component_name'] = info['plugin_name'].capitalize()
info['year'] = time.localtime().tm_year
info['license_longtext'] = ''
info['keyword_list'] = u""
for keywor... | python | def _augment_info(info):
"""Fill out the template information"""
info['description_header'] = "=" * len(info['description'])
info['component_name'] = info['plugin_name'].capitalize()
info['year'] = time.localtime().tm_year
info['license_longtext'] = ''
info['keyword_list'] = u""
for keywor... | [
"def",
"_augment_info",
"(",
"info",
")",
":",
"info",
"[",
"'description_header'",
"]",
"=",
"\"=\"",
"*",
"len",
"(",
"info",
"[",
"'description'",
"]",
")",
"info",
"[",
"'component_name'",
"]",
"=",
"info",
"[",
"'plugin_name'",
"]",
".",
"capitalize",... | Fill out the template information | [
"Fill",
"out",
"the",
"template",
"information"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/create_module.py#L89-L106 | train |
Hackerfleet/hfos | hfos/tool/create_module.py | _construct_module | def _construct_module(info, target):
"""Build a module from templates and user supplied information"""
for path in paths:
real_path = os.path.abspath(os.path.join(target, path.format(**info)))
log("Making directory '%s'" % real_path)
os.makedirs(real_path)
# pprint(info)
for it... | python | def _construct_module(info, target):
"""Build a module from templates and user supplied information"""
for path in paths:
real_path = os.path.abspath(os.path.join(target, path.format(**info)))
log("Making directory '%s'" % real_path)
os.makedirs(real_path)
# pprint(info)
for it... | [
"def",
"_construct_module",
"(",
"info",
",",
"target",
")",
":",
"for",
"path",
"in",
"paths",
":",
"real_path",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"target",
",",
"path",
".",
"format",
"(",
"*",
"*",... | Build a module from templates and user supplied information | [
"Build",
"a",
"module",
"from",
"templates",
"and",
"user",
"supplied",
"information"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/create_module.py#L109-L124 | train |
Hackerfleet/hfos | hfos/tool/create_module.py | _ask_questionnaire | def _ask_questionnaire():
"""Asks questions to fill out a HFOS plugin template"""
answers = {}
print(info_header)
pprint(questions.items())
for question, default in questions.items():
response = _ask(question, default, str(type(default)), show_hint=True)
if type(default) == unicode... | python | def _ask_questionnaire():
"""Asks questions to fill out a HFOS plugin template"""
answers = {}
print(info_header)
pprint(questions.items())
for question, default in questions.items():
response = _ask(question, default, str(type(default)), show_hint=True)
if type(default) == unicode... | [
"def",
"_ask_questionnaire",
"(",
")",
":",
"answers",
"=",
"{",
"}",
"print",
"(",
"info_header",
")",
"pprint",
"(",
"questions",
".",
"items",
"(",
")",
")",
"for",
"question",
",",
"default",
"in",
"questions",
".",
"items",
"(",
")",
":",
"respons... | Asks questions to fill out a HFOS plugin template | [
"Asks",
"questions",
"to",
"fill",
"out",
"a",
"HFOS",
"plugin",
"template"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/create_module.py#L127-L140 | train |
Hackerfleet/hfos | hfos/tool/create_module.py | create_module | def create_module(clear_target, target):
"""Creates a new template HFOS plugin module"""
if os.path.exists(target):
if clear_target:
shutil.rmtree(target)
else:
log("Target exists! Use --clear to delete it first.",
emitter='MANAGE')
sys.exit(2... | python | def create_module(clear_target, target):
"""Creates a new template HFOS plugin module"""
if os.path.exists(target):
if clear_target:
shutil.rmtree(target)
else:
log("Target exists! Use --clear to delete it first.",
emitter='MANAGE')
sys.exit(2... | [
"def",
"create_module",
"(",
"clear_target",
",",
"target",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"target",
")",
":",
"if",
"clear_target",
":",
"shutil",
".",
"rmtree",
"(",
"target",
")",
"else",
":",
"log",
"(",
"\"Target exists! Use ... | Creates a new template HFOS plugin module | [
"Creates",
"a",
"new",
"template",
"HFOS",
"plugin",
"module"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/create_module.py#L148-L170 | train |
Hackerfleet/hfos | hfos/schemata/defaultform.py | lookup_field | def lookup_field(key, lookup_type=None, placeholder=None, html_class="div",
select_type="strapselect", mapping="uuid"):
"""Generates a lookup field for form definitions"""
if lookup_type is None:
lookup_type = key
if placeholder is None:
placeholder = "Select a " + lookup_... | python | def lookup_field(key, lookup_type=None, placeholder=None, html_class="div",
select_type="strapselect", mapping="uuid"):
"""Generates a lookup field for form definitions"""
if lookup_type is None:
lookup_type = key
if placeholder is None:
placeholder = "Select a " + lookup_... | [
"def",
"lookup_field",
"(",
"key",
",",
"lookup_type",
"=",
"None",
",",
"placeholder",
"=",
"None",
",",
"html_class",
"=",
"\"div\"",
",",
"select_type",
"=",
"\"strapselect\"",
",",
"mapping",
"=",
"\"uuid\"",
")",
":",
"if",
"lookup_type",
"is",
"None",
... | Generates a lookup field for form definitions | [
"Generates",
"a",
"lookup",
"field",
"for",
"form",
"definitions"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/schemata/defaultform.py#L92-L114 | train |
Hackerfleet/hfos | hfos/schemata/defaultform.py | fieldset | def fieldset(title, items, options=None):
"""A field set with a title and sub items"""
result = {
'title': title,
'type': 'fieldset',
'items': items
}
if options is not None:
result.update(options)
return result | python | def fieldset(title, items, options=None):
"""A field set with a title and sub items"""
result = {
'title': title,
'type': 'fieldset',
'items': items
}
if options is not None:
result.update(options)
return result | [
"def",
"fieldset",
"(",
"title",
",",
"items",
",",
"options",
"=",
"None",
")",
":",
"result",
"=",
"{",
"'title'",
":",
"title",
",",
"'type'",
":",
"'fieldset'",
",",
"'items'",
":",
"items",
"}",
"if",
"options",
"is",
"not",
"None",
":",
"result... | A field set with a title and sub items | [
"A",
"field",
"set",
"with",
"a",
"title",
"and",
"sub",
"items"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/schemata/defaultform.py#L117-L127 | train |
Hackerfleet/hfos | hfos/schemata/defaultform.py | section | def section(rows, columns, items, label=None):
"""A section consisting of rows and columns"""
# TODO: Integrate label
sections = []
column_class = "section-column col-sm-%i" % (12 / columns)
for vertical in range(columns):
column_items = []
for horizontal in range(rows):
... | python | def section(rows, columns, items, label=None):
"""A section consisting of rows and columns"""
# TODO: Integrate label
sections = []
column_class = "section-column col-sm-%i" % (12 / columns)
for vertical in range(columns):
column_items = []
for horizontal in range(rows):
... | [
"def",
"section",
"(",
"rows",
",",
"columns",
",",
"items",
",",
"label",
"=",
"None",
")",
":",
"# TODO: Integrate label",
"sections",
"=",
"[",
"]",
"column_class",
"=",
"\"section-column col-sm-%i\"",
"%",
"(",
"12",
"/",
"columns",
")",
"for",
"vertical... | A section consisting of rows and columns | [
"A",
"section",
"consisting",
"of",
"rows",
"and",
"columns"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/schemata/defaultform.py#L130-L162 | train |
Hackerfleet/hfos | hfos/schemata/defaultform.py | emptyArray | def emptyArray(key, add_label=None):
"""An array that starts empty"""
result = {
'key': key,
'startEmpty': True
}
if add_label is not None:
result['add'] = add_label
result['style'] = {'add': 'btn-success'}
return result | python | def emptyArray(key, add_label=None):
"""An array that starts empty"""
result = {
'key': key,
'startEmpty': True
}
if add_label is not None:
result['add'] = add_label
result['style'] = {'add': 'btn-success'}
return result | [
"def",
"emptyArray",
"(",
"key",
",",
"add_label",
"=",
"None",
")",
":",
"result",
"=",
"{",
"'key'",
":",
"key",
",",
"'startEmpty'",
":",
"True",
"}",
"if",
"add_label",
"is",
"not",
"None",
":",
"result",
"[",
"'add'",
"]",
"=",
"add_label",
"res... | An array that starts empty | [
"An",
"array",
"that",
"starts",
"empty"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/schemata/defaultform.py#L165-L175 | train |
Hackerfleet/hfos | hfos/schemata/defaultform.py | tabset | def tabset(titles, contents):
"""A tabbed container widget"""
tabs = []
for no, title in enumerate(titles):
tab = {
'title': title,
}
content = contents[no]
if isinstance(content, list):
tab['items'] = content
else:
tab['items'] = ... | python | def tabset(titles, contents):
"""A tabbed container widget"""
tabs = []
for no, title in enumerate(titles):
tab = {
'title': title,
}
content = contents[no]
if isinstance(content, list):
tab['items'] = content
else:
tab['items'] = ... | [
"def",
"tabset",
"(",
"titles",
",",
"contents",
")",
":",
"tabs",
"=",
"[",
"]",
"for",
"no",
",",
"title",
"in",
"enumerate",
"(",
"titles",
")",
":",
"tab",
"=",
"{",
"'title'",
":",
"title",
",",
"}",
"content",
"=",
"contents",
"[",
"no",
"]... | A tabbed container widget | [
"A",
"tabbed",
"container",
"widget"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/schemata/defaultform.py#L178-L198 | train |
Hackerfleet/hfos | hfos/schemata/defaultform.py | country_field | def country_field(key='country'):
"""Provides a select box for country selection"""
country_list = list(countries)
title_map = []
for item in country_list:
title_map.append({'value': item.alpha_3, 'name': item.name})
widget = {
'key': key,
'type': 'uiselect',
'title... | python | def country_field(key='country'):
"""Provides a select box for country selection"""
country_list = list(countries)
title_map = []
for item in country_list:
title_map.append({'value': item.alpha_3, 'name': item.name})
widget = {
'key': key,
'type': 'uiselect',
'title... | [
"def",
"country_field",
"(",
"key",
"=",
"'country'",
")",
":",
"country_list",
"=",
"list",
"(",
"countries",
")",
"title_map",
"=",
"[",
"]",
"for",
"item",
"in",
"country_list",
":",
"title_map",
".",
"append",
"(",
"{",
"'value'",
":",
"item",
".",
... | Provides a select box for country selection | [
"Provides",
"a",
"select",
"box",
"for",
"country",
"selection"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/schemata/defaultform.py#L238-L252 | train |
Hackerfleet/hfos | hfos/schemata/defaultform.py | area_field | def area_field(key='area'):
"""Provides a select box for country selection"""
area_list = list(subdivisions)
title_map = []
for item in area_list:
title_map.append({'value': item.code, 'name': item.name})
widget = {
'key': key,
'type': 'uiselect',
'titleMap': title_... | python | def area_field(key='area'):
"""Provides a select box for country selection"""
area_list = list(subdivisions)
title_map = []
for item in area_list:
title_map.append({'value': item.code, 'name': item.name})
widget = {
'key': key,
'type': 'uiselect',
'titleMap': title_... | [
"def",
"area_field",
"(",
"key",
"=",
"'area'",
")",
":",
"area_list",
"=",
"list",
"(",
"subdivisions",
")",
"title_map",
"=",
"[",
"]",
"for",
"item",
"in",
"area_list",
":",
"title_map",
".",
"append",
"(",
"{",
"'value'",
":",
"item",
".",
"code",
... | Provides a select box for country selection | [
"Provides",
"a",
"select",
"box",
"for",
"country",
"selection"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/schemata/defaultform.py#L255-L269 | train |
Hackerfleet/hfos | modules/comms/hfos/comms/connectivity.py | ConnectivityMonitor.timed_connectivity_check | def timed_connectivity_check(self, event):
"""Tests internet connectivity in regular intervals and updates the nodestate accordingly"""
self.status = self._can_connect()
self.log('Timed connectivity check:', self.status, lvl=verbose)
if self.status:
if not self.old_status:
... | python | def timed_connectivity_check(self, event):
"""Tests internet connectivity in regular intervals and updates the nodestate accordingly"""
self.status = self._can_connect()
self.log('Timed connectivity check:', self.status, lvl=verbose)
if self.status:
if not self.old_status:
... | [
"def",
"timed_connectivity_check",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"status",
"=",
"self",
".",
"_can_connect",
"(",
")",
"self",
".",
"log",
"(",
"'Timed connectivity check:'",
",",
"self",
".",
"status",
",",
"lvl",
"=",
"verbose",
")",
... | Tests internet connectivity in regular intervals and updates the nodestate accordingly | [
"Tests",
"internet",
"connectivity",
"in",
"regular",
"intervals",
"and",
"updates",
"the",
"nodestate",
"accordingly"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/comms/hfos/comms/connectivity.py#L106-L121 | train |
Hackerfleet/hfos | modules/comms/hfos/comms/connectivity.py | ConnectivityMonitor._can_connect | def _can_connect(self):
"""Tries to connect to the configured host:port and returns True if the connection was established"""
self.log('Trying to reach configured connectivity check endpoint', lvl=verbose)
try:
socket.setdefaulttimeout(self.config.timeout)
socket.socket(... | python | def _can_connect(self):
"""Tries to connect to the configured host:port and returns True if the connection was established"""
self.log('Trying to reach configured connectivity check endpoint', lvl=verbose)
try:
socket.setdefaulttimeout(self.config.timeout)
socket.socket(... | [
"def",
"_can_connect",
"(",
"self",
")",
":",
"self",
".",
"log",
"(",
"'Trying to reach configured connectivity check endpoint'",
",",
"lvl",
"=",
"verbose",
")",
"try",
":",
"socket",
".",
"setdefaulttimeout",
"(",
"self",
".",
"config",
".",
"timeout",
")",
... | Tries to connect to the configured host:port and returns True if the connection was established | [
"Tries",
"to",
"connect",
"to",
"the",
"configured",
"host",
":",
"port",
"and",
"returns",
"True",
"if",
"the",
"connection",
"was",
"established"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/comms/hfos/comms/connectivity.py#L123-L133 | train |
Hackerfleet/hfos | hfos/ui/activitymonitor.py | ActivityMonitor.referenceframe | def referenceframe(self, event):
"""Handles navigational reference frame updates.
These are necessary to assign geo coordinates to alerts and other
misc things.
:param event with incoming referenceframe message
"""
self.log("Got a reference frame update! ", event, lvl=v... | python | def referenceframe(self, event):
"""Handles navigational reference frame updates.
These are necessary to assign geo coordinates to alerts and other
misc things.
:param event with incoming referenceframe message
"""
self.log("Got a reference frame update! ", event, lvl=v... | [
"def",
"referenceframe",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"log",
"(",
"\"Got a reference frame update! \"",
",",
"event",
",",
"lvl",
"=",
"verbose",
")",
"self",
".",
"referenceframe",
"=",
"event",
".",
"data"
] | Handles navigational reference frame updates.
These are necessary to assign geo coordinates to alerts and other
misc things.
:param event with incoming referenceframe message | [
"Handles",
"navigational",
"reference",
"frame",
"updates",
".",
"These",
"are",
"necessary",
"to",
"assign",
"geo",
"coordinates",
"to",
"alerts",
"and",
"other",
"misc",
"things",
"."
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/activitymonitor.py#L69-L79 | train |
Hackerfleet/hfos | hfos/ui/activitymonitor.py | ActivityMonitor.activityrequest | def activityrequest(self, event):
"""ActivityMonitor event handler for incoming events
:param event with incoming ActivityMonitor message
"""
# self.log("Event: '%s'" % event.__dict__)
try:
action = event.action
data = event.data
self.log("A... | python | def activityrequest(self, event):
"""ActivityMonitor event handler for incoming events
:param event with incoming ActivityMonitor message
"""
# self.log("Event: '%s'" % event.__dict__)
try:
action = event.action
data = event.data
self.log("A... | [
"def",
"activityrequest",
"(",
"self",
",",
"event",
")",
":",
"# self.log(\"Event: '%s'\" % event.__dict__)",
"try",
":",
"action",
"=",
"event",
".",
"action",
"data",
"=",
"event",
".",
"data",
"self",
".",
"log",
"(",
"\"Activityrequest: \"",
",",
"action",
... | ActivityMonitor event handler for incoming events
:param event with incoming ActivityMonitor message | [
"ActivityMonitor",
"event",
"handler",
"for",
"incoming",
"events"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/activitymonitor.py#L87-L101 | train |
Hackerfleet/hfos | hfos/tool/objects.py | modify | def modify(ctx, schema, uuid, object_filter, field, value):
"""Modify field values of objects"""
database = ctx.obj['db']
model = database.objectmodels[schema]
obj = None
if uuid:
obj = model.find_one({'uuid': uuid})
elif object_filter:
obj = model.find_one(literal_eval(object_... | python | def modify(ctx, schema, uuid, object_filter, field, value):
"""Modify field values of objects"""
database = ctx.obj['db']
model = database.objectmodels[schema]
obj = None
if uuid:
obj = model.find_one({'uuid': uuid})
elif object_filter:
obj = model.find_one(literal_eval(object_... | [
"def",
"modify",
"(",
"ctx",
",",
"schema",
",",
"uuid",
",",
"object_filter",
",",
"field",
",",
"value",
")",
":",
"database",
"=",
"ctx",
".",
"obj",
"[",
"'db'",
"]",
"model",
"=",
"database",
".",
"objectmodels",
"[",
"schema",
"]",
"obj",
"=",
... | Modify field values of objects | [
"Modify",
"field",
"values",
"of",
"objects"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/objects.py#L51-L82 | train |
Hackerfleet/hfos | hfos/tool/objects.py | view | def view(ctx, schema, uuid, object_filter):
"""Show stored objects"""
database = ctx.obj['db']
if schema is None:
log('No schema given. Read the help', lvl=warn)
return
model = database.objectmodels[schema]
if uuid:
obj = model.find({'uuid': uuid})
elif object_filter:... | python | def view(ctx, schema, uuid, object_filter):
"""Show stored objects"""
database = ctx.obj['db']
if schema is None:
log('No schema given. Read the help', lvl=warn)
return
model = database.objectmodels[schema]
if uuid:
obj = model.find({'uuid': uuid})
elif object_filter:... | [
"def",
"view",
"(",
"ctx",
",",
"schema",
",",
"uuid",
",",
"object_filter",
")",
":",
"database",
"=",
"ctx",
".",
"obj",
"[",
"'db'",
"]",
"if",
"schema",
"is",
"None",
":",
"log",
"(",
"'No schema given. Read the help'",
",",
"lvl",
"=",
"warn",
")"... | Show stored objects | [
"Show",
"stored",
"objects"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/objects.py#L90-L109 | train |
Hackerfleet/hfos | hfos/tool/objects.py | delete | def delete(ctx, schema, uuid, object_filter, yes):
"""Delete stored objects (CAUTION!)"""
database = ctx.obj['db']
if schema is None:
log('No schema given. Read the help', lvl=warn)
return
model = database.objectmodels[schema]
if uuid:
count = model.count({'uuid': uuid})
... | python | def delete(ctx, schema, uuid, object_filter, yes):
"""Delete stored objects (CAUTION!)"""
database = ctx.obj['db']
if schema is None:
log('No schema given. Read the help', lvl=warn)
return
model = database.objectmodels[schema]
if uuid:
count = model.count({'uuid': uuid})
... | [
"def",
"delete",
"(",
"ctx",
",",
"schema",
",",
"uuid",
",",
"object_filter",
",",
"yes",
")",
":",
"database",
"=",
"ctx",
".",
"obj",
"[",
"'db'",
"]",
"if",
"schema",
"is",
"None",
":",
"log",
"(",
"'No schema given. Read the help'",
",",
"lvl",
"=... | Delete stored objects (CAUTION!) | [
"Delete",
"stored",
"objects",
"(",
"CAUTION!",
")"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/objects.py#L118-L150 | train |
Hackerfleet/hfos | hfos/tool/objects.py | validate | def validate(ctx, schema, all_schemata):
"""Validates all objects or all objects of a given schema."""
database = ctx.obj['db']
if schema is None:
if all_schemata is False:
log('No schema given. Read the help', lvl=warn)
return
else:
schemata = database.... | python | def validate(ctx, schema, all_schemata):
"""Validates all objects or all objects of a given schema."""
database = ctx.obj['db']
if schema is None:
if all_schemata is False:
log('No schema given. Read the help', lvl=warn)
return
else:
schemata = database.... | [
"def",
"validate",
"(",
"ctx",
",",
"schema",
",",
"all_schemata",
")",
":",
"database",
"=",
"ctx",
".",
"obj",
"[",
"'db'",
"]",
"if",
"schema",
"is",
"None",
":",
"if",
"all_schemata",
"is",
"False",
":",
"log",
"(",
"'No schema given. Read the help'",
... | Validates all objects or all objects of a given schema. | [
"Validates",
"all",
"objects",
"or",
"all",
"objects",
"of",
"a",
"given",
"schema",
"."
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/objects.py#L158-L186 | train |
Hackerfleet/hfos | hfos/tool/objects.py | find_field | def find_field(ctx, search, by_type, obj):
"""Find fields in registered data models."""
# TODO: Fix this to work recursively on all possible subschemes
if search is not None:
search = search
else:
search = _ask("Enter search term")
database = ctx.obj['db']
def find(search_sche... | python | def find_field(ctx, search, by_type, obj):
"""Find fields in registered data models."""
# TODO: Fix this to work recursively on all possible subschemes
if search is not None:
search = search
else:
search = _ask("Enter search term")
database = ctx.obj['db']
def find(search_sche... | [
"def",
"find_field",
"(",
"ctx",
",",
"search",
",",
"by_type",
",",
"obj",
")",
":",
"# TODO: Fix this to work recursively on all possible subschemes",
"if",
"search",
"is",
"not",
"None",
":",
"search",
"=",
"search",
"else",
":",
"search",
"=",
"_ask",
"(",
... | Find fields in registered data models. | [
"Find",
"fields",
"in",
"registered",
"data",
"models",
"."
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/objects.py#L198-L263 | train |
Hackerfleet/hfos | modules/dev/hfos/misc/vesselsim.py | Distance | def Distance(lat1, lon1, lat2, lon2):
"""Get distance between pairs of lat-lon points"""
az12, az21, dist = wgs84_geod.inv(lon1, lat1, lon2, lat2)
return az21, dist | python | def Distance(lat1, lon1, lat2, lon2):
"""Get distance between pairs of lat-lon points"""
az12, az21, dist = wgs84_geod.inv(lon1, lat1, lon2, lat2)
return az21, dist | [
"def",
"Distance",
"(",
"lat1",
",",
"lon1",
",",
"lat2",
",",
"lon2",
")",
":",
"az12",
",",
"az21",
",",
"dist",
"=",
"wgs84_geod",
".",
"inv",
"(",
"lon1",
",",
"lat1",
",",
"lon2",
",",
"lat2",
")",
"return",
"az21",
",",
"dist"
] | Get distance between pairs of lat-lon points | [
"Get",
"distance",
"between",
"pairs",
"of",
"lat",
"-",
"lon",
"points"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/dev/hfos/misc/vesselsim.py#L54-L58 | train |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager.client_details | def client_details(self, *args):
"""Display known details about a given client"""
self.log(_('Client details:', lang='de'))
client = self._clients[args[0]]
self.log('UUID:', client.uuid, 'IP:', client.ip, 'Name:', client.name, 'User:', self._users[client.useruuid],
pre... | python | def client_details(self, *args):
"""Display known details about a given client"""
self.log(_('Client details:', lang='de'))
client = self._clients[args[0]]
self.log('UUID:', client.uuid, 'IP:', client.ip, 'Name:', client.name, 'User:', self._users[client.useruuid],
pre... | [
"def",
"client_details",
"(",
"self",
",",
"*",
"args",
")",
":",
"self",
".",
"log",
"(",
"_",
"(",
"'Client details:'",
",",
"lang",
"=",
"'de'",
")",
")",
"client",
"=",
"self",
".",
"_clients",
"[",
"args",
"[",
"0",
"]",
"]",
"self",
".",
"l... | Display known details about a given client | [
"Display",
"known",
"details",
"about",
"a",
"given",
"client"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L155-L162 | train |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager.client_list | def client_list(self, *args):
"""Display a list of connected clients"""
if len(self._clients) == 0:
self.log('No clients connected')
else:
self.log(self._clients, pretty=True) | python | def client_list(self, *args):
"""Display a list of connected clients"""
if len(self._clients) == 0:
self.log('No clients connected')
else:
self.log(self._clients, pretty=True) | [
"def",
"client_list",
"(",
"self",
",",
"*",
"args",
")",
":",
"if",
"len",
"(",
"self",
".",
"_clients",
")",
"==",
"0",
":",
"self",
".",
"log",
"(",
"'No clients connected'",
")",
"else",
":",
"self",
".",
"log",
"(",
"self",
".",
"_clients",
",... | Display a list of connected clients | [
"Display",
"a",
"list",
"of",
"connected",
"clients"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L165-L170 | train |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager.users_list | def users_list(self, *args):
"""Display a list of connected users"""
if len(self._users) == 0:
self.log('No users connected')
else:
self.log(self._users, pretty=True) | python | def users_list(self, *args):
"""Display a list of connected users"""
if len(self._users) == 0:
self.log('No users connected')
else:
self.log(self._users, pretty=True) | [
"def",
"users_list",
"(",
"self",
",",
"*",
"args",
")",
":",
"if",
"len",
"(",
"self",
".",
"_users",
")",
"==",
"0",
":",
"self",
".",
"log",
"(",
"'No users connected'",
")",
"else",
":",
"self",
".",
"log",
"(",
"self",
".",
"_users",
",",
"p... | Display a list of connected users | [
"Display",
"a",
"list",
"of",
"connected",
"users"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L173-L178 | train |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager.sourcess_list | def sourcess_list(self, *args):
"""Display a list of all registered events"""
from pprint import pprint
sources = {}
sources.update(self.authorized_events)
sources.update(self.anonymous_events)
for source in sources:
pprint(source) | python | def sourcess_list(self, *args):
"""Display a list of all registered events"""
from pprint import pprint
sources = {}
sources.update(self.authorized_events)
sources.update(self.anonymous_events)
for source in sources:
pprint(source) | [
"def",
"sourcess_list",
"(",
"self",
",",
"*",
"args",
")",
":",
"from",
"pprint",
"import",
"pprint",
"sources",
"=",
"{",
"}",
"sources",
".",
"update",
"(",
"self",
".",
"authorized_events",
")",
"sources",
".",
"update",
"(",
"self",
".",
"anonymous_... | Display a list of all registered events | [
"Display",
"a",
"list",
"of",
"all",
"registered",
"events"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L181-L191 | train |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager.events_list | def events_list(self, *args):
"""Display a list of all registered events"""
def merge(a, b, path=None):
"merges b into a"
if path is None: path = []
for key in b:
if key in a:
if isinstance(a[key], dict) and isinstance(b[key], dict... | python | def events_list(self, *args):
"""Display a list of all registered events"""
def merge(a, b, path=None):
"merges b into a"
if path is None: path = []
for key in b:
if key in a:
if isinstance(a[key], dict) and isinstance(b[key], dict... | [
"def",
"events_list",
"(",
"self",
",",
"*",
"args",
")",
":",
"def",
"merge",
"(",
"a",
",",
"b",
",",
"path",
"=",
"None",
")",
":",
"\"merges b into a\"",
"if",
"path",
"is",
"None",
":",
"path",
"=",
"[",
"]",
"for",
"key",
"in",
"b",
":",
... | Display a list of all registered events | [
"Display",
"a",
"list",
"of",
"all",
"registered",
"events"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L194-L220 | train |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager.who | def who(self, *args):
"""Display a table of connected users and clients"""
if len(self._users) == 0:
self.log('No users connected')
if len(self._clients) == 0:
self.log('No clients connected')
return
Row = namedtuple("Row", ['User', 'Clien... | python | def who(self, *args):
"""Display a table of connected users and clients"""
if len(self._users) == 0:
self.log('No users connected')
if len(self._clients) == 0:
self.log('No clients connected')
return
Row = namedtuple("Row", ['User', 'Clien... | [
"def",
"who",
"(",
"self",
",",
"*",
"args",
")",
":",
"if",
"len",
"(",
"self",
".",
"_users",
")",
"==",
"0",
":",
"self",
".",
"log",
"(",
"'No users connected'",
")",
"if",
"len",
"(",
"self",
".",
"_clients",
")",
"==",
"0",
":",
"self",
"... | Display a table of connected users and clients | [
"Display",
"a",
"table",
"of",
"connected",
"users",
"and",
"clients"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L223-L245 | train |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager.disconnect | def disconnect(self, sock):
"""Handles socket disconnections"""
self.log("Disconnect ", sock, lvl=debug)
try:
if sock in self._sockets:
self.log("Getting socket", lvl=debug)
sockobj = self._sockets[sock]
self.log("Getting clientuuid",... | python | def disconnect(self, sock):
"""Handles socket disconnections"""
self.log("Disconnect ", sock, lvl=debug)
try:
if sock in self._sockets:
self.log("Getting socket", lvl=debug)
sockobj = self._sockets[sock]
self.log("Getting clientuuid",... | [
"def",
"disconnect",
"(",
"self",
",",
"sock",
")",
":",
"self",
".",
"log",
"(",
"\"Disconnect \"",
",",
"sock",
",",
"lvl",
"=",
"debug",
")",
"try",
":",
"if",
"sock",
"in",
"self",
".",
"_sockets",
":",
"self",
".",
"log",
"(",
"\"Getting socket\... | Handles socket disconnections | [
"Handles",
"socket",
"disconnections"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L255-L290 | train |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager._logoutclient | def _logoutclient(self, useruuid, clientuuid):
"""Log out a client and possibly associated user"""
self.log("Cleaning up client of logged in user.", lvl=debug)
try:
self._users[useruuid].clients.remove(clientuuid)
if len(self._users[useruuid].clients) == 0:
... | python | def _logoutclient(self, useruuid, clientuuid):
"""Log out a client and possibly associated user"""
self.log("Cleaning up client of logged in user.", lvl=debug)
try:
self._users[useruuid].clients.remove(clientuuid)
if len(self._users[useruuid].clients) == 0:
... | [
"def",
"_logoutclient",
"(",
"self",
",",
"useruuid",
",",
"clientuuid",
")",
":",
"self",
".",
"log",
"(",
"\"Cleaning up client of logged in user.\"",
",",
"lvl",
"=",
"debug",
")",
"try",
":",
"self",
".",
"_users",
"[",
"useruuid",
"]",
".",
"clients",
... | Log out a client and possibly associated user | [
"Log",
"out",
"a",
"client",
"and",
"possibly",
"associated",
"user"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L292-L308 | train |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager.connect | def connect(self, *args):
"""Registers new sockets and their clients and allocates uuids"""
self.log("Connect ", args, lvl=verbose)
try:
sock = args[0]
ip = args[1]
if sock not in self._sockets:
self.log("New client connected:", ip, lvl=debu... | python | def connect(self, *args):
"""Registers new sockets and their clients and allocates uuids"""
self.log("Connect ", args, lvl=verbose)
try:
sock = args[0]
ip = args[1]
if sock not in self._sockets:
self.log("New client connected:", ip, lvl=debu... | [
"def",
"connect",
"(",
"self",
",",
"*",
"args",
")",
":",
"self",
".",
"log",
"(",
"\"Connect \"",
",",
"args",
",",
"lvl",
"=",
"verbose",
")",
"try",
":",
"sock",
"=",
"args",
"[",
"0",
"]",
"ip",
"=",
"args",
"[",
"1",
"]",
"if",
"sock",
... | Registers new sockets and their clients and allocates uuids | [
"Registers",
"new",
"sockets",
"and",
"their",
"clients",
"and",
"allocates",
"uuids"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L311-L340 | train |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager.send | def send(self, event):
"""Sends a packet to an already known user or one of his clients by
UUID"""
try:
jsonpacket = json.dumps(event.packet, cls=ComplexEncoder)
if event.sendtype == "user":
# TODO: I think, caching a user name <-> uuid table would
... | python | def send(self, event):
"""Sends a packet to an already known user or one of his clients by
UUID"""
try:
jsonpacket = json.dumps(event.packet, cls=ComplexEncoder)
if event.sendtype == "user":
# TODO: I think, caching a user name <-> uuid table would
... | [
"def",
"send",
"(",
"self",
",",
"event",
")",
":",
"try",
":",
"jsonpacket",
"=",
"json",
".",
"dumps",
"(",
"event",
".",
"packet",
",",
"cls",
"=",
"ComplexEncoder",
")",
"if",
"event",
".",
"sendtype",
"==",
"\"user\"",
":",
"# TODO: I think, caching... | Sends a packet to an already known user or one of his clients by
UUID | [
"Sends",
"a",
"packet",
"to",
"an",
"already",
"known",
"user",
"or",
"one",
"of",
"his",
"clients",
"by",
"UUID"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L342-L403 | train |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager.broadcast | def broadcast(self, event):
"""Broadcasts an event either to all users or clients, depending on
event flag"""
try:
if event.broadcasttype == "users":
if len(self._users) > 0:
self.log("Broadcasting to all users:",
event... | python | def broadcast(self, event):
"""Broadcasts an event either to all users or clients, depending on
event flag"""
try:
if event.broadcasttype == "users":
if len(self._users) > 0:
self.log("Broadcasting to all users:",
event... | [
"def",
"broadcast",
"(",
"self",
",",
"event",
")",
":",
"try",
":",
"if",
"event",
".",
"broadcasttype",
"==",
"\"users\"",
":",
"if",
"len",
"(",
"self",
".",
"_users",
")",
">",
"0",
":",
"self",
".",
"log",
"(",
"\"Broadcasting to all users:\"",
",... | Broadcasts an event either to all users or clients, depending on
event flag | [
"Broadcasts",
"an",
"event",
"either",
"to",
"all",
"users",
"or",
"clients",
"depending",
"on",
"event",
"flag"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L405-L443 | train |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager._checkPermissions | def _checkPermissions(self, user, event):
"""Checks if the user has in any role that allows to fire the event."""
for role in user.account.roles:
if role in event.roles:
self.log('Access granted', lvl=verbose)
return True
self.log('Access denied', lv... | python | def _checkPermissions(self, user, event):
"""Checks if the user has in any role that allows to fire the event."""
for role in user.account.roles:
if role in event.roles:
self.log('Access granted', lvl=verbose)
return True
self.log('Access denied', lv... | [
"def",
"_checkPermissions",
"(",
"self",
",",
"user",
",",
"event",
")",
":",
"for",
"role",
"in",
"user",
".",
"account",
".",
"roles",
":",
"if",
"role",
"in",
"event",
".",
"roles",
":",
"self",
".",
"log",
"(",
"'Access granted'",
",",
"lvl",
"="... | Checks if the user has in any role that allows to fire the event. | [
"Checks",
"if",
"the",
"user",
"has",
"in",
"any",
"role",
"that",
"allows",
"to",
"fire",
"the",
"event",
"."
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L445-L454 | train |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager._handleAuthorizedEvents | def _handleAuthorizedEvents(self, component, action, data, user, client):
"""Isolated communication link for authorized events."""
try:
if component == "debugger":
self.log(component, action, data, user, client, lvl=info)
if not user and component in self.author... | python | def _handleAuthorizedEvents(self, component, action, data, user, client):
"""Isolated communication link for authorized events."""
try:
if component == "debugger":
self.log(component, action, data, user, client, lvl=info)
if not user and component in self.author... | [
"def",
"_handleAuthorizedEvents",
"(",
"self",
",",
"component",
",",
"action",
",",
"data",
",",
"user",
",",
"client",
")",
":",
"try",
":",
"if",
"component",
"==",
"\"debugger\"",
":",
"self",
".",
"log",
"(",
"component",
",",
"action",
",",
"data",... | Isolated communication link for authorized events. | [
"Isolated",
"communication",
"link",
"for",
"authorized",
"events",
"."
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L456-L488 | train |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager._handleAnonymousEvents | def _handleAnonymousEvents(self, component, action, data, client):
"""Handler for anonymous (public) events"""
try:
event = self.anonymous_events[component][action]['event']
self.log("Firing anonymous event: ", component, action,
str(data)[:20], lvl=network)... | python | def _handleAnonymousEvents(self, component, action, data, client):
"""Handler for anonymous (public) events"""
try:
event = self.anonymous_events[component][action]['event']
self.log("Firing anonymous event: ", component, action,
str(data)[:20], lvl=network)... | [
"def",
"_handleAnonymousEvents",
"(",
"self",
",",
"component",
",",
"action",
",",
"data",
",",
"client",
")",
":",
"try",
":",
"event",
"=",
"self",
".",
"anonymous_events",
"[",
"component",
"]",
"[",
"action",
"]",
"[",
"'event'",
"]",
"self",
".",
... | Handler for anonymous (public) events | [
"Handler",
"for",
"anonymous",
"(",
"public",
")",
"events"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L490-L502 | train |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager._handleAuthenticationEvents | def _handleAuthenticationEvents(self, requestdata, requestaction,
clientuuid, sock):
"""Handler for authentication events"""
# TODO: Move this stuff over to ./auth.py
if requestaction in ("login", "autologin"):
try:
self.log("Login... | python | def _handleAuthenticationEvents(self, requestdata, requestaction,
clientuuid, sock):
"""Handler for authentication events"""
# TODO: Move this stuff over to ./auth.py
if requestaction in ("login", "autologin"):
try:
self.log("Login... | [
"def",
"_handleAuthenticationEvents",
"(",
"self",
",",
"requestdata",
",",
"requestaction",
",",
"clientuuid",
",",
"sock",
")",
":",
"# TODO: Move this stuff over to ./auth.py",
"if",
"requestaction",
"in",
"(",
"\"login\"",
",",
"\"autologin\"",
")",
":",
"try",
... | Handler for authentication events | [
"Handler",
"for",
"authentication",
"events"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L504-L559 | train |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager._reset_flood_offenders | def _reset_flood_offenders(self, *args):
"""Resets the list of flood offenders on event trigger"""
offenders = []
# self.log('Resetting flood offenders')
for offender, offence_time in self._flooding.items():
if time() - offence_time < 10:
self.log('Removed o... | python | def _reset_flood_offenders(self, *args):
"""Resets the list of flood offenders on event trigger"""
offenders = []
# self.log('Resetting flood offenders')
for offender, offence_time in self._flooding.items():
if time() - offence_time < 10:
self.log('Removed o... | [
"def",
"_reset_flood_offenders",
"(",
"self",
",",
"*",
"args",
")",
":",
"offenders",
"=",
"[",
"]",
"# self.log('Resetting flood offenders')",
"for",
"offender",
",",
"offence_time",
"in",
"self",
".",
"_flooding",
".",
"items",
"(",
")",
":",
"if",
"time",
... | Resets the list of flood offenders on event trigger | [
"Resets",
"the",
"list",
"of",
"flood",
"offenders",
"on",
"event",
"trigger"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L569-L581 | train |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager._check_flood_protection | def _check_flood_protection(self, component, action, clientuuid):
"""Checks if any clients have been flooding the node"""
if clientuuid not in self._flood_counter:
self._flood_counter[clientuuid] = 0
self._flood_counter[clientuuid] += 1
if self._flood_counter[clientuuid] >... | python | def _check_flood_protection(self, component, action, clientuuid):
"""Checks if any clients have been flooding the node"""
if clientuuid not in self._flood_counter:
self._flood_counter[clientuuid] = 0
self._flood_counter[clientuuid] += 1
if self._flood_counter[clientuuid] >... | [
"def",
"_check_flood_protection",
"(",
"self",
",",
"component",
",",
"action",
",",
"clientuuid",
")",
":",
"if",
"clientuuid",
"not",
"in",
"self",
".",
"_flood_counter",
":",
"self",
".",
"_flood_counter",
"[",
"clientuuid",
"]",
"=",
"0",
"self",
".",
... | Checks if any clients have been flooding the node | [
"Checks",
"if",
"any",
"clients",
"have",
"been",
"flooding",
"the",
"node"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L583-L599 | train |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager.read | def read(self, *args):
"""Handles raw client requests and distributes them to the
appropriate components"""
self.log("Beginning new transaction: ", args, lvl=network)
try:
sock, msg = args[0], args[1]
user = password = client = clientuuid = useruuid = requestdata... | python | def read(self, *args):
"""Handles raw client requests and distributes them to the
appropriate components"""
self.log("Beginning new transaction: ", args, lvl=network)
try:
sock, msg = args[0], args[1]
user = password = client = clientuuid = useruuid = requestdata... | [
"def",
"read",
"(",
"self",
",",
"*",
"args",
")",
":",
"self",
".",
"log",
"(",
"\"Beginning new transaction: \"",
",",
"args",
",",
"lvl",
"=",
"network",
")",
"try",
":",
"sock",
",",
"msg",
"=",
"args",
"[",
"0",
"]",
",",
"args",
"[",
"1",
"... | Handles raw client requests and distributes them to the
appropriate components | [
"Handles",
"raw",
"client",
"requests",
"and",
"distributes",
"them",
"to",
"the",
"appropriate",
"components"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L602-L700 | train |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager.authentication | def authentication(self, event):
"""Links the client to the granted account and profile,
then notifies the client"""
try:
self.log("Authorization has been granted by DB check:",
event.username, lvl=debug)
account, profile, clientconfig = event.userd... | python | def authentication(self, event):
"""Links the client to the granted account and profile,
then notifies the client"""
try:
self.log("Authorization has been granted by DB check:",
event.username, lvl=debug)
account, profile, clientconfig = event.userd... | [
"def",
"authentication",
"(",
"self",
",",
"event",
")",
":",
"try",
":",
"self",
".",
"log",
"(",
"\"Authorization has been granted by DB check:\"",
",",
"event",
".",
"username",
",",
"lvl",
"=",
"debug",
")",
"account",
",",
"profile",
",",
"clientconfig",
... | Links the client to the granted account and profile,
then notifies the client | [
"Links",
"the",
"client",
"to",
"the",
"granted",
"account",
"and",
"profile",
"then",
"notifies",
"the",
"client"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L703-L801 | train |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager.selectlanguage | def selectlanguage(self, event):
"""Store client's selection of a new translation"""
self.log('Language selection event:', event.client, pretty=True)
if event.data not in all_languages():
self.log('Unavailable language selected:', event.data, lvl=warn)
language = None
... | python | def selectlanguage(self, event):
"""Store client's selection of a new translation"""
self.log('Language selection event:', event.client, pretty=True)
if event.data not in all_languages():
self.log('Unavailable language selected:', event.data, lvl=warn)
language = None
... | [
"def",
"selectlanguage",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"log",
"(",
"'Language selection event:'",
",",
"event",
".",
"client",
",",
"pretty",
"=",
"True",
")",
"if",
"event",
".",
"data",
"not",
"in",
"all_languages",
"(",
")",
":",
... | Store client's selection of a new translation | [
"Store",
"client",
"s",
"selection",
"of",
"a",
"new",
"translation"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L804-L822 | train |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager.getlanguages | def getlanguages(self, event):
"""Compile and return a human readable list of registered translations"""
self.log('Client requests all languages.', lvl=verbose)
result = {
'component': 'hfos.ui.clientmanager',
'action': 'getlanguages',
'data': language_token_... | python | def getlanguages(self, event):
"""Compile and return a human readable list of registered translations"""
self.log('Client requests all languages.', lvl=verbose)
result = {
'component': 'hfos.ui.clientmanager',
'action': 'getlanguages',
'data': language_token_... | [
"def",
"getlanguages",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"log",
"(",
"'Client requests all languages.'",
",",
"lvl",
"=",
"verbose",
")",
"result",
"=",
"{",
"'component'",
":",
"'hfos.ui.clientmanager'",
",",
"'action'",
":",
"'getlanguages'",
... | Compile and return a human readable list of registered translations | [
"Compile",
"and",
"return",
"a",
"human",
"readable",
"list",
"of",
"registered",
"translations"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L825-L834 | train |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager.ping | def ping(self, event):
"""Perform a ping to measure client <-> node latency"""
self.log('Client ping received:', event.data, lvl=verbose)
response = {
'component': 'hfos.ui.clientmanager',
'action': 'pong',
'data': [event.data, time() * 1000]
}
... | python | def ping(self, event):
"""Perform a ping to measure client <-> node latency"""
self.log('Client ping received:', event.data, lvl=verbose)
response = {
'component': 'hfos.ui.clientmanager',
'action': 'pong',
'data': [event.data, time() * 1000]
}
... | [
"def",
"ping",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"log",
"(",
"'Client ping received:'",
",",
"event",
".",
"data",
",",
"lvl",
"=",
"verbose",
")",
"response",
"=",
"{",
"'component'",
":",
"'hfos.ui.clientmanager'",
",",
"'action'",
":",
... | Perform a ping to measure client <-> node latency | [
"Perform",
"a",
"ping",
"to",
"measure",
"client",
"<",
"-",
">",
"node",
"latency"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L837-L847 | train |
aburrell/apexpy | src/apexpy/apex.py | Apex.convert | def convert(self, lat, lon, source, dest, height=0, datetime=None,
precision=1e-10, ssheight=50*6371):
"""Converts between geodetic, modified apex, quasi-dipole and MLT.
Parameters
==========
lat : array_like
Latitude
lon : array_like
Long... | python | def convert(self, lat, lon, source, dest, height=0, datetime=None,
precision=1e-10, ssheight=50*6371):
"""Converts between geodetic, modified apex, quasi-dipole and MLT.
Parameters
==========
lat : array_like
Latitude
lon : array_like
Long... | [
"def",
"convert",
"(",
"self",
",",
"lat",
",",
"lon",
",",
"source",
",",
"dest",
",",
"height",
"=",
"0",
",",
"datetime",
"=",
"None",
",",
"precision",
"=",
"1e-10",
",",
"ssheight",
"=",
"50",
"*",
"6371",
")",
":",
"if",
"datetime",
"is",
"... | Converts between geodetic, modified apex, quasi-dipole and MLT.
Parameters
==========
lat : array_like
Latitude
lon : array_like
Longitude/MLT
source : {'geo', 'apex', 'qd', 'mlt'}
Input coordinate system
dest : {'geo', 'apex', 'qd', '... | [
"Converts",
"between",
"geodetic",
"modified",
"apex",
"quasi",
"-",
"dipole",
"and",
"MLT",
"."
] | a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386 | https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/apex.py#L115-L203 | train |
aburrell/apexpy | src/apexpy/apex.py | Apex.geo2apex | def geo2apex(self, glat, glon, height):
"""Converts geodetic to modified apex coordinates.
Parameters
==========
glat : array_like
Geodetic latitude
glon : array_like
Geodetic longitude
height : array_like
Altitude in km
Retur... | python | def geo2apex(self, glat, glon, height):
"""Converts geodetic to modified apex coordinates.
Parameters
==========
glat : array_like
Geodetic latitude
glon : array_like
Geodetic longitude
height : array_like
Altitude in km
Retur... | [
"def",
"geo2apex",
"(",
"self",
",",
"glat",
",",
"glon",
",",
"height",
")",
":",
"glat",
"=",
"helpers",
".",
"checklat",
"(",
"glat",
",",
"name",
"=",
"'glat'",
")",
"alat",
",",
"alon",
"=",
"self",
".",
"_geo2apex",
"(",
"glat",
",",
"glon",
... | Converts geodetic to modified apex coordinates.
Parameters
==========
glat : array_like
Geodetic latitude
glon : array_like
Geodetic longitude
height : array_like
Altitude in km
Returns
=======
alat : ndarray or float
... | [
"Converts",
"geodetic",
"to",
"modified",
"apex",
"coordinates",
"."
] | a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386 | https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/apex.py#L205-L235 | train |
aburrell/apexpy | src/apexpy/apex.py | Apex.apex2geo | def apex2geo(self, alat, alon, height, precision=1e-10):
"""Converts modified apex to geodetic coordinates.
Parameters
==========
alat : array_like
Modified apex latitude
alon : array_like
Modified apex longitude
height : array_like
Al... | python | def apex2geo(self, alat, alon, height, precision=1e-10):
"""Converts modified apex to geodetic coordinates.
Parameters
==========
alat : array_like
Modified apex latitude
alon : array_like
Modified apex longitude
height : array_like
Al... | [
"def",
"apex2geo",
"(",
"self",
",",
"alat",
",",
"alon",
",",
"height",
",",
"precision",
"=",
"1e-10",
")",
":",
"alat",
"=",
"helpers",
".",
"checklat",
"(",
"alat",
",",
"name",
"=",
"'alat'",
")",
"qlat",
",",
"qlon",
"=",
"self",
".",
"apex2q... | Converts modified apex to geodetic coordinates.
Parameters
==========
alat : array_like
Modified apex latitude
alon : array_like
Modified apex longitude
height : array_like
Altitude in km
precision : float, optional
Precisi... | [
"Converts",
"modified",
"apex",
"to",
"geodetic",
"coordinates",
"."
] | a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386 | https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/apex.py#L237-L274 | train |
aburrell/apexpy | src/apexpy/apex.py | Apex.geo2qd | def geo2qd(self, glat, glon, height):
"""Converts geodetic to quasi-dipole coordinates.
Parameters
==========
glat : array_like
Geodetic latitude
glon : array_like
Geodetic longitude
height : array_like
Altitude in km
Returns
... | python | def geo2qd(self, glat, glon, height):
"""Converts geodetic to quasi-dipole coordinates.
Parameters
==========
glat : array_like
Geodetic latitude
glon : array_like
Geodetic longitude
height : array_like
Altitude in km
Returns
... | [
"def",
"geo2qd",
"(",
"self",
",",
"glat",
",",
"glon",
",",
"height",
")",
":",
"glat",
"=",
"helpers",
".",
"checklat",
"(",
"glat",
",",
"name",
"=",
"'glat'",
")",
"qlat",
",",
"qlon",
"=",
"self",
".",
"_geo2qd",
"(",
"glat",
",",
"glon",
",... | Converts geodetic to quasi-dipole coordinates.
Parameters
==========
glat : array_like
Geodetic latitude
glon : array_like
Geodetic longitude
height : array_like
Altitude in km
Returns
=======
qlat : ndarray or float
... | [
"Converts",
"geodetic",
"to",
"quasi",
"-",
"dipole",
"coordinates",
"."
] | a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386 | https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/apex.py#L276-L302 | train |
aburrell/apexpy | src/apexpy/apex.py | Apex.qd2geo | def qd2geo(self, qlat, qlon, height, precision=1e-10):
"""Converts quasi-dipole to geodetic coordinates.
Parameters
==========
qlat : array_like
Quasi-dipole latitude
qlon : array_like
Quasi-dipole longitude
height : array_like
Altitud... | python | def qd2geo(self, qlat, qlon, height, precision=1e-10):
"""Converts quasi-dipole to geodetic coordinates.
Parameters
==========
qlat : array_like
Quasi-dipole latitude
qlon : array_like
Quasi-dipole longitude
height : array_like
Altitud... | [
"def",
"qd2geo",
"(",
"self",
",",
"qlat",
",",
"qlon",
",",
"height",
",",
"precision",
"=",
"1e-10",
")",
":",
"qlat",
"=",
"helpers",
".",
"checklat",
"(",
"qlat",
",",
"name",
"=",
"'qlat'",
")",
"glat",
",",
"glon",
",",
"error",
"=",
"self",
... | Converts quasi-dipole to geodetic coordinates.
Parameters
==========
qlat : array_like
Quasi-dipole latitude
qlon : array_like
Quasi-dipole longitude
height : array_like
Altitude in km
precision : float, optional
Precision ... | [
"Converts",
"quasi",
"-",
"dipole",
"to",
"geodetic",
"coordinates",
"."
] | a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386 | https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/apex.py#L304-L341 | train |
aburrell/apexpy | src/apexpy/apex.py | Apex._apex2qd_nonvectorized | def _apex2qd_nonvectorized(self, alat, alon, height):
"""Convert from apex to quasi-dipole (not-vectorised)
Parameters
-----------
alat : (float)
Apex latitude in degrees
alon : (float)
Apex longitude in degrees
height : (float)
Height... | python | def _apex2qd_nonvectorized(self, alat, alon, height):
"""Convert from apex to quasi-dipole (not-vectorised)
Parameters
-----------
alat : (float)
Apex latitude in degrees
alon : (float)
Apex longitude in degrees
height : (float)
Height... | [
"def",
"_apex2qd_nonvectorized",
"(",
"self",
",",
"alat",
",",
"alon",
",",
"height",
")",
":",
"alat",
"=",
"helpers",
".",
"checklat",
"(",
"alat",
",",
"name",
"=",
"'alat'",
")",
"# convert modified apex to quasi-dipole:",
"qlon",
"=",
"alon",
"# apex hei... | Convert from apex to quasi-dipole (not-vectorised)
Parameters
-----------
alat : (float)
Apex latitude in degrees
alon : (float)
Apex longitude in degrees
height : (float)
Height in km
Returns
---------
qlat : (float)
... | [
"Convert",
"from",
"apex",
"to",
"quasi",
"-",
"dipole",
"(",
"not",
"-",
"vectorised",
")"
] | a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386 | https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/apex.py#L343-L383 | train |
aburrell/apexpy | src/apexpy/apex.py | Apex.apex2qd | def apex2qd(self, alat, alon, height):
"""Converts modified apex to quasi-dipole coordinates.
Parameters
==========
alat : array_like
Modified apex latitude
alon : array_like
Modified apex longitude
height : array_like
Altitude in km
... | python | def apex2qd(self, alat, alon, height):
"""Converts modified apex to quasi-dipole coordinates.
Parameters
==========
alat : array_like
Modified apex latitude
alon : array_like
Modified apex longitude
height : array_like
Altitude in km
... | [
"def",
"apex2qd",
"(",
"self",
",",
"alat",
",",
"alon",
",",
"height",
")",
":",
"qlat",
",",
"qlon",
"=",
"self",
".",
"_apex2qd",
"(",
"alat",
",",
"alon",
",",
"height",
")",
"# if array is returned, the dtype is object, so convert to float",
"return",
"np... | Converts modified apex to quasi-dipole coordinates.
Parameters
==========
alat : array_like
Modified apex latitude
alon : array_like
Modified apex longitude
height : array_like
Altitude in km
Returns
=======
qlat : nda... | [
"Converts",
"modified",
"apex",
"to",
"quasi",
"-",
"dipole",
"coordinates",
"."
] | a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386 | https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/apex.py#L385-L414 | train |
aburrell/apexpy | src/apexpy/apex.py | Apex.qd2apex | def qd2apex(self, qlat, qlon, height):
"""Converts quasi-dipole to modified apex coordinates.
Parameters
==========
qlat : array_like
Quasi-dipole latitude
qlon : array_like
Quasi-dipole longitude
height : array_like
Altitude in km
... | python | def qd2apex(self, qlat, qlon, height):
"""Converts quasi-dipole to modified apex coordinates.
Parameters
==========
qlat : array_like
Quasi-dipole latitude
qlon : array_like
Quasi-dipole longitude
height : array_like
Altitude in km
... | [
"def",
"qd2apex",
"(",
"self",
",",
"qlat",
",",
"qlon",
",",
"height",
")",
":",
"alat",
",",
"alon",
"=",
"self",
".",
"_qd2apex",
"(",
"qlat",
",",
"qlon",
",",
"height",
")",
"# if array is returned, the dtype is object, so convert to float",
"return",
"np... | Converts quasi-dipole to modified apex coordinates.
Parameters
==========
qlat : array_like
Quasi-dipole latitude
qlon : array_like
Quasi-dipole longitude
height : array_like
Altitude in km
Returns
=======
alat : ndarr... | [
"Converts",
"quasi",
"-",
"dipole",
"to",
"modified",
"apex",
"coordinates",
"."
] | a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386 | https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/apex.py#L438-L467 | train |
aburrell/apexpy | src/apexpy/apex.py | Apex.mlon2mlt | def mlon2mlt(self, mlon, datetime, ssheight=50*6371):
"""Computes the magnetic local time at the specified magnetic longitude
and UT.
Parameters
==========
mlon : array_like
Magnetic longitude (apex and quasi-dipole longitude are always
equal)
da... | python | def mlon2mlt(self, mlon, datetime, ssheight=50*6371):
"""Computes the magnetic local time at the specified magnetic longitude
and UT.
Parameters
==========
mlon : array_like
Magnetic longitude (apex and quasi-dipole longitude are always
equal)
da... | [
"def",
"mlon2mlt",
"(",
"self",
",",
"mlon",
",",
"datetime",
",",
"ssheight",
"=",
"50",
"*",
"6371",
")",
":",
"ssglat",
",",
"ssglon",
"=",
"helpers",
".",
"subsol",
"(",
"datetime",
")",
"ssalat",
",",
"ssalon",
"=",
"self",
".",
"geo2apex",
"(",... | Computes the magnetic local time at the specified magnetic longitude
and UT.
Parameters
==========
mlon : array_like
Magnetic longitude (apex and quasi-dipole longitude are always
equal)
datetime : :class:`datetime.datetime`
Date and time
... | [
"Computes",
"the",
"magnetic",
"local",
"time",
"at",
"the",
"specified",
"magnetic",
"longitude",
"and",
"UT",
"."
] | a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386 | https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/apex.py#L469-L503 | train |
aburrell/apexpy | src/apexpy/apex.py | Apex.mlt2mlon | def mlt2mlon(self, mlt, datetime, ssheight=50*6371):
"""Computes the magnetic longitude at the specified magnetic local time
and UT.
Parameters
==========
mlt : array_like
Magnetic local time
datetime : :class:`datetime.datetime`
Date and time
... | python | def mlt2mlon(self, mlt, datetime, ssheight=50*6371):
"""Computes the magnetic longitude at the specified magnetic local time
and UT.
Parameters
==========
mlt : array_like
Magnetic local time
datetime : :class:`datetime.datetime`
Date and time
... | [
"def",
"mlt2mlon",
"(",
"self",
",",
"mlt",
",",
"datetime",
",",
"ssheight",
"=",
"50",
"*",
"6371",
")",
":",
"ssglat",
",",
"ssglon",
"=",
"helpers",
".",
"subsol",
"(",
"datetime",
")",
"ssalat",
",",
"ssalon",
"=",
"self",
".",
"geo2apex",
"(",
... | Computes the magnetic longitude at the specified magnetic local time
and UT.
Parameters
==========
mlt : array_like
Magnetic local time
datetime : :class:`datetime.datetime`
Date and time
ssheight : float, optional
Altitude in km to us... | [
"Computes",
"the",
"magnetic",
"longitude",
"at",
"the",
"specified",
"magnetic",
"local",
"time",
"and",
"UT",
"."
] | a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386 | https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/apex.py#L505-L539 | train |
aburrell/apexpy | src/apexpy/apex.py | Apex.map_to_height | def map_to_height(self, glat, glon, height, newheight, conjugate=False,
precision=1e-10):
"""Performs mapping of points along the magnetic field to the closest
or conjugate hemisphere.
Parameters
==========
glat : array_like
Geodetic latitude
... | python | def map_to_height(self, glat, glon, height, newheight, conjugate=False,
precision=1e-10):
"""Performs mapping of points along the magnetic field to the closest
or conjugate hemisphere.
Parameters
==========
glat : array_like
Geodetic latitude
... | [
"def",
"map_to_height",
"(",
"self",
",",
"glat",
",",
"glon",
",",
"height",
",",
"newheight",
",",
"conjugate",
"=",
"False",
",",
"precision",
"=",
"1e-10",
")",
":",
"alat",
",",
"alon",
"=",
"self",
".",
"geo2apex",
"(",
"glat",
",",
"glon",
","... | Performs mapping of points along the magnetic field to the closest
or conjugate hemisphere.
Parameters
==========
glat : array_like
Geodetic latitude
glon : array_like
Geodetic longitude
height : array_like
Source altitude in km
... | [
"Performs",
"mapping",
"of",
"points",
"along",
"the",
"magnetic",
"field",
"to",
"the",
"closest",
"or",
"conjugate",
"hemisphere",
"."
] | a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386 | https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/apex.py#L541-L595 | train |
aburrell/apexpy | src/apexpy/apex.py | Apex.map_E_to_height | def map_E_to_height(self, alat, alon, height, newheight, E):
"""Performs mapping of electric field along the magnetic field.
It is assumed that the electric field is perpendicular to B.
Parameters
==========
alat : (N,) array_like or float
Modified apex latitude
... | python | def map_E_to_height(self, alat, alon, height, newheight, E):
"""Performs mapping of electric field along the magnetic field.
It is assumed that the electric field is perpendicular to B.
Parameters
==========
alat : (N,) array_like or float
Modified apex latitude
... | [
"def",
"map_E_to_height",
"(",
"self",
",",
"alat",
",",
"alon",
",",
"height",
",",
"newheight",
",",
"E",
")",
":",
"return",
"self",
".",
"_map_EV_to_height",
"(",
"alat",
",",
"alon",
",",
"height",
",",
"newheight",
",",
"E",
",",
"'E'",
")"
] | Performs mapping of electric field along the magnetic field.
It is assumed that the electric field is perpendicular to B.
Parameters
==========
alat : (N,) array_like or float
Modified apex latitude
alon : (N,) array_like or float
Modified apex longitude... | [
"Performs",
"mapping",
"of",
"electric",
"field",
"along",
"the",
"magnetic",
"field",
"."
] | a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386 | https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/apex.py#L642-L669 | train |
aburrell/apexpy | src/apexpy/apex.py | Apex.map_V_to_height | def map_V_to_height(self, alat, alon, height, newheight, V):
"""Performs mapping of electric drift velocity along the magnetic field.
It is assumed that the electric field is perpendicular to B.
Parameters
==========
alat : (N,) array_like or float
Modified apex lat... | python | def map_V_to_height(self, alat, alon, height, newheight, V):
"""Performs mapping of electric drift velocity along the magnetic field.
It is assumed that the electric field is perpendicular to B.
Parameters
==========
alat : (N,) array_like or float
Modified apex lat... | [
"def",
"map_V_to_height",
"(",
"self",
",",
"alat",
",",
"alon",
",",
"height",
",",
"newheight",
",",
"V",
")",
":",
"return",
"self",
".",
"_map_EV_to_height",
"(",
"alat",
",",
"alon",
",",
"height",
",",
"newheight",
",",
"V",
",",
"'V'",
")"
] | Performs mapping of electric drift velocity along the magnetic field.
It is assumed that the electric field is perpendicular to B.
Parameters
==========
alat : (N,) array_like or float
Modified apex latitude
alon : (N,) array_like or float
Modified apex ... | [
"Performs",
"mapping",
"of",
"electric",
"drift",
"velocity",
"along",
"the",
"magnetic",
"field",
"."
] | a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386 | https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/apex.py#L671-L698 | train |
aburrell/apexpy | src/apexpy/apex.py | Apex.basevectors_qd | def basevectors_qd(self, lat, lon, height, coords='geo', precision=1e-10):
"""Returns quasi-dipole base vectors f1 and f2 at the specified
coordinates.
The vectors are described by Richmond [1995] [2]_ and
Emmert et al. [2010] [3]_. The vector components are geodetic east and
n... | python | def basevectors_qd(self, lat, lon, height, coords='geo', precision=1e-10):
"""Returns quasi-dipole base vectors f1 and f2 at the specified
coordinates.
The vectors are described by Richmond [1995] [2]_ and
Emmert et al. [2010] [3]_. The vector components are geodetic east and
n... | [
"def",
"basevectors_qd",
"(",
"self",
",",
"lat",
",",
"lon",
",",
"height",
",",
"coords",
"=",
"'geo'",
",",
"precision",
"=",
"1e-10",
")",
":",
"glat",
",",
"glon",
"=",
"self",
".",
"convert",
"(",
"lat",
",",
"lon",
",",
"coords",
",",
"'geo'... | Returns quasi-dipole base vectors f1 and f2 at the specified
coordinates.
The vectors are described by Richmond [1995] [2]_ and
Emmert et al. [2010] [3]_. The vector components are geodetic east and
north.
Parameters
==========
lat : (N,) array_like or float
... | [
"Returns",
"quasi",
"-",
"dipole",
"base",
"vectors",
"f1",
"and",
"f2",
"at",
"the",
"specified",
"coordinates",
"."
] | a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386 | https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/apex.py#L700-L758 | train |
aburrell/apexpy | src/apexpy/apex.py | Apex.basevectors_apex | def basevectors_apex(self, lat, lon, height, coords='geo', precision=1e-10):
"""Returns base vectors in quasi-dipole and apex coordinates.
The vectors are described by Richmond [1995] [4]_ and
Emmert et al. [2010] [5]_. The vector components are geodetic east,
north, and up (only east ... | python | def basevectors_apex(self, lat, lon, height, coords='geo', precision=1e-10):
"""Returns base vectors in quasi-dipole and apex coordinates.
The vectors are described by Richmond [1995] [4]_ and
Emmert et al. [2010] [5]_. The vector components are geodetic east,
north, and up (only east ... | [
"def",
"basevectors_apex",
"(",
"self",
",",
"lat",
",",
"lon",
",",
"height",
",",
"coords",
"=",
"'geo'",
",",
"precision",
"=",
"1e-10",
")",
":",
"glat",
",",
"glon",
"=",
"self",
".",
"convert",
"(",
"lat",
",",
"lon",
",",
"coords",
",",
"'ge... | Returns base vectors in quasi-dipole and apex coordinates.
The vectors are described by Richmond [1995] [4]_ and
Emmert et al. [2010] [5]_. The vector components are geodetic east,
north, and up (only east and north for `f1` and `f2`).
Parameters
==========
lat, lon : ... | [
"Returns",
"base",
"vectors",
"in",
"quasi",
"-",
"dipole",
"and",
"apex",
"coordinates",
"."
] | a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386 | https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/apex.py#L760-L886 | train |
aburrell/apexpy | src/apexpy/apex.py | Apex.get_apex | def get_apex(self, lat, height=None):
""" Calculate apex height
Parameters
-----------
lat : (float)
Latitude in degrees
height : (float or NoneType)
Height above the surface of the earth in km or NoneType to use
reference height (default=None... | python | def get_apex(self, lat, height=None):
""" Calculate apex height
Parameters
-----------
lat : (float)
Latitude in degrees
height : (float or NoneType)
Height above the surface of the earth in km or NoneType to use
reference height (default=None... | [
"def",
"get_apex",
"(",
"self",
",",
"lat",
",",
"height",
"=",
"None",
")",
":",
"lat",
"=",
"helpers",
".",
"checklat",
"(",
"lat",
",",
"name",
"=",
"'alat'",
")",
"if",
"height",
"is",
"None",
":",
"height",
"=",
"self",
".",
"refh",
"cos_lat_s... | Calculate apex height
Parameters
-----------
lat : (float)
Latitude in degrees
height : (float or NoneType)
Height above the surface of the earth in km or NoneType to use
reference height (default=None)
Returns
----------
apex... | [
"Calculate",
"apex",
"height"
] | a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386 | https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/apex.py#L888-L911 | train |
aburrell/apexpy | src/apexpy/apex.py | Apex.set_epoch | def set_epoch(self, year):
"""Updates the epoch for all subsequent conversions.
Parameters
==========
year : float
Decimal year
"""
fa.loadapxsh(self.datafile, np.float(year))
self.year = year | python | def set_epoch(self, year):
"""Updates the epoch for all subsequent conversions.
Parameters
==========
year : float
Decimal year
"""
fa.loadapxsh(self.datafile, np.float(year))
self.year = year | [
"def",
"set_epoch",
"(",
"self",
",",
"year",
")",
":",
"fa",
".",
"loadapxsh",
"(",
"self",
".",
"datafile",
",",
"np",
".",
"float",
"(",
"year",
")",
")",
"self",
".",
"year",
"=",
"year"
] | Updates the epoch for all subsequent conversions.
Parameters
==========
year : float
Decimal year | [
"Updates",
"the",
"epoch",
"for",
"all",
"subsequent",
"conversions",
"."
] | a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386 | https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/apex.py#L913-L924 | train |
andychase/reparse | reparse/parsers.py | basic_parser | def basic_parser(patterns, with_name=None):
""" Basic ordered parser.
"""
def parse(line):
output = None
highest_order = 0
highest_pattern_name = None
for pattern in patterns:
results = pattern.findall(line)
if results and any(results):
... | python | def basic_parser(patterns, with_name=None):
""" Basic ordered parser.
"""
def parse(line):
output = None
highest_order = 0
highest_pattern_name = None
for pattern in patterns:
results = pattern.findall(line)
if results and any(results):
... | [
"def",
"basic_parser",
"(",
"patterns",
",",
"with_name",
"=",
"None",
")",
":",
"def",
"parse",
"(",
"line",
")",
":",
"output",
"=",
"None",
"highest_order",
"=",
"0",
"highest_pattern_name",
"=",
"None",
"for",
"pattern",
"in",
"patterns",
":",
"results... | Basic ordered parser. | [
"Basic",
"ordered",
"parser",
"."
] | 5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508 | https://github.com/andychase/reparse/blob/5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508/reparse/parsers.py#L5-L24 | train |
andychase/reparse | reparse/parsers.py | alt_parser | def alt_parser(patterns):
""" This parser is able to handle multiple different patterns
finding stuff in text-- while removing matches that overlap.
"""
from reparse.util import remove_lower_overlapping
get_first = lambda items: [i[0] for i in items]
get_second = lambda items: [i[1] for i in... | python | def alt_parser(patterns):
""" This parser is able to handle multiple different patterns
finding stuff in text-- while removing matches that overlap.
"""
from reparse.util import remove_lower_overlapping
get_first = lambda items: [i[0] for i in items]
get_second = lambda items: [i[1] for i in... | [
"def",
"alt_parser",
"(",
"patterns",
")",
":",
"from",
"reparse",
".",
"util",
"import",
"remove_lower_overlapping",
"get_first",
"=",
"lambda",
"items",
":",
"[",
"i",
"[",
"0",
"]",
"for",
"i",
"in",
"items",
"]",
"get_second",
"=",
"lambda",
"items",
... | This parser is able to handle multiple different patterns
finding stuff in text-- while removing matches that overlap. | [
"This",
"parser",
"is",
"able",
"to",
"handle",
"multiple",
"different",
"patterns",
"finding",
"stuff",
"in",
"text",
"--",
"while",
"removing",
"matches",
"that",
"overlap",
"."
] | 5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508 | https://github.com/andychase/reparse/blob/5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508/reparse/parsers.py#L27-L43 | train |
andychase/reparse | reparse/parsers.py | build_tree_parser | def build_tree_parser(patterns):
""" This parser_type simply outputs an array of [(tree, regex)]
for use in another language.
"""
def output():
for pattern in patterns:
yield (pattern.build_full_tree(), pattern.regex)
return list(output()) | python | def build_tree_parser(patterns):
""" This parser_type simply outputs an array of [(tree, regex)]
for use in another language.
"""
def output():
for pattern in patterns:
yield (pattern.build_full_tree(), pattern.regex)
return list(output()) | [
"def",
"build_tree_parser",
"(",
"patterns",
")",
":",
"def",
"output",
"(",
")",
":",
"for",
"pattern",
"in",
"patterns",
":",
"yield",
"(",
"pattern",
".",
"build_full_tree",
"(",
")",
",",
"pattern",
".",
"regex",
")",
"return",
"list",
"(",
"output",... | This parser_type simply outputs an array of [(tree, regex)]
for use in another language. | [
"This",
"parser_type",
"simply",
"outputs",
"an",
"array",
"of",
"[",
"(",
"tree",
"regex",
")",
"]",
"for",
"use",
"in",
"another",
"language",
"."
] | 5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508 | https://github.com/andychase/reparse/blob/5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508/reparse/parsers.py#L53-L60 | train |
andychase/reparse | reparse/parsers.py | parser | def parser(parser_type=basic_parser, functions=None, patterns=None, expressions=None, patterns_yaml_path=None,
expressions_yaml_path=None):
""" A Reparse parser description.
Simply provide the functions, patterns, & expressions to build.
If you are using YAML for expressions + patterns, y... | python | def parser(parser_type=basic_parser, functions=None, patterns=None, expressions=None, patterns_yaml_path=None,
expressions_yaml_path=None):
""" A Reparse parser description.
Simply provide the functions, patterns, & expressions to build.
If you are using YAML for expressions + patterns, y... | [
"def",
"parser",
"(",
"parser_type",
"=",
"basic_parser",
",",
"functions",
"=",
"None",
",",
"patterns",
"=",
"None",
",",
"expressions",
"=",
"None",
",",
"patterns_yaml_path",
"=",
"None",
",",
"expressions_yaml_path",
"=",
"None",
")",
":",
"from",
"repa... | A Reparse parser description.
Simply provide the functions, patterns, & expressions to build.
If you are using YAML for expressions + patterns, you can use
``expressions_yaml_path`` & ``patterns_yaml_path`` for convenience.
The default parser_type is the basic ordered parser. | [
"A",
"Reparse",
"parser",
"description",
".",
"Simply",
"provide",
"the",
"functions",
"patterns",
"&",
"expressions",
"to",
"build",
".",
"If",
"you",
"are",
"using",
"YAML",
"for",
"expressions",
"+",
"patterns",
"you",
"can",
"use",
"expressions_yaml_path",
... | 5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508 | https://github.com/andychase/reparse/blob/5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508/reparse/parsers.py#L63-L90 | train |
Hackerfleet/hfos | modules/webguides/hfos/guides/guide_manager.py | GuideManager._translate | def _translate(self, input_filename, output_filename):
"""Translate KML file to geojson for import"""
command = [
self.translate_binary,
'-f', 'GeoJSON',
output_filename,
input_filename
]
result = self._runcommand(command)
self.log... | python | def _translate(self, input_filename, output_filename):
"""Translate KML file to geojson for import"""
command = [
self.translate_binary,
'-f', 'GeoJSON',
output_filename,
input_filename
]
result = self._runcommand(command)
self.log... | [
"def",
"_translate",
"(",
"self",
",",
"input_filename",
",",
"output_filename",
")",
":",
"command",
"=",
"[",
"self",
".",
"translate_binary",
",",
"'-f'",
",",
"'GeoJSON'",
",",
"output_filename",
",",
"input_filename",
"]",
"result",
"=",
"self",
".",
"_... | Translate KML file to geojson for import | [
"Translate",
"KML",
"file",
"to",
"geojson",
"for",
"import"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/webguides/hfos/guides/guide_manager.py#L118-L128 | train |
Hackerfleet/hfos | modules/webguides/hfos/guides/guide_manager.py | GuideManager._update_guide | def _update_guide(self, guide, update=False, clear=True):
"""Update a single specified guide"""
kml_filename = os.path.join(self.cache_path, guide + '.kml')
geojson_filename = os.path.join(self.cache_path, guide + '.geojson')
if not os.path.exists(geojson_filename) or update:
... | python | def _update_guide(self, guide, update=False, clear=True):
"""Update a single specified guide"""
kml_filename = os.path.join(self.cache_path, guide + '.kml')
geojson_filename = os.path.join(self.cache_path, guide + '.geojson')
if not os.path.exists(geojson_filename) or update:
... | [
"def",
"_update_guide",
"(",
"self",
",",
"guide",
",",
"update",
"=",
"False",
",",
"clear",
"=",
"True",
")",
":",
"kml_filename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"cache_path",
",",
"guide",
"+",
"'.kml'",
")",
"geojson_filenam... | Update a single specified guide | [
"Update",
"a",
"single",
"specified",
"guide"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/webguides/hfos/guides/guide_manager.py#L136-L198 | train |
Hackerfleet/hfos | modules/mail/hfos/mail/transmitter.py | send_mail_worker | def send_mail_worker(config, mail, event):
"""Worker task to send out an email, which is a blocking process unless it is threaded"""
log = ""
try:
if config.get('ssl', True):
server = SMTP_SSL(config['server'], port=config['port'], timeout=30)
else:
server = SMTP(con... | python | def send_mail_worker(config, mail, event):
"""Worker task to send out an email, which is a blocking process unless it is threaded"""
log = ""
try:
if config.get('ssl', True):
server = SMTP_SSL(config['server'], port=config['port'], timeout=30)
else:
server = SMTP(con... | [
"def",
"send_mail_worker",
"(",
"config",
",",
"mail",
",",
"event",
")",
":",
"log",
"=",
"\"\"",
"try",
":",
"if",
"config",
".",
"get",
"(",
"'ssl'",
",",
"True",
")",
":",
"server",
"=",
"SMTP_SSL",
"(",
"config",
"[",
"'server'",
"]",
",",
"po... | Worker task to send out an email, which is a blocking process unless it is threaded | [
"Worker",
"task",
"to",
"send",
"out",
"an",
"email",
"which",
"is",
"a",
"blocking",
"process",
"unless",
"it",
"is",
"threaded"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/mail/hfos/mail/transmitter.py#L47-L76 | train |
Hackerfleet/hfos | modules/mail/hfos/mail/transmitter.py | MailTransmitter.send_mail | def send_mail(self, event):
"""Connect to mail server and send actual email"""
mime_mail = MIMEText(event.text)
mime_mail['Subject'] = event.subject
if event.account == 'default':
account_name = self.config.default_account
else:
account_name = event.acco... | python | def send_mail(self, event):
"""Connect to mail server and send actual email"""
mime_mail = MIMEText(event.text)
mime_mail['Subject'] = event.subject
if event.account == 'default':
account_name = self.config.default_account
else:
account_name = event.acco... | [
"def",
"send_mail",
"(",
"self",
",",
"event",
")",
":",
"mime_mail",
"=",
"MIMEText",
"(",
"event",
".",
"text",
")",
"mime_mail",
"[",
"'Subject'",
"]",
"=",
"event",
".",
"subject",
"if",
"event",
".",
"account",
"==",
"'default'",
":",
"account_name"... | Connect to mail server and send actual email | [
"Connect",
"to",
"mail",
"server",
"and",
"send",
"actual",
"email"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/mail/hfos/mail/transmitter.py#L189-L211 | train |
Hackerfleet/hfos | hfos/provisions/user.py | provision_system_user | def provision_system_user(items, database_name, overwrite=False, clear=False, skip_user_check=False):
"""Provision a system user"""
from hfos.provisions.base import provisionList
from hfos.database import objectmodels
# TODO: Add a root user and make sure owner can access it later.
# Setting up de... | python | def provision_system_user(items, database_name, overwrite=False, clear=False, skip_user_check=False):
"""Provision a system user"""
from hfos.provisions.base import provisionList
from hfos.database import objectmodels
# TODO: Add a root user and make sure owner can access it later.
# Setting up de... | [
"def",
"provision_system_user",
"(",
"items",
",",
"database_name",
",",
"overwrite",
"=",
"False",
",",
"clear",
"=",
"False",
",",
"skip_user_check",
"=",
"False",
")",
":",
"from",
"hfos",
".",
"provisions",
".",
"base",
"import",
"provisionList",
"from",
... | Provision a system user | [
"Provision",
"a",
"system",
"user"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/provisions/user.py#L48-L68 | train |
andychase/reparse | reparse/expression.py | AlternatesGroup | def AlternatesGroup(expressions, final_function, name=""):
""" Group expressions using the OR character ``|``
>>> from collections import namedtuple
>>> expr = namedtuple('expr', 'regex group_lengths run')('(1)', [1], None)
>>> grouping = AlternatesGroup([expr, expr], lambda f: None, 'yeah')
>>> gro... | python | def AlternatesGroup(expressions, final_function, name=""):
""" Group expressions using the OR character ``|``
>>> from collections import namedtuple
>>> expr = namedtuple('expr', 'regex group_lengths run')('(1)', [1], None)
>>> grouping = AlternatesGroup([expr, expr], lambda f: None, 'yeah')
>>> gro... | [
"def",
"AlternatesGroup",
"(",
"expressions",
",",
"final_function",
",",
"name",
"=",
"\"\"",
")",
":",
"inbetweens",
"=",
"[",
"\"|\"",
"]",
"*",
"(",
"len",
"(",
"expressions",
")",
"+",
"1",
")",
"inbetweens",
"[",
"0",
"]",
"=",
"\"\"",
"inbetween... | Group expressions using the OR character ``|``
>>> from collections import namedtuple
>>> expr = namedtuple('expr', 'regex group_lengths run')('(1)', [1], None)
>>> grouping = AlternatesGroup([expr, expr], lambda f: None, 'yeah')
>>> grouping.regex # doctest: +IGNORE_UNICODE
'(?:(1))|(?:(1))'
>... | [
"Group",
"expressions",
"using",
"the",
"OR",
"character",
"|",
">>>",
"from",
"collections",
"import",
"namedtuple",
">>>",
"expr",
"=",
"namedtuple",
"(",
"expr",
"regex",
"group_lengths",
"run",
")",
"(",
"(",
"1",
")",
"[",
"1",
"]",
"None",
")",
">>... | 5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508 | https://github.com/andychase/reparse/blob/5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508/reparse/expression.py#L108-L121 | train |
andychase/reparse | reparse/expression.py | Group | def Group(expressions, final_function, inbetweens, name=""):
""" Group expressions together with ``inbetweens`` and with the output of a ``final_functions``.
"""
lengths = []
functions = []
regex = ""
i = 0
for expression in expressions:
regex += inbetweens[i]
regex += "(?:" ... | python | def Group(expressions, final_function, inbetweens, name=""):
""" Group expressions together with ``inbetweens`` and with the output of a ``final_functions``.
"""
lengths = []
functions = []
regex = ""
i = 0
for expression in expressions:
regex += inbetweens[i]
regex += "(?:" ... | [
"def",
"Group",
"(",
"expressions",
",",
"final_function",
",",
"inbetweens",
",",
"name",
"=",
"\"\"",
")",
":",
"lengths",
"=",
"[",
"]",
"functions",
"=",
"[",
"]",
"regex",
"=",
"\"\"",
"i",
"=",
"0",
"for",
"expression",
"in",
"expressions",
":",
... | Group expressions together with ``inbetweens`` and with the output of a ``final_functions``. | [
"Group",
"expressions",
"together",
"with",
"inbetweens",
"and",
"with",
"the",
"output",
"of",
"a",
"final_functions",
"."
] | 5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508 | https://github.com/andychase/reparse/blob/5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508/reparse/expression.py#L124-L139 | train |
andychase/reparse | reparse/expression.py | Expression.findall | def findall(self, string):
""" Parse string, returning all outputs as parsed by functions
"""
output = []
for match in self.pattern.findall(string):
if hasattr(match, 'strip'):
match = [match]
self._list_add(output, self.run(match))
return ... | python | def findall(self, string):
""" Parse string, returning all outputs as parsed by functions
"""
output = []
for match in self.pattern.findall(string):
if hasattr(match, 'strip'):
match = [match]
self._list_add(output, self.run(match))
return ... | [
"def",
"findall",
"(",
"self",
",",
"string",
")",
":",
"output",
"=",
"[",
"]",
"for",
"match",
"in",
"self",
".",
"pattern",
".",
"findall",
"(",
"string",
")",
":",
"if",
"hasattr",
"(",
"match",
",",
"'strip'",
")",
":",
"match",
"=",
"[",
"m... | Parse string, returning all outputs as parsed by functions | [
"Parse",
"string",
"returning",
"all",
"outputs",
"as",
"parsed",
"by",
"functions"
] | 5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508 | https://github.com/andychase/reparse/blob/5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508/reparse/expression.py#L47-L55 | train |
andychase/reparse | reparse/expression.py | Expression.scan | def scan(self, string):
""" Like findall, but also returning matching start and end string locations
"""
return list(self._scanner_to_matches(self.pattern.scanner(string), self.run)) | python | def scan(self, string):
""" Like findall, but also returning matching start and end string locations
"""
return list(self._scanner_to_matches(self.pattern.scanner(string), self.run)) | [
"def",
"scan",
"(",
"self",
",",
"string",
")",
":",
"return",
"list",
"(",
"self",
".",
"_scanner_to_matches",
"(",
"self",
".",
"pattern",
".",
"scanner",
"(",
"string",
")",
",",
"self",
".",
"run",
")",
")"
] | Like findall, but also returning matching start and end string locations | [
"Like",
"findall",
"but",
"also",
"returning",
"matching",
"start",
"and",
"end",
"string",
"locations"
] | 5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508 | https://github.com/andychase/reparse/blob/5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508/reparse/expression.py#L57-L60 | train |
andychase/reparse | reparse/expression.py | Expression.run | def run(self, matches):
""" Run group functions over matches
"""
def _run(matches):
group_starting_pos = 0
for current_pos, (group_length, group_function) in enumerate(zip(self.group_lengths, self.group_functions)):
start_pos = current_pos + group_starting... | python | def run(self, matches):
""" Run group functions over matches
"""
def _run(matches):
group_starting_pos = 0
for current_pos, (group_length, group_function) in enumerate(zip(self.group_lengths, self.group_functions)):
start_pos = current_pos + group_starting... | [
"def",
"run",
"(",
"self",
",",
"matches",
")",
":",
"def",
"_run",
"(",
"matches",
")",
":",
"group_starting_pos",
"=",
"0",
"for",
"current_pos",
",",
"(",
"group_length",
",",
"group_function",
")",
"in",
"enumerate",
"(",
"zip",
"(",
"self",
".",
"... | Run group functions over matches | [
"Run",
"group",
"functions",
"over",
"matches"
] | 5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508 | https://github.com/andychase/reparse/blob/5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508/reparse/expression.py#L62-L72 | train |
Hackerfleet/hfos | hfos/logger.py | set_logfile | def set_logfile(path, instance):
"""Specify logfile path"""
global logfile
logfile = os.path.normpath(path) + '/hfos.' + instance + '.log' | python | def set_logfile(path, instance):
"""Specify logfile path"""
global logfile
logfile = os.path.normpath(path) + '/hfos.' + instance + '.log' | [
"def",
"set_logfile",
"(",
"path",
",",
"instance",
")",
":",
"global",
"logfile",
"logfile",
"=",
"os",
".",
"path",
".",
"normpath",
"(",
"path",
")",
"+",
"'/hfos.'",
"+",
"instance",
"+",
"'.log'"
] | Specify logfile path | [
"Specify",
"logfile",
"path"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/logger.py#L113-L117 | train |
Hackerfleet/hfos | hfos/logger.py | is_muted | def is_muted(what):
"""
Checks if a logged event is to be muted for debugging purposes.
Also goes through the solo list - only items in there will be logged!
:param what:
:return:
"""
state = False
for item in solo:
if item not in what:
state = True
else:
... | python | def is_muted(what):
"""
Checks if a logged event is to be muted for debugging purposes.
Also goes through the solo list - only items in there will be logged!
:param what:
:return:
"""
state = False
for item in solo:
if item not in what:
state = True
else:
... | [
"def",
"is_muted",
"(",
"what",
")",
":",
"state",
"=",
"False",
"for",
"item",
"in",
"solo",
":",
"if",
"item",
"not",
"in",
"what",
":",
"state",
"=",
"True",
"else",
":",
"state",
"=",
"False",
"break",
"for",
"item",
"in",
"mute",
":",
"if",
... | Checks if a logged event is to be muted for debugging purposes.
Also goes through the solo list - only items in there will be logged!
:param what:
:return: | [
"Checks",
"if",
"a",
"logged",
"event",
"is",
"to",
"be",
"muted",
"for",
"debugging",
"purposes",
"."
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/logger.py#L120-L144 | train |
Hackerfleet/hfos | hfos/logger.py | hfoslog | def hfoslog(*what, **kwargs):
"""Logs all *what arguments.
:param *what: Loggable objects (i.e. they have a string representation)
:param lvl: Debug message level
:param exc: Switch to better handle exceptions, use if logging in an
except clause
:param emitter: Optional log source, ... | python | def hfoslog(*what, **kwargs):
"""Logs all *what arguments.
:param *what: Loggable objects (i.e. they have a string representation)
:param lvl: Debug message level
:param exc: Switch to better handle exceptions, use if logging in an
except clause
:param emitter: Optional log source, ... | [
"def",
"hfoslog",
"(",
"*",
"what",
",",
"*",
"*",
"kwargs",
")",
":",
"# Count all messages (missing numbers give a hint at too high log level)",
"global",
"count",
"global",
"verbosity",
"count",
"+=",
"1",
"lvl",
"=",
"kwargs",
".",
"get",
"(",
"'lvl'",
",",
... | Logs all *what arguments.
:param *what: Loggable objects (i.e. they have a string representation)
:param lvl: Debug message level
:param exc: Switch to better handle exceptions, use if logging in an
except clause
:param emitter: Optional log source, where this can't be determined
... | [
"Logs",
"all",
"*",
"what",
"arguments",
"."
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/logger.py#L169-L301 | train |
Hackerfleet/hfos | hfos/ui/tagmanager.py | TagManager.get_tagged | def get_tagged(self, event):
"""Return a list of tagged objects for a schema"""
self.log("Tagged objects request for", event.data, "from",
event.user, lvl=debug)
if event.data in self.tags:
tagged = self._get_tagged(event.data)
response = {
... | python | def get_tagged(self, event):
"""Return a list of tagged objects for a schema"""
self.log("Tagged objects request for", event.data, "from",
event.user, lvl=debug)
if event.data in self.tags:
tagged = self._get_tagged(event.data)
response = {
... | [
"def",
"get_tagged",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"log",
"(",
"\"Tagged objects request for\"",
",",
"event",
".",
"data",
",",
"\"from\"",
",",
"event",
".",
"user",
",",
"lvl",
"=",
"debug",
")",
"if",
"event",
".",
"data",
"in",... | Return a list of tagged objects for a schema | [
"Return",
"a",
"list",
"of",
"tagged",
"objects",
"for",
"a",
"schema"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/tagmanager.py#L83-L97 | train |
Hackerfleet/hfos | modules/navdata/hfos/navdata/provisions/vessel.py | provision_system_vessel | def provision_system_vessel(items, database_name, overwrite=False, clear=False, skip_user_check=False):
"""Provisions the default system vessel"""
from hfos.provisions.base import provisionList
from hfos.database import objectmodels
vessel = objectmodels['vessel'].find_one({'name': 'Default System Ves... | python | def provision_system_vessel(items, database_name, overwrite=False, clear=False, skip_user_check=False):
"""Provisions the default system vessel"""
from hfos.provisions.base import provisionList
from hfos.database import objectmodels
vessel = objectmodels['vessel'].find_one({'name': 'Default System Ves... | [
"def",
"provision_system_vessel",
"(",
"items",
",",
"database_name",
",",
"overwrite",
"=",
"False",
",",
"clear",
"=",
"False",
",",
"skip_user_check",
"=",
"False",
")",
":",
"from",
"hfos",
".",
"provisions",
".",
"base",
"import",
"provisionList",
"from",... | Provisions the default system vessel | [
"Provisions",
"the",
"default",
"system",
"vessel"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/navdata/hfos/navdata/provisions/vessel.py#L33-L54 | train |
Hackerfleet/hfos | modules/maps/hfos/map/maptileservice.py | get_tile | def get_tile(url):
"""
Threadable function to retrieve map tiles from the internet
:param url: URL of tile to get
"""
log = ""
connection = None
try:
if six.PY3:
connection = urlopen(url=url, timeout=2) # NOQA
else:
connection = urlopen(url=url)
... | python | def get_tile(url):
"""
Threadable function to retrieve map tiles from the internet
:param url: URL of tile to get
"""
log = ""
connection = None
try:
if six.PY3:
connection = urlopen(url=url, timeout=2) # NOQA
else:
connection = urlopen(url=url)
... | [
"def",
"get_tile",
"(",
"url",
")",
":",
"log",
"=",
"\"\"",
"connection",
"=",
"None",
"try",
":",
"if",
"six",
".",
"PY3",
":",
"connection",
"=",
"urlopen",
"(",
"url",
"=",
"url",
",",
"timeout",
"=",
"2",
")",
"# NOQA",
"else",
":",
"connectio... | Threadable function to retrieve map tiles from the internet
:param url: URL of tile to get | [
"Threadable",
"function",
"to",
"retrieve",
"map",
"tiles",
"from",
"the",
"internet",
":",
"param",
"url",
":",
"URL",
"of",
"tile",
"to",
"get"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/maps/hfos/map/maptileservice.py#L63-L92 | train |
Hackerfleet/hfos | modules/maps/hfos/map/maptileservice.py | MaptileService.tilecache | def tilecache(self, event, *args, **kwargs):
"""Checks and caches a requested tile to disk, then delivers it to
client"""
request, response = event.args[:2]
self.log(request.path, lvl=verbose)
try:
filename, url = self._split_cache_url(request.path, 'tilecache')
... | python | def tilecache(self, event, *args, **kwargs):
"""Checks and caches a requested tile to disk, then delivers it to
client"""
request, response = event.args[:2]
self.log(request.path, lvl=verbose)
try:
filename, url = self._split_cache_url(request.path, 'tilecache')
... | [
"def",
"tilecache",
"(",
"self",
",",
"event",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"request",
",",
"response",
"=",
"event",
".",
"args",
"[",
":",
"2",
"]",
"self",
".",
"log",
"(",
"request",
".",
"path",
",",
"lvl",
"=",
"ve... | Checks and caches a requested tile to disk, then delivers it to
client | [
"Checks",
"and",
"caches",
"a",
"requested",
"tile",
"to",
"disk",
"then",
"delivers",
"it",
"to",
"client"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/maps/hfos/map/maptileservice.py#L464-L543 | train |
yychen/twd97 | twd97/converter.py | todegdec | def todegdec(origin):
"""
Convert from [+/-]DDD°MMM'SSS.SSSS" or [+/-]DDD°MMM.MMMM' to [+/-]DDD.DDDDD
"""
# if the input is already a float (or can be converted to float)
try:
return float(origin)
except ValueError:
pass
# DMS format
m = dms_re.search(origin)
if m:
... | python | def todegdec(origin):
"""
Convert from [+/-]DDD°MMM'SSS.SSSS" or [+/-]DDD°MMM.MMMM' to [+/-]DDD.DDDDD
"""
# if the input is already a float (or can be converted to float)
try:
return float(origin)
except ValueError:
pass
# DMS format
m = dms_re.search(origin)
if m:
... | [
"def",
"todegdec",
"(",
"origin",
")",
":",
"# if the input is already a float (or can be converted to float)",
"try",
":",
"return",
"float",
"(",
"origin",
")",
"except",
"ValueError",
":",
"pass",
"# DMS format",
"m",
"=",
"dms_re",
".",
"search",
"(",
"origin",
... | Convert from [+/-]DDD°MMM'SSS.SSSS" or [+/-]DDD°MMM.MMMM' to [+/-]DDD.DDDDD | [
"Convert",
"from",
"[",
"+",
"/",
"-",
"]",
"DDD°MMM",
"SSS",
".",
"SSSS",
"or",
"[",
"+",
"/",
"-",
"]",
"DDD°MMM",
".",
"MMMM",
"to",
"[",
"+",
"/",
"-",
"]",
"DDD",
".",
"DDDDD"
] | 2fe05dbca335be425a1f451e0ef8f210ec864de1 | https://github.com/yychen/twd97/blob/2fe05dbca335be425a1f451e0ef8f210ec864de1/twd97/converter.py#L41-L67 | train |
yychen/twd97 | twd97/converter.py | tomindec | def tomindec(origin):
"""
Convert [+/-]DDD.DDDDD to a tuple (degrees, minutes)
"""
origin = float(origin)
degrees = int(origin)
minutes = (origin % 1) * 60
return degrees, minutes | python | def tomindec(origin):
"""
Convert [+/-]DDD.DDDDD to a tuple (degrees, minutes)
"""
origin = float(origin)
degrees = int(origin)
minutes = (origin % 1) * 60
return degrees, minutes | [
"def",
"tomindec",
"(",
"origin",
")",
":",
"origin",
"=",
"float",
"(",
"origin",
")",
"degrees",
"=",
"int",
"(",
"origin",
")",
"minutes",
"=",
"(",
"origin",
"%",
"1",
")",
"*",
"60",
"return",
"degrees",
",",
"minutes"
] | Convert [+/-]DDD.DDDDD to a tuple (degrees, minutes) | [
"Convert",
"[",
"+",
"/",
"-",
"]",
"DDD",
".",
"DDDDD",
"to",
"a",
"tuple",
"(",
"degrees",
"minutes",
")"
] | 2fe05dbca335be425a1f451e0ef8f210ec864de1 | https://github.com/yychen/twd97/blob/2fe05dbca335be425a1f451e0ef8f210ec864de1/twd97/converter.py#L69-L78 | train |
yychen/twd97 | twd97/converter.py | tomindecstr | def tomindecstr(origin):
"""
Convert [+/-]DDD.DDDDD to [+/-]DDD°MMM.MMMM'
"""
degrees, minutes = tomindec(origin)
return u'%d°%f\'' % (degrees, minutes) | python | def tomindecstr(origin):
"""
Convert [+/-]DDD.DDDDD to [+/-]DDD°MMM.MMMM'
"""
degrees, minutes = tomindec(origin)
return u'%d°%f\'' % (degrees, minutes) | [
"def",
"tomindecstr",
"(",
"origin",
")",
":",
"degrees",
",",
"minutes",
"=",
"tomindec",
"(",
"origin",
")",
"return",
"u'%d°%f\\'' ",
" ",
"d",
"egrees,",
" ",
"inutes)",
""
] | Convert [+/-]DDD.DDDDD to [+/-]DDD°MMM.MMMM' | [
"Convert",
"[",
"+",
"/",
"-",
"]",
"DDD",
".",
"DDDDD",
"to",
"[",
"+",
"/",
"-",
"]",
"DDD°MMM",
".",
"MMMM"
] | 2fe05dbca335be425a1f451e0ef8f210ec864de1 | https://github.com/yychen/twd97/blob/2fe05dbca335be425a1f451e0ef8f210ec864de1/twd97/converter.py#L80-L86 | train |
yychen/twd97 | twd97/converter.py | todms | def todms(origin):
"""
Convert [+/-]DDD.DDDDD to a tuple (degrees, minutes, seconds)
"""
degrees, minutes = tomindec(origin)
seconds = (minutes % 1) * 60
return degrees, int(minutes), seconds | python | def todms(origin):
"""
Convert [+/-]DDD.DDDDD to a tuple (degrees, minutes, seconds)
"""
degrees, minutes = tomindec(origin)
seconds = (minutes % 1) * 60
return degrees, int(minutes), seconds | [
"def",
"todms",
"(",
"origin",
")",
":",
"degrees",
",",
"minutes",
"=",
"tomindec",
"(",
"origin",
")",
"seconds",
"=",
"(",
"minutes",
"%",
"1",
")",
"*",
"60",
"return",
"degrees",
",",
"int",
"(",
"minutes",
")",
",",
"seconds"
] | Convert [+/-]DDD.DDDDD to a tuple (degrees, minutes, seconds) | [
"Convert",
"[",
"+",
"/",
"-",
"]",
"DDD",
".",
"DDDDD",
"to",
"a",
"tuple",
"(",
"degrees",
"minutes",
"seconds",
")"
] | 2fe05dbca335be425a1f451e0ef8f210ec864de1 | https://github.com/yychen/twd97/blob/2fe05dbca335be425a1f451e0ef8f210ec864de1/twd97/converter.py#L88-L96 | train |
yychen/twd97 | twd97/converter.py | todmsstr | def todmsstr(origin):
"""
Convert [+/-]DDD.DDDDD to [+/-]DDD°MMM'DDD.DDDDD"
"""
degrees, minutes, seconds = todms(origin)
return u'%d°%d\'%f"' % (degrees, minutes, seconds) | python | def todmsstr(origin):
"""
Convert [+/-]DDD.DDDDD to [+/-]DDD°MMM'DDD.DDDDD"
"""
degrees, minutes, seconds = todms(origin)
return u'%d°%d\'%f"' % (degrees, minutes, seconds) | [
"def",
"todmsstr",
"(",
"origin",
")",
":",
"degrees",
",",
"minutes",
",",
"seconds",
"=",
"todms",
"(",
"origin",
")",
"return",
"u'%d°%d\\'%f\"' ",
" ",
"d",
"egrees,",
" ",
"inutes,",
" ",
"econds)",
""
] | Convert [+/-]DDD.DDDDD to [+/-]DDD°MMM'DDD.DDDDD" | [
"Convert",
"[",
"+",
"/",
"-",
"]",
"DDD",
".",
"DDDDD",
"to",
"[",
"+",
"/",
"-",
"]",
"DDD°MMM",
"DDD",
".",
"DDDDD"
] | 2fe05dbca335be425a1f451e0ef8f210ec864de1 | https://github.com/yychen/twd97/blob/2fe05dbca335be425a1f451e0ef8f210ec864de1/twd97/converter.py#L98-L104 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.