id
int32
0
252k
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
235,800
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
235,801
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
235,802
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
235,803
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
235,804
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
235,805
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
235,806
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
235,807
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
235,808
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
235,809
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
235,810
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
235,811
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
235,812
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
235,813
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
235,814
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
235,815
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
235,816
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
235,817
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
235,818
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
235,819
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
235,820
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
235,821
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
235,822
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
235,823
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
235,824
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
235,825
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
235,826
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
235,827
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
235,828
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
235,829
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
235,830
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
235,831
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
235,832
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
235,833
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
235,834
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
235,835
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
235,836
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
235,837
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
235,838
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
235,839
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
235,840
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
235,841
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
235,842
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
235,843
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
235,844
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
235,845
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
235,846
ihabunek/toot
toot/wcstring.py
pad
def pad(text, length): """Pads text to given length, taking into account wide characters.""" text_length = wcswidth(text) if text_length < length: return text + ' ' * (length - text_length) return text
python
def pad(text, length): """Pads text to given length, taking into account wide characters.""" text_length = wcswidth(text) if text_length < length: return text + ' ' * (length - text_length) return text
[ "def", "pad", "(", "text", ",", "length", ")", ":", "text_length", "=", "wcswidth", "(", "text", ")", "if", "text_length", "<", "length", ":", "return", "text", "+", "' '", "*", "(", "length", "-", "text_length", ")", "return", "text" ]
Pads text to given length, taking into account wide characters.
[ "Pads", "text", "to", "given", "length", "taking", "into", "account", "wide", "characters", "." ]
d13fa8685b300f96621fa325774913ec0f413a7f
https://github.com/ihabunek/toot/blob/d13fa8685b300f96621fa325774913ec0f413a7f/toot/wcstring.py#L101-L108
235,847
ihabunek/toot
toot/wcstring.py
fit_text
def fit_text(text, length): """Makes text fit the given length by padding or truncating it.""" text_length = wcswidth(text) if text_length > length: return trunc(text, length) if text_length < length: return pad(text, length) return text
python
def fit_text(text, length): """Makes text fit the given length by padding or truncating it.""" text_length = wcswidth(text) if text_length > length: return trunc(text, length) if text_length < length: return pad(text, length) return text
[ "def", "fit_text", "(", "text", ",", "length", ")", ":", "text_length", "=", "wcswidth", "(", "text", ")", "if", "text_length", ">", "length", ":", "return", "trunc", "(", "text", ",", "length", ")", "if", "text_length", "<", "length", ":", "return", "...
Makes text fit the given length by padding or truncating it.
[ "Makes", "text", "fit", "the", "given", "length", "by", "padding", "or", "truncating", "it", "." ]
d13fa8685b300f96621fa325774913ec0f413a7f
https://github.com/ihabunek/toot/blob/d13fa8685b300f96621fa325774913ec0f413a7f/toot/wcstring.py#L111-L121
235,848
ihabunek/toot
toot/http.py
_get_error_message
def _get_error_message(response): """Attempt to extract an error message from response body""" try: data = response.json() if "error_description" in data: return data['error_description'] if "error" in data: return data['error'] except Exception: pass ...
python
def _get_error_message(response): """Attempt to extract an error message from response body""" try: data = response.json() if "error_description" in data: return data['error_description'] if "error" in data: return data['error'] except Exception: pass ...
[ "def", "_get_error_message", "(", "response", ")", ":", "try", ":", "data", "=", "response", ".", "json", "(", ")", "if", "\"error_description\"", "in", "data", ":", "return", "data", "[", "'error_description'", "]", "if", "\"error\"", "in", "data", ":", "...
Attempt to extract an error message from response body
[ "Attempt", "to", "extract", "an", "error", "message", "from", "response", "body" ]
d13fa8685b300f96621fa325774913ec0f413a7f
https://github.com/ihabunek/toot/blob/d13fa8685b300f96621fa325774913ec0f413a7f/toot/http.py#L19-L30
235,849
ihabunek/toot
toot/api.py
_get_next_path
def _get_next_path(headers): """Given timeline response headers, returns the path to the next batch""" links = headers.get('Link', '') matches = re.match('<([^>]+)>; rel="next"', links) if matches: parsed = urlparse(matches.group(1)) return "?".join([parsed.path, parsed.query])
python
def _get_next_path(headers): """Given timeline response headers, returns the path to the next batch""" links = headers.get('Link', '') matches = re.match('<([^>]+)>; rel="next"', links) if matches: parsed = urlparse(matches.group(1)) return "?".join([parsed.path, parsed.query])
[ "def", "_get_next_path", "(", "headers", ")", ":", "links", "=", "headers", ".", "get", "(", "'Link'", ",", "''", ")", "matches", "=", "re", ".", "match", "(", "'<([^>]+)>; rel=\"next\"'", ",", "links", ")", "if", "matches", ":", "parsed", "=", "urlparse...
Given timeline response headers, returns the path to the next batch
[ "Given", "timeline", "response", "headers", "returns", "the", "path", "to", "the", "next", "batch" ]
d13fa8685b300f96621fa325774913ec0f413a7f
https://github.com/ihabunek/toot/blob/d13fa8685b300f96621fa325774913ec0f413a7f/toot/api.py#L160-L166
235,850
ihabunek/toot
toot/ui/app.py
TimelineApp.select_previous
def select_previous(self): """Move to the previous status in the timeline.""" self.footer.clear_message() if self.selected == 0: self.footer.draw_message("Cannot move beyond first toot.", Color.GREEN) return old_index = self.selected new_index = self.sel...
python
def select_previous(self): """Move to the previous status in the timeline.""" self.footer.clear_message() if self.selected == 0: self.footer.draw_message("Cannot move beyond first toot.", Color.GREEN) return old_index = self.selected new_index = self.sel...
[ "def", "select_previous", "(", "self", ")", ":", "self", ".", "footer", ".", "clear_message", "(", ")", "if", "self", ".", "selected", "==", "0", ":", "self", ".", "footer", ".", "draw_message", "(", "\"Cannot move beyond first toot.\"", ",", "Color", ".", ...
Move to the previous status in the timeline.
[ "Move", "to", "the", "previous", "status", "in", "the", "timeline", "." ]
d13fa8685b300f96621fa325774913ec0f413a7f
https://github.com/ihabunek/toot/blob/d13fa8685b300f96621fa325774913ec0f413a7f/toot/ui/app.py#L692-L704
235,851
ihabunek/toot
toot/ui/app.py
TimelineApp.select_next
def select_next(self): """Move to the next status in the timeline.""" self.footer.clear_message() old_index = self.selected new_index = self.selected + 1 # Load more statuses if no more are available if self.selected + 1 >= len(self.statuses): self.fetch_nex...
python
def select_next(self): """Move to the next status in the timeline.""" self.footer.clear_message() old_index = self.selected new_index = self.selected + 1 # Load more statuses if no more are available if self.selected + 1 >= len(self.statuses): self.fetch_nex...
[ "def", "select_next", "(", "self", ")", ":", "self", ".", "footer", ".", "clear_message", "(", ")", "old_index", "=", "self", ".", "selected", "new_index", "=", "self", ".", "selected", "+", "1", "# Load more statuses if no more are available", "if", "self", "...
Move to the next status in the timeline.
[ "Move", "to", "the", "next", "status", "in", "the", "timeline", "." ]
d13fa8685b300f96621fa325774913ec0f413a7f
https://github.com/ihabunek/toot/blob/d13fa8685b300f96621fa325774913ec0f413a7f/toot/ui/app.py#L706-L720
235,852
ihabunek/toot
toot/ui/app.py
TimelineApp.full_redraw
def full_redraw(self): """Perform a full redraw of the UI.""" self.left.draw_statuses(self.statuses, self.selected) self.right.draw(self.get_selected_status()) self.header.draw(self.user) self.draw_footer_status()
python
def full_redraw(self): """Perform a full redraw of the UI.""" self.left.draw_statuses(self.statuses, self.selected) self.right.draw(self.get_selected_status()) self.header.draw(self.user) self.draw_footer_status()
[ "def", "full_redraw", "(", "self", ")", ":", "self", ".", "left", ".", "draw_statuses", "(", "self", ".", "statuses", ",", "self", ".", "selected", ")", "self", ".", "right", ".", "draw", "(", "self", ".", "get_selected_status", "(", ")", ")", "self", ...
Perform a full redraw of the UI.
[ "Perform", "a", "full", "redraw", "of", "the", "UI", "." ]
d13fa8685b300f96621fa325774913ec0f413a7f
https://github.com/ihabunek/toot/blob/d13fa8685b300f96621fa325774913ec0f413a7f/toot/ui/app.py#L740-L746
235,853
ihabunek/toot
toot/ui/utils.py
size_as_drawn
def size_as_drawn(lines, screen_width): """Get the bottom-right corner of some text as would be drawn by draw_lines""" y = 0 x = 0 for line in lines: wrapped = list(wc_wrap(line, screen_width)) if len(wrapped) > 0: for wrapped_line in wrapped: x = len(wrapped_...
python
def size_as_drawn(lines, screen_width): """Get the bottom-right corner of some text as would be drawn by draw_lines""" y = 0 x = 0 for line in lines: wrapped = list(wc_wrap(line, screen_width)) if len(wrapped) > 0: for wrapped_line in wrapped: x = len(wrapped_...
[ "def", "size_as_drawn", "(", "lines", ",", "screen_width", ")", ":", "y", "=", "0", "x", "=", "0", "for", "line", "in", "lines", ":", "wrapped", "=", "list", "(", "wc_wrap", "(", "line", ",", "screen_width", ")", ")", "if", "len", "(", "wrapped", "...
Get the bottom-right corner of some text as would be drawn by draw_lines
[ "Get", "the", "bottom", "-", "right", "corner", "of", "some", "text", "as", "would", "be", "drawn", "by", "draw_lines" ]
d13fa8685b300f96621fa325774913ec0f413a7f
https://github.com/ihabunek/toot/blob/d13fa8685b300f96621fa325774913ec0f413a7f/toot/ui/utils.py#L49-L62
235,854
ihabunek/toot
toot/commands.py
_find_account
def _find_account(app, user, account_name): """For a given account name, returns the Account object. Raises an exception if not found. """ if not account_name: raise ConsoleError("Empty account name given") accounts = api.search_accounts(app, user, account_name) if account_name[0] == ...
python
def _find_account(app, user, account_name): """For a given account name, returns the Account object. Raises an exception if not found. """ if not account_name: raise ConsoleError("Empty account name given") accounts = api.search_accounts(app, user, account_name) if account_name[0] == ...
[ "def", "_find_account", "(", "app", ",", "user", ",", "account_name", ")", ":", "if", "not", "account_name", ":", "raise", "ConsoleError", "(", "\"Empty account name given\"", ")", "accounts", "=", "api", ".", "search_accounts", "(", "app", ",", "user", ",", ...
For a given account name, returns the Account object. Raises an exception if not found.
[ "For", "a", "given", "account", "name", "returns", "the", "Account", "object", "." ]
d13fa8685b300f96621fa325774913ec0f413a7f
https://github.com/ihabunek/toot/blob/d13fa8685b300f96621fa325774913ec0f413a7f/toot/commands.py#L216-L233
235,855
ihabunek/toot
toot/config_legacy.py
add_username
def add_username(user, apps): """When using broser login, username was not stored so look it up""" if not user: return None apps = [a for a in apps if a.instance == user.instance] if not apps: return None from toot.api import verify_credentials creds = verify_credentials(apps....
python
def add_username(user, apps): """When using broser login, username was not stored so look it up""" if not user: return None apps = [a for a in apps if a.instance == user.instance] if not apps: return None from toot.api import verify_credentials creds = verify_credentials(apps....
[ "def", "add_username", "(", "user", ",", "apps", ")", ":", "if", "not", "user", ":", "return", "None", "apps", "=", "[", "a", "for", "a", "in", "apps", "if", "a", ".", "instance", "==", "user", ".", "instance", "]", "if", "not", "apps", ":", "ret...
When using broser login, username was not stored so look it up
[ "When", "using", "broser", "login", "username", "was", "not", "stored", "so", "look", "it", "up" ]
d13fa8685b300f96621fa325774913ec0f413a7f
https://github.com/ihabunek/toot/blob/d13fa8685b300f96621fa325774913ec0f413a7f/toot/config_legacy.py#L42-L55
235,856
ihabunek/toot
toot/utils.py
get_text
def get_text(html): """Converts html to text, strips all tags.""" # Ignore warnings made by BeautifulSoup, if passed something that looks like # a file (e.g. a dot which matches current dict), it will warn that the file # should be opened instead of passing a filename. with warnings.catch_warnings(...
python
def get_text(html): """Converts html to text, strips all tags.""" # Ignore warnings made by BeautifulSoup, if passed something that looks like # a file (e.g. a dot which matches current dict), it will warn that the file # should be opened instead of passing a filename. with warnings.catch_warnings(...
[ "def", "get_text", "(", "html", ")", ":", "# Ignore warnings made by BeautifulSoup, if passed something that looks like", "# a file (e.g. a dot which matches current dict), it will warn that the file", "# should be opened instead of passing a filename.", "with", "warnings", ".", "catch_warni...
Converts html to text, strips all tags.
[ "Converts", "html", "to", "text", "strips", "all", "tags", "." ]
d13fa8685b300f96621fa325774913ec0f413a7f
https://github.com/ihabunek/toot/blob/d13fa8685b300f96621fa325774913ec0f413a7f/toot/utils.py#L19-L29
235,857
ihabunek/toot
toot/utils.py
parse_html
def parse_html(html): """Attempt to convert html to plain text while keeping line breaks. Returns a list of paragraphs, each being a list of lines. """ paragraphs = re.split("</?p[^>]*>", html) # Convert <br>s to line breaks and remove empty paragraphs paragraphs = [re.split("<br */?>", p) for ...
python
def parse_html(html): """Attempt to convert html to plain text while keeping line breaks. Returns a list of paragraphs, each being a list of lines. """ paragraphs = re.split("</?p[^>]*>", html) # Convert <br>s to line breaks and remove empty paragraphs paragraphs = [re.split("<br */?>", p) for ...
[ "def", "parse_html", "(", "html", ")", ":", "paragraphs", "=", "re", ".", "split", "(", "\"</?p[^>]*>\"", ",", "html", ")", "# Convert <br>s to line breaks and remove empty paragraphs", "paragraphs", "=", "[", "re", ".", "split", "(", "\"<br */?>\"", ",", "p", "...
Attempt to convert html to plain text while keeping line breaks. Returns a list of paragraphs, each being a list of lines.
[ "Attempt", "to", "convert", "html", "to", "plain", "text", "while", "keeping", "line", "breaks", ".", "Returns", "a", "list", "of", "paragraphs", "each", "being", "a", "list", "of", "lines", "." ]
d13fa8685b300f96621fa325774913ec0f413a7f
https://github.com/ihabunek/toot/blob/d13fa8685b300f96621fa325774913ec0f413a7f/toot/utils.py#L32-L42
235,858
ihabunek/toot
toot/utils.py
format_content
def format_content(content): """Given a Status contents in HTML, converts it into lines of plain text. Returns a generator yielding lines of content. """ paragraphs = parse_html(content) first = True for paragraph in paragraphs: if not first: yield "" for line in...
python
def format_content(content): """Given a Status contents in HTML, converts it into lines of plain text. Returns a generator yielding lines of content. """ paragraphs = parse_html(content) first = True for paragraph in paragraphs: if not first: yield "" for line in...
[ "def", "format_content", "(", "content", ")", ":", "paragraphs", "=", "parse_html", "(", "content", ")", "first", "=", "True", "for", "paragraph", "in", "paragraphs", ":", "if", "not", "first", ":", "yield", "\"\"", "for", "line", "in", "paragraph", ":", ...
Given a Status contents in HTML, converts it into lines of plain text. Returns a generator yielding lines of content.
[ "Given", "a", "Status", "contents", "in", "HTML", "converts", "it", "into", "lines", "of", "plain", "text", "." ]
d13fa8685b300f96621fa325774913ec0f413a7f
https://github.com/ihabunek/toot/blob/d13fa8685b300f96621fa325774913ec0f413a7f/toot/utils.py#L45-L62
235,859
ihabunek/toot
toot/utils.py
multiline_input
def multiline_input(): """Lets user input multiple lines of text, terminated by EOF.""" lines = [] while True: try: lines.append(input()) except EOFError: break return "\n".join(lines).strip()
python
def multiline_input(): """Lets user input multiple lines of text, terminated by EOF.""" lines = [] while True: try: lines.append(input()) except EOFError: break return "\n".join(lines).strip()
[ "def", "multiline_input", "(", ")", ":", "lines", "=", "[", "]", "while", "True", ":", "try", ":", "lines", ".", "append", "(", "input", "(", ")", ")", "except", "EOFError", ":", "break", "return", "\"\\n\"", ".", "join", "(", "lines", ")", ".", "s...
Lets user input multiple lines of text, terminated by EOF.
[ "Lets", "user", "input", "multiple", "lines", "of", "text", "terminated", "by", "EOF", "." ]
d13fa8685b300f96621fa325774913ec0f413a7f
https://github.com/ihabunek/toot/blob/d13fa8685b300f96621fa325774913ec0f413a7f/toot/utils.py#L81-L90
235,860
Azure/azure-kusto-python
azure-kusto-data/azure/kusto/data/_models.py
KustoResultTable.to_dict
def to_dict(self): """Converts the table to a dict.""" return {"name": self.table_name, "kind": self.table_kind, "data": [r.to_dict() for r in self]}
python
def to_dict(self): """Converts the table to a dict.""" return {"name": self.table_name, "kind": self.table_kind, "data": [r.to_dict() for r in self]}
[ "def", "to_dict", "(", "self", ")", ":", "return", "{", "\"name\"", ":", "self", ".", "table_name", ",", "\"kind\"", ":", "self", ".", "table_kind", ",", "\"data\"", ":", "[", "r", ".", "to_dict", "(", ")", "for", "r", "in", "self", "]", "}" ]
Converts the table to a dict.
[ "Converts", "the", "table", "to", "a", "dict", "." ]
92466a2ae175d6353d1dee3496a02517b2a71a86
https://github.com/Azure/azure-kusto-python/blob/92466a2ae175d6353d1dee3496a02517b2a71a86/azure-kusto-data/azure/kusto/data/_models.py#L152-L154
235,861
Azure/azure-kusto-python
azure-kusto-data/azure/kusto/data/_converters.py
to_datetime
def to_datetime(value): """Converts a string to a datetime.""" if value is None: return None if isinstance(value, six.integer_types): return parser.parse(value) return parser.isoparse(value)
python
def to_datetime(value): """Converts a string to a datetime.""" if value is None: return None if isinstance(value, six.integer_types): return parser.parse(value) return parser.isoparse(value)
[ "def", "to_datetime", "(", "value", ")", ":", "if", "value", "is", "None", ":", "return", "None", "if", "isinstance", "(", "value", ",", "six", ".", "integer_types", ")", ":", "return", "parser", ".", "parse", "(", "value", ")", "return", "parser", "."...
Converts a string to a datetime.
[ "Converts", "a", "string", "to", "a", "datetime", "." ]
92466a2ae175d6353d1dee3496a02517b2a71a86
https://github.com/Azure/azure-kusto-python/blob/92466a2ae175d6353d1dee3496a02517b2a71a86/azure-kusto-data/azure/kusto/data/_converters.py#L12-L19
235,862
Azure/azure-kusto-python
azure-kusto-data/azure/kusto/data/_converters.py
to_timedelta
def to_timedelta(value): """Converts a string to a timedelta.""" if value is None: return None if isinstance(value, (six.integer_types, float)): return timedelta(microseconds=(float(value) / 10)) match = _TIMESPAN_PATTERN.match(value) if match: if match.group(1) == "-": ...
python
def to_timedelta(value): """Converts a string to a timedelta.""" if value is None: return None if isinstance(value, (six.integer_types, float)): return timedelta(microseconds=(float(value) / 10)) match = _TIMESPAN_PATTERN.match(value) if match: if match.group(1) == "-": ...
[ "def", "to_timedelta", "(", "value", ")", ":", "if", "value", "is", "None", ":", "return", "None", "if", "isinstance", "(", "value", ",", "(", "six", ".", "integer_types", ",", "float", ")", ")", ":", "return", "timedelta", "(", "microseconds", "=", "(...
Converts a string to a timedelta.
[ "Converts", "a", "string", "to", "a", "timedelta", "." ]
92466a2ae175d6353d1dee3496a02517b2a71a86
https://github.com/Azure/azure-kusto-python/blob/92466a2ae175d6353d1dee3496a02517b2a71a86/azure-kusto-data/azure/kusto/data/_converters.py#L22-L41
235,863
Azure/azure-kusto-python
azure-kusto-data/azure/kusto/data/security.py
_AadHelper.acquire_authorization_header
def acquire_authorization_header(self): """Acquire tokens from AAD.""" try: return self._acquire_authorization_header() except AdalError as error: if self._authentication_method is AuthenticationMethod.aad_username_password: kwargs = {"username": self._use...
python
def acquire_authorization_header(self): """Acquire tokens from AAD.""" try: return self._acquire_authorization_header() except AdalError as error: if self._authentication_method is AuthenticationMethod.aad_username_password: kwargs = {"username": self._use...
[ "def", "acquire_authorization_header", "(", "self", ")", ":", "try", ":", "return", "self", ".", "_acquire_authorization_header", "(", ")", "except", "AdalError", "as", "error", ":", "if", "self", ".", "_authentication_method", "is", "AuthenticationMethod", ".", "...
Acquire tokens from AAD.
[ "Acquire", "tokens", "from", "AAD", "." ]
92466a2ae175d6353d1dee3496a02517b2a71a86
https://github.com/Azure/azure-kusto-python/blob/92466a2ae175d6353d1dee3496a02517b2a71a86/azure-kusto-data/azure/kusto/data/security.py#L49-L68
235,864
Azure/azure-kusto-python
azure-kusto-data/azure/kusto/data/request.py
KustoClient._execute
def _execute(self, endpoint, database, query, default_timeout, properties=None): """Executes given query against this client""" request_payload = {"db": database, "csl": query} if properties: request_payload["properties"] = properties.to_json() request_headers = { ...
python
def _execute(self, endpoint, database, query, default_timeout, properties=None): """Executes given query against this client""" request_payload = {"db": database, "csl": query} if properties: request_payload["properties"] = properties.to_json() request_headers = { ...
[ "def", "_execute", "(", "self", ",", "endpoint", ",", "database", ",", "query", ",", "default_timeout", ",", "properties", "=", "None", ")", ":", "request_payload", "=", "{", "\"db\"", ":", "database", ",", "\"csl\"", ":", "query", "}", "if", "properties",...
Executes given query against this client
[ "Executes", "given", "query", "against", "this", "client" ]
92466a2ae175d6353d1dee3496a02517b2a71a86
https://github.com/Azure/azure-kusto-python/blob/92466a2ae175d6353d1dee3496a02517b2a71a86/azure-kusto-data/azure/kusto/data/request.py#L360-L386
235,865
Azure/azure-kusto-python
azure-kusto-data/azure/kusto/data/request.py
ClientRequestProperties.set_option
def set_option(self, name, value): """Sets an option's value""" _assert_value_is_valid(name) self._options[name] = value
python
def set_option(self, name, value): """Sets an option's value""" _assert_value_is_valid(name) self._options[name] = value
[ "def", "set_option", "(", "self", ",", "name", ",", "value", ")", ":", "_assert_value_is_valid", "(", "name", ")", "self", ".", "_options", "[", "name", "]", "=", "value" ]
Sets an option's value
[ "Sets", "an", "option", "s", "value" ]
92466a2ae175d6353d1dee3496a02517b2a71a86
https://github.com/Azure/azure-kusto-python/blob/92466a2ae175d6353d1dee3496a02517b2a71a86/azure-kusto-data/azure/kusto/data/request.py#L467-L470
235,866
Azure/azure-kusto-python
azure-kusto-ingest/azure/kusto/ingest/_resource_manager.py
_ResourceUri.parse
def parse(cls, uri): """Parses uri into a ResourceUri object""" match = _URI_FORMAT.search(uri) return cls(match.group(1), match.group(2), match.group(3), match.group(4))
python
def parse(cls, uri): """Parses uri into a ResourceUri object""" match = _URI_FORMAT.search(uri) return cls(match.group(1), match.group(2), match.group(3), match.group(4))
[ "def", "parse", "(", "cls", ",", "uri", ")", ":", "match", "=", "_URI_FORMAT", ".", "search", "(", "uri", ")", "return", "cls", "(", "match", ".", "group", "(", "1", ")", ",", "match", ".", "group", "(", "2", ")", ",", "match", ".", "group", "(...
Parses uri into a ResourceUri object
[ "Parses", "uri", "into", "a", "ResourceUri", "object" ]
92466a2ae175d6353d1dee3496a02517b2a71a86
https://github.com/Azure/azure-kusto-python/blob/92466a2ae175d6353d1dee3496a02517b2a71a86/azure-kusto-ingest/azure/kusto/ingest/_resource_manager.py#L17-L20
235,867
Azure/azure-kusto-python
azure-kusto-ingest/azure/kusto/ingest/_ingestion_properties.py
IngestionProperties.get_mapping_format
def get_mapping_format(self): """Dictating the corresponding mapping to the format.""" if self.format == DataFormat.json or self.format == DataFormat.avro: return self.format.name else: return DataFormat.csv.name
python
def get_mapping_format(self): """Dictating the corresponding mapping to the format.""" if self.format == DataFormat.json or self.format == DataFormat.avro: return self.format.name else: return DataFormat.csv.name
[ "def", "get_mapping_format", "(", "self", ")", ":", "if", "self", ".", "format", "==", "DataFormat", ".", "json", "or", "self", ".", "format", "==", "DataFormat", ".", "avro", ":", "return", "self", ".", "format", ".", "name", "else", ":", "return", "D...
Dictating the corresponding mapping to the format.
[ "Dictating", "the", "corresponding", "mapping", "to", "the", "format", "." ]
92466a2ae175d6353d1dee3496a02517b2a71a86
https://github.com/Azure/azure-kusto-python/blob/92466a2ae175d6353d1dee3496a02517b2a71a86/azure-kusto-ingest/azure/kusto/ingest/_ingestion_properties.py#L125-L130
235,868
yuce/pyswip
pyswip/easy.py
getAtomChars
def getAtomChars(t): """If t is an atom, return it as a string, otherwise raise InvalidTypeError. """ s = c_char_p() if PL_get_atom_chars(t, byref(s)): return s.value else: raise InvalidTypeError("atom")
python
def getAtomChars(t): """If t is an atom, return it as a string, otherwise raise InvalidTypeError. """ s = c_char_p() if PL_get_atom_chars(t, byref(s)): return s.value else: raise InvalidTypeError("atom")
[ "def", "getAtomChars", "(", "t", ")", ":", "s", "=", "c_char_p", "(", ")", "if", "PL_get_atom_chars", "(", "t", ",", "byref", "(", "s", ")", ")", ":", "return", "s", ".", "value", "else", ":", "raise", "InvalidTypeError", "(", "\"atom\"", ")" ]
If t is an atom, return it as a string, otherwise raise InvalidTypeError.
[ "If", "t", "is", "an", "atom", "return", "it", "as", "a", "string", "otherwise", "raise", "InvalidTypeError", "." ]
f7c1f1e8c3a13b90bd775861d374788a8b5677d8
https://github.com/yuce/pyswip/blob/f7c1f1e8c3a13b90bd775861d374788a8b5677d8/pyswip/easy.py#L333-L340
235,869
yuce/pyswip
pyswip/easy.py
getBool
def getBool(t): """If t is of type bool, return it, otherwise raise InvalidTypeError. """ b = c_int() if PL_get_long(t, byref(b)): return bool(b.value) else: raise InvalidTypeError("bool")
python
def getBool(t): """If t is of type bool, return it, otherwise raise InvalidTypeError. """ b = c_int() if PL_get_long(t, byref(b)): return bool(b.value) else: raise InvalidTypeError("bool")
[ "def", "getBool", "(", "t", ")", ":", "b", "=", "c_int", "(", ")", "if", "PL_get_long", "(", "t", ",", "byref", "(", "b", ")", ")", ":", "return", "bool", "(", "b", ".", "value", ")", "else", ":", "raise", "InvalidTypeError", "(", "\"bool\"", ")"...
If t is of type bool, return it, otherwise raise InvalidTypeError.
[ "If", "t", "is", "of", "type", "bool", "return", "it", "otherwise", "raise", "InvalidTypeError", "." ]
f7c1f1e8c3a13b90bd775861d374788a8b5677d8
https://github.com/yuce/pyswip/blob/f7c1f1e8c3a13b90bd775861d374788a8b5677d8/pyswip/easy.py#L349-L356
235,870
yuce/pyswip
pyswip/easy.py
getLong
def getLong(t): """If t is of type long, return it, otherwise raise InvalidTypeError. """ i = c_long() if PL_get_long(t, byref(i)): return i.value else: raise InvalidTypeError("long")
python
def getLong(t): """If t is of type long, return it, otherwise raise InvalidTypeError. """ i = c_long() if PL_get_long(t, byref(i)): return i.value else: raise InvalidTypeError("long")
[ "def", "getLong", "(", "t", ")", ":", "i", "=", "c_long", "(", ")", "if", "PL_get_long", "(", "t", ",", "byref", "(", "i", ")", ")", ":", "return", "i", ".", "value", "else", ":", "raise", "InvalidTypeError", "(", "\"long\"", ")" ]
If t is of type long, return it, otherwise raise InvalidTypeError.
[ "If", "t", "is", "of", "type", "long", "return", "it", "otherwise", "raise", "InvalidTypeError", "." ]
f7c1f1e8c3a13b90bd775861d374788a8b5677d8
https://github.com/yuce/pyswip/blob/f7c1f1e8c3a13b90bd775861d374788a8b5677d8/pyswip/easy.py#L359-L366
235,871
yuce/pyswip
pyswip/easy.py
getFloat
def getFloat(t): """If t is of type float, return it, otherwise raise InvalidTypeError. """ d = c_double() if PL_get_float(t, byref(d)): return d.value else: raise InvalidTypeError("float")
python
def getFloat(t): """If t is of type float, return it, otherwise raise InvalidTypeError. """ d = c_double() if PL_get_float(t, byref(d)): return d.value else: raise InvalidTypeError("float")
[ "def", "getFloat", "(", "t", ")", ":", "d", "=", "c_double", "(", ")", "if", "PL_get_float", "(", "t", ",", "byref", "(", "d", ")", ")", ":", "return", "d", ".", "value", "else", ":", "raise", "InvalidTypeError", "(", "\"float\"", ")" ]
If t is of type float, return it, otherwise raise InvalidTypeError.
[ "If", "t", "is", "of", "type", "float", "return", "it", "otherwise", "raise", "InvalidTypeError", "." ]
f7c1f1e8c3a13b90bd775861d374788a8b5677d8
https://github.com/yuce/pyswip/blob/f7c1f1e8c3a13b90bd775861d374788a8b5677d8/pyswip/easy.py#L372-L379
235,872
yuce/pyswip
pyswip/easy.py
getString
def getString(t): """If t is of type string, return it, otherwise raise InvalidTypeError. """ slen = c_int() s = c_char_p() if PL_get_string_chars(t, byref(s), byref(slen)): return s.value else: raise InvalidTypeError("string")
python
def getString(t): """If t is of type string, return it, otherwise raise InvalidTypeError. """ slen = c_int() s = c_char_p() if PL_get_string_chars(t, byref(s), byref(slen)): return s.value else: raise InvalidTypeError("string")
[ "def", "getString", "(", "t", ")", ":", "slen", "=", "c_int", "(", ")", "s", "=", "c_char_p", "(", ")", "if", "PL_get_string_chars", "(", "t", ",", "byref", "(", "s", ")", ",", "byref", "(", "slen", ")", ")", ":", "return", "s", ".", "value", "...
If t is of type string, return it, otherwise raise InvalidTypeError.
[ "If", "t", "is", "of", "type", "string", "return", "it", "otherwise", "raise", "InvalidTypeError", "." ]
f7c1f1e8c3a13b90bd775861d374788a8b5677d8
https://github.com/yuce/pyswip/blob/f7c1f1e8c3a13b90bd775861d374788a8b5677d8/pyswip/easy.py#L382-L390
235,873
yuce/pyswip
pyswip/easy.py
getList
def getList(x): """ Return t as a list. """ t = PL_copy_term_ref(x) head = PL_new_term_ref() result = [] while PL_get_list(t, head, t): result.append(getTerm(head)) head = PL_new_term_ref() return result
python
def getList(x): """ Return t as a list. """ t = PL_copy_term_ref(x) head = PL_new_term_ref() result = [] while PL_get_list(t, head, t): result.append(getTerm(head)) head = PL_new_term_ref() return result
[ "def", "getList", "(", "x", ")", ":", "t", "=", "PL_copy_term_ref", "(", "x", ")", "head", "=", "PL_new_term_ref", "(", ")", "result", "=", "[", "]", "while", "PL_get_list", "(", "t", ",", "head", ",", "t", ")", ":", "result", ".", "append", "(", ...
Return t as a list.
[ "Return", "t", "as", "a", "list", "." ]
f7c1f1e8c3a13b90bd775861d374788a8b5677d8
https://github.com/yuce/pyswip/blob/f7c1f1e8c3a13b90bd775861d374788a8b5677d8/pyswip/easy.py#L411-L423
235,874
yuce/pyswip
pyswip/easy.py
Atom.fromTerm
def fromTerm(cls, term): """Create an atom from a Term or term handle.""" if isinstance(term, Term): term = term.handle elif not isinstance(term, (c_void_p, int)): raise ArgumentTypeError((str(Term), str(c_void_p)), str(type(term))) a = atom_t() if PL_ge...
python
def fromTerm(cls, term): """Create an atom from a Term or term handle.""" if isinstance(term, Term): term = term.handle elif not isinstance(term, (c_void_p, int)): raise ArgumentTypeError((str(Term), str(c_void_p)), str(type(term))) a = atom_t() if PL_ge...
[ "def", "fromTerm", "(", "cls", ",", "term", ")", ":", "if", "isinstance", "(", "term", ",", "Term", ")", ":", "term", "=", "term", ".", "handle", "elif", "not", "isinstance", "(", "term", ",", "(", "c_void_p", ",", "int", ")", ")", ":", "raise", ...
Create an atom from a Term or term handle.
[ "Create", "an", "atom", "from", "a", "Term", "or", "term", "handle", "." ]
f7c1f1e8c3a13b90bd775861d374788a8b5677d8
https://github.com/yuce/pyswip/blob/f7c1f1e8c3a13b90bd775861d374788a8b5677d8/pyswip/easy.py#L62-L72
235,875
yuce/pyswip
pyswip/easy.py
Functor.fromTerm
def fromTerm(cls, term): """Create a functor from a Term or term handle.""" if isinstance(term, Term): term = term.handle elif not isinstance(term, (c_void_p, int)): raise ArgumentTypeError((str(Term), str(int)), str(type(term))) f = functor_t() if PL_ge...
python
def fromTerm(cls, term): """Create a functor from a Term or term handle.""" if isinstance(term, Term): term = term.handle elif not isinstance(term, (c_void_p, int)): raise ArgumentTypeError((str(Term), str(int)), str(type(term))) f = functor_t() if PL_ge...
[ "def", "fromTerm", "(", "cls", ",", "term", ")", ":", "if", "isinstance", "(", "term", ",", "Term", ")", ":", "term", "=", "term", ".", "handle", "elif", "not", "isinstance", "(", "term", ",", "(", "c_void_p", ",", "int", ")", ")", ":", "raise", ...
Create a functor from a Term or term handle.
[ "Create", "a", "functor", "from", "a", "Term", "or", "term", "handle", "." ]
f7c1f1e8c3a13b90bd775861d374788a8b5677d8
https://github.com/yuce/pyswip/blob/f7c1f1e8c3a13b90bd775861d374788a8b5677d8/pyswip/easy.py#L235-L254
235,876
yuce/pyswip
pyswip/core.py
_findSwiplWin
def _findSwiplWin(): import re """ This function uses several heuristics to gues where SWI-Prolog is installed in Windows. It always returns None as the path of the resource file because, in Windows, the way to find it is more robust so the SWI-Prolog DLL is always able to find it. :return...
python
def _findSwiplWin(): import re """ This function uses several heuristics to gues where SWI-Prolog is installed in Windows. It always returns None as the path of the resource file because, in Windows, the way to find it is more robust so the SWI-Prolog DLL is always able to find it. :return...
[ "def", "_findSwiplWin", "(", ")", ":", "import", "re", "dllNames", "=", "(", "'swipl.dll'", ",", "'libswipl.dll'", ")", "# First try: check the usual installation path (this is faster but", "# hardcoded)", "programFiles", "=", "os", ".", "getenv", "(", "'ProgramFiles'", ...
This function uses several heuristics to gues where SWI-Prolog is installed in Windows. It always returns None as the path of the resource file because, in Windows, the way to find it is more robust so the SWI-Prolog DLL is always able to find it. :returns: A tuple of (path to the swipl DLL, pa...
[ "This", "function", "uses", "several", "heuristics", "to", "gues", "where", "SWI", "-", "Prolog", "is", "installed", "in", "Windows", ".", "It", "always", "returns", "None", "as", "the", "path", "of", "the", "resource", "file", "because", "in", "Windows", ...
f7c1f1e8c3a13b90bd775861d374788a8b5677d8
https://github.com/yuce/pyswip/blob/f7c1f1e8c3a13b90bd775861d374788a8b5677d8/pyswip/core.py#L159-L232
235,877
yuce/pyswip
pyswip/core.py
_findSwiplLin
def _findSwiplLin(): """ This function uses several heuristics to guess where SWI-Prolog is installed in Linuxes. :returns: A tuple of (path to the swipl so, path to the resource file) :returns type: ({str, None}, {str, None}) """ # Maybe the exec is on path? (path, sw...
python
def _findSwiplLin(): """ This function uses several heuristics to guess where SWI-Prolog is installed in Linuxes. :returns: A tuple of (path to the swipl so, path to the resource file) :returns type: ({str, None}, {str, None}) """ # Maybe the exec is on path? (path, sw...
[ "def", "_findSwiplLin", "(", ")", ":", "# Maybe the exec is on path?", "(", "path", ",", "swiHome", ")", "=", "_findSwiplFromExec", "(", ")", "if", "path", "is", "not", "None", ":", "return", "(", "path", ",", "swiHome", ")", "# If it is not, use find_library",...
This function uses several heuristics to guess where SWI-Prolog is installed in Linuxes. :returns: A tuple of (path to the swipl so, path to the resource file) :returns type: ({str, None}, {str, None})
[ "This", "function", "uses", "several", "heuristics", "to", "guess", "where", "SWI", "-", "Prolog", "is", "installed", "in", "Linuxes", "." ]
f7c1f1e8c3a13b90bd775861d374788a8b5677d8
https://github.com/yuce/pyswip/blob/f7c1f1e8c3a13b90bd775861d374788a8b5677d8/pyswip/core.py#L234-L271
235,878
yuce/pyswip
pyswip/core.py
_findSwiplDar
def _findSwiplDar(): """ This function uses several heuristics to guess where SWI-Prolog is installed in MacOS. :returns: A tuple of (path to the swipl so, path to the resource file) :returns type: ({str, None}, {str, None}) """ # If the exec is in path (path, swiHome)...
python
def _findSwiplDar(): """ This function uses several heuristics to guess where SWI-Prolog is installed in MacOS. :returns: A tuple of (path to the swipl so, path to the resource file) :returns type: ({str, None}, {str, None}) """ # If the exec is in path (path, swiHome)...
[ "def", "_findSwiplDar", "(", ")", ":", "# If the exec is in path", "(", "path", ",", "swiHome", ")", "=", "_findSwiplFromExec", "(", ")", "if", "path", "is", "not", "None", ":", "return", "(", "path", ",", "swiHome", ")", "# If it is not, use find_library", "...
This function uses several heuristics to guess where SWI-Prolog is installed in MacOS. :returns: A tuple of (path to the swipl so, path to the resource file) :returns type: ({str, None}, {str, None})
[ "This", "function", "uses", "several", "heuristics", "to", "guess", "where", "SWI", "-", "Prolog", "is", "installed", "in", "MacOS", "." ]
f7c1f1e8c3a13b90bd775861d374788a8b5677d8
https://github.com/yuce/pyswip/blob/f7c1f1e8c3a13b90bd775861d374788a8b5677d8/pyswip/core.py#L358-L390
235,879
yuce/pyswip
pyswip/core.py
_fixWindowsPath
def _fixWindowsPath(dll): """ When the path to the DLL is not in Windows search path, Windows will not be able to find other DLLs on the same directory, so we have to add it to the path. This function takes care of it. :parameters: - `dll` (str) - File name of the DLL """ if sys.pla...
python
def _fixWindowsPath(dll): """ When the path to the DLL is not in Windows search path, Windows will not be able to find other DLLs on the same directory, so we have to add it to the path. This function takes care of it. :parameters: - `dll` (str) - File name of the DLL """ if sys.pla...
[ "def", "_fixWindowsPath", "(", "dll", ")", ":", "if", "sys", ".", "platform", "[", ":", "3", "]", "!=", "'win'", ":", "return", "# Nothing to do here", "pathToDll", "=", "os", ".", "path", ".", "dirname", "(", "dll", ")", "currentWindowsPath", "=", "os",...
When the path to the DLL is not in Windows search path, Windows will not be able to find other DLLs on the same directory, so we have to add it to the path. This function takes care of it. :parameters: - `dll` (str) - File name of the DLL
[ "When", "the", "path", "to", "the", "DLL", "is", "not", "in", "Windows", "search", "path", "Windows", "will", "not", "be", "able", "to", "find", "other", "DLLs", "on", "the", "same", "directory", "so", "we", "have", "to", "add", "it", "to", "the", "p...
f7c1f1e8c3a13b90bd775861d374788a8b5677d8
https://github.com/yuce/pyswip/blob/f7c1f1e8c3a13b90bd775861d374788a8b5677d8/pyswip/core.py#L435-L454
235,880
yuce/pyswip
pyswip/core.py
list_to_bytes_list
def list_to_bytes_list(strList): """ This function turns an array of strings into a pointer array with pointers pointing to the encodings of those strings Possibly contained bytes are kept as they are. :param strList: List of strings that shall be converted :type strList: List of strings :r...
python
def list_to_bytes_list(strList): """ This function turns an array of strings into a pointer array with pointers pointing to the encodings of those strings Possibly contained bytes are kept as they are. :param strList: List of strings that shall be converted :type strList: List of strings :r...
[ "def", "list_to_bytes_list", "(", "strList", ")", ":", "pList", "=", "c_char_p", "*", "len", "(", "strList", ")", "# if strList is already a pointerarray or None, there is nothing to do", "if", "isinstance", "(", "strList", ",", "(", "pList", ",", "type", "(", "None...
This function turns an array of strings into a pointer array with pointers pointing to the encodings of those strings Possibly contained bytes are kept as they are. :param strList: List of strings that shall be converted :type strList: List of strings :returns: Pointer array with pointers pointing ...
[ "This", "function", "turns", "an", "array", "of", "strings", "into", "a", "pointer", "array", "with", "pointers", "pointing", "to", "the", "encodings", "of", "those", "strings", "Possibly", "contained", "bytes", "are", "kept", "as", "they", "are", "." ]
f7c1f1e8c3a13b90bd775861d374788a8b5677d8
https://github.com/yuce/pyswip/blob/f7c1f1e8c3a13b90bd775861d374788a8b5677d8/pyswip/core.py#L478-L502
235,881
yuce/pyswip
pyswip/core.py
check_strings
def check_strings(strings, arrays): """ Decorator function which can be used to automatically turn an incoming string into a bytes object and an incoming list to a pointer array if necessary. :param strings: Indices of the arguments must be pointers to bytes :type strings: List of integers ...
python
def check_strings(strings, arrays): """ Decorator function which can be used to automatically turn an incoming string into a bytes object and an incoming list to a pointer array if necessary. :param strings: Indices of the arguments must be pointers to bytes :type strings: List of integers ...
[ "def", "check_strings", "(", "strings", ",", "arrays", ")", ":", "# if given a single element, turn it into a list", "if", "isinstance", "(", "strings", ",", "int", ")", ":", "strings", "=", "[", "strings", "]", "elif", "strings", "is", "None", ":", "strings", ...
Decorator function which can be used to automatically turn an incoming string into a bytes object and an incoming list to a pointer array if necessary. :param strings: Indices of the arguments must be pointers to bytes :type strings: List of integers :param arrays: Indices of the arguments must be ...
[ "Decorator", "function", "which", "can", "be", "used", "to", "automatically", "turn", "an", "incoming", "string", "into", "a", "bytes", "object", "and", "an", "incoming", "list", "to", "a", "pointer", "array", "if", "necessary", "." ]
f7c1f1e8c3a13b90bd775861d374788a8b5677d8
https://github.com/yuce/pyswip/blob/f7c1f1e8c3a13b90bd775861d374788a8b5677d8/pyswip/core.py#L506-L563
235,882
hazelcast/hazelcast-python-client
hazelcast/proxy/queue.py
Queue.add
def add(self, item): """ Adds the specified item to this queue if there is available space. :param item: (object), the specified item. :return: (bool), ``true`` if element is successfully added, ``false`` otherwise. """ def result_fnc(f): if f.result(): ...
python
def add(self, item): """ Adds the specified item to this queue if there is available space. :param item: (object), the specified item. :return: (bool), ``true`` if element is successfully added, ``false`` otherwise. """ def result_fnc(f): if f.result(): ...
[ "def", "add", "(", "self", ",", "item", ")", ":", "def", "result_fnc", "(", "f", ")", ":", "if", "f", ".", "result", "(", ")", ":", "return", "True", "raise", "Full", "(", "\"Queue is full!\"", ")", "return", "self", ".", "offer", "(", "item", ")",...
Adds the specified item to this queue if there is available space. :param item: (object), the specified item. :return: (bool), ``true`` if element is successfully added, ``false`` otherwise.
[ "Adds", "the", "specified", "item", "to", "this", "queue", "if", "there", "is", "available", "space", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/queue.py#L39-L51
235,883
hazelcast/hazelcast-python-client
hazelcast/proxy/queue.py
Queue.add_all
def add_all(self, items): """ Adds the elements in the specified collection to this queue. :param items: (Collection), collection which includes the items to be added. :return: (bool), ``true`` if this queue is changed after call, ``false`` otherwise. """ check_not_none(...
python
def add_all(self, items): """ Adds the elements in the specified collection to this queue. :param items: (Collection), collection which includes the items to be added. :return: (bool), ``true`` if this queue is changed after call, ``false`` otherwise. """ check_not_none(...
[ "def", "add_all", "(", "self", ",", "items", ")", ":", "check_not_none", "(", "items", ",", "\"Value can't be None\"", ")", "data_items", "=", "[", "]", "for", "item", "in", "items", ":", "check_not_none", "(", "item", ",", "\"Value can't be None\"", ")", "d...
Adds the elements in the specified collection to this queue. :param items: (Collection), collection which includes the items to be added. :return: (bool), ``true`` if this queue is changed after call, ``false`` otherwise.
[ "Adds", "the", "elements", "in", "the", "specified", "collection", "to", "this", "queue", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/queue.py#L53-L65
235,884
hazelcast/hazelcast-python-client
hazelcast/proxy/queue.py
Queue.contains_all
def contains_all(self, items): """ Determines whether this queue contains all of the items in the specified collection or not. :param items: (Collection), the specified collection which includes the items to be searched. :return: (bool), ``true`` if all of the items in the specified col...
python
def contains_all(self, items): """ Determines whether this queue contains all of the items in the specified collection or not. :param items: (Collection), the specified collection which includes the items to be searched. :return: (bool), ``true`` if all of the items in the specified col...
[ "def", "contains_all", "(", "self", ",", "items", ")", ":", "check_not_none", "(", "items", ",", "\"Items can't be None\"", ")", "data_items", "=", "[", "]", "for", "item", "in", "items", ":", "check_not_none", "(", "item", ",", "\"item can't be None\"", ")", ...
Determines whether this queue contains all of the items in the specified collection or not. :param items: (Collection), the specified collection which includes the items to be searched. :return: (bool), ``true`` if all of the items in the specified collection exist in this queue, ``false`` otherwise.
[ "Determines", "whether", "this", "queue", "contains", "all", "of", "the", "items", "in", "the", "specified", "collection", "or", "not", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/queue.py#L112-L124
235,885
hazelcast/hazelcast-python-client
hazelcast/proxy/queue.py
Queue.drain_to
def drain_to(self, list, max_size=-1): """ Transfers all available items to the given `list`_ and removes these items from this queue. If a max_size is specified, it transfers at most the given number of items. In case of a failure, an item can exist in both collections or none of them. ...
python
def drain_to(self, list, max_size=-1): """ Transfers all available items to the given `list`_ and removes these items from this queue. If a max_size is specified, it transfers at most the given number of items. In case of a failure, an item can exist in both collections or none of them. ...
[ "def", "drain_to", "(", "self", ",", "list", ",", "max_size", "=", "-", "1", ")", ":", "def", "drain_result", "(", "f", ")", ":", "resp", "=", "f", ".", "result", "(", ")", "list", ".", "extend", "(", "resp", ")", "return", "len", "(", "resp", ...
Transfers all available items to the given `list`_ and removes these items from this queue. If a max_size is specified, it transfers at most the given number of items. In case of a failure, an item can exist in both collections or none of them. This operation may be more efficient than polling ...
[ "Transfers", "all", "available", "items", "to", "the", "given", "list", "_", "and", "removes", "these", "items", "from", "this", "queue", ".", "If", "a", "max_size", "is", "specified", "it", "transfers", "at", "most", "the", "given", "number", "of", "items...
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/queue.py#L126-L146
235,886
hazelcast/hazelcast-python-client
hazelcast/proxy/queue.py
Queue.put
def put(self, item): """ Adds the specified element into this queue. If there is no space, it waits until necessary space becomes available. :param item: (object), the specified item. """ check_not_none(item, "Value can't be None") element_data = self._to_data(it...
python
def put(self, item): """ Adds the specified element into this queue. If there is no space, it waits until necessary space becomes available. :param item: (object), the specified item. """ check_not_none(item, "Value can't be None") element_data = self._to_data(it...
[ "def", "put", "(", "self", ",", "item", ")", ":", "check_not_none", "(", "item", ",", "\"Value can't be None\"", ")", "element_data", "=", "self", ".", "_to_data", "(", "item", ")", "return", "self", ".", "_encode_invoke", "(", "queue_put_codec", ",", "value...
Adds the specified element into this queue. If there is no space, it waits until necessary space becomes available. :param item: (object), the specified item.
[ "Adds", "the", "specified", "element", "into", "this", "queue", ".", "If", "there", "is", "no", "space", "it", "waits", "until", "necessary", "space", "becomes", "available", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/queue.py#L199-L208
235,887
hazelcast/hazelcast-python-client
hazelcast/proxy/queue.py
Queue.remove_all
def remove_all(self, items): """ Removes all of the elements of the specified collection from this queue. :param items: (Collection), the specified collection. :return: (bool), ``true`` if the call changed this queue, ``false`` otherwise. """ check_not_none(items, "Value...
python
def remove_all(self, items): """ Removes all of the elements of the specified collection from this queue. :param items: (Collection), the specified collection. :return: (bool), ``true`` if the call changed this queue, ``false`` otherwise. """ check_not_none(items, "Value...
[ "def", "remove_all", "(", "self", ",", "items", ")", ":", "check_not_none", "(", "items", ",", "\"Value can't be None\"", ")", "data_items", "=", "[", "]", "for", "item", "in", "items", ":", "check_not_none", "(", "item", ",", "\"Value can't be None\"", ")", ...
Removes all of the elements of the specified collection from this queue. :param items: (Collection), the specified collection. :return: (bool), ``true`` if the call changed this queue, ``false`` otherwise.
[ "Removes", "all", "of", "the", "elements", "of", "the", "specified", "collection", "from", "this", "queue", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/queue.py#L229-L241
235,888
hazelcast/hazelcast-python-client
hazelcast/proxy/queue.py
Queue.retain_all
def retain_all(self, items): """ Removes the items which are not contained in the specified collection. In other words, only the items that are contained in the specified collection will be retained. :param items: (Collection), collection which includes the elements to be retained in th...
python
def retain_all(self, items): """ Removes the items which are not contained in the specified collection. In other words, only the items that are contained in the specified collection will be retained. :param items: (Collection), collection which includes the elements to be retained in th...
[ "def", "retain_all", "(", "self", ",", "items", ")", ":", "check_not_none", "(", "items", ",", "\"Value can't be None\"", ")", "data_items", "=", "[", "]", "for", "item", "in", "items", ":", "check_not_none", "(", "item", ",", "\"Value can't be None\"", ")", ...
Removes the items which are not contained in the specified collection. In other words, only the items that are contained in the specified collection will be retained. :param items: (Collection), collection which includes the elements to be retained in this set. :return: (bool), ``true`` if this...
[ "Removes", "the", "items", "which", "are", "not", "contained", "in", "the", "specified", "collection", ".", "In", "other", "words", "only", "the", "items", "that", "are", "contained", "in", "the", "specified", "collection", "will", "be", "retained", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/queue.py#L252-L265
235,889
hazelcast/hazelcast-python-client
hazelcast/proxy/pn_counter.py
PNCounter.get_and_add
def get_and_add(self, delta): """ Adds the given value to the current value and returns the previous value. :raises NoDataMemberInClusterError: if the cluster does not contain any data members. :raises UnsupportedOperationError: if the cluster version is less than 3.10. :raises ...
python
def get_and_add(self, delta): """ Adds the given value to the current value and returns the previous value. :raises NoDataMemberInClusterError: if the cluster does not contain any data members. :raises UnsupportedOperationError: if the cluster version is less than 3.10. :raises ...
[ "def", "get_and_add", "(", "self", ",", "delta", ")", ":", "return", "self", ".", "_invoke_internal", "(", "pn_counter_add_codec", ",", "delta", "=", "delta", ",", "get_before_update", "=", "True", ")" ]
Adds the given value to the current value and returns the previous value. :raises NoDataMemberInClusterError: if the cluster does not contain any data members. :raises UnsupportedOperationError: if the cluster version is less than 3.10. :raises ConsistencyLostError: if the session guarantees ha...
[ "Adds", "the", "given", "value", "to", "the", "current", "value", "and", "returns", "the", "previous", "value", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/pn_counter.py#L77-L89
235,890
hazelcast/hazelcast-python-client
hazelcast/proxy/pn_counter.py
PNCounter.add_and_get
def add_and_get(self, delta): """ Adds the given value to the current value and returns the updated value. :raises NoDataMemberInClusterError: if the cluster does not contain any data members. :raises UnsupportedOperationError: if the cluster version is less than 3.10. :raises C...
python
def add_and_get(self, delta): """ Adds the given value to the current value and returns the updated value. :raises NoDataMemberInClusterError: if the cluster does not contain any data members. :raises UnsupportedOperationError: if the cluster version is less than 3.10. :raises C...
[ "def", "add_and_get", "(", "self", ",", "delta", ")", ":", "return", "self", ".", "_invoke_internal", "(", "pn_counter_add_codec", ",", "delta", "=", "delta", ",", "get_before_update", "=", "False", ")" ]
Adds the given value to the current value and returns the updated value. :raises NoDataMemberInClusterError: if the cluster does not contain any data members. :raises UnsupportedOperationError: if the cluster version is less than 3.10. :raises ConsistencyLostError: if the session guarantees hav...
[ "Adds", "the", "given", "value", "to", "the", "current", "value", "and", "returns", "the", "updated", "value", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/pn_counter.py#L91-L103
235,891
hazelcast/hazelcast-python-client
hazelcast/proxy/pn_counter.py
PNCounter.get_and_subtract
def get_and_subtract(self, delta): """ Subtracts the given value from the current value and returns the previous value. :raises NoDataMemberInClusterError: if the cluster does not contain any data members. :raises UnsupportedOperationError: if the cluster version is less than 3.10. ...
python
def get_and_subtract(self, delta): """ Subtracts the given value from the current value and returns the previous value. :raises NoDataMemberInClusterError: if the cluster does not contain any data members. :raises UnsupportedOperationError: if the cluster version is less than 3.10. ...
[ "def", "get_and_subtract", "(", "self", ",", "delta", ")", ":", "return", "self", ".", "_invoke_internal", "(", "pn_counter_add_codec", ",", "delta", "=", "-", "1", "*", "delta", ",", "get_before_update", "=", "True", ")" ]
Subtracts the given value from the current value and returns the previous value. :raises NoDataMemberInClusterError: if the cluster does not contain any data members. :raises UnsupportedOperationError: if the cluster version is less than 3.10. :raises ConsistencyLostError: if the session guaran...
[ "Subtracts", "the", "given", "value", "from", "the", "current", "value", "and", "returns", "the", "previous", "value", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/pn_counter.py#L105-L117
235,892
hazelcast/hazelcast-python-client
hazelcast/proxy/pn_counter.py
PNCounter.subtract_and_get
def subtract_and_get(self, delta): """ Subtracts the given value from the current value and returns the updated value. :raises NoDataMemberInClusterError: if the cluster does not contain any data members. :raises UnsupportedOperationError: if the cluster version is less than 3.10. ...
python
def subtract_and_get(self, delta): """ Subtracts the given value from the current value and returns the updated value. :raises NoDataMemberInClusterError: if the cluster does not contain any data members. :raises UnsupportedOperationError: if the cluster version is less than 3.10. ...
[ "def", "subtract_and_get", "(", "self", ",", "delta", ")", ":", "return", "self", ".", "_invoke_internal", "(", "pn_counter_add_codec", ",", "delta", "=", "-", "1", "*", "delta", ",", "get_before_update", "=", "False", ")" ]
Subtracts the given value from the current value and returns the updated value. :raises NoDataMemberInClusterError: if the cluster does not contain any data members. :raises UnsupportedOperationError: if the cluster version is less than 3.10. :raises ConsistencyLostError: if the session guarant...
[ "Subtracts", "the", "given", "value", "from", "the", "current", "value", "and", "returns", "the", "updated", "value", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/pn_counter.py#L119-L131
235,893
hazelcast/hazelcast-python-client
hazelcast/client.py
HazelcastClient.shutdown
def shutdown(self): """ Shuts down this HazelcastClient. """ if self.lifecycle.is_live: self.lifecycle.fire_lifecycle_event(LIFECYCLE_STATE_SHUTTING_DOWN) self.near_cache_manager.destroy_all_near_caches() self.statistics.shutdown() self.par...
python
def shutdown(self): """ Shuts down this HazelcastClient. """ if self.lifecycle.is_live: self.lifecycle.fire_lifecycle_event(LIFECYCLE_STATE_SHUTTING_DOWN) self.near_cache_manager.destroy_all_near_caches() self.statistics.shutdown() self.par...
[ "def", "shutdown", "(", "self", ")", ":", "if", "self", ".", "lifecycle", ".", "is_live", ":", "self", ".", "lifecycle", ".", "fire_lifecycle_event", "(", "LIFECYCLE_STATE_SHUTTING_DOWN", ")", "self", ".", "near_cache_manager", ".", "destroy_all_near_caches", "(",...
Shuts down this HazelcastClient.
[ "Shuts", "down", "this", "HazelcastClient", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/client.py#L251-L264
235,894
hazelcast/hazelcast-python-client
hazelcast/proxy/topic.py
Topic.publish
def publish(self, message): """ Publishes the message to all subscribers of this topic :param message: (object), the message to be published. """ message_data = self._to_data(message) self._encode_invoke(topic_publish_codec, message=message_data)
python
def publish(self, message): """ Publishes the message to all subscribers of this topic :param message: (object), the message to be published. """ message_data = self._to_data(message) self._encode_invoke(topic_publish_codec, message=message_data)
[ "def", "publish", "(", "self", ",", "message", ")", ":", "message_data", "=", "self", ".", "_to_data", "(", "message", ")", "self", ".", "_encode_invoke", "(", "topic_publish_codec", ",", "message", "=", "message_data", ")" ]
Publishes the message to all subscribers of this topic :param message: (object), the message to be published.
[ "Publishes", "the", "message", "to", "all", "subscribers", "of", "this", "topic" ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/topic.py#L39-L46
235,895
hazelcast/hazelcast-python-client
hazelcast/proxy/topic.py
Topic.remove_listener
def remove_listener(self, registration_id): """ Stops receiving messages for the given message listener. If the given listener already removed, this method does nothing. :param registration_id: (str), registration id of the listener to be removed. :return: (bool), ``true`` if th...
python
def remove_listener(self, registration_id): """ Stops receiving messages for the given message listener. If the given listener already removed, this method does nothing. :param registration_id: (str), registration id of the listener to be removed. :return: (bool), ``true`` if th...
[ "def", "remove_listener", "(", "self", ",", "registration_id", ")", ":", "return", "self", ".", "_stop_listening", "(", "registration_id", ",", "lambda", "i", ":", "topic_remove_message_listener_codec", ".", "encode_request", "(", "self", ".", "name", ",", "i", ...
Stops receiving messages for the given message listener. If the given listener already removed, this method does nothing. :param registration_id: (str), registration id of the listener to be removed. :return: (bool), ``true`` if the listener is removed, ``false`` otherwise.
[ "Stops", "receiving", "messages", "for", "the", "given", "message", "listener", ".", "If", "the", "given", "listener", "already", "removed", "this", "method", "does", "nothing", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/topic.py#L48-L57
235,896
hazelcast/hazelcast-python-client
hazelcast/util.py
validate_serializer
def validate_serializer(serializer, _type): """ Validates the serializer for given type. :param serializer: (Serializer), the serializer to be validated. :param _type: (Type), type to be used for serializer validation. """ if not issubclass(serializer, _type): raise ValueError("Serializ...
python
def validate_serializer(serializer, _type): """ Validates the serializer for given type. :param serializer: (Serializer), the serializer to be validated. :param _type: (Type), type to be used for serializer validation. """ if not issubclass(serializer, _type): raise ValueError("Serializ...
[ "def", "validate_serializer", "(", "serializer", ",", "_type", ")", ":", "if", "not", "issubclass", "(", "serializer", ",", "_type", ")", ":", "raise", "ValueError", "(", "\"Serializer should be an instance of {}\"", ".", "format", "(", "_type", ".", "__name__", ...
Validates the serializer for given type. :param serializer: (Serializer), the serializer to be validated. :param _type: (Type), type to be used for serializer validation.
[ "Validates", "the", "serializer", "for", "given", "type", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/util.py#L119-L127
235,897
hazelcast/hazelcast-python-client
hazelcast/exception.py
create_exception
def create_exception(error_codec): """ Creates an exception with given error codec. :param error_codec: (Error Codec), error codec which includes the class name, message and exception trace. :return: (Exception), the created exception. """ if error_codec.error_code in ERROR_CODE_TO_ERROR: ...
python
def create_exception(error_codec): """ Creates an exception with given error codec. :param error_codec: (Error Codec), error codec which includes the class name, message and exception trace. :return: (Exception), the created exception. """ if error_codec.error_code in ERROR_CODE_TO_ERROR: ...
[ "def", "create_exception", "(", "error_codec", ")", ":", "if", "error_codec", ".", "error_code", "in", "ERROR_CODE_TO_ERROR", ":", "return", "ERROR_CODE_TO_ERROR", "[", "error_codec", ".", "error_code", "]", "(", "error_codec", ".", "message", ")", "stack_trace", ...
Creates an exception with given error codec. :param error_codec: (Error Codec), error codec which includes the class name, message and exception trace. :return: (Exception), the created exception.
[ "Creates", "an", "exception", "with", "given", "error", "codec", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/exception.py#L460-L476
235,898
hazelcast/hazelcast-python-client
hazelcast/proxy/ringbuffer.py
Ringbuffer.capacity
def capacity(self): """ Returns the capacity of this Ringbuffer. :return: (long), the capacity of Ringbuffer. """ if not self._capacity: def cache_capacity(f): self._capacity = f.result() return f.result() return self._enc...
python
def capacity(self): """ Returns the capacity of this Ringbuffer. :return: (long), the capacity of Ringbuffer. """ if not self._capacity: def cache_capacity(f): self._capacity = f.result() return f.result() return self._enc...
[ "def", "capacity", "(", "self", ")", ":", "if", "not", "self", ".", "_capacity", ":", "def", "cache_capacity", "(", "f", ")", ":", "self", ".", "_capacity", "=", "f", ".", "result", "(", ")", "return", "f", ".", "result", "(", ")", "return", "self"...
Returns the capacity of this Ringbuffer. :return: (long), the capacity of Ringbuffer.
[ "Returns", "the", "capacity", "of", "this", "Ringbuffer", "." ]
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/ringbuffer.py#L53-L65
235,899
hazelcast/hazelcast-python-client
hazelcast/proxy/ringbuffer.py
Ringbuffer.read_one
def read_one(self, sequence): """ Reads one item from the Ringbuffer. If the sequence is one beyond the current tail, this call blocks until an item is added. Currently it isn't possible to control how long this call is going to block. :param sequence: (long), the sequence of the item t...
python
def read_one(self, sequence): """ Reads one item from the Ringbuffer. If the sequence is one beyond the current tail, this call blocks until an item is added. Currently it isn't possible to control how long this call is going to block. :param sequence: (long), the sequence of the item t...
[ "def", "read_one", "(", "self", ",", "sequence", ")", ":", "check_not_negative", "(", "sequence", ",", "\"sequence can't be smaller than 0\"", ")", "return", "self", ".", "_encode_invoke", "(", "ringbuffer_read_one_codec", ",", "sequence", "=", "sequence", ")" ]
Reads one item from the Ringbuffer. If the sequence is one beyond the current tail, this call blocks until an item is added. Currently it isn't possible to control how long this call is going to block. :param sequence: (long), the sequence of the item to read. :return: (object), the read item.
[ "Reads", "one", "item", "from", "the", "Ringbuffer", ".", "If", "the", "sequence", "is", "one", "beyond", "the", "current", "tail", "this", "call", "blocks", "until", "an", "item", "is", "added", ".", "Currently", "it", "isn", "t", "possible", "to", "con...
3f6639443c23d6d036aa343f8e094f052250d2c1
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/ringbuffer.py#L135-L144