repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_terrain.py
TerrainModule.cmd_terrain_check
def cmd_terrain_check(self, args): '''check a piece of terrain data''' if len(args) >= 2: latlon = (float(args[0]), float(args[1])) else: try: latlon = self.module('map').click_position except Exception: print("No map available"...
python
def cmd_terrain_check(self, args): '''check a piece of terrain data''' if len(args) >= 2: latlon = (float(args[0]), float(args[1])) else: try: latlon = self.module('map').click_position except Exception: print("No map available"...
[ "def", "cmd_terrain_check", "(", "self", ",", "args", ")", ":", "if", "len", "(", "args", ")", ">=", "2", ":", "latlon", "=", "(", "float", "(", "args", "[", "0", "]", ")", ",", "float", "(", "args", "[", "1", "]", ")", ")", "else", ":", "try...
check a piece of terrain data
[ "check", "a", "piece", "of", "terrain", "data" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_terrain.py#L49-L64
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_terrain.py
TerrainModule.idle_task
def idle_task(self): '''called when idle''' if self.current_request is None: return if time.time() - self.last_send_time < 0.2: # limit to 5 per second return self.send_terrain_data()
python
def idle_task(self): '''called when idle''' if self.current_request is None: return if time.time() - self.last_send_time < 0.2: # limit to 5 per second return self.send_terrain_data()
[ "def", "idle_task", "(", "self", ")", ":", "if", "self", ".", "current_request", "is", "None", ":", "return", "if", "time", ".", "time", "(", ")", "-", "self", ".", "last_send_time", "<", "0.2", ":", "# limit to 5 per second", "return", "self", ".", "sen...
called when idle
[ "called", "when", "idle" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_terrain.py#L134-L141
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_mode.py
ModeModule.unknown_command
def unknown_command(self, args): '''handle mode switch by mode name as command''' mode_mapping = self.master.mode_mapping() mode = args[0].upper() if mode in mode_mapping: self.master.set_mode(mode_mapping[mode]) return True return False
python
def unknown_command(self, args): '''handle mode switch by mode name as command''' mode_mapping = self.master.mode_mapping() mode = args[0].upper() if mode in mode_mapping: self.master.set_mode(mode_mapping[mode]) return True return False
[ "def", "unknown_command", "(", "self", ",", "args", ")", ":", "mode_mapping", "=", "self", ".", "master", ".", "mode_mapping", "(", ")", "mode", "=", "args", "[", "0", "]", ".", "upper", "(", ")", "if", "mode", "in", "mode_mapping", ":", "self", ".",...
handle mode switch by mode name as command
[ "handle", "mode", "switch", "by", "mode", "name", "as", "command" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_mode.py#L41-L48
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_mode.py
ModeModule.cmd_guided
def cmd_guided(self, args): '''set GUIDED target''' if len(args) != 1 and len(args) != 3: print("Usage: guided ALTITUDE | guided LAT LON ALTITUDE") return if len(args) == 3: latitude = float(args[0]) longitude = float(args[1]) altitude...
python
def cmd_guided(self, args): '''set GUIDED target''' if len(args) != 1 and len(args) != 3: print("Usage: guided ALTITUDE | guided LAT LON ALTITUDE") return if len(args) == 3: latitude = float(args[0]) longitude = float(args[1]) altitude...
[ "def", "cmd_guided", "(", "self", ",", "args", ")", ":", "if", "len", "(", "args", ")", "!=", "1", "and", "len", "(", "args", ")", "!=", "3", ":", "print", "(", "\"Usage: guided ALTITUDE | guided LAT LON ALTITUDE\"", ")", "return", "if", "len", "(", "arg...
set GUIDED target
[ "set", "GUIDED", "target" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_mode.py#L50-L79
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_HIL.py
HILModule.check_sim_in
def check_sim_in(self): '''check for FDM packets from runsim''' try: pkt = self.sim_in.recv(17*8 + 4) except socket.error as e: if not e.errno in [ errno.EAGAIN, errno.EWOULDBLOCK ]: raise return if len(pkt) != 17*8 + 4: # w...
python
def check_sim_in(self): '''check for FDM packets from runsim''' try: pkt = self.sim_in.recv(17*8 + 4) except socket.error as e: if not e.errno in [ errno.EAGAIN, errno.EWOULDBLOCK ]: raise return if len(pkt) != 17*8 + 4: # w...
[ "def", "check_sim_in", "(", "self", ")", ":", "try", ":", "pkt", "=", "self", ".", "sim_in", ".", "recv", "(", "17", "*", "8", "+", "4", ")", "except", "socket", ".", "error", "as", "e", ":", "if", "not", "e", ".", "errno", "in", "[", "errno", ...
check for FDM packets from runsim
[ "check", "for", "FDM", "packets", "from", "runsim" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_HIL.py#L53-L90
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_HIL.py
HILModule.check_sim_out
def check_sim_out(self): '''check if we should send new servos to flightgear''' now = time.time() if now - self.last_sim_send_time < 0.02 or self.rc_channels_scaled is None: return self.last_sim_send_time = now servos = [] for ch in range(1,9): se...
python
def check_sim_out(self): '''check if we should send new servos to flightgear''' now = time.time() if now - self.last_sim_send_time < 0.02 or self.rc_channels_scaled is None: return self.last_sim_send_time = now servos = [] for ch in range(1,9): se...
[ "def", "check_sim_out", "(", "self", ")", ":", "now", "=", "time", ".", "time", "(", ")", "if", "now", "-", "self", ".", "last_sim_send_time", "<", "0.02", "or", "self", ".", "rc_channels_scaled", "is", "None", ":", "return", "self", ".", "last_sim_send_...
check if we should send new servos to flightgear
[ "check", "if", "we", "should", "send", "new", "servos", "to", "flightgear" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_HIL.py#L95-L112
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_HIL.py
HILModule.check_apm_out
def check_apm_out(self): '''check if we should send new data to the APM''' now = time.time() if now - self.last_apm_send_time < 0.02: return self.last_apm_send_time = now if self.hil_state_msg is not None: self.master.mav.send(self.hil_state_msg)
python
def check_apm_out(self): '''check if we should send new data to the APM''' now = time.time() if now - self.last_apm_send_time < 0.02: return self.last_apm_send_time = now if self.hil_state_msg is not None: self.master.mav.send(self.hil_state_msg)
[ "def", "check_apm_out", "(", "self", ")", ":", "now", "=", "time", ".", "time", "(", ")", "if", "now", "-", "self", ".", "last_apm_send_time", "<", "0.02", ":", "return", "self", ".", "last_apm_send_time", "=", "now", "if", "self", ".", "hil_state_msg", ...
check if we should send new data to the APM
[ "check", "if", "we", "should", "send", "new", "data", "to", "the", "APM" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_HIL.py#L115-L122
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_HIL.py
HILModule.convert_body_frame
def convert_body_frame(self, phi, theta, phiDot, thetaDot, psiDot): '''convert a set of roll rates from earth frame to body frame''' p = phiDot - psiDot*math.sin(theta) q = math.cos(phi)*thetaDot + math.sin(phi)*psiDot*math.cos(theta) r = math.cos(phi)*psiDot*math.cos(theta) - math.sin(p...
python
def convert_body_frame(self, phi, theta, phiDot, thetaDot, psiDot): '''convert a set of roll rates from earth frame to body frame''' p = phiDot - psiDot*math.sin(theta) q = math.cos(phi)*thetaDot + math.sin(phi)*psiDot*math.cos(theta) r = math.cos(phi)*psiDot*math.cos(theta) - math.sin(p...
[ "def", "convert_body_frame", "(", "self", ",", "phi", ",", "theta", ",", "phiDot", ",", "thetaDot", ",", "psiDot", ")", ":", "p", "=", "phiDot", "-", "psiDot", "*", "math", ".", "sin", "(", "theta", ")", "q", "=", "math", ".", "cos", "(", "phi", ...
convert a set of roll rates from earth frame to body frame
[ "convert", "a", "set", "of", "roll", "rates", "from", "earth", "frame", "to", "body", "frame" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_HIL.py#L124-L129
train
ArduPilot/MAVProxy
MAVProxy/modules/lib/mp_settings.py
MPSettings.append
def append(self, v): '''add a new setting''' if isinstance(v, MPSetting): setting = v else: (name,type,default) = v label = name tab = None if len(v) > 3: label = v[3] if len(v) > 4: tab = v[4...
python
def append(self, v): '''add a new setting''' if isinstance(v, MPSetting): setting = v else: (name,type,default) = v label = name tab = None if len(v) > 3: label = v[3] if len(v) > 4: tab = v[4...
[ "def", "append", "(", "self", ",", "v", ")", ":", "if", "isinstance", "(", "v", ",", "MPSetting", ")", ":", "setting", "=", "v", "else", ":", "(", "name", ",", "type", ",", "default", ")", "=", "v", "label", "=", "name", "tab", "=", "None", "if...
add a new setting
[ "add", "a", "new", "setting" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/mp_settings.py#L80-L101
train
ArduPilot/MAVProxy
MAVProxy/modules/lib/mp_settings.py
MPSettings.get
def get(self, name): '''get a setting''' if not name in self._vars: raise AttributeError setting = self._vars[name] return setting.value
python
def get(self, name): '''get a setting''' if not name in self._vars: raise AttributeError setting = self._vars[name] return setting.value
[ "def", "get", "(", "self", ",", "name", ")", ":", "if", "not", "name", "in", "self", ".", "_vars", ":", "raise", "AttributeError", "setting", "=", "self", ".", "_vars", "[", "name", "]", "return", "setting", ".", "value" ]
get a setting
[ "get", "a", "setting" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/mp_settings.py#L134-L139
train
ArduPilot/MAVProxy
MAVProxy/modules/lib/mp_settings.py
MPSettings.command
def command(self, args): '''control options from cmdline''' if len(args) == 0: self.show_all() return if getattr(self, args[0], [None]) == [None]: print("Unknown setting '%s'" % args[0]) return if len(args) == 1: self.show(args[...
python
def command(self, args): '''control options from cmdline''' if len(args) == 0: self.show_all() return if getattr(self, args[0], [None]) == [None]: print("Unknown setting '%s'" % args[0]) return if len(args) == 1: self.show(args[...
[ "def", "command", "(", "self", ",", "args", ")", ":", "if", "len", "(", "args", ")", "==", "0", ":", "self", ".", "show_all", "(", ")", "return", "if", "getattr", "(", "self", ",", "args", "[", "0", "]", ",", "[", "None", "]", ")", "==", "[",...
control options from cmdline
[ "control", "options", "from", "cmdline" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/mp_settings.py#L158-L169
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_arm.py
ArmModule.all_checks_enabled
def all_checks_enabled(self): ''' returns true if the UAV is skipping any arming checks''' arming_mask = int(self.get_mav_param("ARMING_CHECK",0)) if arming_mask == 1: return True for bit in arming_masks.values(): if not arming_mask & bit and bit != 1: ...
python
def all_checks_enabled(self): ''' returns true if the UAV is skipping any arming checks''' arming_mask = int(self.get_mav_param("ARMING_CHECK",0)) if arming_mask == 1: return True for bit in arming_masks.values(): if not arming_mask & bit and bit != 1: ...
[ "def", "all_checks_enabled", "(", "self", ")", ":", "arming_mask", "=", "int", "(", "self", ".", "get_mav_param", "(", "\"ARMING_CHECK\"", ",", "0", ")", ")", "if", "arming_mask", "==", "1", ":", "return", "True", "for", "bit", "in", "arming_masks", ".", ...
returns true if the UAV is skipping any arming checks
[ "returns", "true", "if", "the", "UAV", "is", "skipping", "any", "arming", "checks" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_arm.py#L144-L152
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_param.py
ParamState.handle_px4_param_value
def handle_px4_param_value(self, m): '''special handling for the px4 style of PARAM_VALUE''' if m.param_type == mavutil.mavlink.MAV_PARAM_TYPE_REAL32: # already right type return m.param_value is_px4_params = False if m.get_srcComponent() in [mavutil.mavlink.MAV_C...
python
def handle_px4_param_value(self, m): '''special handling for the px4 style of PARAM_VALUE''' if m.param_type == mavutil.mavlink.MAV_PARAM_TYPE_REAL32: # already right type return m.param_value is_px4_params = False if m.get_srcComponent() in [mavutil.mavlink.MAV_C...
[ "def", "handle_px4_param_value", "(", "self", ",", "m", ")", ":", "if", "m", ".", "param_type", "==", "mavutil", ".", "mavlink", ".", "MAV_PARAM_TYPE_REAL32", ":", "# already right type", "return", "m", ".", "param_value", "is_px4_params", "=", "False", "if", ...
special handling for the px4 style of PARAM_VALUE
[ "special", "handling", "for", "the", "px4", "style", "of", "PARAM_VALUE" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_param.py#L28-L64
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_param.py
ParamState.param_help_download
def param_help_download(self): '''download XML files for parameters''' files = [] for vehicle in ['APMrover2', 'ArduCopter', 'ArduPlane', 'ArduSub', 'AntennaTracker']: url = 'http://autotest.ardupilot.org/Parameters/%s/apm.pdef.xml' % vehicle path = mp_util.dot_mavproxy("...
python
def param_help_download(self): '''download XML files for parameters''' files = [] for vehicle in ['APMrover2', 'ArduCopter', 'ArduPlane', 'ArduSub', 'AntennaTracker']: url = 'http://autotest.ardupilot.org/Parameters/%s/apm.pdef.xml' % vehicle path = mp_util.dot_mavproxy("...
[ "def", "param_help_download", "(", "self", ")", ":", "files", "=", "[", "]", "for", "vehicle", "in", "[", "'APMrover2'", ",", "'ArduCopter'", ",", "'ArduPlane'", ",", "'ArduSub'", ",", "'AntennaTracker'", "]", ":", "url", "=", "'http://autotest.ardupilot.org/Par...
download XML files for parameters
[ "download", "XML", "files", "for", "parameters" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_param.py#L121-L137
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_param.py
ParamState.param_help_tree
def param_help_tree(self): '''return a "help tree", a map between a parameter and its metadata. May return None if help is not available''' if self.xml_filepath is not None: print("param: using xml_filepath=%s" % self.xml_filepath) path = self.xml_filepath else: ...
python
def param_help_tree(self): '''return a "help tree", a map between a parameter and its metadata. May return None if help is not available''' if self.xml_filepath is not None: print("param: using xml_filepath=%s" % self.xml_filepath) path = self.xml_filepath else: ...
[ "def", "param_help_tree", "(", "self", ")", ":", "if", "self", ".", "xml_filepath", "is", "not", "None", ":", "print", "(", "\"param: using xml_filepath=%s\"", "%", "self", ".", "xml_filepath", ")", "path", "=", "self", ".", "xml_filepath", "else", ":", "if"...
return a "help tree", a map between a parameter and its metadata. May return None if help is not available
[ "return", "a", "help", "tree", "a", "map", "between", "a", "parameter", "and", "its", "metadata", ".", "May", "return", "None", "if", "help", "is", "not", "available" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_param.py#L142-L170
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_param.py
ParamState.param_apropos
def param_apropos(self, args): '''search parameter help for a keyword, list those parameters''' if len(args) == 0: print("Usage: param apropos keyword") return htree = self.param_help_tree() if htree is None: return contains = {} for ...
python
def param_apropos(self, args): '''search parameter help for a keyword, list those parameters''' if len(args) == 0: print("Usage: param apropos keyword") return htree = self.param_help_tree() if htree is None: return contains = {} for ...
[ "def", "param_apropos", "(", "self", ",", "args", ")", ":", "if", "len", "(", "args", ")", "==", "0", ":", "print", "(", "\"Usage: param apropos keyword\"", ")", "return", "htree", "=", "self", ".", "param_help_tree", "(", ")", "if", "htree", "is", "None...
search parameter help for a keyword, list those parameters
[ "search", "parameter", "help", "for", "a", "keyword", "list", "those", "parameters" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_param.py#L175-L191
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_param.py
ParamModule.get_component_id_list
def get_component_id_list(self, system_id): '''get list of component IDs with parameters for a given system ID''' ret = [] for (s,c) in self.mpstate.mav_param_by_sysid.keys(): if s == system_id: ret.append(c) return ret
python
def get_component_id_list(self, system_id): '''get list of component IDs with parameters for a given system ID''' ret = [] for (s,c) in self.mpstate.mav_param_by_sysid.keys(): if s == system_id: ret.append(c) return ret
[ "def", "get_component_id_list", "(", "self", ",", "system_id", ")", ":", "ret", "=", "[", "]", "for", "(", "s", ",", "c", ")", "in", "self", ".", "mpstate", ".", "mav_param_by_sysid", ".", "keys", "(", ")", ":", "if", "s", "==", "system_id", ":", "...
get list of component IDs with parameters for a given system ID
[ "get", "list", "of", "component", "IDs", "with", "parameters", "for", "a", "given", "system", "ID" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_param.py#L371-L377
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_param.py
ParamModule.get_sysid
def get_sysid(self): '''get sysid tuple to use for parameters''' component = self.target_component if component == 0: component = 1 return (self.target_system, component)
python
def get_sysid(self): '''get sysid tuple to use for parameters''' component = self.target_component if component == 0: component = 1 return (self.target_system, component)
[ "def", "get_sysid", "(", "self", ")", ":", "component", "=", "self", ".", "target_component", "if", "component", "==", "0", ":", "component", "=", "1", "return", "(", "self", ".", "target_system", ",", "component", ")" ]
get sysid tuple to use for parameters
[ "get", "sysid", "tuple", "to", "use", "for", "parameters" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_param.py#L398-L403
train
ArduPilot/MAVProxy
MAVProxy/modules/lib/optparse_gui/__init__.py
OptionParser.parse_args
def parse_args( self, args = None, values = None ): ''' multiprocessing wrapper around _parse_args ''' q = multiproc.Queue() p = multiproc.Process(target=self._parse_args, args=(q, args, values)) p.start() ret = q.get() p.join() return ret
python
def parse_args( self, args = None, values = None ): ''' multiprocessing wrapper around _parse_args ''' q = multiproc.Queue() p = multiproc.Process(target=self._parse_args, args=(q, args, values)) p.start() ret = q.get() p.join() return ret
[ "def", "parse_args", "(", "self", ",", "args", "=", "None", ",", "values", "=", "None", ")", ":", "q", "=", "multiproc", ".", "Queue", "(", ")", "p", "=", "multiproc", ".", "Process", "(", "target", "=", "self", ".", "_parse_args", ",", "args", "="...
multiprocessing wrapper around _parse_args
[ "multiprocessing", "wrapper", "around", "_parse_args" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/optparse_gui/__init__.py#L206-L215
train
ArduPilot/MAVProxy
MAVProxy/modules/lib/optparse_gui/__init__.py
OptionParser._parse_args
def _parse_args( self, q, args, values): ''' This is the heart of it all - overrides optparse.OptionParser.parse_args @param arg is irrelevant and thus ignored, it is here only for interface compatibility ''' if wx.GetApp() is None: self.app = wx.App( F...
python
def _parse_args( self, q, args, values): ''' This is the heart of it all - overrides optparse.OptionParser.parse_args @param arg is irrelevant and thus ignored, it is here only for interface compatibility ''' if wx.GetApp() is None: self.app = wx.App( F...
[ "def", "_parse_args", "(", "self", ",", "q", ",", "args", ",", "values", ")", ":", "if", "wx", ".", "GetApp", "(", ")", "is", "None", ":", "self", ".", "app", "=", "wx", ".", "App", "(", "False", ")", "# preprocess command line arguments and set to defau...
This is the heart of it all - overrides optparse.OptionParser.parse_args @param arg is irrelevant and thus ignored, it is here only for interface compatibility
[ "This", "is", "the", "heart", "of", "it", "all", "-", "overrides", "optparse", ".", "OptionParser", ".", "parse_args" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/optparse_gui/__init__.py#L217-L261
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_genobstacles.py
DNFZ.distance_from
def distance_from(self, lat, lon): '''get distance from a point''' lat1 = self.pkt['I105']['Lat']['val'] lon1 = self.pkt['I105']['Lon']['val'] return mp_util.gps_distance(lat1, lon1, lat, lon)
python
def distance_from(self, lat, lon): '''get distance from a point''' lat1 = self.pkt['I105']['Lat']['val'] lon1 = self.pkt['I105']['Lon']['val'] return mp_util.gps_distance(lat1, lon1, lat, lon)
[ "def", "distance_from", "(", "self", ",", "lat", ",", "lon", ")", ":", "lat1", "=", "self", ".", "pkt", "[", "'I105'", "]", "[", "'Lat'", "]", "[", "'val'", "]", "lon1", "=", "self", ".", "pkt", "[", "'I105'", "]", "[", "'Lon'", "]", "[", "'val...
get distance from a point
[ "get", "distance", "from", "a", "point" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_genobstacles.py#L65-L69
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_genobstacles.py
DNFZ.randpos
def randpos(self): '''random initial position''' self.setpos(gen_settings.home_lat, gen_settings.home_lon) self.move(random.uniform(0, 360), random.uniform(0, gen_settings.region_width))
python
def randpos(self): '''random initial position''' self.setpos(gen_settings.home_lat, gen_settings.home_lon) self.move(random.uniform(0, 360), random.uniform(0, gen_settings.region_width))
[ "def", "randpos", "(", "self", ")", ":", "self", ".", "setpos", "(", "gen_settings", ".", "home_lat", ",", "gen_settings", ".", "home_lon", ")", "self", ".", "move", "(", "random", ".", "uniform", "(", "0", ",", "360", ")", ",", "random", ".", "unifo...
random initial position
[ "random", "initial", "position" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_genobstacles.py#L75-L78
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_genobstacles.py
DNFZ.ground_height
def ground_height(self): '''return height above ground in feet''' lat = self.pkt['I105']['Lat']['val'] lon = self.pkt['I105']['Lon']['val'] global ElevationMap ret = ElevationMap.GetElevation(lat, lon) ret -= gen_settings.wgs84_to_AMSL return ret * 3.2807
python
def ground_height(self): '''return height above ground in feet''' lat = self.pkt['I105']['Lat']['val'] lon = self.pkt['I105']['Lon']['val'] global ElevationMap ret = ElevationMap.GetElevation(lat, lon) ret -= gen_settings.wgs84_to_AMSL return ret * 3.2807
[ "def", "ground_height", "(", "self", ")", ":", "lat", "=", "self", ".", "pkt", "[", "'I105'", "]", "[", "'Lat'", "]", "[", "'val'", "]", "lon", "=", "self", ".", "pkt", "[", "'I105'", "]", "[", "'Lon'", "]", "[", "'val'", "]", "global", "Elevatio...
return height above ground in feet
[ "return", "height", "above", "ground", "in", "feet" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_genobstacles.py#L80-L87
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_genobstacles.py
DNFZ.move
def move(self, bearing, distance): '''move position by bearing and distance''' lat = self.pkt['I105']['Lat']['val'] lon = self.pkt['I105']['Lon']['val'] (lat, lon) = mp_util.gps_newpos(lat, lon, bearing, distance) self.setpos(lat, lon)
python
def move(self, bearing, distance): '''move position by bearing and distance''' lat = self.pkt['I105']['Lat']['val'] lon = self.pkt['I105']['Lon']['val'] (lat, lon) = mp_util.gps_newpos(lat, lon, bearing, distance) self.setpos(lat, lon)
[ "def", "move", "(", "self", ",", "bearing", ",", "distance", ")", ":", "lat", "=", "self", ".", "pkt", "[", "'I105'", "]", "[", "'Lat'", "]", "[", "'val'", "]", "lon", "=", "self", ".", "pkt", "[", "'I105'", "]", "[", "'Lon'", "]", "[", "'val'"...
move position by bearing and distance
[ "move", "position", "by", "bearing", "and", "distance" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_genobstacles.py#L93-L98
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_genobstacles.py
Aircraft.update
def update(self, deltat=1.0): '''fly a square circuit''' DNFZ.update(self, deltat) self.dist_flown += self.speed * deltat if self.dist_flown > self.circuit_width: self.desired_heading = self.heading + 90 self.dist_flown = 0 if self.getalt() < self.ground_h...
python
def update(self, deltat=1.0): '''fly a square circuit''' DNFZ.update(self, deltat) self.dist_flown += self.speed * deltat if self.dist_flown > self.circuit_width: self.desired_heading = self.heading + 90 self.dist_flown = 0 if self.getalt() < self.ground_h...
[ "def", "update", "(", "self", ",", "deltat", "=", "1.0", ")", ":", "DNFZ", ".", "update", "(", "self", ",", "deltat", ")", "self", ".", "dist_flown", "+=", "self", ".", "speed", "*", "deltat", "if", "self", ".", "dist_flown", ">", "self", ".", "cir...
fly a square circuit
[ "fly", "a", "square", "circuit" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_genobstacles.py#L180-L189
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_genobstacles.py
BirdOfPrey.update
def update(self, deltat=1.0): '''fly circles, then dive''' DNFZ.update(self, deltat) self.time_circling += deltat self.setheading(self.heading + self.turn_rate * deltat) self.move(self.drift_heading, self.drift_speed) if self.getalt() > self.max_alt or self.getalt() < sel...
python
def update(self, deltat=1.0): '''fly circles, then dive''' DNFZ.update(self, deltat) self.time_circling += deltat self.setheading(self.heading + self.turn_rate * deltat) self.move(self.drift_heading, self.drift_speed) if self.getalt() > self.max_alt or self.getalt() < sel...
[ "def", "update", "(", "self", ",", "deltat", "=", "1.0", ")", ":", "DNFZ", ".", "update", "(", "self", ",", "deltat", ")", "self", ".", "time_circling", "+=", "deltat", "self", ".", "setheading", "(", "self", ".", "heading", "+", "self", ".", "turn_r...
fly circles, then dive
[ "fly", "circles", "then", "dive" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_genobstacles.py#L209-L224
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_genobstacles.py
BirdMigrating.update
def update(self, deltat=1.0): '''fly in long curves''' DNFZ.update(self, deltat) if (self.distance_from_home() > gen_settings.region_width or self.getalt() < self.ground_height() or self.getalt() > self.ground_height() + 1000): self.randpos() self....
python
def update(self, deltat=1.0): '''fly in long curves''' DNFZ.update(self, deltat) if (self.distance_from_home() > gen_settings.region_width or self.getalt() < self.ground_height() or self.getalt() > self.ground_height() + 1000): self.randpos() self....
[ "def", "update", "(", "self", ",", "deltat", "=", "1.0", ")", ":", "DNFZ", ".", "update", "(", "self", ",", "deltat", ")", "if", "(", "self", ".", "distance_from_home", "(", ")", ">", "gen_settings", ".", "region_width", "or", "self", ".", "getalt", ...
fly in long curves
[ "fly", "in", "long", "curves" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_genobstacles.py#L234-L241
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_genobstacles.py
Weather.update
def update(self, deltat=1.0): '''straight lines, with short life''' DNFZ.update(self, deltat) self.lifetime -= deltat if self.lifetime <= 0: self.randpos() self.lifetime = random.uniform(300,600)
python
def update(self, deltat=1.0): '''straight lines, with short life''' DNFZ.update(self, deltat) self.lifetime -= deltat if self.lifetime <= 0: self.randpos() self.lifetime = random.uniform(300,600)
[ "def", "update", "(", "self", ",", "deltat", "=", "1.0", ")", ":", "DNFZ", ".", "update", "(", "self", ",", "deltat", ")", "self", ".", "lifetime", "-=", "deltat", "if", "self", ".", "lifetime", "<=", "0", ":", "self", ".", "randpos", "(", ")", "...
straight lines, with short life
[ "straight", "lines", "with", "short", "life" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_genobstacles.py#L252-L258
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_genobstacles.py
GenobstaclesModule.cmd_dropobject
def cmd_dropobject(self, obj): '''drop an object on the map''' latlon = self.module('map').click_position if self.last_click is not None and self.last_click == latlon: return self.last_click = latlon if latlon is not None: obj.setpos(latlon[0], latlon[1]) ...
python
def cmd_dropobject(self, obj): '''drop an object on the map''' latlon = self.module('map').click_position if self.last_click is not None and self.last_click == latlon: return self.last_click = latlon if latlon is not None: obj.setpos(latlon[0], latlon[1]) ...
[ "def", "cmd_dropobject", "(", "self", ",", "obj", ")", ":", "latlon", "=", "self", ".", "module", "(", "'map'", ")", ".", "click_position", "if", "self", ".", "last_click", "is", "not", "None", "and", "self", ".", "last_click", "==", "latlon", ":", "re...
drop an object on the map
[ "drop", "an", "object", "on", "the", "map" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_genobstacles.py#L291-L299
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_genobstacles.py
GenobstaclesModule.cmd_genobstacles
def cmd_genobstacles(self, args): '''genobstacles command parser''' usage = "usage: genobstacles <start|stop|restart|clearall|status|set>" if len(args) == 0: print(usage) return if args[0] == "set": gen_settings.command(args[1:]) elif args[0] =...
python
def cmd_genobstacles(self, args): '''genobstacles command parser''' usage = "usage: genobstacles <start|stop|restart|clearall|status|set>" if len(args) == 0: print(usage) return if args[0] == "set": gen_settings.command(args[1:]) elif args[0] =...
[ "def", "cmd_genobstacles", "(", "self", ",", "args", ")", ":", "usage", "=", "\"usage: genobstacles <start|stop|restart|clearall|status|set>\"", "if", "len", "(", "args", ")", "==", "0", ":", "print", "(", "usage", ")", "return", "if", "args", "[", "0", "]", ...
genobstacles command parser
[ "genobstacles", "command", "parser" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_genobstacles.py#L309-L359
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_genobstacles.py
GenobstaclesModule.start
def start(self): '''start sending packets''' if self.sock is not None: self.sock.close() self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) self.sock.connect(('', gen_setting...
python
def start(self): '''start sending packets''' if self.sock is not None: self.sock.close() self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) self.sock.connect(('', gen_setting...
[ "def", "start", "(", "self", ")", ":", "if", "self", ".", "sock", "is", "not", "None", ":", "self", ".", "sock", ".", "close", "(", ")", "self", ".", "sock", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_D...
start sending packets
[ "start", "sending", "packets" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_genobstacles.py#L361-L389
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_genobstacles.py
GenobstaclesModule.mavlink_packet
def mavlink_packet(self, m): '''trigger sends from ATTITUDE packets''' if not self.have_home and m.get_type() == 'GPS_RAW_INT' and m.fix_type >= 3: gen_settings.home_lat = m.lat * 1.0e-7 gen_settings.home_lon = m.lon * 1.0e-7 self.have_home = True if self....
python
def mavlink_packet(self, m): '''trigger sends from ATTITUDE packets''' if not self.have_home and m.get_type() == 'GPS_RAW_INT' and m.fix_type >= 3: gen_settings.home_lat = m.lat * 1.0e-7 gen_settings.home_lon = m.lon * 1.0e-7 self.have_home = True if self....
[ "def", "mavlink_packet", "(", "self", ",", "m", ")", ":", "if", "not", "self", ".", "have_home", "and", "m", ".", "get_type", "(", ")", "==", "'GPS_RAW_INT'", "and", "m", ".", "fix_type", ">=", "3", ":", "gen_settings", ".", "home_lat", "=", "m", "."...
trigger sends from ATTITUDE packets
[ "trigger", "sends", "from", "ATTITUDE", "packets" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_genobstacles.py#L409-L436
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_adsb.py
ADSBVehicle.update
def update(self, state, tnow): '''update the threat state''' self.state = state self.update_time = tnow
python
def update(self, state, tnow): '''update the threat state''' self.state = state self.update_time = tnow
[ "def", "update", "(", "self", ",", "state", ",", "tnow", ")", ":", "self", ".", "state", "=", "state", "self", ".", "update_time", "=", "tnow" ]
update the threat state
[ "update", "the", "threat", "state" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_adsb.py#L50-L53
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_adsb.py
ADSBModule.cmd_ADSB
def cmd_ADSB(self, args): '''adsb command parser''' usage = "usage: adsb <set>" if len(args) == 0: print(usage) return if args[0] == "status": print("total threat count: %u active threat count: %u" % (len(self.threat_vehicles), len(s...
python
def cmd_ADSB(self, args): '''adsb command parser''' usage = "usage: adsb <set>" if len(args) == 0: print(usage) return if args[0] == "status": print("total threat count: %u active threat count: %u" % (len(self.threat_vehicles), len(s...
[ "def", "cmd_ADSB", "(", "self", ",", "args", ")", ":", "usage", "=", "\"usage: adsb <set>\"", "if", "len", "(", "args", ")", "==", "0", ":", "print", "(", "usage", ")", "return", "if", "args", "[", "0", "]", "==", "\"status\"", ":", "print", "(", "...
adsb command parser
[ "adsb", "command", "parser" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_adsb.py#L79-L97
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_adsb.py
ADSBModule.update_threat_distances
def update_threat_distances(self, latlonalt): '''update the distance between threats and vehicle''' for id in self.threat_vehicles.keys(): threat_latlonalt = (self.threat_vehicles[id].state['lat'] * 1e-7, self.threat_vehicles[id].state['lon'] * 1e-7, ...
python
def update_threat_distances(self, latlonalt): '''update the distance between threats and vehicle''' for id in self.threat_vehicles.keys(): threat_latlonalt = (self.threat_vehicles[id].state['lat'] * 1e-7, self.threat_vehicles[id].state['lon'] * 1e-7, ...
[ "def", "update_threat_distances", "(", "self", ",", "latlonalt", ")", ":", "for", "id", "in", "self", ".", "threat_vehicles", ".", "keys", "(", ")", ":", "threat_latlonalt", "=", "(", "self", ".", "threat_vehicles", "[", "id", "]", ".", "state", "[", "'l...
update the distance between threats and vehicle
[ "update", "the", "distance", "between", "threats", "and", "vehicle" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_adsb.py#L122-L134
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_adsb.py
ADSBModule.check_threat_timeout
def check_threat_timeout(self): '''check and handle threat time out''' for id in self.threat_vehicles.keys(): if self.threat_vehicles[id].update_time == 0: self.threat_vehicles[id].update_time = self.get_time() dt = self.get_time() - self.threat_vehicles[id].updat...
python
def check_threat_timeout(self): '''check and handle threat time out''' for id in self.threat_vehicles.keys(): if self.threat_vehicles[id].update_time == 0: self.threat_vehicles[id].update_time = self.get_time() dt = self.get_time() - self.threat_vehicles[id].updat...
[ "def", "check_threat_timeout", "(", "self", ")", ":", "for", "id", "in", "self", ".", "threat_vehicles", ".", "keys", "(", ")", ":", "if", "self", ".", "threat_vehicles", "[", "id", "]", ".", "update_time", "==", "0", ":", "self", ".", "threat_vehicles",...
check and handle threat time out
[ "check", "and", "handle", "threat", "time", "out" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_adsb.py#L160-L176
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_gopro.py
GoProModule.cmd_gopro_status
def cmd_gopro_status(self, args): '''show gopro status''' master = self.master if 'GOPRO_HEARTBEAT' in master.messages: print(master.messages['GOPRO_HEARTBEAT']) else: print("No GOPRO_HEARTBEAT messages")
python
def cmd_gopro_status(self, args): '''show gopro status''' master = self.master if 'GOPRO_HEARTBEAT' in master.messages: print(master.messages['GOPRO_HEARTBEAT']) else: print("No GOPRO_HEARTBEAT messages")
[ "def", "cmd_gopro_status", "(", "self", ",", "args", ")", ":", "master", "=", "self", ".", "master", "if", "'GOPRO_HEARTBEAT'", "in", "master", ".", "messages", ":", "print", "(", "master", ".", "messages", "[", "'GOPRO_HEARTBEAT'", "]", ")", "else", ":", ...
show gopro status
[ "show", "gopro", "status" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_gopro.py#L76-L82
train
ArduPilot/MAVProxy
MAVProxy/modules/lib/wxconsole_ui.py
ConsoleFrame.on_text_url
def on_text_url(self, event): '''handle double clicks on URL text''' try: import webbrowser except ImportError: return mouse_event = event.GetMouseEvent() if mouse_event.LeftDClick(): url_start = event.GetURLStart() url_end = event....
python
def on_text_url(self, event): '''handle double clicks on URL text''' try: import webbrowser except ImportError: return mouse_event = event.GetMouseEvent() if mouse_event.LeftDClick(): url_start = event.GetURLStart() url_end = event....
[ "def", "on_text_url", "(", "self", ",", "event", ")", ":", "try", ":", "import", "webbrowser", "except", "ImportError", ":", "return", "mouse_event", "=", "event", ".", "GetMouseEvent", "(", ")", "if", "mouse_event", ".", "LeftDClick", "(", ")", ":", "url_...
handle double clicks on URL text
[ "handle", "double", "clicks", "on", "URL", "text" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/wxconsole_ui.py#L55-L72
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_heliplane.py
HeliPlaneModule.update_channels
def update_channels(self): '''update which channels provide input''' self.interlock_channel = -1 self.override_channel = -1 self.zero_I_channel = -1 self.no_vtol_channel = -1 # output channels self.rsc_out_channel = 9 self.fwd_thr_channel = 10 fo...
python
def update_channels(self): '''update which channels provide input''' self.interlock_channel = -1 self.override_channel = -1 self.zero_I_channel = -1 self.no_vtol_channel = -1 # output channels self.rsc_out_channel = 9 self.fwd_thr_channel = 10 fo...
[ "def", "update_channels", "(", "self", ")", ":", "self", ".", "interlock_channel", "=", "-", "1", "self", ".", "override_channel", "=", "-", "1", "self", ".", "zero_I_channel", "=", "-", "1", "self", ".", "no_vtol_channel", "=", "-", "1", "# output channel...
update which channels provide input
[ "update", "which", "channels", "provide", "input" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_heliplane.py#L102-L130
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_rally.py
RallyModule.rallyloader
def rallyloader(self): '''rally loader by system ID''' if not self.target_system in self.rallyloader_by_sysid: self.rallyloader_by_sysid[self.target_system] = mavwp.MAVRallyLoader(self.settings.target_system, se...
python
def rallyloader(self): '''rally loader by system ID''' if not self.target_system in self.rallyloader_by_sysid: self.rallyloader_by_sysid[self.target_system] = mavwp.MAVRallyLoader(self.settings.target_system, se...
[ "def", "rallyloader", "(", "self", ")", ":", "if", "not", "self", ".", "target_system", "in", "self", ".", "rallyloader_by_sysid", ":", "self", ".", "rallyloader_by_sysid", "[", "self", ".", "target_system", "]", "=", "mavwp", ".", "MAVRallyLoader", "(", "se...
rally loader by system ID
[ "rally", "loader", "by", "system", "ID" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_rally.py#L45-L50
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_dataflash_logger.py
dataflash_logger.packet_is_for_me
def packet_is_for_me(self, m): '''returns true if this packet is appropriately addressed''' if m.target_system != self.master.mav.srcSystem: return False if m.target_component != self.master.mav.srcComponent: return False # if have a sender we can also check the s...
python
def packet_is_for_me(self, m): '''returns true if this packet is appropriately addressed''' if m.target_system != self.master.mav.srcSystem: return False if m.target_component != self.master.mav.srcComponent: return False # if have a sender we can also check the s...
[ "def", "packet_is_for_me", "(", "self", ",", "m", ")", ":", "if", "m", ".", "target_system", "!=", "self", ".", "master", ".", "mav", ".", "srcSystem", ":", "return", "False", "if", "m", ".", "target_component", "!=", "self", ".", "master", ".", "mav",...
returns true if this packet is appropriately addressed
[ "returns", "true", "if", "this", "packet", "is", "appropriately", "addressed" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_dataflash_logger.py#L261-L271
train
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wxagg.py
_convert_agg_to_wx_image
def _convert_agg_to_wx_image(agg, bbox): """ Convert the region of the agg buffer bounded by bbox to a wx.Image. If bbox is None, the entire buffer is converted. Note: agg must be a backend_agg.RendererAgg instance. """ if bbox is None: # agg => rgb -> image image = wx.EmptyIma...
python
def _convert_agg_to_wx_image(agg, bbox): """ Convert the region of the agg buffer bounded by bbox to a wx.Image. If bbox is None, the entire buffer is converted. Note: agg must be a backend_agg.RendererAgg instance. """ if bbox is None: # agg => rgb -> image image = wx.EmptyIma...
[ "def", "_convert_agg_to_wx_image", "(", "agg", ",", "bbox", ")", ":", "if", "bbox", "is", "None", ":", "# agg => rgb -> image", "image", "=", "wx", ".", "EmptyImage", "(", "int", "(", "agg", ".", "width", ")", ",", "int", "(", "agg", ".", "height", ")"...
Convert the region of the agg buffer bounded by bbox to a wx.Image. If bbox is None, the entire buffer is converted. Note: agg must be a backend_agg.RendererAgg instance.
[ "Convert", "the", "region", "of", "the", "agg", "buffer", "bounded", "by", "bbox", "to", "a", "wx", ".", "Image", ".", "If", "bbox", "is", "None", "the", "entire", "buffer", "is", "converted", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wxagg.py#L128-L142
train
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wxagg.py
_convert_agg_to_wx_bitmap
def _convert_agg_to_wx_bitmap(agg, bbox): """ Convert the region of the agg buffer bounded by bbox to a wx.Bitmap. If bbox is None, the entire buffer is converted. Note: agg must be a backend_agg.RendererAgg instance. """ if bbox is None: # agg => rgba buffer -> bitmap return w...
python
def _convert_agg_to_wx_bitmap(agg, bbox): """ Convert the region of the agg buffer bounded by bbox to a wx.Bitmap. If bbox is None, the entire buffer is converted. Note: agg must be a backend_agg.RendererAgg instance. """ if bbox is None: # agg => rgba buffer -> bitmap return w...
[ "def", "_convert_agg_to_wx_bitmap", "(", "agg", ",", "bbox", ")", ":", "if", "bbox", "is", "None", ":", "# agg => rgba buffer -> bitmap", "return", "wx", ".", "BitmapFromBufferRGBA", "(", "int", "(", "agg", ".", "width", ")", ",", "int", "(", "agg", ".", "...
Convert the region of the agg buffer bounded by bbox to a wx.Bitmap. If bbox is None, the entire buffer is converted. Note: agg must be a backend_agg.RendererAgg instance.
[ "Convert", "the", "region", "of", "the", "agg", "buffer", "bounded", "by", "bbox", "to", "a", "wx", ".", "Bitmap", ".", "If", "bbox", "is", "None", "the", "entire", "buffer", "is", "converted", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wxagg.py#L145-L158
train
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wxagg.py
_WX28_clipped_agg_as_bitmap
def _WX28_clipped_agg_as_bitmap(agg, bbox): """ Convert the region of a the agg buffer bounded by bbox to a wx.Bitmap. Note: agg must be a backend_agg.RendererAgg instance. """ l, b, width, height = bbox.bounds r = l + width t = b + height srcBmp = wx.BitmapFromBufferRGBA(int(agg.width...
python
def _WX28_clipped_agg_as_bitmap(agg, bbox): """ Convert the region of a the agg buffer bounded by bbox to a wx.Bitmap. Note: agg must be a backend_agg.RendererAgg instance. """ l, b, width, height = bbox.bounds r = l + width t = b + height srcBmp = wx.BitmapFromBufferRGBA(int(agg.width...
[ "def", "_WX28_clipped_agg_as_bitmap", "(", "agg", ",", "bbox", ")", ":", "l", ",", "b", ",", "width", ",", "height", "=", "bbox", ".", "bounds", "r", "=", "l", "+", "width", "t", "=", "b", "+", "height", "srcBmp", "=", "wx", ".", "BitmapFromBufferRGB...
Convert the region of a the agg buffer bounded by bbox to a wx.Bitmap. Note: agg must be a backend_agg.RendererAgg instance.
[ "Convert", "the", "region", "of", "a", "the", "agg", "buffer", "bounded", "by", "bbox", "to", "a", "wx", ".", "Bitmap", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wxagg.py#L161-L189
train
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wxagg.py
FigureCanvasWxAgg.draw
def draw(self, drawDC=None): """ Render the figure using agg. """ DEBUG_MSG("draw()", 1, self) FigureCanvasAgg.draw(self) self.bitmap = _convert_agg_to_wx_bitmap(self.get_renderer(), None) self._isDrawn = True self.gui_repaint(drawDC=drawDC)
python
def draw(self, drawDC=None): """ Render the figure using agg. """ DEBUG_MSG("draw()", 1, self) FigureCanvasAgg.draw(self) self.bitmap = _convert_agg_to_wx_bitmap(self.get_renderer(), None) self._isDrawn = True self.gui_repaint(drawDC=drawDC)
[ "def", "draw", "(", "self", ",", "drawDC", "=", "None", ")", ":", "DEBUG_MSG", "(", "\"draw()\"", ",", "1", ",", "self", ")", "FigureCanvasAgg", ".", "draw", "(", "self", ")", "self", ".", "bitmap", "=", "_convert_agg_to_wx_bitmap", "(", "self", ".", "...
Render the figure using agg.
[ "Render", "the", "figure", "using", "agg", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wxagg.py#L39-L48
train
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wxagg.py
FigureCanvasWxAgg.blit
def blit(self, bbox=None): """ Transfer the region of the agg buffer defined by bbox to the display. If bbox is None, the entire buffer is transferred. """ if bbox is None: self.bitmap = _convert_agg_to_wx_bitmap(self.get_renderer(), None) self.gui_repaint...
python
def blit(self, bbox=None): """ Transfer the region of the agg buffer defined by bbox to the display. If bbox is None, the entire buffer is transferred. """ if bbox is None: self.bitmap = _convert_agg_to_wx_bitmap(self.get_renderer(), None) self.gui_repaint...
[ "def", "blit", "(", "self", ",", "bbox", "=", "None", ")", ":", "if", "bbox", "is", "None", ":", "self", ".", "bitmap", "=", "_convert_agg_to_wx_bitmap", "(", "self", ".", "get_renderer", "(", ")", ",", "None", ")", "self", ".", "gui_repaint", "(", "...
Transfer the region of the agg buffer defined by bbox to the display. If bbox is None, the entire buffer is transferred.
[ "Transfer", "the", "region", "of", "the", "agg", "buffer", "defined", "by", "bbox", "to", "the", "display", ".", "If", "bbox", "is", "None", "the", "entire", "buffer", "is", "transferred", "." ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wxagg.py#L50-L79
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_antenna.py
AntennaModule.cmd_antenna
def cmd_antenna(self, args): '''set gcs location''' if len(args) != 2: if self.gcs_location is None: print("GCS location not set") else: print("GCS location %s" % str(self.gcs_location)) return self.gcs_location = (float(args[0]...
python
def cmd_antenna(self, args): '''set gcs location''' if len(args) != 2: if self.gcs_location is None: print("GCS location not set") else: print("GCS location %s" % str(self.gcs_location)) return self.gcs_location = (float(args[0]...
[ "def", "cmd_antenna", "(", "self", ",", "args", ")", ":", "if", "len", "(", "args", ")", "!=", "2", ":", "if", "self", ".", "gcs_location", "is", "None", ":", "print", "(", "\"GCS location not set\"", ")", "else", ":", "print", "(", "\"GCS location %s\""...
set gcs location
[ "set", "gcs", "location" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_antenna.py#L20-L28
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_signing.py
SigningModule.passphrase_to_key
def passphrase_to_key(self, passphrase): '''convert a passphrase to a 32 byte key''' import hashlib h = hashlib.new('sha256') h.update(passphrase) return h.digest()
python
def passphrase_to_key(self, passphrase): '''convert a passphrase to a 32 byte key''' import hashlib h = hashlib.new('sha256') h.update(passphrase) return h.digest()
[ "def", "passphrase_to_key", "(", "self", ",", "passphrase", ")", ":", "import", "hashlib", "h", "=", "hashlib", ".", "new", "(", "'sha256'", ")", "h", ".", "update", "(", "passphrase", ")", "return", "h", ".", "digest", "(", ")" ]
convert a passphrase to a 32 byte key
[ "convert", "a", "passphrase", "to", "a", "32", "byte", "key" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_signing.py#L39-L44
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_signing.py
SigningModule.cmd_signing_setup
def cmd_signing_setup(self, args): '''setup signing key on board''' if len(args) == 0: print("usage: signing setup passphrase") return if not self.master.mavlink20(): print("You must be using MAVLink2 for signing") return passphrase = args[...
python
def cmd_signing_setup(self, args): '''setup signing key on board''' if len(args) == 0: print("usage: signing setup passphrase") return if not self.master.mavlink20(): print("You must be using MAVLink2 for signing") return passphrase = args[...
[ "def", "cmd_signing_setup", "(", "self", ",", "args", ")", ":", "if", "len", "(", "args", ")", "==", "0", ":", "print", "(", "\"usage: signing setup passphrase\"", ")", "return", "if", "not", "self", ".", "master", ".", "mavlink20", "(", ")", ":", "print...
setup signing key on board
[ "setup", "signing", "key", "on", "board" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_signing.py#L46-L66
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_signing.py
SigningModule.allow_unsigned
def allow_unsigned(self, mav, msgId): '''see if an unsigned packet should be allowed''' if self.allow is None: self.allow = { mavutil.mavlink.MAVLINK_MSG_ID_RADIO : True, mavutil.mavlink.MAVLINK_MSG_ID_RADIO_STATUS : True } if msgId in ...
python
def allow_unsigned(self, mav, msgId): '''see if an unsigned packet should be allowed''' if self.allow is None: self.allow = { mavutil.mavlink.MAVLINK_MSG_ID_RADIO : True, mavutil.mavlink.MAVLINK_MSG_ID_RADIO_STATUS : True } if msgId in ...
[ "def", "allow_unsigned", "(", "self", ",", "mav", ",", "msgId", ")", ":", "if", "self", ".", "allow", "is", "None", ":", "self", ".", "allow", "=", "{", "mavutil", ".", "mavlink", ".", "MAVLINK_MSG_ID_RADIO", ":", "True", ",", "mavutil", ".", "mavlink"...
see if an unsigned packet should be allowed
[ "see", "if", "an", "unsigned", "packet", "should", "be", "allowed" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_signing.py#L69-L80
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_signing.py
SigningModule.cmd_signing_key
def cmd_signing_key(self, args): '''set signing key on connection''' if len(args) == 0: print("usage: signing setup passphrase") return if not self.master.mavlink20(): print("You must be using MAVLink2 for signing") return passphrase = args...
python
def cmd_signing_key(self, args): '''set signing key on connection''' if len(args) == 0: print("usage: signing setup passphrase") return if not self.master.mavlink20(): print("You must be using MAVLink2 for signing") return passphrase = args...
[ "def", "cmd_signing_key", "(", "self", ",", "args", ")", ":", "if", "len", "(", "args", ")", "==", "0", ":", "print", "(", "\"usage: signing setup passphrase\"", ")", "return", "if", "not", "self", ".", "master", ".", "mavlink20", "(", ")", ":", "print",...
set signing key on connection
[ "set", "signing", "key", "on", "connection" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_signing.py#L82-L93
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_signing.py
SigningModule.cmd_signing_remove
def cmd_signing_remove(self, args): '''remove signing from server''' if not self.master.mavlink20(): print("You must be using MAVLink2 for signing") return self.master.mav.setup_signing_send(self.target_system, self.target_component, [0]*32, 0) self.master.disable...
python
def cmd_signing_remove(self, args): '''remove signing from server''' if not self.master.mavlink20(): print("You must be using MAVLink2 for signing") return self.master.mav.setup_signing_send(self.target_system, self.target_component, [0]*32, 0) self.master.disable...
[ "def", "cmd_signing_remove", "(", "self", ",", "args", ")", ":", "if", "not", "self", ".", "master", ".", "mavlink20", "(", ")", ":", "print", "(", "\"You must be using MAVLink2 for signing\"", ")", "return", "self", ".", "master", ".", "mav", ".", "setup_si...
remove signing from server
[ "remove", "signing", "from", "server" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_signing.py#L100-L107
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_output.py
OutputModule.cmd_output
def cmd_output(self, args): '''handle output commands''' if len(args) < 1 or args[0] == "list": self.cmd_output_list() elif args[0] == "add": if len(args) != 2: print("Usage: output add OUTPUT") return self.cmd_output_add(args[1...
python
def cmd_output(self, args): '''handle output commands''' if len(args) < 1 or args[0] == "list": self.cmd_output_list() elif args[0] == "add": if len(args) != 2: print("Usage: output add OUTPUT") return self.cmd_output_add(args[1...
[ "def", "cmd_output", "(", "self", ",", "args", ")", ":", "if", "len", "(", "args", ")", "<", "1", "or", "args", "[", "0", "]", "==", "\"list\"", ":", "self", ".", "cmd_output_list", "(", ")", "elif", "args", "[", "0", "]", "==", "\"add\"", ":", ...
handle output commands
[ "handle", "output", "commands" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_output.py#L21-L41
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_output.py
OutputModule.cmd_output_add
def cmd_output_add(self, args): '''add new output''' device = args[0] print("Adding output %s" % device) try: conn = mavutil.mavlink_connection(device, input=False, source_system=self.settings.source_system) conn.mav.srcComponent = self.settings.source_component ...
python
def cmd_output_add(self, args): '''add new output''' device = args[0] print("Adding output %s" % device) try: conn = mavutil.mavlink_connection(device, input=False, source_system=self.settings.source_system) conn.mav.srcComponent = self.settings.source_component ...
[ "def", "cmd_output_add", "(", "self", ",", "args", ")", ":", "device", "=", "args", "[", "0", "]", "print", "(", "\"Adding output %s\"", "%", "device", ")", "try", ":", "conn", "=", "mavutil", ".", "mavlink_connection", "(", "device", ",", "input", "=", ...
add new output
[ "add", "new", "output" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_output.py#L55-L69
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_output.py
OutputModule.cmd_output_sysid
def cmd_output_sysid(self, args): '''add new output for a specific MAVLink sysID''' sysid = int(args[0]) device = args[1] print("Adding output %s for sysid %u" % (device, sysid)) try: conn = mavutil.mavlink_connection(device, input=False, source_system=self.settings.s...
python
def cmd_output_sysid(self, args): '''add new output for a specific MAVLink sysID''' sysid = int(args[0]) device = args[1] print("Adding output %s for sysid %u" % (device, sysid)) try: conn = mavutil.mavlink_connection(device, input=False, source_system=self.settings.s...
[ "def", "cmd_output_sysid", "(", "self", ",", "args", ")", ":", "sysid", "=", "int", "(", "args", "[", "0", "]", ")", "device", "=", "args", "[", "1", "]", "print", "(", "\"Adding output %s for sysid %u\"", "%", "(", "device", ",", "sysid", ")", ")", ...
add new output for a specific MAVLink sysID
[ "add", "new", "output", "for", "a", "specific", "MAVLink", "sysID" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_output.py#L71-L88
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_output.py
OutputModule.cmd_output_remove
def cmd_output_remove(self, args): '''remove an output''' device = args[0] for i in range(len(self.mpstate.mav_outputs)): conn = self.mpstate.mav_outputs[i] if str(i) == device or conn.address == device: print("Removing output %s" % conn.address) ...
python
def cmd_output_remove(self, args): '''remove an output''' device = args[0] for i in range(len(self.mpstate.mav_outputs)): conn = self.mpstate.mav_outputs[i] if str(i) == device or conn.address == device: print("Removing output %s" % conn.address) ...
[ "def", "cmd_output_remove", "(", "self", ",", "args", ")", ":", "device", "=", "args", "[", "0", "]", "for", "i", "in", "range", "(", "len", "(", "self", ".", "mpstate", ".", "mav_outputs", ")", ")", ":", "conn", "=", "self", ".", "mpstate", ".", ...
remove an output
[ "remove", "an", "output" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_output.py#L90-L103
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_map/mp_slipmap.py
MPSlipMap.set_center
def set_center(self, lat, lon): '''set center of view''' self.object_queue.put(SlipCenter((lat,lon)))
python
def set_center(self, lat, lon): '''set center of view''' self.object_queue.put(SlipCenter((lat,lon)))
[ "def", "set_center", "(", "self", ",", "lat", ",", "lon", ")", ":", "self", ".", "object_queue", ".", "put", "(", "SlipCenter", "(", "(", "lat", ",", "lon", ")", ")", ")" ]
set center of view
[ "set", "center", "of", "view" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_map/mp_slipmap.py#L125-L127
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_map/mp_slipmap.py
MPSlipMap.get_event
def get_event(self): '''return next event or None''' if self.event_queue.qsize() == 0: return None evt = self.event_queue.get() while isinstance(evt, win_layout.WinLayout): win_layout.set_layout(evt, self.set_layout) if self.event_queue.qsize() == 0: ...
python
def get_event(self): '''return next event or None''' if self.event_queue.qsize() == 0: return None evt = self.event_queue.get() while isinstance(evt, win_layout.WinLayout): win_layout.set_layout(evt, self.set_layout) if self.event_queue.qsize() == 0: ...
[ "def", "get_event", "(", "self", ")", ":", "if", "self", ".", "event_queue", ".", "qsize", "(", ")", "==", "0", ":", "return", "None", "evt", "=", "self", ".", "event_queue", ".", "get", "(", ")", "while", "isinstance", "(", "evt", ",", "win_layout",...
return next event or None
[ "return", "next", "event", "or", "None" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_map/mp_slipmap.py#L153-L163
train
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_layout.py
LayoutModule.cmd_layout
def cmd_layout(self, args): '''handle layout command''' from MAVProxy.modules.lib import win_layout if len(args) < 1: print("usage: layout <save|load>") return if args[0] == "load": win_layout.load_layout(self.mpstate.settings.vehicle_name) eli...
python
def cmd_layout(self, args): '''handle layout command''' from MAVProxy.modules.lib import win_layout if len(args) < 1: print("usage: layout <save|load>") return if args[0] == "load": win_layout.load_layout(self.mpstate.settings.vehicle_name) eli...
[ "def", "cmd_layout", "(", "self", ",", "args", ")", ":", "from", "MAVProxy", ".", "modules", ".", "lib", "import", "win_layout", "if", "len", "(", "args", ")", "<", "1", ":", "print", "(", "\"usage: layout <save|load>\"", ")", "return", "if", "args", "["...
handle layout command
[ "handle", "layout", "command" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_layout.py#L13-L22
train
ArduPilot/MAVProxy
MAVProxy/modules/lib/mp_util.py
download_files
def download_files(files): '''download an array of files''' for (url, file) in files: print("Downloading %s as %s" % (url, file)) data = download_url(url) if data is None: continue try: open(file, mode='wb').write(data) except Exception as e: ...
python
def download_files(files): '''download an array of files''' for (url, file) in files: print("Downloading %s as %s" % (url, file)) data = download_url(url) if data is None: continue try: open(file, mode='wb').write(data) except Exception as e: ...
[ "def", "download_files", "(", "files", ")", ":", "for", "(", "url", ",", "file", ")", "in", "files", ":", "print", "(", "\"Downloading %s as %s\"", "%", "(", "url", ",", "file", ")", ")", "data", "=", "download_url", "(", "url", ")", "if", "data", "i...
download an array of files
[ "download", "an", "array", "of", "files" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/mp_util.py#L265-L275
train
ArduPilot/MAVProxy
MAVProxy/modules/lib/mp_util.py
null_term
def null_term(str): '''null terminate a string for py3''' if sys.version_info.major < 3: return str if isinstance(str, bytes): str = str.decode("utf-8") idx = str.find("\0") if idx != -1: str = str[:idx] return str
python
def null_term(str): '''null terminate a string for py3''' if sys.version_info.major < 3: return str if isinstance(str, bytes): str = str.decode("utf-8") idx = str.find("\0") if idx != -1: str = str[:idx] return str
[ "def", "null_term", "(", "str", ")", ":", "if", "sys", ".", "version_info", ".", "major", "<", "3", ":", "return", "str", "if", "isinstance", "(", "str", ",", "bytes", ")", ":", "str", "=", "str", ".", "decode", "(", "\"utf-8\"", ")", "idx", "=", ...
null terminate a string for py3
[ "null", "terminate", "a", "string", "for", "py3" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/mp_util.py#L316-L325
train
ArduPilot/MAVProxy
MAVProxy/modules/lib/mp_util.py
decode_devid
def decode_devid(devid, pname): '''decode one device ID. Used for 'devid' command in mavproxy and MAVExplorer''' devid = int(devid) if devid == 0: return bus_type=devid & 0x07 bus=(devid>>3) & 0x1F address=(devid>>8)&0xFF devtype=(devid>>16) bustypes = { 1: "I2C", ...
python
def decode_devid(devid, pname): '''decode one device ID. Used for 'devid' command in mavproxy and MAVExplorer''' devid = int(devid) if devid == 0: return bus_type=devid & 0x07 bus=(devid>>3) & 0x1F address=(devid>>8)&0xFF devtype=(devid>>16) bustypes = { 1: "I2C", ...
[ "def", "decode_devid", "(", "devid", ",", "pname", ")", ":", "devid", "=", "int", "(", "devid", ")", "if", "devid", "==", "0", ":", "return", "bus_type", "=", "devid", "&", "0x07", "bus", "=", "(", "devid", ">>", "3", ")", "&", "0x1F", "address", ...
decode one device ID. Used for 'devid' command in mavproxy and MAVExplorer
[ "decode", "one", "device", "ID", ".", "Used", "for", "devid", "command", "in", "mavproxy", "and", "MAVExplorer" ]
f50bdeff33064876f7dc8dc4683d278ff47f75d5
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/mp_util.py#L328-L400
train
django-auth-ldap/django-auth-ldap
django_auth_ldap/backend.py
_LDAPUser._authenticate_user_dn
def _authenticate_user_dn(self, password): """ Binds to the LDAP server with the user's DN and password. Raises AuthenticationFailed on failure. """ if self.dn is None: raise self.AuthenticationFailed("failed to map the username to a DN.") try: st...
python
def _authenticate_user_dn(self, password): """ Binds to the LDAP server with the user's DN and password. Raises AuthenticationFailed on failure. """ if self.dn is None: raise self.AuthenticationFailed("failed to map the username to a DN.") try: st...
[ "def", "_authenticate_user_dn", "(", "self", ",", "password", ")", ":", "if", "self", ".", "dn", "is", "None", ":", "raise", "self", ".", "AuthenticationFailed", "(", "\"failed to map the username to a DN.\"", ")", "try", ":", "sticky", "=", "self", ".", "sett...
Binds to the LDAP server with the user's DN and password. Raises AuthenticationFailed on failure.
[ "Binds", "to", "the", "LDAP", "server", "with", "the", "user", "s", "DN", "and", "password", ".", "Raises", "AuthenticationFailed", "on", "failure", "." ]
9ce3c2825527f8faa1793958b041816e63d839af
https://github.com/django-auth-ldap/django-auth-ldap/blob/9ce3c2825527f8faa1793958b041816e63d839af/django_auth_ldap/backend.py#L471-L484
train
django-auth-ldap/django-auth-ldap
django_auth_ldap/backend.py
_LDAPUser._load_user_dn
def _load_user_dn(self): """ Populates self._user_dn with the distinguished name of our user. This will either construct the DN from a template in AUTH_LDAP_USER_DN_TEMPLATE or connect to the server and search for it. If we have to search, we'll cache the DN. """ ...
python
def _load_user_dn(self): """ Populates self._user_dn with the distinguished name of our user. This will either construct the DN from a template in AUTH_LDAP_USER_DN_TEMPLATE or connect to the server and search for it. If we have to search, we'll cache the DN. """ ...
[ "def", "_load_user_dn", "(", "self", ")", ":", "if", "self", ".", "_using_simple_bind_mode", "(", ")", ":", "self", ".", "_user_dn", "=", "self", ".", "_construct_simple_user_dn", "(", ")", "else", ":", "if", "self", ".", "settings", ".", "CACHE_TIMEOUT", ...
Populates self._user_dn with the distinguished name of our user. This will either construct the DN from a template in AUTH_LDAP_USER_DN_TEMPLATE or connect to the server and search for it. If we have to search, we'll cache the DN.
[ "Populates", "self", ".", "_user_dn", "with", "the", "distinguished", "name", "of", "our", "user", "." ]
9ce3c2825527f8faa1793958b041816e63d839af
https://github.com/django-auth-ldap/django-auth-ldap/blob/9ce3c2825527f8faa1793958b041816e63d839af/django_auth_ldap/backend.py#L496-L516
train
django-auth-ldap/django-auth-ldap
django_auth_ldap/backend.py
_LDAPUser._search_for_user_dn
def _search_for_user_dn(self): """ Searches the directory for a user matching AUTH_LDAP_USER_SEARCH. Populates self._user_dn and self._user_attrs. """ search = self.settings.USER_SEARCH if search is None: raise ImproperlyConfigured( "AUTH_LDAP_...
python
def _search_for_user_dn(self): """ Searches the directory for a user matching AUTH_LDAP_USER_SEARCH. Populates self._user_dn and self._user_attrs. """ search = self.settings.USER_SEARCH if search is None: raise ImproperlyConfigured( "AUTH_LDAP_...
[ "def", "_search_for_user_dn", "(", "self", ")", ":", "search", "=", "self", ".", "settings", ".", "USER_SEARCH", "if", "search", "is", "None", ":", "raise", "ImproperlyConfigured", "(", "\"AUTH_LDAP_USER_SEARCH must be an LDAPSearch instance.\"", ")", "results", "=", ...
Searches the directory for a user matching AUTH_LDAP_USER_SEARCH. Populates self._user_dn and self._user_attrs.
[ "Searches", "the", "directory", "for", "a", "user", "matching", "AUTH_LDAP_USER_SEARCH", ".", "Populates", "self", ".", "_user_dn", "and", "self", ".", "_user_attrs", "." ]
9ce3c2825527f8faa1793958b041816e63d839af
https://github.com/django-auth-ldap/django-auth-ldap/blob/9ce3c2825527f8faa1793958b041816e63d839af/django_auth_ldap/backend.py#L526-L543
train
django-auth-ldap/django-auth-ldap
django_auth_ldap/backend.py
_LDAPUser._normalize_group_dns
def _normalize_group_dns(self, group_dns): """ Converts one or more group DNs to an LDAPGroupQuery. group_dns may be a string, a non-empty list or tuple of strings, or an LDAPGroupQuery. The result will be an LDAPGroupQuery. A list or tuple will be joined with the | operator. ...
python
def _normalize_group_dns(self, group_dns): """ Converts one or more group DNs to an LDAPGroupQuery. group_dns may be a string, a non-empty list or tuple of strings, or an LDAPGroupQuery. The result will be an LDAPGroupQuery. A list or tuple will be joined with the | operator. ...
[ "def", "_normalize_group_dns", "(", "self", ",", "group_dns", ")", ":", "if", "isinstance", "(", "group_dns", ",", "LDAPGroupQuery", ")", ":", "query", "=", "group_dns", "elif", "isinstance", "(", "group_dns", ",", "str", ")", ":", "query", "=", "LDAPGroupQu...
Converts one or more group DNs to an LDAPGroupQuery. group_dns may be a string, a non-empty list or tuple of strings, or an LDAPGroupQuery. The result will be an LDAPGroupQuery. A list or tuple will be joined with the | operator.
[ "Converts", "one", "or", "more", "group", "DNs", "to", "an", "LDAPGroupQuery", "." ]
9ce3c2825527f8faa1793958b041816e63d839af
https://github.com/django-auth-ldap/django-auth-ldap/blob/9ce3c2825527f8faa1793958b041816e63d839af/django_auth_ldap/backend.py#L668-L686
train
django-auth-ldap/django-auth-ldap
django_auth_ldap/backend.py
_LDAPUser._normalize_mirror_settings
def _normalize_mirror_settings(self): """ Validates the group mirroring settings and converts them as necessary. """ def malformed_mirror_groups_except(): return ImproperlyConfigured( "{} must be a collection of group names".format( self.s...
python
def _normalize_mirror_settings(self): """ Validates the group mirroring settings and converts them as necessary. """ def malformed_mirror_groups_except(): return ImproperlyConfigured( "{} must be a collection of group names".format( self.s...
[ "def", "_normalize_mirror_settings", "(", "self", ")", ":", "def", "malformed_mirror_groups_except", "(", ")", ":", "return", "ImproperlyConfigured", "(", "\"{} must be a collection of group names\"", ".", "format", "(", "self", ".", "settings", ".", "_name", "(", "\"...
Validates the group mirroring settings and converts them as necessary.
[ "Validates", "the", "group", "mirroring", "settings", "and", "converts", "them", "as", "necessary", "." ]
9ce3c2825527f8faa1793958b041816e63d839af
https://github.com/django-auth-ldap/django-auth-ldap/blob/9ce3c2825527f8faa1793958b041816e63d839af/django_auth_ldap/backend.py#L688-L742
train
django-auth-ldap/django-auth-ldap
django_auth_ldap/backend.py
_LDAPUser._get_groups
def _get_groups(self): """ Returns an _LDAPUserGroups object, which can determine group membership. """ if self._groups is None: self._groups = _LDAPUserGroups(self) return self._groups
python
def _get_groups(self): """ Returns an _LDAPUserGroups object, which can determine group membership. """ if self._groups is None: self._groups = _LDAPUserGroups(self) return self._groups
[ "def", "_get_groups", "(", "self", ")", ":", "if", "self", ".", "_groups", "is", "None", ":", "self", ".", "_groups", "=", "_LDAPUserGroups", "(", "self", ")", "return", "self", ".", "_groups" ]
Returns an _LDAPUserGroups object, which can determine group membership.
[ "Returns", "an", "_LDAPUserGroups", "object", "which", "can", "determine", "group", "membership", "." ]
9ce3c2825527f8faa1793958b041816e63d839af
https://github.com/django-auth-ldap/django-auth-ldap/blob/9ce3c2825527f8faa1793958b041816e63d839af/django_auth_ldap/backend.py#L801-L809
train
django-auth-ldap/django-auth-ldap
django_auth_ldap/backend.py
_LDAPUser._bind
def _bind(self): """ Binds to the LDAP server with AUTH_LDAP_BIND_DN and AUTH_LDAP_BIND_PASSWORD. """ self._bind_as(self.settings.BIND_DN, self.settings.BIND_PASSWORD, sticky=True)
python
def _bind(self): """ Binds to the LDAP server with AUTH_LDAP_BIND_DN and AUTH_LDAP_BIND_PASSWORD. """ self._bind_as(self.settings.BIND_DN, self.settings.BIND_PASSWORD, sticky=True)
[ "def", "_bind", "(", "self", ")", ":", "self", ".", "_bind_as", "(", "self", ".", "settings", ".", "BIND_DN", ",", "self", ".", "settings", ".", "BIND_PASSWORD", ",", "sticky", "=", "True", ")" ]
Binds to the LDAP server with AUTH_LDAP_BIND_DN and AUTH_LDAP_BIND_PASSWORD.
[ "Binds", "to", "the", "LDAP", "server", "with", "AUTH_LDAP_BIND_DN", "and", "AUTH_LDAP_BIND_PASSWORD", "." ]
9ce3c2825527f8faa1793958b041816e63d839af
https://github.com/django-auth-ldap/django-auth-ldap/blob/9ce3c2825527f8faa1793958b041816e63d839af/django_auth_ldap/backend.py#L815-L820
train
django-auth-ldap/django-auth-ldap
django_auth_ldap/backend.py
_LDAPUser._bind_as
def _bind_as(self, bind_dn, bind_password, sticky=False): """ Binds to the LDAP server with the given credentials. This does not trap exceptions. If sticky is True, then we will consider the connection to be bound for the life of this object. If False, then the caller only wishe...
python
def _bind_as(self, bind_dn, bind_password, sticky=False): """ Binds to the LDAP server with the given credentials. This does not trap exceptions. If sticky is True, then we will consider the connection to be bound for the life of this object. If False, then the caller only wishe...
[ "def", "_bind_as", "(", "self", ",", "bind_dn", ",", "bind_password", ",", "sticky", "=", "False", ")", ":", "self", ".", "_get_connection", "(", ")", ".", "simple_bind_s", "(", "bind_dn", ",", "bind_password", ")", "self", ".", "_connection_bound", "=", "...
Binds to the LDAP server with the given credentials. This does not trap exceptions. If sticky is True, then we will consider the connection to be bound for the life of this object. If False, then the caller only wishes to test the credentials, after which the connection will be consider...
[ "Binds", "to", "the", "LDAP", "server", "with", "the", "given", "credentials", ".", "This", "does", "not", "trap", "exceptions", "." ]
9ce3c2825527f8faa1793958b041816e63d839af
https://github.com/django-auth-ldap/django-auth-ldap/blob/9ce3c2825527f8faa1793958b041816e63d839af/django_auth_ldap/backend.py#L822-L833
train
django-auth-ldap/django-auth-ldap
django_auth_ldap/backend.py
_LDAPUserGroups._init_group_settings
def _init_group_settings(self): """ Loads the settings we need to deal with groups. Raises ImproperlyConfigured if anything's not right. """ self._group_type = self.settings.GROUP_TYPE if self._group_type is None: raise ImproperlyConfigured( ...
python
def _init_group_settings(self): """ Loads the settings we need to deal with groups. Raises ImproperlyConfigured if anything's not right. """ self._group_type = self.settings.GROUP_TYPE if self._group_type is None: raise ImproperlyConfigured( ...
[ "def", "_init_group_settings", "(", "self", ")", ":", "self", ".", "_group_type", "=", "self", ".", "settings", ".", "GROUP_TYPE", "if", "self", ".", "_group_type", "is", "None", ":", "raise", "ImproperlyConfigured", "(", "\"AUTH_LDAP_GROUP_TYPE must be an LDAPGroup...
Loads the settings we need to deal with groups. Raises ImproperlyConfigured if anything's not right.
[ "Loads", "the", "settings", "we", "need", "to", "deal", "with", "groups", "." ]
9ce3c2825527f8faa1793958b041816e63d839af
https://github.com/django-auth-ldap/django-auth-ldap/blob/9ce3c2825527f8faa1793958b041816e63d839af/django_auth_ldap/backend.py#L882-L899
train
django-auth-ldap/django-auth-ldap
django_auth_ldap/backend.py
_LDAPUserGroups.get_group_names
def get_group_names(self): """ Returns the set of Django group names that this user belongs to by virtue of LDAP group memberships. """ if self._group_names is None: self._load_cached_attr("_group_names") if self._group_names is None: group_infos ...
python
def get_group_names(self): """ Returns the set of Django group names that this user belongs to by virtue of LDAP group memberships. """ if self._group_names is None: self._load_cached_attr("_group_names") if self._group_names is None: group_infos ...
[ "def", "get_group_names", "(", "self", ")", ":", "if", "self", ".", "_group_names", "is", "None", ":", "self", ".", "_load_cached_attr", "(", "\"_group_names\"", ")", "if", "self", ".", "_group_names", "is", "None", ":", "group_infos", "=", "self", ".", "_...
Returns the set of Django group names that this user belongs to by virtue of LDAP group memberships.
[ "Returns", "the", "set", "of", "Django", "group", "names", "that", "this", "user", "belongs", "to", "by", "virtue", "of", "LDAP", "group", "memberships", "." ]
9ce3c2825527f8faa1793958b041816e63d839af
https://github.com/django-auth-ldap/django-auth-ldap/blob/9ce3c2825527f8faa1793958b041816e63d839af/django_auth_ldap/backend.py#L901-L917
train
django-auth-ldap/django-auth-ldap
django_auth_ldap/backend.py
_LDAPUserGroups.is_member_of
def is_member_of(self, group_dn): """ Returns true if our user is a member of the given group. """ is_member = None # Normalize the DN group_dn = group_dn.lower() # If we have self._group_dns, we'll use it. Otherwise, we'll try to # avoid the cost of loa...
python
def is_member_of(self, group_dn): """ Returns true if our user is a member of the given group. """ is_member = None # Normalize the DN group_dn = group_dn.lower() # If we have self._group_dns, we'll use it. Otherwise, we'll try to # avoid the cost of loa...
[ "def", "is_member_of", "(", "self", ",", "group_dn", ")", ":", "is_member", "=", "None", "# Normalize the DN", "group_dn", "=", "group_dn", ".", "lower", "(", ")", "# If we have self._group_dns, we'll use it. Otherwise, we'll try to", "# avoid the cost of loading it.", "if"...
Returns true if our user is a member of the given group.
[ "Returns", "true", "if", "our", "user", "is", "a", "member", "of", "the", "given", "group", "." ]
9ce3c2825527f8faa1793958b041816e63d839af
https://github.com/django-auth-ldap/django-auth-ldap/blob/9ce3c2825527f8faa1793958b041816e63d839af/django_auth_ldap/backend.py#L919-L942
train
django-auth-ldap/django-auth-ldap
django_auth_ldap/config.py
_LDAPConfig.get_ldap
def get_ldap(cls, global_options=None): """ Returns the configured ldap module. """ # Apply global LDAP options once if not cls._ldap_configured and global_options is not None: for opt, value in global_options.items(): ldap.set_option(opt, value) ...
python
def get_ldap(cls, global_options=None): """ Returns the configured ldap module. """ # Apply global LDAP options once if not cls._ldap_configured and global_options is not None: for opt, value in global_options.items(): ldap.set_option(opt, value) ...
[ "def", "get_ldap", "(", "cls", ",", "global_options", "=", "None", ")", ":", "# Apply global LDAP options once", "if", "not", "cls", ".", "_ldap_configured", "and", "global_options", "is", "not", "None", ":", "for", "opt", ",", "value", "in", "global_options", ...
Returns the configured ldap module.
[ "Returns", "the", "configured", "ldap", "module", "." ]
9ce3c2825527f8faa1793958b041816e63d839af
https://github.com/django-auth-ldap/django-auth-ldap/blob/9ce3c2825527f8faa1793958b041816e63d839af/django_auth_ldap/config.py#L54-L65
train
django-auth-ldap/django-auth-ldap
django_auth_ldap/config.py
LDAPSearch.search_with_additional_terms
def search_with_additional_terms(self, term_dict, escape=True): """ Returns a new search object with additional search terms and-ed to the filter string. term_dict maps attribute names to assertion values. If you don't want the values escaped, pass escape=False. """ term_...
python
def search_with_additional_terms(self, term_dict, escape=True): """ Returns a new search object with additional search terms and-ed to the filter string. term_dict maps attribute names to assertion values. If you don't want the values escaped, pass escape=False. """ term_...
[ "def", "search_with_additional_terms", "(", "self", ",", "term_dict", ",", "escape", "=", "True", ")", ":", "term_strings", "=", "[", "self", ".", "filterstr", "]", "for", "name", ",", "value", "in", "term_dict", ".", "items", "(", ")", ":", "if", "escap...
Returns a new search object with additional search terms and-ed to the filter string. term_dict maps attribute names to assertion values. If you don't want the values escaped, pass escape=False.
[ "Returns", "a", "new", "search", "object", "with", "additional", "search", "terms", "and", "-", "ed", "to", "the", "filter", "string", ".", "term_dict", "maps", "attribute", "names", "to", "assertion", "values", ".", "If", "you", "don", "t", "want", "the",...
9ce3c2825527f8faa1793958b041816e63d839af
https://github.com/django-auth-ldap/django-auth-ldap/blob/9ce3c2825527f8faa1793958b041816e63d839af/django_auth_ldap/config.py#L105-L122
train
django-auth-ldap/django-auth-ldap
django_auth_ldap/config.py
PosixGroupType.user_groups
def user_groups(self, ldap_user, group_search): """ Searches for any group that is either the user's primary or contains the user as a member. """ groups = [] try: user_uid = ldap_user.attrs["uid"][0] if "gidNumber" in ldap_user.attrs: ...
python
def user_groups(self, ldap_user, group_search): """ Searches for any group that is either the user's primary or contains the user as a member. """ groups = [] try: user_uid = ldap_user.attrs["uid"][0] if "gidNumber" in ldap_user.attrs: ...
[ "def", "user_groups", "(", "self", ",", "ldap_user", ",", "group_search", ")", ":", "groups", "=", "[", "]", "try", ":", "user_uid", "=", "ldap_user", ".", "attrs", "[", "\"uid\"", "]", "[", "0", "]", "if", "\"gidNumber\"", "in", "ldap_user", ".", "att...
Searches for any group that is either the user's primary or contains the user as a member.
[ "Searches", "for", "any", "group", "that", "is", "either", "the", "user", "s", "primary", "or", "contains", "the", "user", "as", "a", "member", "." ]
9ce3c2825527f8faa1793958b041816e63d839af
https://github.com/django-auth-ldap/django-auth-ldap/blob/9ce3c2825527f8faa1793958b041816e63d839af/django_auth_ldap/config.py#L402-L428
train
django-auth-ldap/django-auth-ldap
django_auth_ldap/config.py
PosixGroupType.is_member
def is_member(self, ldap_user, group_dn): """ Returns True if the group is the user's primary group or if the user is listed in the group's memberUid attribute. """ try: user_uid = ldap_user.attrs["uid"][0] try: is_member = ldap_user.conne...
python
def is_member(self, ldap_user, group_dn): """ Returns True if the group is the user's primary group or if the user is listed in the group's memberUid attribute. """ try: user_uid = ldap_user.attrs["uid"][0] try: is_member = ldap_user.conne...
[ "def", "is_member", "(", "self", ",", "ldap_user", ",", "group_dn", ")", ":", "try", ":", "user_uid", "=", "ldap_user", ".", "attrs", "[", "\"uid\"", "]", "[", "0", "]", "try", ":", "is_member", "=", "ldap_user", ".", "connection", ".", "compare_s", "(...
Returns True if the group is the user's primary group or if the user is listed in the group's memberUid attribute.
[ "Returns", "True", "if", "the", "group", "is", "the", "user", "s", "primary", "group", "or", "if", "the", "user", "is", "listed", "in", "the", "group", "s", "memberUid", "attribute", "." ]
9ce3c2825527f8faa1793958b041816e63d839af
https://github.com/django-auth-ldap/django-auth-ldap/blob/9ce3c2825527f8faa1793958b041816e63d839af/django_auth_ldap/config.py#L430-L456
train
django-auth-ldap/django-auth-ldap
django_auth_ldap/config.py
NestedMemberDNGroupType.user_groups
def user_groups(self, ldap_user, group_search): """ This searches for all of a user's groups from the bottom up. In other words, it returns the groups that the user belongs to, the groups that those groups belong to, etc. Circular references will be detected and pruned. "...
python
def user_groups(self, ldap_user, group_search): """ This searches for all of a user's groups from the bottom up. In other words, it returns the groups that the user belongs to, the groups that those groups belong to, etc. Circular references will be detected and pruned. "...
[ "def", "user_groups", "(", "self", ",", "ldap_user", ",", "group_search", ")", ":", "group_info_map", "=", "{", "}", "# Maps group_dn to group_info of groups we've found", "member_dn_set", "=", "{", "ldap_user", ".", "dn", "}", "# Member DNs to search with next", "handl...
This searches for all of a user's groups from the bottom up. In other words, it returns the groups that the user belongs to, the groups that those groups belong to, etc. Circular references will be detected and pruned.
[ "This", "searches", "for", "all", "of", "a", "user", "s", "groups", "from", "the", "bottom", "up", ".", "In", "other", "words", "it", "returns", "the", "groups", "that", "the", "user", "belongs", "to", "the", "groups", "that", "those", "groups", "belong"...
9ce3c2825527f8faa1793958b041816e63d839af
https://github.com/django-auth-ldap/django-auth-ldap/blob/9ce3c2825527f8faa1793958b041816e63d839af/django_auth_ldap/config.py#L509-L532
train
django-auth-ldap/django-auth-ldap
django_auth_ldap/config.py
LDAPGroupQuery.aggregator
def aggregator(self): """ Returns a function for aggregating a sequence of sub-results. """ if self.connector == self.AND: aggregator = all elif self.connector == self.OR: aggregator = any else: raise ValueError(self.connector) ...
python
def aggregator(self): """ Returns a function for aggregating a sequence of sub-results. """ if self.connector == self.AND: aggregator = all elif self.connector == self.OR: aggregator = any else: raise ValueError(self.connector) ...
[ "def", "aggregator", "(", "self", ")", ":", "if", "self", ".", "connector", "==", "self", ".", "AND", ":", "aggregator", "=", "all", "elif", "self", ".", "connector", "==", "self", ".", "OR", ":", "aggregator", "=", "any", "else", ":", "raise", "Valu...
Returns a function for aggregating a sequence of sub-results.
[ "Returns", "a", "function", "for", "aggregating", "a", "sequence", "of", "sub", "-", "results", "." ]
9ce3c2825527f8faa1793958b041816e63d839af
https://github.com/django-auth-ldap/django-auth-ldap/blob/9ce3c2825527f8faa1793958b041816e63d839af/django_auth_ldap/config.py#L682-L693
train
django-auth-ldap/django-auth-ldap
django_auth_ldap/config.py
LDAPGroupQuery._resolve_children
def _resolve_children(self, ldap_user, groups): """ Generates the query result for each child. """ for child in self.children: if isinstance(child, LDAPGroupQuery): yield child.resolve(ldap_user, groups) else: yield groups.is_member...
python
def _resolve_children(self, ldap_user, groups): """ Generates the query result for each child. """ for child in self.children: if isinstance(child, LDAPGroupQuery): yield child.resolve(ldap_user, groups) else: yield groups.is_member...
[ "def", "_resolve_children", "(", "self", ",", "ldap_user", ",", "groups", ")", ":", "for", "child", "in", "self", ".", "children", ":", "if", "isinstance", "(", "child", ",", "LDAPGroupQuery", ")", ":", "yield", "child", ".", "resolve", "(", "ldap_user", ...
Generates the query result for each child.
[ "Generates", "the", "query", "result", "for", "each", "child", "." ]
9ce3c2825527f8faa1793958b041816e63d839af
https://github.com/django-auth-ldap/django-auth-ldap/blob/9ce3c2825527f8faa1793958b041816e63d839af/django_auth_ldap/config.py#L695-L703
train
regebro/hovercraft
hovercraft/position.py
gather_positions
def gather_positions(tree): """Makes a list of positions and position commands from the tree""" pos = {'data-x': 'r0', 'data-y': 'r0', 'data-z': 'r0', 'data-rotate-x': 'r0', 'data-rotate-y': 'r0', 'data-rotate-z': 'r0', 'data-scale': 'r0', ...
python
def gather_positions(tree): """Makes a list of positions and position commands from the tree""" pos = {'data-x': 'r0', 'data-y': 'r0', 'data-z': 'r0', 'data-rotate-x': 'r0', 'data-rotate-y': 'r0', 'data-rotate-z': 'r0', 'data-scale': 'r0', ...
[ "def", "gather_positions", "(", "tree", ")", ":", "pos", "=", "{", "'data-x'", ":", "'r0'", ",", "'data-y'", ":", "'r0'", ",", "'data-z'", ":", "'r0'", ",", "'data-rotate-x'", ":", "'r0'", ",", "'data-rotate-y'", ":", "'r0'", ",", "'data-rotate-z'", ":", ...
Makes a list of positions and position commands from the tree
[ "Makes", "a", "list", "of", "positions", "and", "position", "commands", "from", "the", "tree" ]
d9f63bfdfe1519c4d7a81697ee066e49dc26a30b
https://github.com/regebro/hovercraft/blob/d9f63bfdfe1519c4d7a81697ee066e49dc26a30b/hovercraft/position.py#L10-L67
train
regebro/hovercraft
hovercraft/position.py
calculate_positions
def calculate_positions(positions): """Calculates position information""" current_position = {'data-x': 0, 'data-y': 0, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0,...
python
def calculate_positions(positions): """Calculates position information""" current_position = {'data-x': 0, 'data-y': 0, 'data-z': 0, 'data-rotate-x': 0, 'data-rotate-y': 0, 'data-rotate-z': 0,...
[ "def", "calculate_positions", "(", "positions", ")", ":", "current_position", "=", "{", "'data-x'", ":", "0", ",", "'data-y'", ":", "0", ",", "'data-z'", ":", "0", ",", "'data-rotate-x'", ":", "0", ",", "'data-rotate-y'", ":", "0", ",", "'data-rotate-z'", ...
Calculates position information
[ "Calculates", "position", "information" ]
d9f63bfdfe1519c4d7a81697ee066e49dc26a30b
https://github.com/regebro/hovercraft/blob/d9f63bfdfe1519c4d7a81697ee066e49dc26a30b/hovercraft/position.py#L131-L216
train
regebro/hovercraft
hovercraft/position.py
update_positions
def update_positions(tree, positions): """Updates the tree with new positions""" for step, pos in zip(tree.findall('step'), positions): for key in sorted(pos): value = pos.get(key) if key.endswith("-rel"): abs_key = key[:key.index("-rel")] if valu...
python
def update_positions(tree, positions): """Updates the tree with new positions""" for step, pos in zip(tree.findall('step'), positions): for key in sorted(pos): value = pos.get(key) if key.endswith("-rel"): abs_key = key[:key.index("-rel")] if valu...
[ "def", "update_positions", "(", "tree", ",", "positions", ")", ":", "for", "step", ",", "pos", "in", "zip", "(", "tree", ".", "findall", "(", "'step'", ")", ",", "positions", ")", ":", "for", "key", "in", "sorted", "(", "pos", ")", ":", "value", "=...
Updates the tree with new positions
[ "Updates", "the", "tree", "with", "new", "positions" ]
d9f63bfdfe1519c4d7a81697ee066e49dc26a30b
https://github.com/regebro/hovercraft/blob/d9f63bfdfe1519c4d7a81697ee066e49dc26a30b/hovercraft/position.py#L219-L236
train
regebro/hovercraft
hovercraft/position.py
position_slides
def position_slides(tree): """Position the slides in the tree""" positions = gather_positions(tree) positions = calculate_positions(positions) update_positions(tree, positions)
python
def position_slides(tree): """Position the slides in the tree""" positions = gather_positions(tree) positions = calculate_positions(positions) update_positions(tree, positions)
[ "def", "position_slides", "(", "tree", ")", ":", "positions", "=", "gather_positions", "(", "tree", ")", "positions", "=", "calculate_positions", "(", "positions", ")", "update_positions", "(", "tree", ",", "positions", ")" ]
Position the slides in the tree
[ "Position", "the", "slides", "in", "the", "tree" ]
d9f63bfdfe1519c4d7a81697ee066e49dc26a30b
https://github.com/regebro/hovercraft/blob/d9f63bfdfe1519c4d7a81697ee066e49dc26a30b/hovercraft/position.py#L239-L244
train
regebro/hovercraft
hovercraft/parse.py
copy_node
def copy_node(node): """Makes a copy of a node with the same attributes and text, but no children.""" element = node.makeelement(node.tag) element.text = node.text element.tail = node.tail for key, value in node.items(): element.set(key, value) return element
python
def copy_node(node): """Makes a copy of a node with the same attributes and text, but no children.""" element = node.makeelement(node.tag) element.text = node.text element.tail = node.tail for key, value in node.items(): element.set(key, value) return element
[ "def", "copy_node", "(", "node", ")", ":", "element", "=", "node", ".", "makeelement", "(", "node", ".", "tag", ")", "element", ".", "text", "=", "node", ".", "text", "element", ".", "tail", "=", "node", ".", "tail", "for", "key", ",", "value", "in...
Makes a copy of a node with the same attributes and text, but no children.
[ "Makes", "a", "copy", "of", "a", "node", "with", "the", "same", "attributes", "and", "text", "but", "no", "children", "." ]
d9f63bfdfe1519c4d7a81697ee066e49dc26a30b
https://github.com/regebro/hovercraft/blob/d9f63bfdfe1519c4d7a81697ee066e49dc26a30b/hovercraft/parse.py#L84-L92
train
regebro/hovercraft
hovercraft/template.py
Template.copy_resource
def copy_resource(self, resource, targetdir): """Copies a resource file and returns the source path for monitoring""" final_path = resource.final_path() if final_path[0] == '/' or (':' in final_path) or ('?' in final_path): # Absolute path or URI: Do nothing return ...
python
def copy_resource(self, resource, targetdir): """Copies a resource file and returns the source path for monitoring""" final_path = resource.final_path() if final_path[0] == '/' or (':' in final_path) or ('?' in final_path): # Absolute path or URI: Do nothing return ...
[ "def", "copy_resource", "(", "self", ",", "resource", ",", "targetdir", ")", ":", "final_path", "=", "resource", ".", "final_path", "(", ")", "if", "final_path", "[", "0", "]", "==", "'/'", "or", "(", "':'", "in", "final_path", ")", "or", "(", "'?'", ...
Copies a resource file and returns the source path for monitoring
[ "Copies", "a", "resource", "file", "and", "returns", "the", "source", "path", "for", "monitoring" ]
d9f63bfdfe1519c4d7a81697ee066e49dc26a30b
https://github.com/regebro/hovercraft/blob/d9f63bfdfe1519c4d7a81697ee066e49dc26a30b/hovercraft/template.py#L143-L162
train
regebro/hovercraft
hovercraft/generate.py
generate
def generate(args): """Generates the presentation and returns a list of files used""" source_files = {args.presentation} # Parse the template info template_info = Template(args.template) if args.css: presentation_dir = os.path.split(args.presentation)[0] target_path = os.path.relpa...
python
def generate(args): """Generates the presentation and returns a list of files used""" source_files = {args.presentation} # Parse the template info template_info = Template(args.template) if args.css: presentation_dir = os.path.split(args.presentation)[0] target_path = os.path.relpa...
[ "def", "generate", "(", "args", ")", ":", "source_files", "=", "{", "args", ".", "presentation", "}", "# Parse the template info", "template_info", "=", "Template", "(", "args", ".", "template", ")", "if", "args", ".", "css", ":", "presentation_dir", "=", "o...
Generates the presentation and returns a list of files used
[ "Generates", "the", "presentation", "and", "returns", "a", "list", "of", "files", "used" ]
d9f63bfdfe1519c4d7a81697ee066e49dc26a30b
https://github.com/regebro/hovercraft/blob/d9f63bfdfe1519c4d7a81697ee066e49dc26a30b/hovercraft/generate.py#L144-L207
train
sourceperl/pyModbusTCP
pyModbusTCP/client.py
ModbusClient.port
def port(self, port=None): """Get or set TCP port :param port: TCP port number or None for get value :type port: int or None :returns: TCP port or None if set fail :rtype: int or None """ if (port is None) or (port == self.__port): return self.__port ...
python
def port(self, port=None): """Get or set TCP port :param port: TCP port number or None for get value :type port: int or None :returns: TCP port or None if set fail :rtype: int or None """ if (port is None) or (port == self.__port): return self.__port ...
[ "def", "port", "(", "self", ",", "port", "=", "None", ")", ":", "if", "(", "port", "is", "None", ")", "or", "(", "port", "==", "self", ".", "__port", ")", ":", "return", "self", ".", "__port", "# when port change ensure old socket is close", "self", ".",...
Get or set TCP port :param port: TCP port number or None for get value :type port: int or None :returns: TCP port or None if set fail :rtype: int or None
[ "Get", "or", "set", "TCP", "port" ]
993f6e2f5ab52eba164be049e42cea560c3751a5
https://github.com/sourceperl/pyModbusTCP/blob/993f6e2f5ab52eba164be049e42cea560c3751a5/pyModbusTCP/client.py#L145-L162
train
sourceperl/pyModbusTCP
pyModbusTCP/client.py
ModbusClient.unit_id
def unit_id(self, unit_id=None): """Get or set unit ID field :param unit_id: unit ID (0 to 255) or None for get value :type unit_id: int or None :returns: unit ID or None if set fail :rtype: int or None """ if unit_id is None: return self.__unit_id ...
python
def unit_id(self, unit_id=None): """Get or set unit ID field :param unit_id: unit ID (0 to 255) or None for get value :type unit_id: int or None :returns: unit ID or None if set fail :rtype: int or None """ if unit_id is None: return self.__unit_id ...
[ "def", "unit_id", "(", "self", ",", "unit_id", "=", "None", ")", ":", "if", "unit_id", "is", "None", ":", "return", "self", ".", "__unit_id", "if", "0", "<=", "int", "(", "unit_id", ")", "<", "256", ":", "self", ".", "__unit_id", "=", "int", "(", ...
Get or set unit ID field :param unit_id: unit ID (0 to 255) or None for get value :type unit_id: int or None :returns: unit ID or None if set fail :rtype: int or None
[ "Get", "or", "set", "unit", "ID", "field" ]
993f6e2f5ab52eba164be049e42cea560c3751a5
https://github.com/sourceperl/pyModbusTCP/blob/993f6e2f5ab52eba164be049e42cea560c3751a5/pyModbusTCP/client.py#L164-L178
train
sourceperl/pyModbusTCP
pyModbusTCP/client.py
ModbusClient.timeout
def timeout(self, timeout=None): """Get or set timeout field :param timeout: socket timeout in seconds or None for get value :type timeout: float or None :returns: timeout or None if set fail :rtype: float or None """ if timeout is None: return self._...
python
def timeout(self, timeout=None): """Get or set timeout field :param timeout: socket timeout in seconds or None for get value :type timeout: float or None :returns: timeout or None if set fail :rtype: float or None """ if timeout is None: return self._...
[ "def", "timeout", "(", "self", ",", "timeout", "=", "None", ")", ":", "if", "timeout", "is", "None", ":", "return", "self", ".", "__timeout", "if", "0", "<", "float", "(", "timeout", ")", "<", "3600", ":", "self", ".", "__timeout", "=", "float", "(...
Get or set timeout field :param timeout: socket timeout in seconds or None for get value :type timeout: float or None :returns: timeout or None if set fail :rtype: float or None
[ "Get", "or", "set", "timeout", "field" ]
993f6e2f5ab52eba164be049e42cea560c3751a5
https://github.com/sourceperl/pyModbusTCP/blob/993f6e2f5ab52eba164be049e42cea560c3751a5/pyModbusTCP/client.py#L180-L194
train
sourceperl/pyModbusTCP
pyModbusTCP/client.py
ModbusClient.debug
def debug(self, state=None): """Get or set debug mode :param state: debug state or None for get value :type state: bool or None :returns: debug state or None if set fail :rtype: bool or None """ if state is None: return self.__debug self.__deb...
python
def debug(self, state=None): """Get or set debug mode :param state: debug state or None for get value :type state: bool or None :returns: debug state or None if set fail :rtype: bool or None """ if state is None: return self.__debug self.__deb...
[ "def", "debug", "(", "self", ",", "state", "=", "None", ")", ":", "if", "state", "is", "None", ":", "return", "self", ".", "__debug", "self", ".", "__debug", "=", "bool", "(", "state", ")", "return", "self", ".", "__debug" ]
Get or set debug mode :param state: debug state or None for get value :type state: bool or None :returns: debug state or None if set fail :rtype: bool or None
[ "Get", "or", "set", "debug", "mode" ]
993f6e2f5ab52eba164be049e42cea560c3751a5
https://github.com/sourceperl/pyModbusTCP/blob/993f6e2f5ab52eba164be049e42cea560c3751a5/pyModbusTCP/client.py#L196-L207
train
sourceperl/pyModbusTCP
pyModbusTCP/client.py
ModbusClient.auto_open
def auto_open(self, state=None): """Get or set automatic TCP connect mode :param state: auto_open state or None for get value :type state: bool or None :returns: auto_open state or None if set fail :rtype: bool or None """ if state is None: return sel...
python
def auto_open(self, state=None): """Get or set automatic TCP connect mode :param state: auto_open state or None for get value :type state: bool or None :returns: auto_open state or None if set fail :rtype: bool or None """ if state is None: return sel...
[ "def", "auto_open", "(", "self", ",", "state", "=", "None", ")", ":", "if", "state", "is", "None", ":", "return", "self", ".", "__auto_open", "self", ".", "__auto_open", "=", "bool", "(", "state", ")", "return", "self", ".", "__auto_open" ]
Get or set automatic TCP connect mode :param state: auto_open state or None for get value :type state: bool or None :returns: auto_open state or None if set fail :rtype: bool or None
[ "Get", "or", "set", "automatic", "TCP", "connect", "mode" ]
993f6e2f5ab52eba164be049e42cea560c3751a5
https://github.com/sourceperl/pyModbusTCP/blob/993f6e2f5ab52eba164be049e42cea560c3751a5/pyModbusTCP/client.py#L209-L220
train
sourceperl/pyModbusTCP
pyModbusTCP/client.py
ModbusClient._can_read
def _can_read(self): """Wait data available for socket read :returns: True if data available or None if timeout or socket error :rtype: bool or None """ if self.__sock is None: return None if select.select([self.__sock], [], [], self.__timeout)[0]: ...
python
def _can_read(self): """Wait data available for socket read :returns: True if data available or None if timeout or socket error :rtype: bool or None """ if self.__sock is None: return None if select.select([self.__sock], [], [], self.__timeout)[0]: ...
[ "def", "_can_read", "(", "self", ")", ":", "if", "self", ".", "__sock", "is", "None", ":", "return", "None", "if", "select", ".", "select", "(", "[", "self", ".", "__sock", "]", ",", "[", "]", ",", "[", "]", ",", "self", ".", "__timeout", ")", ...
Wait data available for socket read :returns: True if data available or None if timeout or socket error :rtype: bool or None
[ "Wait", "data", "available", "for", "socket", "read" ]
993f6e2f5ab52eba164be049e42cea560c3751a5
https://github.com/sourceperl/pyModbusTCP/blob/993f6e2f5ab52eba164be049e42cea560c3751a5/pyModbusTCP/client.py#L740-L754
train
sourceperl/pyModbusTCP
pyModbusTCP/client.py
ModbusClient._send
def _send(self, data): """Send data over current socket :param data: registers value to write :type data: str (Python2) or class bytes (Python3) :returns: True if send ok or None if error :rtype: bool or None """ # check link if self.__sock is None: ...
python
def _send(self, data): """Send data over current socket :param data: registers value to write :type data: str (Python2) or class bytes (Python3) :returns: True if send ok or None if error :rtype: bool or None """ # check link if self.__sock is None: ...
[ "def", "_send", "(", "self", ",", "data", ")", ":", "# check link", "if", "self", ".", "__sock", "is", "None", ":", "self", ".", "__debug_msg", "(", "'call _send on close socket'", ")", "return", "None", "# send", "data_l", "=", "len", "(", "data", ")", ...
Send data over current socket :param data: registers value to write :type data: str (Python2) or class bytes (Python3) :returns: True if send ok or None if error :rtype: bool or None
[ "Send", "data", "over", "current", "socket" ]
993f6e2f5ab52eba164be049e42cea560c3751a5
https://github.com/sourceperl/pyModbusTCP/blob/993f6e2f5ab52eba164be049e42cea560c3751a5/pyModbusTCP/client.py#L756-L781
train
sourceperl/pyModbusTCP
pyModbusTCP/client.py
ModbusClient._recv
def _recv(self, max_size): """Receive data over current socket :param max_size: number of bytes to receive :type max_size: int :returns: receive data or None if error :rtype: str (Python2) or class bytes (Python3) or None """ # wait for read if not self._...
python
def _recv(self, max_size): """Receive data over current socket :param max_size: number of bytes to receive :type max_size: int :returns: receive data or None if error :rtype: str (Python2) or class bytes (Python3) or None """ # wait for read if not self._...
[ "def", "_recv", "(", "self", ",", "max_size", ")", ":", "# wait for read", "if", "not", "self", ".", "_can_read", "(", ")", ":", "self", ".", "close", "(", ")", "return", "None", "# recv", "try", ":", "r_buffer", "=", "self", ".", "__sock", ".", "rec...
Receive data over current socket :param max_size: number of bytes to receive :type max_size: int :returns: receive data or None if error :rtype: str (Python2) or class bytes (Python3) or None
[ "Receive", "data", "over", "current", "socket" ]
993f6e2f5ab52eba164be049e42cea560c3751a5
https://github.com/sourceperl/pyModbusTCP/blob/993f6e2f5ab52eba164be049e42cea560c3751a5/pyModbusTCP/client.py#L783-L806
train
sourceperl/pyModbusTCP
pyModbusTCP/client.py
ModbusClient._send_mbus
def _send_mbus(self, frame): """Send modbus frame :param frame: modbus frame to send (with MBAP for TCP/CRC for RTU) :type frame: str (Python2) or class bytes (Python3) :returns: number of bytes send or None if error :rtype: int or None """ # for auto_open mode, ...
python
def _send_mbus(self, frame): """Send modbus frame :param frame: modbus frame to send (with MBAP for TCP/CRC for RTU) :type frame: str (Python2) or class bytes (Python3) :returns: number of bytes send or None if error :rtype: int or None """ # for auto_open mode, ...
[ "def", "_send_mbus", "(", "self", ",", "frame", ")", ":", "# for auto_open mode, check TCP and open if need", "if", "self", ".", "__auto_open", "and", "not", "self", ".", "is_open", "(", ")", ":", "self", ".", "open", "(", ")", "# send request", "bytes_send", ...
Send modbus frame :param frame: modbus frame to send (with MBAP for TCP/CRC for RTU) :type frame: str (Python2) or class bytes (Python3) :returns: number of bytes send or None if error :rtype: int or None
[ "Send", "modbus", "frame" ]
993f6e2f5ab52eba164be049e42cea560c3751a5
https://github.com/sourceperl/pyModbusTCP/blob/993f6e2f5ab52eba164be049e42cea560c3751a5/pyModbusTCP/client.py#L824-L842
train
sourceperl/pyModbusTCP
pyModbusTCP/client.py
ModbusClient._recv_mbus
def _recv_mbus(self): """Receive a modbus frame :returns: modbus frame body or None if error :rtype: str (Python2) or class bytes (Python3) or None """ # receive # modbus TCP receive if self.__mode == const.MODBUS_TCP: # 7 bytes header (mbap) ...
python
def _recv_mbus(self): """Receive a modbus frame :returns: modbus frame body or None if error :rtype: str (Python2) or class bytes (Python3) or None """ # receive # modbus TCP receive if self.__mode == const.MODBUS_TCP: # 7 bytes header (mbap) ...
[ "def", "_recv_mbus", "(", "self", ")", ":", "# receive", "# modbus TCP receive", "if", "self", ".", "__mode", "==", "const", ".", "MODBUS_TCP", ":", "# 7 bytes header (mbap)", "rx_buffer", "=", "self", ".", "_recv_all", "(", "7", ")", "# check recv", "if", "no...
Receive a modbus frame :returns: modbus frame body or None if error :rtype: str (Python2) or class bytes (Python3) or None
[ "Receive", "a", "modbus", "frame" ]
993f6e2f5ab52eba164be049e42cea560c3751a5
https://github.com/sourceperl/pyModbusTCP/blob/993f6e2f5ab52eba164be049e42cea560c3751a5/pyModbusTCP/client.py#L844-L939
train
ihabunek/toot
toot/wcstring.py
_wc_hard_wrap
def _wc_hard_wrap(line, length): """ Wrap text to length characters, breaking when target length is reached, taking into account character width. Used to wrap lines which cannot be wrapped on whitespace. """ chars = [] chars_len = 0 for char in line: char_len = wcwidth(char) ...
python
def _wc_hard_wrap(line, length): """ Wrap text to length characters, breaking when target length is reached, taking into account character width. Used to wrap lines which cannot be wrapped on whitespace. """ chars = [] chars_len = 0 for char in line: char_len = wcwidth(char) ...
[ "def", "_wc_hard_wrap", "(", "line", ",", "length", ")", ":", "chars", "=", "[", "]", "chars_len", "=", "0", "for", "char", "in", "line", ":", "char_len", "=", "wcwidth", "(", "char", ")", "if", "chars_len", "+", "char_len", ">", "length", ":", "yiel...
Wrap text to length characters, breaking when target length is reached, taking into account character width. Used to wrap lines which cannot be wrapped on whitespace.
[ "Wrap", "text", "to", "length", "characters", "breaking", "when", "target", "length", "is", "reached", "taking", "into", "account", "character", "width", "." ]
d13fa8685b300f96621fa325774913ec0f413a7f
https://github.com/ihabunek/toot/blob/d13fa8685b300f96621fa325774913ec0f413a7f/toot/wcstring.py#L10-L30
train
ihabunek/toot
toot/wcstring.py
wc_wrap
def wc_wrap(text, length): """ Wrap text to given length, breaking on whitespace and taking into account character width. Meant for use on a single line or paragraph. Will destroy spacing between words and paragraphs and any indentation. """ line_words = [] line_len = 0 words = re....
python
def wc_wrap(text, length): """ Wrap text to given length, breaking on whitespace and taking into account character width. Meant for use on a single line or paragraph. Will destroy spacing between words and paragraphs and any indentation. """ line_words = [] line_len = 0 words = re....
[ "def", "wc_wrap", "(", "text", ",", "length", ")", ":", "line_words", "=", "[", "]", "line_len", "=", "0", "words", "=", "re", ".", "split", "(", "r\"\\s+\"", ",", "text", ".", "strip", "(", ")", ")", "for", "word", "in", "words", ":", "word_len", ...
Wrap text to given length, breaking on whitespace and taking into account character width. Meant for use on a single line or paragraph. Will destroy spacing between words and paragraphs and any indentation.
[ "Wrap", "text", "to", "given", "length", "breaking", "on", "whitespace", "and", "taking", "into", "account", "character", "width", "." ]
d13fa8685b300f96621fa325774913ec0f413a7f
https://github.com/ihabunek/toot/blob/d13fa8685b300f96621fa325774913ec0f413a7f/toot/wcstring.py#L33-L66
train
ihabunek/toot
toot/wcstring.py
trunc
def trunc(text, length): """ Truncates text to given length, taking into account wide characters. If truncated, the last char is replaced by an elipsis. """ if length < 1: raise ValueError("length should be 1 or larger") # Remove whitespace first so no unneccesary truncation is done. ...
python
def trunc(text, length): """ Truncates text to given length, taking into account wide characters. If truncated, the last char is replaced by an elipsis. """ if length < 1: raise ValueError("length should be 1 or larger") # Remove whitespace first so no unneccesary truncation is done. ...
[ "def", "trunc", "(", "text", ",", "length", ")", ":", "if", "length", "<", "1", ":", "raise", "ValueError", "(", "\"length should be 1 or larger\"", ")", "# Remove whitespace first so no unneccesary truncation is done.", "text", "=", "text", ".", "strip", "(", ")", ...
Truncates text to given length, taking into account wide characters. If truncated, the last char is replaced by an elipsis.
[ "Truncates", "text", "to", "given", "length", "taking", "into", "account", "wide", "characters", "." ]
d13fa8685b300f96621fa325774913ec0f413a7f
https://github.com/ihabunek/toot/blob/d13fa8685b300f96621fa325774913ec0f413a7f/toot/wcstring.py#L69-L98
train