Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
LegacyMetadata.check
(self, strict=False)
Check if the metadata is compliant. If strict is True then raise if no Name or Version are provided
Check if the metadata is compliant. If strict is True then raise if no Name or Version are provided
def check(self, strict=False): """Check if the metadata is compliant. If strict is True then raise if no Name or Version are provided""" self.set_metadata_version() # XXX should check the versions (if the file was loaded) missing, warnings = [], [] for attr in ('Name', ...
[ "def", "check", "(", "self", ",", "strict", "=", "False", ")", ":", "self", ".", "set_metadata_version", "(", ")", "# XXX should check the versions (if the file was loaded)", "missing", ",", "warnings", "=", "[", "]", ",", "[", "]", "for", "attr", "in", "(", ...
[ 499, 4 ]
[ 541, 32 ]
python
en
['en', 'en', 'en']
True
LegacyMetadata.todict
(self, skip_missing=False)
Return fields as a dict. Field names will be converted to use the underscore-lowercase style instead of hyphen-mixed case (i.e. home_page instead of Home-page). This is as per https://www.python.org/dev/peps/pep-0566/#id17.
Return fields as a dict.
def todict(self, skip_missing=False): """Return fields as a dict. Field names will be converted to use the underscore-lowercase style instead of hyphen-mixed case (i.e. home_page instead of Home-page). This is as per https://www.python.org/dev/peps/pep-0566/#id17. """ se...
[ "def", "todict", "(", "self", ",", "skip_missing", "=", "False", ")", ":", "self", ".", "set_metadata_version", "(", ")", "fields", "=", "_version2fieldlist", "(", "self", "[", "'Metadata-Version'", "]", ")", "data", "=", "{", "}", "for", "field_name", "in...
[ 543, 4 ]
[ 564, 19 ]
python
en
['en', 'en', 'en']
True
Metadata.get_requirements
(self, reqts, extras=None, env=None)
Base method to get dependencies, given a set of extras to satisfy and an optional environment context. :param reqts: A list of sometimes-wanted dependencies, perhaps dependent on extras and environment. :param extras: A list of optional components being requested. ...
Base method to get dependencies, given a set of extras to satisfy and an optional environment context. :param reqts: A list of sometimes-wanted dependencies, perhaps dependent on extras and environment. :param extras: A list of optional components being requested. ...
def get_requirements(self, reqts, extras=None, env=None): """ Base method to get dependencies, given a set of extras to satisfy and an optional environment context. :param reqts: A list of sometimes-wanted dependencies, perhaps dependent on extras and environment. ...
[ "def", "get_requirements", "(", "self", ",", "reqts", ",", "extras", "=", "None", ",", "env", "=", "None", ")", ":", "if", "self", ".", "_legacy", ":", "result", "=", "reqts", "else", ":", "result", "=", "[", "]", "extras", "=", "get_extras", "(", ...
[ 824, 4 ]
[ 864, 21 ]
python
en
['en', 'error', 'th']
False
LSM6DS33.__init__
(self, bus_id=1)
Set up I2C connection and initialize some flags and values.
Set up I2C connection and initialize some flags and values.
def __init__(self, bus_id=1): """ Set up I2C connection and initialize some flags and values. """ super(LSM6DS33, self).__init__(bus_id) self.is_accel_enabled = False self.is_gyro_enabled = False self.is_gyro_calibrated = False self.gyro_cal = [0, 0, 0] ...
[ "def", "__init__", "(", "self", ",", "bus_id", "=", "1", ")", ":", "super", "(", "LSM6DS33", ",", "self", ")", ".", "__init__", "(", "bus_id", ")", "self", ".", "is_accel_enabled", "=", "False", "self", ".", "is_gyro_enabled", "=", "False", "self", "."...
[ 42, 4 ]
[ 54, 37 ]
python
en
['en', 'en', 'en']
True
LSM6DS33.enable
(self, accelerometer=True, gyroscope=True, calibration=True)
Enable and set up the given sensors in the IMU.
Enable and set up the given sensors in the IMU.
def enable(self, accelerometer=True, gyroscope=True, calibration=True): """ Enable and set up the given sensors in the IMU.""" if accelerometer: # 1.66 kHz (high performance) / +/- 4g # binary value -> 0b01011000, hex value -> 0x58 self.write_register(LSM6DS33_ADDR, L...
[ "def", "enable", "(", "self", ",", "accelerometer", "=", "True", ",", "gyroscope", "=", "True", ",", "calibration", "=", "True", ")", ":", "if", "accelerometer", ":", "# 1.66 kHz (high performance) / +/- 4g", "# binary value -> 0b01011000, hex value -> 0x58", "self", ...
[ 67, 4 ]
[ 82, 43 ]
python
en
['en', 'en', 'en']
True
LSM6DS33.calibrate
(self, iterations=2000)
Calibrate the gyro's raw values.
Calibrate the gyro's raw values.
def calibrate(self, iterations=2000): """ Calibrate the gyro's raw values.""" print('Calibrating Gryo and Accelerometer...') for i in range(iterations): gyro_raw = self.get_gyroscope_raw() accel_angles = self.get_accelerometer_angles() self.gyro_cal[0] += gy...
[ "def", "calibrate", "(", "self", ",", "iterations", "=", "2000", ")", ":", "print", "(", "'Calibrating Gryo and Accelerometer...'", ")", "for", "i", "in", "range", "(", "iterations", ")", ":", "gyro_raw", "=", "self", ".", "get_gyroscope_raw", "(", ")", "acc...
[ 84, 4 ]
[ 108, 33 ]
python
en
['en', 'en', 'en']
True
LSM6DS33.get_gyroscope_raw
(self)
Return a 3D vector of raw gyro data.
Return a 3D vector of raw gyro data.
def get_gyroscope_raw(self): """ Return a 3D vector of raw gyro data. """ # Check if gyroscope has been enabled if not self.is_gyro_enabled: raise(Exception('Gyroscope is not enabled!')) sensor_data = self.read_3d_sensor(LSM6DS33_ADDR, self.gyro_registers) #...
[ "def", "get_gyroscope_raw", "(", "self", ")", ":", "# Check if gyroscope has been enabled", "if", "not", "self", ".", "is_gyro_enabled", ":", "raise", "(", "Exception", "(", "'Gyroscope is not enabled!'", ")", ")", "sensor_data", "=", "self", ".", "read_3d_sensor", ...
[ 110, 4 ]
[ 127, 30 ]
python
en
['en', 'ga', 'en']
True
LSM6DS33.get_gyro_angular_velocity
(self)
Return a 3D vector of the angular velocity measured by the gyro in degrees/second.
Return a 3D vector of the angular velocity measured by the gyro in degrees/second.
def get_gyro_angular_velocity(self): """ Return a 3D vector of the angular velocity measured by the gyro in degrees/second. """ # Check if gyroscope has been enabled if not self.is_gyro_enabled: raise(Exception('Gyroscope is not enabled!')) # Check if gyr...
[ "def", "get_gyro_angular_velocity", "(", "self", ")", ":", "# Check if gyroscope has been enabled", "if", "not", "self", ".", "is_gyro_enabled", ":", "raise", "(", "Exception", "(", "'Gyroscope is not enabled!'", ")", ")", "# Check if gyroscope has been calibrated", "if", ...
[ 129, 4 ]
[ 147, 24 ]
python
en
['en', 'en', 'en']
True
LSM6DS33.get_accelerometer_raw
(self)
Return a 3D vector of raw accelerometer data.
Return a 3D vector of raw accelerometer data.
def get_accelerometer_raw(self): """ Return a 3D vector of raw accelerometer data. """ # Check if accelerometer has been enabled if not self.is_accel_enabled: raise(Exception('Accelerometer is not enabled!')) return self.read_3d_sensor(LSM6DS33_ADDR, self.accel_regi...
[ "def", "get_accelerometer_raw", "(", "self", ")", ":", "# Check if accelerometer has been enabled", "if", "not", "self", ".", "is_accel_enabled", ":", "raise", "(", "Exception", "(", "'Accelerometer is not enabled!'", ")", ")", "return", "self", ".", "read_3d_sensor", ...
[ 149, 4 ]
[ 157, 71 ]
python
en
['en', 'en', 'en']
True
LSM6DS33.get_accelerometer_g_forces
(self)
Return a 3D vector of the g forces measured by the accelerometer
Return a 3D vector of the g forces measured by the accelerometer
def get_accelerometer_g_forces(self): """ Return a 3D vector of the g forces measured by the accelerometer""" [x_val, y_val, z_val] = self.get_accelerometer_raw() x_val = (x_val * ACCEL_CONVERSION_FACTOR) / 1000 y_val = (y_val * ACCEL_CONVERSION_FACTOR) / 1000 z_val = (z_val * A...
[ "def", "get_accelerometer_g_forces", "(", "self", ")", ":", "[", "x_val", ",", "y_val", ",", "z_val", "]", "=", "self", ".", "get_accelerometer_raw", "(", ")", "x_val", "=", "(", "x_val", "*", "ACCEL_CONVERSION_FACTOR", ")", "/", "1000", "y_val", "=", "(",...
[ 159, 4 ]
[ 167, 36 ]
python
en
['en', 'en', 'en']
True
LSM6DS33.get_accelerometer_angles
(self, round_digits=0)
Return a 2D vector of roll and pitch angles, based on accelerometer g forces
Return a 2D vector of roll and pitch angles, based on accelerometer g forces
def get_accelerometer_angles(self, round_digits=0): """ Return a 2D vector of roll and pitch angles, based on accelerometer g forces """ # Get raw accelerometer g forces [acc_xg_force, acc_yg_force, acc_zg_force] = self.get_accelerometer_g_forces() # Calculate angle...
[ "def", "get_accelerometer_angles", "(", "self", ",", "round_digits", "=", "0", ")", ":", "# Get raw accelerometer g forces", "[", "acc_xg_force", ",", "acc_yg_force", ",", "acc_zg_force", "]", "=", "self", ".", "get_accelerometer_g_forces", "(", ")", "# Calculate angl...
[ 169, 4 ]
[ 191, 56 ]
python
en
['en', 'en', 'en']
True
HttpTransport.__init__
(self, **kwargs)
@param kwargs: Keyword arguments. - B{proxy} - An http proxy to be specified on requests. The proxy is defined as {protocol:proxy,} - type: I{dict} - default: {} - B{timeout} - Set the url open timeout (seconds). ...
def __init__(self, **kwargs): """ @param kwargs: Keyword arguments. - B{proxy} - An http proxy to be specified on requests. The proxy is defined as {protocol:proxy,} - type: I{dict} - default: {} - B{timeout} - Set the url ...
[ "def", "__init__", "(", "self", ",", "*", "*", "kwargs", ")", ":", "Transport", ".", "__init__", "(", "self", ")", "Unskin", "(", "self", ".", "options", ")", ".", "update", "(", "kwargs", ")", "self", ".", "cookiejar", "=", "CookieJar", "(", ")", ...
[ 38, 4 ]
[ 53, 29 ]
python
en
['en', 'error', 'th']
False
HttpTransport.addcookies
(self, u2request)
Add cookies in the cookiejar to the request. @param u2request: A urllib2 request. @rtype: u2request: urllib2.Requet.
Add cookies in the cookiejar to the request.
def addcookies(self, u2request): """ Add cookies in the cookiejar to the request. @param u2request: A urllib2 request. @rtype: u2request: urllib2.Requet. """ self.cookiejar.add_cookie_header(u2request)
[ "def", "addcookies", "(", "self", ",", "u2request", ")", ":", "self", ".", "cookiejar", ".", "add_cookie_header", "(", "u2request", ")" ]
[ 87, 4 ]
[ 93, 51 ]
python
en
['en', 'error', 'th']
False
HttpTransport.getcookies
(self, fp, u2request)
Add cookies in the request to the cookiejar. @param u2request: A urllib2 request. @rtype: u2request: urllib2.Requet.
Add cookies in the request to the cookiejar.
def getcookies(self, fp, u2request): """ Add cookies in the request to the cookiejar. @param u2request: A urllib2 request. @rtype: u2request: urllib2.Requet. """ self.cookiejar.extract_cookies(fp, u2request)
[ "def", "getcookies", "(", "self", ",", "fp", ",", "u2request", ")", ":", "self", ".", "cookiejar", ".", "extract_cookies", "(", "fp", ",", "u2request", ")" ]
[ 95, 4 ]
[ 101, 53 ]
python
en
['en', 'error', 'th']
False
HttpTransport.u2open
(self, u2request)
Open a connection. @param u2request: A urllib2 request. @type u2request: urllib2.Requet. @return: The opened file-like urllib2 object. @rtype: fp
Open a connection.
def u2open(self, u2request): """ Open a connection. @param u2request: A urllib2 request. @type u2request: urllib2.Requet. @return: The opened file-like urllib2 object. @rtype: fp """ tm = self.options.timeout url = self.u2opener() if self.u...
[ "def", "u2open", "(", "self", ",", "u2request", ")", ":", "tm", "=", "self", ".", "options", ".", "timeout", "url", "=", "self", ".", "u2opener", "(", ")", "if", "self", ".", "u2ver", "(", ")", "<", "2.6", ":", "socket", ".", "setdefaulttimeout", "...
[ 103, 4 ]
[ 117, 50 ]
python
en
['en', 'error', 'th']
False
HttpTransport.u2opener
(self)
Create a urllib opener. @return: An opener. @rtype: I{OpenerDirector}
Create a urllib opener.
def u2opener(self): """ Create a urllib opener. @return: An opener. @rtype: I{OpenerDirector} """ if self.urlopener is None: return u2.build_opener(*self.u2handlers()) else: return self.urlopener
[ "def", "u2opener", "(", "self", ")", ":", "if", "self", ".", "urlopener", "is", "None", ":", "return", "u2", ".", "build_opener", "(", "*", "self", ".", "u2handlers", "(", ")", ")", "else", ":", "return", "self", ".", "urlopener" ]
[ 119, 4 ]
[ 128, 33 ]
python
en
['en', 'error', 'th']
False
HttpTransport.u2handlers
(self)
Get a collection of urllib handlers. @return: A list of handlers to be installed in the opener. @rtype: [Handler,...]
Get a collection of urllib handlers.
def u2handlers(self): """ Get a collection of urllib handlers. @return: A list of handlers to be installed in the opener. @rtype: [Handler,...] """ handlers = [] handlers.append(u2.ProxyHandler(self.proxy)) return handlers
[ "def", "u2handlers", "(", "self", ")", ":", "handlers", "=", "[", "]", "handlers", ".", "append", "(", "u2", ".", "ProxyHandler", "(", "self", ".", "proxy", ")", ")", "return", "handlers" ]
[ 130, 4 ]
[ 138, 23 ]
python
en
['en', 'error', 'th']
False
HttpTransport.u2ver
(self)
Get the major/minor version of the urllib2 lib. @return: The urllib2 version. @rtype: float
Get the major/minor version of the urllib2 lib.
def u2ver(self): """ Get the major/minor version of the urllib2 lib. @return: The urllib2 version. @rtype: float """ try: part = u2.__version__.split('.', 1) n = float('.'.join(part)) return n except Exception, e: lo...
[ "def", "u2ver", "(", "self", ")", ":", "try", ":", "part", "=", "u2", ".", "__version__", ".", "split", "(", "'.'", ",", "1", ")", "n", "=", "float", "(", "'.'", ".", "join", "(", "part", ")", ")", "return", "n", "except", "Exception", ",", "e"...
[ 140, 4 ]
[ 152, 20 ]
python
en
['en', 'error', 'th']
False
HTTPConnection.host
(self)
Getter method to remove any trailing dots that indicate the hostname is an FQDN. In general, SSL certificates don't include the trailing dot indicating a fully-qualified domain name, and thus, they don't validate properly when checked against a domain name that includes the dot. In add...
Getter method to remove any trailing dots that indicate the hostname is an FQDN.
def host(self): """ Getter method to remove any trailing dots that indicate the hostname is an FQDN. In general, SSL certificates don't include the trailing dot indicating a fully-qualified domain name, and thus, they don't validate properly when checked against a domain name th...
[ "def", "host", "(", "self", ")", ":", "return", "self", ".", "_dns_host", ".", "rstrip", "(", "\".\"", ")" ]
[ 117, 4 ]
[ 133, 41 ]
python
en
['en', 'error', 'th']
False
HTTPConnection.host
(self, value)
Setter for the `host` property. We assume that only urllib3 uses the _dns_host attribute; httplib itself only uses `host`, and it seems reasonable that other libraries follow suit.
Setter for the `host` property.
def host(self, value): """ Setter for the `host` property. We assume that only urllib3 uses the _dns_host attribute; httplib itself only uses `host`, and it seems reasonable that other libraries follow suit. """ self._dns_host = value
[ "def", "host", "(", "self", ",", "value", ")", ":", "self", ".", "_dns_host", "=", "value" ]
[ 136, 4 ]
[ 143, 30 ]
python
en
['en', 'error', 'th']
False
HTTPConnection._new_conn
(self)
Establish a socket connection and set nodelay settings on it. :return: New socket connection.
Establish a socket connection and set nodelay settings on it.
def _new_conn(self): """ Establish a socket connection and set nodelay settings on it. :return: New socket connection. """ extra_kw = {} if self.source_address: extra_kw["source_address"] = self.source_address if self.socket_options: extra_kw["so...
[ "def", "_new_conn", "(", "self", ")", ":", "extra_kw", "=", "{", "}", "if", "self", ".", "source_address", ":", "extra_kw", "[", "\"source_address\"", "]", "=", "self", ".", "source_address", "if", "self", ".", "socket_options", ":", "extra_kw", "[", "\"so...
[ 145, 4 ]
[ 174, 19 ]
python
en
['en', 'st', 'en']
True
HTTPConnection.putrequest
(self, method, url, *args, **kwargs)
Send a request to the server
Send a request to the server
def putrequest(self, method, url, *args, **kwargs): """Send a request to the server""" match = _CONTAINS_CONTROL_CHAR_RE.search(method) if match: raise ValueError( "Method cannot contain non-token characters %r (found at least %r)" % (method, match.gro...
[ "def", "putrequest", "(", "self", ",", "method", ",", "url", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "match", "=", "_CONTAINS_CONTROL_CHAR_RE", ".", "search", "(", "method", ")", "if", "match", ":", "raise", "ValueError", "(", "\"Method cann...
[ 189, 4 ]
[ 198, 77 ]
python
en
['en', 'en', 'en']
True
HTTPConnection.request_chunked
(self, method, url, body=None, headers=None)
Alternative to the common request method, which sends the body with chunked encoding and not as one block
Alternative to the common request method, which sends the body with chunked encoding and not as one block
def request_chunked(self, method, url, body=None, headers=None): """ Alternative to the common request method, which sends the body with chunked encoding and not as one block """ headers = HTTPHeaderDict(headers if headers is not None else {}) skip_accept_encoding = "acce...
[ "def", "request_chunked", "(", "self", ",", "method", ",", "url", ",", "body", "=", "None", ",", "headers", "=", "None", ")", ":", "headers", "=", "HTTPHeaderDict", "(", "headers", "if", "headers", "is", "not", "None", "else", "{", "}", ")", "skip_acce...
[ 200, 4 ]
[ 233, 31 ]
python
en
['en', 'error', 'th']
False
HTTPSConnection.set_cert
( self, key_file=None, cert_file=None, cert_reqs=None, key_password=None, ca_certs=None, assert_hostname=None, assert_fingerprint=None, ca_cert_dir=None, ca_cert_data=None, )
This method should only be called once, before the connection is used.
This method should only be called once, before the connection is used.
def set_cert( self, key_file=None, cert_file=None, cert_reqs=None, key_password=None, ca_certs=None, assert_hostname=None, assert_fingerprint=None, ca_cert_dir=None, ca_cert_data=None, ): """ This method should only be c...
[ "def", "set_cert", "(", "self", ",", "key_file", "=", "None", ",", "cert_file", "=", "None", ",", "cert_reqs", "=", "None", ",", "key_password", "=", "None", ",", "ca_certs", "=", "None", ",", "assert_hostname", "=", "None", ",", "assert_fingerprint", "=",...
[ 272, 4 ]
[ 303, 40 ]
python
en
['en', 'error', 'th']
False
sew_messages_and_reactions
( messages: List[Dict[str, Any]], reactions: List[Dict[str, Any]] )
Given a iterable of messages and reactions stitch reactions into messages.
Given a iterable of messages and reactions stitch reactions into messages.
def sew_messages_and_reactions( messages: List[Dict[str, Any]], reactions: List[Dict[str, Any]] ) -> List[Dict[str, Any]]: """Given a iterable of messages and reactions stitch reactions into messages. """ # Add all messages with empty reaction item for message in messages: message["react...
[ "def", "sew_messages_and_reactions", "(", "messages", ":", "List", "[", "Dict", "[", "str", ",", "Any", "]", "]", ",", "reactions", ":", "List", "[", "Dict", "[", "str", ",", "Any", "]", "]", ")", "->", "List", "[", "Dict", "[", "str", ",", "Any", ...
[ 178, 0 ]
[ 194, 44 ]
python
en
['en', 'en', 'en']
True
access_message
( user_profile: UserProfile, message_id: int )
You can access a message by ID in our APIs that either: (1) You received or have previously accessed via starring (aka have a UserMessage row for). (2) Was sent to a public stream in your realm. We produce consistent, boring error messages to avoid leaking any information from a security perspe...
You can access a message by ID in our APIs that either: (1) You received or have previously accessed via starring (aka have a UserMessage row for). (2) Was sent to a public stream in your realm.
def access_message( user_profile: UserProfile, message_id: int ) -> Tuple[Message, Optional[UserMessage]]: """You can access a message by ID in our APIs that either: (1) You received or have previously accessed via starring (aka have a UserMessage row for). (2) Was sent to a public stream in you...
[ "def", "access_message", "(", "user_profile", ":", "UserProfile", ",", "message_id", ":", "int", ")", "->", "Tuple", "[", "Message", ",", "Optional", "[", "UserMessage", "]", "]", ":", "try", ":", "message", "=", "Message", ".", "objects", ".", "select_rel...
[ 656, 0 ]
[ 676, 48 ]
python
en
['en', 'en', 'en']
True
has_message_access
( user_profile: UserProfile, message: Message, *, has_user_message: bool, stream: Optional[Stream] = None, is_subscribed: Optional[bool] = None, )
Returns whether a user has access to a given message. * The user_message parameter must be provded if the user has a UserMessage row for the target message. * The optional stream parameter is validated; is_subscribed is not.
Returns whether a user has access to a given message.
def has_message_access( user_profile: UserProfile, message: Message, *, has_user_message: bool, stream: Optional[Stream] = None, is_subscribed: Optional[bool] = None, ) -> bool: """ Returns whether a user has access to a given message. * The user_message parameter must be provded if...
[ "def", "has_message_access", "(", "user_profile", ":", "UserProfile", ",", "message", ":", "Message", ",", "*", ",", "has_user_message", ":", "bool", ",", "stream", ":", "Optional", "[", "Stream", "]", "=", "None", ",", "is_subscribed", ":", "Optional", "[",...
[ 679, 0 ]
[ 726, 14 ]
python
en
['en', 'error', 'th']
False
bulk_access_messages
( user_profile: UserProfile, messages: Sequence[Message], *, stream: Optional[Stream] = None )
This function does the full has_message_access check for each message. If stream is provided, it is used to avoid unnecessary database queries, and will use exactly 2 bulk queries instead. Throws AssertionError if stream is passed and any of the messages were not sent to that stream.
This function does the full has_message_access check for each message. If stream is provided, it is used to avoid unnecessary database queries, and will use exactly 2 bulk queries instead.
def bulk_access_messages( user_profile: UserProfile, messages: Sequence[Message], *, stream: Optional[Stream] = None ) -> List[Message]: """This function does the full has_message_access check for each message. If stream is provided, it is used to avoid unnecessary database queries, and will use exactl...
[ "def", "bulk_access_messages", "(", "user_profile", ":", "UserProfile", ",", "messages", ":", "Sequence", "[", "Message", "]", ",", "*", ",", "stream", ":", "Optional", "[", "Stream", "]", "=", "None", ")", "->", "List", "[", "Message", "]", ":", "filter...
[ 729, 0 ]
[ 764, 28 ]
python
en
['en', 'en', 'en']
True
bulk_access_messages_expect_usermessage
( user_profile_id: int, message_ids: Sequence[int] )
Like bulk_access_messages, but faster and potentially stricter. Returns a subset of `message_ids` containing only messages the user can access. Makes O(1) database queries. Use this function only when the user is expected to have a UserMessage row for every message in `message_ids`. If a Us...
Like bulk_access_messages, but faster and potentially stricter.
def bulk_access_messages_expect_usermessage( user_profile_id: int, message_ids: Sequence[int] ) -> List[int]: """ Like bulk_access_messages, but faster and potentially stricter. Returns a subset of `message_ids` containing only messages the user can access. Makes O(1) database queries. Use th...
[ "def", "bulk_access_messages_expect_usermessage", "(", "user_profile_id", ":", "int", ",", "message_ids", ":", "Sequence", "[", "int", "]", ")", "->", "List", "[", "int", "]", ":", "return", "UserMessage", ".", "objects", ".", "filter", "(", "user_profile_id", ...
[ 767, 0 ]
[ 786, 42 ]
python
en
['en', 'error', 'th']
False
render_markdown
( message: Message, content: str, realm: Optional[Realm] = None, realm_alert_words_automaton: Optional[ahocorasick.Automaton] = None, mention_data: Optional[MentionData] = None, email_gateway: bool = False, )
This is basically just a wrapper for do_render_markdown.
This is basically just a wrapper for do_render_markdown.
def render_markdown( message: Message, content: str, realm: Optional[Realm] = None, realm_alert_words_automaton: Optional[ahocorasick.Automaton] = None, mention_data: Optional[MentionData] = None, email_gateway: bool = False, ) -> str: """ This is basically just a wrapper for do_render_m...
[ "def", "render_markdown", "(", "message", ":", "Message", ",", "content", ":", "str", ",", "realm", ":", "Optional", "[", "Realm", "]", "=", "None", ",", "realm_alert_words_automaton", ":", "Optional", "[", "ahocorasick", ".", "Automaton", "]", "=", "None", ...
[ 789, 0 ]
[ 819, 27 ]
python
en
['en', 'error', 'th']
False
do_render_markdown
( message: Message, content: str, realm: Realm, sent_by_bot: bool, translate_emoticons: bool, realm_alert_words_automaton: Optional[ahocorasick.Automaton] = None, mention_data: Optional[MentionData] = None, email_gateway: bool = False, )
Return HTML for given Markdown. Markdown may add properties to the message object such as `mentions_user_ids`, `mentions_user_group_ids`, and `mentions_wildcard`. These are only on this Django object and are not saved in the database.
Return HTML for given Markdown. Markdown may add properties to the message object such as `mentions_user_ids`, `mentions_user_group_ids`, and `mentions_wildcard`. These are only on this Django object and are not saved in the database.
def do_render_markdown( message: Message, content: str, realm: Realm, sent_by_bot: bool, translate_emoticons: bool, realm_alert_words_automaton: Optional[ahocorasick.Automaton] = None, mention_data: Optional[MentionData] = None, email_gateway: bool = False, ) -> str: """Return HTML f...
[ "def", "do_render_markdown", "(", "message", ":", "Message", ",", "content", ":", "str", ",", "realm", ":", "Realm", ",", "sent_by_bot", ":", "bool", ",", "translate_emoticons", ":", "bool", ",", "realm_alert_words_automaton", ":", "Optional", "[", "ahocorasick"...
[ 822, 0 ]
[ 856, 27 ]
python
en
['en', 'en', 'en']
True
aggregate_message_dict
( input_dict: Dict[int, Dict[str, Any]], lookup_fields: List[str], collect_senders: bool )
A concrete example might help explain the inputs here: input_dict = { 1002: dict(stream_id=5, topic='foo', sender_id=40), 1003: dict(stream_id=5, topic='foo', sender_id=41), 1004: dict(stream_id=6, topic='baz', sender_id=99), } lookup_fields = ['stream_id', 'topic'] The f...
A concrete example might help explain the inputs here:
def aggregate_message_dict( input_dict: Dict[int, Dict[str, Any]], lookup_fields: List[str], collect_senders: bool ) -> List[Dict[str, Any]]: lookup_dict: Dict[Tuple[Any, ...], Dict[str, Any]] = {} """ A concrete example might help explain the inputs here: input_dict = { 1002: dict(stream_...
[ "def", "aggregate_message_dict", "(", "input_dict", ":", "Dict", "[", "int", ",", "Dict", "[", "str", ",", "Any", "]", "]", ",", "lookup_fields", ":", "List", "[", "str", "]", ",", "collect_senders", ":", "bool", ")", "->", "List", "[", "Dict", "[", ...
[ 874, 0 ]
[ 934, 48 ]
python
en
['en', 'error', 'th']
False
get_recent_conversations_recipient_id
( user_profile: UserProfile, recipient_id: int, sender_id: int )
Helper for doing lookups of the recipient_id that get_recent_private_conversations would have used to record that message in its data structure.
Helper for doing lookups of the recipient_id that get_recent_private_conversations would have used to record that message in its data structure.
def get_recent_conversations_recipient_id( user_profile: UserProfile, recipient_id: int, sender_id: int ) -> int: """Helper for doing lookups of the recipient_id that get_recent_private_conversations would have used to record that message in its data structure. """ my_recipient_id = user_profile...
[ "def", "get_recent_conversations_recipient_id", "(", "user_profile", ":", "UserProfile", ",", "recipient_id", ":", "int", ",", "sender_id", ":", "int", ")", "->", "int", ":", "my_recipient_id", "=", "user_profile", ".", "recipient_id", "if", "recipient_id", "==", ...
[ 1297, 0 ]
[ 1307, 23 ]
python
en
['en', 'en', 'en']
True
get_recent_private_conversations
(user_profile: UserProfile)
This function uses some carefully optimized SQL queries, designed to use the UserMessage index on private_messages. It is significantly complicated by the fact that for 1:1 private messages, we store the message against a recipient_id of whichever user was the recipient, and thus for 1:1 private messag...
This function uses some carefully optimized SQL queries, designed to use the UserMessage index on private_messages. It is significantly complicated by the fact that for 1:1 private messages, we store the message against a recipient_id of whichever user was the recipient, and thus for 1:1 private messag...
def get_recent_private_conversations(user_profile: UserProfile) -> Dict[int, Dict[str, Any]]: """This function uses some carefully optimized SQL queries, designed to use the UserMessage index on private_messages. It is significantly complicated by the fact that for 1:1 private messages, we store the me...
[ "def", "get_recent_private_conversations", "(", "user_profile", ":", "UserProfile", ")", "->", "Dict", "[", "int", ",", "Dict", "[", "str", ",", "Any", "]", "]", ":", "RECENT_CONVERSATIONS_LIMIT", "=", "1000", "recipient_map", "=", "{", "}", "my_recipient_id", ...
[ 1310, 0 ]
[ 1415, 24 ]
python
en
['en', 'en', 'en']
True
MessageDict.wide_dict
(message: Message, realm_id: Optional[int] = None)
The next two lines get the cacheable field related to our message object, with the side effect of populating the cache.
The next two lines get the cacheable field related to our message object, with the side effect of populating the cache.
def wide_dict(message: Message, realm_id: Optional[int] = None) -> Dict[str, Any]: """ The next two lines get the cacheable field related to our message object, with the side effect of populating the cache. """ json = message_to_dict_json(message, realm_id) obj = ...
[ "def", "wide_dict", "(", "message", ":", "Message", ",", "realm_id", ":", "Optional", "[", "int", "]", "=", "None", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "json", "=", "message_to_dict_json", "(", "message", ",", "realm_id", ")", "obj", ...
[ 257, 4 ]
[ 275, 18 ]
python
en
['en', 'error', 'th']
False
MessageDict.post_process_dicts
( objs: List[Dict[str, Any]], apply_markdown: bool, client_gravatar: bool )
NOTE: This function mutates the objects in the `objs` list, rather than making shallow copies. It might be safer to make shallow copies here, but performance is somewhat important here, as we are often fetching hundreds of messages. ...
NOTE: This function mutates the objects in the `objs` list, rather than making shallow copies. It might be safer to make shallow copies here, but performance is somewhat important here, as we are often fetching hundreds of messages. ...
def post_process_dicts( objs: List[Dict[str, Any]], apply_markdown: bool, client_gravatar: bool ) -> None: """ NOTE: This function mutates the objects in the `objs` list, rather than making shallow copies. It might be safer to make shallow copies he...
[ "def", "post_process_dicts", "(", "objs", ":", "List", "[", "Dict", "[", "str", ",", "Any", "]", "]", ",", "apply_markdown", ":", "bool", ",", "client_gravatar", ":", "bool", ")", "->", "None", ":", "MessageDict", ".", "bulk_hydrate_sender_info", "(", "obj...
[ 278, 4 ]
[ 293, 94 ]
python
en
['en', 'error', 'th']
False
MessageDict.finalize_payload
( obj: Dict[str, Any], apply_markdown: bool, client_gravatar: bool, keep_rendered_content: bool = False, skip_copy: bool = False, )
By default, we make a shallow copy of the incoming dict to avoid mutation-related bugs. Code paths that are passing a unique object can pass skip_copy=True to avoid this extra work.
By default, we make a shallow copy of the incoming dict to avoid mutation-related bugs. Code paths that are passing a unique object can pass skip_copy=True to avoid this extra work.
def finalize_payload( obj: Dict[str, Any], apply_markdown: bool, client_gravatar: bool, keep_rendered_content: bool = False, skip_copy: bool = False, ) -> Dict[str, Any]: """ By default, we make a shallow copy of the incoming dict to avoid mutation-rel...
[ "def", "finalize_payload", "(", "obj", ":", "Dict", "[", "str", ",", "Any", "]", ",", "apply_markdown", ":", "bool", ",", "client_gravatar", ":", "bool", ",", "keep_rendered_content", ":", "bool", "=", "False", ",", "skip_copy", ":", "bool", "=", "False", ...
[ 296, 4 ]
[ 328, 18 ]
python
en
['en', 'error', 'th']
False
MessageDict.build_dict_from_raw_db_row
(row: Dict[str, Any])
row is a row from a .values() call, and it needs to have all the relevant fields populated
row is a row from a .values() call, and it needs to have all the relevant fields populated
def build_dict_from_raw_db_row(row: Dict[str, Any]) -> Dict[str, Any]: """ row is a row from a .values() call, and it needs to have all the relevant fields populated """ return MessageDict.build_message_dict( message_id=row["id"], last_edit_time=row["last_...
[ "def", "build_dict_from_raw_db_row", "(", "row", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "return", "MessageDict", ".", "build_message_dict", "(", "message_id", "=", "row", "[", "\"id\"", "]", ",", ...
[ 414, 4 ]
[ 437, 9 ]
python
en
['en', 'error', 'th']
False
MessageDict.hydrate_recipient_info
(obj: Dict[str, Any], display_recipient: DisplayRecipientT)
This method hyrdrates recipient info with things like full names and emails of senders. Eventually our clients should be able to hyrdrate these fields themselves with info they already have on users.
This method hyrdrates recipient info with things like full names and emails of senders. Eventually our clients should be able to hyrdrate these fields themselves with info they already have on users.
def hydrate_recipient_info(obj: Dict[str, Any], display_recipient: DisplayRecipientT) -> None: """ This method hyrdrates recipient info with things like full names and emails of senders. Eventually our clients should be able to hyrdrate these fields themselves with info they alr...
[ "def", "hydrate_recipient_info", "(", "obj", ":", "Dict", "[", "str", ",", "Any", "]", ",", "display_recipient", ":", "DisplayRecipientT", ")", "->", "None", ":", "recipient_type", "=", "obj", "[", "\"recipient_type\"", "]", "recipient_type_id", "=", "obj", "[...
[ 558, 4 ]
[ 597, 48 ]
python
en
['en', 'error', 'th']
False
avatar_url_from_dict
(userdict: Dict[str, Any], medium: bool = False)
DEPRECATED: We should start using get_avatar_field to populate users, particularly for codepaths where the client can compute gravatar URLs on the client side.
DEPRECATED: We should start using get_avatar_field to populate users, particularly for codepaths where the client can compute gravatar URLs on the client side.
def avatar_url_from_dict(userdict: Dict[str, Any], medium: bool = False) -> str: """ DEPRECATED: We should start using get_avatar_field to populate users, particularly for codepaths where the client can compute gravatar URLs on the client side. ...
[ "def", "avatar_url_from_dict", "(", "userdict", ":", "Dict", "[", "str", ",", "Any", "]", ",", "medium", ":", "bool", "=", "False", ")", "->", "str", ":", "url", "=", "_get_unversioned_avatar_url", "(", "userdict", "[", "\"id\"", "]", ",", "userdict", "[...
[ 29, 0 ]
[ 45, 14 ]
python
en
['en', 'error', 'th']
False
get_avatar_field
( user_id: int, realm_id: int, email: str, avatar_source: str, avatar_version: int, medium: bool, client_gravatar: bool, )
Most of the parameters to this function map to fields by the same name in UserProfile (avatar_source, realm_id, email, etc.). Then there are these: medium - This means we want a medium-sized avatar. This can affect the "s" parameter for gravatar avatars, or it can give...
Most of the parameters to this function map to fields by the same name in UserProfile (avatar_source, realm_id, email, etc.).
def get_avatar_field( user_id: int, realm_id: int, email: str, avatar_source: str, avatar_version: int, medium: bool, client_gravatar: bool, ) -> Optional[str]: """ Most of the parameters to this function map to fields by the same name in UserProfile (avatar_source, realm_id, ...
[ "def", "get_avatar_field", "(", "user_id", ":", "int", ",", "realm_id", ":", "int", ",", "email", ":", "str", ",", "avatar_source", ":", "str", ",", "avatar_version", ":", "int", ",", "medium", ":", "bool", ",", "client_gravatar", ":", "bool", ",", ")", ...
[ 48, 0 ]
[ 97, 14 ]
python
en
['en', 'error', 'th']
False
absolute_avatar_url
(user_profile: UserProfile)
Absolute URLs are used to simplify logic for applications that won't be served by browsers, such as rendering GCM notifications.
Absolute URLs are used to simplify logic for applications that won't be served by browsers, such as rendering GCM notifications.
def absolute_avatar_url(user_profile: UserProfile) -> str: """ Absolute URLs are used to simplify logic for applications that won't be served by browsers, such as rendering GCM notifications. """ avatar = avatar_url(user_profile) # avatar_url can return None if client_gravatar=True, however here...
[ "def", "absolute_avatar_url", "(", "user_profile", ":", "UserProfile", ")", "->", "str", ":", "avatar", "=", "avatar_url", "(", "user_profile", ")", "# avatar_url can return None if client_gravatar=True, however here we use the default value of False", "assert", "avatar", "is",...
[ 128, 0 ]
[ 136, 63 ]
python
en
['en', 'error', 'th']
False
truncate_angle
(angle_degrees: Real)
:return: The angle, truncated to be in the range [0, 240] degrees.
:return: The angle, truncated to be in the range [0, 240] degrees.
def truncate_angle(angle_degrees: Real) -> Real: """:return: The angle, truncated to be in the range [0, 240] degrees.""" return min(max(MIN_ANGLE_DEGREES, angle_degrees), MAX_ANGLE_DEGREES)
[ "def", "truncate_angle", "(", "angle_degrees", ":", "Real", ")", "->", "Real", ":", "return", "min", "(", "max", "(", "MIN_ANGLE_DEGREES", ",", "angle_degrees", ")", ",", "MAX_ANGLE_DEGREES", ")" ]
[ 712, 0 ]
[ 715, 72 ]
python
en
['en', 'en', 'en']
True
Xarm.__init__
( self, serial_port_regexp: str = r'/dev/ttyACM\d+', timeout: float = 1.0, on_enter_power_on: bool = False, on_exit_power_off: bool = True, verify_checksum: bool = True )
:param serial_port_regexp: Search pattern passed to serial.tools.list_ports.grep used to find the controller. :param timeout: How long to wait for a response from the controller before timing out. None means never timeout. :param on_enter_power_on: If the servos should be powered on when enteri...
:param serial_port_regexp: Search pattern passed to serial.tools.list_ports.grep used to find the controller. :param timeout: How long to wait for a response from the controller before timing out. None means never timeout. :param on_enter_power_on: If the servos should be powered on when enteri...
def __init__( self, serial_port_regexp: str = r'/dev/ttyACM\d+', timeout: float = 1.0, on_enter_power_on: bool = False, on_exit_power_off: bool = True, verify_checksum: bool = True ) -> None: """ :param serial_port_regexp: Searc...
[ "def", "__init__", "(", "self", ",", "serial_port_regexp", ":", "str", "=", "r'/dev/ttyACM\\d+'", ",", "timeout", ":", "float", "=", "1.0", ",", "on_enter_power_on", ":", "bool", "=", "False", ",", "on_exit_power_off", ":", "bool", "=", "True", ",", "verify_...
[ 94, 4 ]
[ 120, 33 ]
python
en
['en', 'error', 'th']
False
Xarm._move_time_write
(self, servo_id: int, angle_degrees: Real, time_s: Real, command: int, wait: bool)
:param servo_id: :param angle_degrees: Should be in the range [0, 240] degrees; will be truncated if outside this range. :param time_s: Should be in the range [0, 30] seconds; will be truncated if outside this range. :param wait: Whether or not to wait time_s seconds after sending the c...
:param servo_id: :param angle_degrees: Should be in the range [0, 240] degrees; will be truncated if outside this range. :param time_s: Should be in the range [0, 30] seconds; will be truncated if outside this range. :param wait: Whether or not to wait time_s seconds after sending the c...
def _move_time_write(self, servo_id: int, angle_degrees: Real, time_s: Real, command: int, wait: bool) -> None: """ :param servo_id: :param angle_degrees: Should be in the range [0, 240] degrees; will be truncated if outside this range. :param time_s: Should be in the range [0, 30] secon...
[ "def", "_move_time_write", "(", "self", ",", "servo_id", ":", "int", ",", "angle_degrees", ":", "Real", ",", "time_s", ":", "Real", ",", "command", ":", "int", ",", "wait", ":", "bool", ")", "->", "None", ":", "if", "command", "not", "in", "{", "_SER...
[ 219, 4 ]
[ 243, 30 ]
python
en
['en', 'error', 'th']
False
Xarm.move_time_write
(self, servo_id: int, angle_degrees: Real, time_s: Real, wait: bool = False)
Tells the servo to start moving to the specified angle within the specified amount of time. :param servo_id: :param angle_degrees: Should be in the range [0, 240] degrees; will be truncated if outside this range. :param time_s: Should be in the range [0, 30] s; will be truncated if out...
Tells the servo to start moving to the specified angle within the specified amount of time.
def move_time_write(self, servo_id: int, angle_degrees: Real, time_s: Real, wait: bool = False) -> None: """ Tells the servo to start moving to the specified angle within the specified amount of time. :param servo_id: :param angle_degrees: Should be in the range [0, 240] degrees; will b...
[ "def", "move_time_write", "(", "self", ",", "servo_id", ":", "int", ",", "angle_degrees", ":", "Real", ",", "time_s", ":", "Real", ",", "wait", ":", "bool", "=", "False", ")", "->", "None", ":", "return", "self", ".", "_move_time_write", "(", "servo_id",...
[ 245, 4 ]
[ 255, 99 ]
python
en
['en', 'error', 'th']
False
Xarm.move_time_wait_write
(self, servo_id: int, angle_degrees: Real, time_s: Real)
Just like move_time_write(), except the servo will not start moving until move_start() is called. :param servo_id: :param angle_degrees: Should be in the range [0, 240] degrees; will be truncated if outside this range. :param time_s: Should be in the range [0, 30] s; will be truncated ...
Just like move_time_write(), except the servo will not start moving until move_start() is called.
def move_time_wait_write(self, servo_id: int, angle_degrees: Real, time_s: Real) -> None: """ Just like move_time_write(), except the servo will not start moving until move_start() is called. :param servo_id: :param angle_degrees: Should be in the range [0, 240] degrees; will be truncat...
[ "def", "move_time_wait_write", "(", "self", ",", "servo_id", ":", "int", ",", "angle_degrees", ":", "Real", ",", "time_s", ":", "Real", ")", "->", "None", ":", "return", "self", ".", "_move_time_write", "(", "servo_id", ",", "angle_degrees", ",", "time_s", ...
[ 257, 4 ]
[ 266, 105 ]
python
en
['en', 'error', 'th']
False
Xarm._move_time_read
(self, servo_id: int, command: int)
:param servo_id: :param command: Either _SERVO_MOVE_TIME_READ or _SERVO_MOVE_TIME_WAIT_READ. :return: A tuple of (angle_degrees, time_s).
:param servo_id: :param command: Either _SERVO_MOVE_TIME_READ or _SERVO_MOVE_TIME_WAIT_READ. :return: A tuple of (angle_degrees, time_s).
def _move_time_read(self, servo_id: int, command: int) -> Tuple[float, float]: """ :param servo_id: :param command: Either _SERVO_MOVE_TIME_READ or _SERVO_MOVE_TIME_WAIT_READ. :return: A tuple of (angle_degrees, time_s). """ if command not in {_SERVO_MOVE_TIME_READ, _SER...
[ "def", "_move_time_read", "(", "self", ",", "servo_id", ":", "int", ",", "command", ":", "int", ")", "->", "Tuple", "[", "float", ",", "float", "]", ":", "if", "command", "not", "in", "{", "_SERVO_MOVE_TIME_READ", ",", "_SERVO_MOVE_TIME_WAIT_READ", "}", ":...
[ 268, 4 ]
[ 287, 36 ]
python
en
['en', 'error', 'th']
False
Xarm.move_time_read
(self, servo_id: int)
Returns the parameters set by the last call to move_time_write(). :param servo_id: :return: A tuple of (angle_degrees, time_s).
Returns the parameters set by the last call to move_time_write().
def move_time_read(self, servo_id: int) -> Tuple[float, float]: """ Returns the parameters set by the last call to move_time_write(). :param servo_id: :return: A tuple of (angle_degrees, time_s). """ return self._move_time_read(servo_id, command=_SERVO_MOVE_TIME_READ)
[ "def", "move_time_read", "(", "self", ",", "servo_id", ":", "int", ")", "->", "Tuple", "[", "float", ",", "float", "]", ":", "return", "self", ".", "_move_time_read", "(", "servo_id", ",", "command", "=", "_SERVO_MOVE_TIME_READ", ")" ]
[ 289, 4 ]
[ 297, 76 ]
python
en
['en', 'error', 'th']
False
Xarm.move_time_wait_read
(self, servo_id: int)
Returns the parameters set by the last call to move_time_wait_write(). :param servo_id: :return: A tuple of (angle_degrees, time_s).
Returns the parameters set by the last call to move_time_wait_write().
def move_time_wait_read(self, servo_id: int) -> Tuple[float, float]: """ Returns the parameters set by the last call to move_time_wait_write(). :param servo_id: :return: A tuple of (angle_degrees, time_s). """ return self._move_time_read(servo_id, command=_SERVO_MOVE_TI...
[ "def", "move_time_wait_read", "(", "self", ",", "servo_id", ":", "int", ")", "->", "Tuple", "[", "float", ",", "float", "]", ":", "return", "self", ".", "_move_time_read", "(", "servo_id", ",", "command", "=", "_SERVO_MOVE_TIME_WAIT_READ", ")" ]
[ 299, 4 ]
[ 307, 81 ]
python
en
['en', 'error', 'th']
False
Xarm.move_speed_write
(self, servo_id: int, angle_degrees: Real, speed_dps: Real, wait: bool = False)
Tells the servo to go to the specified angle at a certain speed. :param servo_id: :param angle_degrees: Should be in the range [0, 240] degrees; will be truncated if outside this range. :param speed_dps: The speed in degrees-per-second that the servo should move to the target. ...
Tells the servo to go to the specified angle at a certain speed.
def move_speed_write(self, servo_id: int, angle_degrees: Real, speed_dps: Real, wait: bool = False) -> None: """ Tells the servo to go to the specified angle at a certain speed. :param servo_id: :param angle_degrees: Should be in the range [0, 240] degrees; will be truncated if outside ...
[ "def", "move_speed_write", "(", "self", ",", "servo_id", ":", "int", ",", "angle_degrees", ":", "Real", ",", "speed_dps", ":", "Real", ",", "wait", ":", "bool", "=", "False", ")", "->", "None", ":", "current_angle", "=", "self", ".", "pos_read", "(", "...
[ 309, 4 ]
[ 323, 72 ]
python
en
['en', 'error', 'th']
False
Xarm.velocity_read
(self, *servo_ids: int, period_s: Real = 0.1)
Determines the servo's current velocity by taking two position measurements period_s seconds apart. :param servo_ids: One or more servo IDs. :param period_s: The observation period -- how long to wait between position measurements. :return: The current velocity of the servo in degrees ...
Determines the servo's current velocity by taking two position measurements period_s seconds apart.
def velocity_read(self, *servo_ids: int, period_s: Real = 0.1) -> List[float]: """ Determines the servo's current velocity by taking two position measurements period_s seconds apart. :param servo_ids: One or more servo IDs. :param period_s: The observation period -- how long to wait bet...
[ "def", "velocity_read", "(", "self", ",", "*", "servo_ids", ":", "int", ",", "period_s", ":", "Real", "=", "0.1", ")", "->", "List", "[", "float", "]", ":", "measurements0", "=", "[", "(", "time", ".", "monotonic", "(", ")", ",", "self", ".", "pos_...
[ 325, 4 ]
[ 344, 25 ]
python
en
['en', 'error', 'th']
False
Xarm.move_start
(self, servo_id: int)
Tells the servo to start the motion specified by the last call to move_time_wait_write().
Tells the servo to start the motion specified by the last call to move_time_wait_write().
def move_start(self, servo_id: int) -> None: """Tells the servo to start the motion specified by the last call to move_time_wait_write().""" self._send_packet(servo_id, _SERVO_MOVE_START)
[ "def", "move_start", "(", "self", ",", "servo_id", ":", "int", ")", "->", "None", ":", "self", ".", "_send_packet", "(", "servo_id", ",", "_SERVO_MOVE_START", ")" ]
[ 346, 4 ]
[ 348, 54 ]
python
en
['en', 'en', 'en']
True
Xarm.move_stop
(self, servo_id: int)
Stop the servo at whatever its current angle is.
Stop the servo at whatever its current angle is.
def move_stop(self, servo_id: int) -> None: """Stop the servo at whatever its current angle is.""" self._send_packet(servo_id, _SERVO_MOVE_STOP)
[ "def", "move_stop", "(", "self", ",", "servo_id", ":", "int", ")", "->", "None", ":", "self", ".", "_send_packet", "(", "servo_id", ",", "_SERVO_MOVE_STOP", ")" ]
[ 350, 4 ]
[ 352, 53 ]
python
en
['en', 'en', 'en']
True
Xarm.id_write
(self, old_id: int, new_id: int)
Give the specified servo a new ID.
Give the specified servo a new ID.
def id_write(self, old_id: int, new_id: int) -> None: """Give the specified servo a new ID.""" if new_id < 0 or new_id > 253: raise ValueError(f'new_id must be in range [0, 253]; got {new_id}.') self._send_packet(old_id, _SERVO_ID_WRITE, bytes((new_id,)))
[ "def", "id_write", "(", "self", ",", "old_id", ":", "int", ",", "new_id", ":", "int", ")", "->", "None", ":", "if", "new_id", "<", "0", "or", "new_id", ">", "253", ":", "raise", "ValueError", "(", "f'new_id must be in range [0, 253]; got {new_id}.'", ")", ...
[ 354, 4 ]
[ 360, 68 ]
python
en
['en', 'en', 'en']
True
Xarm.angle_offset_adjust
(self, servo_id: int, offset_degrees: Real, write: bool = True)
Sets the servo's angle offset. :param servo_id: :param offset_degrees: Servo angle offset, in the range [-30, +30] degrees. :param write: If True, then angle_offset_write(servo_id) will be called after the offset adjustment has been made. Otherwise, the offset adjustment wi...
Sets the servo's angle offset.
def angle_offset_adjust(self, servo_id: int, offset_degrees: Real, write: bool = True) -> None: """ Sets the servo's angle offset. :param servo_id: :param offset_degrees: Servo angle offset, in the range [-30, +30] degrees. :param write: If True, then angle_offset_write(servo_id...
[ "def", "angle_offset_adjust", "(", "self", ",", "servo_id", ":", "int", ",", "offset_degrees", ":", "Real", ",", "write", ":", "bool", "=", "True", ")", "->", "None", ":", "if", "offset_degrees", "<", "-", "30", "or", "offset_degrees", ">", "30", ":", ...
[ 362, 4 ]
[ 380, 45 ]
python
en
['en', 'error', 'th']
False
Xarm.angle_offset_write
(self, servo_id: int)
Saves the offset adjust value set by angle_offset_adjust() so that it will persist after the servo loses power.
Saves the offset adjust value set by angle_offset_adjust() so that it will persist after the servo loses power.
def angle_offset_write(self, servo_id: int) -> None: """ Saves the offset adjust value set by angle_offset_adjust() so that it will persist after the servo loses power. """ self._send_packet(servo_id, _SERVO_ANGLE_OFFSET_WRITE)
[ "def", "angle_offset_write", "(", "self", ",", "servo_id", ":", "int", ")", "->", "None", ":", "self", ".", "_send_packet", "(", "servo_id", ",", "_SERVO_ANGLE_OFFSET_WRITE", ")" ]
[ 382, 4 ]
[ 388, 62 ]
python
en
['en', 'error', 'th']
False
Xarm.angle_offset_read
(self, servo_id: int)
:return: The angle offset of the servo in degrees. Defaults to 0. Range is [-30, 30].
:return: The angle offset of the servo in degrees. Defaults to 0. Range is [-30, 30].
def angle_offset_read(self, servo_id: int) -> float: """ :return: The angle offset of the servo in degrees. Defaults to 0. Range is [-30, 30]. """ response = self._send_and_receive_packet(servo_id, _SERVO_ANGLE_OFFSET_READ) offset = _1_SIGNED_CHAR_STRUCT.unpack(response.paramete...
[ "def", "angle_offset_read", "(", "self", ",", "servo_id", ":", "int", ")", "->", "float", ":", "response", "=", "self", ".", "_send_and_receive_packet", "(", "servo_id", ",", "_SERVO_ANGLE_OFFSET_READ", ")", "offset", "=", "_1_SIGNED_CHAR_STRUCT", ".", "unpack", ...
[ 390, 4 ]
[ 397, 32 ]
python
en
['en', 'error', 'th']
False
Xarm.angle_limit_write
(self, servo_id: int, min_angle_degrees: Real, max_angle_degrees: Real)
Sets the minimum and maximum servo angles allowed. This setting will persist after the servo loses power. :param servo_id: :param min_angle_degrees: Minimum servo angle, in the range [0, 240] degrees. Will be truncated if out of range. Must be lower than max_angle_degrees. ...
Sets the minimum and maximum servo angles allowed. This setting will persist after the servo loses power.
def angle_limit_write(self, servo_id: int, min_angle_degrees: Real, max_angle_degrees: Real) -> None: """ Sets the minimum and maximum servo angles allowed. This setting will persist after the servo loses power. :param servo_id: :param min_angle_degrees: Minimum servo angle, in ...
[ "def", "angle_limit_write", "(", "self", ",", "servo_id", ":", "int", ",", "min_angle_degrees", ":", "Real", ",", "max_angle_degrees", ":", "Real", ")", "->", "None", ":", "min_angle_degrees", "=", "truncate_angle", "(", "min_angle_degrees", ")", "max_angle_degree...
[ 399, 4 ]
[ 425, 69 ]
python
en
['en', 'error', 'th']
False
Xarm.angle_limit_read
(self, servo_id: int)
Gets the angle limits as set by angle_limit_write(). :return: The angle limits as a tuple of (min_angle_degrees, max_angle_degrees).
Gets the angle limits as set by angle_limit_write().
def angle_limit_read(self, servo_id: int) -> Tuple[float, float]: """ Gets the angle limits as set by angle_limit_write(). :return: The angle limits as a tuple of (min_angle_degrees, max_angle_degrees). """ response = self._send_and_receive_packet(servo_id, _SERVO_ANGLE_LIMIT_R...
[ "def", "angle_limit_read", "(", "self", ",", "servo_id", ":", "int", ")", "->", "Tuple", "[", "float", ",", "float", "]", ":", "response", "=", "self", ".", "_send_and_receive_packet", "(", "servo_id", ",", "_SERVO_ANGLE_LIMIT_READ", ")", "min_angle", ",", "...
[ 427, 4 ]
[ 441, 51 ]
python
en
['en', 'error', 'th']
False
Xarm.vin_limit_write
(self, servo_id: int, min_voltage: Real, max_voltage: Real)
Sets the minimum and maximum supply voltages allowed to power the servo. If the supply voltage goes outside the specified range, the servos will be powered off. This setting will persist after a servo loses power. :param servo_id: :param min_voltage: Should be in the range [4.5...
Sets the minimum and maximum supply voltages allowed to power the servo. If the supply voltage goes outside the specified range, the servos will be powered off. This setting will persist after a servo loses power.
def vin_limit_write(self, servo_id: int, min_voltage: Real, max_voltage: Real) -> None: """ Sets the minimum and maximum supply voltages allowed to power the servo. If the supply voltage goes outside the specified range, the servos will be powered off. This setting will persist after a s...
[ "def", "vin_limit_write", "(", "self", ",", "servo_id", ":", "int", ",", "min_voltage", ":", "Real", ",", "max_voltage", ":", "Real", ")", "->", "None", ":", "def", "scrub_voltage", "(", "v", ":", "Real", ")", "->", "int", ":", "\"\"\"Converts to mV and li...
[ 443, 4 ]
[ 472, 67 ]
python
en
['en', 'error', 'th']
False
Xarm.vin_limit_read
(self, servo_id: int)
Gets the input voltage limits as set by vin_limit_write(). :param servo_id: :return: A tuple of the (min_voltage, max_voltage) settings in Volts.
Gets the input voltage limits as set by vin_limit_write().
def vin_limit_read(self, servo_id: int) -> Tuple[float, float]: """ Gets the input voltage limits as set by vin_limit_write(). :param servo_id: :return: A tuple of the (min_voltage, max_voltage) settings in Volts. """ response = self._send_and_receive_packet(servo_id, _...
[ "def", "vin_limit_read", "(", "self", ",", "servo_id", ":", "int", ")", "->", "Tuple", "[", "float", ",", "float", "]", ":", "response", "=", "self", ".", "_send_and_receive_packet", "(", "servo_id", ",", "_SERVO_VIN_LIMIT_READ", ")", "min_voltage_mv", ",", ...
[ 474, 4 ]
[ 488, 39 ]
python
en
['en', 'error', 'th']
False
Xarm.temp_max_limit_write
(self, servo_id: int, temp: Real, units: Literal['C', 'F'] = 'F')
Sets the maximum allowed temperature at which the servo will operate. If the servo temperature exceeds this limit, then the motor will be powered off. This setting persists after a servo loses power. :param servo_id: :param temp: Max allowed temperature. Should be in range [50,...
Sets the maximum allowed temperature at which the servo will operate. If the servo temperature exceeds this limit, then the motor will be powered off. This setting persists after a servo loses power.
def temp_max_limit_write(self, servo_id: int, temp: Real, units: Literal['C', 'F'] = 'F') -> None: """ Sets the maximum allowed temperature at which the servo will operate. If the servo temperature exceeds this limit, then the motor will be powered off. This setting persists after a serv...
[ "def", "temp_max_limit_write", "(", "self", ",", "servo_id", ":", "int", ",", "temp", ":", "Real", ",", "units", ":", "Literal", "[", "'C'", ",", "'F'", "]", "=", "'F'", ")", "->", "None", ":", "units", "=", "_validate_temp_units", "(", "units", ")", ...
[ 490, 4 ]
[ 510, 80 ]
python
en
['en', 'error', 'th']
False
Xarm.temp_max_limit_read
(self, servo_id: int, units: Literal['C', 'F'] = 'F')
Gets the maximum temperature limit s set by temp_max_limit_write(). :param servo_id: :param units: Use 'C' for Celsius or 'F' for Fahrenheit. :return: The max allowed temperature, in degrees Celsius or Fahrenheit.
Gets the maximum temperature limit s set by temp_max_limit_write().
def temp_max_limit_read(self, servo_id: int, units: Literal['C', 'F'] = 'F') -> float: """ Gets the maximum temperature limit s set by temp_max_limit_write(). :param servo_id: :param units: Use 'C' for Celsius or 'F' for Fahrenheit. :return: The max allowed temperature, in degre...
[ "def", "temp_max_limit_read", "(", "self", ",", "servo_id", ":", "int", ",", "units", ":", "Literal", "[", "'C'", ",", "'F'", "]", "=", "'F'", ")", "->", "float", ":", "units", "=", "_validate_temp_units", "(", "units", ")", "response", "=", "self", "....
[ 512, 4 ]
[ 529, 19 ]
python
en
['en', 'error', 'th']
False
Xarm.temp_read
(self, servo_id: int, units: Literal['C', 'F'] = 'F')
Reads the temperature of the servo and returns in units of either Celsius or Fahrenheit. :param servo_id: :param units: Use 'C' for Celsius or 'F' for Fahrenheit.
Reads the temperature of the servo and returns in units of either Celsius or Fahrenheit.
def temp_read(self, servo_id: int, units: Literal['C', 'F'] = 'F') -> float: """ Reads the temperature of the servo and returns in units of either Celsius or Fahrenheit. :param servo_id: :param units: Use 'C' for Celsius or 'F' for Fahrenheit. """ units = _validate_temp...
[ "def", "temp_read", "(", "self", ",", "servo_id", ":", "int", ",", "units", ":", "Literal", "[", "'C'", ",", "'F'", "]", "=", "'F'", ")", "->", "float", ":", "units", "=", "_validate_temp_units", "(", "units", ")", "response", "=", "self", ".", "_sen...
[ 531, 4 ]
[ 550, 19 ]
python
en
['en', 'error', 'th']
False
Xarm.vin_read
(self, servo_id: int)
Gets the input voltage to the servo.
Gets the input voltage to the servo.
def vin_read(self, servo_id: int) -> float: """Gets the input voltage to the servo.""" response = self._send_and_receive_packet(servo_id, _SERVO_VIN_READ) vin_mv = _1_SIGNED_SHORT_STRUCT.unpack(response.parameters)[0] return vin_mv / 1000
[ "def", "vin_read", "(", "self", ",", "servo_id", ":", "int", ")", "->", "float", ":", "response", "=", "self", ".", "_send_and_receive_packet", "(", "servo_id", ",", "_SERVO_VIN_READ", ")", "vin_mv", "=", "_1_SIGNED_SHORT_STRUCT", ".", "unpack", "(", "response...
[ 552, 4 ]
[ 559, 28 ]
python
en
['en', 'en', 'en']
True
Xarm.pos_read
(self, servo_id: int)
Gets the servo angle, in degrees. May be negative.
Gets the servo angle, in degrees. May be negative.
def pos_read(self, servo_id: int) -> float: """Gets the servo angle, in degrees. May be negative.""" response = self._send_and_receive_packet(servo_id, _SERVO_POS_READ) angle = _1_SIGNED_SHORT_STRUCT.unpack(response.parameters)[0] return _ticks_to_degrees(angle)
[ "def", "pos_read", "(", "self", ",", "servo_id", ":", "int", ")", "->", "float", ":", "response", "=", "self", ".", "_send_and_receive_packet", "(", "servo_id", ",", "_SERVO_POS_READ", ")", "angle", "=", "_1_SIGNED_SHORT_STRUCT", ".", "unpack", "(", "response"...
[ 561, 4 ]
[ 568, 39 ]
python
en
['en', 'en', 'en']
True
Xarm.mode_write
(self, servo_id: int, mode: Literal['motor', 'servo'], speed: Real = None)
Sets the servo mode to either 'motor' -- where it rotates continuously at a certain speed -- or 'servo' -- where it holds to a specific position. :param servo_id: :param mode: Either 'motor' or 'servo'. If 'motor', then speed must be specified. :param speed: In the range [-1000...
Sets the servo mode to either 'motor' -- where it rotates continuously at a certain speed -- or 'servo' -- where it holds to a specific position.
def mode_write(self, servo_id: int, mode: Literal['motor', 'servo'], speed: Real = None) -> None: """ Sets the servo mode to either 'motor' -- where it rotates continuously at a certain speed -- or 'servo' -- where it holds to a specific position. :param servo_id: :param mode: E...
[ "def", "mode_write", "(", "self", ",", "servo_id", ":", "int", ",", "mode", ":", "Literal", "[", "'motor'", ",", "'servo'", "]", ",", "speed", ":", "Real", "=", "None", ")", "->", "None", ":", "if", "mode", ".", "lower", "(", ")", "not", "in", "{...
[ 570, 4 ]
[ 594, 71 ]
python
en
['en', 'error', 'th']
False
Xarm.mode_read
(self, servo_id: int)
Gets the mode the servo is currently set to, based on the last call to mode_write(). :param servo_id: :return: A tuple of ('motor' or 'servo', speed or None).
Gets the mode the servo is currently set to, based on the last call to mode_write().
def mode_read(self, servo_id: int) -> Tuple[str, Optional[int]]: """ Gets the mode the servo is currently set to, based on the last call to mode_write(). :param servo_id: :return: A tuple of ('motor' or 'servo', speed or None). """ response = self._send_and_receive_pack...
[ "def", "mode_read", "(", "self", ",", "servo_id", ":", "int", ")", "->", "Tuple", "[", "str", ",", "Optional", "[", "int", "]", "]", ":", "response", "=", "self", ".", "_send_and_receive_packet", "(", "servo_id", ",", "_SERVO_OR_MOTOR_MODE_READ", ")", "mod...
[ 596, 4 ]
[ 617, 26 ]
python
en
['en', 'error', 'th']
False
Xarm.set_powered
(self, servo_id: int, powered: bool)
Sets whether or not the servo is powered and attempting to hold its position.
Sets whether or not the servo is powered and attempting to hold its position.
def set_powered(self, servo_id: int, powered: bool) -> None: """Sets whether or not the servo is powered and attempting to hold its position.""" self._send_packet(servo_id, _SERVO_LOAD_OR_UNLOAD_WRITE, b'\x01' if powered else b'\x00')
[ "def", "set_powered", "(", "self", ",", "servo_id", ":", "int", ",", "powered", ":", "bool", ")", "->", "None", ":", "self", ".", "_send_packet", "(", "servo_id", ",", "_SERVO_LOAD_OR_UNLOAD_WRITE", ",", "b'\\x01'", "if", "powered", "else", "b'\\x00'", ")" ]
[ 619, 4 ]
[ 622, 97 ]
python
en
['en', 'en', 'en']
True
Xarm.is_powered
(self, servo_id: int)
Gets whether or not the servo is powered and attempting to hold its position.
Gets whether or not the servo is powered and attempting to hold its position.
def is_powered(self, servo_id: int) -> bool: """Gets whether or not the servo is powered and attempting to hold its position.""" response = self._send_and_receive_packet(servo_id, _SERVO_LOAD_OR_UNLOAD_READ) return bool(response.parameters[0])
[ "def", "is_powered", "(", "self", ",", "servo_id", ":", "int", ")", "->", "bool", ":", "response", "=", "self", ".", "_send_and_receive_packet", "(", "servo_id", ",", "_SERVO_LOAD_OR_UNLOAD_READ", ")", "return", "bool", "(", "response", ".", "parameters", "[",...
[ 624, 4 ]
[ 628, 43 ]
python
en
['en', 'en', 'en']
True
Xarm.led_ctrl_write
(self, servo_id: int, state: bool)
Sets whether or not the LED should be on when there are no errors. :param servo_id: :param state: Whether or not the LED should be on when there are no errors.
Sets whether or not the LED should be on when there are no errors.
def led_ctrl_write(self, servo_id: int, state: bool) -> None: """ Sets whether or not the LED should be on when there are no errors. :param servo_id: :param state: Whether or not the LED should be on when there are no errors. """ self._send_packet(servo_id, _SERVO_LED_C...
[ "def", "led_ctrl_write", "(", "self", ",", "servo_id", ":", "int", ",", "state", ":", "bool", ")", "->", "None", ":", "self", ".", "_send_packet", "(", "servo_id", ",", "_SERVO_LED_CTRL_WRITE", ",", "b'\\x00'", "if", "state", "else", "b'\\x01'", ")" ]
[ 630, 4 ]
[ 638, 89 ]
python
en
['en', 'error', 'th']
False
Xarm.led_ctrl_read
(self, servo_id: int)
Gets whether or not the LED is on when there are no errors. :param servo_id: :return: Whether or not the LED is on when there are no errors.
Gets whether or not the LED is on when there are no errors.
def led_ctrl_read(self, servo_id: int) -> bool: """ Gets whether or not the LED is on when there are no errors. :param servo_id: :return: Whether or not the LED is on when there are no errors. """ response = self._send_and_receive_packet(servo_id, _SERVO_LED_CTRL_READ) ...
[ "def", "led_ctrl_read", "(", "self", ",", "servo_id", ":", "int", ")", "->", "bool", ":", "response", "=", "self", ".", "_send_and_receive_packet", "(", "servo_id", ",", "_SERVO_LED_CTRL_READ", ")", "return", "response", ".", "parameters", "==", "b'\\x00'" ]
[ 640, 4 ]
[ 649, 45 ]
python
en
['en', 'error', 'th']
False
Xarm.led_error_write
(self, servo_id: int, stalled: bool, over_voltage: bool, over_temp: bool)
Sets which error conditions will cause the LED to indicate an error has occurred. :param servo_id: :param stalled: :param over_voltage: :param over_temp:
Sets which error conditions will cause the LED to indicate an error has occurred.
def led_error_write(self, servo_id: int, stalled: bool, over_voltage: bool, over_temp: bool) -> None: """ Sets which error conditions will cause the LED to indicate an error has occurred. :param servo_id: :param stalled: :param over_voltage: :param over_temp: """...
[ "def", "led_error_write", "(", "self", ",", "servo_id", ":", "int", ",", "stalled", ":", "bool", ",", "over_voltage", ":", "bool", ",", "over_temp", ":", "bool", ")", "->", "None", ":", "params", "=", "(", "stalled", "<<", "2", ")", "|", "(", "over_v...
[ 651, 4 ]
[ 663, 67 ]
python
en
['en', 'error', 'th']
False
Xarm.led_error_read
(self, servo_id: int)
Returns which error conditions will cause the LED to indicate an error has occurred. Note: This is NOT the error condition that the servo is currently experiencing. There appears to be no way to get that information. :param servo_id: :return: A tuple of booleans (stalled, over...
Returns which error conditions will cause the LED to indicate an error has occurred.
def led_error_read(self, servo_id: int) -> Tuple[bool, bool, bool]: """ Returns which error conditions will cause the LED to indicate an error has occurred. Note: This is NOT the error condition that the servo is currently experiencing. There appears to be no way to get that information...
[ "def", "led_error_read", "(", "self", ",", "servo_id", ":", "int", ")", "->", "Tuple", "[", "bool", ",", "bool", ",", "bool", "]", ":", "result", "=", "self", ".", "_send_and_receive_packet", "(", "servo_id", ",", "_SERVO_LED_ERROR_READ", ")", "params", "=...
[ 665, 4 ]
[ 683, 47 ]
python
en
['en', 'error', 'th']
False
DmlabEnv.step
(self, actions)
Action is either a single value (discrete, one-hot), or a tuple with an action for each of the discrete action subspaces.
Action is either a single value (discrete, one-hot), or a tuple with an action for each of the discrete action subspaces.
def step(self, actions): """ Action is either a single value (discrete, one-hot), or a tuple with an action for each of the discrete action subspaces. """ action = actions.item() obs, rew, done, info = self.env.step(action) # print('Obs shape as returned by the en...
[ "def", "step", "(", "self", ",", "actions", ")", ":", "action", "=", "actions", ".", "item", "(", ")", "obs", ",", "rew", ",", "done", ",", "info", "=", "self", ".", "env", ".", "step", "(", "action", ")", "# print('Obs shape as returned by the env:', ob...
[ 83, 4 ]
[ 92, 49 ]
python
en
['en', 'error', 'th']
False
Date.__init__
(self, date)
@param date: The value of the object. @type date: (date|str) @raise ValueError: When I{date} is invalid.
def __init__(self, date): """ @param date: The value of the object. @type date: (date|str) @raise ValueError: When I{date} is invalid. """ if isinstance(date, dt.date): self.date = date return if isinstance(date, basestring): se...
[ "def", "__init__", "(", "self", ",", "date", ")", ":", "if", "isinstance", "(", "date", ",", "dt", ".", "date", ")", ":", "self", ".", "date", "=", "date", "return", "if", "isinstance", "(", "date", ",", "basestring", ")", ":", "self", ".", "date",...
[ 42, 4 ]
[ 54, 36 ]
python
en
['en', 'error', 'th']
False
Date.year
(self)
Get the I{year} component. @return: The year. @rtype: int
Get the I{year} component.
def year(self): """ Get the I{year} component. @return: The year. @rtype: int """ return self.date.year
[ "def", "year", "(", "self", ")", ":", "return", "self", ".", "date", ".", "year" ]
[ 56, 4 ]
[ 62, 29 ]
python
en
['en', 'error', 'th']
False
Date.month
(self)
Get the I{month} component. @return: The month. @rtype: int
Get the I{month} component.
def month(self): """ Get the I{month} component. @return: The month. @rtype: int """ return self.date.month
[ "def", "month", "(", "self", ")", ":", "return", "self", ".", "date", ".", "month" ]
[ 64, 4 ]
[ 70, 30 ]
python
en
['en', 'error', 'th']
False
Date.day
(self)
Get the I{day} component. @return: The day. @rtype: int
Get the I{day} component.
def day(self): """ Get the I{day} component. @return: The day. @rtype: int """ return self.date.day
[ "def", "day", "(", "self", ")", ":", "return", "self", ".", "date", ".", "day" ]
[ 72, 4 ]
[ 78, 28 ]
python
en
['en', 'error', 'th']
False
Date.__parse
(self, s)
Parse the string date. Supported formats: - YYYY-MM-DD - YYYY-MM-DD(z|Z) - YYYY-MM-DD+06:00 - YYYY-MM-DD-06:00 Although, the TZ is ignored because it's meaningless without the time, right? @param s: A date string. @type s: ...
Parse the string date. Supported formats: - YYYY-MM-DD - YYYY-MM-DD(z|Z) - YYYY-MM-DD+06:00 - YYYY-MM-DD-06:00 Although, the TZ is ignored because it's meaningless without the time, right?
def __parse(self, s): """ Parse the string date. Supported formats: - YYYY-MM-DD - YYYY-MM-DD(z|Z) - YYYY-MM-DD+06:00 - YYYY-MM-DD-06:00 Although, the TZ is ignored because it's meaningless without the time, right? @param s:...
[ "def", "__parse", "(", "self", ",", "s", ")", ":", "try", ":", "year", ",", "month", ",", "day", "=", "s", "[", ":", "10", "]", ".", "split", "(", "'-'", ",", "2", ")", "year", "=", "int", "(", "year", ")", "month", "=", "int", "(", "month"...
[ 80, 4 ]
[ 103, 55 ]
python
en
['en', 'error', 'th']
False
Time.__init__
(self, time, adjusted=True)
@param time: The value of the object. @type time: (time|str) @param adjusted: Adjust for I{local} Timezone. @type adjusted: boolean @raise ValueError: When I{time} is invalid.
def __init__(self, time, adjusted=True): """ @param time: The value of the object. @type time: (time|str) @param adjusted: Adjust for I{local} Timezone. @type adjusted: boolean @raise ValueError: When I{time} is invalid. """ self.tz = Timezone() if...
[ "def", "__init__", "(", "self", ",", "time", ",", "adjusted", "=", "True", ")", ":", "self", ".", "tz", "=", "Timezone", "(", ")", "if", "isinstance", "(", "time", ",", "dt", ".", "time", ")", ":", "self", ".", "time", "=", "time", "return", "if"...
[ 128, 4 ]
[ 145, 36 ]
python
en
['en', 'error', 'th']
False
Time.hour
(self)
Get the I{hour} component. @return: The hour. @rtype: int
Get the I{hour} component.
def hour(self): """ Get the I{hour} component. @return: The hour. @rtype: int """ return self.time.hour
[ "def", "hour", "(", "self", ")", ":", "return", "self", ".", "time", ".", "hour" ]
[ 147, 4 ]
[ 153, 29 ]
python
en
['en', 'error', 'th']
False
Time.minute
(self)
Get the I{minute} component. @return: The minute. @rtype: int
Get the I{minute} component.
def minute(self): """ Get the I{minute} component. @return: The minute. @rtype: int """ return self.time.minute
[ "def", "minute", "(", "self", ")", ":", "return", "self", ".", "time", ".", "minute" ]
[ 155, 4 ]
[ 161, 31 ]
python
en
['en', 'error', 'th']
False
Time.second
(self)
Get the I{seconds} component. @return: The seconds. @rtype: int
Get the I{seconds} component.
def second(self): """ Get the I{seconds} component. @return: The seconds. @rtype: int """ return self.time.second
[ "def", "second", "(", "self", ")", ":", "return", "self", ".", "time", ".", "second" ]
[ 163, 4 ]
[ 169, 31 ]
python
en
['en', 'error', 'th']
False
Time.microsecond
(self)
Get the I{microsecond} component. @return: The microsecond. @rtype: int
Get the I{microsecond} component.
def microsecond(self): """ Get the I{microsecond} component. @return: The microsecond. @rtype: int """ return self.time.microsecond
[ "def", "microsecond", "(", "self", ")", ":", "return", "self", ".", "time", ".", "microsecond" ]
[ 171, 4 ]
[ 177, 36 ]
python
en
['en', 'error', 'th']
False
Time.__adjust
(self)
Adjust for TZ offset.
Adjust for TZ offset.
def __adjust(self): """ Adjust for TZ offset. """ if hasattr(self, 'offset'): today = dt.date.today() delta = self.tz.adjustment(self.offset) d = dt.datetime.combine(today, self.time) d = ( d + delta ) self.time = d.time()
[ "def", "__adjust", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "'offset'", ")", ":", "today", "=", "dt", ".", "date", ".", "today", "(", ")", "delta", "=", "self", ".", "tz", ".", "adjustment", "(", "self", ".", "offset", ")", "d", ...
[ 179, 4 ]
[ 188, 32 ]
python
en
['en', 'error', 'th']
False
Time.__parse
(self, s)
Parse the string date. Patterns: - HH:MI:SS - HH:MI:SS(z|Z) - HH:MI:SS.ms - HH:MI:SS.ms(z|Z) - HH:MI:SS(+|-)06:00 - HH:MI:SS.ms(+|-)06:00 @param s: A time string. @type s: str @return: A time object. ...
Parse the string date. Patterns: - HH:MI:SS - HH:MI:SS(z|Z) - HH:MI:SS.ms - HH:MI:SS.ms(z|Z) - HH:MI:SS(+|-)06:00 - HH:MI:SS.ms(+|-)06:00
def __parse(self, s): """ Parse the string date. Patterns: - HH:MI:SS - HH:MI:SS(z|Z) - HH:MI:SS.ms - HH:MI:SS.ms(z|Z) - HH:MI:SS(+|-)06:00 - HH:MI:SS.ms(+|-)06:00 @param s: A time string. @type s: str ...
[ "def", "__parse", "(", "self", ",", "s", ")", ":", "try", ":", "offset", "=", "None", "part", "=", "Timezone", ".", "split", "(", "s", ")", "hour", ",", "minute", ",", "second", "=", "part", "[", "0", "]", ".", "split", "(", "':'", ",", "2", ...
[ 190, 4 ]
[ 220, 55 ]
python
en
['en', 'error', 'th']
False
Time.__second
(self, s)
Parse the seconds and microseconds. The microseconds are truncated to 999999 due to a restriction in the python datetime.datetime object. @param s: A string representation of the seconds. @type s: str @return: Tuple of (sec,ms) @rtype: tuple.
Parse the seconds and microseconds. The microseconds are truncated to 999999 due to a restriction in the python datetime.datetime object.
def __second(self, s): """ Parse the seconds and microseconds. The microseconds are truncated to 999999 due to a restriction in the python datetime.datetime object. @param s: A string representation of the seconds. @type s: str @return: Tuple of (sec,ms) @...
[ "def", "__second", "(", "self", ",", "s", ")", ":", "part", "=", "s", ".", "split", "(", "'.'", ")", "if", "len", "(", "part", ")", ">", "1", ":", "return", "(", "int", "(", "part", "[", "0", "]", ")", ",", "int", "(", "part", "[", "1", "...
[ 222, 4 ]
[ 236, 39 ]
python
en
['en', 'error', 'th']
False
Time.__offset
(self, s)
Parse the TZ offset. @param s: A string representation of the TZ offset. @type s: str @return: The signed offset in hours. @rtype: str
Parse the TZ offset.
def __offset(self, s): """ Parse the TZ offset. @param s: A string representation of the TZ offset. @type s: str @return: The signed offset in hours. @rtype: str """ if len(s) == len('-00:00'): return int(s[:3]) if len(s) == 0: ...
[ "def", "__offset", "(", "self", ",", "s", ")", ":", "if", "len", "(", "s", ")", "==", "len", "(", "'-00:00'", ")", ":", "return", "int", "(", "s", "[", ":", "3", "]", ")", "if", "len", "(", "s", ")", "==", "0", ":", "return", "self", ".", ...
[ 238, 4 ]
[ 252, 25 ]
python
en
['en', 'error', 'th']
False
DateTime.__init__
(self, date)
@param date: The value of the object. @type date: (datetime|str) @raise ValueError: When I{tm} is invalid.
def __init__(self, date): """ @param date: The value of the object. @type date: (datetime|str) @raise ValueError: When I{tm} is invalid. """ if isinstance(date, dt.datetime): Date.__init__(self, date.date()) Time.__init__(self, date.time()) ...
[ "def", "__init__", "(", "self", ",", "date", ")", ":", "if", "isinstance", "(", "date", ",", "dt", ".", "datetime", ")", ":", "Date", ".", "__init__", "(", "self", ",", "date", ".", "date", "(", ")", ")", "Time", ".", "__init__", "(", "self", ","...
[ 278, 4 ]
[ 298, 36 ]
python
en
['en', 'error', 'th']
False
DateTime.__adjust
(self)
Adjust for TZ offset.
Adjust for TZ offset.
def __adjust(self): """ Adjust for TZ offset. """ if not hasattr(self, 'offset'): return delta = self.tz.adjustment(self.offset) try: d = ( self.datetime + delta ) self.datetime = d self.date = d.date() self.time...
[ "def", "__adjust", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'offset'", ")", ":", "return", "delta", "=", "self", ".", "tz", ".", "adjustment", "(", "self", ".", "offset", ")", "try", ":", "d", "=", "(", "self", ".", "date...
[ 300, 4 ]
[ 313, 73 ]
python
en
['en', 'error', 'th']
False
Timezone.split
(cls, s)
Split the TZ from string. @param s: A string containing a timezone @type s: basestring @return: The split parts. @rtype: tuple
Split the TZ from string.
def split(cls, s): """ Split the TZ from string. @param s: A string containing a timezone @type s: basestring @return: The split parts. @rtype: tuple """ m = cls.pattern.search(s) if m is None: return (s,) x = m.start(0) ...
[ "def", "split", "(", "cls", ",", "s", ")", ":", "m", "=", "cls", ".", "pattern", ".", "search", "(", "s", ")", "if", "m", "is", "None", ":", "return", "(", "s", ",", ")", "x", "=", "m", ".", "start", "(", "0", ")", "return", "(", "s", "["...
[ 356, 4 ]
[ 368, 29 ]
python
en
['en', 'error', 'th']
False
Timezone.adjustment
(self, offset)
Get the adjustment to the I{local} TZ. @return: The delta between I{offset} and local TZ. @rtype: B{datetime}.I{timedelta}
Get the adjustment to the I{local} TZ.
def adjustment(self, offset): """ Get the adjustment to the I{local} TZ. @return: The delta between I{offset} and local TZ. @rtype: B{datetime}.I{timedelta} """ delta = ( self.local - offset ) return dt.timedelta(hours=delta)
[ "def", "adjustment", "(", "self", ",", "offset", ")", ":", "delta", "=", "(", "self", ".", "local", "-", "offset", ")", "return", "dt", ".", "timedelta", "(", "hours", "=", "delta", ")" ]
[ 370, 4 ]
[ 377, 40 ]
python
en
['en', 'error', 'th']
False
servers_update_addresses
(request, servers, all_tenants=False)
Retrieve servers networking information from Neutron if enabled. Should be used when up to date networking information is required, and Nova's networking info caching mechanism is not fast enough.
Retrieve servers networking information from Neutron if enabled.
def servers_update_addresses(request, servers, all_tenants=False): """Retrieve servers networking information from Neutron if enabled. Should be used when up to date networking information is required, and Nova's networking info caching mechanism is not fast enough. """ # NOTE(amotoki): This...
[ "def", "servers_update_addresses", "(", "request", ",", "servers", ",", "all_tenants", "=", "False", ")", ":", "# NOTE(amotoki): This check is still needed because 'instances' panel", "# calls this method. We dropped security group and floating IP support", "# through Nova API (due to no...
[ 25, 0 ]
[ 42, 71 ]
python
en
['en', 'en', 'en']
True
ServiceProxy.__init__
(self, url, **kwargs)
@param url: The URL for the WSDL. @type url: str @param kwargs: keyword arguments. @keyword faults: Raise faults raised by server (default:True), else return tuple from service method invocation as (http code, object). @type faults: boolean @keyword proxy...
def __init__(self, url, **kwargs): """ @param url: The URL for the WSDL. @type url: str @param kwargs: keyword arguments. @keyword faults: Raise faults raised by server (default:True), else return tuple from service method invocation as (http code, object). ...
[ "def", "__init__", "(", "self", ",", "url", ",", "*", "*", "kwargs", ")", ":", "client", "=", "Client", "(", "url", ",", "*", "*", "kwargs", ")", "self", ".", "__client__", "=", "client" ]
[ 39, 4 ]
[ 52, 32 ]
python
en
['en', 'error', 'th']
False
ServiceProxy.get_instance
(self, name)
Get an instance of a WSDL type by name @param name: The name of a type defined in the WSDL. @type name: str @return: An instance on success, else None @rtype: L{sudsobject.Object}
Get an instance of a WSDL type by name
def get_instance(self, name): """ Get an instance of a WSDL type by name @param name: The name of a type defined in the WSDL. @type name: str @return: An instance on success, else None @rtype: L{sudsobject.Object} """ return self.__client__.factory.create(...
[ "def", "get_instance", "(", "self", ",", "name", ")", ":", "return", "self", ".", "__client__", ".", "factory", ".", "create", "(", "name", ")" ]
[ 54, 4 ]
[ 62, 51 ]
python
en
['en', 'error', 'th']
False
ServiceProxy.get_enum
(self, name)
Get an instance of an enumeration defined in the WSDL by name. @param name: The name of a enumeration defined in the WSDL. @type name: str @return: An instance on success, else None @rtype: L{sudsobject.Object}
Get an instance of an enumeration defined in the WSDL by name.
def get_enum(self, name): """ Get an instance of an enumeration defined in the WSDL by name. @param name: The name of a enumeration defined in the WSDL. @type name: str @return: An instance on success, else None @rtype: L{sudsobject.Object} """ return self...
[ "def", "get_enum", "(", "self", ",", "name", ")", ":", "return", "self", ".", "__client__", ".", "factory", ".", "create", "(", "name", ")" ]
[ 64, 4 ]
[ 72, 51 ]
python
en
['en', 'error', 'th']
False
dictfetchall
(cursor: connection.cursor)
Returns all rows from a cursor as a dict
Returns all rows from a cursor as a dict
def dictfetchall(cursor: connection.cursor) -> List[Dict[str, Any]]: "Returns all rows from a cursor as a dict" desc = cursor.description return [dict(zip((col[0] for col in desc), row)) for row in cursor.fetchall()]
[ "def", "dictfetchall", "(", "cursor", ":", "connection", ".", "cursor", ")", "->", "List", "[", "Dict", "[", "str", ",", "Any", "]", "]", ":", "desc", "=", "cursor", ".", "description", "return", "[", "dict", "(", "zip", "(", "(", "col", "[", "0", ...
[ 576, 0 ]
[ 579, 82 ]
python
en
['en', 'en', 'en']
True
RunnerManager._before_create_runner
(self, *args, **kwargs)
Точка расширения поведения менеджера ранера перед созданием ранера
Точка расширения поведения менеджера ранера перед созданием ранера
def _before_create_runner(self, *args, **kwargs): """ Точка расширения поведения менеджера ранера перед созданием ранера """
[ "def", "_before_create_runner", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":" ]
[ 33, 4 ]
[ 36, 11 ]
python
en
['en', 'error', 'th']
False