code
string
signature
string
docstring
string
loss_without_docstring
float64
loss_with_docstring
float64
factor
float64
if len(name.split(".")) == 3: return self.get_objects([name])[0] else: return self.get_account_by_name(name, **kwargs)
def get_account(self, name, **kwargs)
Get full account details from account name or id :param str name: Account name or account id
3.513108
4.426969
0.79357
if len(name.split(".")) == 3: return self.get_objects([name], **kwargs)[0] else: return self.lookup_asset_symbols([name], **kwargs)[0]
def get_asset(self, name, **kwargs)
Get full asset from name of id :param str name: Symbol name or asset id (e.g. 1.3.0)
4.369973
3.942162
1.108522
self.login(self.user, self.password, api_id=1) self.database(api_id=1) self.__set_subscriptions() self.keepalive = threading.Thread(target=self._ping) self.keepalive.start()
def on_open(self, *args, **kwargs)
This method will be called once the websocket connection is established. It will * login, * register to the database api, and * subscribe to the objects defined if there is a callback/slot available for callbacks
6.125947
5.199339
1.178217
id = notice["id"] _a, _b, _ = id.split(".") if id in self.subscription_objects: self.on_object(notice) elif ".".join([_a, _b, "x"]) in self.subscription_objects: self.on_object(notice) elif id[:4] == "2.6.": # Treat account updates...
def process_notice(self, notice)
This method is called on notices that need processing. Here, we call ``on_object`` and ``on_account`` slots.
6.010884
4.852572
1.238701
self.run_event.set() self.ws.close() if self.keepalive and self.keepalive.is_alive(): self.keepalive.join()
def close(self, *args, **kwargs)
Closes the websocket connection and waits for the ping thread to close
4.69813
3.63177
1.29362
log.debug(json.dumps(payload)) self.ws.send(json.dumps(payload, ensure_ascii=False).encode("utf8"))
def rpcexec(self, payload)
Execute a call by sending the payload :param dict payload: Payload data :raises ValueError: if the server does not respond in proper JSON format :raises RPCError: if the server returns an error
3.72639
4.356511
0.855361
"Put the texts in `items` in an HTML table." html_code = f html_code += f for i in items[0]: html_code += f" <th>{i}</th>\n" html_code += f" </tr>\n </thead>\n <tbody>\n" for line in items[1:]: html_code += " <tr>\n" for i in line: html_code += f" <td>{i}</td>\n...
def text2html_table(items)
Put the texts in `items` in an HTML table.
2.631807
2.290472
1.149024
global _default_logger if _default_logger is not None: raise ValueError('default logger already configured') _default_logger = Logger(logdir, flush_secs=flush_secs)
def configure(logdir, flush_secs=2)
Configure logging: a file will be written to logdir, and flushed every flush_secs.
2.701113
2.831174
0.954061
if isinstance(value, six.string_types): raise TypeError('"value" should be a number, got {}' .format(type(value))) value = float(value) self._check_step(step) tf_name = self._ensure_tf_name(name) summary = self._scalar_summary(tf...
def log_value(self, name, value, step=None)
Log new value for given name on given step. Args: name (str): name of the variable (it will be converted to a valid tensorflow summary name). value (float): this is a real number to be logged as a scalar. step (int): non-negative integer used for visualizatio...
3.468828
3.559449
0.974541
if isinstance(value, six.string_types): raise TypeError('"value" should be a number, got {}' .format(type(value))) self._check_step(step) tf_name = self._ensure_tf_name(name) summary = self._histogram_summary(tf_name, value, step=step) ...
def log_histogram(self, name, value, step=None)
Log a histogram for given name on given step. Args: name (str): name of the variable (it will be converted to a valid tensorflow summary name). value (tuple or list): either list of numbers to be summarized as a histogram, or a tuple of bin_edges and ...
3.56425
3.896043
0.914839
if isinstance(images, six.string_types): raise TypeError('"images" should be a list of ndarrays, got {}' .format(type(images))) self._check_step(step) tf_name = self._ensure_tf_name(name) summary = self._image_summary(tf_name, images, st...
def log_images(self, name, images, step=None)
Log new images for given name on given step. Args: name (str): name of the variable (it will be converted to a valid tensorflow summary name). images (list): list of images to visualize step (int): non-negative integer used for visualization
3.548419
3.682805
0.96351
img_summaries = [] for i, img in enumerate(images): # Write the image to a string try: s = StringIO() except: s = BytesIO() scipy.misc.toimage(img).save(s, format="png") # Create an Image object ...
def _image_summary(self, tf_name, images, step=None)
Log a list of images. References: https://github.com/yunjey/pytorch-tutorial/blob/master/tutorials/04-utils/tensorboard/logger.py#L22 Example: >>> tf_name = 'foo' >>> value = ([0, 1, 2, 3, 4, 5], [1, 20, 10, 22, 11]) >>> self = Logger(None, is_dummy=True...
1.707685
1.913456
0.892461
if isinstance(value, tuple): bin_edges, bincounts = value assert len(bin_edges) == len(bincounts) + 1, ( 'must have one more edge than count') hist = summary_pb2.HistogramProto() hist.min = float(min(bin_edges)) hist.max = floa...
def _histogram_summary(self, tf_name, value, step=None)
Args: tf_name (str): name of tensorflow variable value (tuple or list): either a tuple of bin_edges and bincounts or a list of values to summarize in a histogram. References: https://github.com/yunjey/pytorch-tutorial/blob/master/tutorials/04-utils/tensorboar...
1.855787
1.813267
1.023449
if (type(value) == bool) and not bool_is_str: if (value) == True: return '1' else: return '0' elif type(value) == str or ((type(value) == bool) and bool_is_str): return str_quote_style + str(value) + str_quote_style else: return str(value)
def jinja_filter_param_value_str(value, str_quote_style="", bool_is_str=False)
Convert a parameter value to string suitable to be passed to an EDA tool Rules: - Booleans are represented as 0/1 or "true"/"false" depending on the bool_is_str argument - Strings are either passed through or enclosed in the characters specified in str_quote_style (e.g. '"' or '\\"') - Ever...
2.162027
2.13212
1.014027
template_dir = str(self.__class__.__name__).lower() template = self.jinja_env.get_template(os.path.join(template_dir, template_file)) file_path = os.path.join(self.work_root, target_file) with open(file_path, 'w') as f: f.write(template.render(template_vars))
def render_template(self, template_file, target_file, template_vars = {})
Render a Jinja2 template for the backend The template file is expected in the directory templates/BACKEND_NAME.
2.2349
2.175013
1.027534
reply = NVCtrlQueryTargetCountReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), target_type=target.type()) return int(reply._data.get('count'))
def query_target_count(self, target)
Return the target count
21.485567
21.553225
0.996861
reply = NVCtrlQueryAttributeReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), target_id=target.id(), target_type=target.type(), ...
def query_int_attribute(self, target, display_mask, attr)
Return the value of an integer attribute
8.20446
8.192728
1.001432
reply = NVCtrlSetAttributeAndGetStatusReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), target_id=target.id(), ...
def set_int_attribute(self, target, display_mask, attr, value)
Set the value of an integer attribute
10.094339
10.133504
0.996135
reply = NVCtrlQueryStringAttributeReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), target_id=target.id(), target_type=targ...
def query_string_attribute(self, target, display_mask, attr)
Return the value of a string attribute
9.525687
9.486342
1.004148
reply = NVCtrlQueryBinaryDataReplyRequest(display=self.display, opcode=self.display.get_extension_major(extname), target_id=target.id(), target_type=target.type(), ...
def query_binary_data(self, target, display_mask, attr)
Return binary data
7.700397
7.731049
0.996035
num = None for s, n in [('DFP-', 16), ('TV-', 8), ('CRT-', 0)]: if st.startswith(s): try: curnum = int(st[len(s):]) if 0 <= curnum <= 7: num = n + curnum break except Exception: pass ...
def _displaystr2num(st)
Return a display number from a string
3.907362
3.933855
0.993265
return self.display.resource_classes[type](self.display, id)
def create_resource_object(self, type, id)
Create a resource object of type for the integer id. type should be one of the following strings: resource drawable window pixmap fontable font gc colormap cursor This function can be used when a resource ID has been fetched ...
10.351003
11.330932
0.913517
if object == 'display': if hasattr(self, name): raise AssertionError('attempting to replace display method: %s' % name) self.display_extension_methods[name] = function else: class_list = (object, ) + _resource_hierarchy.get(object, ()) ...
def extension_add_method(self, object, name, function)
extension_add_method(object, name, function) Add an X extension module method. OBJECT is the type of object to add the function to, a string from this list: display resource drawable window pixmap fontable font ...
3.716125
3.640988
1.020636
newevt = type(evt.__name__, evt.__bases__, evt.__dict__.copy()) newevt._code = code self.display.add_extension_event(code, newevt) if name is None: name = evt.__name__ setattr(self.extension_event, name, code)
def extension_add_event(self, code, evt, name = None)
extension_add_event(code, evt, [name]) Add an extension event. CODE is the numeric code, and EVT is the event class. EVT will be cloned, and the attribute _code of the new event class will be set to CODE. If NAME is omitted, it will be set to the name of EVT. This name is us...
4.565102
4.105227
1.112022
try: return self._keymap_codes[keycode][index] except IndexError: return X.NoSymbol
def keycode_to_keysym(self, keycode, index)
Convert a keycode to a keysym, looking in entry index. Normally index 0 is unshifted, 1 is shifted, 2 is alt grid, and 3 is shift+alt grid. If that key entry is not bound, X.NoSymbol is returned.
7.09894
4.321838
1.642574
try: # Copy the map list, reversing the arguments return map(lambda x: (x[1], x[0]), self._keymap_syms[keysym]) except KeyError: return []
def keysym_to_keycodes(self, keysym)
Look up all the keycodes that is bound to keysym. A list of tuples (keycode, index) is returned, sorted primarily on the lowest index and secondarily on the lowest keycode.
7.797664
7.639398
1.020717
if isinstance(evt, event.MappingNotify): if evt.request == X.MappingKeyboard: self._update_keymap(evt.first_keycode, evt.count) else: raise TypeError('expected a MappingNotify event')
def refresh_keyboard_mapping(self, evt)
This method should be called once when a MappingNotify event is received, to update the keymap cache. evt should be the event object.
12.19412
7.007977
1.740034
# Delete all sym->code maps for the changed codes lastcode = first_keycode + count for keysym, codes in self._keymap_syms.items(): i = 0 while i < len(codes): code = codes[i][1] if code >= first_keycode and code < lastcode: ...
def _update_keymap(self, first_keycode, count)
Internal function, called to refresh the keymap cache.
3.121371
3.042118
1.026052
s = self.keysym_translations.get(keysym) if s is not None: return s import Xlib.XK return Xlib.XK.keysym_to_string(keysym)
def lookup_string(self, keysym)
Return a string corresponding to KEYSYM, or None if no reasonable translation is found.
3.953379
3.697493
1.069205
if newstring is None: try: del self.keysym_translations[keysym] except KeyError: pass else: self.keysym_translations[keysym] = newstring
def rebind_string(self, keysym, newstring)
Change the translation of KEYSYM to NEWSTRING. If NEWSTRING is None, remove old translation if any.
2.549746
1.953434
1.305264
r = request.InternAtom(display = self.display, name = name, only_if_exists = only_if_exists) return r.atom
def intern_atom(self, name, only_if_exists = 0)
Intern the string name, returning its atom number. If only_if_exists is true and the atom does not already exist, it will not be created and X.NONE is returned.
6.481167
6.216173
1.04263
r = request.GetAtomName(display = self.display, atom = atom) return r.name
def get_atom_name(self, atom)
Look up the name of atom, returning it as a string. Will raise BadAtom if atom does not exist.
16.421392
15.414538
1.065318
r = request.GetSelectionOwner(display = self.display, selection = selection) return r.owner
def get_selection_owner(self, selection)
Return the window that owns selection (an atom), or X.NONE if there is no owner for the selection. Can raise BadAtom.
13.601845
14.341573
0.948421
request.SendEvent(display = self.display, onerror = onerror, propagate = propagate, destination = destination, event_mask = event_mask, event = event)
def send_event(self, destination, event, event_mask = 0, propagate = 0, onerror = None)
Send a synthetic event to the window destination which can be a window object, or X.PointerWindow or X.InputFocus. event is the event object to send, instantiated from one of the classes in protocol.events. See XSendEvent(3X11) for details. There is also a Window.send_event() method.
4.073313
5.128424
0.794262
request.UngrabPointer(display = self.display, onerror = onerror, time = time)
def ungrab_pointer(self, time, onerror = None)
Release a grabbed pointer and any queued events. See XUngrabPointer(3X11).
8.961818
12.262102
0.730855
request.ChangeActivePointerGrab(display = self.display, onerror = onerror, cursor = cursor, time = time, event_mask = event_mask)
def change_active_pointer_grab(self, event_mask, cursor, time, onerror = None)
Change the dynamic parameters of a pointer grab. See XChangeActivePointerGrab(3X11).
3.854598
4.797563
0.803449
request.UngrabKeyboard(display = self.display, onerror = onerror, time = time)
def ungrab_keyboard(self, time, onerror = None)
Ungrab a grabbed keyboard and any queued events. See XUngrabKeyboard(3X11).
8.011859
12.314419
0.650608
request.AllowEvents(display = self.display, onerror = onerror, mode = mode, time = time)
def allow_events(self, mode, time, onerror = None)
Release some queued events. mode should be one of X.AsyncPointer, X.SyncPointer, X.AsyncKeyboard, X.SyncKeyboard, X.ReplayPointer, X.ReplayKeyboard, X.AsyncBoth, or X.SyncBoth. time should be a timestamp or X.CurrentTime.
6.983248
7.718613
0.904728
request.GrabServer(display = self.display, onerror = onerror)
def grab_server(self, onerror = None)
Disable processing of requests on all other client connections until the server is ungrabbed. Server grabbing should be avoided as much as possible.
12.182959
14.093293
0.864451
request.UngrabServer(display = self.display, onerror = onerror)
def ungrab_server(self, onerror = None)
Release the server if it was previously grabbed by this client.
11.903853
11.097455
1.072665
request.WarpPointer(display = self.display, onerror = onerror, src_window = src_window, dst_window = X.NONE, src_x = src_x, src_y = src_y, ...
def warp_pointer(self, x, y, src_window = X.NONE, src_x = 0, src_y = 0, src_width = 0, src_height = 0, onerror = None)
Move the pointer relative its current position by the offsets (x, y). However, if src_window is a window the pointer is only moved if the specified rectangle in src_window contains it. If src_width is 0 it will be replaced with the width of src_window - src_x. src_height is treated in a ...
2.066792
2.477454
0.83424
request.SetInputFocus(display = self.display, onerror = onerror, revert_to = revert_to, focus = focus, time = time)
def set_input_focus(self, focus, revert_to, time, onerror = None)
Set input focus to focus, which should be a window, X.PointerRoot or X.NONE. revert_to specifies where the focus reverts to if the focused window becomes not visible, and should be X.RevertToParent, RevertToPointerRoot, or RevertToNone. See XSetInputFocus(3X11) for details. Ther...
5.676915
7.17066
0.791686
r = request.QueryKeymap(display = self.display) return r.map
def query_keymap(self)
Return a bit vector for the logical state of the keyboard, where each bit set to 1 indicates that the corresponding key is currently pressed down. The vector is represented as a list of 32 integers. List item N contains the bits for keys 8N to 8N + 7 with the least significant bit in the...
25.245596
21.802534
1.15792
fid = self.display.allocate_resource_id() ec = error.CatchError(error.BadName) request.OpenFont(display = self.display, onerror = ec, fid = fid, name = name) self.sync() if ec.get_error(): ...
def open_font(self, name)
Open the font identifed by the pattern name and return its font object. If name does not match any font, None is returned.
7.03722
6.574913
1.070314
r = request.ListFonts(display = self.display, max_names = max_names, pattern = pattern) return r.fonts
def list_fonts(self, pattern, max_names)
Return a list of font names matching pattern. No more than max_names will be returned.
8.323745
7.916406
1.051455
return request.ListFontsWithInfo(display = self.display, max_names = max_names, pattern = pattern)
def list_fonts_with_info(self, pattern, max_names)
Return a list of fonts matching pattern. No more than max_names will be returned. Each list item represents one font and has the following properties: name The name of the font. min_bounds max_bounds min_char_or_byte2 max_char_or_byte2 default...
9.078087
9.81787
0.924649
request.SetFontPath(display = self.display, onerror = onerror, path = path)
def set_font_path(self, path, onerror = None)
Set the font path to path, which should be a list of strings. If path is empty, the default font path of the server will be restored.
10.86555
10.283821
1.056567
r = request.GetFontPath(display = self.display) return r.paths
def get_font_path(self)
Return the current font path as a list of strings.
26.937426
20.538618
1.31155
r = request.QueryExtension(display = self.display, name = name) if r.present: return r else: return None
def query_extension(self, name)
Ask the server if it supports the extension name. If it is supported an object with the following attributes is returned: major_opcode The major opcode that the requests of this extension uses. first_event The base event code if the extension have additional events, or 0...
9.667931
11.088675
0.871874
r = request.ListExtensions(display = self.display) return r.names
def list_extensions(self)
Return a list of all the extensions provided by the server.
35.54517
26.55505
1.338547
request.ChangeKeyboardMapping(display = self.display, onerror = onerror, first_keycode = first_keycode, keysyms = keysyms)
def change_keyboard_mapping(self, first_keycode, keysyms, onerror = None)
Modify the keyboard mapping, starting with first_keycode. keysyms is a list of tuples of keysyms. keysyms[n][i] will be assigned to keycode first_keycode+n at index i.
3.952434
4.18043
0.945461
r = request.GetKeyboardMapping(display = self.display, first_keycode = first_keycode, count = count) return r.keysyms
def get_keyboard_mapping(self, first_keycode, count)
Return the current keyboard mapping as a list of tuples, starting at first_keycount and no more than count.
6.233343
5.992306
1.040224
request.ChangeKeyboardControl(display = self.display, onerror = onerror, attrs = keys)
def change_keyboard_control(self, onerror = None, **keys)
Change the parameters provided as keyword arguments: key_click_percent The volume of key clicks between 0 (off) and 100 (load). -1 will restore default setting. bell_percent The base volume of the bell, coded as above. bell_pitch The pitch of the ...
12.052982
19.383089
0.62183
request.Bell(display = self.display, onerror = onerror, percent = percent)
def bell(self, percent = 0, onerror = None)
Ring the bell at the volume percent which is relative the base volume. See XBell(3X11).
9.816483
12.555583
0.781842
if accel is None: do_accel = 0 accel_num = 0 accel_denum = 0 else: do_accel = 1 accel_num, accel_denum = accel if threshold is None: do_threshold = 0 else: do_threshold = 1 request.Chan...
def change_pointer_control(self, accel = None, threshold = None, onerror = None)
To change the pointer acceleration, set accel to a tuple (num, denum). The pointer will then move num/denum times the normal speed if it moves beyond the threshold number of pixels at once. To change the threshold, set it to the number of pixels. -1 restores the default.
2.617683
2.339727
1.118799
request.SetScreenSaver(display = self.display, onerror = onerror, timeout = timeout, interval = interval, prefer_blank = prefer_blank, allow_exposur...
def set_screen_saver(self, timeout, interval, prefer_blank, allow_exposures, onerror = None)
See XSetScreenSaver(3X11).
2.940608
2.862449
1.027305
request.ChangeHosts(display = self.display, onerror = onerror, mode = mode, host_family = host_family, host = host)
def change_hosts(self, mode, host_family, host, onerror = None)
mode is either X.HostInsert or X.HostDelete. host_family is one of X.FamilyInternet, X.FamilyDECnet or X.FamilyChaos. host is a list of bytes. For the Internet family, it should be the four bytes of an IPv4 address.
4.599373
5.618215
0.818654
request.SetAccessControl(display = self.display, onerror = onerror, mode = mode)
def set_access_control(self, mode, onerror = None)
Enable use of access control lists at connection setup if mode is X.EnableAccess, disable if it is X.DisableAccess.
10.087357
10.893291
0.926015
request.SetCloseDownMode(display = self.display, onerror = onerror, mode = mode)
def set_close_down_mode(self, mode, onerror = None)
Control what will happen with the client's resources at connection close. The default is X.DestroyAll, the other values are X.RetainPermanent and X.RetainTemporary.
9.076754
10.065505
0.901768
request.ForceScreenSaver(display = self.display, onerror = onerror, mode = mode)
def force_screen_saver(self, mode, onerror = None)
If mode is X.ScreenSaverActive the screen saver is activated. If it is X.ScreenSaverReset, the screen saver is deactivated as if device input had been received.
8.721704
10.852374
0.803668
r = request.SetPointerMapping(display = self.display, map = map) return r.status
def set_pointer_mapping(self, map)
Set the mapping of the pointer buttons. map is a list of logical button numbers. map must be of the same length as the list returned by Display.get_pointer_mapping(). map[n] sets the logical number for the physical button n+1. Logical number 0 disables the button. Two physical b...
15.545323
19.271687
0.806641
r = request.GetPointerMapping(display = self.display) return r.map
def get_pointer_mapping(self)
Return a list of the pointer button mappings. Entry N in the list sets the logical button number for the physical button N+1.
25.754406
19.742493
1.304516
r = request.SetModifierMapping(display = self.display, keycodes = keycodes) return r.status
def set_modifier_mapping(self, keycodes)
Set the keycodes for the eight modifiers X.Shift, X.Lock, X.Control, X.Mod1, X.Mod2, X.Mod3, X.Mod4 and X.Mod5. keycodes should be a eight-element list where each entry is a list of the keycodes that should be bound to that modifier. If any changed key is logically in the down s...
12.553039
12.464314
1.007118
r = request.GetModifierMapping(display = self.display) return r.keycodes
def get_modifier_mapping(self)
Return a list of eight lists, one for each modifier. The list can be indexed using X.ShiftMapIndex, X.Mod1MapIndex, and so on. The sublists list the keycodes bound to that modifier.
34.966434
21.858973
1.599638
request.NoOperation(display = self.display, onerror = onerror)
def no_operation(self, onerror = None)
Do nothing but send a request to the server.
14.786652
10.148799
1.456985
self.resource_id_lock.acquire() try: i = self.last_resource_id while i in self.resource_ids: i = i + 1 if i > self.info.resource_id_mask: i = 0 if i == self.last_resource_id: raise e...
def allocate_resource_id(self)
id = d.allocate_resource_id() Allocate a new X resource id number ID. Raises ResourceIDError if there are no free resource ids.
2.848173
2.504164
1.137375
self.resource_id_lock.acquire() try: i = rid & self.info.resource_id_mask # Attempting to free a resource id outside our range if rid - i != self.info.resource_id_base: return None try: del self.resource_ids[i] ...
def free_resource_id(self, rid)
d.free_resource_id(rid) Free resource id RID. Attempts to free a resource id which isn't allocated by us are ignored.
4.184465
3.67963
1.137197
if request == -1: return self.parse_connection_setup() # Parse ordinary server response gotreq = 0 while 1: if self.data_recv: # Check the first byte to find out what kind of response it is rtype = byte2int(self.data_recv...
def parse_response(self, request)
Internal method. Parse data received from server. If REQUEST is not None true is returned if the request with that serial number was received, otherwise false is returned. If REQUEST is -1, we're parsing the server connection setup response.
4.567854
4.243788
1.076362
# Only the ConnectionSetupRequest has been sent so far r = self.sent_requests[0] while 1: # print 'data_send:', repr(self.data_send) # print 'data_recv:', repr(self.data_recv) if r._data: alen = r._data['additional_length'] * 4 ...
def parse_connection_setup(self)
Internal function used to parse connection setup response.
4.539482
4.434772
1.023611
modname = _display_mods.get(platform, _default_display_mod) mod = _relative_import(modname) return mod.get_display(display)
def get_display(display)
dname, protocol, host, dno, screen = get_display(display) Parse DISPLAY into its components. If DISPLAY is None, use the default display. The return values are: DNAME -- the full display name (string) PROTOCOL -- the protocol to use (None if automatic) HOST -- the host name (string,...
6.599015
7.248988
0.910336
modname = _socket_mods.get(platform, _default_socket_mod) mod = _relative_import(modname) return mod.get_socket(dname, protocol, host, dno)
def get_socket(dname, protocol, host, dno)
socket = get_socket(dname, protocol, host, dno) Connect to the display specified by DNAME, PROTOCOL, HOST and DNO, which are the corresponding values from a previous call to get_display(). Return SOCKET, a new socket object connected to the X server.
4.52948
5.385047
0.841122
modname = _auth_mods.get(platform, _default_auth_mod) mod = _relative_import(modname) return mod.get_auth(sock, dname, protocol, host, dno)
def get_auth(sock, dname, protocol, host, dno)
auth_name, auth_data = get_auth(sock, dname, protocol, host, dno) Return authentication data for the display on the other side of SOCK, which was opened with DNAME, HOST and DNO, using PROTOCOL. Return AUTH_NAME and AUTH_DATA, two strings to be used in the connection setup request.
4.261369
4.989275
0.854106
RedirectSubwindows(display = self.display, onerror = onerror, opcode = self.display.get_extension_major(extname), window = self, update = update, )
def redirect_subwindows(self, update, onerror = None)
Redirect the hierarchies starting at all current and future children to this window to off-screen storage.
8.793583
9.520165
0.92368
UnredirectWindow(display = self.display, onerror = onerror, opcode = self.display.get_extension_major(extname), window = self, update = update, )
def unredirect_window(self, update, onerror = None)
Stop redirecting this window hierarchy.
8.535438
9.045211
0.943642
RedirectWindow(display = self.display, onerror = onerror, opcode = self.display.get_extension_major(extname), window = self, update = update, )
def unredirect_subwindows(self, update, onerror = None)
Stop redirecting the hierarchies of children to this window.
9.481556
9.411072
1.007489
rid = self.display.allocate_resource_id() CreateRegionFromBorderClip( display = self.display, onerror = onerror, opcode = self.display.get_extension_major(extname), region = rid, window = self, ) # FIXME: create Region object and return it return ri...
def create_region_from_border_clip(self, onerror = None)
Create a region of the border clip of the window, i.e. the area that is not clipped by the parent and any sibling windows.
9.778428
9.073386
1.077704
pid = self.display.allocate_resource_id() NameWindowPixmap(display = self.display, onerror = onerror, opcode = self.display.get_extension_major(extname), window = self, pixmap = pid, ) cls = self....
def name_window_pixmap(self, onerror = None)
Create a new pixmap that refers to the off-screen storage of the window, including its border. This pixmap will remain allocated until freed whatever happens with the window. However, the window will get a new off-screen pixmap every time it is mapped or resized, so to keep track of the contents y...
7.834067
8.047867
0.973434
return GetOverlayWindow(display = self.display, opcode = self.display.get_extension_major(extname), window = self)
def get_overlay_window(self)
Return the overlay window of the root window.
14.186584
12.383705
1.145585
''' select_events(event_masks) event_masks: Sequence of (deviceid, mask) pairs, where deviceid is a numerical device ID, or AllDevices or AllMasterDevices, and mask is either an unsigned integer or sequence of 32 bits unsigned values ''' return XISelectEvents( display=self...
def select_events(self, event_masks)
select_events(event_masks) event_masks: Sequence of (deviceid, mask) pairs, where deviceid is a numerical device ID, or AllDevices or AllMasterDevices, and mask is either an unsigned integer or sequence of 32 bits unsigned values
11.20993
3.531109
3.17462
if isinstance(val, bytes): val = list(iterbytes(val)) slen = len(val) if self.pad: pad = b'\0\0' * (slen % 2) else: pad = b'' return struct.pack('>' + 'H' * slen, *val) + pad, slen, None
def pack_value(self, val)
Convert 8-byte string into 16-byte list
4.172526
3.484579
1.197426
# Emulate Python function argument handling with our field names names = [f.name for f in self.fields \ if isinstance(f, ValueField) and f.name] field_args = dict(zip(names, varargs)) if set(field_args).intersection(keys): dupes = ", ".join(set(field...
def to_binary(self, *varargs, **keys)
data = s.to_binary(...) Convert Python values into the binary representation. The arguments will be all value fields with names, in the order given when the Struct object was instantiated. With one exception: fields with default arguments will be last. Returns the binary repr...
3.487947
3.48501
1.000843
if type(value) is tuple: return self.to_binary(*value) elif isinstance(value, dict): return self.to_binary(**value) elif isinstance(value, DictWrapper): return self.to_binary(**value._data) else: raise BadDataError('%s is not a t...
def pack_value(self, value)
This function allows Struct objects to be used in List and Object fields. Each item represents the arguments to pass to to_binary, either a tuple, a dictionary or a DictWrapper.
4.039486
2.912091
1.387143
ret = {} vno = 0 for f in self.static_fields: # Fields without names should be ignored, and there should # not be any length or format fields if this function # ever gets called. (If there were such fields, there should # be a matching f...
def parse_value(self, val, display, rawdict = 0)
This function is used by List and Object fields to convert Struct objects with no var_fields into Python values.
4.616524
4.29541
1.074757
ret = {} val = struct.unpack(self.static_codes, data[:self.static_size]) lengths = {} formats = {} vno = 0 for f in self.static_fields: # Fields without name should be ignored. This is typically # pad and constant fields i...
def parse_binary(self, data, display, rawdict = 0)
values, remdata = s.parse_binary(data, display, rawdict = 0) Convert a binary representation of the structure into Python values. DATA is a string or a buffer containing the binary data. DISPLAY should be a Xlib.protocol.display.Display object if there are any Resource fields or Lists ...
3.769896
3.694875
1.020304
num = str(dispno).encode() matches = {} for efam, eaddr, enum, ename, edata in self.entries: if efam == family and eaddr == address and num == enum: matches[ename] = edata for t in types: try: return (t, matches[t]) ...
def get_best_auth(self, family, address, dispno, types = ( b"MIT-MAGIC-COOKIE-1", ))
Find an authentication entry matching FAMILY, ADDRESS and DISPNO. The name of the auth scheme must match one of the names in TYPES. If several entries match, the first scheme in TYPES will be choosen. If an entry is found, the tuple (name, data) is returned, otherwise ...
5.342939
3.932907
1.358522
cmd = "{0} {1}".format(sys.executable, path) proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) res = proc.communicate() if proc.returncode: print(res[1].decode()) return proc.returncode
def run_example(path)
Returns returncode of example
2.16017
2.063668
1.046762
'''Load all the keysyms in group. Given a group name such as 'latin1' or 'katakana' load the keysyms defined in module 'Xlib.keysymdef.group-name' into this XK module.''' if '.' in group: raise ValueError('invalid keysym group name: %s' % group) G = globals() #Get a reference to XK.__dict_...
def load_keysym_group(group)
Load all the keysyms in group. Given a group name such as 'latin1' or 'katakana' load the keysyms defined in module 'Xlib.keysymdef.group-name' into this XK module.
5.069004
3.349958
1.513154
'''Translate a keysym (16 bit number) into a python string. This will pass 0 to 0xff as well as XK_BackSpace, XK_Tab, XK_Clear, XK_Return, XK_Pause, XK_Scroll_Lock, XK_Escape, XK_Delete. For other values it returns None.''' # ISO latin 1, LSB is the code if keysym & 0xff00 == 0: return...
def keysym_to_string(keysym)
Translate a keysym (16 bit number) into a python string. This will pass 0 to 0xff as well as XK_BackSpace, XK_Tab, XK_Clear, XK_Return, XK_Pause, XK_Scroll_Lock, XK_Escape, XK_Delete. For other values it returns None.
5.023094
3.05999
1.641539
return _1_0SetScreenConfig( display=self.display, opcode=self.display.get_extension_major(extname), drawable=self, timestamp=timestamp, config_timestamp=config_timestamp, size_id=size_id, rotation=rotation, )
def _1_0set_screen_config(self, size_id, rotation, config_timestamp, timestamp=X.CurrentTime)
Sets the screen to the specified size and rotation.
4.529987
4.937171
0.917527
return SetScreenConfig( display=self.display, opcode=self.display.get_extension_major(extname), drawable=self, timestamp=timestamp, config_timestamp=config_timestamp, size_id=size_id, rotation=rotation, rate=rate, )
def set_screen_config(self, size_id, rotation, config_timestamp, rate=0, timestamp=X.CurrentTime)
Sets the screen to the specified size, rate, rotation and reflection. rate can be 0 to have the server select an appropriate rate.
4.063522
4.986858
0.814846
return GetScreenInfo( display=self.display, opcode=self.display.get_extension_major(extname), window=self, )
def get_screen_info(self)
Retrieve information about the current and available configurations for the screen associated with this window.
12.108055
9.966401
1.214887
return GetScreenSizeRange( display=self.display, opcode=self.display.get_extension_major(extname), window=self, )
def get_screen_size_range(self)
Retrieve the range of possible screen sizes. The screen may be set to any size within this range.
12.11312
12.549331
0.96524
if not list: list.append(element) return lower = 0 upper = len(list) - 1 while lower <= upper: center = (lower + upper) // 2 if element < list[center]: upper = center - 1 elif element > list[center]: lower = center + 1 elif ...
def bin_insert(list, element)
bin_insert(list, element) Insert ELEMENT into LIST. LIST must be sorted, and ELEMENT will be inserted to that LIST remains sorted. If LIST already contains ELEMENT, it will not be duplicated.
1.684077
1.667328
1.010045
from Xlib import display, Xatom import os name = os.path.splitext(os.path.basename(argv[0]))[0] optdb = ResourceDB() leftargv = optdb.getopt(name, argv[1:], options) dname = optdb.get(name + '.display', name + '.Display', None) d = display.Display(dname) rdbstring = d.screen(0)...
def get_display_opts(options, argv = sys.argv)
display, name, db, args = get_display_opts(options, [argv]) Parse X OPTIONS from ARGV (or sys.argv if not provided). Connect to the display specified by a *.display resource if one is set, or to the default X display otherwise. Extract the RESOURCE_MANAGER property and insert all resources from ARGV....
5.710907
4.61398
1.23774
if type(file) is bytes: file = open(file, 'r') self.insert_string(file.read())
def insert_file(self, file)
insert_file(file) Load resources entries from FILE, and insert them into the database. FILE can be a filename (a string)or a file object.
5.048762
4.741319
1.064843
# First split string into lines lines = data.split('\n') while lines: line = lines[0] del lines[0] # Skip empty line if not line: continue # Skip comments if comment_re.match(line): ...
def insert_string(self, data)
insert_string(data) Insert the resources entries in the string DATA into the database.
3.10407
3.039031
1.021401
for res, value in resources: self.insert(res, value)
def insert_resources(self, resources)
insert_resources(resources) Insert all resources entries in the list RESOURCES into the database. Each element in RESOURCES should be a tuple: (resource, value) Where RESOURCE is a string and VALUE can be any Python value.
8.279929
6.513478
1.271199
# Split res into components and bindings parts = resource_parts_re.split(resource) # If the last part is empty, this is an invalid resource # which we simply ignore if parts[-1] == '': return self.lock.acquire() db = self.db for i ...
def insert(self, resource, value)
insert(resource, value) Insert a resource entry into the database. RESOURCE is a string and VALUE can be any Python value.
4.146653
4.110806
1.00872
try: return self[(res, cls)] except KeyError: return default
def get(self, res, cls, default = None)
get(name, class [, default]) Return the value matching the resource identified by NAME and CLASS. If no match is found, DEFAULT is returned, or None if DEFAULT isn't specified.
5.444239
5.332629
1.02093
self.lock.acquire() update_db(self.db, db.db) self.lock.release()
def update(self, db)
update(db) Update this database with all resources entries in the resource database DB.
7.412872
4.869389
1.522341