repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
Hackerfleet/hfos | hfos/tool/rbac.py | change_owner | 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)
... | python | 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",
")",
":",
"objects",
"=",
"ctx",
".",
"obj",
"[",
"'objects'",
"]",
"database",
"=",
"ctx",
".",
"obj",
"[",
"'db'",
"]",
"if",
"uuid",
"is",
"True",
":",
"owner_filter",
"=",
"{",
"'uui... | Changes the ownership of objects | [
"Changes",
"the",
"ownership",
"of",
"objects"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/rbac.py#L122-L142 |
Hackerfleet/hfos | modules/notifications/hfos/notifications/notificationmanager.py | NotificationManager.notify | def notify(self, event):
"""Notify a user"""
self.log('Got a notification event!')
self.log(event, pretty=True)
self.log(event.__dict__) | python | 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",
")",
":",
"self",
".",
"log",
"(",
"'Got a notification event!'",
")",
"self",
".",
"log",
"(",
"event",
",",
"pretty",
"=",
"True",
")",
"self",
".",
"log",
"(",
"event",
".",
"__dict__",
")"
] | Notify a user | [
"Notify",
"a",
"user"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/notifications/hfos/notifications/notificationmanager.py#L64-L70 |
Hackerfleet/hfos | modules/robot/hfos/robot/rcmanager.py | RemoteControlManager.clientdisconnect | 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... | python | 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",
")",
":",
"try",
":",
"if",
"event",
".",
"clientuuid",
"==",
"self",
".",
"remote_controller",
":",
"self",
".",
"log",
"(",
"\"Remote controller disconnected!\"",
",",
"lvl",
"=",
"critical",
")",
"self... | Handler to deal with a possibly disconnected remote controlling
client
:param event: ClientDisconnect Event | [
"Handler",
"to",
"deal",
"with",
"a",
"possibly",
"disconnected",
"remote",
"controlling",
"client",
":",
"param",
"event",
":",
"ClientDisconnect",
"Event"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/robot/hfos/robot/rcmanager.py#L75-L86 |
Hackerfleet/hfos | hfos/ui/configurator.py | Configurator.getlist | def getlist(self, event):
"""Processes configuration list requests
:param event:
"""
try:
componentlist = model_factory(Schema).find({})
data = []
for comp in componentlist:
try:
data.append({
... | python | 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",
")",
":",
"try",
":",
"componentlist",
"=",
"model_factory",
"(",
"Schema",
")",
".",
"find",
"(",
"{",
"}",
")",
"data",
"=",
"[",
"]",
"for",
"comp",
"in",
"componentlist",
":",
"try",
":",
"data",
"."... | Processes configuration list requests
:param event: | [
"Processes",
"configuration",
"list",
"requests"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/configurator.py#L81-L113 |
Hackerfleet/hfos | hfos/ui/configurator.py | Configurator.put | 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)
... | python | 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",
")",
":",
"self",
".",
"log",
"(",
"\"Configuration put request \"",
",",
"event",
".",
"user",
")",
"try",
":",
"component",
"=",
"model_factory",
"(",
"Schema",
")",
".",
"find_one",
"(",
"{",
"'uuid'",
":",
"... | Store a given configuration | [
"Store",
"a",
"given",
"configuration"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/configurator.py#L116-L149 |
Hackerfleet/hfos | hfos/ui/configurator.py | Configurator.get | 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... | python | 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",
")",
":",
"try",
":",
"comp",
"=",
"event",
".",
"data",
"[",
"'uuid'",
"]",
"except",
"KeyError",
":",
"comp",
"=",
"None",
"if",
"not",
"comp",
":",
"self",
".",
"log",
"(",
"'Invalid get request without schem... | Get a stored configuration | [
"Get",
"a",
"stored",
"configuration"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/configurator.py#L152-L176 |
Hackerfleet/hfos | modules/camera/hfos/camera/manager.py | Manager.rec | def rec(self):
"""Records a single snapshot"""
try:
self._snapshot()
except Exception as e:
self.log("Timer error: ", e, type(e), lvl=error) | python | 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",
")",
":",
"try",
":",
"self",
".",
"_snapshot",
"(",
")",
"except",
"Exception",
"as",
"e",
":",
"self",
".",
"log",
"(",
"\"Timer error: \"",
",",
"e",
",",
"type",
"(",
"e",
")",
",",
"lvl",
"=",
"error",
")"
] | Records a single snapshot | [
"Records",
"a",
"single",
"snapshot"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/camera/hfos/camera/manager.py#L99-L105 |
Hackerfleet/hfos | modules/camera/hfos/camera/manager.py | Manager._toggle_filming | 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... | python | 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",
")",
":",
"if",
"self",
".",
"_filming",
":",
"self",
".",
"log",
"(",
"\"Stopping operation\"",
")",
"self",
".",
"_filming",
"=",
"False",
"self",
".",
"timer",
".",
"stop",
"(",
")",
"else",
":",
"self",
".",
... | Toggles the camera system recording state | [
"Toggles",
"the",
"camera",
"system",
"recording",
"state"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/camera/hfos/camera/manager.py#L141-L151 |
Hackerfleet/hfos | modules/camera/hfos/camera/manager.py | Manager.client_disconnect | 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) | python | 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",
")",
":",
"self",
".",
"log",
"(",
"\"Removing disconnected client from subscriptions\"",
",",
"lvl",
"=",
"debug",
")",
"client_uuid",
"=",
"event",
".",
"clientuuid",
"self",
".",
"_unsubscribe",
"(",
"cli... | A client has disconnected, update possible subscriptions accordingly.
:param event: | [
"A",
"client",
"has",
"disconnected",
"update",
"possible",
"subscriptions",
"accordingly",
"."
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/camera/hfos/camera/manager.py#L183-L191 |
Hackerfleet/hfos | hfos/ui/objectmanager.py | ObjectManager.get | 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... | python | 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",
")",
":",
"try",
":",
"data",
",",
"schema",
",",
"user",
",",
"client",
"=",
"self",
".",
"_get_args",
"(",
"event",
")",
"except",
"AttributeError",
":",
"return",
"object_filter",
"=",
"self",
".",
"_get_filt... | Get a specified object | [
"Get",
"a",
"specified",
"object"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/objectmanager.py#L192-L254 |
Hackerfleet/hfos | hfos/ui/objectmanager.py | ObjectManager.search | 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... | python | 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",
")",
":",
"try",
":",
"data",
",",
"schema",
",",
"user",
",",
"client",
"=",
"self",
".",
"_get_args",
"(",
"event",
")",
"except",
"AttributeError",
":",
"return",
"# object_filter['$text'] = {'$search': str(data['... | Search for an object | [
"Search",
"for",
"an",
"object"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/objectmanager.py#L257-L371 |
Hackerfleet/hfos | hfos/ui/objectmanager.py | ObjectManager.objectlist | 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... | python | 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",
")",
":",
"self",
".",
"log",
"(",
"'LEGACY LIST FUNCTION CALLED!'",
",",
"lvl",
"=",
"warn",
")",
"try",
":",
"data",
",",
"schema",
",",
"user",
",",
"client",
"=",
"self",
".",
"_get_args",
"(",
"event... | Get a list of objects | [
"Get",
"a",
"list",
"of",
"objects"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/objectmanager.py#L374-L441 |
Hackerfleet/hfos | hfos/ui/objectmanager.py | ObjectManager.change | 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']
... | python | 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",
")",
":",
"try",
":",
"data",
",",
"schema",
",",
"user",
",",
"client",
"=",
"self",
".",
"_get_args",
"(",
"event",
")",
"except",
"AttributeError",
":",
"return",
"try",
":",
"uuid",
"=",
"data",
"[",
... | Change an existing object | [
"Change",
"an",
"existing",
"object"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/objectmanager.py#L444-L503 |
Hackerfleet/hfos | hfos/ui/objectmanager.py | ObjectManager.put | 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... | python | 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",
")",
":",
"try",
":",
"data",
",",
"schema",
",",
"user",
",",
"client",
"=",
"self",
".",
"_get_args",
"(",
"event",
")",
"except",
"AttributeError",
":",
"return",
"try",
":",
"clientobject",
"=",
"data",
"[... | Put an object | [
"Put",
"an",
"object"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/objectmanager.py#L506-L592 |
Hackerfleet/hfos | hfos/ui/objectmanager.py | ObjectManager.delete | 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]
... | python | 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",
")",
":",
"try",
":",
"data",
",",
"schema",
",",
"user",
",",
"client",
"=",
"self",
".",
"_get_args",
"(",
"event",
")",
"except",
"AttributeError",
":",
"return",
"try",
":",
"uuids",
"=",
"data",
"[",
... | Delete an existing object | [
"Delete",
"an",
"existing",
"object"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/objectmanager.py#L595-L662 |
Hackerfleet/hfos | hfos/ui/objectmanager.py | ObjectManager.subscribe | 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... | python | 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",
")",
":",
"uuids",
"=",
"event",
".",
"data",
"if",
"not",
"isinstance",
"(",
"uuids",
",",
"list",
")",
":",
"uuids",
"=",
"[",
"uuids",
"]",
"subscribed",
"=",
"[",
"]",
"for",
"uuid",
"in",
"uuids",... | Subscribe to an object's future changes | [
"Subscribe",
"to",
"an",
"object",
"s",
"future",
"changes"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/objectmanager.py#L665-L687 |
Hackerfleet/hfos | hfos/ui/objectmanager.py | ObjectManager.unsubscribe | 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:
... | python | 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",
")",
":",
"# TODO: Automatic Unsubscription",
"uuids",
"=",
"event",
".",
"data",
"if",
"not",
"isinstance",
"(",
"uuids",
",",
"list",
")",
":",
"uuids",
"=",
"[",
"uuids",
"]",
"result",
"=",
"[",
"]",
... | Unsubscribe from an object's future changes | [
"Unsubscribe",
"from",
"an",
"object",
"s",
"future",
"changes"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/objectmanager.py#L698-L725 |
Hackerfleet/hfos | hfos/ui/objectmanager.py | ObjectManager.update_subscriptions | 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)... | python | 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",
")",
":",
"# self.log(\"Event: '%s'\" % event.__dict__)",
"try",
":",
"self",
".",
"_update_subscribers",
"(",
"event",
".",
"schema",
",",
"event",
".",
"data",
")",
"except",
"Exception",
"as",
"e",
":"... | OM event handler for to be stored and client shared objectmodels
:param event: OMRequest with uuid, schema and object data | [
"OM",
"event",
"handler",
"for",
"to",
"be",
"stored",
"and",
"client",
"shared",
"objectmodels",
":",
"param",
"event",
":",
"OMRequest",
"with",
"uuid",
"schema",
"and",
"object",
"data"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/objectmanager.py#L728-L739 |
Hackerfleet/hfos | modules/project/hfos/project/importer/github.py | GithubImporter | 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:
... | python | 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",
")",
":",
"db",
"=",
"ctx",
".",
"obj",
"[",
"'db'",
"]",
"if",
"project",
"is",
... | Project Importer for Github Repository Issues
Argument REPOSITORY must be given as 'username/repository'
Owner and project have to be UUIDs | [
"Project",
"Importer",
"for",
"Github",
"Repository",
"Issues"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/project/hfos/project/importer/github.py#L29-L140 |
Hackerfleet/hfos | hfos/misc/__init__.py | all_languages | 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... | python | 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",
"(",
")",
":",
"rv",
"=",
"[",
"]",
"for",
"lang",
"in",
"os",
".",
"listdir",
"(",
"localedir",
")",
":",
"base",
"=",
"lang",
".",
"split",
"(",
"'_'",
")",
"[",
"0",
"]",
".",
"split",
"(",
"'.'",
")",
"[",
"0",
"]"... | Compile a list of all available language translations | [
"Compile",
"a",
"list",
"of",
"all",
"available",
"language",
"translations"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/misc/__init__.py#L24-L38 |
Hackerfleet/hfos | hfos/misc/__init__.py | language_token_to_name | 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... | python | 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",
")",
":",
"result",
"=",
"{",
"}",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"localedir",
",",
"'languages.json'",
")",
",",
"'r'",
")",
"as",
"f",
":",
"language_lookup",
"=",
"json",
... | Get a descriptive title for all languages | [
"Get",
"a",
"descriptive",
"title",
"for",
"all",
"languages"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/misc/__init__.py#L41-L57 |
Hackerfleet/hfos | hfos/misc/__init__.py | print_messages | 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)) | python | 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",
")",
":",
"domain",
"=",
"Domain",
"(",
"domain",
")",
"for",
"lang",
"in",
"all_languages",
"(",
")",
":",
"print",
"(",
"lang",
",",
"':'",
",",
"domain",
".",
"get",
"(",
"lang",
",",
"msg",
")... | Debugging function to print all message language variants | [
"Debugging",
"function",
"to",
"print",
"all",
"message",
"language",
"variants"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/misc/__init__.py#L84-L89 |
Hackerfleet/hfos | hfos/misc/__init__.py | i18n | def i18n(msg, event=None, lang='en', domain='backend'):
"""Gettext function wrapper to return a message in a specified language by domain
To use internationalization (i18n) on your messages, import it as '_' and use as usual.
Do not forget to supply the client's language setting."""
if event is not No... | python | def i18n(msg, event=None, lang='en', domain='backend'):
"""Gettext function wrapper to return a message in a specified language by domain
To use internationalization (i18n) on your messages, import it as '_' and use as usual.
Do not forget to supply the client's language setting."""
if event is not No... | [
"def",
"i18n",
"(",
"msg",
",",
"event",
"=",
"None",
",",
"lang",
"=",
"'en'",
",",
"domain",
"=",
"'backend'",
")",
":",
"if",
"event",
"is",
"not",
"None",
":",
"language",
"=",
"event",
".",
"client",
".",
"language",
"else",
":",
"language",
"... | Gettext function wrapper to return a message in a specified language by domain
To use internationalization (i18n) on your messages, import it as '_' and use as usual.
Do not forget to supply the client's language setting. | [
"Gettext",
"function",
"wrapper",
"to",
"return",
"a",
"message",
"in",
"a",
"specified",
"language",
"by",
"domain"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/misc/__init__.py#L92-L104 |
Hackerfleet/hfos | hfos/misc/__init__.py | std_hash | def std_hash(word, salt):
"""Generates a cryptographically strong (sha512) hash with this nodes
salt added."""
try:
password = word.encode('utf-8')
except UnicodeDecodeError:
password = word
word_hash = sha512(password)
word_hash.update(salt)
hex_hash = word_hash.hexdigest(... | python | def std_hash(word, salt):
"""Generates a cryptographically strong (sha512) hash with this nodes
salt added."""
try:
password = word.encode('utf-8')
except UnicodeDecodeError:
password = word
word_hash = sha512(password)
word_hash.update(salt)
hex_hash = word_hash.hexdigest(... | [
"def",
"std_hash",
"(",
"word",
",",
"salt",
")",
":",
"try",
":",
"password",
"=",
"word",
".",
"encode",
"(",
"'utf-8'",
")",
"except",
"UnicodeDecodeError",
":",
"password",
"=",
"word",
"word_hash",
"=",
"sha512",
"(",
"password",
")",
"word_hash",
"... | Generates a cryptographically strong (sha512) hash with this nodes
salt added. | [
"Generates",
"a",
"cryptographically",
"strong",
"(",
"sha512",
")",
"hash",
"with",
"this",
"nodes",
"salt",
"added",
"."
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/misc/__init__.py#L107-L120 |
Hackerfleet/hfos | hfos/misc/__init__.py | std_human_uid | def std_human_uid(kind=None):
"""Return a random generated human-friendly phrase as low-probability unique id"""
kind_list = alphabet
if kind == 'animal':
kind_list = animals
elif kind == 'place':
kind_list = places
name = "{color} {adjective} {kind} of {attribute}".format(
... | python | def std_human_uid(kind=None):
"""Return a random generated human-friendly phrase as low-probability unique id"""
kind_list = alphabet
if kind == 'animal':
kind_list = animals
elif kind == 'place':
kind_list = places
name = "{color} {adjective} {kind} of {attribute}".format(
... | [
"def",
"std_human_uid",
"(",
"kind",
"=",
"None",
")",
":",
"kind_list",
"=",
"alphabet",
"if",
"kind",
"==",
"'animal'",
":",
"kind_list",
"=",
"animals",
"elif",
"kind",
"==",
"'place'",
":",
"kind_list",
"=",
"places",
"name",
"=",
"\"{color} {adjective} ... | Return a random generated human-friendly phrase as low-probability unique id | [
"Return",
"a",
"random",
"generated",
"human",
"-",
"friendly",
"phrase",
"as",
"low",
"-",
"probability",
"unique",
"id"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/misc/__init__.py#L242-L259 |
Hackerfleet/hfos | hfos/misc/__init__.py | std_table | def std_table(rows):
"""Return a formatted table of given rows"""
result = ""
if len(rows) > 1:
headers = rows[0]._fields
lens = []
for i in range(len(rows[0])):
lens.append(len(max([x[i] for x in rows] + [headers[i]],
key=lambda x: len(st... | python | def std_table(rows):
"""Return a formatted table of given rows"""
result = ""
if len(rows) > 1:
headers = rows[0]._fields
lens = []
for i in range(len(rows[0])):
lens.append(len(max([x[i] for x in rows] + [headers[i]],
key=lambda x: len(st... | [
"def",
"std_table",
"(",
"rows",
")",
":",
"result",
"=",
"\"\"",
"if",
"len",
"(",
"rows",
")",
">",
"1",
":",
"headers",
"=",
"rows",
"[",
"0",
"]",
".",
"_fields",
"lens",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"rows",
... | Return a formatted table of given rows | [
"Return",
"a",
"formatted",
"table",
"of",
"given",
"rows"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/misc/__init__.py#L262-L294 |
Hackerfleet/hfos | hfos/misc/__init__.py | std_salt | def std_salt(length=16, lowercase=True):
"""Generates a cryptographically sane salt of 'length' (default: 16) alphanumeric
characters
"""
alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
if lowercase is True:
alphabet += "abcdefghijklmnopqrstuvwxyz"
chars = []
for i in range(lengt... | python | def std_salt(length=16, lowercase=True):
"""Generates a cryptographically sane salt of 'length' (default: 16) alphanumeric
characters
"""
alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
if lowercase is True:
alphabet += "abcdefghijklmnopqrstuvwxyz"
chars = []
for i in range(lengt... | [
"def",
"std_salt",
"(",
"length",
"=",
"16",
",",
"lowercase",
"=",
"True",
")",
":",
"alphabet",
"=",
"\"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\"",
"if",
"lowercase",
"is",
"True",
":",
"alphabet",
"+=",
"\"abcdefghijklmnopqrstuvwxyz\"",
"chars",
"=",
"[",
"]",
"... | Generates a cryptographically sane salt of 'length' (default: 16) alphanumeric
characters | [
"Generates",
"a",
"cryptographically",
"sane",
"salt",
"of",
"length",
"(",
"default",
":",
"16",
")",
"alphanumeric",
"characters"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/misc/__init__.py#L297-L310 |
Hackerfleet/hfos | hfos/misc/__init__.py | Domain._get_translation | def _get_translation(self, lang):
"""Add a new translation language to the live gettext translator"""
try:
return self._translations[lang]
except KeyError:
# The fact that `fallback=True` is not the default is a serious design flaw.
rv = self._translations[la... | python | def _get_translation(self, lang):
"""Add a new translation language to the live gettext translator"""
try:
return self._translations[lang]
except KeyError:
# The fact that `fallback=True` is not the default is a serious design flaw.
rv = self._translations[la... | [
"def",
"_get_translation",
"(",
"self",
",",
"lang",
")",
":",
"try",
":",
"return",
"self",
".",
"_translations",
"[",
"lang",
"]",
"except",
"KeyError",
":",
"# The fact that `fallback=True` is not the default is a serious design flaw.",
"rv",
"=",
"self",
".",
"_... | Add a new translation language to the live gettext translator | [
"Add",
"a",
"new",
"translation",
"language",
"to",
"the",
"live",
"gettext",
"translator"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/misc/__init__.py#L67-L76 |
Hackerfleet/hfos | hfos/component.py | handler | def handler(*names, **kwargs):
"""Creates an Event Handler
This decorator can be applied to methods of classes derived from
:class:`circuits.core.components.BaseComponent`. It marks the method as a
handler for the events passed as arguments to the ``@handler`` decorator.
The events are specified by... | python | def handler(*names, **kwargs):
"""Creates an Event Handler
This decorator can be applied to methods of classes derived from
:class:`circuits.core.components.BaseComponent`. It marks the method as a
handler for the events passed as arguments to the ``@handler`` decorator.
The events are specified by... | [
"def",
"handler",
"(",
"*",
"names",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"wrapper",
"(",
"f",
")",
":",
"if",
"names",
"and",
"isinstance",
"(",
"names",
"[",
"0",
"]",
",",
"bool",
")",
"and",
"not",
"names",
"[",
"0",
"]",
":",
"f",
"... | Creates an Event Handler
This decorator can be applied to methods of classes derived from
:class:`circuits.core.components.BaseComponent`. It marks the method as a
handler for the events passed as arguments to the ``@handler`` decorator.
The events are specified by their name.
The decorated method... | [
"Creates",
"an",
"Event",
"Handler"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/component.py#L64-L145 |
Hackerfleet/hfos | hfos/component.py | LoggingMeta.log | def log(self, *args, **kwargs):
"""Log a statement from this component"""
func = inspect.currentframe().f_back.f_code
# Dump the message + the name of this function to the log.
if 'exc' in kwargs and kwargs['exc'] is True:
exc_type, exc_obj, exc_tb = exc_info()
... | python | def log(self, *args, **kwargs):
"""Log a statement from this component"""
func = inspect.currentframe().f_back.f_code
# Dump the message + the name of this function to the log.
if 'exc' in kwargs and kwargs['exc'] is True:
exc_type, exc_obj, exc_tb = exc_info()
... | [
"def",
"log",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"func",
"=",
"inspect",
".",
"currentframe",
"(",
")",
".",
"f_back",
".",
"f_code",
"# Dump the message + the name of this function to the log.",
"if",
"'exc'",
"in",
"kwargs",
... | Log a statement from this component | [
"Log",
"a",
"statement",
"from",
"this",
"component"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/component.py#L175-L194 |
Hackerfleet/hfos | hfos/component.py | ConfigurableMeta.register | def register(self, *args):
"""Register a configurable component in the configuration schema
store"""
super(ConfigurableMeta, self).register(*args)
from hfos.database import configschemastore
# self.log('ADDING SCHEMA:')
# pprint(self.configschema)
configschemasto... | python | def register(self, *args):
"""Register a configurable component in the configuration schema
store"""
super(ConfigurableMeta, self).register(*args)
from hfos.database import configschemastore
# self.log('ADDING SCHEMA:')
# pprint(self.configschema)
configschemasto... | [
"def",
"register",
"(",
"self",
",",
"*",
"args",
")",
":",
"super",
"(",
"ConfigurableMeta",
",",
"self",
")",
".",
"register",
"(",
"*",
"args",
")",
"from",
"hfos",
".",
"database",
"import",
"configschemastore",
"# self.log('ADDING SCHEMA:')",
"# pprint(se... | Register a configurable component in the configuration schema
store | [
"Register",
"a",
"configurable",
"component",
"in",
"the",
"configuration",
"schema",
"store"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/component.py#L240-L248 |
Hackerfleet/hfos | hfos/component.py | ConfigurableMeta.unregister | def unregister(self):
"""Removes the unique name from the systems unique name list"""
self.names.remove(self.uniquename)
super(ConfigurableMeta, self).unregister() | python | def unregister(self):
"""Removes the unique name from the systems unique name list"""
self.names.remove(self.uniquename)
super(ConfigurableMeta, self).unregister() | [
"def",
"unregister",
"(",
"self",
")",
":",
"self",
".",
"names",
".",
"remove",
"(",
"self",
".",
"uniquename",
")",
"super",
"(",
"ConfigurableMeta",
",",
"self",
")",
".",
"unregister",
"(",
")"
] | Removes the unique name from the systems unique name list | [
"Removes",
"the",
"unique",
"name",
"from",
"the",
"systems",
"unique",
"name",
"list"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/component.py#L250-L253 |
Hackerfleet/hfos | hfos/component.py | ConfigurableMeta._read_config | def _read_config(self):
"""Read this component's configuration from the database"""
try:
self.config = self.componentmodel.find_one(
{'name': self.uniquename})
except ServerSelectionTimeoutError: # pragma: no cover
self.log("No database access! Check if ... | python | def _read_config(self):
"""Read this component's configuration from the database"""
try:
self.config = self.componentmodel.find_one(
{'name': self.uniquename})
except ServerSelectionTimeoutError: # pragma: no cover
self.log("No database access! Check if ... | [
"def",
"_read_config",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"config",
"=",
"self",
".",
"componentmodel",
".",
"find_one",
"(",
"{",
"'name'",
":",
"self",
".",
"uniquename",
"}",
")",
"except",
"ServerSelectionTimeoutError",
":",
"# pragma: no co... | Read this component's configuration from the database | [
"Read",
"this",
"component",
"s",
"configuration",
"from",
"the",
"database"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/component.py#L255-L267 |
Hackerfleet/hfos | hfos/component.py | ConfigurableMeta._write_config | def _write_config(self):
"""Write this component's configuration back to the database"""
if not self.config:
self.log("Unable to write non existing configuration", lvl=error)
return
self.config.save()
self.log("Configuration stored.") | python | def _write_config(self):
"""Write this component's configuration back to the database"""
if not self.config:
self.log("Unable to write non existing configuration", lvl=error)
return
self.config.save()
self.log("Configuration stored.") | [
"def",
"_write_config",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"config",
":",
"self",
".",
"log",
"(",
"\"Unable to write non existing configuration\"",
",",
"lvl",
"=",
"error",
")",
"return",
"self",
".",
"config",
".",
"save",
"(",
")",
"self"... | Write this component's configuration back to the database | [
"Write",
"this",
"component",
"s",
"configuration",
"back",
"to",
"the",
"database"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/component.py#L270-L278 |
Hackerfleet/hfos | hfos/component.py | ConfigurableMeta._set_config | def _set_config(self, config=None):
"""Set this component's initial configuration"""
if not config:
config = {}
try:
# pprint(self.configschema)
self.config = self.componentmodel(config)
# self.log("Config schema:", lvl=critical)
# ppr... | python | def _set_config(self, config=None):
"""Set this component's initial configuration"""
if not config:
config = {}
try:
# pprint(self.configschema)
self.config = self.componentmodel(config)
# self.log("Config schema:", lvl=critical)
# ppr... | [
"def",
"_set_config",
"(",
"self",
",",
"config",
"=",
"None",
")",
":",
"if",
"not",
"config",
":",
"config",
"=",
"{",
"}",
"try",
":",
"# pprint(self.configschema)",
"self",
".",
"config",
"=",
"self",
".",
"componentmodel",
"(",
"config",
")",
"# sel... | Set this component's initial configuration | [
"Set",
"this",
"component",
"s",
"initial",
"configuration"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/component.py#L280-L336 |
Hackerfleet/hfos | hfos/component.py | ConfigurableMeta.reload_configuration | def reload_configuration(self, event):
"""Event triggered configuration reload"""
if event.target == self.uniquename:
self.log('Reloading configuration')
self._read_config() | python | def reload_configuration(self, event):
"""Event triggered configuration reload"""
if event.target == self.uniquename:
self.log('Reloading configuration')
self._read_config() | [
"def",
"reload_configuration",
"(",
"self",
",",
"event",
")",
":",
"if",
"event",
".",
"target",
"==",
"self",
".",
"uniquename",
":",
"self",
".",
"log",
"(",
"'Reloading configuration'",
")",
"self",
".",
"_read_config",
"(",
")"
] | Event triggered configuration reload | [
"Event",
"triggered",
"configuration",
"reload"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/component.py#L341-L346 |
Hackerfleet/hfos | hfos/tool/create_module.py | _augment_info | def _augment_info(info):
"""Fill out the template information"""
info['description_header'] = "=" * len(info['description'])
info['component_name'] = info['plugin_name'].capitalize()
info['year'] = time.localtime().tm_year
info['license_longtext'] = ''
info['keyword_list'] = u""
for keywor... | python | def _augment_info(info):
"""Fill out the template information"""
info['description_header'] = "=" * len(info['description'])
info['component_name'] = info['plugin_name'].capitalize()
info['year'] = time.localtime().tm_year
info['license_longtext'] = ''
info['keyword_list'] = u""
for keywor... | [
"def",
"_augment_info",
"(",
"info",
")",
":",
"info",
"[",
"'description_header'",
"]",
"=",
"\"=\"",
"*",
"len",
"(",
"info",
"[",
"'description'",
"]",
")",
"info",
"[",
"'component_name'",
"]",
"=",
"info",
"[",
"'plugin_name'",
"]",
".",
"capitalize",... | Fill out the template information | [
"Fill",
"out",
"the",
"template",
"information"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/create_module.py#L89-L106 |
Hackerfleet/hfos | hfos/tool/create_module.py | _construct_module | def _construct_module(info, target):
"""Build a module from templates and user supplied information"""
for path in paths:
real_path = os.path.abspath(os.path.join(target, path.format(**info)))
log("Making directory '%s'" % real_path)
os.makedirs(real_path)
# pprint(info)
for it... | python | def _construct_module(info, target):
"""Build a module from templates and user supplied information"""
for path in paths:
real_path = os.path.abspath(os.path.join(target, path.format(**info)))
log("Making directory '%s'" % real_path)
os.makedirs(real_path)
# pprint(info)
for it... | [
"def",
"_construct_module",
"(",
"info",
",",
"target",
")",
":",
"for",
"path",
"in",
"paths",
":",
"real_path",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"target",
",",
"path",
".",
"format",
"(",
"*",
"*",... | Build a module from templates and user supplied information | [
"Build",
"a",
"module",
"from",
"templates",
"and",
"user",
"supplied",
"information"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/create_module.py#L109-L124 |
Hackerfleet/hfos | hfos/tool/create_module.py | _ask_questionnaire | def _ask_questionnaire():
"""Asks questions to fill out a HFOS plugin template"""
answers = {}
print(info_header)
pprint(questions.items())
for question, default in questions.items():
response = _ask(question, default, str(type(default)), show_hint=True)
if type(default) == unicode... | python | def _ask_questionnaire():
"""Asks questions to fill out a HFOS plugin template"""
answers = {}
print(info_header)
pprint(questions.items())
for question, default in questions.items():
response = _ask(question, default, str(type(default)), show_hint=True)
if type(default) == unicode... | [
"def",
"_ask_questionnaire",
"(",
")",
":",
"answers",
"=",
"{",
"}",
"print",
"(",
"info_header",
")",
"pprint",
"(",
"questions",
".",
"items",
"(",
")",
")",
"for",
"question",
",",
"default",
"in",
"questions",
".",
"items",
"(",
")",
":",
"respons... | Asks questions to fill out a HFOS plugin template | [
"Asks",
"questions",
"to",
"fill",
"out",
"a",
"HFOS",
"plugin",
"template"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/create_module.py#L127-L140 |
Hackerfleet/hfos | hfos/tool/create_module.py | create_module | def create_module(clear_target, target):
"""Creates a new template HFOS plugin module"""
if os.path.exists(target):
if clear_target:
shutil.rmtree(target)
else:
log("Target exists! Use --clear to delete it first.",
emitter='MANAGE')
sys.exit(2... | python | def create_module(clear_target, target):
"""Creates a new template HFOS plugin module"""
if os.path.exists(target):
if clear_target:
shutil.rmtree(target)
else:
log("Target exists! Use --clear to delete it first.",
emitter='MANAGE')
sys.exit(2... | [
"def",
"create_module",
"(",
"clear_target",
",",
"target",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"target",
")",
":",
"if",
"clear_target",
":",
"shutil",
".",
"rmtree",
"(",
"target",
")",
"else",
":",
"log",
"(",
"\"Target exists! Use ... | Creates a new template HFOS plugin module | [
"Creates",
"a",
"new",
"template",
"HFOS",
"plugin",
"module"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/create_module.py#L148-L170 |
Hackerfleet/hfos | hfos/schemata/defaultform.py | lookup_field | def lookup_field(key, lookup_type=None, placeholder=None, html_class="div",
select_type="strapselect", mapping="uuid"):
"""Generates a lookup field for form definitions"""
if lookup_type is None:
lookup_type = key
if placeholder is None:
placeholder = "Select a " + lookup_... | python | def lookup_field(key, lookup_type=None, placeholder=None, html_class="div",
select_type="strapselect", mapping="uuid"):
"""Generates a lookup field for form definitions"""
if lookup_type is None:
lookup_type = key
if placeholder is None:
placeholder = "Select a " + lookup_... | [
"def",
"lookup_field",
"(",
"key",
",",
"lookup_type",
"=",
"None",
",",
"placeholder",
"=",
"None",
",",
"html_class",
"=",
"\"div\"",
",",
"select_type",
"=",
"\"strapselect\"",
",",
"mapping",
"=",
"\"uuid\"",
")",
":",
"if",
"lookup_type",
"is",
"None",
... | Generates a lookup field for form definitions | [
"Generates",
"a",
"lookup",
"field",
"for",
"form",
"definitions"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/schemata/defaultform.py#L92-L114 |
Hackerfleet/hfos | hfos/schemata/defaultform.py | fieldset | def fieldset(title, items, options=None):
"""A field set with a title and sub items"""
result = {
'title': title,
'type': 'fieldset',
'items': items
}
if options is not None:
result.update(options)
return result | python | def fieldset(title, items, options=None):
"""A field set with a title and sub items"""
result = {
'title': title,
'type': 'fieldset',
'items': items
}
if options is not None:
result.update(options)
return result | [
"def",
"fieldset",
"(",
"title",
",",
"items",
",",
"options",
"=",
"None",
")",
":",
"result",
"=",
"{",
"'title'",
":",
"title",
",",
"'type'",
":",
"'fieldset'",
",",
"'items'",
":",
"items",
"}",
"if",
"options",
"is",
"not",
"None",
":",
"result... | A field set with a title and sub items | [
"A",
"field",
"set",
"with",
"a",
"title",
"and",
"sub",
"items"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/schemata/defaultform.py#L117-L127 |
Hackerfleet/hfos | hfos/schemata/defaultform.py | section | def section(rows, columns, items, label=None):
"""A section consisting of rows and columns"""
# TODO: Integrate label
sections = []
column_class = "section-column col-sm-%i" % (12 / columns)
for vertical in range(columns):
column_items = []
for horizontal in range(rows):
... | python | def section(rows, columns, items, label=None):
"""A section consisting of rows and columns"""
# TODO: Integrate label
sections = []
column_class = "section-column col-sm-%i" % (12 / columns)
for vertical in range(columns):
column_items = []
for horizontal in range(rows):
... | [
"def",
"section",
"(",
"rows",
",",
"columns",
",",
"items",
",",
"label",
"=",
"None",
")",
":",
"# TODO: Integrate label",
"sections",
"=",
"[",
"]",
"column_class",
"=",
"\"section-column col-sm-%i\"",
"%",
"(",
"12",
"/",
"columns",
")",
"for",
"vertical... | A section consisting of rows and columns | [
"A",
"section",
"consisting",
"of",
"rows",
"and",
"columns"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/schemata/defaultform.py#L130-L162 |
Hackerfleet/hfos | hfos/schemata/defaultform.py | emptyArray | def emptyArray(key, add_label=None):
"""An array that starts empty"""
result = {
'key': key,
'startEmpty': True
}
if add_label is not None:
result['add'] = add_label
result['style'] = {'add': 'btn-success'}
return result | python | def emptyArray(key, add_label=None):
"""An array that starts empty"""
result = {
'key': key,
'startEmpty': True
}
if add_label is not None:
result['add'] = add_label
result['style'] = {'add': 'btn-success'}
return result | [
"def",
"emptyArray",
"(",
"key",
",",
"add_label",
"=",
"None",
")",
":",
"result",
"=",
"{",
"'key'",
":",
"key",
",",
"'startEmpty'",
":",
"True",
"}",
"if",
"add_label",
"is",
"not",
"None",
":",
"result",
"[",
"'add'",
"]",
"=",
"add_label",
"res... | An array that starts empty | [
"An",
"array",
"that",
"starts",
"empty"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/schemata/defaultform.py#L165-L175 |
Hackerfleet/hfos | hfos/schemata/defaultform.py | tabset | def tabset(titles, contents):
"""A tabbed container widget"""
tabs = []
for no, title in enumerate(titles):
tab = {
'title': title,
}
content = contents[no]
if isinstance(content, list):
tab['items'] = content
else:
tab['items'] = ... | python | def tabset(titles, contents):
"""A tabbed container widget"""
tabs = []
for no, title in enumerate(titles):
tab = {
'title': title,
}
content = contents[no]
if isinstance(content, list):
tab['items'] = content
else:
tab['items'] = ... | [
"def",
"tabset",
"(",
"titles",
",",
"contents",
")",
":",
"tabs",
"=",
"[",
"]",
"for",
"no",
",",
"title",
"in",
"enumerate",
"(",
"titles",
")",
":",
"tab",
"=",
"{",
"'title'",
":",
"title",
",",
"}",
"content",
"=",
"contents",
"[",
"no",
"]... | A tabbed container widget | [
"A",
"tabbed",
"container",
"widget"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/schemata/defaultform.py#L178-L198 |
Hackerfleet/hfos | hfos/schemata/defaultform.py | country_field | def country_field(key='country'):
"""Provides a select box for country selection"""
country_list = list(countries)
title_map = []
for item in country_list:
title_map.append({'value': item.alpha_3, 'name': item.name})
widget = {
'key': key,
'type': 'uiselect',
'title... | python | def country_field(key='country'):
"""Provides a select box for country selection"""
country_list = list(countries)
title_map = []
for item in country_list:
title_map.append({'value': item.alpha_3, 'name': item.name})
widget = {
'key': key,
'type': 'uiselect',
'title... | [
"def",
"country_field",
"(",
"key",
"=",
"'country'",
")",
":",
"country_list",
"=",
"list",
"(",
"countries",
")",
"title_map",
"=",
"[",
"]",
"for",
"item",
"in",
"country_list",
":",
"title_map",
".",
"append",
"(",
"{",
"'value'",
":",
"item",
".",
... | Provides a select box for country selection | [
"Provides",
"a",
"select",
"box",
"for",
"country",
"selection"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/schemata/defaultform.py#L238-L252 |
Hackerfleet/hfos | hfos/schemata/defaultform.py | area_field | def area_field(key='area'):
"""Provides a select box for country selection"""
area_list = list(subdivisions)
title_map = []
for item in area_list:
title_map.append({'value': item.code, 'name': item.name})
widget = {
'key': key,
'type': 'uiselect',
'titleMap': title_... | python | def area_field(key='area'):
"""Provides a select box for country selection"""
area_list = list(subdivisions)
title_map = []
for item in area_list:
title_map.append({'value': item.code, 'name': item.name})
widget = {
'key': key,
'type': 'uiselect',
'titleMap': title_... | [
"def",
"area_field",
"(",
"key",
"=",
"'area'",
")",
":",
"area_list",
"=",
"list",
"(",
"subdivisions",
")",
"title_map",
"=",
"[",
"]",
"for",
"item",
"in",
"area_list",
":",
"title_map",
".",
"append",
"(",
"{",
"'value'",
":",
"item",
".",
"code",
... | Provides a select box for country selection | [
"Provides",
"a",
"select",
"box",
"for",
"country",
"selection"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/schemata/defaultform.py#L255-L269 |
Hackerfleet/hfos | modules/comms/hfos/comms/connectivity.py | ConnectivityMonitor.timed_connectivity_check | def timed_connectivity_check(self, event):
"""Tests internet connectivity in regular intervals and updates the nodestate accordingly"""
self.status = self._can_connect()
self.log('Timed connectivity check:', self.status, lvl=verbose)
if self.status:
if not self.old_status:
... | python | def timed_connectivity_check(self, event):
"""Tests internet connectivity in regular intervals and updates the nodestate accordingly"""
self.status = self._can_connect()
self.log('Timed connectivity check:', self.status, lvl=verbose)
if self.status:
if not self.old_status:
... | [
"def",
"timed_connectivity_check",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"status",
"=",
"self",
".",
"_can_connect",
"(",
")",
"self",
".",
"log",
"(",
"'Timed connectivity check:'",
",",
"self",
".",
"status",
",",
"lvl",
"=",
"verbose",
")",
... | Tests internet connectivity in regular intervals and updates the nodestate accordingly | [
"Tests",
"internet",
"connectivity",
"in",
"regular",
"intervals",
"and",
"updates",
"the",
"nodestate",
"accordingly"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/comms/hfos/comms/connectivity.py#L106-L121 |
Hackerfleet/hfos | modules/comms/hfos/comms/connectivity.py | ConnectivityMonitor._can_connect | def _can_connect(self):
"""Tries to connect to the configured host:port and returns True if the connection was established"""
self.log('Trying to reach configured connectivity check endpoint', lvl=verbose)
try:
socket.setdefaulttimeout(self.config.timeout)
socket.socket(... | python | def _can_connect(self):
"""Tries to connect to the configured host:port and returns True if the connection was established"""
self.log('Trying to reach configured connectivity check endpoint', lvl=verbose)
try:
socket.setdefaulttimeout(self.config.timeout)
socket.socket(... | [
"def",
"_can_connect",
"(",
"self",
")",
":",
"self",
".",
"log",
"(",
"'Trying to reach configured connectivity check endpoint'",
",",
"lvl",
"=",
"verbose",
")",
"try",
":",
"socket",
".",
"setdefaulttimeout",
"(",
"self",
".",
"config",
".",
"timeout",
")",
... | Tries to connect to the configured host:port and returns True if the connection was established | [
"Tries",
"to",
"connect",
"to",
"the",
"configured",
"host",
":",
"port",
"and",
"returns",
"True",
"if",
"the",
"connection",
"was",
"established"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/comms/hfos/comms/connectivity.py#L123-L133 |
Hackerfleet/hfos | hfos/ui/activitymonitor.py | ActivityMonitor.referenceframe | def referenceframe(self, event):
"""Handles navigational reference frame updates.
These are necessary to assign geo coordinates to alerts and other
misc things.
:param event with incoming referenceframe message
"""
self.log("Got a reference frame update! ", event, lvl=v... | python | def referenceframe(self, event):
"""Handles navigational reference frame updates.
These are necessary to assign geo coordinates to alerts and other
misc things.
:param event with incoming referenceframe message
"""
self.log("Got a reference frame update! ", event, lvl=v... | [
"def",
"referenceframe",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"log",
"(",
"\"Got a reference frame update! \"",
",",
"event",
",",
"lvl",
"=",
"verbose",
")",
"self",
".",
"referenceframe",
"=",
"event",
".",
"data"
] | Handles navigational reference frame updates.
These are necessary to assign geo coordinates to alerts and other
misc things.
:param event with incoming referenceframe message | [
"Handles",
"navigational",
"reference",
"frame",
"updates",
".",
"These",
"are",
"necessary",
"to",
"assign",
"geo",
"coordinates",
"to",
"alerts",
"and",
"other",
"misc",
"things",
"."
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/activitymonitor.py#L69-L79 |
Hackerfleet/hfos | hfos/ui/activitymonitor.py | ActivityMonitor.activityrequest | def activityrequest(self, event):
"""ActivityMonitor event handler for incoming events
:param event with incoming ActivityMonitor message
"""
# self.log("Event: '%s'" % event.__dict__)
try:
action = event.action
data = event.data
self.log("A... | python | def activityrequest(self, event):
"""ActivityMonitor event handler for incoming events
:param event with incoming ActivityMonitor message
"""
# self.log("Event: '%s'" % event.__dict__)
try:
action = event.action
data = event.data
self.log("A... | [
"def",
"activityrequest",
"(",
"self",
",",
"event",
")",
":",
"# self.log(\"Event: '%s'\" % event.__dict__)",
"try",
":",
"action",
"=",
"event",
".",
"action",
"data",
"=",
"event",
".",
"data",
"self",
".",
"log",
"(",
"\"Activityrequest: \"",
",",
"action",
... | ActivityMonitor event handler for incoming events
:param event with incoming ActivityMonitor message | [
"ActivityMonitor",
"event",
"handler",
"for",
"incoming",
"events"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/activitymonitor.py#L87-L101 |
Hackerfleet/hfos | hfos/tool/objects.py | modify | def modify(ctx, schema, uuid, object_filter, field, value):
"""Modify field values of objects"""
database = ctx.obj['db']
model = database.objectmodels[schema]
obj = None
if uuid:
obj = model.find_one({'uuid': uuid})
elif object_filter:
obj = model.find_one(literal_eval(object_... | python | def modify(ctx, schema, uuid, object_filter, field, value):
"""Modify field values of objects"""
database = ctx.obj['db']
model = database.objectmodels[schema]
obj = None
if uuid:
obj = model.find_one({'uuid': uuid})
elif object_filter:
obj = model.find_one(literal_eval(object_... | [
"def",
"modify",
"(",
"ctx",
",",
"schema",
",",
"uuid",
",",
"object_filter",
",",
"field",
",",
"value",
")",
":",
"database",
"=",
"ctx",
".",
"obj",
"[",
"'db'",
"]",
"model",
"=",
"database",
".",
"objectmodels",
"[",
"schema",
"]",
"obj",
"=",
... | Modify field values of objects | [
"Modify",
"field",
"values",
"of",
"objects"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/objects.py#L51-L82 |
Hackerfleet/hfos | hfos/tool/objects.py | view | def view(ctx, schema, uuid, object_filter):
"""Show stored objects"""
database = ctx.obj['db']
if schema is None:
log('No schema given. Read the help', lvl=warn)
return
model = database.objectmodels[schema]
if uuid:
obj = model.find({'uuid': uuid})
elif object_filter:... | python | def view(ctx, schema, uuid, object_filter):
"""Show stored objects"""
database = ctx.obj['db']
if schema is None:
log('No schema given. Read the help', lvl=warn)
return
model = database.objectmodels[schema]
if uuid:
obj = model.find({'uuid': uuid})
elif object_filter:... | [
"def",
"view",
"(",
"ctx",
",",
"schema",
",",
"uuid",
",",
"object_filter",
")",
":",
"database",
"=",
"ctx",
".",
"obj",
"[",
"'db'",
"]",
"if",
"schema",
"is",
"None",
":",
"log",
"(",
"'No schema given. Read the help'",
",",
"lvl",
"=",
"warn",
")"... | Show stored objects | [
"Show",
"stored",
"objects"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/objects.py#L90-L109 |
Hackerfleet/hfos | hfos/tool/objects.py | delete | def delete(ctx, schema, uuid, object_filter, yes):
"""Delete stored objects (CAUTION!)"""
database = ctx.obj['db']
if schema is None:
log('No schema given. Read the help', lvl=warn)
return
model = database.objectmodels[schema]
if uuid:
count = model.count({'uuid': uuid})
... | python | def delete(ctx, schema, uuid, object_filter, yes):
"""Delete stored objects (CAUTION!)"""
database = ctx.obj['db']
if schema is None:
log('No schema given. Read the help', lvl=warn)
return
model = database.objectmodels[schema]
if uuid:
count = model.count({'uuid': uuid})
... | [
"def",
"delete",
"(",
"ctx",
",",
"schema",
",",
"uuid",
",",
"object_filter",
",",
"yes",
")",
":",
"database",
"=",
"ctx",
".",
"obj",
"[",
"'db'",
"]",
"if",
"schema",
"is",
"None",
":",
"log",
"(",
"'No schema given. Read the help'",
",",
"lvl",
"=... | Delete stored objects (CAUTION!) | [
"Delete",
"stored",
"objects",
"(",
"CAUTION!",
")"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/objects.py#L118-L150 |
Hackerfleet/hfos | hfos/tool/objects.py | validate | def validate(ctx, schema, all_schemata):
"""Validates all objects or all objects of a given schema."""
database = ctx.obj['db']
if schema is None:
if all_schemata is False:
log('No schema given. Read the help', lvl=warn)
return
else:
schemata = database.... | python | def validate(ctx, schema, all_schemata):
"""Validates all objects or all objects of a given schema."""
database = ctx.obj['db']
if schema is None:
if all_schemata is False:
log('No schema given. Read the help', lvl=warn)
return
else:
schemata = database.... | [
"def",
"validate",
"(",
"ctx",
",",
"schema",
",",
"all_schemata",
")",
":",
"database",
"=",
"ctx",
".",
"obj",
"[",
"'db'",
"]",
"if",
"schema",
"is",
"None",
":",
"if",
"all_schemata",
"is",
"False",
":",
"log",
"(",
"'No schema given. Read the help'",
... | Validates all objects or all objects of a given schema. | [
"Validates",
"all",
"objects",
"or",
"all",
"objects",
"of",
"a",
"given",
"schema",
"."
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/objects.py#L158-L186 |
Hackerfleet/hfos | hfos/tool/objects.py | find_field | def find_field(ctx, search, by_type, obj):
"""Find fields in registered data models."""
# TODO: Fix this to work recursively on all possible subschemes
if search is not None:
search = search
else:
search = _ask("Enter search term")
database = ctx.obj['db']
def find(search_sche... | python | def find_field(ctx, search, by_type, obj):
"""Find fields in registered data models."""
# TODO: Fix this to work recursively on all possible subschemes
if search is not None:
search = search
else:
search = _ask("Enter search term")
database = ctx.obj['db']
def find(search_sche... | [
"def",
"find_field",
"(",
"ctx",
",",
"search",
",",
"by_type",
",",
"obj",
")",
":",
"# TODO: Fix this to work recursively on all possible subschemes",
"if",
"search",
"is",
"not",
"None",
":",
"search",
"=",
"search",
"else",
":",
"search",
"=",
"_ask",
"(",
... | Find fields in registered data models. | [
"Find",
"fields",
"in",
"registered",
"data",
"models",
"."
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/objects.py#L198-L263 |
Hackerfleet/hfos | modules/dev/hfos/misc/vesselsim.py | Distance | def Distance(lat1, lon1, lat2, lon2):
"""Get distance between pairs of lat-lon points"""
az12, az21, dist = wgs84_geod.inv(lon1, lat1, lon2, lat2)
return az21, dist | python | def Distance(lat1, lon1, lat2, lon2):
"""Get distance between pairs of lat-lon points"""
az12, az21, dist = wgs84_geod.inv(lon1, lat1, lon2, lat2)
return az21, dist | [
"def",
"Distance",
"(",
"lat1",
",",
"lon1",
",",
"lat2",
",",
"lon2",
")",
":",
"az12",
",",
"az21",
",",
"dist",
"=",
"wgs84_geod",
".",
"inv",
"(",
"lon1",
",",
"lat1",
",",
"lon2",
",",
"lat2",
")",
"return",
"az21",
",",
"dist"
] | Get distance between pairs of lat-lon points | [
"Get",
"distance",
"between",
"pairs",
"of",
"lat",
"-",
"lon",
"points"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/dev/hfos/misc/vesselsim.py#L54-L58 |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager.client_details | def client_details(self, *args):
"""Display known details about a given client"""
self.log(_('Client details:', lang='de'))
client = self._clients[args[0]]
self.log('UUID:', client.uuid, 'IP:', client.ip, 'Name:', client.name, 'User:', self._users[client.useruuid],
pre... | python | def client_details(self, *args):
"""Display known details about a given client"""
self.log(_('Client details:', lang='de'))
client = self._clients[args[0]]
self.log('UUID:', client.uuid, 'IP:', client.ip, 'Name:', client.name, 'User:', self._users[client.useruuid],
pre... | [
"def",
"client_details",
"(",
"self",
",",
"*",
"args",
")",
":",
"self",
".",
"log",
"(",
"_",
"(",
"'Client details:'",
",",
"lang",
"=",
"'de'",
")",
")",
"client",
"=",
"self",
".",
"_clients",
"[",
"args",
"[",
"0",
"]",
"]",
"self",
".",
"l... | Display known details about a given client | [
"Display",
"known",
"details",
"about",
"a",
"given",
"client"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L155-L162 |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager.client_list | def client_list(self, *args):
"""Display a list of connected clients"""
if len(self._clients) == 0:
self.log('No clients connected')
else:
self.log(self._clients, pretty=True) | python | def client_list(self, *args):
"""Display a list of connected clients"""
if len(self._clients) == 0:
self.log('No clients connected')
else:
self.log(self._clients, pretty=True) | [
"def",
"client_list",
"(",
"self",
",",
"*",
"args",
")",
":",
"if",
"len",
"(",
"self",
".",
"_clients",
")",
"==",
"0",
":",
"self",
".",
"log",
"(",
"'No clients connected'",
")",
"else",
":",
"self",
".",
"log",
"(",
"self",
".",
"_clients",
",... | Display a list of connected clients | [
"Display",
"a",
"list",
"of",
"connected",
"clients"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L165-L170 |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager.users_list | def users_list(self, *args):
"""Display a list of connected users"""
if len(self._users) == 0:
self.log('No users connected')
else:
self.log(self._users, pretty=True) | python | def users_list(self, *args):
"""Display a list of connected users"""
if len(self._users) == 0:
self.log('No users connected')
else:
self.log(self._users, pretty=True) | [
"def",
"users_list",
"(",
"self",
",",
"*",
"args",
")",
":",
"if",
"len",
"(",
"self",
".",
"_users",
")",
"==",
"0",
":",
"self",
".",
"log",
"(",
"'No users connected'",
")",
"else",
":",
"self",
".",
"log",
"(",
"self",
".",
"_users",
",",
"p... | Display a list of connected users | [
"Display",
"a",
"list",
"of",
"connected",
"users"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L173-L178 |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager.sourcess_list | def sourcess_list(self, *args):
"""Display a list of all registered events"""
from pprint import pprint
sources = {}
sources.update(self.authorized_events)
sources.update(self.anonymous_events)
for source in sources:
pprint(source) | python | def sourcess_list(self, *args):
"""Display a list of all registered events"""
from pprint import pprint
sources = {}
sources.update(self.authorized_events)
sources.update(self.anonymous_events)
for source in sources:
pprint(source) | [
"def",
"sourcess_list",
"(",
"self",
",",
"*",
"args",
")",
":",
"from",
"pprint",
"import",
"pprint",
"sources",
"=",
"{",
"}",
"sources",
".",
"update",
"(",
"self",
".",
"authorized_events",
")",
"sources",
".",
"update",
"(",
"self",
".",
"anonymous_... | Display a list of all registered events | [
"Display",
"a",
"list",
"of",
"all",
"registered",
"events"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L181-L191 |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager.events_list | def events_list(self, *args):
"""Display a list of all registered events"""
def merge(a, b, path=None):
"merges b into a"
if path is None: path = []
for key in b:
if key in a:
if isinstance(a[key], dict) and isinstance(b[key], dict... | python | def events_list(self, *args):
"""Display a list of all registered events"""
def merge(a, b, path=None):
"merges b into a"
if path is None: path = []
for key in b:
if key in a:
if isinstance(a[key], dict) and isinstance(b[key], dict... | [
"def",
"events_list",
"(",
"self",
",",
"*",
"args",
")",
":",
"def",
"merge",
"(",
"a",
",",
"b",
",",
"path",
"=",
"None",
")",
":",
"\"merges b into a\"",
"if",
"path",
"is",
"None",
":",
"path",
"=",
"[",
"]",
"for",
"key",
"in",
"b",
":",
... | Display a list of all registered events | [
"Display",
"a",
"list",
"of",
"all",
"registered",
"events"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L194-L220 |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager.who | def who(self, *args):
"""Display a table of connected users and clients"""
if len(self._users) == 0:
self.log('No users connected')
if len(self._clients) == 0:
self.log('No clients connected')
return
Row = namedtuple("Row", ['User', 'Clien... | python | def who(self, *args):
"""Display a table of connected users and clients"""
if len(self._users) == 0:
self.log('No users connected')
if len(self._clients) == 0:
self.log('No clients connected')
return
Row = namedtuple("Row", ['User', 'Clien... | [
"def",
"who",
"(",
"self",
",",
"*",
"args",
")",
":",
"if",
"len",
"(",
"self",
".",
"_users",
")",
"==",
"0",
":",
"self",
".",
"log",
"(",
"'No users connected'",
")",
"if",
"len",
"(",
"self",
".",
"_clients",
")",
"==",
"0",
":",
"self",
"... | Display a table of connected users and clients | [
"Display",
"a",
"table",
"of",
"connected",
"users",
"and",
"clients"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L223-L245 |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager.disconnect | def disconnect(self, sock):
"""Handles socket disconnections"""
self.log("Disconnect ", sock, lvl=debug)
try:
if sock in self._sockets:
self.log("Getting socket", lvl=debug)
sockobj = self._sockets[sock]
self.log("Getting clientuuid",... | python | def disconnect(self, sock):
"""Handles socket disconnections"""
self.log("Disconnect ", sock, lvl=debug)
try:
if sock in self._sockets:
self.log("Getting socket", lvl=debug)
sockobj = self._sockets[sock]
self.log("Getting clientuuid",... | [
"def",
"disconnect",
"(",
"self",
",",
"sock",
")",
":",
"self",
".",
"log",
"(",
"\"Disconnect \"",
",",
"sock",
",",
"lvl",
"=",
"debug",
")",
"try",
":",
"if",
"sock",
"in",
"self",
".",
"_sockets",
":",
"self",
".",
"log",
"(",
"\"Getting socket\... | Handles socket disconnections | [
"Handles",
"socket",
"disconnections"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L255-L290 |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager._logoutclient | def _logoutclient(self, useruuid, clientuuid):
"""Log out a client and possibly associated user"""
self.log("Cleaning up client of logged in user.", lvl=debug)
try:
self._users[useruuid].clients.remove(clientuuid)
if len(self._users[useruuid].clients) == 0:
... | python | def _logoutclient(self, useruuid, clientuuid):
"""Log out a client and possibly associated user"""
self.log("Cleaning up client of logged in user.", lvl=debug)
try:
self._users[useruuid].clients.remove(clientuuid)
if len(self._users[useruuid].clients) == 0:
... | [
"def",
"_logoutclient",
"(",
"self",
",",
"useruuid",
",",
"clientuuid",
")",
":",
"self",
".",
"log",
"(",
"\"Cleaning up client of logged in user.\"",
",",
"lvl",
"=",
"debug",
")",
"try",
":",
"self",
".",
"_users",
"[",
"useruuid",
"]",
".",
"clients",
... | Log out a client and possibly associated user | [
"Log",
"out",
"a",
"client",
"and",
"possibly",
"associated",
"user"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L292-L308 |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager.connect | def connect(self, *args):
"""Registers new sockets and their clients and allocates uuids"""
self.log("Connect ", args, lvl=verbose)
try:
sock = args[0]
ip = args[1]
if sock not in self._sockets:
self.log("New client connected:", ip, lvl=debu... | python | def connect(self, *args):
"""Registers new sockets and their clients and allocates uuids"""
self.log("Connect ", args, lvl=verbose)
try:
sock = args[0]
ip = args[1]
if sock not in self._sockets:
self.log("New client connected:", ip, lvl=debu... | [
"def",
"connect",
"(",
"self",
",",
"*",
"args",
")",
":",
"self",
".",
"log",
"(",
"\"Connect \"",
",",
"args",
",",
"lvl",
"=",
"verbose",
")",
"try",
":",
"sock",
"=",
"args",
"[",
"0",
"]",
"ip",
"=",
"args",
"[",
"1",
"]",
"if",
"sock",
... | Registers new sockets and their clients and allocates uuids | [
"Registers",
"new",
"sockets",
"and",
"their",
"clients",
"and",
"allocates",
"uuids"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L311-L340 |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager.send | def send(self, event):
"""Sends a packet to an already known user or one of his clients by
UUID"""
try:
jsonpacket = json.dumps(event.packet, cls=ComplexEncoder)
if event.sendtype == "user":
# TODO: I think, caching a user name <-> uuid table would
... | python | def send(self, event):
"""Sends a packet to an already known user or one of his clients by
UUID"""
try:
jsonpacket = json.dumps(event.packet, cls=ComplexEncoder)
if event.sendtype == "user":
# TODO: I think, caching a user name <-> uuid table would
... | [
"def",
"send",
"(",
"self",
",",
"event",
")",
":",
"try",
":",
"jsonpacket",
"=",
"json",
".",
"dumps",
"(",
"event",
".",
"packet",
",",
"cls",
"=",
"ComplexEncoder",
")",
"if",
"event",
".",
"sendtype",
"==",
"\"user\"",
":",
"# TODO: I think, caching... | Sends a packet to an already known user or one of his clients by
UUID | [
"Sends",
"a",
"packet",
"to",
"an",
"already",
"known",
"user",
"or",
"one",
"of",
"his",
"clients",
"by",
"UUID"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L342-L403 |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager.broadcast | def broadcast(self, event):
"""Broadcasts an event either to all users or clients, depending on
event flag"""
try:
if event.broadcasttype == "users":
if len(self._users) > 0:
self.log("Broadcasting to all users:",
event... | python | def broadcast(self, event):
"""Broadcasts an event either to all users or clients, depending on
event flag"""
try:
if event.broadcasttype == "users":
if len(self._users) > 0:
self.log("Broadcasting to all users:",
event... | [
"def",
"broadcast",
"(",
"self",
",",
"event",
")",
":",
"try",
":",
"if",
"event",
".",
"broadcasttype",
"==",
"\"users\"",
":",
"if",
"len",
"(",
"self",
".",
"_users",
")",
">",
"0",
":",
"self",
".",
"log",
"(",
"\"Broadcasting to all users:\"",
",... | Broadcasts an event either to all users or clients, depending on
event flag | [
"Broadcasts",
"an",
"event",
"either",
"to",
"all",
"users",
"or",
"clients",
"depending",
"on",
"event",
"flag"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L405-L443 |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager._checkPermissions | def _checkPermissions(self, user, event):
"""Checks if the user has in any role that allows to fire the event."""
for role in user.account.roles:
if role in event.roles:
self.log('Access granted', lvl=verbose)
return True
self.log('Access denied', lv... | python | def _checkPermissions(self, user, event):
"""Checks if the user has in any role that allows to fire the event."""
for role in user.account.roles:
if role in event.roles:
self.log('Access granted', lvl=verbose)
return True
self.log('Access denied', lv... | [
"def",
"_checkPermissions",
"(",
"self",
",",
"user",
",",
"event",
")",
":",
"for",
"role",
"in",
"user",
".",
"account",
".",
"roles",
":",
"if",
"role",
"in",
"event",
".",
"roles",
":",
"self",
".",
"log",
"(",
"'Access granted'",
",",
"lvl",
"="... | Checks if the user has in any role that allows to fire the event. | [
"Checks",
"if",
"the",
"user",
"has",
"in",
"any",
"role",
"that",
"allows",
"to",
"fire",
"the",
"event",
"."
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L445-L454 |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager._handleAuthorizedEvents | def _handleAuthorizedEvents(self, component, action, data, user, client):
"""Isolated communication link for authorized events."""
try:
if component == "debugger":
self.log(component, action, data, user, client, lvl=info)
if not user and component in self.author... | python | def _handleAuthorizedEvents(self, component, action, data, user, client):
"""Isolated communication link for authorized events."""
try:
if component == "debugger":
self.log(component, action, data, user, client, lvl=info)
if not user and component in self.author... | [
"def",
"_handleAuthorizedEvents",
"(",
"self",
",",
"component",
",",
"action",
",",
"data",
",",
"user",
",",
"client",
")",
":",
"try",
":",
"if",
"component",
"==",
"\"debugger\"",
":",
"self",
".",
"log",
"(",
"component",
",",
"action",
",",
"data",... | Isolated communication link for authorized events. | [
"Isolated",
"communication",
"link",
"for",
"authorized",
"events",
"."
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L456-L488 |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager._handleAnonymousEvents | def _handleAnonymousEvents(self, component, action, data, client):
"""Handler for anonymous (public) events"""
try:
event = self.anonymous_events[component][action]['event']
self.log("Firing anonymous event: ", component, action,
str(data)[:20], lvl=network)... | python | def _handleAnonymousEvents(self, component, action, data, client):
"""Handler for anonymous (public) events"""
try:
event = self.anonymous_events[component][action]['event']
self.log("Firing anonymous event: ", component, action,
str(data)[:20], lvl=network)... | [
"def",
"_handleAnonymousEvents",
"(",
"self",
",",
"component",
",",
"action",
",",
"data",
",",
"client",
")",
":",
"try",
":",
"event",
"=",
"self",
".",
"anonymous_events",
"[",
"component",
"]",
"[",
"action",
"]",
"[",
"'event'",
"]",
"self",
".",
... | Handler for anonymous (public) events | [
"Handler",
"for",
"anonymous",
"(",
"public",
")",
"events"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L490-L502 |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager._handleAuthenticationEvents | def _handleAuthenticationEvents(self, requestdata, requestaction,
clientuuid, sock):
"""Handler for authentication events"""
# TODO: Move this stuff over to ./auth.py
if requestaction in ("login", "autologin"):
try:
self.log("Login... | python | def _handleAuthenticationEvents(self, requestdata, requestaction,
clientuuid, sock):
"""Handler for authentication events"""
# TODO: Move this stuff over to ./auth.py
if requestaction in ("login", "autologin"):
try:
self.log("Login... | [
"def",
"_handleAuthenticationEvents",
"(",
"self",
",",
"requestdata",
",",
"requestaction",
",",
"clientuuid",
",",
"sock",
")",
":",
"# TODO: Move this stuff over to ./auth.py",
"if",
"requestaction",
"in",
"(",
"\"login\"",
",",
"\"autologin\"",
")",
":",
"try",
... | Handler for authentication events | [
"Handler",
"for",
"authentication",
"events"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L504-L559 |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager._reset_flood_offenders | def _reset_flood_offenders(self, *args):
"""Resets the list of flood offenders on event trigger"""
offenders = []
# self.log('Resetting flood offenders')
for offender, offence_time in self._flooding.items():
if time() - offence_time < 10:
self.log('Removed o... | python | def _reset_flood_offenders(self, *args):
"""Resets the list of flood offenders on event trigger"""
offenders = []
# self.log('Resetting flood offenders')
for offender, offence_time in self._flooding.items():
if time() - offence_time < 10:
self.log('Removed o... | [
"def",
"_reset_flood_offenders",
"(",
"self",
",",
"*",
"args",
")",
":",
"offenders",
"=",
"[",
"]",
"# self.log('Resetting flood offenders')",
"for",
"offender",
",",
"offence_time",
"in",
"self",
".",
"_flooding",
".",
"items",
"(",
")",
":",
"if",
"time",
... | Resets the list of flood offenders on event trigger | [
"Resets",
"the",
"list",
"of",
"flood",
"offenders",
"on",
"event",
"trigger"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L569-L581 |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager._check_flood_protection | def _check_flood_protection(self, component, action, clientuuid):
"""Checks if any clients have been flooding the node"""
if clientuuid not in self._flood_counter:
self._flood_counter[clientuuid] = 0
self._flood_counter[clientuuid] += 1
if self._flood_counter[clientuuid] >... | python | def _check_flood_protection(self, component, action, clientuuid):
"""Checks if any clients have been flooding the node"""
if clientuuid not in self._flood_counter:
self._flood_counter[clientuuid] = 0
self._flood_counter[clientuuid] += 1
if self._flood_counter[clientuuid] >... | [
"def",
"_check_flood_protection",
"(",
"self",
",",
"component",
",",
"action",
",",
"clientuuid",
")",
":",
"if",
"clientuuid",
"not",
"in",
"self",
".",
"_flood_counter",
":",
"self",
".",
"_flood_counter",
"[",
"clientuuid",
"]",
"=",
"0",
"self",
".",
... | Checks if any clients have been flooding the node | [
"Checks",
"if",
"any",
"clients",
"have",
"been",
"flooding",
"the",
"node"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L583-L599 |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager.read | def read(self, *args):
"""Handles raw client requests and distributes them to the
appropriate components"""
self.log("Beginning new transaction: ", args, lvl=network)
try:
sock, msg = args[0], args[1]
user = password = client = clientuuid = useruuid = requestdata... | python | def read(self, *args):
"""Handles raw client requests and distributes them to the
appropriate components"""
self.log("Beginning new transaction: ", args, lvl=network)
try:
sock, msg = args[0], args[1]
user = password = client = clientuuid = useruuid = requestdata... | [
"def",
"read",
"(",
"self",
",",
"*",
"args",
")",
":",
"self",
".",
"log",
"(",
"\"Beginning new transaction: \"",
",",
"args",
",",
"lvl",
"=",
"network",
")",
"try",
":",
"sock",
",",
"msg",
"=",
"args",
"[",
"0",
"]",
",",
"args",
"[",
"1",
"... | Handles raw client requests and distributes them to the
appropriate components | [
"Handles",
"raw",
"client",
"requests",
"and",
"distributes",
"them",
"to",
"the",
"appropriate",
"components"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L602-L700 |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager.authentication | def authentication(self, event):
"""Links the client to the granted account and profile,
then notifies the client"""
try:
self.log("Authorization has been granted by DB check:",
event.username, lvl=debug)
account, profile, clientconfig = event.userd... | python | def authentication(self, event):
"""Links the client to the granted account and profile,
then notifies the client"""
try:
self.log("Authorization has been granted by DB check:",
event.username, lvl=debug)
account, profile, clientconfig = event.userd... | [
"def",
"authentication",
"(",
"self",
",",
"event",
")",
":",
"try",
":",
"self",
".",
"log",
"(",
"\"Authorization has been granted by DB check:\"",
",",
"event",
".",
"username",
",",
"lvl",
"=",
"debug",
")",
"account",
",",
"profile",
",",
"clientconfig",
... | Links the client to the granted account and profile,
then notifies the client | [
"Links",
"the",
"client",
"to",
"the",
"granted",
"account",
"and",
"profile",
"then",
"notifies",
"the",
"client"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L703-L801 |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager.selectlanguage | def selectlanguage(self, event):
"""Store client's selection of a new translation"""
self.log('Language selection event:', event.client, pretty=True)
if event.data not in all_languages():
self.log('Unavailable language selected:', event.data, lvl=warn)
language = None
... | python | def selectlanguage(self, event):
"""Store client's selection of a new translation"""
self.log('Language selection event:', event.client, pretty=True)
if event.data not in all_languages():
self.log('Unavailable language selected:', event.data, lvl=warn)
language = None
... | [
"def",
"selectlanguage",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"log",
"(",
"'Language selection event:'",
",",
"event",
".",
"client",
",",
"pretty",
"=",
"True",
")",
"if",
"event",
".",
"data",
"not",
"in",
"all_languages",
"(",
")",
":",
... | Store client's selection of a new translation | [
"Store",
"client",
"s",
"selection",
"of",
"a",
"new",
"translation"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L804-L822 |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager.getlanguages | def getlanguages(self, event):
"""Compile and return a human readable list of registered translations"""
self.log('Client requests all languages.', lvl=verbose)
result = {
'component': 'hfos.ui.clientmanager',
'action': 'getlanguages',
'data': language_token_... | python | def getlanguages(self, event):
"""Compile and return a human readable list of registered translations"""
self.log('Client requests all languages.', lvl=verbose)
result = {
'component': 'hfos.ui.clientmanager',
'action': 'getlanguages',
'data': language_token_... | [
"def",
"getlanguages",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"log",
"(",
"'Client requests all languages.'",
",",
"lvl",
"=",
"verbose",
")",
"result",
"=",
"{",
"'component'",
":",
"'hfos.ui.clientmanager'",
",",
"'action'",
":",
"'getlanguages'",
... | Compile and return a human readable list of registered translations | [
"Compile",
"and",
"return",
"a",
"human",
"readable",
"list",
"of",
"registered",
"translations"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L825-L834 |
Hackerfleet/hfos | hfos/ui/clientmanager.py | ClientManager.ping | def ping(self, event):
"""Perform a ping to measure client <-> node latency"""
self.log('Client ping received:', event.data, lvl=verbose)
response = {
'component': 'hfos.ui.clientmanager',
'action': 'pong',
'data': [event.data, time() * 1000]
}
... | python | def ping(self, event):
"""Perform a ping to measure client <-> node latency"""
self.log('Client ping received:', event.data, lvl=verbose)
response = {
'component': 'hfos.ui.clientmanager',
'action': 'pong',
'data': [event.data, time() * 1000]
}
... | [
"def",
"ping",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"log",
"(",
"'Client ping received:'",
",",
"event",
".",
"data",
",",
"lvl",
"=",
"verbose",
")",
"response",
"=",
"{",
"'component'",
":",
"'hfos.ui.clientmanager'",
",",
"'action'",
":",
... | Perform a ping to measure client <-> node latency | [
"Perform",
"a",
"ping",
"to",
"measure",
"client",
"<",
"-",
">",
"node",
"latency"
] | train | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L837-L847 |
aburrell/apexpy | src/apexpy/apex.py | Apex.convert | def convert(self, lat, lon, source, dest, height=0, datetime=None,
precision=1e-10, ssheight=50*6371):
"""Converts between geodetic, modified apex, quasi-dipole and MLT.
Parameters
==========
lat : array_like
Latitude
lon : array_like
Long... | python | def convert(self, lat, lon, source, dest, height=0, datetime=None,
precision=1e-10, ssheight=50*6371):
"""Converts between geodetic, modified apex, quasi-dipole and MLT.
Parameters
==========
lat : array_like
Latitude
lon : array_like
Long... | [
"def",
"convert",
"(",
"self",
",",
"lat",
",",
"lon",
",",
"source",
",",
"dest",
",",
"height",
"=",
"0",
",",
"datetime",
"=",
"None",
",",
"precision",
"=",
"1e-10",
",",
"ssheight",
"=",
"50",
"*",
"6371",
")",
":",
"if",
"datetime",
"is",
"... | Converts between geodetic, modified apex, quasi-dipole and MLT.
Parameters
==========
lat : array_like
Latitude
lon : array_like
Longitude/MLT
source : {'geo', 'apex', 'qd', 'mlt'}
Input coordinate system
dest : {'geo', 'apex', 'qd', '... | [
"Converts",
"between",
"geodetic",
"modified",
"apex",
"quasi",
"-",
"dipole",
"and",
"MLT",
"."
] | train | https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/apex.py#L115-L203 |
aburrell/apexpy | src/apexpy/apex.py | Apex.geo2apex | def geo2apex(self, glat, glon, height):
"""Converts geodetic to modified apex coordinates.
Parameters
==========
glat : array_like
Geodetic latitude
glon : array_like
Geodetic longitude
height : array_like
Altitude in km
Retur... | python | def geo2apex(self, glat, glon, height):
"""Converts geodetic to modified apex coordinates.
Parameters
==========
glat : array_like
Geodetic latitude
glon : array_like
Geodetic longitude
height : array_like
Altitude in km
Retur... | [
"def",
"geo2apex",
"(",
"self",
",",
"glat",
",",
"glon",
",",
"height",
")",
":",
"glat",
"=",
"helpers",
".",
"checklat",
"(",
"glat",
",",
"name",
"=",
"'glat'",
")",
"alat",
",",
"alon",
"=",
"self",
".",
"_geo2apex",
"(",
"glat",
",",
"glon",
... | Converts geodetic to modified apex coordinates.
Parameters
==========
glat : array_like
Geodetic latitude
glon : array_like
Geodetic longitude
height : array_like
Altitude in km
Returns
=======
alat : ndarray or float
... | [
"Converts",
"geodetic",
"to",
"modified",
"apex",
"coordinates",
"."
] | train | https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/apex.py#L205-L235 |
aburrell/apexpy | src/apexpy/apex.py | Apex.apex2geo | def apex2geo(self, alat, alon, height, precision=1e-10):
"""Converts modified apex to geodetic coordinates.
Parameters
==========
alat : array_like
Modified apex latitude
alon : array_like
Modified apex longitude
height : array_like
Al... | python | def apex2geo(self, alat, alon, height, precision=1e-10):
"""Converts modified apex to geodetic coordinates.
Parameters
==========
alat : array_like
Modified apex latitude
alon : array_like
Modified apex longitude
height : array_like
Al... | [
"def",
"apex2geo",
"(",
"self",
",",
"alat",
",",
"alon",
",",
"height",
",",
"precision",
"=",
"1e-10",
")",
":",
"alat",
"=",
"helpers",
".",
"checklat",
"(",
"alat",
",",
"name",
"=",
"'alat'",
")",
"qlat",
",",
"qlon",
"=",
"self",
".",
"apex2q... | Converts modified apex to geodetic coordinates.
Parameters
==========
alat : array_like
Modified apex latitude
alon : array_like
Modified apex longitude
height : array_like
Altitude in km
precision : float, optional
Precisi... | [
"Converts",
"modified",
"apex",
"to",
"geodetic",
"coordinates",
"."
] | train | https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/apex.py#L237-L274 |
aburrell/apexpy | src/apexpy/apex.py | Apex.geo2qd | def geo2qd(self, glat, glon, height):
"""Converts geodetic to quasi-dipole coordinates.
Parameters
==========
glat : array_like
Geodetic latitude
glon : array_like
Geodetic longitude
height : array_like
Altitude in km
Returns
... | python | def geo2qd(self, glat, glon, height):
"""Converts geodetic to quasi-dipole coordinates.
Parameters
==========
glat : array_like
Geodetic latitude
glon : array_like
Geodetic longitude
height : array_like
Altitude in km
Returns
... | [
"def",
"geo2qd",
"(",
"self",
",",
"glat",
",",
"glon",
",",
"height",
")",
":",
"glat",
"=",
"helpers",
".",
"checklat",
"(",
"glat",
",",
"name",
"=",
"'glat'",
")",
"qlat",
",",
"qlon",
"=",
"self",
".",
"_geo2qd",
"(",
"glat",
",",
"glon",
",... | Converts geodetic to quasi-dipole coordinates.
Parameters
==========
glat : array_like
Geodetic latitude
glon : array_like
Geodetic longitude
height : array_like
Altitude in km
Returns
=======
qlat : ndarray or float
... | [
"Converts",
"geodetic",
"to",
"quasi",
"-",
"dipole",
"coordinates",
"."
] | train | https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/apex.py#L276-L302 |
aburrell/apexpy | src/apexpy/apex.py | Apex.qd2geo | def qd2geo(self, qlat, qlon, height, precision=1e-10):
"""Converts quasi-dipole to geodetic coordinates.
Parameters
==========
qlat : array_like
Quasi-dipole latitude
qlon : array_like
Quasi-dipole longitude
height : array_like
Altitud... | python | def qd2geo(self, qlat, qlon, height, precision=1e-10):
"""Converts quasi-dipole to geodetic coordinates.
Parameters
==========
qlat : array_like
Quasi-dipole latitude
qlon : array_like
Quasi-dipole longitude
height : array_like
Altitud... | [
"def",
"qd2geo",
"(",
"self",
",",
"qlat",
",",
"qlon",
",",
"height",
",",
"precision",
"=",
"1e-10",
")",
":",
"qlat",
"=",
"helpers",
".",
"checklat",
"(",
"qlat",
",",
"name",
"=",
"'qlat'",
")",
"glat",
",",
"glon",
",",
"error",
"=",
"self",
... | Converts quasi-dipole to geodetic coordinates.
Parameters
==========
qlat : array_like
Quasi-dipole latitude
qlon : array_like
Quasi-dipole longitude
height : array_like
Altitude in km
precision : float, optional
Precision ... | [
"Converts",
"quasi",
"-",
"dipole",
"to",
"geodetic",
"coordinates",
"."
] | train | https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/apex.py#L304-L341 |
aburrell/apexpy | src/apexpy/apex.py | Apex._apex2qd_nonvectorized | def _apex2qd_nonvectorized(self, alat, alon, height):
"""Convert from apex to quasi-dipole (not-vectorised)
Parameters
-----------
alat : (float)
Apex latitude in degrees
alon : (float)
Apex longitude in degrees
height : (float)
Height... | python | def _apex2qd_nonvectorized(self, alat, alon, height):
"""Convert from apex to quasi-dipole (not-vectorised)
Parameters
-----------
alat : (float)
Apex latitude in degrees
alon : (float)
Apex longitude in degrees
height : (float)
Height... | [
"def",
"_apex2qd_nonvectorized",
"(",
"self",
",",
"alat",
",",
"alon",
",",
"height",
")",
":",
"alat",
"=",
"helpers",
".",
"checklat",
"(",
"alat",
",",
"name",
"=",
"'alat'",
")",
"# convert modified apex to quasi-dipole:",
"qlon",
"=",
"alon",
"# apex hei... | Convert from apex to quasi-dipole (not-vectorised)
Parameters
-----------
alat : (float)
Apex latitude in degrees
alon : (float)
Apex longitude in degrees
height : (float)
Height in km
Returns
---------
qlat : (float)
... | [
"Convert",
"from",
"apex",
"to",
"quasi",
"-",
"dipole",
"(",
"not",
"-",
"vectorised",
")"
] | train | https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/apex.py#L343-L383 |
aburrell/apexpy | src/apexpy/apex.py | Apex.apex2qd | def apex2qd(self, alat, alon, height):
"""Converts modified apex to quasi-dipole coordinates.
Parameters
==========
alat : array_like
Modified apex latitude
alon : array_like
Modified apex longitude
height : array_like
Altitude in km
... | python | def apex2qd(self, alat, alon, height):
"""Converts modified apex to quasi-dipole coordinates.
Parameters
==========
alat : array_like
Modified apex latitude
alon : array_like
Modified apex longitude
height : array_like
Altitude in km
... | [
"def",
"apex2qd",
"(",
"self",
",",
"alat",
",",
"alon",
",",
"height",
")",
":",
"qlat",
",",
"qlon",
"=",
"self",
".",
"_apex2qd",
"(",
"alat",
",",
"alon",
",",
"height",
")",
"# if array is returned, the dtype is object, so convert to float",
"return",
"np... | Converts modified apex to quasi-dipole coordinates.
Parameters
==========
alat : array_like
Modified apex latitude
alon : array_like
Modified apex longitude
height : array_like
Altitude in km
Returns
=======
qlat : nda... | [
"Converts",
"modified",
"apex",
"to",
"quasi",
"-",
"dipole",
"coordinates",
"."
] | train | https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/apex.py#L385-L414 |
aburrell/apexpy | src/apexpy/apex.py | Apex.qd2apex | def qd2apex(self, qlat, qlon, height):
"""Converts quasi-dipole to modified apex coordinates.
Parameters
==========
qlat : array_like
Quasi-dipole latitude
qlon : array_like
Quasi-dipole longitude
height : array_like
Altitude in km
... | python | def qd2apex(self, qlat, qlon, height):
"""Converts quasi-dipole to modified apex coordinates.
Parameters
==========
qlat : array_like
Quasi-dipole latitude
qlon : array_like
Quasi-dipole longitude
height : array_like
Altitude in km
... | [
"def",
"qd2apex",
"(",
"self",
",",
"qlat",
",",
"qlon",
",",
"height",
")",
":",
"alat",
",",
"alon",
"=",
"self",
".",
"_qd2apex",
"(",
"qlat",
",",
"qlon",
",",
"height",
")",
"# if array is returned, the dtype is object, so convert to float",
"return",
"np... | Converts quasi-dipole to modified apex coordinates.
Parameters
==========
qlat : array_like
Quasi-dipole latitude
qlon : array_like
Quasi-dipole longitude
height : array_like
Altitude in km
Returns
=======
alat : ndarr... | [
"Converts",
"quasi",
"-",
"dipole",
"to",
"modified",
"apex",
"coordinates",
"."
] | train | https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/apex.py#L438-L467 |
aburrell/apexpy | src/apexpy/apex.py | Apex.mlon2mlt | def mlon2mlt(self, mlon, datetime, ssheight=50*6371):
"""Computes the magnetic local time at the specified magnetic longitude
and UT.
Parameters
==========
mlon : array_like
Magnetic longitude (apex and quasi-dipole longitude are always
equal)
da... | python | def mlon2mlt(self, mlon, datetime, ssheight=50*6371):
"""Computes the magnetic local time at the specified magnetic longitude
and UT.
Parameters
==========
mlon : array_like
Magnetic longitude (apex and quasi-dipole longitude are always
equal)
da... | [
"def",
"mlon2mlt",
"(",
"self",
",",
"mlon",
",",
"datetime",
",",
"ssheight",
"=",
"50",
"*",
"6371",
")",
":",
"ssglat",
",",
"ssglon",
"=",
"helpers",
".",
"subsol",
"(",
"datetime",
")",
"ssalat",
",",
"ssalon",
"=",
"self",
".",
"geo2apex",
"(",... | Computes the magnetic local time at the specified magnetic longitude
and UT.
Parameters
==========
mlon : array_like
Magnetic longitude (apex and quasi-dipole longitude are always
equal)
datetime : :class:`datetime.datetime`
Date and time
... | [
"Computes",
"the",
"magnetic",
"local",
"time",
"at",
"the",
"specified",
"magnetic",
"longitude",
"and",
"UT",
"."
] | train | https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/apex.py#L469-L503 |
aburrell/apexpy | src/apexpy/apex.py | Apex.mlt2mlon | def mlt2mlon(self, mlt, datetime, ssheight=50*6371):
"""Computes the magnetic longitude at the specified magnetic local time
and UT.
Parameters
==========
mlt : array_like
Magnetic local time
datetime : :class:`datetime.datetime`
Date and time
... | python | def mlt2mlon(self, mlt, datetime, ssheight=50*6371):
"""Computes the magnetic longitude at the specified magnetic local time
and UT.
Parameters
==========
mlt : array_like
Magnetic local time
datetime : :class:`datetime.datetime`
Date and time
... | [
"def",
"mlt2mlon",
"(",
"self",
",",
"mlt",
",",
"datetime",
",",
"ssheight",
"=",
"50",
"*",
"6371",
")",
":",
"ssglat",
",",
"ssglon",
"=",
"helpers",
".",
"subsol",
"(",
"datetime",
")",
"ssalat",
",",
"ssalon",
"=",
"self",
".",
"geo2apex",
"(",
... | Computes the magnetic longitude at the specified magnetic local time
and UT.
Parameters
==========
mlt : array_like
Magnetic local time
datetime : :class:`datetime.datetime`
Date and time
ssheight : float, optional
Altitude in km to us... | [
"Computes",
"the",
"magnetic",
"longitude",
"at",
"the",
"specified",
"magnetic",
"local",
"time",
"and",
"UT",
"."
] | train | https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/apex.py#L505-L539 |
aburrell/apexpy | src/apexpy/apex.py | Apex.map_to_height | def map_to_height(self, glat, glon, height, newheight, conjugate=False,
precision=1e-10):
"""Performs mapping of points along the magnetic field to the closest
or conjugate hemisphere.
Parameters
==========
glat : array_like
Geodetic latitude
... | python | def map_to_height(self, glat, glon, height, newheight, conjugate=False,
precision=1e-10):
"""Performs mapping of points along the magnetic field to the closest
or conjugate hemisphere.
Parameters
==========
glat : array_like
Geodetic latitude
... | [
"def",
"map_to_height",
"(",
"self",
",",
"glat",
",",
"glon",
",",
"height",
",",
"newheight",
",",
"conjugate",
"=",
"False",
",",
"precision",
"=",
"1e-10",
")",
":",
"alat",
",",
"alon",
"=",
"self",
".",
"geo2apex",
"(",
"glat",
",",
"glon",
","... | Performs mapping of points along the magnetic field to the closest
or conjugate hemisphere.
Parameters
==========
glat : array_like
Geodetic latitude
glon : array_like
Geodetic longitude
height : array_like
Source altitude in km
... | [
"Performs",
"mapping",
"of",
"points",
"along",
"the",
"magnetic",
"field",
"to",
"the",
"closest",
"or",
"conjugate",
"hemisphere",
"."
] | train | https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/apex.py#L541-L595 |
aburrell/apexpy | src/apexpy/apex.py | Apex.map_E_to_height | def map_E_to_height(self, alat, alon, height, newheight, E):
"""Performs mapping of electric field along the magnetic field.
It is assumed that the electric field is perpendicular to B.
Parameters
==========
alat : (N,) array_like or float
Modified apex latitude
... | python | def map_E_to_height(self, alat, alon, height, newheight, E):
"""Performs mapping of electric field along the magnetic field.
It is assumed that the electric field is perpendicular to B.
Parameters
==========
alat : (N,) array_like or float
Modified apex latitude
... | [
"def",
"map_E_to_height",
"(",
"self",
",",
"alat",
",",
"alon",
",",
"height",
",",
"newheight",
",",
"E",
")",
":",
"return",
"self",
".",
"_map_EV_to_height",
"(",
"alat",
",",
"alon",
",",
"height",
",",
"newheight",
",",
"E",
",",
"'E'",
")"
] | Performs mapping of electric field along the magnetic field.
It is assumed that the electric field is perpendicular to B.
Parameters
==========
alat : (N,) array_like or float
Modified apex latitude
alon : (N,) array_like or float
Modified apex longitude... | [
"Performs",
"mapping",
"of",
"electric",
"field",
"along",
"the",
"magnetic",
"field",
"."
] | train | https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/apex.py#L642-L669 |
aburrell/apexpy | src/apexpy/apex.py | Apex.map_V_to_height | def map_V_to_height(self, alat, alon, height, newheight, V):
"""Performs mapping of electric drift velocity along the magnetic field.
It is assumed that the electric field is perpendicular to B.
Parameters
==========
alat : (N,) array_like or float
Modified apex lat... | python | def map_V_to_height(self, alat, alon, height, newheight, V):
"""Performs mapping of electric drift velocity along the magnetic field.
It is assumed that the electric field is perpendicular to B.
Parameters
==========
alat : (N,) array_like or float
Modified apex lat... | [
"def",
"map_V_to_height",
"(",
"self",
",",
"alat",
",",
"alon",
",",
"height",
",",
"newheight",
",",
"V",
")",
":",
"return",
"self",
".",
"_map_EV_to_height",
"(",
"alat",
",",
"alon",
",",
"height",
",",
"newheight",
",",
"V",
",",
"'V'",
")"
] | Performs mapping of electric drift velocity along the magnetic field.
It is assumed that the electric field is perpendicular to B.
Parameters
==========
alat : (N,) array_like or float
Modified apex latitude
alon : (N,) array_like or float
Modified apex ... | [
"Performs",
"mapping",
"of",
"electric",
"drift",
"velocity",
"along",
"the",
"magnetic",
"field",
"."
] | train | https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/apex.py#L671-L698 |
aburrell/apexpy | src/apexpy/apex.py | Apex.basevectors_qd | def basevectors_qd(self, lat, lon, height, coords='geo', precision=1e-10):
"""Returns quasi-dipole base vectors f1 and f2 at the specified
coordinates.
The vectors are described by Richmond [1995] [2]_ and
Emmert et al. [2010] [3]_. The vector components are geodetic east and
n... | python | def basevectors_qd(self, lat, lon, height, coords='geo', precision=1e-10):
"""Returns quasi-dipole base vectors f1 and f2 at the specified
coordinates.
The vectors are described by Richmond [1995] [2]_ and
Emmert et al. [2010] [3]_. The vector components are geodetic east and
n... | [
"def",
"basevectors_qd",
"(",
"self",
",",
"lat",
",",
"lon",
",",
"height",
",",
"coords",
"=",
"'geo'",
",",
"precision",
"=",
"1e-10",
")",
":",
"glat",
",",
"glon",
"=",
"self",
".",
"convert",
"(",
"lat",
",",
"lon",
",",
"coords",
",",
"'geo'... | Returns quasi-dipole base vectors f1 and f2 at the specified
coordinates.
The vectors are described by Richmond [1995] [2]_ and
Emmert et al. [2010] [3]_. The vector components are geodetic east and
north.
Parameters
==========
lat : (N,) array_like or float
... | [
"Returns",
"quasi",
"-",
"dipole",
"base",
"vectors",
"f1",
"and",
"f2",
"at",
"the",
"specified",
"coordinates",
"."
] | train | https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/apex.py#L700-L758 |
aburrell/apexpy | src/apexpy/apex.py | Apex.basevectors_apex | def basevectors_apex(self, lat, lon, height, coords='geo', precision=1e-10):
"""Returns base vectors in quasi-dipole and apex coordinates.
The vectors are described by Richmond [1995] [4]_ and
Emmert et al. [2010] [5]_. The vector components are geodetic east,
north, and up (only east ... | python | def basevectors_apex(self, lat, lon, height, coords='geo', precision=1e-10):
"""Returns base vectors in quasi-dipole and apex coordinates.
The vectors are described by Richmond [1995] [4]_ and
Emmert et al. [2010] [5]_. The vector components are geodetic east,
north, and up (only east ... | [
"def",
"basevectors_apex",
"(",
"self",
",",
"lat",
",",
"lon",
",",
"height",
",",
"coords",
"=",
"'geo'",
",",
"precision",
"=",
"1e-10",
")",
":",
"glat",
",",
"glon",
"=",
"self",
".",
"convert",
"(",
"lat",
",",
"lon",
",",
"coords",
",",
"'ge... | Returns base vectors in quasi-dipole and apex coordinates.
The vectors are described by Richmond [1995] [4]_ and
Emmert et al. [2010] [5]_. The vector components are geodetic east,
north, and up (only east and north for `f1` and `f2`).
Parameters
==========
lat, lon : ... | [
"Returns",
"base",
"vectors",
"in",
"quasi",
"-",
"dipole",
"and",
"apex",
"coordinates",
"."
] | train | https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/apex.py#L760-L886 |
aburrell/apexpy | src/apexpy/apex.py | Apex.get_apex | def get_apex(self, lat, height=None):
""" Calculate apex height
Parameters
-----------
lat : (float)
Latitude in degrees
height : (float or NoneType)
Height above the surface of the earth in km or NoneType to use
reference height (default=None... | python | def get_apex(self, lat, height=None):
""" Calculate apex height
Parameters
-----------
lat : (float)
Latitude in degrees
height : (float or NoneType)
Height above the surface of the earth in km or NoneType to use
reference height (default=None... | [
"def",
"get_apex",
"(",
"self",
",",
"lat",
",",
"height",
"=",
"None",
")",
":",
"lat",
"=",
"helpers",
".",
"checklat",
"(",
"lat",
",",
"name",
"=",
"'alat'",
")",
"if",
"height",
"is",
"None",
":",
"height",
"=",
"self",
".",
"refh",
"cos_lat_s... | Calculate apex height
Parameters
-----------
lat : (float)
Latitude in degrees
height : (float or NoneType)
Height above the surface of the earth in km or NoneType to use
reference height (default=None)
Returns
----------
apex... | [
"Calculate",
"apex",
"height"
] | train | https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/apex.py#L888-L911 |
aburrell/apexpy | src/apexpy/apex.py | Apex.set_epoch | def set_epoch(self, year):
"""Updates the epoch for all subsequent conversions.
Parameters
==========
year : float
Decimal year
"""
fa.loadapxsh(self.datafile, np.float(year))
self.year = year | python | def set_epoch(self, year):
"""Updates the epoch for all subsequent conversions.
Parameters
==========
year : float
Decimal year
"""
fa.loadapxsh(self.datafile, np.float(year))
self.year = year | [
"def",
"set_epoch",
"(",
"self",
",",
"year",
")",
":",
"fa",
".",
"loadapxsh",
"(",
"self",
".",
"datafile",
",",
"np",
".",
"float",
"(",
"year",
")",
")",
"self",
".",
"year",
"=",
"year"
] | Updates the epoch for all subsequent conversions.
Parameters
==========
year : float
Decimal year | [
"Updates",
"the",
"epoch",
"for",
"all",
"subsequent",
"conversions",
"."
] | train | https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/apex.py#L913-L924 |
andychase/reparse | reparse/parsers.py | basic_parser | def basic_parser(patterns, with_name=None):
""" Basic ordered parser.
"""
def parse(line):
output = None
highest_order = 0
highest_pattern_name = None
for pattern in patterns:
results = pattern.findall(line)
if results and any(results):
... | python | def basic_parser(patterns, with_name=None):
""" Basic ordered parser.
"""
def parse(line):
output = None
highest_order = 0
highest_pattern_name = None
for pattern in patterns:
results = pattern.findall(line)
if results and any(results):
... | [
"def",
"basic_parser",
"(",
"patterns",
",",
"with_name",
"=",
"None",
")",
":",
"def",
"parse",
"(",
"line",
")",
":",
"output",
"=",
"None",
"highest_order",
"=",
"0",
"highest_pattern_name",
"=",
"None",
"for",
"pattern",
"in",
"patterns",
":",
"results... | Basic ordered parser. | [
"Basic",
"ordered",
"parser",
"."
] | train | https://github.com/andychase/reparse/blob/5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508/reparse/parsers.py#L5-L24 |
andychase/reparse | reparse/parsers.py | alt_parser | def alt_parser(patterns):
""" This parser is able to handle multiple different patterns
finding stuff in text-- while removing matches that overlap.
"""
from reparse.util import remove_lower_overlapping
get_first = lambda items: [i[0] for i in items]
get_second = lambda items: [i[1] for i in... | python | def alt_parser(patterns):
""" This parser is able to handle multiple different patterns
finding stuff in text-- while removing matches that overlap.
"""
from reparse.util import remove_lower_overlapping
get_first = lambda items: [i[0] for i in items]
get_second = lambda items: [i[1] for i in... | [
"def",
"alt_parser",
"(",
"patterns",
")",
":",
"from",
"reparse",
".",
"util",
"import",
"remove_lower_overlapping",
"get_first",
"=",
"lambda",
"items",
":",
"[",
"i",
"[",
"0",
"]",
"for",
"i",
"in",
"items",
"]",
"get_second",
"=",
"lambda",
"items",
... | This parser is able to handle multiple different patterns
finding stuff in text-- while removing matches that overlap. | [
"This",
"parser",
"is",
"able",
"to",
"handle",
"multiple",
"different",
"patterns",
"finding",
"stuff",
"in",
"text",
"--",
"while",
"removing",
"matches",
"that",
"overlap",
"."
] | train | https://github.com/andychase/reparse/blob/5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508/reparse/parsers.py#L27-L43 |
andychase/reparse | reparse/parsers.py | build_tree_parser | def build_tree_parser(patterns):
""" This parser_type simply outputs an array of [(tree, regex)]
for use in another language.
"""
def output():
for pattern in patterns:
yield (pattern.build_full_tree(), pattern.regex)
return list(output()) | python | def build_tree_parser(patterns):
""" This parser_type simply outputs an array of [(tree, regex)]
for use in another language.
"""
def output():
for pattern in patterns:
yield (pattern.build_full_tree(), pattern.regex)
return list(output()) | [
"def",
"build_tree_parser",
"(",
"patterns",
")",
":",
"def",
"output",
"(",
")",
":",
"for",
"pattern",
"in",
"patterns",
":",
"yield",
"(",
"pattern",
".",
"build_full_tree",
"(",
")",
",",
"pattern",
".",
"regex",
")",
"return",
"list",
"(",
"output",... | This parser_type simply outputs an array of [(tree, regex)]
for use in another language. | [
"This",
"parser_type",
"simply",
"outputs",
"an",
"array",
"of",
"[",
"(",
"tree",
"regex",
")",
"]",
"for",
"use",
"in",
"another",
"language",
"."
] | train | https://github.com/andychase/reparse/blob/5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508/reparse/parsers.py#L53-L60 |
andychase/reparse | reparse/parsers.py | parser | def parser(parser_type=basic_parser, functions=None, patterns=None, expressions=None, patterns_yaml_path=None,
expressions_yaml_path=None):
""" A Reparse parser description.
Simply provide the functions, patterns, & expressions to build.
If you are using YAML for expressions + patterns, y... | python | def parser(parser_type=basic_parser, functions=None, patterns=None, expressions=None, patterns_yaml_path=None,
expressions_yaml_path=None):
""" A Reparse parser description.
Simply provide the functions, patterns, & expressions to build.
If you are using YAML for expressions + patterns, y... | [
"def",
"parser",
"(",
"parser_type",
"=",
"basic_parser",
",",
"functions",
"=",
"None",
",",
"patterns",
"=",
"None",
",",
"expressions",
"=",
"None",
",",
"patterns_yaml_path",
"=",
"None",
",",
"expressions_yaml_path",
"=",
"None",
")",
":",
"from",
"repa... | A Reparse parser description.
Simply provide the functions, patterns, & expressions to build.
If you are using YAML for expressions + patterns, you can use
``expressions_yaml_path`` & ``patterns_yaml_path`` for convenience.
The default parser_type is the basic ordered parser. | [
"A",
"Reparse",
"parser",
"description",
".",
"Simply",
"provide",
"the",
"functions",
"patterns",
"&",
"expressions",
"to",
"build",
".",
"If",
"you",
"are",
"using",
"YAML",
"for",
"expressions",
"+",
"patterns",
"you",
"can",
"use",
"expressions_yaml_path",
... | train | https://github.com/andychase/reparse/blob/5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508/reparse/parsers.py#L63-L90 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.