partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
smoothpolygon
smoothed filled polygon
canvasvg.py
def smoothpolygon(document, coords): "smoothed filled polygon" element = document.createElement('path') path = [] points = [(coords[i], coords[i+1]) for i in range(0, len(coords), 2)] def pt(points): p = points n = len(points) for i in range(0, len(points)): a = p[(i-1) % n] b = p[i] c = p[(i...
def smoothpolygon(document, coords): "smoothed filled polygon" element = document.createElement('path') path = [] points = [(coords[i], coords[i+1]) for i in range(0, len(coords), 2)] def pt(points): p = points n = len(points) for i in range(0, len(points)): a = p[(i-1) % n] b = p[i] c = p[(i...
[ "smoothed", "filled", "polygon" ]
WojciechMula/canvas2svg
python
https://github.com/WojciechMula/canvas2svg/blob/c05d73d88499e5c565386a1765f79d9417a14dac/canvasvg.py#L472-L497
[ "def", "smoothpolygon", "(", "document", ",", "coords", ")", ":", "element", "=", "document", ".", "createElement", "(", "'path'", ")", "path", "=", "[", "]", "points", "=", "[", "(", "coords", "[", "i", "]", ",", "coords", "[", "i", "+", "1", "]",...
c05d73d88499e5c565386a1765f79d9417a14dac
train
oval
circle/ellipse
canvasvg.py
def oval(document, coords): "circle/ellipse" x1, y1, x2, y2 = coords # circle if x2-x1 == y2-y1: return setattribs(document.createElement('circle'), cx = (x1+x2)/2, cy = (y1+y2)/2, r = abs(x2-x1)/2, ) # ellipse else: return setattribs(document.createElement('ellipse'), cx = (x1+x2)/2, cy ...
def oval(document, coords): "circle/ellipse" x1, y1, x2, y2 = coords # circle if x2-x1 == y2-y1: return setattribs(document.createElement('circle'), cx = (x1+x2)/2, cy = (y1+y2)/2, r = abs(x2-x1)/2, ) # ellipse else: return setattribs(document.createElement('ellipse'), cx = (x1+x2)/2, cy ...
[ "circle", "/", "ellipse" ]
WojciechMula/canvas2svg
python
https://github.com/WojciechMula/canvas2svg/blob/c05d73d88499e5c565386a1765f79d9417a14dac/canvasvg.py#L510-L531
[ "def", "oval", "(", "document", ",", "coords", ")", ":", "x1", ",", "y1", ",", "x2", ",", "y2", "=", "coords", "# circle", "if", "x2", "-", "x1", "==", "y2", "-", "y1", ":", "return", "setattribs", "(", "document", ".", "createElement", "(", "'circ...
c05d73d88499e5c565386a1765f79d9417a14dac
train
arc
arc, pieslice (filled), arc with chord (filled)
canvasvg.py
def arc(document, bounding_rect, start, extent, style): "arc, pieslice (filled), arc with chord (filled)" (x1, y1, x2, y2) = bounding_rect import math cx = (x1 + x2)/2.0 cy = (y1 + y2)/2.0 rx = (x2 - x1)/2.0 ry = (y2 - y1)/2.0 start = math.radians(float(start)) extent = math.radians(float(extent)) # fr...
def arc(document, bounding_rect, start, extent, style): "arc, pieslice (filled), arc with chord (filled)" (x1, y1, x2, y2) = bounding_rect import math cx = (x1 + x2)/2.0 cy = (y1 + y2)/2.0 rx = (x2 - x1)/2.0 ry = (y2 - y1)/2.0 start = math.radians(float(start)) extent = math.radians(float(extent)) # fr...
[ "arc", "pieslice", "(", "filled", ")", "arc", "with", "chord", "(", "filled", ")" ]
WojciechMula/canvas2svg
python
https://github.com/WojciechMula/canvas2svg/blob/c05d73d88499e5c565386a1765f79d9417a14dac/canvasvg.py#L534-L581
[ "def", "arc", "(", "document", ",", "bounding_rect", ",", "start", ",", "extent", ",", "style", ")", ":", "(", "x1", ",", "y1", ",", "x2", ",", "y2", ")", "=", "bounding_rect", "import", "math", "cx", "=", "(", "x1", "+", "x2", ")", "/", "2.0", ...
c05d73d88499e5c565386a1765f79d9417a14dac
train
HTMLcolor
returns Tk color in form '#rrggbb' or '#rgb
canvasvg.py
def HTMLcolor(canvas, color): "returns Tk color in form '#rrggbb' or '#rgb'" if color: # r, g, b \in [0..2**16] r, g, b = ["%02x" % (c // 256) for c in canvas.winfo_rgb(color)] if (r[0] == r[1]) and (g[0] == g[1]) and (b[0] == b[1]): # shorter form #rgb return "#" + r[0] + g[0] + b[0] else: return ...
def HTMLcolor(canvas, color): "returns Tk color in form '#rrggbb' or '#rgb'" if color: # r, g, b \in [0..2**16] r, g, b = ["%02x" % (c // 256) for c in canvas.winfo_rgb(color)] if (r[0] == r[1]) and (g[0] == g[1]) and (b[0] == b[1]): # shorter form #rgb return "#" + r[0] + g[0] + b[0] else: return ...
[ "returns", "Tk", "color", "in", "form", "#rrggbb", "or", "#rgb" ]
WojciechMula/canvas2svg
python
https://github.com/WojciechMula/canvas2svg/blob/c05d73d88499e5c565386a1765f79d9417a14dac/canvasvg.py#L599-L612
[ "def", "HTMLcolor", "(", "canvas", ",", "color", ")", ":", "if", "color", ":", "# r, g, b \\in [0..2**16]", "r", ",", "g", ",", "b", "=", "[", "\"%02x\"", "%", "(", "c", "//", "256", ")", "for", "c", "in", "canvas", ".", "winfo_rgb", "(", "color", ...
c05d73d88499e5c565386a1765f79d9417a14dac
train
arrow_head
make arrow head at (x1,y1), arrowshape is tuple (d1, d2, d3)
canvasvg.py
def arrow_head(document, x0, y0, x1, y1, arrowshape): "make arrow head at (x1,y1), arrowshape is tuple (d1, d2, d3)" import math dx = x1 - x0 dy = y1 - y0 poly = document.createElement('polygon') d = math.sqrt(dx*dx + dy*dy) if d == 0.0: # XXX: equal, no "close enough" return poly try: d1, d2, d3 = l...
def arrow_head(document, x0, y0, x1, y1, arrowshape): "make arrow head at (x1,y1), arrowshape is tuple (d1, d2, d3)" import math dx = x1 - x0 dy = y1 - y0 poly = document.createElement('polygon') d = math.sqrt(dx*dx + dy*dy) if d == 0.0: # XXX: equal, no "close enough" return poly try: d1, d2, d3 = l...
[ "make", "arrow", "head", "at", "(", "x1", "y1", ")", "arrowshape", "is", "tuple", "(", "d1", "d2", "d3", ")" ]
WojciechMula/canvas2svg
python
https://github.com/WojciechMula/canvas2svg/blob/c05d73d88499e5c565386a1765f79d9417a14dac/canvasvg.py#L615-L648
[ "def", "arrow_head", "(", "document", ",", "x0", ",", "y0", ",", "x1", ",", "y1", ",", "arrowshape", ")", ":", "import", "math", "dx", "=", "x1", "-", "x0", "dy", "=", "y1", "-", "y0", "poly", "=", "document", ".", "createElement", "(", "'polygon'"...
c05d73d88499e5c565386a1765f79d9417a14dac
train
font_actual
actual font parameters
canvasvg.py
def font_actual(tkapp, font): "actual font parameters" tmp = tkapp.call('font', 'actual', font) return dict( (tmp[i][1:], tmp[i+1]) for i in range(0, len(tmp), 2) )
def font_actual(tkapp, font): "actual font parameters" tmp = tkapp.call('font', 'actual', font) return dict( (tmp[i][1:], tmp[i+1]) for i in range(0, len(tmp), 2) )
[ "actual", "font", "parameters" ]
WojciechMula/canvas2svg
python
https://github.com/WojciechMula/canvas2svg/blob/c05d73d88499e5c565386a1765f79d9417a14dac/canvasvg.py#L651-L656
[ "def", "font_actual", "(", "tkapp", ",", "font", ")", ":", "tmp", "=", "tkapp", ".", "call", "(", "'font'", ",", "'actual'", ",", "font", ")", "return", "dict", "(", "(", "tmp", "[", "i", "]", "[", "1", ":", "]", ",", "tmp", "[", "i", "+", "1...
c05d73d88499e5c565386a1765f79d9417a14dac
train
parse_dash
parse dash pattern specified with string
canvasvg.py
def parse_dash(string, width): "parse dash pattern specified with string" # DashConvert from {tk-sources}/generic/tkCanvUtil.c w = max(1, int(width + 0.5)) n = len(string) result = [] for i, c in enumerate(string): if c == " " and len(result): result[-1] += w + 1 elif c == "_": result.append(8*w) ...
def parse_dash(string, width): "parse dash pattern specified with string" # DashConvert from {tk-sources}/generic/tkCanvUtil.c w = max(1, int(width + 0.5)) n = len(string) result = [] for i, c in enumerate(string): if c == " " and len(result): result[-1] += w + 1 elif c == "_": result.append(8*w) ...
[ "parse", "dash", "pattern", "specified", "with", "string" ]
WojciechMula/canvas2svg
python
https://github.com/WojciechMula/canvas2svg/blob/c05d73d88499e5c565386a1765f79d9417a14dac/canvasvg.py#L668-L691
[ "def", "parse_dash", "(", "string", ",", "width", ")", ":", "# DashConvert from {tk-sources}/generic/tkCanvUtil.c", "w", "=", "max", "(", "1", ",", "int", "(", "width", "+", "0.5", ")", ")", "n", "=", "len", "(", "string", ")", "result", "=", "[", "]", ...
c05d73d88499e5c565386a1765f79d9417a14dac
train
prof_altitude
Return altitude for given pressure. This function evaluates a polynomial at log10(pressure) values. Parameters ---------- pressure : array-like pressure values [hPa]. p_coef : array-like coefficients of the polynomial (default values are for the US Standard Atmosphere). ...
xbpch/util/gridspec.py
def prof_altitude(pressure, p_coef=(-0.028389, -0.0493698, 0.485718, 0.278656, -17.5703, 48.0926)): """ Return altitude for given pressure. This function evaluates a polynomial at log10(pressure) values. Parameters ---------- pressure : array-like pr...
def prof_altitude(pressure, p_coef=(-0.028389, -0.0493698, 0.485718, 0.278656, -17.5703, 48.0926)): """ Return altitude for given pressure. This function evaluates a polynomial at log10(pressure) values. Parameters ---------- pressure : array-like pr...
[ "Return", "altitude", "for", "given", "pressure", "." ]
darothen/xbpch
python
https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/util/gridspec.py#L477-L519
[ "def", "prof_altitude", "(", "pressure", ",", "p_coef", "=", "(", "-", "0.028389", ",", "-", "0.0493698", ",", "0.485718", ",", "0.278656", ",", "-", "17.5703", ",", "48.0926", ")", ")", ":", "pressure", "=", "np", ".", "asarray", "(", "pressure", ")",...
31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5
train
prof_pressure
Return pressure for given altitude. This function evaluates a polynomial at altitudes values. Parameters ---------- altitude : array-like altitude values [km]. z_coef : array-like coefficients of the polynomial (default values are for the US Standard Atmosphere). Retur...
xbpch/util/gridspec.py
def prof_pressure(altitude, z_coef=(1.94170e-9, -5.14580e-7, 4.57018e-5, -1.55620e-3, -4.61994e-2, 2.99955)): """ Return pressure for given altitude. This function evaluates a polynomial at altitudes values. Parameters ---------- altitude : array-like ...
def prof_pressure(altitude, z_coef=(1.94170e-9, -5.14580e-7, 4.57018e-5, -1.55620e-3, -4.61994e-2, 2.99955)): """ Return pressure for given altitude. This function evaluates a polynomial at altitudes values. Parameters ---------- altitude : array-like ...
[ "Return", "pressure", "for", "given", "altitude", "." ]
darothen/xbpch
python
https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/util/gridspec.py#L522-L564
[ "def", "prof_pressure", "(", "altitude", ",", "z_coef", "=", "(", "1.94170e-9", ",", "-", "5.14580e-7", ",", "4.57018e-5", ",", "-", "1.55620e-3", ",", "-", "4.61994e-2", ",", "2.99955", ")", ")", ":", "altitude", "=", "np", ".", "asarray", "(", "altitud...
31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5
train
_find_references
Iterate over model references for `model_name` and return a list of parent model specifications (including those of `model_name`, ordered from parent to child).
xbpch/util/gridspec.py
def _find_references(model_name, references=None): """ Iterate over model references for `model_name` and return a list of parent model specifications (including those of `model_name`, ordered from parent to child). """ references = references or [] references.append(model_name) ref = M...
def _find_references(model_name, references=None): """ Iterate over model references for `model_name` and return a list of parent model specifications (including those of `model_name`, ordered from parent to child). """ references = references or [] references.append(model_name) ref = M...
[ "Iterate", "over", "model", "references", "for", "model_name", "and", "return", "a", "list", "of", "parent", "model", "specifications", "(", "including", "those", "of", "model_name", "ordered", "from", "parent", "to", "child", ")", "." ]
darothen/xbpch
python
https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/util/gridspec.py#L575-L591
[ "def", "_find_references", "(", "model_name", ",", "references", "=", "None", ")", ":", "references", "=", "references", "or", "[", "]", "references", ".", "append", "(", "model_name", ")", "ref", "=", "MODELS", "[", "model_name", "]", ".", "get", "(", "...
31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5
train
_get_model_info
Get the grid specifications for a given model. Parameters ---------- model_name : string Name of the model. Supports multiple formats (e.g., 'GEOS5', 'GEOS-5' or 'GEOS_5'). Returns ------- specifications : dict Grid specifications as a dictionary. Raises ------...
xbpch/util/gridspec.py
def _get_model_info(model_name): """ Get the grid specifications for a given model. Parameters ---------- model_name : string Name of the model. Supports multiple formats (e.g., 'GEOS5', 'GEOS-5' or 'GEOS_5'). Returns ------- specifications : dict Grid specifica...
def _get_model_info(model_name): """ Get the grid specifications for a given model. Parameters ---------- model_name : string Name of the model. Supports multiple formats (e.g., 'GEOS5', 'GEOS-5' or 'GEOS_5'). Returns ------- specifications : dict Grid specifica...
[ "Get", "the", "grid", "specifications", "for", "a", "given", "model", "." ]
darothen/xbpch
python
https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/util/gridspec.py#L594-L646
[ "def", "_get_model_info", "(", "model_name", ")", ":", "# trying to get as much as possible a valid model name from the given", "# `model_name`, using regular expressions.", "split_name", "=", "re", ".", "split", "(", "r'[\\-_\\s]'", ",", "model_name", ".", "strip", "(", ")",...
31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5
train
_get_archive_filelist
Extract the list of files from a tar or zip archive. Args: filename: name of the archive Returns: Sorted list of files in the archive, excluding './' Raises: ValueError: when the file is neither a zip nor a tar archive FileNotFoundError: when the provided file does not exi...
py2pack/utils.py
def _get_archive_filelist(filename): # type: (str) -> List[str] """Extract the list of files from a tar or zip archive. Args: filename: name of the archive Returns: Sorted list of files in the archive, excluding './' Raises: ValueError: when the file is neither a zip nor a...
def _get_archive_filelist(filename): # type: (str) -> List[str] """Extract the list of files from a tar or zip archive. Args: filename: name of the archive Returns: Sorted list of files in the archive, excluding './' Raises: ValueError: when the file is neither a zip nor a...
[ "Extract", "the", "list", "of", "files", "from", "a", "tar", "or", "zip", "archive", "." ]
openSUSE/py2pack
python
https://github.com/openSUSE/py2pack/blob/4ff689900dd2c1a390b5359ce1037c188b75fc65/py2pack/utils.py#L26-L53
[ "def", "_get_archive_filelist", "(", "filename", ")", ":", "# type: (str) -> List[str]", "names", "=", "[", "]", "# type: List[str]", "if", "tarfile", ".", "is_tarfile", "(", "filename", ")", ":", "with", "tarfile", ".", "open", "(", "filename", ")", "as", "ta...
4ff689900dd2c1a390b5359ce1037c188b75fc65
train
Manager._augment_book
Checks if the newly created object is a book and only has an ISBN. If so, tries to fetch the book data off the internet. :param uuid: uuid of book to augment :param client: requesting client
modules/library/hfos/library/manager.py
def _augment_book(self, uuid, event): """ Checks if the newly created object is a book and only has an ISBN. If so, tries to fetch the book data off the internet. :param uuid: uuid of book to augment :param client: requesting client """ try: if not is...
def _augment_book(self, uuid, event): """ Checks if the newly created object is a book and only has an ISBN. If so, tries to fetch the book data off the internet. :param uuid: uuid of book to augment :param client: requesting client """ try: if not is...
[ "Checks", "if", "the", "newly", "created", "object", "is", "a", "book", "and", "only", "has", "an", "ISBN", ".", "If", "so", "tries", "to", "fetch", "the", "book", "data", "off", "the", "internet", "." ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/library/hfos/library/manager.py#L141-L215
[ "def", "_augment_book", "(", "self", ",", "uuid", ",", "event", ")", ":", "try", ":", "if", "not", "isbnmeta", ":", "self", ".", "log", "(", "\"No isbntools found! Install it to get full \"", "\"functionality!\"", ",", "lvl", "=", "warn", ")", "return", "new_b...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
serial_ports
Lists serial port names :raises EnvironmentError: On unsupported or unknown platforms :returns: A list of the serial ports available on the system Courtesy: Thomas ( http://stackoverflow.com/questions/12090503 /listing-available-com-ports-with-python )
modules/robot/hfos/robot/machineroom.py
def serial_ports(): """ Lists serial port names :raises EnvironmentError: On unsupported or unknown platforms :returns: A list of the serial ports available on the system Courtesy: Thomas ( http://stackoverflow.com/questions/12090503 /listing-available-com-p...
def serial_ports(): """ Lists serial port names :raises EnvironmentError: On unsupported or unknown platforms :returns: A list of the serial ports available on the system Courtesy: Thomas ( http://stackoverflow.com/questions/12090503 /listing-available-com-p...
[ "Lists", "serial", "port", "names" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/robot/hfos/robot/machineroom.py#L58-L87
[ "def", "serial_ports", "(", ")", ":", "if", "sys", ".", "platform", ".", "startswith", "(", "'win'", ")", ":", "ports", "=", "[", "'COM%s'", "%", "(", "i", "+", "1", ")", "for", "i", "in", "range", "(", "256", ")", "]", "elif", "sys", ".", "pla...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
Machineroom.opened
Initiates communication with the remote controlled device. :param args:
modules/robot/hfos/robot/machineroom.py
def opened(self, *args): """Initiates communication with the remote controlled device. :param args: """ self._serial_open = True self.log("Opened: ", args, lvl=debug) self._send_command(b'l,1') # Saying hello, shortly self.log("Turning off engine, pump and neut...
def opened(self, *args): """Initiates communication with the remote controlled device. :param args: """ self._serial_open = True self.log("Opened: ", args, lvl=debug) self._send_command(b'l,1') # Saying hello, shortly self.log("Turning off engine, pump and neut...
[ "Initiates", "communication", "with", "the", "remote", "controlled", "device", "." ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/robot/hfos/robot/machineroom.py#L172-L188
[ "def", "opened", "(", "self", ",", "*", "args", ")", ":", "self", ".", "_serial_open", "=", "True", "self", ".", "log", "(", "\"Opened: \"", ",", "args", ",", "lvl", "=", "debug", ")", "self", ".", "_send_command", "(", "b'l,1'", ")", "# Saying hello, ...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
Machineroom.on_machinerequest
Sets a new machine speed. :param event:
modules/robot/hfos/robot/machineroom.py
def on_machinerequest(self, event): """ Sets a new machine speed. :param event: """ self.log("Updating new machine power: ", event.controlvalue) self._handle_servo(self._machine_channel, event.controlvalue)
def on_machinerequest(self, event): """ Sets a new machine speed. :param event: """ self.log("Updating new machine power: ", event.controlvalue) self._handle_servo(self._machine_channel, event.controlvalue)
[ "Sets", "a", "new", "machine", "speed", "." ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/robot/hfos/robot/machineroom.py#L221-L228
[ "def", "on_machinerequest", "(", "self", ",", "event", ")", ":", "self", ".", "log", "(", "\"Updating new machine power: \"", ",", "event", ".", "controlvalue", ")", "self", ".", "_handle_servo", "(", "self", ".", "_machine_channel", ",", "event", ".", "contro...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
Machineroom.on_rudderrequest
Sets a new rudder angle. :param event:
modules/robot/hfos/robot/machineroom.py
def on_rudderrequest(self, event): """ Sets a new rudder angle. :param event: """ self.log("Updating new rudder angle: ", event.controlvalue) self._handle_servo(self._rudder_channel, event.controlvalue)
def on_rudderrequest(self, event): """ Sets a new rudder angle. :param event: """ self.log("Updating new rudder angle: ", event.controlvalue) self._handle_servo(self._rudder_channel, event.controlvalue)
[ "Sets", "a", "new", "rudder", "angle", "." ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/robot/hfos/robot/machineroom.py#L231-L238
[ "def", "on_rudderrequest", "(", "self", ",", "event", ")", ":", "self", ".", "log", "(", "\"Updating new rudder angle: \"", ",", "event", ".", "controlvalue", ")", "self", ".", "_handle_servo", "(", "self", ".", "_rudder_channel", ",", "event", ".", "controlva...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
Machineroom.on_pumprequest
Activates or deactivates a connected pump. :param event:
modules/robot/hfos/robot/machineroom.py
def on_pumprequest(self, event): """ Activates or deactivates a connected pump. :param event: """ self.log("Updating pump status: ", event.controlvalue) self._set_digital_pin(self._pump_channel, event.controlvalue)
def on_pumprequest(self, event): """ Activates or deactivates a connected pump. :param event: """ self.log("Updating pump status: ", event.controlvalue) self._set_digital_pin(self._pump_channel, event.controlvalue)
[ "Activates", "or", "deactivates", "a", "connected", "pump", "." ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/robot/hfos/robot/machineroom.py#L241-L248
[ "def", "on_pumprequest", "(", "self", ",", "event", ")", ":", "self", ".", "log", "(", "\"Updating pump status: \"", ",", "event", ".", "controlvalue", ")", "self", ".", "_set_digital_pin", "(", "self", ".", "_pump_channel", ",", "event", ".", "controlvalue", ...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
provisionList
Provisions a list of items according to their schema :param items: A list of provisionable items. :param database_object: A warmongo database object :param overwrite: Causes existing items to be overwritten :param clear: Clears the collection first (Danger!) :param skip_user_check: Skips checking i...
hfos/provisions/base.py
def provisionList(items, database_name, overwrite=False, clear=False, skip_user_check=False): """Provisions a list of items according to their schema :param items: A list of provisionable items. :param database_object: A warmongo database object :param overwrite: Causes existing items to be overwritten...
def provisionList(items, database_name, overwrite=False, clear=False, skip_user_check=False): """Provisions a list of items according to their schema :param items: A list of provisionable items. :param database_object: A warmongo database object :param overwrite: Causes existing items to be overwritten...
[ "Provisions", "a", "list", "of", "items", "according", "to", "their", "schema" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/provisions/base.py#L48-L148
[ "def", "provisionList", "(", "items", ",", "database_name", ",", "overwrite", "=", "False", ",", "clear", "=", "False", ",", "skip_user_check", "=", "False", ")", ":", "log", "(", "'Provisioning'", ",", "items", ",", "database_name", ",", "lvl", "=", "debu...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
DefaultExtension
Create a default field
hfos/schemata/extends.py
def DefaultExtension(schema_obj, form_obj, schemata=None): """Create a default field""" if schemata is None: schemata = ['systemconfig', 'profile', 'client'] DefaultExtends = { 'schema': { "properties/modules": [ schema_obj ] }, 'form...
def DefaultExtension(schema_obj, form_obj, schemata=None): """Create a default field""" if schemata is None: schemata = ['systemconfig', 'profile', 'client'] DefaultExtends = { 'schema': { "properties/modules": [ schema_obj ] }, 'form...
[ "Create", "a", "default", "field" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/schemata/extends.py#L25-L49
[ "def", "DefaultExtension", "(", "schema_obj", ",", "form_obj", ",", "schemata", "=", "None", ")", ":", "if", "schemata", "is", "None", ":", "schemata", "=", "[", "'systemconfig'", ",", "'profile'", ",", "'client'", "]", "DefaultExtends", "=", "{", "'schema'"...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
copytree
Copies a whole directory tree
hfos/ui/builder.py
def copytree(root_src_dir, root_dst_dir, hardlink=True): """Copies a whole directory tree""" for src_dir, dirs, files in os.walk(root_src_dir): dst_dir = src_dir.replace(root_src_dir, root_dst_dir, 1) if not os.path.exists(dst_dir): os.makedirs(dst_dir) for file_ in files: ...
def copytree(root_src_dir, root_dst_dir, hardlink=True): """Copies a whole directory tree""" for src_dir, dirs, files in os.walk(root_src_dir): dst_dir = src_dir.replace(root_src_dir, root_dst_dir, 1) if not os.path.exists(dst_dir): os.makedirs(dst_dir) for file_ in files: ...
[ "Copies", "a", "whole", "directory", "tree" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/builder.py#L41-L79
[ "def", "copytree", "(", "root_src_dir", ",", "root_dst_dir", ",", "hardlink", "=", "True", ")", ":", "for", "src_dir", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "root_src_dir", ")", ":", "dst_dir", "=", "src_dir", ".", "replace", "(", "r...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
install_frontend
Builds and installs the frontend
hfos/ui/builder.py
def install_frontend(instance='default', forcereload=False, forcerebuild=False, forcecopy=True, install=True, development=False, build_type='dist'): """Builds and installs the frontend""" hfoslog("Updating frontend components", emitter='BUILDER') components = {} loadable_components...
def install_frontend(instance='default', forcereload=False, forcerebuild=False, forcecopy=True, install=True, development=False, build_type='dist'): """Builds and installs the frontend""" hfoslog("Updating frontend components", emitter='BUILDER') components = {} loadable_components...
[ "Builds", "and", "installs", "the", "frontend" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/builder.py#L83-L281
[ "def", "install_frontend", "(", "instance", "=", "'default'", ",", "forcereload", "=", "False", ",", "forcerebuild", "=", "False", ",", "forcecopy", "=", "True", ",", "install", "=", "True", ",", "development", "=", "False", ",", "build_type", "=", "'dist'",...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
config
[GROUP] Configuration management operations
hfos/tool/configuration.py
def config(ctx): """[GROUP] Configuration management operations""" from hfos import database database.initialize(ctx.obj['dbhost'], ctx.obj['dbname']) from hfos.schemata.component import ComponentConfigSchemaTemplate ctx.obj['col'] = model_factory(ComponentConfigSchemaTemplate)
def config(ctx): """[GROUP] Configuration management operations""" from hfos import database database.initialize(ctx.obj['dbhost'], ctx.obj['dbname']) from hfos.schemata.component import ComponentConfigSchemaTemplate ctx.obj['col'] = model_factory(ComponentConfigSchemaTemplate)
[ "[", "GROUP", "]", "Configuration", "management", "operations" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/configuration.py#L35-L42
[ "def", "config", "(", "ctx", ")", ":", "from", "hfos", "import", "database", "database", ".", "initialize", "(", "ctx", ".", "obj", "[", "'dbhost'", "]", ",", "ctx", ".", "obj", "[", "'dbname'", "]", ")", "from", "hfos", ".", "schemata", ".", "compon...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
delete
Delete an existing component configuration. This will trigger the creation of its default configuration upon next restart.
hfos/tool/configuration.py
def delete(ctx, componentname): """Delete an existing component configuration. This will trigger the creation of its default configuration upon next restart.""" col = ctx.obj['col'] if col.count({'name': componentname}) > 1: log('More than one component configuration of this name! Try ' ...
def delete(ctx, componentname): """Delete an existing component configuration. This will trigger the creation of its default configuration upon next restart.""" col = ctx.obj['col'] if col.count({'name': componentname}) > 1: log('More than one component configuration of this name! Try ' ...
[ "Delete", "an", "existing", "component", "configuration", ".", "This", "will", "trigger", "the", "creation", "of", "its", "default", "configuration", "upon", "next", "restart", "." ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/configuration.py#L48-L73
[ "def", "delete", "(", "ctx", ",", "componentname", ")", ":", "col", "=", "ctx", ".", "obj", "[", "'col'", "]", "if", "col", ".", "count", "(", "{", "'name'", ":", "componentname", "}", ")", ">", "1", ":", "log", "(", "'More than one component configura...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
show
Show the stored, active configuration of a component.
hfos/tool/configuration.py
def show(ctx, component): """Show the stored, active configuration of a component.""" col = ctx.obj['col'] if col.count({'name': component}) > 1: log('More than one component configuration of this name! Try ' 'one of the uuids as argument. Get a list with "config ' 'list"')...
def show(ctx, component): """Show the stored, active configuration of a component.""" col = ctx.obj['col'] if col.count({'name': component}) > 1: log('More than one component configuration of this name! Try ' 'one of the uuids as argument. Get a list with "config ' 'list"')...
[ "Show", "the", "stored", "active", "configuration", "of", "a", "component", "." ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/configuration.py#L79-L106
[ "def", "show", "(", "ctx", ",", "component", ")", ":", "col", "=", "ctx", ".", "obj", "[", "'col'", "]", "if", "col", ".", "count", "(", "{", "'name'", ":", "component", "}", ")", ">", "1", ":", "log", "(", "'More than one component configuration of th...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
separate_string
>>> separate_string("test <2>") (['test ', ''], ['2'])
reparse/util.py
def separate_string(string): """ >>> separate_string("test <2>") (['test ', ''], ['2']) """ string_list = regex.split(r'<(?![!=])', regex.sub(r'>', '<', string)) return string_list[::2], string_list[1::2]
def separate_string(string): """ >>> separate_string("test <2>") (['test ', ''], ['2']) """ string_list = regex.split(r'<(?![!=])', regex.sub(r'>', '<', string)) return string_list[::2], string_list[1::2]
[ ">>>", "separate_string", "(", "test", "<2", ">", ")", "(", "[", "test", "]", "[", "2", "]", ")" ]
andychase/reparse
python
https://github.com/andychase/reparse/blob/5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508/reparse/util.py#L3-L9
[ "def", "separate_string", "(", "string", ")", ":", "string_list", "=", "regex", ".", "split", "(", "r'<(?![!=])'", ",", "regex", ".", "sub", "(", "r'>'", ",", "'<'", ",", "string", ")", ")", "return", "string_list", "[", ":", ":", "2", "]", ",", "str...
5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508
train
overlapping
>>> overlapping(0, 5, 6, 7) False >>> overlapping(1, 2, 0, 4) True >>> overlapping(5,6,0,5) False
reparse/util.py
def overlapping(start1, end1, start2, end2): """ >>> overlapping(0, 5, 6, 7) False >>> overlapping(1, 2, 0, 4) True >>> overlapping(5,6,0,5) False """ return not ((start1 <= start2 and start1 <= end2 and end1 <= end2 and end1 <= start2) or (start1 >= start2 and start1...
def overlapping(start1, end1, start2, end2): """ >>> overlapping(0, 5, 6, 7) False >>> overlapping(1, 2, 0, 4) True >>> overlapping(5,6,0,5) False """ return not ((start1 <= start2 and start1 <= end2 and end1 <= end2 and end1 <= start2) or (start1 >= start2 and start1...
[ ">>>", "overlapping", "(", "0", "5", "6", "7", ")", "False", ">>>", "overlapping", "(", "1", "2", "0", "4", ")", "True", ">>>", "overlapping", "(", "5", "6", "0", "5", ")", "False" ]
andychase/reparse
python
https://github.com/andychase/reparse/blob/5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508/reparse/util.py#L12-L22
[ "def", "overlapping", "(", "start1", ",", "end1", ",", "start2", ",", "end2", ")", ":", "return", "not", "(", "(", "start1", "<=", "start2", "and", "start1", "<=", "end2", "and", "end1", "<=", "end2", "and", "end1", "<=", "start2", ")", "or", "(", ...
5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508
train
remove_lower_overlapping
>>> remove_lower_overlapping([], [('a', 0, 5)]) [('a', 0, 5)] >>> remove_lower_overlapping([('z', 0, 4)], [('a', 0, 5)]) [('a', 0, 5)] >>> remove_lower_overlapping([('z', 5, 6)], [('a', 0, 5)]) [('z', 5, 6), ('a', 0, 5)]
reparse/util.py
def remove_lower_overlapping(current, higher): """ >>> remove_lower_overlapping([], [('a', 0, 5)]) [('a', 0, 5)] >>> remove_lower_overlapping([('z', 0, 4)], [('a', 0, 5)]) [('a', 0, 5)] >>> remove_lower_overlapping([('z', 5, 6)], [('a', 0, 5)]) [('z', 5, 6), ('a', 0, 5)] """ for (mat...
def remove_lower_overlapping(current, higher): """ >>> remove_lower_overlapping([], [('a', 0, 5)]) [('a', 0, 5)] >>> remove_lower_overlapping([('z', 0, 4)], [('a', 0, 5)]) [('a', 0, 5)] >>> remove_lower_overlapping([('z', 5, 6)], [('a', 0, 5)]) [('z', 5, 6), ('a', 0, 5)] """ for (mat...
[ ">>>", "remove_lower_overlapping", "(", "[]", "[", "(", "a", "0", "5", ")", "]", ")", "[", "(", "a", "0", "5", ")", "]", ">>>", "remove_lower_overlapping", "(", "[", "(", "z", "0", "4", ")", "]", "[", "(", "a", "0", "5", ")", "]", ")", "[", ...
andychase/reparse
python
https://github.com/andychase/reparse/blob/5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508/reparse/util.py#L31-L50
[ "def", "remove_lower_overlapping", "(", "current", ",", "higher", ")", ":", "for", "(", "match", ",", "h_start", ",", "h_end", ")", "in", "higher", ":", "overlaps", "=", "list", "(", "overlapping_at", "(", "h_start", ",", "h_end", ",", "current", ")", ")...
5f46cdd0fc4e239c0ddeca4b542e48a5ae95c508
train
HFDebugger.debugrequest
Handler for client-side debug requests
hfos/debugger.py
def debugrequest(self, event): """Handler for client-side debug requests""" try: self.log("Event: ", event.__dict__, lvl=critical) if event.data == "storejson": self.log("Storing received object to /tmp", lvl=critical) fp = open('/tmp/hfosdebugger...
def debugrequest(self, event): """Handler for client-side debug requests""" try: self.log("Event: ", event.__dict__, lvl=critical) if event.data == "storejson": self.log("Storing received object to /tmp", lvl=critical) fp = open('/tmp/hfosdebugger...
[ "Handler", "for", "client", "-", "side", "debug", "requests" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/debugger.py#L223-L264
[ "def", "debugrequest", "(", "self", ",", "event", ")", ":", "try", ":", "self", ".", "log", "(", "\"Event: \"", ",", "event", ".", "__dict__", ",", "lvl", "=", "critical", ")", "if", "event", ".", "data", "==", "\"storejson\"", ":", "self", ".", "log...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
CLI.stdin_read
read Event (on channel ``stdin``) This is the event handler for ``read`` events specifically from the ``stdin`` channel. This is triggered each time stdin has data that it has read.
hfos/debugger.py
def stdin_read(self, data): """read Event (on channel ``stdin``) This is the event handler for ``read`` events specifically from the ``stdin`` channel. This is triggered each time stdin has data that it has read. """ data = data.strip().decode("utf-8") self.log("...
def stdin_read(self, data): """read Event (on channel ``stdin``) This is the event handler for ``read`` events specifically from the ``stdin`` channel. This is triggered each time stdin has data that it has read. """ data = data.strip().decode("utf-8") self.log("...
[ "read", "Event", "(", "on", "channel", "stdin", ")", "This", "is", "the", "event", "handler", "for", "read", "events", "specifically", "from", "the", "stdin", "channel", ".", "This", "is", "triggered", "each", "time", "stdin", "has", "data", "that", "it", ...
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/debugger.py#L284-L320
[ "def", "stdin_read", "(", "self", ",", "data", ")", ":", "data", "=", "data", ".", "strip", "(", ")", ".", "decode", "(", "\"utf-8\"", ")", "self", ".", "log", "(", "\"Incoming:\"", ",", "data", ",", "lvl", "=", "verbose", ")", "if", "len", "(", ...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
CLI.register_event
Registers a new command line interface event hook as command
hfos/debugger.py
def register_event(self, event): """Registers a new command line interface event hook as command""" self.log('Registering event hook:', event.cmd, event.thing, pretty=True, lvl=verbose) self.hooks[event.cmd] = event.thing
def register_event(self, event): """Registers a new command line interface event hook as command""" self.log('Registering event hook:', event.cmd, event.thing, pretty=True, lvl=verbose) self.hooks[event.cmd] = event.thing
[ "Registers", "a", "new", "command", "line", "interface", "event", "hook", "as", "command" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/debugger.py#L348-L353
[ "def", "register_event", "(", "self", ",", "event", ")", ":", "self", ".", "log", "(", "'Registering event hook:'", ",", "event", ".", "cmd", ",", "event", ".", "thing", ",", "pretty", "=", "True", ",", "lvl", "=", "verbose", ")", "self", ".", "hooks",...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
populate_user_events
Generate a list of all registered authorized and anonymous events
hfos/events/system.py
def populate_user_events(): """Generate a list of all registered authorized and anonymous events""" global AuthorizedEvents global AnonymousEvents def inheritors(klass): """Find inheritors of a specified object class""" subclasses = {} subclasses_set = set() work = [kl...
def populate_user_events(): """Generate a list of all registered authorized and anonymous events""" global AuthorizedEvents global AnonymousEvents def inheritors(klass): """Find inheritors of a specified object class""" subclasses = {} subclasses_set = set() work = [kl...
[ "Generate", "a", "list", "of", "all", "registered", "authorized", "and", "anonymous", "events" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/events/system.py#L57-L100
[ "def", "populate_user_events", "(", ")", ":", "global", "AuthorizedEvents", "global", "AnonymousEvents", "def", "inheritors", "(", "klass", ")", ":", "\"\"\"Find inheritors of a specified object class\"\"\"", "subclasses", "=", "{", "}", "subclasses_set", "=", "set", "(...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
db
[GROUP] Database management operations
hfos/tool/database.py
def db(ctx): """[GROUP] Database management operations""" from hfos import database database.initialize(ctx.obj['dbhost'], ctx.obj['dbname']) ctx.obj['db'] = database
def db(ctx): """[GROUP] Database management operations""" from hfos import database database.initialize(ctx.obj['dbhost'], ctx.obj['dbname']) ctx.obj['db'] = database
[ "[", "GROUP", "]", "Database", "management", "operations" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/database.py#L37-L42
[ "def", "db", "(", "ctx", ")", ":", "from", "hfos", "import", "database", "database", ".", "initialize", "(", "ctx", ".", "obj", "[", "'dbhost'", "]", ",", "ctx", ".", "obj", "[", "'dbname'", "]", ")", "ctx", ".", "obj", "[", "'db'", "]", "=", "da...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
clear
Clears an entire database collection irrevocably. Use with caution!
hfos/tool/database.py
def clear(ctx, schema): """Clears an entire database collection irrevocably. Use with caution!""" response = _ask('Are you sure you want to delete the collection "%s"' % ( schema), default='N', data_type='bool') if response is True: host, port = ctx.obj['dbhost'].split(':') client ...
def clear(ctx, schema): """Clears an entire database collection irrevocably. Use with caution!""" response = _ask('Are you sure you want to delete the collection "%s"' % ( schema), default='N', data_type='bool') if response is True: host, port = ctx.obj['dbhost'].split(':') client ...
[ "Clears", "an", "entire", "database", "collection", "irrevocably", ".", "Use", "with", "caution!" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/database.py#L94-L112
[ "def", "clear", "(", "ctx", ",", "schema", ")", ":", "response", "=", "_ask", "(", "'Are you sure you want to delete the collection \"%s\"'", "%", "(", "schema", ")", ",", "default", "=", "'N'", ",", "data_type", "=", "'bool'", ")", "if", "response", "is", "...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
provision_system_config
Provision a basic system configuration
hfos/provisions/system.py
def provision_system_config(items, database_name, overwrite=False, clear=False, skip_user_check=False): """Provision a basic system configuration""" from hfos.provisions.base import provisionList from hfos.database import objectmodels default_system_config_count = objectmodels['systemconfig'].count({ ...
def provision_system_config(items, database_name, overwrite=False, clear=False, skip_user_check=False): """Provision a basic system configuration""" from hfos.provisions.base import provisionList from hfos.database import objectmodels default_system_config_count = objectmodels['systemconfig'].count({ ...
[ "Provision", "a", "basic", "system", "configuration" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/provisions/system.py#L50-L64
[ "def", "provision_system_config", "(", "items", ",", "database_name", ",", "overwrite", "=", "False", ",", "clear", "=", "False", ",", "skip_user_check", "=", "False", ")", ":", "from", "hfos", ".", "provisions", ".", "base", "import", "provisionList", "from",...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
ICALImporter
Calendar Importer for iCal (ics) files
modules/calendar/hfos/calendar/importer/ical.py
def ICALImporter(ctx, filename, all, owner, calendar, create_calendar, clear_calendar, dry, execfilter): """Calendar Importer for iCal (ics) files """ log('iCal importer running') objectmodels = ctx.obj['db'].objectmodels if objectmodels['user'].count({'name': owner}) > 0: owner_object =...
def ICALImporter(ctx, filename, all, owner, calendar, create_calendar, clear_calendar, dry, execfilter): """Calendar Importer for iCal (ics) files """ log('iCal importer running') objectmodels = ctx.obj['db'].objectmodels if objectmodels['user'].count({'name': owner}) > 0: owner_object =...
[ "Calendar", "Importer", "for", "iCal", "(", "ics", ")", "files" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/calendar/hfos/calendar/importer/ical.py#L28-L148
[ "def", "ICALImporter", "(", "ctx", ",", "filename", ",", "all", ",", "owner", ",", "calendar", ",", "create_calendar", ",", "clear_calendar", ",", "dry", ",", "execfilter", ")", ":", "log", "(", "'iCal importer running'", ")", "objectmodels", "=", "ctx", "."...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
make_migrations
Create migration data for a specified schema
hfos/migration.py
def make_migrations(schema=None): """Create migration data for a specified schema""" entrypoints = {} old = {} def apply_migrations(migrations, new_model): """Apply migration data to compile an up to date model""" def get_path(raw_path): """Get local path of schema definit...
def make_migrations(schema=None): """Create migration data for a specified schema""" entrypoints = {} old = {} def apply_migrations(migrations, new_model): """Apply migration data to compile an up to date model""" def get_path(raw_path): """Get local path of schema definit...
[ "Create", "migration", "data", "for", "a", "specified", "schema" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/migration.py#L48-L227
[ "def", "make_migrations", "(", "schema", "=", "None", ")", ":", "entrypoints", "=", "{", "}", "old", "=", "{", "}", "def", "apply_migrations", "(", "migrations", ",", "new_model", ")", ":", "\"\"\"Apply migration data to compile an up to date model\"\"\"", "def", ...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
Host.userlogin
Provides the newly authenticated user with a backlog and general channel status information
modules/chat/hfos/chat/host.py
def userlogin(self, event): """Provides the newly authenticated user with a backlog and general channel status information""" try: user_uuid = event.useruuid user = objectmodels['user'].find_one({'uuid': user_uuid}) if user_uuid not in self.lastlogs: ...
def userlogin(self, event): """Provides the newly authenticated user with a backlog and general channel status information""" try: user_uuid = event.useruuid user = objectmodels['user'].find_one({'uuid': user_uuid}) if user_uuid not in self.lastlogs: ...
[ "Provides", "the", "newly", "authenticated", "user", "with", "a", "backlog", "and", "general", "channel", "status", "information" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/chat/hfos/chat/host.py#L163-L185
[ "def", "userlogin", "(", "self", ",", "event", ")", ":", "try", ":", "user_uuid", "=", "event", ".", "useruuid", "user", "=", "objectmodels", "[", "'user'", "]", ".", "find_one", "(", "{", "'uuid'", ":", "user_uuid", "}", ")", "if", "user_uuid", "not",...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
Host.join
Chat event handler for incoming events :param event: say-event with incoming chat message
modules/chat/hfos/chat/host.py
def join(self, event): """Chat event handler for incoming events :param event: say-event with incoming chat message """ try: channel_uuid = event.data user_uuid = event.user.uuid if channel_uuid in self.chat_channels: self.log('User j...
def join(self, event): """Chat event handler for incoming events :param event: say-event with incoming chat message """ try: channel_uuid = event.data user_uuid = event.user.uuid if channel_uuid in self.chat_channels: self.log('User j...
[ "Chat", "event", "handler", "for", "incoming", "events", ":", "param", "event", ":", "say", "-", "event", "with", "incoming", "chat", "message" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/chat/hfos/chat/host.py#L267-L292
[ "def", "join", "(", "self", ",", "event", ")", ":", "try", ":", "channel_uuid", "=", "event", ".", "data", "user_uuid", "=", "event", ".", "user", ".", "uuid", "if", "channel_uuid", "in", "self", ".", "chat_channels", ":", "self", ".", "log", "(", "'...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
Host.say
Chat event handler for incoming events :param event: say-event with incoming chat message
modules/chat/hfos/chat/host.py
def say(self, event): """Chat event handler for incoming events :param event: say-event with incoming chat message """ try: userid = event.user.uuid recipient = self._get_recipient(event) content = self._get_content(event) message = objec...
def say(self, event): """Chat event handler for incoming events :param event: say-event with incoming chat message """ try: userid = event.user.uuid recipient = self._get_recipient(event) content = self._get_content(event) message = objec...
[ "Chat", "event", "handler", "for", "incoming", "events", ":", "param", "event", ":", "say", "-", "event", "with", "incoming", "chat", "message" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/chat/hfos/chat/host.py#L350-L387
[ "def", "say", "(", "self", ",", "event", ")", ":", "try", ":", "userid", "=", "event", ".", "user", ".", "uuid", "recipient", "=", "self", ".", "_get_recipient", "(", "event", ")", "content", "=", "self", ".", "_get_content", "(", "event", ")", "mess...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
install_docs
Builds and installs the complete HFOS documentation.
hfos/tool/installer.py
def install_docs(instance, clear_target): """Builds and installs the complete HFOS documentation.""" _check_root() def make_docs(): """Trigger a Sphinx make command to build the documentation.""" log("Generating HTML documentation") try: build = Popen( ...
def install_docs(instance, clear_target): """Builds and installs the complete HFOS documentation.""" _check_root() def make_docs(): """Trigger a Sphinx make command to build the documentation.""" log("Generating HTML documentation") try: build = Popen( ...
[ "Builds", "and", "installs", "the", "complete", "HFOS", "documentation", "." ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/installer.py#L67-L115
[ "def", "install_docs", "(", "instance", ",", "clear_target", ")", ":", "_check_root", "(", ")", "def", "make_docs", "(", ")", ":", "\"\"\"Trigger a Sphinx make command to build the documentation.\"\"\"", "log", "(", "\"Generating HTML documentation\"", ")", "try", ":", ...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
var
Install variable data to /var/[lib,cache]/hfos
hfos/tool/installer.py
def var(ctx, clear_target, clear_all): """Install variable data to /var/[lib,cache]/hfos""" install_var(str(ctx.obj['instance']), clear_target, clear_all)
def var(ctx, clear_target, clear_all): """Install variable data to /var/[lib,cache]/hfos""" install_var(str(ctx.obj['instance']), clear_target, clear_all)
[ "Install", "variable", "data", "to", "/", "var", "/", "[", "lib", "cache", "]", "/", "hfos" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/installer.py#L124-L127
[ "def", "var", "(", "ctx", ",", "clear_target", ",", "clear_all", ")", ":", "install_var", "(", "str", "(", "ctx", ".", "obj", "[", "'instance'", "]", ")", ",", "clear_target", ",", "clear_all", ")" ]
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
install_var
Install required folders in /var
hfos/tool/installer.py
def install_var(instance, clear_target, clear_all): """Install required folders in /var""" _check_root() log("Checking frontend library and cache directories", emitter='MANAGE') uid = pwd.getpwnam("hfos").pw_uid gid = grp.getgrnam("hfos").gr_gid join = os.path.join # If these nee...
def install_var(instance, clear_target, clear_all): """Install required folders in /var""" _check_root() log("Checking frontend library and cache directories", emitter='MANAGE') uid = pwd.getpwnam("hfos").pw_uid gid = grp.getgrnam("hfos").gr_gid join = os.path.join # If these nee...
[ "Install", "required", "folders", "in", "/", "var" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/installer.py#L130-L172
[ "def", "install_var", "(", "instance", ",", "clear_target", ",", "clear_all", ")", ":", "_check_root", "(", ")", "log", "(", "\"Checking frontend library and cache directories\"", ",", "emitter", "=", "'MANAGE'", ")", "uid", "=", "pwd", ".", "getpwnam", "(", "\"...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
provisions
Install default provisioning data
hfos/tool/installer.py
def provisions(ctx, provision, clear_existing, overwrite, list_provisions): """Install default provisioning data""" install_provisions(ctx, provision, clear_existing, overwrite, list_provisions)
def provisions(ctx, provision, clear_existing, overwrite, list_provisions): """Install default provisioning data""" install_provisions(ctx, provision, clear_existing, overwrite, list_provisions)
[ "Install", "default", "provisioning", "data" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/installer.py#L186-L189
[ "def", "provisions", "(", "ctx", ",", "provision", ",", "clear_existing", ",", "overwrite", ",", "list_provisions", ")", ":", "install_provisions", "(", "ctx", ",", "provision", ",", "clear_existing", ",", "overwrite", ",", "list_provisions", ")" ]
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
install_provisions
Install default provisioning data
hfos/tool/installer.py
def install_provisions(ctx, provision, clear_provisions=False, overwrite=False, list_provisions=False): """Install default provisioning data""" log("Installing HFOS default provisions") # from hfos.logger import verbosity, events # verbosity['console'] = verbosity['global'] = events from hfos imp...
def install_provisions(ctx, provision, clear_provisions=False, overwrite=False, list_provisions=False): """Install default provisioning data""" log("Installing HFOS default provisions") # from hfos.logger import verbosity, events # verbosity['console'] = verbosity['global'] = events from hfos imp...
[ "Install", "default", "provisioning", "data" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/installer.py#L192-L263
[ "def", "install_provisions", "(", "ctx", ",", "provision", ",", "clear_provisions", "=", "False", ",", "overwrite", "=", "False", ",", "list_provisions", "=", "False", ")", ":", "log", "(", "\"Installing HFOS default provisions\"", ")", "# from hfos.logger import verb...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
install_modules
Install the plugin modules
hfos/tool/installer.py
def install_modules(wip): """Install the plugin modules""" def install_module(hfos_module): """Install a single module via setuptools""" try: setup = Popen( [ sys.executable, 'setup.py', 'develop' ...
def install_modules(wip): """Install the plugin modules""" def install_module(hfos_module): """Install a single module via setuptools""" try: setup = Popen( [ sys.executable, 'setup.py', 'develop' ...
[ "Install", "the", "plugin", "modules" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/installer.py#L274-L372
[ "def", "install_modules", "(", "wip", ")", ":", "def", "install_module", "(", "hfos_module", ")", ":", "\"\"\"Install a single module via setuptools\"\"\"", "try", ":", "setup", "=", "Popen", "(", "[", "sys", ".", "executable", ",", "'setup.py'", ",", "'develop'",...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
service
Install systemd service configuration
hfos/tool/installer.py
def service(ctx): """Install systemd service configuration""" install_service(ctx.obj['instance'], ctx.obj['dbhost'], ctx.obj['dbname'], ctx.obj['port'])
def service(ctx): """Install systemd service configuration""" install_service(ctx.obj['instance'], ctx.obj['dbhost'], ctx.obj['dbname'], ctx.obj['port'])
[ "Install", "systemd", "service", "configuration" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/installer.py#L377-L380
[ "def", "service", "(", "ctx", ")", ":", "install_service", "(", "ctx", ".", "obj", "[", "'instance'", "]", ",", "ctx", ".", "obj", "[", "'dbhost'", "]", ",", "ctx", ".", "obj", "[", "'dbname'", "]", ",", "ctx", ".", "obj", "[", "'port'", "]", ")"...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
install_service
Install systemd service configuration
hfos/tool/installer.py
def install_service(instance, dbhost, dbname, port): """Install systemd service configuration""" _check_root() log("Installing systemd service") launcher = os.path.realpath(__file__).replace('manage', 'launcher') executable = sys.executable + " " + launcher executable += " --instance " + inst...
def install_service(instance, dbhost, dbname, port): """Install systemd service configuration""" _check_root() log("Installing systemd service") launcher = os.path.realpath(__file__).replace('manage', 'launcher') executable = sys.executable + " " + launcher executable += " --instance " + inst...
[ "Install", "systemd", "service", "configuration" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/installer.py#L383-L422
[ "def", "install_service", "(", "instance", ",", "dbhost", ",", "dbname", ",", "port", ")", ":", "_check_root", "(", ")", "log", "(", "\"Installing systemd service\"", ")", "launcher", "=", "os", ".", "path", ".", "realpath", "(", "__file__", ")", ".", "rep...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
nginx
Install nginx configuration
hfos/tool/installer.py
def nginx(ctx, hostname): """Install nginx configuration""" install_nginx(ctx.obj['dbhost'], ctx.obj['dbname'], ctx.obj['port'], hostname)
def nginx(ctx, hostname): """Install nginx configuration""" install_nginx(ctx.obj['dbhost'], ctx.obj['dbname'], ctx.obj['port'], hostname)
[ "Install", "nginx", "configuration" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/installer.py#L430-L433
[ "def", "nginx", "(", "ctx", ",", "hostname", ")", ":", "install_nginx", "(", "ctx", ".", "obj", "[", "'dbhost'", "]", ",", "ctx", ".", "obj", "[", "'dbname'", "]", ",", "ctx", ".", "obj", "[", "'port'", "]", ",", "hostname", ")" ]
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
install_nginx
Install nginx configuration
hfos/tool/installer.py
def install_nginx(instance, dbhost, dbname, port, hostname=None): """Install nginx configuration""" _check_root() log("Installing nginx configuration") if hostname is None: try: configuration = _get_system_configuration(dbhost, dbname) hostname = configuration.hostname...
def install_nginx(instance, dbhost, dbname, port, hostname=None): """Install nginx configuration""" _check_root() log("Installing nginx configuration") if hostname is None: try: configuration = _get_system_configuration(dbhost, dbname) hostname = configuration.hostname...
[ "Install", "nginx", "configuration" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/installer.py#L436-L492
[ "def", "install_nginx", "(", "instance", ",", "dbhost", ",", "dbname", ",", "port", ",", "hostname", "=", "None", ")", ":", "_check_root", "(", ")", "log", "(", "\"Installing nginx configuration\"", ")", "if", "hostname", "is", "None", ":", "try", ":", "co...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
install_cert
Install a local SSL certificate
hfos/tool/installer.py
def install_cert(selfsigned): """Install a local SSL certificate""" _check_root() if selfsigned: log('Generating self signed (insecure) certificate/key ' 'combination') try: os.mkdir('/etc/ssl/certs/hfos') except FileExistsError: pass ex...
def install_cert(selfsigned): """Install a local SSL certificate""" _check_root() if selfsigned: log('Generating self signed (insecure) certificate/key ' 'combination') try: os.mkdir('/etc/ssl/certs/hfos') except FileExistsError: pass ex...
[ "Install", "a", "local", "SSL", "certificate" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/installer.py#L531-L608
[ "def", "install_cert", "(", "selfsigned", ")", ":", "_check_root", "(", ")", "if", "selfsigned", ":", "log", "(", "'Generating self signed (insecure) certificate/key '", "'combination'", ")", "try", ":", "os", ".", "mkdir", "(", "'/etc/ssl/certs/hfos'", ")", "except...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
frontend
Build and install frontend
hfos/tool/installer.py
def frontend(ctx, dev, rebuild, no_install, build_type): """Build and install frontend""" install_frontend(instance=ctx.obj['instance'], forcerebuild=rebuild, development=dev, install=not no_install, build_type=build_type)
def frontend(ctx, dev, rebuild, no_install, build_type): """Build and install frontend""" install_frontend(instance=ctx.obj['instance'], forcerebuild=rebuild, development=dev, install=not no_install, build_type=build_type)
[ "Build", "and", "install", "frontend" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/installer.py#L621-L628
[ "def", "frontend", "(", "ctx", ",", "dev", ",", "rebuild", ",", "no_install", ",", "build_type", ")", ":", "install_frontend", "(", "instance", "=", "ctx", ".", "obj", "[", "'instance'", "]", ",", "forcerebuild", "=", "rebuild", ",", "development", "=", ...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
install_all
Default-Install everything installable \b This includes * System user (hfos.hfos) * Self signed certificate * Variable data locations (/var/lib/hfos and /var/cache/hfos) * All the official modules in this repository * Default module provisioning data * Documentation * systemd servic...
hfos/tool/installer.py
def install_all(ctx, clear_all): """Default-Install everything installable \b This includes * System user (hfos.hfos) * Self signed certificate * Variable data locations (/var/lib/hfos and /var/cache/hfos) * All the official modules in this repository * Default module provisioning data ...
def install_all(ctx, clear_all): """Default-Install everything installable \b This includes * System user (hfos.hfos) * Self signed certificate * Variable data locations (/var/lib/hfos and /var/cache/hfos) * All the official modules in this repository * Default module provisioning data ...
[ "Default", "-", "Install", "everything", "installable" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/installer.py#L635-L668
[ "def", "install_all", "(", "ctx", ",", "clear_all", ")", ":", "_check_root", "(", ")", "instance", "=", "ctx", ".", "obj", "[", "'instance'", "]", "dbhost", "=", "ctx", ".", "obj", "[", "'dbhost'", "]", "dbname", "=", "ctx", ".", "obj", "[", "'dbname...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
uninstall
Uninstall data and resource locations
hfos/tool/installer.py
def uninstall(): """Uninstall data and resource locations""" _check_root() response = _ask("This will delete all data of your HFOS installations! Type" "YES to continue:", default="N", show_hint=False) if response == 'YES': shutil.rmtree('/var/lib/hfos') shutil.rmtr...
def uninstall(): """Uninstall data and resource locations""" _check_root() response = _ask("This will delete all data of your HFOS installations! Type" "YES to continue:", default="N", show_hint=False) if response == 'YES': shutil.rmtree('/var/lib/hfos') shutil.rmtr...
[ "Uninstall", "data", "and", "resource", "locations" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/installer.py#L672-L681
[ "def", "uninstall", "(", ")", ":", "_check_root", "(", ")", "response", "=", "_ask", "(", "\"This will delete all data of your HFOS installations! Type\"", "\"YES to continue:\"", ",", "default", "=", "\"N\"", ",", "show_hint", "=", "False", ")", "if", "response", "...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
update
Update a HFOS node
hfos/tool/installer.py
def update(ctx, no_restart, no_rebuild): """Update a HFOS node""" # 0. (NOT YET! MAKE A BACKUP OF EVERYTHING) # 1. update repository # 2. update frontend repository # 3. (Not yet: update venv) # 4. rebuild frontend # 5. restart service instance = ctx.obj['instance'] log('Pulling g...
def update(ctx, no_restart, no_rebuild): """Update a HFOS node""" # 0. (NOT YET! MAKE A BACKUP OF EVERYTHING) # 1. update repository # 2. update frontend repository # 3. (Not yet: update venv) # 4. rebuild frontend # 5. restart service instance = ctx.obj['instance'] log('Pulling g...
[ "Update", "a", "HFOS", "node" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/installer.py#L688-L715
[ "def", "update", "(", "ctx", ",", "no_restart", ",", "no_rebuild", ")", ":", "# 0. (NOT YET! MAKE A BACKUP OF EVERYTHING)", "# 1. update repository", "# 2. update frontend repository", "# 3. (Not yet: update venv)", "# 4. rebuild frontend", "# 5. restart service", "instance", "=", ...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
NMEAParser.raw_data
Handles incoming raw sensor data :param event: Raw sentences incoming data
modules/nmea/hfos/nmea/nmea.py
def raw_data(self, event): """Handles incoming raw sensor data :param event: Raw sentences incoming data """ self.log('Received raw data from bus', lvl=events) if not parse: return nmea_time = event.data[0] try: parsed_data = parse(event....
def raw_data(self, event): """Handles incoming raw sensor data :param event: Raw sentences incoming data """ self.log('Received raw data from bus', lvl=events) if not parse: return nmea_time = event.data[0] try: parsed_data = parse(event....
[ "Handles", "incoming", "raw", "sensor", "data", ":", "param", "event", ":", "Raw", "sentences", "incoming", "data" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/nmea/hfos/nmea/nmea.py#L106-L133
[ "def", "raw_data", "(", "self", ",", "event", ")", ":", "self", ".", "log", "(", "'Received raw data from bus'", ",", "lvl", "=", "events", ")", "if", "not", "parse", ":", "return", "nmea_time", "=", "event", ".", "data", "[", "0", "]", "try", ":", "...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
clear_all
DANGER! *This command is a maintenance tool and clears the complete database.*
hfos/database.py
def clear_all(): """DANGER! *This command is a maintenance tool and clears the complete database.* """ sure = input("Are you sure to drop the complete database content? (Type " "in upppercase YES)") if not (sure == 'YES'): db_log('Not deleting the database.') sys.ex...
def clear_all(): """DANGER! *This command is a maintenance tool and clears the complete database.* """ sure = input("Are you sure to drop the complete database content? (Type " "in upppercase YES)") if not (sure == 'YES'): db_log('Not deleting the database.') sys.ex...
[ "DANGER!", "*", "This", "command", "is", "a", "maintenance", "tool", "and", "clears", "the", "complete", "database", ".", "*" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/database.py#L102-L118
[ "def", "clear_all", "(", ")", ":", "sure", "=", "input", "(", "\"Are you sure to drop the complete database content? (Type \"", "\"in upppercase YES)\"", ")", "if", "not", "(", "sure", "==", "'YES'", ")", ":", "db_log", "(", "'Not deleting the database.'", ")", "sys",...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
_build_model_factories
Generate factories to construct objects from schemata
hfos/database.py
def _build_model_factories(store): """Generate factories to construct objects from schemata""" result = {} for schemaname in store: schema = None try: schema = store[schemaname]['schema'] except KeyError: schemata_log("No schema found for ", schemaname, lv...
def _build_model_factories(store): """Generate factories to construct objects from schemata""" result = {} for schemaname in store: schema = None try: schema = store[schemaname]['schema'] except KeyError: schemata_log("No schema found for ", schemaname, lv...
[ "Generate", "factories", "to", "construct", "objects", "from", "schemata" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/database.py#L257-L276
[ "def", "_build_model_factories", "(", "store", ")", ":", "result", "=", "{", "}", "for", "schemaname", "in", "store", ":", "schema", "=", "None", "try", ":", "schema", "=", "store", "[", "schemaname", "]", "[", "'schema'", "]", "except", "KeyError", ":",...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
_build_collections
Generate database collections with indices from the schemastore
hfos/database.py
def _build_collections(store): """Generate database collections with indices from the schemastore""" result = {} client = pymongo.MongoClient(host=dbhost, port=dbport) db = client[dbname] for schemaname in store: schema = None indices = None try: schema = sto...
def _build_collections(store): """Generate database collections with indices from the schemastore""" result = {} client = pymongo.MongoClient(host=dbhost, port=dbport) db = client[dbname] for schemaname in store: schema = None indices = None try: schema = sto...
[ "Generate", "database", "collections", "with", "indices", "from", "the", "schemastore" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/database.py#L279-L349
[ "def", "_build_collections", "(", "store", ")", ":", "result", "=", "{", "}", "client", "=", "pymongo", ".", "MongoClient", "(", "host", "=", "dbhost", ",", "port", "=", "dbport", ")", "db", "=", "client", "[", "dbname", "]", "for", "schemaname", "in",...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
initialize
Initializes the database connectivity, schemata and finally object models
hfos/database.py
def initialize(address='127.0.0.1:27017', database_name='hfos', instance_name="default", reload=False): """Initializes the database connectivity, schemata and finally object models""" global schemastore global l10n_schemastore global objectmodels global collections global dbhost global dbpo...
def initialize(address='127.0.0.1:27017', database_name='hfos', instance_name="default", reload=False): """Initializes the database connectivity, schemata and finally object models""" global schemastore global l10n_schemastore global objectmodels global collections global dbhost global dbpo...
[ "Initializes", "the", "database", "connectivity", "schemata", "and", "finally", "object", "models" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/database.py#L352-L392
[ "def", "initialize", "(", "address", "=", "'127.0.0.1:27017'", ",", "database_name", "=", "'hfos'", ",", "instance_name", "=", "\"default\"", ",", "reload", "=", "False", ")", ":", "global", "schemastore", "global", "l10n_schemastore", "global", "objectmodels", "g...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
profile
Profiles object model handling with a very simple benchmarking test
hfos/database.py
def profile(schemaname='sensordata', profiletype='pjs'): """Profiles object model handling with a very simple benchmarking test""" db_log("Profiling ", schemaname) schema = schemastore[schemaname]['schema'] db_log("Schema: ", schema, lvl=debug) testclass = None if profiletype == 'warmongo':...
def profile(schemaname='sensordata', profiletype='pjs'): """Profiles object model handling with a very simple benchmarking test""" db_log("Profiling ", schemaname) schema = schemastore[schemaname]['schema'] db_log("Schema: ", schema, lvl=debug) testclass = None if profiletype == 'warmongo':...
[ "Profiles", "object", "model", "handling", "with", "a", "very", "simple", "benchmarking", "test" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/database.py#L412-L449
[ "def", "profile", "(", "schemaname", "=", "'sensordata'", ",", "profiletype", "=", "'pjs'", ")", ":", "db_log", "(", "\"Profiling \"", ",", "schemaname", ")", "schema", "=", "schemastore", "[", "schemaname", "]", "[", "'schema'", "]", "db_log", "(", "\"Schem...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
backup
Exports all collections to (JSON-) files.
hfos/database.py
def backup(schema, uuid, export_filter, export_format, filename, pretty, export_all, omit): """Exports all collections to (JSON-) files.""" export_format = export_format.upper() if pretty: indent = 4 else: indent = 0 f = None if filename: try: f = open(fil...
def backup(schema, uuid, export_filter, export_format, filename, pretty, export_all, omit): """Exports all collections to (JSON-) files.""" export_format = export_format.upper() if pretty: indent = 4 else: indent = 0 f = None if filename: try: f = open(fil...
[ "Exports", "all", "collections", "to", "(", "JSON", "-", ")", "files", "." ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/database.py#L657-L733
[ "def", "backup", "(", "schema", ",", "uuid", ",", "export_filter", ",", "export_format", ",", "filename", ",", "pretty", ",", "export_all", ",", "omit", ")", ":", "export_format", "=", "export_format", ".", "upper", "(", ")", "if", "pretty", ":", "indent",...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
Maintenance._check_collections
Checks node local collection storage sizes
hfos/database.py
def _check_collections(self): """Checks node local collection storage sizes""" self.collection_sizes = {} self.collection_total = 0 for col in self.db.collection_names(include_system_collections=False): self.collection_sizes[col] = self.db.command('collstats', col).get( ...
def _check_collections(self): """Checks node local collection storage sizes""" self.collection_sizes = {} self.collection_total = 0 for col in self.db.collection_names(include_system_collections=False): self.collection_sizes[col] = self.db.command('collstats', col).get( ...
[ "Checks", "node", "local", "collection", "storage", "sizes" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/database.py#L558-L577
[ "def", "_check_collections", "(", "self", ")", ":", "self", ".", "collection_sizes", "=", "{", "}", "self", ".", "collection_total", "=", "0", "for", "col", "in", "self", ".", "db", ".", "collection_names", "(", "include_system_collections", "=", "False", ")...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
Maintenance._check_free_space
Checks used filesystem storage sizes
hfos/database.py
def _check_free_space(self): """Checks used filesystem storage sizes""" def get_folder_size(path): """Aggregates used size of a specified path, recursively""" total_size = 0 for item in walk(path): for file in item[2]: try: ...
def _check_free_space(self): """Checks used filesystem storage sizes""" def get_folder_size(path): """Aggregates used size of a specified path, recursively""" total_size = 0 for item in walk(path): for file in item[2]: try: ...
[ "Checks", "used", "filesystem", "storage", "sizes" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/database.py#L579-L611
[ "def", "_check_free_space", "(", "self", ")", ":", "def", "get_folder_size", "(", "path", ")", ":", "\"\"\"Aggregates used size of a specified path, recursively\"\"\"", "total_size", "=", "0", "for", "item", "in", "walk", "(", "path", ")", ":", "for", "file", "in"...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
send_mail_worker
Worker task to send out an email, which blocks the process unless it is threaded
modules/enrol/hfos/enrol/enrolmanager.py
def send_mail_worker(config, mail, event): """Worker task to send out an email, which blocks the process unless it is threaded""" log = "" try: if config.mail_ssl: server = SMTP_SSL(config.mail_server, port=config.mail_server_port, timeout=30) else: server = SMTP(con...
def send_mail_worker(config, mail, event): """Worker task to send out an email, which blocks the process unless it is threaded""" log = "" try: if config.mail_ssl: server = SMTP_SSL(config.mail_server, port=config.mail_server_port, timeout=30) else: server = SMTP(con...
[ "Worker", "task", "to", "send", "out", "an", "email", "which", "blocks", "the", "process", "unless", "it", "is", "threaded" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/enrol/hfos/enrol/enrolmanager.py#L792-L821
[ "def", "send_mail_worker", "(", "config", ",", "mail", ",", "event", ")", ":", "log", "=", "\"\"", "try", ":", "if", "config", ".", "mail_ssl", ":", "server", "=", "SMTP_SSL", "(", "config", ".", "mail_server", ",", "port", "=", "config", ".", "mail_se...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
EnrolManager.reload_configuration
Reload the current configuration and set up everything depending on it
modules/enrol/hfos/enrol/enrolmanager.py
def reload_configuration(self, event): """Reload the current configuration and set up everything depending on it""" super(EnrolManager, self).reload_configuration(event) self.log('Reloaded configuration.') self._setup()
def reload_configuration(self, event): """Reload the current configuration and set up everything depending on it""" super(EnrolManager, self).reload_configuration(event) self.log('Reloaded configuration.') self._setup()
[ "Reload", "the", "current", "configuration", "and", "set", "up", "everything", "depending", "on", "it" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/enrol/hfos/enrol/enrolmanager.py#L261-L266
[ "def", "reload_configuration", "(", "self", ",", "event", ")", ":", "super", "(", "EnrolManager", ",", "self", ")", ".", "reload_configuration", "(", "event", ")", "self", ".", "log", "(", "'Reloaded configuration.'", ")", "self", ".", "_setup", "(", ")" ]
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
EnrolManager.change
An admin user requests a change to an enrolment
modules/enrol/hfos/enrol/enrolmanager.py
def change(self, event): """An admin user requests a change to an enrolment""" uuid = event.data['uuid'] status = event.data['status'] if status not in ['Open', 'Pending', 'Accepted', 'Denied', 'Resend']: self.log('Erroneous status for enrollment requested!', lvl=warn) ...
def change(self, event): """An admin user requests a change to an enrolment""" uuid = event.data['uuid'] status = event.data['status'] if status not in ['Open', 'Pending', 'Accepted', 'Denied', 'Resend']: self.log('Erroneous status for enrollment requested!', lvl=warn) ...
[ "An", "admin", "user", "requests", "a", "change", "to", "an", "enrolment" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/enrol/hfos/enrol/enrolmanager.py#L315-L354
[ "def", "change", "(", "self", ",", "event", ")", ":", "uuid", "=", "event", ".", "data", "[", "'uuid'", "]", "status", "=", "event", ".", "data", "[", "'status'", "]", "if", "status", "not", "in", "[", "'Open'", ",", "'Pending'", ",", "'Accepted'", ...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
EnrolManager.changepassword
An enrolled user wants to change their password
modules/enrol/hfos/enrol/enrolmanager.py
def changepassword(self, event): """An enrolled user wants to change their password""" old = event.data['old'] new = event.data['new'] uuid = event.user.uuid # TODO: Write email to notify user of password change user = objectmodels['user'].find_one({'uuid': uuid}) ...
def changepassword(self, event): """An enrolled user wants to change their password""" old = event.data['old'] new = event.data['new'] uuid = event.user.uuid # TODO: Write email to notify user of password change user = objectmodels['user'].find_one({'uuid': uuid}) ...
[ "An", "enrolled", "user", "wants", "to", "change", "their", "password" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/enrol/hfos/enrol/enrolmanager.py#L357-L385
[ "def", "changepassword", "(", "self", ",", "event", ")", ":", "old", "=", "event", ".", "data", "[", "'old'", "]", "new", "=", "event", ".", "data", "[", "'new'", "]", "uuid", "=", "event", ".", "user", ".", "uuid", "# TODO: Write email to notify user of...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
EnrolManager.invite
A new user has been invited to enrol by an admin user
modules/enrol/hfos/enrol/enrolmanager.py
def invite(self, event): """A new user has been invited to enrol by an admin user""" self.log('Inviting new user to enrol') name = event.data['name'] email = event.data['email'] method = event.data['method'] self._invite(name, method, email, event.client.uuid, event)
def invite(self, event): """A new user has been invited to enrol by an admin user""" self.log('Inviting new user to enrol') name = event.data['name'] email = event.data['email'] method = event.data['method'] self._invite(name, method, email, event.client.uuid, event)
[ "A", "new", "user", "has", "been", "invited", "to", "enrol", "by", "an", "admin", "user" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/enrol/hfos/enrol/enrolmanager.py#L388-L396
[ "def", "invite", "(", "self", ",", "event", ")", ":", "self", ".", "log", "(", "'Inviting new user to enrol'", ")", "name", "=", "event", ".", "data", "[", "'name'", "]", "email", "=", "event", ".", "data", "[", "'email'", "]", "method", "=", "event", ...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
EnrolManager.enrol
A user tries to self-enrol with the enrolment form
modules/enrol/hfos/enrol/enrolmanager.py
def enrol(self, event): """A user tries to self-enrol with the enrolment form""" if self.config.allow_registration is False: self.log('Someone tried to register although enrolment is closed.') return self.log('Client trying to register a new account:', event, pretty=Tru...
def enrol(self, event): """A user tries to self-enrol with the enrolment form""" if self.config.allow_registration is False: self.log('Someone tried to register although enrolment is closed.') return self.log('Client trying to register a new account:', event, pretty=Tru...
[ "A", "user", "tries", "to", "self", "-", "enrol", "with", "the", "enrolment", "form" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/enrol/hfos/enrol/enrolmanager.py#L399-L450
[ "def", "enrol", "(", "self", ",", "event", ")", ":", "if", "self", ".", "config", ".", "allow_registration", "is", "False", ":", "self", ".", "log", "(", "'Someone tried to register although enrolment is closed.'", ")", "return", "self", ".", "log", "(", "'Cli...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
EnrolManager.accept
A challenge/response for an enrolment has been accepted
modules/enrol/hfos/enrol/enrolmanager.py
def accept(self, event): """A challenge/response for an enrolment has been accepted""" self.log('Invitation accepted:', event.__dict__, lvl=debug) try: uuid = event.data enrollment = objectmodels['enrollment'].find_one({ 'uuid': uuid }) ...
def accept(self, event): """A challenge/response for an enrolment has been accepted""" self.log('Invitation accepted:', event.__dict__, lvl=debug) try: uuid = event.data enrollment = objectmodels['enrollment'].find_one({ 'uuid': uuid }) ...
[ "A", "challenge", "/", "response", "for", "an", "enrolment", "has", "been", "accepted" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/enrol/hfos/enrol/enrolmanager.py#L453-L514
[ "def", "accept", "(", "self", ",", "event", ")", ":", "self", ".", "log", "(", "'Invitation accepted:'", ",", "event", ".", "__dict__", ",", "lvl", "=", "debug", ")", "try", ":", "uuid", "=", "event", ".", "data", "enrollment", "=", "objectmodels", "["...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
EnrolManager.status
An anonymous client wants to know if we're open for enrollment
modules/enrol/hfos/enrol/enrolmanager.py
def status(self, event): """An anonymous client wants to know if we're open for enrollment""" self.log('Registration status requested') response = { 'component': 'hfos.enrol.enrolmanager', 'action': 'status', 'data': self.config.allow_registration } ...
def status(self, event): """An anonymous client wants to know if we're open for enrollment""" self.log('Registration status requested') response = { 'component': 'hfos.enrol.enrolmanager', 'action': 'status', 'data': self.config.allow_registration } ...
[ "An", "anonymous", "client", "wants", "to", "know", "if", "we", "re", "open", "for", "enrollment" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/enrol/hfos/enrol/enrolmanager.py#L517-L528
[ "def", "status", "(", "self", ",", "event", ")", ":", "self", ".", "log", "(", "'Registration status requested'", ")", "response", "=", "{", "'component'", ":", "'hfos.enrol.enrolmanager'", ",", "'action'", ":", "'status'", ",", "'data'", ":", "self", ".", "...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
EnrolManager.request_reset
An anonymous client requests a password reset
modules/enrol/hfos/enrol/enrolmanager.py
def request_reset(self, event): """An anonymous client requests a password reset""" self.log('Password reset request received:', event.__dict__, lvl=hilight) user_object = objectmodels['user'] email = event.data.get('email', None) email_user = None if email is not Non...
def request_reset(self, event): """An anonymous client requests a password reset""" self.log('Password reset request received:', event.__dict__, lvl=hilight) user_object = objectmodels['user'] email = event.data.get('email', None) email_user = None if email is not Non...
[ "An", "anonymous", "client", "requests", "a", "password", "reset" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/enrol/hfos/enrol/enrolmanager.py#L537-L552
[ "def", "request_reset", "(", "self", ",", "event", ")", ":", "self", ".", "log", "(", "'Password reset request received:'", ",", "event", ".", "__dict__", ",", "lvl", "=", "hilight", ")", "user_object", "=", "objectmodels", "[", "'user'", "]", "email", "=", ...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
EnrolManager.captcha_transmit
Delayed transmission of a requested captcha
modules/enrol/hfos/enrol/enrolmanager.py
def captcha_transmit(self, captcha, uuid): """Delayed transmission of a requested captcha""" self.log('Transmitting captcha') response = { 'component': 'hfos.enrol.enrolmanager', 'action': 'captcha', 'data': b64encode(captcha['image'].getvalue()).decode('utf...
def captcha_transmit(self, captcha, uuid): """Delayed transmission of a requested captcha""" self.log('Transmitting captcha') response = { 'component': 'hfos.enrol.enrolmanager', 'action': 'captcha', 'data': b64encode(captcha['image'].getvalue()).decode('utf...
[ "Delayed", "transmission", "of", "a", "requested", "captcha" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/enrol/hfos/enrol/enrolmanager.py#L639-L649
[ "def", "captcha_transmit", "(", "self", ",", "captcha", ",", "uuid", ")", ":", "self", ".", "log", "(", "'Transmitting captcha'", ")", "response", "=", "{", "'component'", ":", "'hfos.enrol.enrolmanager'", ",", "'action'", ":", "'captcha'", ",", "'data'", ":",...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
EnrolManager._invite
Actually invite a given user
modules/enrol/hfos/enrol/enrolmanager.py
def _invite(self, name, method, email, uuid, event, password=""): """Actually invite a given user""" props = { 'uuid': std_uuid(), 'status': 'Open', 'name': name, 'method': method, 'email': email, 'password': password, ...
def _invite(self, name, method, email, uuid, event, password=""): """Actually invite a given user""" props = { 'uuid': std_uuid(), 'status': 'Open', 'name': name, 'method': method, 'email': email, 'password': password, ...
[ "Actually", "invite", "a", "given", "user" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/enrol/hfos/enrol/enrolmanager.py#L651-L675
[ "def", "_invite", "(", "self", ",", "name", ",", "method", ",", "email", ",", "uuid", ",", "event", ",", "password", "=", "\"\"", ")", ":", "props", "=", "{", "'uuid'", ":", "std_uuid", "(", ")", ",", "'status'", ":", "'Open'", ",", "'name'", ":", ...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
EnrolManager._create_user
Create a new user and all initial data
modules/enrol/hfos/enrol/enrolmanager.py
def _create_user(self, username, password, mail, method, uuid): """Create a new user and all initial data""" try: if method == 'Invited': config_role = self.config.group_accept_invited else: config_role = self.config.group_accept_enrolled ...
def _create_user(self, username, password, mail, method, uuid): """Create a new user and all initial data""" try: if method == 'Invited': config_role = self.config.group_accept_invited else: config_role = self.config.group_accept_enrolled ...
[ "Create", "a", "new", "user", "and", "all", "initial", "data" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/enrol/hfos/enrol/enrolmanager.py#L677-L731
[ "def", "_create_user", "(", "self", ",", "username", ",", "password", ",", "mail", ",", "method", ",", "uuid", ")", ":", "try", ":", "if", "method", "==", "'Invited'", ":", "config_role", "=", "self", ".", "config", ".", "group_accept_invited", "else", "...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
EnrolManager._send_invitation
Send an invitation mail to an open enrolment
modules/enrol/hfos/enrol/enrolmanager.py
def _send_invitation(self, enrollment, event): """Send an invitation mail to an open enrolment""" self.log('Sending enrollment status mail to user') self._send_mail(self.config.invitation_subject, self.config.invitation_mail, enrollment, event)
def _send_invitation(self, enrollment, event): """Send an invitation mail to an open enrolment""" self.log('Sending enrollment status mail to user') self._send_mail(self.config.invitation_subject, self.config.invitation_mail, enrollment, event)
[ "Send", "an", "invitation", "mail", "to", "an", "open", "enrolment" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/enrol/hfos/enrol/enrolmanager.py#L733-L738
[ "def", "_send_invitation", "(", "self", ",", "enrollment", ",", "event", ")", ":", "self", ".", "log", "(", "'Sending enrollment status mail to user'", ")", "self", ".", "_send_mail", "(", "self", ".", "config", ".", "invitation_subject", ",", "self", ".", "co...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
EnrolManager._send_acceptance
Send an acceptance mail to an open enrolment
modules/enrol/hfos/enrol/enrolmanager.py
def _send_acceptance(self, enrollment, password, event): """Send an acceptance mail to an open enrolment""" self.log('Sending acceptance status mail to user') if password is not "": password_hint = '\n\nPS: Your new password is ' + password + ' - please change it after your first l...
def _send_acceptance(self, enrollment, password, event): """Send an acceptance mail to an open enrolment""" self.log('Sending acceptance status mail to user') if password is not "": password_hint = '\n\nPS: Your new password is ' + password + ' - please change it after your first l...
[ "Send", "an", "acceptance", "mail", "to", "an", "open", "enrolment" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/enrol/hfos/enrol/enrolmanager.py#L740-L752
[ "def", "_send_acceptance", "(", "self", ",", "enrollment", ",", "password", ",", "event", ")", ":", "self", ".", "log", "(", "'Sending acceptance status mail to user'", ")", "if", "password", "is", "not", "\"\"", ":", "password_hint", "=", "'\\n\\nPS: Your new pas...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
EnrolManager._send_mail
Connect to mail server and send actual email
modules/enrol/hfos/enrol/enrolmanager.py
def _send_mail(self, subject, template, enrollment, event): """Connect to mail server and send actual email""" context = { 'name': enrollment.name, 'invitation_url': self.invitation_url, 'node_name': self.node_name, 'node_url': self.node_url, ...
def _send_mail(self, subject, template, enrollment, event): """Connect to mail server and send actual email""" context = { 'name': enrollment.name, 'invitation_url': self.invitation_url, 'node_name': self.node_name, 'node_url': self.node_url, ...
[ "Connect", "to", "mail", "server", "and", "send", "actual", "email" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/enrol/hfos/enrol/enrolmanager.py#L754-L778
[ "def", "_send_mail", "(", "self", ",", "subject", ",", "template", ",", "enrollment", ",", "event", ")", ":", "context", "=", "{", "'name'", ":", "enrollment", ".", "name", ",", "'invitation_url'", ":", "self", ".", "invitation_url", ",", "'node_name'", ":...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
Bot.say
Chat event handler for incoming events :param event: say-event with incoming chat message
modules/chat/hfos/chat/bot.py
def say(self, event): """Chat event handler for incoming events :param event: say-event with incoming chat message """ try: userid = event.user.uuid recipient = self._get_recipient(event) content = self._get_content(event) if self.config....
def say(self, event): """Chat event handler for incoming events :param event: say-event with incoming chat message """ try: userid = event.user.uuid recipient = self._get_recipient(event) content = self._get_content(event) if self.config....
[ "Chat", "event", "handler", "for", "incoming", "events", ":", "param", "event", ":", "say", "-", "event", "with", "incoming", "chat", "message" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/chat/hfos/chat/bot.py#L67-L81
[ "def", "say", "(", "self", ",", "event", ")", ":", "try", ":", "userid", "=", "event", ".", "user", ".", "uuid", "recipient", "=", "self", ".", "_get_recipient", "(", "event", ")", "content", "=", "self", ".", "_get_content", "(", "event", ")", "if",...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
Authenticator.add_auth_hook
Register event hook on reception of add_auth_hook-event
hfos/ui/auth.py
def add_auth_hook(self, event): """Register event hook on reception of add_auth_hook-event""" self.log('Adding authentication hook for', event.authenticator_name) self.auth_hooks[event.authenticator_name] = event.event
def add_auth_hook(self, event): """Register event hook on reception of add_auth_hook-event""" self.log('Adding authentication hook for', event.authenticator_name) self.auth_hooks[event.authenticator_name] = event.event
[ "Register", "event", "hook", "on", "reception", "of", "add_auth_hook", "-", "event" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/auth.py#L90-L94
[ "def", "add_auth_hook", "(", "self", ",", "event", ")", ":", "self", ".", "log", "(", "'Adding authentication hook for'", ",", "event", ".", "authenticator_name", ")", "self", ".", "auth_hooks", "[", "event", ".", "authenticator_name", "]", "=", "event", ".", ...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
Authenticator._fail
Sends a failure message to the requesting client
hfos/ui/auth.py
def _fail(self, event, message='Invalid credentials'): """Sends a failure message to the requesting client""" notification = { 'component': 'auth', 'action': 'fail', 'data': message } ip = event.sock.getpeername()[0] self.failing_clients[ip]...
def _fail(self, event, message='Invalid credentials'): """Sends a failure message to the requesting client""" notification = { 'component': 'auth', 'action': 'fail', 'data': message } ip = event.sock.getpeername()[0] self.failing_clients[ip]...
[ "Sends", "a", "failure", "message", "to", "the", "requesting", "client" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/auth.py#L96-L108
[ "def", "_fail", "(", "self", ",", "event", ",", "message", "=", "'Invalid credentials'", ")", ":", "notification", "=", "{", "'component'", ":", "'auth'", ",", "'action'", ":", "'fail'", ",", "'data'", ":", "message", "}", "ip", "=", "event", ".", "sock"...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
Authenticator._login
Send login notification to client
hfos/ui/auth.py
def _login(self, event, user_account, user_profile, client_config): """Send login notification to client""" user_account.lastlogin = std_now() user_account.save() user_account.passhash = "" self.fireEvent( authentication(user_account.name, ( user_acc...
def _login(self, event, user_account, user_profile, client_config): """Send login notification to client""" user_account.lastlogin = std_now() user_account.save() user_account.passhash = "" self.fireEvent( authentication(user_account.name, ( user_acc...
[ "Send", "login", "notification", "to", "client" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/auth.py#L115-L128
[ "def", "_login", "(", "self", ",", "event", ",", "user_account", ",", "user_profile", ",", "client_config", ")", ":", "user_account", ".", "lastlogin", "=", "std_now", "(", ")", "user_account", ".", "save", "(", ")", "user_account", ".", "passhash", "=", "...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
Authenticator.authenticationrequest
Handles authentication requests from clients :param event: AuthenticationRequest with user's credentials
hfos/ui/auth.py
def authenticationrequest(self, event): """Handles authentication requests from clients :param event: AuthenticationRequest with user's credentials """ if event.sock.getpeername()[0] in self.failing_clients: self.log('Client failed a login and has to wait', lvl=debug) ...
def authenticationrequest(self, event): """Handles authentication requests from clients :param event: AuthenticationRequest with user's credentials """ if event.sock.getpeername()[0] in self.failing_clients: self.log('Client failed a login and has to wait', lvl=debug) ...
[ "Handles", "authentication", "requests", "from", "clients", ":", "param", "event", ":", "AuthenticationRequest", "with", "user", "s", "credentials" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/auth.py#L131-L143
[ "def", "authenticationrequest", "(", "self", ",", "event", ")", ":", "if", "event", ".", "sock", ".", "getpeername", "(", ")", "[", "0", "]", "in", "self", ".", "failing_clients", ":", "self", ".", "log", "(", "'Client failed a login and has to wait'", ",", ...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
Authenticator._handle_autologin
Automatic logins for client configurations that allow it
hfos/ui/auth.py
def _handle_autologin(self, event): """Automatic logins for client configurations that allow it""" self.log("Verifying automatic login request") # TODO: Check for a common secret # noinspection PyBroadException try: client_config = objectmodels['client'].find_one({...
def _handle_autologin(self, event): """Automatic logins for client configurations that allow it""" self.log("Verifying automatic login request") # TODO: Check for a common secret # noinspection PyBroadException try: client_config = objectmodels['client'].find_one({...
[ "Automatic", "logins", "for", "client", "configurations", "that", "allow", "it" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/auth.py#L145-L188
[ "def", "_handle_autologin", "(", "self", ",", "event", ")", ":", "self", ".", "log", "(", "\"Verifying automatic login request\"", ")", "# TODO: Check for a common secret", "# noinspection PyBroadException", "try", ":", "client_config", "=", "objectmodels", "[", "'client'...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
Authenticator._handle_login
Manual password based login
hfos/ui/auth.py
def _handle_login(self, event): """Manual password based login""" # TODO: Refactor to simplify self.log("Auth request for ", event.username, 'client:', event.clientuuid) # TODO: Define the requirements for secure passwords etc. # They're also required in the E...
def _handle_login(self, event): """Manual password based login""" # TODO: Refactor to simplify self.log("Auth request for ", event.username, 'client:', event.clientuuid) # TODO: Define the requirements for secure passwords etc. # They're also required in the E...
[ "Manual", "password", "based", "login" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/auth.py#L190-L275
[ "def", "_handle_login", "(", "self", ",", "event", ")", ":", "# TODO: Refactor to simplify", "self", ".", "log", "(", "\"Auth request for \"", ",", "event", ".", "username", ",", "'client:'", ",", "event", ".", "clientuuid", ")", "# TODO: Define the requirements for...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
Authenticator._get_profile
Retrieves a user's profile
hfos/ui/auth.py
def _get_profile(self, user_account): """Retrieves a user's profile""" try: # TODO: Load active profile, not just any user_profile = objectmodels['profile'].find_one( {'owner': str(user_account.uuid)}) self.log("Profile: ", user_profile, ...
def _get_profile(self, user_account): """Retrieves a user's profile""" try: # TODO: Load active profile, not just any user_profile = objectmodels['profile'].find_one( {'owner': str(user_account.uuid)}) self.log("Profile: ", user_profile, ...
[ "Retrieves", "a", "user", "s", "profile" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/auth.py#L277-L302
[ "def", "_get_profile", "(", "self", ",", "user_account", ")", ":", "try", ":", "# TODO: Load active profile, not just any", "user_profile", "=", "objectmodels", "[", "'profile'", "]", ".", "find_one", "(", "{", "'owner'", ":", "str", "(", "user_account", ".", "u...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
SerialBusManager._parse
Called when a sensor sends a new raw data to this serial connector. The data is sanitized and sent to the registered protocol listeners as time/raw/bus sentence tuple.
modules/navdata/hfos/navdata/bus.py
def _parse(self, bus, data): """ Called when a sensor sends a new raw data to this serial connector. The data is sanitized and sent to the registered protocol listeners as time/raw/bus sentence tuple. """ sen_time = time.time() try: # Split up multi...
def _parse(self, bus, data): """ Called when a sensor sends a new raw data to this serial connector. The data is sanitized and sent to the registered protocol listeners as time/raw/bus sentence tuple. """ sen_time = time.time() try: # Split up multi...
[ "Called", "when", "a", "sensor", "sends", "a", "new", "raw", "data", "to", "this", "serial", "connector", "." ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/navdata/hfos/navdata/bus.py#L534-L567
[ "def", "_parse", "(", "self", ",", "bus", ",", "data", ")", ":", "sen_time", "=", "time", ".", "time", "(", ")", "try", ":", "# Split up multiple sentences", "if", "isinstance", "(", "data", ",", "bytes", ")", ":", "data", "=", "data", ".", "decode", ...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
SerialBusManager.serial_packet
Handles incoming raw sensor data :param data: raw incoming data
modules/navdata/hfos/navdata/bus.py
def serial_packet(self, event): """Handles incoming raw sensor data :param data: raw incoming data """ self.log('Incoming serial packet:', event.__dict__, lvl=verbose) if self.scanning: pass else: # self.log("Incoming data: ", '%.50s ...' % event...
def serial_packet(self, event): """Handles incoming raw sensor data :param data: raw incoming data """ self.log('Incoming serial packet:', event.__dict__, lvl=verbose) if self.scanning: pass else: # self.log("Incoming data: ", '%.50s ...' % event...
[ "Handles", "incoming", "raw", "sensor", "data", ":", "param", "data", ":", "raw", "incoming", "data" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/modules/navdata/hfos/navdata/bus.py#L583-L597
[ "def", "serial_packet", "(", "self", ",", "event", ")", ":", "self", ".", "log", "(", "'Incoming serial packet:'", ",", "event", ".", "__dict__", ",", "lvl", "=", "verbose", ")", "if", "self", ".", "scanning", ":", "pass", "else", ":", "# self.log(\"Incomi...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
main
Entry point for the script
src/apexpy/__main__.py
def main(): """Entry point for the script""" desc = 'Converts between geodetic, modified apex, quasi-dipole and MLT' parser = argparse.ArgumentParser(description=desc, prog='apexpy') parser.add_argument('source', metavar='SOURCE', choices=['geo', 'apex', 'qd', 'mlt'], ...
def main(): """Entry point for the script""" desc = 'Converts between geodetic, modified apex, quasi-dipole and MLT' parser = argparse.ArgumentParser(description=desc, prog='apexpy') parser.add_argument('source', metavar='SOURCE', choices=['geo', 'apex', 'qd', 'mlt'], ...
[ "Entry", "point", "for", "the", "script" ]
aburrell/apexpy
python
https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/__main__.py#L24-L68
[ "def", "main", "(", ")", ":", "desc", "=", "'Converts between geodetic, modified apex, quasi-dipole and MLT'", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "desc", ",", "prog", "=", "'apexpy'", ")", "parser", ".", "add_argument", "(", ...
a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386
train
run_process
Executes an external process via subprocess.Popen
hfos/tool/__init__.py
def run_process(cwd, args): """Executes an external process via subprocess.Popen""" try: process = check_output(args, cwd=cwd, stderr=STDOUT) return process except CalledProcessError as e: log('Uh oh, the teapot broke again! Error:', e, type(e), lvl=verbose, pretty=True) log...
def run_process(cwd, args): """Executes an external process via subprocess.Popen""" try: process = check_output(args, cwd=cwd, stderr=STDOUT) return process except CalledProcessError as e: log('Uh oh, the teapot broke again! Error:', e, type(e), lvl=verbose, pretty=True) log...
[ "Executes", "an", "external", "process", "via", "subprocess", ".", "Popen" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/__init__.py#L66-L75
[ "def", "run_process", "(", "cwd", ",", "args", ")", ":", "try", ":", "process", "=", "check_output", "(", "args", ",", "cwd", "=", "cwd", ",", "stderr", "=", "STDOUT", ")", "return", "process", "except", "CalledProcessError", "as", "e", ":", "log", "("...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
_ask_password
Securely and interactively ask for a password
hfos/tool/__init__.py
def _ask_password(): """Securely and interactively ask for a password""" password = "Foo" password_trial = "" while password != password_trial: password = getpass.getpass() password_trial = getpass.getpass(prompt="Repeat:") if password != password_trial: print("\nPa...
def _ask_password(): """Securely and interactively ask for a password""" password = "Foo" password_trial = "" while password != password_trial: password = getpass.getpass() password_trial = getpass.getpass(prompt="Repeat:") if password != password_trial: print("\nPa...
[ "Securely", "and", "interactively", "ask", "for", "a", "password" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/__init__.py#L78-L90
[ "def", "_ask_password", "(", ")", ":", "password", "=", "\"Foo\"", "password_trial", "=", "\"\"", "while", "password", "!=", "password_trial", ":", "password", "=", "getpass", ".", "getpass", "(", ")", "password_trial", "=", "getpass", ".", "getpass", "(", "...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
_get_credentials
Obtain user credentials by arguments or asking the user
hfos/tool/__init__.py
def _get_credentials(username=None, password=None, dbhost=None): """Obtain user credentials by arguments or asking the user""" # Database salt system_config = dbhost.objectmodels['systemconfig'].find_one({ 'active': True }) try: salt = system_config.salt.encode('ascii') except ...
def _get_credentials(username=None, password=None, dbhost=None): """Obtain user credentials by arguments or asking the user""" # Database salt system_config = dbhost.objectmodels['systemconfig'].find_one({ 'active': True }) try: salt = system_config.salt.encode('ascii') except ...
[ "Obtain", "user", "credentials", "by", "arguments", "or", "asking", "the", "user" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/__init__.py#L93-L127
[ "def", "_get_credentials", "(", "username", "=", "None", ",", "password", "=", "None", ",", "dbhost", "=", "None", ")", ":", "# Database salt", "system_config", "=", "dbhost", ".", "objectmodels", "[", "'systemconfig'", "]", ".", "find_one", "(", "{", "'acti...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
_ask
Interactively ask the user for data
hfos/tool/__init__.py
def _ask(question, default=None, data_type='str', show_hint=False): """Interactively ask the user for data""" data = default if data_type == 'bool': data = None default_string = "Y" if default else "N" while data not in ('Y', 'J', 'N', '1', '0'): data = input("%s? [%s]...
def _ask(question, default=None, data_type='str', show_hint=False): """Interactively ask the user for data""" data = default if data_type == 'bool': data = None default_string = "Y" if default else "N" while data not in ('Y', 'J', 'N', '1', '0'): data = input("%s? [%s]...
[ "Interactively", "ask", "the", "user", "for", "data" ]
Hackerfleet/hfos
python
https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/tool/__init__.py#L140-L180
[ "def", "_ask", "(", "question", ",", "default", "=", "None", ",", "data_type", "=", "'str'", ",", "show_hint", "=", "False", ")", ":", "data", "=", "default", "if", "data_type", "==", "'bool'", ":", "data", "=", "None", "default_string", "=", "\"Y\"", ...
b6df14eacaffb6be5c844108873ff8763ec7f0c9
train
checklat
Makes sure the latitude is inside [-90, 90], clipping close values (tolerance 1e-4). Parameters ========== lat : array_like latitude name : str, optional parameter name to use in the exception message Returns ======= lat : ndarray or float Same as input where va...
src/apexpy/helpers.py
def checklat(lat, name='lat'): """Makes sure the latitude is inside [-90, 90], clipping close values (tolerance 1e-4). Parameters ========== lat : array_like latitude name : str, optional parameter name to use in the exception message Returns ======= lat : ndarray o...
def checklat(lat, name='lat'): """Makes sure the latitude is inside [-90, 90], clipping close values (tolerance 1e-4). Parameters ========== lat : array_like latitude name : str, optional parameter name to use in the exception message Returns ======= lat : ndarray o...
[ "Makes", "sure", "the", "latitude", "is", "inside", "[", "-", "90", "90", "]", "clipping", "close", "values", "(", "tolerance", "1e", "-", "4", ")", "." ]
aburrell/apexpy
python
https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/helpers.py#L11-L52
[ "def", "checklat", "(", "lat", ",", "name", "=", "'lat'", ")", ":", "if", "np", ".", "all", "(", "np", ".", "float64", "(", "lat", ")", ">=", "-", "90", ")", "and", "np", ".", "all", "(", "np", ".", "float64", "(", "lat", ")", "<=", "90", "...
a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386
train
getsinIm
Computes sinIm from modified apex latitude. Parameters ========== alat : array_like Modified apex latitude Returns ======= sinIm : ndarray or float
src/apexpy/helpers.py
def getsinIm(alat): """Computes sinIm from modified apex latitude. Parameters ========== alat : array_like Modified apex latitude Returns ======= sinIm : ndarray or float """ alat = np.float64(alat) return 2*np.sin(np.radians(alat))/np.sqrt(4 - 3*np.cos(np.radians(al...
def getsinIm(alat): """Computes sinIm from modified apex latitude. Parameters ========== alat : array_like Modified apex latitude Returns ======= sinIm : ndarray or float """ alat = np.float64(alat) return 2*np.sin(np.radians(alat))/np.sqrt(4 - 3*np.cos(np.radians(al...
[ "Computes", "sinIm", "from", "modified", "apex", "latitude", "." ]
aburrell/apexpy
python
https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/helpers.py#L55-L71
[ "def", "getsinIm", "(", "alat", ")", ":", "alat", "=", "np", ".", "float64", "(", "alat", ")", "return", "2", "*", "np", ".", "sin", "(", "np", ".", "radians", "(", "alat", ")", ")", "/", "np", ".", "sqrt", "(", "4", "-", "3", "*", "np", "....
a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386
train
getcosIm
Computes cosIm from modified apex latitude. Parameters ========== alat : array_like Modified apex latitude Returns ======= cosIm : ndarray or float
src/apexpy/helpers.py
def getcosIm(alat): """Computes cosIm from modified apex latitude. Parameters ========== alat : array_like Modified apex latitude Returns ======= cosIm : ndarray or float """ alat = np.float64(alat) return np.cos(np.radians(alat))/np.sqrt(4 - 3*np.cos(np.radians(alat...
def getcosIm(alat): """Computes cosIm from modified apex latitude. Parameters ========== alat : array_like Modified apex latitude Returns ======= cosIm : ndarray or float """ alat = np.float64(alat) return np.cos(np.radians(alat))/np.sqrt(4 - 3*np.cos(np.radians(alat...
[ "Computes", "cosIm", "from", "modified", "apex", "latitude", "." ]
aburrell/apexpy
python
https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/helpers.py#L74-L90
[ "def", "getcosIm", "(", "alat", ")", ":", "alat", "=", "np", ".", "float64", "(", "alat", ")", "return", "np", ".", "cos", "(", "np", ".", "radians", "(", "alat", ")", ")", "/", "np", ".", "sqrt", "(", "4", "-", "3", "*", "np", ".", "cos", ...
a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386
train
toYearFraction
Converts :class:`datetime.date` or :class:`datetime.datetime` to decimal year. Parameters ========== date : :class:`datetime.date` or :class:`datetime.datetime` Returns ======= year : float Decimal year Notes ===== The algorithm is taken from http://stackoverflow.com/a...
src/apexpy/helpers.py
def toYearFraction(date): """Converts :class:`datetime.date` or :class:`datetime.datetime` to decimal year. Parameters ========== date : :class:`datetime.date` or :class:`datetime.datetime` Returns ======= year : float Decimal year Notes ===== The algorithm is take...
def toYearFraction(date): """Converts :class:`datetime.date` or :class:`datetime.datetime` to decimal year. Parameters ========== date : :class:`datetime.date` or :class:`datetime.datetime` Returns ======= year : float Decimal year Notes ===== The algorithm is take...
[ "Converts", ":", "class", ":", "datetime", ".", "date", "or", ":", "class", ":", "datetime", ".", "datetime", "to", "decimal", "year", "." ]
aburrell/apexpy
python
https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/helpers.py#L93-L123
[ "def", "toYearFraction", "(", "date", ")", ":", "def", "sinceEpoch", "(", "date", ")", ":", "\"\"\"returns seconds since epoch\"\"\"", "return", "time", ".", "mktime", "(", "date", ".", "timetuple", "(", ")", ")", "year", "=", "date", ".", "year", "startOfTh...
a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386
train
gc2gdlat
Converts geocentric latitude to geodetic latitude using WGS84. Parameters ========== gclat : array_like Geocentric latitude Returns ======= gdlat : ndarray or float Geodetic latitude
src/apexpy/helpers.py
def gc2gdlat(gclat): """Converts geocentric latitude to geodetic latitude using WGS84. Parameters ========== gclat : array_like Geocentric latitude Returns ======= gdlat : ndarray or float Geodetic latitude """ WGS84_e2 = 0.006694379990141317 # WGS84 first eccentr...
def gc2gdlat(gclat): """Converts geocentric latitude to geodetic latitude using WGS84. Parameters ========== gclat : array_like Geocentric latitude Returns ======= gdlat : ndarray or float Geodetic latitude """ WGS84_e2 = 0.006694379990141317 # WGS84 first eccentr...
[ "Converts", "geocentric", "latitude", "to", "geodetic", "latitude", "using", "WGS84", "." ]
aburrell/apexpy
python
https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/helpers.py#L126-L141
[ "def", "gc2gdlat", "(", "gclat", ")", ":", "WGS84_e2", "=", "0.006694379990141317", "# WGS84 first eccentricity squared", "return", "np", ".", "rad2deg", "(", "-", "np", ".", "arctan", "(", "np", ".", "tan", "(", "np", ".", "deg2rad", "(", "gclat", ")", ")...
a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386
train
subsol
Finds subsolar geocentric latitude and longitude. Parameters ========== datetime : :class:`datetime.datetime` Returns ======= sbsllat : float Latitude of subsolar point sbsllon : float Longitude of subsolar point Notes ===== Based on formulas in Astronomical Al...
src/apexpy/helpers.py
def subsol(datetime): """Finds subsolar geocentric latitude and longitude. Parameters ========== datetime : :class:`datetime.datetime` Returns ======= sbsllat : float Latitude of subsolar point sbsllon : float Longitude of subsolar point Notes ===== Based o...
def subsol(datetime): """Finds subsolar geocentric latitude and longitude. Parameters ========== datetime : :class:`datetime.datetime` Returns ======= sbsllat : float Latitude of subsolar point sbsllon : float Longitude of subsolar point Notes ===== Based o...
[ "Finds", "subsolar", "geocentric", "latitude", "and", "longitude", "." ]
aburrell/apexpy
python
https://github.com/aburrell/apexpy/blob/a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386/src/apexpy/helpers.py#L144-L226
[ "def", "subsol", "(", "datetime", ")", ":", "# convert to year, day of year and seconds since midnight", "year", "=", "datetime", ".", "year", "doy", "=", "datetime", ".", "timetuple", "(", ")", ".", "tm_yday", "ut", "=", "datetime", ".", "hour", "*", "3600", ...
a2e919fd9ea9a65d49c4c22c9eb030c8ccf48386