partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | make_auth_headers | Make the authentication headers needed to use the Appveyor API. | ci/appveyor-download.py | def make_auth_headers():
"""Make the authentication headers needed to use the Appveyor API."""
if not os.path.exists(".appveyor.token"):
raise RuntimeError(
"Please create a file named `.appveyor.token` in the current directory. "
"You can get the token from https://ci.appveyor.c... | def make_auth_headers():
"""Make the authentication headers needed to use the Appveyor API."""
if not os.path.exists(".appveyor.token"):
raise RuntimeError(
"Please create a file named `.appveyor.token` in the current directory. "
"You can get the token from https://ci.appveyor.c... | [
"Make",
"the",
"authentication",
"headers",
"needed",
"to",
"use",
"the",
"Appveyor",
"API",
"."
] | aburrell/apexpy | python | https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/ci/appveyor-download.py#L15-L28 | [
"def",
"make_auth_headers",
"(",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"\".appveyor.token\"",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Please create a file named `.appveyor.token` in the current directory. \"",
"\"You can get the token from https://c... | a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386 |
train | get_project_build | Get the details of the latest Appveyor build. | ci/appveyor-download.py | def get_project_build(account_project):
"""Get the details of the latest Appveyor build."""
url = make_url("/projects/{account_project}", account_project=account_project)
response = requests.get(url, headers=make_auth_headers())
return response.json() | def get_project_build(account_project):
"""Get the details of the latest Appveyor build."""
url = make_url("/projects/{account_project}", account_project=account_project)
response = requests.get(url, headers=make_auth_headers())
return response.json() | [
"Get",
"the",
"details",
"of",
"the",
"latest",
"Appveyor",
"build",
"."
] | aburrell/apexpy | python | https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/ci/appveyor-download.py#L36-L40 | [
"def",
"get_project_build",
"(",
"account_project",
")",
":",
"url",
"=",
"make_url",
"(",
"\"/projects/{account_project}\"",
",",
"account_project",
"=",
"account_project",
")",
"response",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"headers",
"=",
"make_auth_... | a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386 |
train | download_url | Download a file from `url` to `filename`. | ci/appveyor-download.py | def download_url(url, filename, headers):
"""Download a file from `url` to `filename`."""
ensure_dirs(filename)
response = requests.get(url, headers=headers, stream=True)
if response.status_code == 200:
with open(filename, 'wb') as f:
for chunk in response.iter_content(16 * 1024):
... | def download_url(url, filename, headers):
"""Download a file from `url` to `filename`."""
ensure_dirs(filename)
response = requests.get(url, headers=headers, stream=True)
if response.status_code == 200:
with open(filename, 'wb') as f:
for chunk in response.iter_content(16 * 1024):
... | [
"Download",
"a",
"file",
"from",
"url",
"to",
"filename",
"."
] | aburrell/apexpy | python | https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/ci/appveyor-download.py#L80-L87 | [
"def",
"download_url",
"(",
"url",
",",
"filename",
",",
"headers",
")",
":",
"ensure_dirs",
"(",
"filename",
")",
"response",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"headers",
"=",
"headers",
",",
"stream",
"=",
"True",
")",
"if",
"response",
"... | a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386 |
train | SchemaManager.cli_schemata_list | Display a list of registered schemata | hfos/ui/schemamanager.py | def cli_schemata_list(self, *args):
"""Display a list of registered schemata"""
self.log('Registered schemata languages:', ",".join(sorted(l10n_schemastore.keys())))
self.log('Registered Schemata:', ",".join(sorted(schemastore.keys())))
if '-c' in args or '-config' in args:
... | def cli_schemata_list(self, *args):
"""Display a list of registered schemata"""
self.log('Registered schemata languages:', ",".join(sorted(l10n_schemastore.keys())))
self.log('Registered Schemata:', ",".join(sorted(schemastore.keys())))
if '-c' in args or '-config' in args:
... | [
"Display",
"a",
"list",
"of",
"registered",
"schemata"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/schemamanager.py#L87-L93 | [
"def",
"cli_schemata_list",
"(",
"self",
",",
"*",
"args",
")",
":",
"self",
".",
"log",
"(",
"'Registered schemata languages:'",
",",
"\",\"",
".",
"join",
"(",
"sorted",
"(",
"l10n_schemastore",
".",
"keys",
"(",
")",
")",
")",
")",
"self",
".",
"log",... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | SchemaManager.cli_form | Display a schemata's form definition | hfos/ui/schemamanager.py | def cli_form(self, *args):
"""Display a schemata's form definition"""
if args[0] == '*':
for schema in schemastore:
self.log(schema, ':', schemastore[schema]['form'], pretty=True)
else:
self.log(schemastore[args[0]]['form'], pretty=True) | def cli_form(self, *args):
"""Display a schemata's form definition"""
if args[0] == '*':
for schema in schemastore:
self.log(schema, ':', schemastore[schema]['form'], pretty=True)
else:
self.log(schemastore[args[0]]['form'], pretty=True) | [
"Display",
"a",
"schemata",
"s",
"form",
"definition"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/schemamanager.py#L96-L103 | [
"def",
"cli_form",
"(",
"self",
",",
"*",
"args",
")",
":",
"if",
"args",
"[",
"0",
"]",
"==",
"'*'",
":",
"for",
"schema",
"in",
"schemastore",
":",
"self",
".",
"log",
"(",
"schema",
",",
"':'",
",",
"schemastore",
"[",
"schema",
"]",
"[",
"'fo... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | SchemaManager.cli_schema | Display a single schema definition | hfos/ui/schemamanager.py | def cli_schema(self, *args):
"""Display a single schema definition"""
key = None
if len(args) > 1:
key = args[1]
args = list(args)
if '-config' in args or '-c' in args:
store = configschemastore
try:
args.remove('-c')
... | def cli_schema(self, *args):
"""Display a single schema definition"""
key = None
if len(args) > 1:
key = args[1]
args = list(args)
if '-config' in args or '-c' in args:
store = configschemastore
try:
args.remove('-c')
... | [
"Display",
"a",
"single",
"schema",
"definition"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/schemamanager.py#L106-L144 | [
"def",
"cli_schema",
"(",
"self",
",",
"*",
"args",
")",
":",
"key",
"=",
"None",
"if",
"len",
"(",
"args",
")",
">",
"1",
":",
"key",
"=",
"args",
"[",
"1",
"]",
"args",
"=",
"list",
"(",
"args",
")",
"if",
"'-config'",
"in",
"args",
"or",
"... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | SchemaManager.cli_forms | List all available form definitions | hfos/ui/schemamanager.py | def cli_forms(self, *args):
"""List all available form definitions"""
forms = []
missing = []
for key, item in schemastore.items():
if 'form' in item and len(item['form']) > 0:
forms.append(key)
else:
missing.append(key)
... | def cli_forms(self, *args):
"""List all available form definitions"""
forms = []
missing = []
for key, item in schemastore.items():
if 'form' in item and len(item['form']) > 0:
forms.append(key)
else:
missing.append(key)
... | [
"List",
"all",
"available",
"form",
"definitions"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/schemamanager.py#L147-L160 | [
"def",
"cli_forms",
"(",
"self",
",",
"*",
"args",
")",
":",
"forms",
"=",
"[",
"]",
"missing",
"=",
"[",
"]",
"for",
"key",
",",
"item",
"in",
"schemastore",
".",
"items",
"(",
")",
":",
"if",
"'form'",
"in",
"item",
"and",
"len",
"(",
"item",
... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | SchemaManager.cli_default_perms | Show default permissions for all schemata | hfos/ui/schemamanager.py | def cli_default_perms(self, *args):
"""Show default permissions for all schemata"""
for key, item in schemastore.items():
# self.log(item, pretty=True)
if item['schema'].get('no_perms', False):
self.log('Schema without permissions:', key)
continue... | def cli_default_perms(self, *args):
"""Show default permissions for all schemata"""
for key, item in schemastore.items():
# self.log(item, pretty=True)
if item['schema'].get('no_perms', False):
self.log('Schema without permissions:', key)
continue... | [
"Show",
"default",
"permissions",
"for",
"all",
"schemata"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/schemamanager.py#L163-L185 | [
"def",
"cli_default_perms",
"(",
"self",
",",
"*",
"args",
")",
":",
"for",
"key",
",",
"item",
"in",
"schemastore",
".",
"items",
"(",
")",
":",
"# self.log(item, pretty=True)",
"if",
"item",
"[",
"'schema'",
"]",
".",
"get",
"(",
"'no_perms'",
",",
"Fa... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | SchemaManager.ready | Sets up the application after startup. | hfos/ui/schemamanager.py | def ready(self):
"""Sets up the application after startup."""
self.log('Got', len(schemastore), 'data and',
len(configschemastore), 'component schemata.', lvl=debug) | def ready(self):
"""Sets up the application after startup."""
self.log('Got', len(schemastore), 'data and',
len(configschemastore), 'component schemata.', lvl=debug) | [
"Sets",
"up",
"the",
"application",
"after",
"startup",
"."
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/schemamanager.py#L188-L192 | [
"def",
"ready",
"(",
"self",
")",
":",
"self",
".",
"log",
"(",
"'Got'",
",",
"len",
"(",
"schemastore",
")",
",",
"'data and'",
",",
"len",
"(",
"configschemastore",
")",
",",
"'component schemata.'",
",",
"lvl",
"=",
"debug",
")"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | SchemaManager.all | Return all known schemata to the requesting client | hfos/ui/schemamanager.py | def all(self, event):
"""Return all known schemata to the requesting client"""
self.log("Schemarequest for all schemata from",
event.user, lvl=debug)
response = {
'component': 'hfos.events.schemamanager',
'action': 'all',
'data': l10n_schemas... | def all(self, event):
"""Return all known schemata to the requesting client"""
self.log("Schemarequest for all schemata from",
event.user, lvl=debug)
response = {
'component': 'hfos.events.schemamanager',
'action': 'all',
'data': l10n_schemas... | [
"Return",
"all",
"known",
"schemata",
"to",
"the",
"requesting",
"client"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/schemamanager.py#L198-L208 | [
"def",
"all",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"log",
"(",
"\"Schemarequest for all schemata from\"",
",",
"event",
".",
"user",
",",
"lvl",
"=",
"debug",
")",
"response",
"=",
"{",
"'component'",
":",
"'hfos.events.schemamanager'",
",",
"'a... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | SchemaManager.get | Return a single schema | hfos/ui/schemamanager.py | def get(self, event):
"""Return a single schema"""
self.log("Schemarequest for", event.data, "from",
event.user, lvl=debug)
if event.data in schemastore:
response = {
'component': 'hfos.events.schemamanager',
'action': 'get',
... | def get(self, event):
"""Return a single schema"""
self.log("Schemarequest for", event.data, "from",
event.user, lvl=debug)
if event.data in schemastore:
response = {
'component': 'hfos.events.schemamanager',
'action': 'get',
... | [
"Return",
"a",
"single",
"schema"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/schemamanager.py#L211-L223 | [
"def",
"get",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"log",
"(",
"\"Schemarequest for\"",
",",
"event",
".",
"data",
",",
"\"from\"",
",",
"event",
".",
"user",
",",
"lvl",
"=",
"debug",
")",
"if",
"event",
".",
"data",
"in",
"schemastore"... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | SchemaManager.configuration | Return all configurable components' schemata | hfos/ui/schemamanager.py | def configuration(self, event):
"""Return all configurable components' schemata"""
try:
self.log("Schemarequest for all configuration schemata from",
event.user.account.name, lvl=debug)
response = {
'component': 'hfos.events.schemamanager',
... | def configuration(self, event):
"""Return all configurable components' schemata"""
try:
self.log("Schemarequest for all configuration schemata from",
event.user.account.name, lvl=debug)
response = {
'component': 'hfos.events.schemamanager',
... | [
"Return",
"all",
"configurable",
"components",
"schemata"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/schemamanager.py#L226-L239 | [
"def",
"configuration",
"(",
"self",
",",
"event",
")",
":",
"try",
":",
"self",
".",
"log",
"(",
"\"Schemarequest for all configuration schemata from\"",
",",
"event",
".",
"user",
".",
"account",
".",
"name",
",",
"lvl",
"=",
"debug",
")",
"response",
"=",... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | uuid_object | Generates a regular expression controlled UUID field | hfos/schemata/base.py | def uuid_object(title="Reference", description="Select an object", default=None, display=True):
"""Generates a regular expression controlled UUID field"""
uuid = {
'pattern': '^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{'
'4}-['
'a-fA-F0-9]{4}-[a-fA-F0-9]{12}$',
... | def uuid_object(title="Reference", description="Select an object", default=None, display=True):
"""Generates a regular expression controlled UUID field"""
uuid = {
'pattern': '^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{'
'4}-['
'a-fA-F0-9]{4}-[a-fA-F0-9]{12}$',
... | [
"Generates",
"a",
"regular",
"expression",
"controlled",
"UUID",
"field"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/schemata/base.py#L42-L62 | [
"def",
"uuid_object",
"(",
"title",
"=",
"\"Reference\"",
",",
"description",
"=",
"\"Select an object\"",
",",
"default",
"=",
"None",
",",
"display",
"=",
"True",
")",
":",
"uuid",
"=",
"{",
"'pattern'",
":",
"'^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{'",
"'4}... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | base_object | Generates a basic object with RBAC properties | hfos/schemata/base.py | def base_object(name,
no_perms=False,
has_owner=True,
hide_owner=True,
has_uuid=True,
roles_write=None,
roles_read=None,
roles_list=None,
roles_create=None,
all_roles=None):
... | def base_object(name,
no_perms=False,
has_owner=True,
hide_owner=True,
has_uuid=True,
roles_write=None,
roles_read=None,
roles_list=None,
roles_create=None,
all_roles=None):
... | [
"Generates",
"a",
"basic",
"object",
"with",
"RBAC",
"properties"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/schemata/base.py#L65-L172 | [
"def",
"base_object",
"(",
"name",
",",
"no_perms",
"=",
"False",
",",
"has_owner",
"=",
"True",
",",
"hide_owner",
"=",
"True",
",",
"has_uuid",
"=",
"True",
",",
"roles_write",
"=",
"None",
",",
"roles_read",
"=",
"None",
",",
"roles_list",
"=",
"None"... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | serial_ports | Lists serial port names
:raises EnvironmentError:
On unsupported or unknown platforms
:returns:
A list of the serial ports available on the system
Courtesy: Thomas ( http://stackoverflow.com/questions/12090503
/listing-available-com-ports-with-python ) | modules/navdata/hfos/navdata/sensors.py | def serial_ports():
""" Lists serial port names
:raises EnvironmentError:
On unsupported or unknown platforms
:returns:
A list of the serial ports available on the system
Courtesy: Thomas ( http://stackoverflow.com/questions/12090503
/listing-available-com-p... | def serial_ports():
""" Lists serial port names
:raises EnvironmentError:
On unsupported or unknown platforms
:returns:
A list of the serial ports available on the system
Courtesy: Thomas ( http://stackoverflow.com/questions/12090503
/listing-available-com-p... | [
"Lists",
"serial",
"port",
"names"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/navdata/hfos/navdata/sensors.py#L61-L91 | [
"def",
"serial_ports",
"(",
")",
":",
"if",
"sys",
".",
"platform",
".",
"startswith",
"(",
"'win'",
")",
":",
"ports",
"=",
"[",
"'COM%s'",
"%",
"(",
"i",
"+",
"1",
")",
"for",
"i",
"in",
"range",
"(",
"256",
")",
"]",
"elif",
"sys",
".",
"pla... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | Sensors.sensordata | Generates a new reference frame from incoming sensordata
:param event: new sensordata to be merged into referenceframe | modules/navdata/hfos/navdata/sensors.py | def sensordata(self, event):
"""
Generates a new reference frame from incoming sensordata
:param event: new sensordata to be merged into referenceframe
"""
if len(self.datatypes) == 0:
return
data = event.data
timestamp = event.timestamp
# b... | def sensordata(self, event):
"""
Generates a new reference frame from incoming sensordata
:param event: new sensordata to be merged into referenceframe
"""
if len(self.datatypes) == 0:
return
data = event.data
timestamp = event.timestamp
# b... | [
"Generates",
"a",
"new",
"reference",
"frame",
"from",
"incoming",
"sensordata"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/navdata/hfos/navdata/sensors.py#L225-L288 | [
"def",
"sensordata",
"(",
"self",
",",
"event",
")",
":",
"if",
"len",
"(",
"self",
".",
"datatypes",
")",
"==",
"0",
":",
"return",
"data",
"=",
"event",
".",
"data",
"timestamp",
"=",
"event",
".",
"timestamp",
"# bus = event.bus",
"# TODO: What about mu... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | Sensors.navdatapush | Pushes the current :referenceframe: out to clients.
:return: | modules/navdata/hfos/navdata/sensors.py | def navdatapush(self):
"""
Pushes the current :referenceframe: out to clients.
:return:
"""
try:
self.fireEvent(referenceframe({
'data': self.referenceframe, 'ages': self.referenceages
}), "navdata")
self.intervalcount += 1
... | def navdatapush(self):
"""
Pushes the current :referenceframe: out to clients.
:return:
"""
try:
self.fireEvent(referenceframe({
'data': self.referenceframe, 'ages': self.referenceages
}), "navdata")
self.intervalcount += 1
... | [
"Pushes",
"the",
"current",
":",
"referenceframe",
":",
"out",
"to",
"clients",
"."
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/navdata/hfos/navdata/sensors.py#L290-L318 | [
"def",
"navdatapush",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"fireEvent",
"(",
"referenceframe",
"(",
"{",
"'data'",
":",
"self",
".",
"referenceframe",
",",
"'ages'",
":",
"self",
".",
"referenceages",
"}",
")",
",",
"\"navdata\"",
")",
"self",... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | db_export | Export stored objects
Warning! This functionality is work in progress and you may destroy live data by using it!
Be very careful when using the export/import functionality! | hfos/tool/backup.py | def db_export(schema, uuid, object_filter, export_format, filename, pretty, all_schemata, omit):
"""Export stored objects
Warning! This functionality is work in progress and you may destroy live data by using it!
Be very careful when using the export/import functionality!"""
internal_backup(schema, uu... | def db_export(schema, uuid, object_filter, export_format, filename, pretty, all_schemata, omit):
"""Export stored objects
Warning! This functionality is work in progress and you may destroy live data by using it!
Be very careful when using the export/import functionality!"""
internal_backup(schema, uu... | [
"Export",
"stored",
"objects"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/backup.py#L45-L51 | [
"def",
"db_export",
"(",
"schema",
",",
"uuid",
",",
"object_filter",
",",
"export_format",
",",
"filename",
",",
"pretty",
",",
"all_schemata",
",",
"omit",
")",
":",
"internal_backup",
"(",
"schema",
",",
"uuid",
",",
"object_filter",
",",
"export_format",
... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | db_import | Import objects from file
Warning! This functionality is work in progress and you may destroy live data by using it!
Be very careful when using the export/import functionality! | hfos/tool/backup.py | def db_import(ctx, schema, uuid, object_filter, import_format, filename, all_schemata, dry):
"""Import objects from file
Warning! This functionality is work in progress and you may destroy live data by using it!
Be very careful when using the export/import functionality!"""
import_format = import_form... | def db_import(ctx, schema, uuid, object_filter, import_format, filename, all_schemata, dry):
"""Import objects from file
Warning! This functionality is work in progress and you may destroy live data by using it!
Be very careful when using the export/import functionality!"""
import_format = import_form... | [
"Import",
"objects",
"from",
"file"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/backup.py#L65-L121 | [
"def",
"db_import",
"(",
"ctx",
",",
"schema",
",",
"uuid",
",",
"object_filter",
",",
"import_format",
",",
"filename",
",",
"all_schemata",
",",
"dry",
")",
":",
"import_format",
"=",
"import_format",
".",
"upper",
"(",
")",
"with",
"open",
"(",
"filenam... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | Wiki._page_update | Checks if the newly created object is a wikipage..
If so, rerenders the automatic index.
:param event: objectchange or objectcreation event | modules/wiki/hfos/wiki/wiki.py | def _page_update(self, event):
"""
Checks if the newly created object is a wikipage..
If so, rerenders the automatic index.
:param event: objectchange or objectcreation event
"""
try:
if event.schema == 'wikipage':
self._update_index()
... | def _page_update(self, event):
"""
Checks if the newly created object is a wikipage..
If so, rerenders the automatic index.
:param event: objectchange or objectcreation event
"""
try:
if event.schema == 'wikipage':
self._update_index()
... | [
"Checks",
"if",
"the",
"newly",
"created",
"object",
"is",
"a",
"wikipage",
"..",
"If",
"so",
"rerenders",
"the",
"automatic",
"index",
"."
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/wiki/hfos/wiki/wiki.py#L73-L86 | [
"def",
"_page_update",
"(",
"self",
",",
"event",
")",
":",
"try",
":",
"if",
"event",
".",
"schema",
"==",
"'wikipage'",
":",
"self",
".",
"_update_index",
"(",
")",
"except",
"Exception",
"as",
"e",
":",
"self",
".",
"log",
"(",
"\"Page creation notifi... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | drop_privileges | Attempt to drop privileges and change user to 'hfos' user/group | hfos/launcher.py | def drop_privileges(uid_name='hfos', gid_name='hfos'):
"""Attempt to drop privileges and change user to 'hfos' user/group"""
if os.getuid() != 0:
hfoslog("Not root, cannot drop privileges", lvl=warn, emitter='CORE')
return
try:
# Get the uid/gid from the name
running_uid = ... | def drop_privileges(uid_name='hfos', gid_name='hfos'):
"""Attempt to drop privileges and change user to 'hfos' user/group"""
if os.getuid() != 0:
hfoslog("Not root, cannot drop privileges", lvl=warn, emitter='CORE')
return
try:
# Get the uid/gid from the name
running_uid = ... | [
"Attempt",
"to",
"drop",
"privileges",
"and",
"change",
"user",
"to",
"hfos",
"user",
"/",
"group"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/launcher.py#L108-L131 | [
"def",
"drop_privileges",
"(",
"uid_name",
"=",
"'hfos'",
",",
"gid_name",
"=",
"'hfos'",
")",
":",
"if",
"os",
".",
"getuid",
"(",
")",
"!=",
"0",
":",
"hfoslog",
"(",
"\"Not root, cannot drop privileges\"",
",",
"lvl",
"=",
"warn",
",",
"emitter",
"=",
... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | construct_graph | Preliminary HFOS application Launcher | hfos/launcher.py | def construct_graph(args):
"""Preliminary HFOS application Launcher"""
app = Core(args)
setup_root(app)
if args['debug']:
from circuits import Debugger
hfoslog("Starting circuits debugger", lvl=warn, emitter='GRAPH')
dbg = Debugger().register(app)
# TODO: Make these co... | def construct_graph(args):
"""Preliminary HFOS application Launcher"""
app = Core(args)
setup_root(app)
if args['debug']:
from circuits import Debugger
hfoslog("Starting circuits debugger", lvl=warn, emitter='GRAPH')
dbg = Debugger().register(app)
# TODO: Make these co... | [
"Preliminary",
"HFOS",
"application",
"Launcher"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/launcher.py#L512-L551 | [
"def",
"construct_graph",
"(",
"args",
")",
":",
"app",
"=",
"Core",
"(",
"args",
")",
"setup_root",
"(",
"app",
")",
"if",
"args",
"[",
"'debug'",
"]",
":",
"from",
"circuits",
"import",
"Debugger",
"hfoslog",
"(",
"\"Starting circuits debugger\"",
",",
"... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | launch | Bootstrap basics, assemble graph and hand over control to the Core
component | hfos/launcher.py | def launch(run=True, **args):
"""Bootstrap basics, assemble graph and hand over control to the Core
component"""
verbosity['console'] = args['log'] if not args['quiet'] else 100
verbosity['global'] = min(args['log'], args['logfileverbosity'])
verbosity['file'] = args['logfileverbosity'] if args['do... | def launch(run=True, **args):
"""Bootstrap basics, assemble graph and hand over control to the Core
component"""
verbosity['console'] = args['log'] if not args['quiet'] else 100
verbosity['global'] = min(args['log'], args['logfileverbosity'])
verbosity['file'] = args['logfileverbosity'] if args['do... | [
"Bootstrap",
"basics",
"assemble",
"graph",
"and",
"hand",
"over",
"control",
"to",
"the",
"Core",
"component"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/launcher.py#L585-L612 | [
"def",
"launch",
"(",
"run",
"=",
"True",
",",
"*",
"*",
"args",
")",
":",
"verbosity",
"[",
"'console'",
"]",
"=",
"args",
"[",
"'log'",
"]",
"if",
"not",
"args",
"[",
"'quiet'",
"]",
"else",
"100",
"verbosity",
"[",
"'global'",
"]",
"=",
"min",
... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | Core.ready | All components have initialized, set up the component
configuration schema-store, run the local server and drop privileges | hfos/launcher.py | def ready(self, source):
"""All components have initialized, set up the component
configuration schema-store, run the local server and drop privileges"""
from hfos.database import configschemastore
configschemastore[self.name] = self.configschema
self._start_server()
i... | def ready(self, source):
"""All components have initialized, set up the component
configuration schema-store, run the local server and drop privileges"""
from hfos.database import configschemastore
configschemastore[self.name] = self.configschema
self._start_server()
i... | [
"All",
"components",
"have",
"initialized",
"set",
"up",
"the",
"component",
"configuration",
"schema",
"-",
"store",
"run",
"the",
"local",
"server",
"and",
"drop",
"privileges"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/launcher.py#L228-L245 | [
"def",
"ready",
"(",
"self",
",",
"source",
")",
":",
"from",
"hfos",
".",
"database",
"import",
"configschemastore",
"configschemastore",
"[",
"self",
".",
"name",
"]",
"=",
"self",
".",
"configschema",
"self",
".",
"_start_server",
"(",
")",
"if",
"not",... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | Core.trigger_frontend_build | Event hook to trigger a new frontend build | hfos/launcher.py | def trigger_frontend_build(self, event):
"""Event hook to trigger a new frontend build"""
from hfos.database import instance
install_frontend(instance=instance,
forcerebuild=event.force,
install=event.install,
developmen... | def trigger_frontend_build(self, event):
"""Event hook to trigger a new frontend build"""
from hfos.database import instance
install_frontend(instance=instance,
forcerebuild=event.force,
install=event.install,
developmen... | [
"Event",
"hook",
"to",
"trigger",
"a",
"new",
"frontend",
"build"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/launcher.py#L248-L256 | [
"def",
"trigger_frontend_build",
"(",
"self",
",",
"event",
")",
":",
"from",
"hfos",
".",
"database",
"import",
"instance",
"install_frontend",
"(",
"instance",
"=",
"instance",
",",
"forcerebuild",
"=",
"event",
".",
"force",
",",
"install",
"=",
"event",
... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | Core.cli_reload | Experimental call to reload the component tree | hfos/launcher.py | def cli_reload(self, event):
"""Experimental call to reload the component tree"""
self.log('Reloading all components.')
self.update_components(forcereload=True)
initialize()
from hfos.debugger import cli_compgraph
self.fireEvent(cli_compgraph()) | def cli_reload(self, event):
"""Experimental call to reload the component tree"""
self.log('Reloading all components.')
self.update_components(forcereload=True)
initialize()
from hfos.debugger import cli_compgraph
self.fireEvent(cli_compgraph()) | [
"Experimental",
"call",
"to",
"reload",
"the",
"component",
"tree"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/launcher.py#L280-L289 | [
"def",
"cli_reload",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"log",
"(",
"'Reloading all components.'",
")",
"self",
".",
"update_components",
"(",
"forcereload",
"=",
"True",
")",
"initialize",
"(",
")",
"from",
"hfos",
".",
"debugger",
"import",
... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | Core.cli_info | Provides information about the running instance | hfos/launcher.py | def cli_info(self, event):
"""Provides information about the running instance"""
self.log('Instance:', self.instance,
'Dev:', self.development,
'Host:', self.host,
'Port:', self.port,
'Insecure:', self.insecure,
'Front... | def cli_info(self, event):
"""Provides information about the running instance"""
self.log('Instance:', self.instance,
'Dev:', self.development,
'Host:', self.host,
'Port:', self.port,
'Insecure:', self.insecure,
'Front... | [
"Provides",
"information",
"about",
"the",
"running",
"instance"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/launcher.py#L299-L307 | [
"def",
"cli_info",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"log",
"(",
"'Instance:'",
",",
"self",
".",
"instance",
",",
"'Dev:'",
",",
"self",
".",
"development",
",",
"'Host:'",
",",
"self",
".",
"host",
",",
"'Port:'",
",",
"self",
".",
... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | Core._start_server | Run the node local server | hfos/launcher.py | def _start_server(self, *args):
"""Run the node local server"""
self.log("Starting server", args)
secure = self.certificate is not None
if secure:
self.log("Running SSL server with cert:", self.certificate)
else:
self.log("Running insecure server without ... | def _start_server(self, *args):
"""Run the node local server"""
self.log("Starting server", args)
secure = self.certificate is not None
if secure:
self.log("Running SSL server with cert:", self.certificate)
else:
self.log("Running insecure server without ... | [
"Run",
"the",
"node",
"local",
"server"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/launcher.py#L309-L328 | [
"def",
"_start_server",
"(",
"self",
",",
"*",
"args",
")",
":",
"self",
".",
"log",
"(",
"\"Starting server\"",
",",
"args",
")",
"secure",
"=",
"self",
".",
"certificate",
"is",
"not",
"None",
"if",
"secure",
":",
"self",
".",
"log",
"(",
"\"Running ... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | Core.update_components | Check all known entry points for components. If necessary,
manage configuration updates | hfos/launcher.py | def update_components(self, forcereload=False, forcerebuild=False,
forcecopy=True, install=False):
"""Check all known entry points for components. If necessary,
manage configuration updates"""
# TODO: See if we can pull out major parts of the component handling.
... | def update_components(self, forcereload=False, forcerebuild=False,
forcecopy=True, install=False):
"""Check all known entry points for components. If necessary,
manage configuration updates"""
# TODO: See if we can pull out major parts of the component handling.
... | [
"Check",
"all",
"known",
"entry",
"points",
"for",
"components",
".",
"If",
"necessary",
"manage",
"configuration",
"updates"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/launcher.py#L340-L428 | [
"def",
"update_components",
"(",
"self",
",",
"forcereload",
"=",
"False",
",",
"forcerebuild",
"=",
"False",
",",
"forcecopy",
"=",
"True",
",",
"install",
"=",
"False",
")",
":",
"# TODO: See if we can pull out major parts of the component handling.",
"# They are also... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | Core._start_frontend | Check if it is enabled and start the frontend http & websocket | hfos/launcher.py | def _start_frontend(self, restart=False):
"""Check if it is enabled and start the frontend http & websocket"""
self.log(self.config, self.config.frontendenabled, lvl=verbose)
if self.config.frontendenabled and not self.frontendrunning or restart:
self.log("Restarting webfrontend ser... | def _start_frontend(self, restart=False):
"""Check if it is enabled and start the frontend http & websocket"""
self.log(self.config, self.config.frontendenabled, lvl=verbose)
if self.config.frontendenabled and not self.frontendrunning or restart:
self.log("Restarting webfrontend ser... | [
"Check",
"if",
"it",
"is",
"enabled",
"and",
"start",
"the",
"frontend",
"http",
"&",
"websocket"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/launcher.py#L430-L442 | [
"def",
"_start_frontend",
"(",
"self",
",",
"restart",
"=",
"False",
")",
":",
"self",
".",
"log",
"(",
"self",
".",
"config",
",",
"self",
".",
"config",
".",
"frontendenabled",
",",
"lvl",
"=",
"verbose",
")",
"if",
"self",
".",
"config",
".",
"fro... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | Core._instantiate_components | Inspect all loadable components and run them | hfos/launcher.py | def _instantiate_components(self, clear=True):
"""Inspect all loadable components and run them"""
if clear:
import objgraph
from copy import deepcopy
from circuits.tools import kill
from circuits import Component
for comp in self.runningcompon... | def _instantiate_components(self, clear=True):
"""Inspect all loadable components and run them"""
if clear:
import objgraph
from copy import deepcopy
from circuits.tools import kill
from circuits import Component
for comp in self.runningcompon... | [
"Inspect",
"all",
"loadable",
"components",
"and",
"run",
"them"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/launcher.py#L444-L494 | [
"def",
"_instantiate_components",
"(",
"self",
",",
"clear",
"=",
"True",
")",
":",
"if",
"clear",
":",
"import",
"objgraph",
"from",
"copy",
"import",
"deepcopy",
"from",
"circuits",
".",
"tools",
"import",
"kill",
"from",
"circuits",
"import",
"Component",
... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | Core.started | Sets up the application after startup. | hfos/launcher.py | def started(self, component):
"""Sets up the application after startup."""
self.log("Running.")
self.log("Started event origin: ", component, lvl=verbose)
populate_user_events()
from hfos.events.system import AuthorizedEvents
self.log(len(AuthorizedEvents), "authorized ... | def started(self, component):
"""Sets up the application after startup."""
self.log("Running.")
self.log("Started event origin: ", component, lvl=verbose)
populate_user_events()
from hfos.events.system import AuthorizedEvents
self.log(len(AuthorizedEvents), "authorized ... | [
"Sets",
"up",
"the",
"application",
"after",
"startup",
"."
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/launcher.py#L496-L509 | [
"def",
"started",
"(",
"self",
",",
"component",
")",
":",
"self",
".",
"log",
"(",
"\"Running.\"",
")",
"self",
".",
"log",
"(",
"\"Started event origin: \"",
",",
"component",
",",
"lvl",
"=",
"verbose",
")",
"populate_user_events",
"(",
")",
"from",
"hf... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | user | [GROUP] User management operations | hfos/tool/user.py | def user(ctx, username, password):
"""[GROUP] User management operations"""
ctx.obj['username'] = username
ctx.obj['password'] = password | def user(ctx, username, password):
"""[GROUP] User management operations"""
ctx.obj['username'] = username
ctx.obj['password'] = password | [
"[",
"GROUP",
"]",
"User",
"management",
"operations"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/user.py#L41-L45 | [
"def",
"user",
"(",
"ctx",
",",
"username",
",",
"password",
")",
":",
"ctx",
".",
"obj",
"[",
"'username'",
"]",
"=",
"username",
"ctx",
".",
"obj",
"[",
"'password'",
"]",
"=",
"password"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | _create_user | Internal method to create a normal user | hfos/tool/user.py | def _create_user(ctx):
"""Internal method to create a normal user"""
username, passhash = _get_credentials(ctx.obj['username'],
ctx.obj['password'],
ctx.obj['db'])
if ctx.obj['db'].objectmodels['user'].count({'name': usern... | def _create_user(ctx):
"""Internal method to create a normal user"""
username, passhash = _get_credentials(ctx.obj['username'],
ctx.obj['password'],
ctx.obj['db'])
if ctx.obj['db'].objectmodels['user'].count({'name': usern... | [
"Internal",
"method",
"to",
"create",
"a",
"normal",
"user"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/user.py#L48-L66 | [
"def",
"_create_user",
"(",
"ctx",
")",
":",
"username",
",",
"passhash",
"=",
"_get_credentials",
"(",
"ctx",
".",
"obj",
"[",
"'username'",
"]",
",",
"ctx",
".",
"obj",
"[",
"'password'",
"]",
",",
"ctx",
".",
"obj",
"[",
"'db'",
"]",
")",
"if",
... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | create_user | Creates a new local user | hfos/tool/user.py | def create_user(ctx):
"""Creates a new local user"""
try:
new_user = _create_user(ctx)
new_user.save()
log("Done")
except KeyError:
log('User already exists', lvl=warn) | def create_user(ctx):
"""Creates a new local user"""
try:
new_user = _create_user(ctx)
new_user.save()
log("Done")
except KeyError:
log('User already exists', lvl=warn) | [
"Creates",
"a",
"new",
"local",
"user"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/user.py#L71-L80 | [
"def",
"create_user",
"(",
"ctx",
")",
":",
"try",
":",
"new_user",
"=",
"_create_user",
"(",
"ctx",
")",
"new_user",
".",
"save",
"(",
")",
"log",
"(",
"\"Done\"",
")",
"except",
"KeyError",
":",
"log",
"(",
"'User already exists'",
",",
"lvl",
"=",
"... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | create_admin | Creates a new local user and assigns admin role | hfos/tool/user.py | def create_admin(ctx):
"""Creates a new local user and assigns admin role"""
try:
admin = _create_user(ctx)
admin.roles.append('admin')
admin.save()
log("Done")
except KeyError:
log('User already exists', lvl=warn) | def create_admin(ctx):
"""Creates a new local user and assigns admin role"""
try:
admin = _create_user(ctx)
admin.roles.append('admin')
admin.save()
log("Done")
except KeyError:
log('User already exists', lvl=warn) | [
"Creates",
"a",
"new",
"local",
"user",
"and",
"assigns",
"admin",
"role"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/user.py#L85-L95 | [
"def",
"create_admin",
"(",
"ctx",
")",
":",
"try",
":",
"admin",
"=",
"_create_user",
"(",
"ctx",
")",
"admin",
".",
"roles",
".",
"append",
"(",
"'admin'",
")",
"admin",
".",
"save",
"(",
")",
"log",
"(",
"\"Done\"",
")",
"except",
"KeyError",
":",... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | delete_user | Delete a local user | hfos/tool/user.py | def delete_user(ctx, yes):
"""Delete a local user"""
if ctx.obj['username'] is None:
username = _ask("Please enter username:")
else:
username = ctx.obj['username']
del_user = ctx.obj['db'].objectmodels['user'].find_one({'name': username})
if yes or _ask('Confirm deletion', default=... | def delete_user(ctx, yes):
"""Delete a local user"""
if ctx.obj['username'] is None:
username = _ask("Please enter username:")
else:
username = ctx.obj['username']
del_user = ctx.obj['db'].objectmodels['user'].find_one({'name': username})
if yes or _ask('Confirm deletion', default=... | [
"Delete",
"a",
"local",
"user"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/user.py#L102-L118 | [
"def",
"delete_user",
"(",
"ctx",
",",
"yes",
")",
":",
"if",
"ctx",
".",
"obj",
"[",
"'username'",
"]",
"is",
"None",
":",
"username",
"=",
"_ask",
"(",
"\"Please enter username:\"",
")",
"else",
":",
"username",
"=",
"ctx",
".",
"obj",
"[",
"'usernam... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | change_password | Change password of an existing user | hfos/tool/user.py | def change_password(ctx):
"""Change password of an existing user"""
username, passhash = _get_credentials(ctx.obj['username'],
ctx.obj['password'],
ctx.obj['db'])
change_user = ctx.obj['db'].objectmodels['user'].find_one({... | def change_password(ctx):
"""Change password of an existing user"""
username, passhash = _get_credentials(ctx.obj['username'],
ctx.obj['password'],
ctx.obj['db'])
change_user = ctx.obj['db'].objectmodels['user'].find_one({... | [
"Change",
"password",
"of",
"an",
"existing",
"user"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/user.py#L123-L140 | [
"def",
"change_password",
"(",
"ctx",
")",
":",
"username",
",",
"passhash",
"=",
"_get_credentials",
"(",
"ctx",
".",
"obj",
"[",
"'username'",
"]",
",",
"ctx",
".",
"obj",
"[",
"'password'",
"]",
",",
"ctx",
".",
"obj",
"[",
"'db'",
"]",
")",
"chan... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | list_users | List all locally known users | hfos/tool/user.py | def list_users(ctx, search, uuid, active):
"""List all locally known users"""
users = ctx.obj['db'].objectmodels['user']
for found_user in users.find():
if not search or (search and search in found_user.name):
# TODO: Not 2.x compatible
print(found_user.name, end=' ' if act... | def list_users(ctx, search, uuid, active):
"""List all locally known users"""
users = ctx.obj['db'].objectmodels['user']
for found_user in users.find():
if not search or (search and search in found_user.name):
# TODO: Not 2.x compatible
print(found_user.name, end=' ' if act... | [
"List",
"all",
"locally",
"known",
"users"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/user.py#L151-L165 | [
"def",
"list_users",
"(",
"ctx",
",",
"search",
",",
"uuid",
",",
"active",
")",
":",
"users",
"=",
"ctx",
".",
"obj",
"[",
"'db'",
"]",
".",
"objectmodels",
"[",
"'user'",
"]",
"for",
"found_user",
"in",
"users",
".",
"find",
"(",
")",
":",
"if",
... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | disable | Disable an existing user | hfos/tool/user.py | def disable(ctx):
"""Disable an existing user"""
if ctx.obj['username'] is None:
log('Specify the username with "iso db user --username ..."')
return
change_user = ctx.obj['db'].objectmodels['user'].find_one({
'name': ctx.obj['username']
})
change_user.active = False
c... | def disable(ctx):
"""Disable an existing user"""
if ctx.obj['username'] is None:
log('Specify the username with "iso db user --username ..."')
return
change_user = ctx.obj['db'].objectmodels['user'].find_one({
'name': ctx.obj['username']
})
change_user.active = False
c... | [
"Disable",
"an",
"existing",
"user"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/user.py#L170-L183 | [
"def",
"disable",
"(",
"ctx",
")",
":",
"if",
"ctx",
".",
"obj",
"[",
"'username'",
"]",
"is",
"None",
":",
"log",
"(",
"'Specify the username with \"iso db user --username ...\"'",
")",
"return",
"change_user",
"=",
"ctx",
".",
"obj",
"[",
"'db'",
"]",
".",... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | enable | Enable an existing user | hfos/tool/user.py | def enable(ctx):
"""Enable an existing user"""
if ctx.obj['username'] is None:
log('Specify the username with "iso db user --username ..."')
return
change_user = ctx.obj['db'].objectmodels['user'].find_one({
'name': ctx.obj['username']
})
change_user.active = True
chan... | def enable(ctx):
"""Enable an existing user"""
if ctx.obj['username'] is None:
log('Specify the username with "iso db user --username ..."')
return
change_user = ctx.obj['db'].objectmodels['user'].find_one({
'name': ctx.obj['username']
})
change_user.active = True
chan... | [
"Enable",
"an",
"existing",
"user"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/user.py#L188-L201 | [
"def",
"enable",
"(",
"ctx",
")",
":",
"if",
"ctx",
".",
"obj",
"[",
"'username'",
"]",
"is",
"None",
":",
"log",
"(",
"'Specify the username with \"iso db user --username ...\"'",
")",
"return",
"change_user",
"=",
"ctx",
".",
"obj",
"[",
"'db'",
"]",
".",
... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | add_role | Grant a role to an existing user | hfos/tool/user.py | def add_role(ctx, role):
"""Grant a role to an existing user"""
if role is None:
log('Specify the role with --role')
return
if ctx.obj['username'] is None:
log('Specify the username with --username')
return
change_user = ctx.obj['db'].objectmodels['user'].find_one({
... | def add_role(ctx, role):
"""Grant a role to an existing user"""
if role is None:
log('Specify the role with --role')
return
if ctx.obj['username'] is None:
log('Specify the username with --username')
return
change_user = ctx.obj['db'].objectmodels['user'].find_one({
... | [
"Grant",
"a",
"role",
"to",
"an",
"existing",
"user"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/user.py#L207-L225 | [
"def",
"add_role",
"(",
"ctx",
",",
"role",
")",
":",
"if",
"role",
"is",
"None",
":",
"log",
"(",
"'Specify the role with --role'",
")",
"return",
"if",
"ctx",
".",
"obj",
"[",
"'username'",
"]",
"is",
"None",
":",
"log",
"(",
"'Specify the username with ... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | check_expression | >>> class mock_framework:
... def assertIn(self, item, list, msg="Failed asserting item is in list"):
... if item not in list: raise Exception(msg)
... def assertTrue(self, value, msg="Failed asserting true"):
... if not value: raise Exception(msg)
... def assertFalse(self, value, msg)... | reparse/tools/expression_checker.py | def check_expression(testing_framework, expression_dict):
"""
>>> class mock_framework:
... def assertIn(self, item, list, msg="Failed asserting item is in list"):
... if item not in list: raise Exception(msg)
... def assertTrue(self, value, msg="Failed asserting true"):
... if not v... | def check_expression(testing_framework, expression_dict):
"""
>>> class mock_framework:
... def assertIn(self, item, list, msg="Failed asserting item is in list"):
... if item not in list: raise Exception(msg)
... def assertTrue(self, value, msg="Failed asserting true"):
... if not v... | [
">>>",
"class",
"mock_framework",
":",
"...",
"def",
"assertIn",
"(",
"self",
"item",
"list",
"msg",
"=",
"Failed",
"asserting",
"item",
"is",
"in",
"list",
")",
":",
"...",
"if",
"item",
"not",
"in",
"list",
":",
"raise",
"Exception",
"(",
"msg",
")",... | andychase/reparse | python | https://github.com/andychase/reparse/blob/5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508/reparse/tools/expression_checker.py#L25-L48 | [
"def",
"check_expression",
"(",
"testing_framework",
",",
"expression_dict",
")",
":",
"expression_sub",
"=",
"get_expression_sub",
"(",
")",
"for",
"expression_type_name",
",",
"expression_type",
"in",
"expression_dict",
".",
"items",
"(",
")",
":",
"for",
"name",
... | 5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508 |
train | ProjectService._get_future_tasks | Assemble a list of future alerts | modules/project/hfos/project/projectservice.py | def _get_future_tasks(self):
"""Assemble a list of future alerts"""
self.alerts = {}
now = std_now()
for task in objectmodels['task'].find({'alert_time': {'$gt': now}}):
self.alerts[task.alert_time] = task
self.log('Found', len(self.alerts), 'future tasks') | def _get_future_tasks(self):
"""Assemble a list of future alerts"""
self.alerts = {}
now = std_now()
for task in objectmodels['task'].find({'alert_time': {'$gt': now}}):
self.alerts[task.alert_time] = task
self.log('Found', len(self.alerts), 'future tasks') | [
"Assemble",
"a",
"list",
"of",
"future",
"alerts"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/project/hfos/project/projectservice.py#L69-L78 | [
"def",
"_get_future_tasks",
"(",
"self",
")",
":",
"self",
".",
"alerts",
"=",
"{",
"}",
"now",
"=",
"std_now",
"(",
")",
"for",
"task",
"in",
"objectmodels",
"[",
"'task'",
"]",
".",
"find",
"(",
"{",
"'alert_time'",
":",
"{",
"'$gt'",
":",
"now",
... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | ProjectService.check_alerts | Periodical check to issue due alerts | modules/project/hfos/project/projectservice.py | def check_alerts(self):
"""Periodical check to issue due alerts"""
alerted = []
for alert_time, task in self.alerts.items():
task_time = dateutil.parser.parse(alert_time)
if task_time < get_time():
self.log('Alerting about task now:', task)
... | def check_alerts(self):
"""Periodical check to issue due alerts"""
alerted = []
for alert_time, task in self.alerts.items():
task_time = dateutil.parser.parse(alert_time)
if task_time < get_time():
self.log('Alerting about task now:', task)
... | [
"Periodical",
"check",
"to",
"issue",
"due",
"alerts"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/project/hfos/project/projectservice.py#L103-L122 | [
"def",
"check_alerts",
"(",
"self",
")",
":",
"alerted",
"=",
"[",
"]",
"for",
"alert_time",
",",
"task",
"in",
"self",
".",
"alerts",
".",
"items",
"(",
")",
":",
"task_time",
"=",
"dateutil",
".",
"parser",
".",
"parse",
"(",
"alert_time",
")",
"if... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | BusRepeater.read | Handles incoming raw sensor data and broadcasts it to specified
udp servers and connected tcp clients
:param data: NMEA raw sentences incoming data | modules/busrepeater/hfos/busrepeater/busrepeater.py | def read(self, data):
"""Handles incoming raw sensor data and broadcasts it to specified
udp servers and connected tcp clients
:param data: NMEA raw sentences incoming data
"""
self.log('Received NMEA data:', data, lvl=debug)
# self.log(data, pretty=True)
if sel... | def read(self, data):
"""Handles incoming raw sensor data and broadcasts it to specified
udp servers and connected tcp clients
:param data: NMEA raw sentences incoming data
"""
self.log('Received NMEA data:', data, lvl=debug)
# self.log(data, pretty=True)
if sel... | [
"Handles",
"incoming",
"raw",
"sensor",
"data",
"and",
"broadcasts",
"it",
"to",
"specified",
"udp",
"servers",
"and",
"connected",
"tcp",
"clients",
":",
"param",
"data",
":",
"NMEA",
"raw",
"sentences",
"incoming",
"data"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/busrepeater/hfos/busrepeater/busrepeater.py#L130-L163 | [
"def",
"read",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"log",
"(",
"'Received NMEA data:'",
",",
"data",
",",
"lvl",
"=",
"debug",
")",
"# self.log(data, pretty=True)",
"if",
"self",
".",
"_tcp_socket",
"is",
"not",
"None",
"and",
"len",
"(",
"s... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | cmdmap | Generates a command map | hfos/tool/misc.py | def cmdmap(xdot):
"""Generates a command map"""
# TODO: Integrate the output into documentation
from copy import copy
def print_commands(command, map_output, groups=None, depth=0):
if groups is None:
groups = []
if 'commands' in command.__dict__:
if len(groups) ... | def cmdmap(xdot):
"""Generates a command map"""
# TODO: Integrate the output into documentation
from copy import copy
def print_commands(command, map_output, groups=None, depth=0):
if groups is None:
groups = []
if 'commands' in command.__dict__:
if len(groups) ... | [
"Generates",
"a",
"command",
"map"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/misc.py#L47-L88 | [
"def",
"cmdmap",
"(",
"xdot",
")",
":",
"# TODO: Integrate the output into documentation",
"from",
"copy",
"import",
"copy",
"def",
"print_commands",
"(",
"command",
",",
"map_output",
",",
"groups",
"=",
"None",
",",
"depth",
"=",
"0",
")",
":",
"if",
"groups... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | format_template | Render a given pystache template
with given content | hfos/tool/templates.py | def format_template(template, content):
"""Render a given pystache template
with given content"""
import pystache
result = u""
if True: # try:
result = pystache.render(template, content, string_encoding='utf-8')
# except (ValueError, KeyError) as e:
# print("Templating error: %s... | def format_template(template, content):
"""Render a given pystache template
with given content"""
import pystache
result = u""
if True: # try:
result = pystache.render(template, content, string_encoding='utf-8')
# except (ValueError, KeyError) as e:
# print("Templating error: %s... | [
"Render",
"a",
"given",
"pystache",
"template",
"with",
"given",
"content"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/templates.py#L27-L39 | [
"def",
"format_template",
"(",
"template",
",",
"content",
")",
":",
"import",
"pystache",
"result",
"=",
"u\"\"",
"if",
"True",
":",
"# try:",
"result",
"=",
"pystache",
".",
"render",
"(",
"template",
",",
"content",
",",
"string_encoding",
"=",
"'utf-8'",... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | format_template_file | Render a given pystache template file with given content | hfos/tool/templates.py | def format_template_file(filename, content):
"""Render a given pystache template file with given content"""
with open(filename, 'r') as f:
template = f.read()
if type(template) != str:
template = template.decode('utf-8')
return format_template(template, content) | def format_template_file(filename, content):
"""Render a given pystache template file with given content"""
with open(filename, 'r') as f:
template = f.read()
if type(template) != str:
template = template.decode('utf-8')
return format_template(template, content) | [
"Render",
"a",
"given",
"pystache",
"template",
"file",
"with",
"given",
"content"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/templates.py#L42-L50 | [
"def",
"format_template_file",
"(",
"filename",
",",
"content",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'r'",
")",
"as",
"f",
":",
"template",
"=",
"f",
".",
"read",
"(",
")",
"if",
"type",
"(",
"template",
")",
"!=",
"str",
":",
"template",... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | write_template_file | Write a new file from a given pystache template file and content | hfos/tool/templates.py | def write_template_file(source, target, content):
"""Write a new file from a given pystache template file and content"""
# print(formatTemplateFile(source, content))
print(target)
data = format_template_file(source, content)
with open(target, 'w') as f:
for line in data:
if type... | def write_template_file(source, target, content):
"""Write a new file from a given pystache template file and content"""
# print(formatTemplateFile(source, content))
print(target)
data = format_template_file(source, content)
with open(target, 'w') as f:
for line in data:
if type... | [
"Write",
"a",
"new",
"file",
"from",
"a",
"given",
"pystache",
"template",
"file",
"and",
"content"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/templates.py#L53-L63 | [
"def",
"write_template_file",
"(",
"source",
",",
"target",
",",
"content",
")",
":",
"# print(formatTemplateFile(source, content))",
"print",
"(",
"target",
")",
"data",
"=",
"format_template_file",
"(",
"source",
",",
"content",
")",
"with",
"open",
"(",
"target... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | insert_nginx_service | Insert a new nginx service definition | hfos/tool/templates.py | def insert_nginx_service(definition): # pragma: no cover
"""Insert a new nginx service definition"""
config_file = '/etc/nginx/sites-available/hfos.conf'
splitter = "### SERVICE DEFINITIONS ###"
with open(config_file, 'r') as f:
old_config = "".join(f.readlines())
pprint(old_config)
... | def insert_nginx_service(definition): # pragma: no cover
"""Insert a new nginx service definition"""
config_file = '/etc/nginx/sites-available/hfos.conf'
splitter = "### SERVICE DEFINITIONS ###"
with open(config_file, 'r') as f:
old_config = "".join(f.readlines())
pprint(old_config)
... | [
"Insert",
"a",
"new",
"nginx",
"service",
"definition"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/templates.py#L66-L99 | [
"def",
"insert_nginx_service",
"(",
"definition",
")",
":",
"# pragma: no cover",
"config_file",
"=",
"'/etc/nginx/sites-available/hfos.conf'",
"splitter",
"=",
"\"### SERVICE DEFINITIONS ###\"",
"with",
"open",
"(",
"config_file",
",",
"'r'",
")",
"as",
"f",
":",
"old_... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | rbac | [GROUP] Role based access control | hfos/tool/rbac.py | def rbac(ctx, schema, object_filter, action, role, all_schemata):
"""[GROUP] Role based access control"""
database = ctx.obj['db']
if schema is None:
if all_schemata is False:
log('No schema given. Read the RBAC group help', lvl=warn)
sys.exit()
else:
sc... | def rbac(ctx, schema, object_filter, action, role, all_schemata):
"""[GROUP] Role based access control"""
database = ctx.obj['db']
if schema is None:
if all_schemata is False:
log('No schema given. Read the RBAC group help', lvl=warn)
sys.exit()
else:
sc... | [
"[",
"GROUP",
"]",
"Role",
"based",
"access",
"control"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/rbac.py#L42-L73 | [
"def",
"rbac",
"(",
"ctx",
",",
"schema",
",",
"object_filter",
",",
"action",
",",
"role",
",",
"all_schemata",
")",
":",
"database",
"=",
"ctx",
".",
"obj",
"[",
"'db'",
"]",
"if",
"schema",
"is",
"None",
":",
"if",
"all_schemata",
"is",
"False",
"... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | add_action_role | Adds a role to an action on objects | hfos/tool/rbac.py | def add_action_role(ctx):
"""Adds a role to an action on objects"""
objects = ctx.obj['objects']
action = ctx.obj['action']
role = ctx.obj['role']
if action is None or role is None:
log('You need to specify an action or role to the RBAC command group for this to work.', lvl=warn)
r... | def add_action_role(ctx):
"""Adds a role to an action on objects"""
objects = ctx.obj['objects']
action = ctx.obj['action']
role = ctx.obj['role']
if action is None or role is None:
log('You need to specify an action or role to the RBAC command group for this to work.', lvl=warn)
r... | [
"Adds",
"a",
"role",
"to",
"an",
"action",
"on",
"objects"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/rbac.py#L78-L94 | [
"def",
"add_action_role",
"(",
"ctx",
")",
":",
"objects",
"=",
"ctx",
".",
"obj",
"[",
"'objects'",
"]",
"action",
"=",
"ctx",
".",
"obj",
"[",
"'action'",
"]",
"role",
"=",
"ctx",
".",
"obj",
"[",
"'role'",
"]",
"if",
"action",
"is",
"None",
"or"... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | del_action_role | Deletes a role from an action on objects | hfos/tool/rbac.py | def del_action_role(ctx):
"""Deletes a role from an action on objects"""
objects = ctx.obj['objects']
action = ctx.obj['action']
role = ctx.obj['role']
if action is None or role is None:
log('You need to specify an action or role to the RBAC command group for this to work.', lvl=warn)
... | def del_action_role(ctx):
"""Deletes a role from an action on objects"""
objects = ctx.obj['objects']
action = ctx.obj['action']
role = ctx.obj['role']
if action is None or role is None:
log('You need to specify an action or role to the RBAC command group for this to work.', lvl=warn)
... | [
"Deletes",
"a",
"role",
"from",
"an",
"action",
"on",
"objects"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/rbac.py#L99-L115 | [
"def",
"del_action_role",
"(",
"ctx",
")",
":",
"objects",
"=",
"ctx",
".",
"obj",
"[",
"'objects'",
"]",
"action",
"=",
"ctx",
".",
"obj",
"[",
"'action'",
"]",
"role",
"=",
"ctx",
".",
"obj",
"[",
"'role'",
"]",
"if",
"action",
"is",
"None",
"or"... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | change_owner | Changes the ownership of objects | hfos/tool/rbac.py | def change_owner(ctx, owner, uuid):
"""Changes the ownership of objects"""
objects = ctx.obj['objects']
database = ctx.obj['db']
if uuid is True:
owner_filter = {'uuid': owner}
else:
owner_filter = {'name': owner}
owner = database.objectmodels['user'].find_one(owner_filter)
... | def change_owner(ctx, owner, uuid):
"""Changes the ownership of objects"""
objects = ctx.obj['objects']
database = ctx.obj['db']
if uuid is True:
owner_filter = {'uuid': owner}
else:
owner_filter = {'name': owner}
owner = database.objectmodels['user'].find_one(owner_filter)
... | [
"Changes",
"the",
"ownership",
"of",
"objects"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/rbac.py#L122-L142 | [
"def",
"change_owner",
"(",
"ctx",
",",
"owner",
",",
"uuid",
")",
":",
"objects",
"=",
"ctx",
".",
"obj",
"[",
"'objects'",
"]",
"database",
"=",
"ctx",
".",
"obj",
"[",
"'db'",
"]",
"if",
"uuid",
"is",
"True",
":",
"owner_filter",
"=",
"{",
"'uui... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | NotificationManager.notify | Notify a user | modules/notifications/hfos/notifications/notificationmanager.py | def notify(self, event):
"""Notify a user"""
self.log('Got a notification event!')
self.log(event, pretty=True)
self.log(event.__dict__) | def notify(self, event):
"""Notify a user"""
self.log('Got a notification event!')
self.log(event, pretty=True)
self.log(event.__dict__) | [
"Notify",
"a",
"user"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/notifications/hfos/notifications/notificationmanager.py#L64-L70 | [
"def",
"notify",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"log",
"(",
"'Got a notification event!'",
")",
"self",
".",
"log",
"(",
"event",
",",
"pretty",
"=",
"True",
")",
"self",
".",
"log",
"(",
"event",
".",
"__dict__",
")"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | RemoteControlManager.clientdisconnect | Handler to deal with a possibly disconnected remote controlling
client
:param event: ClientDisconnect Event | modules/robot/hfos/robot/rcmanager.py | def clientdisconnect(self, event):
"""Handler to deal with a possibly disconnected remote controlling
client
:param event: ClientDisconnect Event
"""
try:
if event.clientuuid == self.remote_controller:
self.log("Remote controller disconnected!", lvl=c... | def clientdisconnect(self, event):
"""Handler to deal with a possibly disconnected remote controlling
client
:param event: ClientDisconnect Event
"""
try:
if event.clientuuid == self.remote_controller:
self.log("Remote controller disconnected!", lvl=c... | [
"Handler",
"to",
"deal",
"with",
"a",
"possibly",
"disconnected",
"remote",
"controlling",
"client",
":",
"param",
"event",
":",
"ClientDisconnect",
"Event"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/robot/hfos/robot/rcmanager.py#L75-L86 | [
"def",
"clientdisconnect",
"(",
"self",
",",
"event",
")",
":",
"try",
":",
"if",
"event",
".",
"clientuuid",
"==",
"self",
".",
"remote_controller",
":",
"self",
".",
"log",
"(",
"\"Remote controller disconnected!\"",
",",
"lvl",
"=",
"critical",
")",
"self... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | Configurator.getlist | Processes configuration list requests
:param event: | hfos/ui/configurator.py | def getlist(self, event):
"""Processes configuration list requests
:param event:
"""
try:
componentlist = model_factory(Schema).find({})
data = []
for comp in componentlist:
try:
data.append({
... | def getlist(self, event):
"""Processes configuration list requests
:param event:
"""
try:
componentlist = model_factory(Schema).find({})
data = []
for comp in componentlist:
try:
data.append({
... | [
"Processes",
"configuration",
"list",
"requests"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/configurator.py#L81-L113 | [
"def",
"getlist",
"(",
"self",
",",
"event",
")",
":",
"try",
":",
"componentlist",
"=",
"model_factory",
"(",
"Schema",
")",
".",
"find",
"(",
"{",
"}",
")",
"data",
"=",
"[",
"]",
"for",
"comp",
"in",
"componentlist",
":",
"try",
":",
"data",
"."... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | Configurator.put | Store a given configuration | hfos/ui/configurator.py | def put(self, event):
"""Store a given configuration"""
self.log("Configuration put request ",
event.user)
try:
component = model_factory(Schema).find_one({
'uuid': event.data['uuid']
})
component.update(event.data)
... | def put(self, event):
"""Store a given configuration"""
self.log("Configuration put request ",
event.user)
try:
component = model_factory(Schema).find_one({
'uuid': event.data['uuid']
})
component.update(event.data)
... | [
"Store",
"a",
"given",
"configuration"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/configurator.py#L116-L149 | [
"def",
"put",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"log",
"(",
"\"Configuration put request \"",
",",
"event",
".",
"user",
")",
"try",
":",
"component",
"=",
"model_factory",
"(",
"Schema",
")",
".",
"find_one",
"(",
"{",
"'uuid'",
":",
"... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | Configurator.get | Get a stored configuration | hfos/ui/configurator.py | def get(self, event):
"""Get a stored configuration"""
try:
comp = event.data['uuid']
except KeyError:
comp = None
if not comp:
self.log('Invalid get request without schema or component',
lvl=error)
return
se... | def get(self, event):
"""Get a stored configuration"""
try:
comp = event.data['uuid']
except KeyError:
comp = None
if not comp:
self.log('Invalid get request without schema or component',
lvl=error)
return
se... | [
"Get",
"a",
"stored",
"configuration"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/configurator.py#L152-L176 | [
"def",
"get",
"(",
"self",
",",
"event",
")",
":",
"try",
":",
"comp",
"=",
"event",
".",
"data",
"[",
"'uuid'",
"]",
"except",
"KeyError",
":",
"comp",
"=",
"None",
"if",
"not",
"comp",
":",
"self",
".",
"log",
"(",
"'Invalid get request without schem... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | Manager.rec | Records a single snapshot | modules/camera/hfos/camera/manager.py | def rec(self):
"""Records a single snapshot"""
try:
self._snapshot()
except Exception as e:
self.log("Timer error: ", e, type(e), lvl=error) | def rec(self):
"""Records a single snapshot"""
try:
self._snapshot()
except Exception as e:
self.log("Timer error: ", e, type(e), lvl=error) | [
"Records",
"a",
"single",
"snapshot"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/camera/hfos/camera/manager.py#L99-L105 | [
"def",
"rec",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"_snapshot",
"(",
")",
"except",
"Exception",
"as",
"e",
":",
"self",
".",
"log",
"(",
"\"Timer error: \"",
",",
"e",
",",
"type",
"(",
"e",
")",
",",
"lvl",
"=",
"error",
")"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | Manager._toggle_filming | Toggles the camera system recording state | modules/camera/hfos/camera/manager.py | def _toggle_filming(self):
"""Toggles the camera system recording state"""
if self._filming:
self.log("Stopping operation")
self._filming = False
self.timer.stop()
else:
self.log("Starting operation")
self._filming = True
s... | def _toggle_filming(self):
"""Toggles the camera system recording state"""
if self._filming:
self.log("Stopping operation")
self._filming = False
self.timer.stop()
else:
self.log("Starting operation")
self._filming = True
s... | [
"Toggles",
"the",
"camera",
"system",
"recording",
"state"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/camera/hfos/camera/manager.py#L141-L151 | [
"def",
"_toggle_filming",
"(",
"self",
")",
":",
"if",
"self",
".",
"_filming",
":",
"self",
".",
"log",
"(",
"\"Stopping operation\"",
")",
"self",
".",
"_filming",
"=",
"False",
"self",
".",
"timer",
".",
"stop",
"(",
")",
"else",
":",
"self",
".",
... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | Manager.client_disconnect | A client has disconnected, update possible subscriptions accordingly.
:param event: | modules/camera/hfos/camera/manager.py | def client_disconnect(self, event):
"""
A client has disconnected, update possible subscriptions accordingly.
:param event:
"""
self.log("Removing disconnected client from subscriptions", lvl=debug)
client_uuid = event.clientuuid
self._unsubscribe(client_uuid) | def client_disconnect(self, event):
"""
A client has disconnected, update possible subscriptions accordingly.
:param event:
"""
self.log("Removing disconnected client from subscriptions", lvl=debug)
client_uuid = event.clientuuid
self._unsubscribe(client_uuid) | [
"A",
"client",
"has",
"disconnected",
"update",
"possible",
"subscriptions",
"accordingly",
"."
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/camera/hfos/camera/manager.py#L183-L191 | [
"def",
"client_disconnect",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"log",
"(",
"\"Removing disconnected client from subscriptions\"",
",",
"lvl",
"=",
"debug",
")",
"client_uuid",
"=",
"event",
".",
"clientuuid",
"self",
".",
"_unsubscribe",
"(",
"cli... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | ObjectManager.get | Get a specified object | hfos/ui/objectmanager.py | def get(self, event):
"""Get a specified object"""
try:
data, schema, user, client = self._get_args(event)
except AttributeError:
return
object_filter = self._get_filter(event)
if 'subscribe' in data:
do_subscribe = data['subscribe'] is True... | def get(self, event):
"""Get a specified object"""
try:
data, schema, user, client = self._get_args(event)
except AttributeError:
return
object_filter = self._get_filter(event)
if 'subscribe' in data:
do_subscribe = data['subscribe'] is True... | [
"Get",
"a",
"specified",
"object"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/objectmanager.py#L192-L254 | [
"def",
"get",
"(",
"self",
",",
"event",
")",
":",
"try",
":",
"data",
",",
"schema",
",",
"user",
",",
"client",
"=",
"self",
".",
"_get_args",
"(",
"event",
")",
"except",
"AttributeError",
":",
"return",
"object_filter",
"=",
"self",
".",
"_get_filt... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | ObjectManager.search | Search for an object | hfos/ui/objectmanager.py | def search(self, event):
"""Search for an object"""
try:
data, schema, user, client = self._get_args(event)
except AttributeError:
return
# object_filter['$text'] = {'$search': str(data['search'])}
if data.get('fulltext', False) is True:
obje... | def search(self, event):
"""Search for an object"""
try:
data, schema, user, client = self._get_args(event)
except AttributeError:
return
# object_filter['$text'] = {'$search': str(data['search'])}
if data.get('fulltext', False) is True:
obje... | [
"Search",
"for",
"an",
"object"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/objectmanager.py#L257-L371 | [
"def",
"search",
"(",
"self",
",",
"event",
")",
":",
"try",
":",
"data",
",",
"schema",
",",
"user",
",",
"client",
"=",
"self",
".",
"_get_args",
"(",
"event",
")",
"except",
"AttributeError",
":",
"return",
"# object_filter['$text'] = {'$search': str(data['... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | ObjectManager.objectlist | Get a list of objects | hfos/ui/objectmanager.py | def objectlist(self, event):
"""Get a list of objects"""
self.log('LEGACY LIST FUNCTION CALLED!', lvl=warn)
try:
data, schema, user, client = self._get_args(event)
except AttributeError:
return
object_filter = self._get_filter(event)
self.log('Ob... | def objectlist(self, event):
"""Get a list of objects"""
self.log('LEGACY LIST FUNCTION CALLED!', lvl=warn)
try:
data, schema, user, client = self._get_args(event)
except AttributeError:
return
object_filter = self._get_filter(event)
self.log('Ob... | [
"Get",
"a",
"list",
"of",
"objects"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/objectmanager.py#L374-L441 | [
"def",
"objectlist",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"log",
"(",
"'LEGACY LIST FUNCTION CALLED!'",
",",
"lvl",
"=",
"warn",
")",
"try",
":",
"data",
",",
"schema",
",",
"user",
",",
"client",
"=",
"self",
".",
"_get_args",
"(",
"event... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | ObjectManager.change | Change an existing object | hfos/ui/objectmanager.py | def change(self, event):
"""Change an existing object"""
try:
data, schema, user, client = self._get_args(event)
except AttributeError:
return
try:
uuid = data['uuid']
change = data['change']
field = change['field']
... | def change(self, event):
"""Change an existing object"""
try:
data, schema, user, client = self._get_args(event)
except AttributeError:
return
try:
uuid = data['uuid']
change = data['change']
field = change['field']
... | [
"Change",
"an",
"existing",
"object"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/objectmanager.py#L444-L503 | [
"def",
"change",
"(",
"self",
",",
"event",
")",
":",
"try",
":",
"data",
",",
"schema",
",",
"user",
",",
"client",
"=",
"self",
".",
"_get_args",
"(",
"event",
")",
"except",
"AttributeError",
":",
"return",
"try",
":",
"uuid",
"=",
"data",
"[",
... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | ObjectManager.put | Put an object | hfos/ui/objectmanager.py | def put(self, event):
"""Put an object"""
try:
data, schema, user, client = self._get_args(event)
except AttributeError:
return
try:
clientobject = data['obj']
uuid = clientobject['uuid']
except KeyError as e:
self.log... | def put(self, event):
"""Put an object"""
try:
data, schema, user, client = self._get_args(event)
except AttributeError:
return
try:
clientobject = data['obj']
uuid = clientobject['uuid']
except KeyError as e:
self.log... | [
"Put",
"an",
"object"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/objectmanager.py#L506-L592 | [
"def",
"put",
"(",
"self",
",",
"event",
")",
":",
"try",
":",
"data",
",",
"schema",
",",
"user",
",",
"client",
"=",
"self",
".",
"_get_args",
"(",
"event",
")",
"except",
"AttributeError",
":",
"return",
"try",
":",
"clientobject",
"=",
"data",
"[... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | ObjectManager.delete | Delete an existing object | hfos/ui/objectmanager.py | def delete(self, event):
"""Delete an existing object"""
try:
data, schema, user, client = self._get_args(event)
except AttributeError:
return
try:
uuids = data['uuid']
if not isinstance(uuids, list):
uuids = [uuids]
... | def delete(self, event):
"""Delete an existing object"""
try:
data, schema, user, client = self._get_args(event)
except AttributeError:
return
try:
uuids = data['uuid']
if not isinstance(uuids, list):
uuids = [uuids]
... | [
"Delete",
"an",
"existing",
"object"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/objectmanager.py#L595-L662 | [
"def",
"delete",
"(",
"self",
",",
"event",
")",
":",
"try",
":",
"data",
",",
"schema",
",",
"user",
",",
"client",
"=",
"self",
".",
"_get_args",
"(",
"event",
")",
"except",
"AttributeError",
":",
"return",
"try",
":",
"uuids",
"=",
"data",
"[",
... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | ObjectManager.subscribe | Subscribe to an object's future changes | hfos/ui/objectmanager.py | def subscribe(self, event):
"""Subscribe to an object's future changes"""
uuids = event.data
if not isinstance(uuids, list):
uuids = [uuids]
subscribed = []
for uuid in uuids:
try:
self._add_subscription(uuid, event)
subsc... | def subscribe(self, event):
"""Subscribe to an object's future changes"""
uuids = event.data
if not isinstance(uuids, list):
uuids = [uuids]
subscribed = []
for uuid in uuids:
try:
self._add_subscription(uuid, event)
subsc... | [
"Subscribe",
"to",
"an",
"object",
"s",
"future",
"changes"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/objectmanager.py#L665-L687 | [
"def",
"subscribe",
"(",
"self",
",",
"event",
")",
":",
"uuids",
"=",
"event",
".",
"data",
"if",
"not",
"isinstance",
"(",
"uuids",
",",
"list",
")",
":",
"uuids",
"=",
"[",
"uuids",
"]",
"subscribed",
"=",
"[",
"]",
"for",
"uuid",
"in",
"uuids",... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | ObjectManager.unsubscribe | Unsubscribe from an object's future changes | hfos/ui/objectmanager.py | def unsubscribe(self, event):
"""Unsubscribe from an object's future changes"""
# TODO: Automatic Unsubscription
uuids = event.data
if not isinstance(uuids, list):
uuids = [uuids]
result = []
for uuid in uuids:
if uuid in self.subscriptions:
... | def unsubscribe(self, event):
"""Unsubscribe from an object's future changes"""
# TODO: Automatic Unsubscription
uuids = event.data
if not isinstance(uuids, list):
uuids = [uuids]
result = []
for uuid in uuids:
if uuid in self.subscriptions:
... | [
"Unsubscribe",
"from",
"an",
"object",
"s",
"future",
"changes"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/objectmanager.py#L698-L725 | [
"def",
"unsubscribe",
"(",
"self",
",",
"event",
")",
":",
"# TODO: Automatic Unsubscription",
"uuids",
"=",
"event",
".",
"data",
"if",
"not",
"isinstance",
"(",
"uuids",
",",
"list",
")",
":",
"uuids",
"=",
"[",
"uuids",
"]",
"result",
"=",
"[",
"]",
... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | ObjectManager.update_subscriptions | OM event handler for to be stored and client shared objectmodels
:param event: OMRequest with uuid, schema and object data | hfos/ui/objectmanager.py | def update_subscriptions(self, event):
"""OM event handler for to be stored and client shared objectmodels
:param event: OMRequest with uuid, schema and object data
"""
# self.log("Event: '%s'" % event.__dict__)
try:
self._update_subscribers(event.schema, event.data)... | def update_subscriptions(self, event):
"""OM event handler for to be stored and client shared objectmodels
:param event: OMRequest with uuid, schema and object data
"""
# self.log("Event: '%s'" % event.__dict__)
try:
self._update_subscribers(event.schema, event.data)... | [
"OM",
"event",
"handler",
"for",
"to",
"be",
"stored",
"and",
"client",
"shared",
"objectmodels",
":",
"param",
"event",
":",
"OMRequest",
"with",
"uuid",
"schema",
"and",
"object",
"data"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/objectmanager.py#L728-L739 | [
"def",
"update_subscriptions",
"(",
"self",
",",
"event",
")",
":",
"# self.log(\"Event: '%s'\" % event.__dict__)",
"try",
":",
"self",
".",
"_update_subscribers",
"(",
"event",
".",
"schema",
",",
"event",
".",
"data",
")",
"except",
"Exception",
"as",
"e",
":"... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | GithubImporter | Project Importer for Github Repository Issues
Argument REPOSITORY must be given as 'username/repository'
Owner and project have to be UUIDs | modules/project/hfos/project/importer/github.py | def GithubImporter(ctx, repository, all, owner, project, ignore_labels, no_tags, username, password):
"""Project Importer for Github Repository Issues
Argument REPOSITORY must be given as 'username/repository'
Owner and project have to be UUIDs
"""
db = ctx.obj['db']
if project is not None:
... | def GithubImporter(ctx, repository, all, owner, project, ignore_labels, no_tags, username, password):
"""Project Importer for Github Repository Issues
Argument REPOSITORY must be given as 'username/repository'
Owner and project have to be UUIDs
"""
db = ctx.obj['db']
if project is not None:
... | [
"Project",
"Importer",
"for",
"Github",
"Repository",
"Issues"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/project/hfos/project/importer/github.py#L29-L140 | [
"def",
"GithubImporter",
"(",
"ctx",
",",
"repository",
",",
"all",
",",
"owner",
",",
"project",
",",
"ignore_labels",
",",
"no_tags",
",",
"username",
",",
"password",
")",
":",
"db",
"=",
"ctx",
".",
"obj",
"[",
"'db'",
"]",
"if",
"project",
"is",
... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | all_languages | Compile a list of all available language translations | hfos/misc/__init__.py | def all_languages():
"""Compile a list of all available language translations"""
rv = []
for lang in os.listdir(localedir):
base = lang.split('_')[0].split('.')[0].split('@')[0]
if 2 <= len(base) <= 3 and all(c.islower() for c in base):
if base != 'all':
rv.appe... | def all_languages():
"""Compile a list of all available language translations"""
rv = []
for lang in os.listdir(localedir):
base = lang.split('_')[0].split('.')[0].split('@')[0]
if 2 <= len(base) <= 3 and all(c.islower() for c in base):
if base != 'all':
rv.appe... | [
"Compile",
"a",
"list",
"of",
"all",
"available",
"language",
"translations"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/misc/__init__.py#L24-L38 | [
"def",
"all_languages",
"(",
")",
":",
"rv",
"=",
"[",
"]",
"for",
"lang",
"in",
"os",
".",
"listdir",
"(",
"localedir",
")",
":",
"base",
"=",
"lang",
".",
"split",
"(",
"'_'",
")",
"[",
"0",
"]",
".",
"split",
"(",
"'.'",
")",
"[",
"0",
"]"... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | language_token_to_name | Get a descriptive title for all languages | hfos/misc/__init__.py | def language_token_to_name(languages):
"""Get a descriptive title for all languages"""
result = {}
with open(os.path.join(localedir, 'languages.json'), 'r') as f:
language_lookup = json.load(f)
for language in languages:
language = language.lower()
try:
result[lang... | def language_token_to_name(languages):
"""Get a descriptive title for all languages"""
result = {}
with open(os.path.join(localedir, 'languages.json'), 'r') as f:
language_lookup = json.load(f)
for language in languages:
language = language.lower()
try:
result[lang... | [
"Get",
"a",
"descriptive",
"title",
"for",
"all",
"languages"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/misc/__init__.py#L41-L57 | [
"def",
"language_token_to_name",
"(",
"languages",
")",
":",
"result",
"=",
"{",
"}",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"localedir",
",",
"'languages.json'",
")",
",",
"'r'",
")",
"as",
"f",
":",
"language_lookup",
"=",
"json",
... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | print_messages | Debugging function to print all message language variants | hfos/misc/__init__.py | def print_messages(domain, msg):
"""Debugging function to print all message language variants"""
domain = Domain(domain)
for lang in all_languages():
print(lang, ':', domain.get(lang, msg)) | def print_messages(domain, msg):
"""Debugging function to print all message language variants"""
domain = Domain(domain)
for lang in all_languages():
print(lang, ':', domain.get(lang, msg)) | [
"Debugging",
"function",
"to",
"print",
"all",
"message",
"language",
"variants"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/misc/__init__.py#L84-L89 | [
"def",
"print_messages",
"(",
"domain",
",",
"msg",
")",
":",
"domain",
"=",
"Domain",
"(",
"domain",
")",
"for",
"lang",
"in",
"all_languages",
"(",
")",
":",
"print",
"(",
"lang",
",",
"':'",
",",
"domain",
".",
"get",
"(",
"lang",
",",
"msg",
")... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | i18n | 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. | hfos/misc/__init__.py | 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'):
"""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... | [
"Gettext",
"function",
"wrapper",
"to",
"return",
"a",
"message",
"in",
"a",
"specified",
"language",
"by",
"domain"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/misc/__init__.py#L92-L104 | [
"def",
"i18n",
"(",
"msg",
",",
"event",
"=",
"None",
",",
"lang",
"=",
"'en'",
",",
"domain",
"=",
"'backend'",
")",
":",
"if",
"event",
"is",
"not",
"None",
":",
"language",
"=",
"event",
".",
"client",
".",
"language",
"else",
":",
"language",
"... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | std_hash | Generates a cryptographically strong (sha512) hash with this nodes
salt added. | hfos/misc/__init__.py | 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):
"""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(... | [
"Generates",
"a",
"cryptographically",
"strong",
"(",
"sha512",
")",
"hash",
"with",
"this",
"nodes",
"salt",
"added",
"."
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/misc/__init__.py#L107-L120 | [
"def",
"std_hash",
"(",
"word",
",",
"salt",
")",
":",
"try",
":",
"password",
"=",
"word",
".",
"encode",
"(",
"'utf-8'",
")",
"except",
"UnicodeDecodeError",
":",
"password",
"=",
"word",
"word_hash",
"=",
"sha512",
"(",
"password",
")",
"word_hash",
"... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | std_human_uid | Return a random generated human-friendly phrase as low-probability unique id | hfos/misc/__init__.py | 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):
"""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(
... | [
"Return",
"a",
"random",
"generated",
"human",
"-",
"friendly",
"phrase",
"as",
"low",
"-",
"probability",
"unique",
"id"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/misc/__init__.py#L242-L259 | [
"def",
"std_human_uid",
"(",
"kind",
"=",
"None",
")",
":",
"kind_list",
"=",
"alphabet",
"if",
"kind",
"==",
"'animal'",
":",
"kind_list",
"=",
"animals",
"elif",
"kind",
"==",
"'place'",
":",
"kind_list",
"=",
"places",
"name",
"=",
"\"{color} {adjective} ... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | std_table | Return a formatted table of given rows | hfos/misc/__init__.py | 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):
"""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... | [
"Return",
"a",
"formatted",
"table",
"of",
"given",
"rows"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/misc/__init__.py#L262-L294 | [
"def",
"std_table",
"(",
"rows",
")",
":",
"result",
"=",
"\"\"",
"if",
"len",
"(",
"rows",
")",
">",
"1",
":",
"headers",
"=",
"rows",
"[",
"0",
"]",
".",
"_fields",
"lens",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"rows",
... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | std_salt | Generates a cryptographically sane salt of 'length' (default: 16) alphanumeric
characters | hfos/misc/__init__.py | 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):
"""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... | [
"Generates",
"a",
"cryptographically",
"sane",
"salt",
"of",
"length",
"(",
"default",
":",
"16",
")",
"alphanumeric",
"characters"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/misc/__init__.py#L297-L310 | [
"def",
"std_salt",
"(",
"length",
"=",
"16",
",",
"lowercase",
"=",
"True",
")",
":",
"alphabet",
"=",
"\"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\"",
"if",
"lowercase",
"is",
"True",
":",
"alphabet",
"+=",
"\"abcdefghijklmnopqrstuvwxyz\"",
"chars",
"=",
"[",
"]",
"... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | Domain._get_translation | Add a new translation language to the live gettext translator | hfos/misc/__init__.py | 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):
"""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... | [
"Add",
"a",
"new",
"translation",
"language",
"to",
"the",
"live",
"gettext",
"translator"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/misc/__init__.py#L67-L76 | [
"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",
".",
"_... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | handler | 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... | hfos/component.py | 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):
"""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... | [
"Creates",
"an",
"Event",
"Handler"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/component.py#L64-L145 | [
"def",
"handler",
"(",
"*",
"names",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"wrapper",
"(",
"f",
")",
":",
"if",
"names",
"and",
"isinstance",
"(",
"names",
"[",
"0",
"]",
",",
"bool",
")",
"and",
"not",
"names",
"[",
"0",
"]",
":",
"f",
"... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | LoggingMeta.log | Log a statement from this component | hfos/component.py | 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):
"""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()
... | [
"Log",
"a",
"statement",
"from",
"this",
"component"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/component.py#L175-L194 | [
"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",
... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | ConfigurableMeta.register | Register a configurable component in the configuration schema
store | hfos/component.py | 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):
"""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... | [
"Register",
"a",
"configurable",
"component",
"in",
"the",
"configuration",
"schema",
"store"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/component.py#L240-L248 | [
"def",
"register",
"(",
"self",
",",
"*",
"args",
")",
":",
"super",
"(",
"ConfigurableMeta",
",",
"self",
")",
".",
"register",
"(",
"*",
"args",
")",
"from",
"hfos",
".",
"database",
"import",
"configschemastore",
"# self.log('ADDING SCHEMA:')",
"# pprint(se... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | ConfigurableMeta.unregister | Removes the unique name from the systems unique name list | hfos/component.py | 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):
"""Removes the unique name from the systems unique name list"""
self.names.remove(self.uniquename)
super(ConfigurableMeta, self).unregister() | [
"Removes",
"the",
"unique",
"name",
"from",
"the",
"systems",
"unique",
"name",
"list"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/component.py#L250-L253 | [
"def",
"unregister",
"(",
"self",
")",
":",
"self",
".",
"names",
".",
"remove",
"(",
"self",
".",
"uniquename",
")",
"super",
"(",
"ConfigurableMeta",
",",
"self",
")",
".",
"unregister",
"(",
")"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | ConfigurableMeta._read_config | Read this component's configuration from the database | hfos/component.py | 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):
"""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 ... | [
"Read",
"this",
"component",
"s",
"configuration",
"from",
"the",
"database"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/component.py#L255-L267 | [
"def",
"_read_config",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"config",
"=",
"self",
".",
"componentmodel",
".",
"find_one",
"(",
"{",
"'name'",
":",
"self",
".",
"uniquename",
"}",
")",
"except",
"ServerSelectionTimeoutError",
":",
"# pragma: no co... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | ConfigurableMeta._write_config | Write this component's configuration back to the database | hfos/component.py | 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):
"""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.") | [
"Write",
"this",
"component",
"s",
"configuration",
"back",
"to",
"the",
"database"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/component.py#L270-L278 | [
"def",
"_write_config",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"config",
":",
"self",
".",
"log",
"(",
"\"Unable to write non existing configuration\"",
",",
"lvl",
"=",
"error",
")",
"return",
"self",
".",
"config",
".",
"save",
"(",
")",
"self"... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | ConfigurableMeta._set_config | Set this component's initial configuration | hfos/component.py | 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):
"""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... | [
"Set",
"this",
"component",
"s",
"initial",
"configuration"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/component.py#L280-L336 | [
"def",
"_set_config",
"(",
"self",
",",
"config",
"=",
"None",
")",
":",
"if",
"not",
"config",
":",
"config",
"=",
"{",
"}",
"try",
":",
"# pprint(self.configschema)",
"self",
".",
"config",
"=",
"self",
".",
"componentmodel",
"(",
"config",
")",
"# sel... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | ConfigurableMeta.reload_configuration | Event triggered configuration reload | hfos/component.py | 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):
"""Event triggered configuration reload"""
if event.target == self.uniquename:
self.log('Reloading configuration')
self._read_config() | [
"Event",
"triggered",
"configuration",
"reload"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/component.py#L341-L346 | [
"def",
"reload_configuration",
"(",
"self",
",",
"event",
")",
":",
"if",
"event",
".",
"target",
"==",
"self",
".",
"uniquename",
":",
"self",
".",
"log",
"(",
"'Reloading configuration'",
")",
"self",
".",
"_read_config",
"(",
")"
] | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | _augment_info | Fill out the template information | hfos/tool/create_module.py | 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):
"""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... | [
"Fill",
"out",
"the",
"template",
"information"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/create_module.py#L89-L106 | [
"def",
"_augment_info",
"(",
"info",
")",
":",
"info",
"[",
"'description_header'",
"]",
"=",
"\"=\"",
"*",
"len",
"(",
"info",
"[",
"'description'",
"]",
")",
"info",
"[",
"'component_name'",
"]",
"=",
"info",
"[",
"'plugin_name'",
"]",
".",
"capitalize",... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | _construct_module | Build a module from templates and user supplied information | hfos/tool/create_module.py | 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):
"""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... | [
"Build",
"a",
"module",
"from",
"templates",
"and",
"user",
"supplied",
"information"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/create_module.py#L109-L124 | [
"def",
"_construct_module",
"(",
"info",
",",
"target",
")",
":",
"for",
"path",
"in",
"paths",
":",
"real_path",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"target",
",",
"path",
".",
"format",
"(",
"*",
"*",... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | _ask_questionnaire | Asks questions to fill out a HFOS plugin template | hfos/tool/create_module.py | 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():
"""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... | [
"Asks",
"questions",
"to",
"fill",
"out",
"a",
"HFOS",
"plugin",
"template"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/create_module.py#L127-L140 | [
"def",
"_ask_questionnaire",
"(",
")",
":",
"answers",
"=",
"{",
"}",
"print",
"(",
"info_header",
")",
"pprint",
"(",
"questions",
".",
"items",
"(",
")",
")",
"for",
"question",
",",
"default",
"in",
"questions",
".",
"items",
"(",
")",
":",
"respons... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | create_module | Creates a new template HFOS plugin module | hfos/tool/create_module.py | 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):
"""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... | [
"Creates",
"a",
"new",
"template",
"HFOS",
"plugin",
"module"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/create_module.py#L148-L170 | [
"def",
"create_module",
"(",
"clear_target",
",",
"target",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"target",
")",
":",
"if",
"clear_target",
":",
"shutil",
".",
"rmtree",
"(",
"target",
")",
"else",
":",
"log",
"(",
"\"Target exists! Use ... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | lookup_field | Generates a lookup field for form definitions | hfos/schemata/defaultform.py | 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"):
"""Generates a lookup field for form definitions"""
if lookup_type is None:
lookup_type = key
if placeholder is None:
placeholder = "Select a " + lookup_... | [
"Generates",
"a",
"lookup",
"field",
"for",
"form",
"definitions"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/schemata/defaultform.py#L92-L114 | [
"def",
"lookup_field",
"(",
"key",
",",
"lookup_type",
"=",
"None",
",",
"placeholder",
"=",
"None",
",",
"html_class",
"=",
"\"div\"",
",",
"select_type",
"=",
"\"strapselect\"",
",",
"mapping",
"=",
"\"uuid\"",
")",
":",
"if",
"lookup_type",
"is",
"None",
... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | fieldset | A field set with a title and sub items | hfos/schemata/defaultform.py | 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):
"""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 | [
"A",
"field",
"set",
"with",
"a",
"title",
"and",
"sub",
"items"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/schemata/defaultform.py#L117-L127 | [
"def",
"fieldset",
"(",
"title",
",",
"items",
",",
"options",
"=",
"None",
")",
":",
"result",
"=",
"{",
"'title'",
":",
"title",
",",
"'type'",
":",
"'fieldset'",
",",
"'items'",
":",
"items",
"}",
"if",
"options",
"is",
"not",
"None",
":",
"result... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | section | A section consisting of rows and columns | hfos/schemata/defaultform.py | 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):
"""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):
... | [
"A",
"section",
"consisting",
"of",
"rows",
"and",
"columns"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/schemata/defaultform.py#L130-L162 | [
"def",
"section",
"(",
"rows",
",",
"columns",
",",
"items",
",",
"label",
"=",
"None",
")",
":",
"# TODO: Integrate label",
"sections",
"=",
"[",
"]",
"column_class",
"=",
"\"section-column col-sm-%i\"",
"%",
"(",
"12",
"/",
"columns",
")",
"for",
"vertical... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | emptyArray | An array that starts empty | hfos/schemata/defaultform.py | 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):
"""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 | [
"An",
"array",
"that",
"starts",
"empty"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/schemata/defaultform.py#L165-L175 | [
"def",
"emptyArray",
"(",
"key",
",",
"add_label",
"=",
"None",
")",
":",
"result",
"=",
"{",
"'key'",
":",
"key",
",",
"'startEmpty'",
":",
"True",
"}",
"if",
"add_label",
"is",
"not",
"None",
":",
"result",
"[",
"'add'",
"]",
"=",
"add_label",
"res... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | tabset | A tabbed container widget | hfos/schemata/defaultform.py | 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):
"""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'] = ... | [
"A",
"tabbed",
"container",
"widget"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/schemata/defaultform.py#L178-L198 | [
"def",
"tabset",
"(",
"titles",
",",
"contents",
")",
":",
"tabs",
"=",
"[",
"]",
"for",
"no",
",",
"title",
"in",
"enumerate",
"(",
"titles",
")",
":",
"tab",
"=",
"{",
"'title'",
":",
"title",
",",
"}",
"content",
"=",
"contents",
"[",
"no",
"]... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
train | country_field | Provides a select box for country selection | hfos/schemata/defaultform.py | 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'):
"""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... | [
"Provides",
"a",
"select",
"box",
"for",
"country",
"selection"
] | Hackerfleet/hfos | python | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/schemata/defaultform.py#L238-L252 | [
"def",
"country_field",
"(",
"key",
"=",
"'country'",
")",
":",
"country_list",
"=",
"list",
"(",
"countries",
")",
"title_map",
"=",
"[",
"]",
"for",
"item",
"in",
"country_list",
":",
"title_map",
".",
"append",
"(",
"{",
"'value'",
":",
"item",
".",
... | b6df14eacaffb6be5c844108873ff8763ec7f0c9 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.