repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
frmdstryr/enamlx
enamlx/qt/qt_key_event.py
QtKeyEvent.set_keys
def set_keys(self, keys): """ Parse all the key codes and save them """ codes = {} for key in keys: parts = [k.strip().lower() for k in key.split("+")] code = KEYS.get(parts[-1]) modifier = Qt.KeyboardModifiers() if code is None: ra...
python
def set_keys(self, keys): """ Parse all the key codes and save them """ codes = {} for key in keys: parts = [k.strip().lower() for k in key.split("+")] code = KEYS.get(parts[-1]) modifier = Qt.KeyboardModifiers() if code is None: ra...
[ "def", "set_keys", "(", "self", ",", "keys", ")", ":", "codes", "=", "{", "}", "for", "key", "in", "keys", ":", "parts", "=", "[", "k", ".", "strip", "(", ")", ".", "lower", "(", ")", "for", "k", "in", "key", ".", "split", "(", "\"+\"", ")", ...
Parse all the key codes and save them
[ "Parse", "all", "the", "key", "codes", "and", "save", "them" ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_key_event.py#L70-L89
frmdstryr/enamlx
enamlx/widgets/table_view.py
TableView._update_proxy
def _update_proxy(self, change): """ An observer which sends state change to the proxy. """ if change['name'] == 'items': self._update_visible_area() super(TableView, self)._update_proxy(change)
python
def _update_proxy(self, change): """ An observer which sends state change to the proxy. """ if change['name'] == 'items': self._update_visible_area() super(TableView, self)._update_proxy(change)
[ "def", "_update_proxy", "(", "self", ",", "change", ")", ":", "if", "change", "[", "'name'", "]", "==", "'items'", ":", "self", ".", "_update_visible_area", "(", ")", "super", "(", "TableView", ",", "self", ")", ".", "_update_proxy", "(", "change", ")" ]
An observer which sends state change to the proxy.
[ "An", "observer", "which", "sends", "state", "change", "to", "the", "proxy", "." ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/widgets/table_view.py#L63-L69
frmdstryr/enamlx
enamlx/qt/qt_graphics_view.py
FeatureMixin._setup_features
def _setup_features(self): """ Setup the advanced widget feature handlers. """ features = self._features = self.declaration.features if not features: return if features & Feature.FocusTraversal: self.hook_focus_traversal() if features & Feature.Fo...
python
def _setup_features(self): """ Setup the advanced widget feature handlers. """ features = self._features = self.declaration.features if not features: return if features & Feature.FocusTraversal: self.hook_focus_traversal() if features & Feature.Fo...
[ "def", "_setup_features", "(", "self", ")", ":", "features", "=", "self", ".", "_features", "=", "self", ".", "declaration", ".", "features", "if", "not", "features", ":", "return", "if", "features", "&", "Feature", ".", "FocusTraversal", ":", "self", ".",...
Setup the advanced widget feature handlers.
[ "Setup", "the", "advanced", "widget", "feature", "handlers", "." ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_graphics_view.py#L158-L178
frmdstryr/enamlx
enamlx/qt/qt_graphics_view.py
FeatureMixin._teardown_features
def _teardown_features(self): """ Teardowns the advanced widget feature handlers. """ features = self._features if not features: return if features & Feature.FocusTraversal: self.unhook_focus_traversal() if features & Feature.FocusEvents: ...
python
def _teardown_features(self): """ Teardowns the advanced widget feature handlers. """ features = self._features if not features: return if features & Feature.FocusTraversal: self.unhook_focus_traversal() if features & Feature.FocusEvents: ...
[ "def", "_teardown_features", "(", "self", ")", ":", "features", "=", "self", ".", "_features", "if", "not", "features", ":", "return", "if", "features", "&", "Feature", ".", "FocusTraversal", ":", "self", ".", "unhook_focus_traversal", "(", ")", "if", "featu...
Teardowns the advanced widget feature handlers.
[ "Teardowns", "the", "advanced", "widget", "feature", "handlers", "." ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_graphics_view.py#L180-L200
frmdstryr/enamlx
enamlx/qt/qt_graphics_view.py
FeatureMixin.tab_focus_request
def tab_focus_request(self, reason): """ Handle a custom tab focus request. This method is called when focus is being set on the proxy as a result of a user-implemented focus traversal handler. This can be reimplemented by subclasses as needed. Parameters ---------- ...
python
def tab_focus_request(self, reason): """ Handle a custom tab focus request. This method is called when focus is being set on the proxy as a result of a user-implemented focus traversal handler. This can be reimplemented by subclasses as needed. Parameters ---------- ...
[ "def", "tab_focus_request", "(", "self", ",", "reason", ")", ":", "widget", "=", "self", ".", "focus_target", "(", ")", "if", "not", "widget", ".", "focusPolicy", "&", "Qt", ".", "TabFocus", ":", "return", "False", "if", "not", "widget", ".", "isEnabled"...
Handle a custom tab focus request. This method is called when focus is being set on the proxy as a result of a user-implemented focus traversal handler. This can be reimplemented by subclasses as needed. Parameters ---------- reason : Qt.FocusReason The reas...
[ "Handle", "a", "custom", "tab", "focus", "request", "." ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_graphics_view.py#L205-L231
frmdstryr/enamlx
enamlx/qt/qt_graphics_view.py
FeatureMixin.hook_focus_events
def hook_focus_events(self): """ Install the hooks for focus events. This method may be overridden by subclasses as needed. """ widget = self.widget widget.focusInEvent = self.focusInEvent widget.focusOutEvent = self.focusOutEvent
python
def hook_focus_events(self): """ Install the hooks for focus events. This method may be overridden by subclasses as needed. """ widget = self.widget widget.focusInEvent = self.focusInEvent widget.focusOutEvent = self.focusOutEvent
[ "def", "hook_focus_events", "(", "self", ")", ":", "widget", "=", "self", ".", "widget", "widget", ".", "focusInEvent", "=", "self", ".", "focusInEvent", "widget", ".", "focusOutEvent", "=", "self", ".", "focusOutEvent" ]
Install the hooks for focus events. This method may be overridden by subclasses as needed.
[ "Install", "the", "hooks", "for", "focus", "events", "." ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_graphics_view.py#L258-L266
frmdstryr/enamlx
enamlx/qt/qt_graphics_view.py
FeatureMixin.focusNextPrevChild
def focusNextPrevChild(self, next_child): """ The default 'focusNextPrevChild' implementation. """ fd = focus_registry.focused_declaration() if next_child: child = self.declaration.next_focus_child(fd) reason = Qt.TabFocusReason else: child = ...
python
def focusNextPrevChild(self, next_child): """ The default 'focusNextPrevChild' implementation. """ fd = focus_registry.focused_declaration() if next_child: child = self.declaration.next_focus_child(fd) reason = Qt.TabFocusReason else: child = ...
[ "def", "focusNextPrevChild", "(", "self", ",", "next_child", ")", ":", "fd", "=", "focus_registry", ".", "focused_declaration", "(", ")", "if", "next_child", ":", "child", "=", "self", ".", "declaration", ".", "next_focus_child", "(", "fd", ")", "reason", "=...
The default 'focusNextPrevChild' implementation.
[ "The", "default", "focusNextPrevChild", "implementation", "." ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_graphics_view.py#L278-L292
frmdstryr/enamlx
enamlx/qt/qt_graphics_view.py
FeatureMixin.focusInEvent
def focusInEvent(self, event): """ The default 'focusInEvent' implementation. """ widget = self.widget type(widget).focusInEvent(widget, event) self.declaration.focus_gained()
python
def focusInEvent(self, event): """ The default 'focusInEvent' implementation. """ widget = self.widget type(widget).focusInEvent(widget, event) self.declaration.focus_gained()
[ "def", "focusInEvent", "(", "self", ",", "event", ")", ":", "widget", "=", "self", ".", "widget", "type", "(", "widget", ")", ".", "focusInEvent", "(", "widget", ",", "event", ")", "self", ".", "declaration", ".", "focus_gained", "(", ")" ]
The default 'focusInEvent' implementation.
[ "The", "default", "focusInEvent", "implementation", "." ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_graphics_view.py#L294-L300
frmdstryr/enamlx
enamlx/qt/qt_graphics_view.py
FeatureMixin.focusOutEvent
def focusOutEvent(self, event): """ The default 'focusOutEvent' implementation. """ widget = self.widget type(widget).focusOutEvent(widget, event) self.declaration.focus_lost()
python
def focusOutEvent(self, event): """ The default 'focusOutEvent' implementation. """ widget = self.widget type(widget).focusOutEvent(widget, event) self.declaration.focus_lost()
[ "def", "focusOutEvent", "(", "self", ",", "event", ")", ":", "widget", "=", "self", ".", "widget", "type", "(", "widget", ")", ".", "focusOutEvent", "(", "widget", ",", "event", ")", "self", ".", "declaration", ".", "focus_lost", "(", ")" ]
The default 'focusOutEvent' implementation.
[ "The", "default", "focusOutEvent", "implementation", "." ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_graphics_view.py#L302-L308
frmdstryr/enamlx
enamlx/qt/qt_graphics_view.py
FeatureMixin.hook_drag
def hook_drag(self): """ Install the hooks for drag operations. """ widget = self.widget widget.mousePressEvent = self.mousePressEvent widget.mouseMoveEvent = self.mouseMoveEvent widget.mouseReleaseEvent = self.mouseReleaseEvent
python
def hook_drag(self): """ Install the hooks for drag operations. """ widget = self.widget widget.mousePressEvent = self.mousePressEvent widget.mouseMoveEvent = self.mouseMoveEvent widget.mouseReleaseEvent = self.mouseReleaseEvent
[ "def", "hook_drag", "(", "self", ")", ":", "widget", "=", "self", ".", "widget", "widget", ".", "mousePressEvent", "=", "self", ".", "mousePressEvent", "widget", ".", "mouseMoveEvent", "=", "self", ".", "mouseMoveEvent", "widget", ".", "mouseReleaseEvent", "="...
Install the hooks for drag operations.
[ "Install", "the", "hooks", "for", "drag", "operations", "." ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_graphics_view.py#L310-L317
frmdstryr/enamlx
enamlx/qt/qt_graphics_view.py
FeatureMixin.unhook_drag
def unhook_drag(self): """ Remove the hooks for drag operations. """ widget = self.widget del widget.mousePressEvent del widget.mouseMoveEvent del widget.mouseReleaseEvent
python
def unhook_drag(self): """ Remove the hooks for drag operations. """ widget = self.widget del widget.mousePressEvent del widget.mouseMoveEvent del widget.mouseReleaseEvent
[ "def", "unhook_drag", "(", "self", ")", ":", "widget", "=", "self", ".", "widget", "del", "widget", ".", "mousePressEvent", "del", "widget", ".", "mouseMoveEvent", "del", "widget", ".", "mouseReleaseEvent" ]
Remove the hooks for drag operations.
[ "Remove", "the", "hooks", "for", "drag", "operations", "." ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_graphics_view.py#L319-L326
frmdstryr/enamlx
enamlx/qt/qt_graphics_view.py
FeatureMixin.mousePressEvent
def mousePressEvent(self, event): """ Handle the mouse press event for a drag operation. """ if event.button() == Qt.LeftButton: self._drag_origin = event.pos() widget = self.widget type(widget).mousePressEvent(widget, event)
python
def mousePressEvent(self, event): """ Handle the mouse press event for a drag operation. """ if event.button() == Qt.LeftButton: self._drag_origin = event.pos() widget = self.widget type(widget).mousePressEvent(widget, event)
[ "def", "mousePressEvent", "(", "self", ",", "event", ")", ":", "if", "event", ".", "button", "(", ")", "==", "Qt", ".", "LeftButton", ":", "self", ".", "_drag_origin", "=", "event", ".", "pos", "(", ")", "widget", "=", "self", ".", "widget", "type", ...
Handle the mouse press event for a drag operation.
[ "Handle", "the", "mouse", "press", "event", "for", "a", "drag", "operation", "." ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_graphics_view.py#L328-L335
frmdstryr/enamlx
enamlx/qt/qt_graphics_view.py
FeatureMixin.mouseMoveEvent
def mouseMoveEvent(self, event): """ Handle the mouse move event for a drag operation. """ #if event.buttons() & Qt.LeftButton and self._drag_origin is not None: #dist = (event.pos() - self._drag_origin).manhattanLength() #if dist >= QApplication.startDragDistance(): ...
python
def mouseMoveEvent(self, event): """ Handle the mouse move event for a drag operation. """ #if event.buttons() & Qt.LeftButton and self._drag_origin is not None: #dist = (event.pos() - self._drag_origin).manhattanLength() #if dist >= QApplication.startDragDistance(): ...
[ "def", "mouseMoveEvent", "(", "self", ",", "event", ")", ":", "#if event.buttons() & Qt.LeftButton and self._drag_origin is not None:", "#dist = (event.pos() - self._drag_origin).manhattanLength()", "#if dist >= QApplication.startDragDistance():", "#self.do_drag(event.widget())", "#self._dra...
Handle the mouse move event for a drag operation.
[ "Handle", "the", "mouse", "move", "event", "for", "a", "drag", "operation", "." ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_graphics_view.py#L337-L348
frmdstryr/enamlx
enamlx/qt/qt_graphics_view.py
FeatureMixin.mouseReleaseEvent
def mouseReleaseEvent(self, event): """ Handle the mouse release event for the drag operation. """ if event.button() == Qt.LeftButton: self._drag_origin = None widget = self.widget type(widget).mouseReleaseEvent(widget, event)
python
def mouseReleaseEvent(self, event): """ Handle the mouse release event for the drag operation. """ if event.button() == Qt.LeftButton: self._drag_origin = None widget = self.widget type(widget).mouseReleaseEvent(widget, event)
[ "def", "mouseReleaseEvent", "(", "self", ",", "event", ")", ":", "if", "event", ".", "button", "(", ")", "==", "Qt", ".", "LeftButton", ":", "self", ".", "_drag_origin", "=", "None", "widget", "=", "self", ".", "widget", "type", "(", "widget", ")", "...
Handle the mouse release event for the drag operation.
[ "Handle", "the", "mouse", "release", "event", "for", "the", "drag", "operation", "." ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_graphics_view.py#L350-L357
frmdstryr/enamlx
enamlx/qt/qt_graphics_view.py
FeatureMixin.hook_drop
def hook_drop(self): """ Install hooks for drop operations. """ widget = self.widget widget.setAcceptDrops(True) widget.dragEnterEvent = self.dragEnterEvent widget.dragMoveEvent = self.dragMoveEvent widget.dragLeaveEvent = self.dragLeaveEvent widget.dropE...
python
def hook_drop(self): """ Install hooks for drop operations. """ widget = self.widget widget.setAcceptDrops(True) widget.dragEnterEvent = self.dragEnterEvent widget.dragMoveEvent = self.dragMoveEvent widget.dragLeaveEvent = self.dragLeaveEvent widget.dropE...
[ "def", "hook_drop", "(", "self", ")", ":", "widget", "=", "self", ".", "widget", "widget", ".", "setAcceptDrops", "(", "True", ")", "widget", ".", "dragEnterEvent", "=", "self", ".", "dragEnterEvent", "widget", ".", "dragMoveEvent", "=", "self", ".", "drag...
Install hooks for drop operations.
[ "Install", "hooks", "for", "drop", "operations", "." ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_graphics_view.py#L359-L368
frmdstryr/enamlx
enamlx/qt/qt_graphics_view.py
FeatureMixin.unhook_drop
def unhook_drop(self): """ Remove hooks for drop operations. """ widget = self.widget widget.setAcceptDrops(False) del widget.dragEnterEvent del widget.dragMoveEvent del widget.dragLeaveEvent del widget.dropEvent
python
def unhook_drop(self): """ Remove hooks for drop operations. """ widget = self.widget widget.setAcceptDrops(False) del widget.dragEnterEvent del widget.dragMoveEvent del widget.dragLeaveEvent del widget.dropEvent
[ "def", "unhook_drop", "(", "self", ")", ":", "widget", "=", "self", ".", "widget", "widget", ".", "setAcceptDrops", "(", "False", ")", "del", "widget", ".", "dragEnterEvent", "del", "widget", ".", "dragMoveEvent", "del", "widget", ".", "dragLeaveEvent", "del...
Remove hooks for drop operations.
[ "Remove", "hooks", "for", "drop", "operations", "." ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_graphics_view.py#L370-L379
frmdstryr/enamlx
enamlx/qt/qt_graphics_view.py
FeatureMixin.do_drag
def do_drag(self, widget): """ Perform the drag operation for the widget. Parameters ---------- widget: QWidget A reference to the viewport widget. """ drag_data = self.declaration.drag_start() if drag_data is None: return ...
python
def do_drag(self, widget): """ Perform the drag operation for the widget. Parameters ---------- widget: QWidget A reference to the viewport widget. """ drag_data = self.declaration.drag_start() if drag_data is None: return ...
[ "def", "do_drag", "(", "self", ",", "widget", ")", ":", "drag_data", "=", "self", ".", "declaration", ".", "drag_start", "(", ")", "if", "drag_data", "is", "None", ":", "return", "#widget = self.widget", "qdrag", "=", "QDrag", "(", "widget", ")", "qdrag", ...
Perform the drag operation for the widget. Parameters ---------- widget: QWidget A reference to the viewport widget.
[ "Perform", "the", "drag", "operation", "for", "the", "widget", ".", "Parameters", "----------", "widget", ":", "QWidget", "A", "reference", "to", "the", "viewport", "widget", "." ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_graphics_view.py#L381-L412
frmdstryr/enamlx
enamlx/qt/qt_graphics_view.py
FeatureMixin.draw
def draw(self, painter, options, widget): """ Handle the draw event for the widget. """ self.declaration.draw(painter, options, widget)
python
def draw(self, painter, options, widget): """ Handle the draw event for the widget. """ self.declaration.draw(painter, options, widget)
[ "def", "draw", "(", "self", ",", "painter", ",", "options", ",", "widget", ")", ":", "self", ".", "declaration", ".", "draw", "(", "painter", ",", "options", ",", "widget", ")" ]
Handle the draw event for the widget.
[ "Handle", "the", "draw", "event", "for", "the", "widget", "." ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_graphics_view.py#L477-L481
frmdstryr/enamlx
enamlx/qt/qt_graphics_view.py
FeatureMixin.get_action
def get_action(self, create=False): """ Get the shared widget action for this widget. This API is used to support widgets in tool bars and menus. Parameters ---------- create : bool, optional Whether to create the action if it doesn't already exist. The ...
python
def get_action(self, create=False): """ Get the shared widget action for this widget. This API is used to support widgets in tool bars and menus. Parameters ---------- create : bool, optional Whether to create the action if it doesn't already exist. The ...
[ "def", "get_action", "(", "self", ",", "create", "=", "False", ")", ":", "action", "=", "self", ".", "_widget_action", "if", "action", "is", "None", "and", "create", ":", "action", "=", "self", ".", "_widget_action", "=", "QWidgetAction", "(", "None", ")...
Get the shared widget action for this widget. This API is used to support widgets in tool bars and menus. Parameters ---------- create : bool, optional Whether to create the action if it doesn't already exist. The default is False. Returns -----...
[ "Get", "the", "shared", "widget", "action", "for", "this", "widget", "." ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_graphics_view.py#L486-L507
frmdstryr/enamlx
enamlx/qt/qt_graphics_view.py
QtGraphicsView.mousePressEvent
def mousePressEvent(self, event): """ Handle the mouse press event for a drag operation. """ self.declaration.mouse_press_event(event) super(QtGraphicsView, self).mousePressEvent(event)
python
def mousePressEvent(self, event): """ Handle the mouse press event for a drag operation. """ self.declaration.mouse_press_event(event) super(QtGraphicsView, self).mousePressEvent(event)
[ "def", "mousePressEvent", "(", "self", ",", "event", ")", ":", "self", ".", "declaration", ".", "mouse_press_event", "(", "event", ")", "super", "(", "QtGraphicsView", ",", "self", ")", ".", "mousePressEvent", "(", "event", ")" ]
Handle the mouse press event for a drag operation.
[ "Handle", "the", "mouse", "press", "event", "for", "a", "drag", "operation", "." ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_graphics_view.py#L638-L643
frmdstryr/enamlx
enamlx/qt/qt_graphics_view.py
QtGraphicsView.mouseMoveEvent
def mouseMoveEvent(self, event): """ Handle the mouse move event for a drag operation. """ self.declaration.mouse_move_event(event) super(QtGraphicsView, self).mouseMoveEvent(event)
python
def mouseMoveEvent(self, event): """ Handle the mouse move event for a drag operation. """ self.declaration.mouse_move_event(event) super(QtGraphicsView, self).mouseMoveEvent(event)
[ "def", "mouseMoveEvent", "(", "self", ",", "event", ")", ":", "self", ".", "declaration", ".", "mouse_move_event", "(", "event", ")", "super", "(", "QtGraphicsView", ",", "self", ")", ".", "mouseMoveEvent", "(", "event", ")" ]
Handle the mouse move event for a drag operation.
[ "Handle", "the", "mouse", "move", "event", "for", "a", "drag", "operation", "." ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_graphics_view.py#L645-L650
frmdstryr/enamlx
enamlx/qt/qt_graphics_view.py
QtGraphicsView.mouseReleaseEvent
def mouseReleaseEvent(self, event): """ Handle the mouse release event for the drag operation. """ self.declaration.mouse_release_event(event) super(QtGraphicsView, self).mouseReleaseEvent(event)
python
def mouseReleaseEvent(self, event): """ Handle the mouse release event for the drag operation. """ self.declaration.mouse_release_event(event) super(QtGraphicsView, self).mouseReleaseEvent(event)
[ "def", "mouseReleaseEvent", "(", "self", ",", "event", ")", ":", "self", ".", "declaration", ".", "mouse_release_event", "(", "event", ")", "super", "(", "QtGraphicsView", ",", "self", ")", ".", "mouseReleaseEvent", "(", "event", ")" ]
Handle the mouse release event for the drag operation.
[ "Handle", "the", "mouse", "release", "event", "for", "the", "drag", "operation", "." ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_graphics_view.py#L653-L658
frmdstryr/enamlx
enamlx/qt/qt_graphics_view.py
QtGraphicsView.set_renderer
def set_renderer(self, renderer): """ Set the viewport widget. """ viewport = None if renderer == 'opengl': from enaml.qt.QtWidgets import QOpenGLWidget viewport = QOpenGLWidget() elif renderer == 'default': try: from ...
python
def set_renderer(self, renderer): """ Set the viewport widget. """ viewport = None if renderer == 'opengl': from enaml.qt.QtWidgets import QOpenGLWidget viewport = QOpenGLWidget() elif renderer == 'default': try: from ...
[ "def", "set_renderer", "(", "self", ",", "renderer", ")", ":", "viewport", "=", "None", "if", "renderer", "==", "'opengl'", ":", "from", "enaml", ".", "qt", ".", "QtWidgets", "import", "QOpenGLWidget", "viewport", "=", "QOpenGLWidget", "(", ")", "elif", "r...
Set the viewport widget.
[ "Set", "the", "viewport", "widget", "." ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_graphics_view.py#L674-L689
frmdstryr/enamlx
enamlx/qt/qt_graphics_view.py
QtGraphicsView.on_selection_changed
def on_selection_changed(self): """ Callback invoked one the selection has changed. """ d = self.declaration selection = self.scene.selectedItems() self._guards |= 0x01 try: d.selected_items = [item.ref().declaration for item in selection ...
python
def on_selection_changed(self): """ Callback invoked one the selection has changed. """ d = self.declaration selection = self.scene.selectedItems() self._guards |= 0x01 try: d.selected_items = [item.ref().declaration for item in selection ...
[ "def", "on_selection_changed", "(", "self", ")", ":", "d", "=", "self", ".", "declaration", "selection", "=", "self", ".", "scene", ".", "selectedItems", "(", ")", "self", ".", "_guards", "|=", "0x01", "try", ":", "d", ".", "selected_items", "=", "[", ...
Callback invoked one the selection has changed.
[ "Callback", "invoked", "one", "the", "selection", "has", "changed", "." ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_graphics_view.py#L698-L709
frmdstryr/enamlx
enamlx/qt/qt_graphics_view.py
QtGraphicsView.set_background
def set_background(self, background): """ Set the background color of the widget. """ scene = self.scene scene.setBackgroundBrush(QColor.fromRgba(background.argb))
python
def set_background(self, background): """ Set the background color of the widget. """ scene = self.scene scene.setBackgroundBrush(QColor.fromRgba(background.argb))
[ "def", "set_background", "(", "self", ",", "background", ")", ":", "scene", "=", "self", ".", "scene", "scene", ".", "setBackgroundBrush", "(", "QColor", ".", "fromRgba", "(", "background", ".", "argb", ")", ")" ]
Set the background color of the widget.
[ "Set", "the", "background", "color", "of", "the", "widget", "." ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_graphics_view.py#L711-L716
frmdstryr/enamlx
enamlx/qt/qt_graphics_view.py
QtGraphicsView.scale_view
def scale_view(self, x, y): """ Scale the zoom but keep in in the min and max zoom bounds. """ d = self.declaration factor = self.widget.transform().scale(x, y).mapRect( QRectF(0, 0, 1, 1)).width() if (d.min_zoom > factor > d.max_zoom): return sel...
python
def scale_view(self, x, y): """ Scale the zoom but keep in in the min and max zoom bounds. """ d = self.declaration factor = self.widget.transform().scale(x, y).mapRect( QRectF(0, 0, 1, 1)).width() if (d.min_zoom > factor > d.max_zoom): return sel...
[ "def", "scale_view", "(", "self", ",", "x", ",", "y", ")", ":", "d", "=", "self", ".", "declaration", "factor", "=", "self", ".", "widget", ".", "transform", "(", ")", ".", "scale", "(", "x", ",", "y", ")", ".", "mapRect", "(", "QRectF", "(", "...
Scale the zoom but keep in in the min and max zoom bounds.
[ "Scale", "the", "zoom", "but", "keep", "in", "in", "the", "min", "and", "max", "zoom", "bounds", "." ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_graphics_view.py#L748-L758
frmdstryr/enamlx
enamlx/qt/qt_graphics_view.py
QtGraphicsItem.destroy
def destroy(self): """ Destroy the underlying QWidget object. """ self._teardown_features() focus_registry.unregister(self.widget) widget = self.widget if widget is not None: del self.widget super(QtGraphicsItem, self).destroy() # If a QWidget...
python
def destroy(self): """ Destroy the underlying QWidget object. """ self._teardown_features() focus_registry.unregister(self.widget) widget = self.widget if widget is not None: del self.widget super(QtGraphicsItem, self).destroy() # If a QWidget...
[ "def", "destroy", "(", "self", ")", ":", "self", ".", "_teardown_features", "(", ")", "focus_registry", ".", "unregister", "(", "self", ".", "widget", ")", "widget", "=", "self", ".", "widget", "if", "widget", "is", "not", "None", ":", "del", "self", "...
Destroy the underlying QWidget object.
[ "Destroy", "the", "underlying", "QWidget", "object", "." ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_graphics_view.py#L830-L845
frmdstryr/enamlx
enamlx/qt/qt_graphics_view.py
QtGraphicsItem.parent_widget
def parent_widget(self): """ Reimplemented to only return GraphicsItems """ parent = self.parent() if parent is not None and isinstance(parent, QtGraphicsItem): return parent.widget
python
def parent_widget(self): """ Reimplemented to only return GraphicsItems """ parent = self.parent() if parent is not None and isinstance(parent, QtGraphicsItem): return parent.widget
[ "def", "parent_widget", "(", "self", ")", ":", "parent", "=", "self", ".", "parent", "(", ")", "if", "parent", "is", "not", "None", "and", "isinstance", "(", "parent", ",", "QtGraphicsItem", ")", ":", "return", "parent", ".", "widget" ]
Reimplemented to only return GraphicsItems
[ "Reimplemented", "to", "only", "return", "GraphicsItems" ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_graphics_view.py#L847-L851
frmdstryr/enamlx
enamlx/qt/qt_graphics_view.py
QtGraphicsWidget.init_layout
def init_layout(self): """ Create the widget in the layout pass after the child widget has been created and intialized. We do this so the child widget does not attempt to use this proxy widget as its parent and because repositioning must be done after the widget is set. """ ...
python
def init_layout(self): """ Create the widget in the layout pass after the child widget has been created and intialized. We do this so the child widget does not attempt to use this proxy widget as its parent and because repositioning must be done after the widget is set. """ ...
[ "def", "init_layout", "(", "self", ")", ":", "self", ".", "widget", "=", "QGraphicsProxyWidget", "(", "self", ".", "parent_widget", "(", ")", ")", "widget", "=", "self", ".", "widget", "for", "item", "in", "self", ".", "child_widgets", "(", ")", ":", "...
Create the widget in the layout pass after the child widget has been created and intialized. We do this so the child widget does not attempt to use this proxy widget as its parent and because repositioning must be done after the widget is set.
[ "Create", "the", "widget", "in", "the", "layout", "pass", "after", "the", "child", "widget", "has", "been", "created", "and", "intialized", ".", "We", "do", "this", "so", "the", "child", "widget", "does", "not", "attempt", "to", "use", "this", "proxy", "...
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_graphics_view.py#L937-L949
frmdstryr/enamlx
examples/occ_viewer/occ/occ_algo.py
OccOperation._dequeue_update
def _dequeue_update(self,change): """ Only update when all changes are done """ self._update_count -=1 if self._update_count !=0: return self.update_shape(change)
python
def _dequeue_update(self,change): """ Only update when all changes are done """ self._update_count -=1 if self._update_count !=0: return self.update_shape(change)
[ "def", "_dequeue_update", "(", "self", ",", "change", ")", ":", "self", ".", "_update_count", "-=", "1", "if", "self", ".", "_update_count", "!=", "0", ":", "return", "self", ".", "update_shape", "(", "change", ")" ]
Only update when all changes are done
[ "Only", "update", "when", "all", "changes", "are", "done" ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/examples/occ_viewer/occ/occ_algo.py#L72-L77
frmdstryr/enamlx
examples/occ_viewer/occ/occ_algo.py
OccBooleanOperation.create_shape
def create_shape(self): """ Create the toolkit shape for the proxy object. This method is called during the top-down pass, just before the 'init_shape()' method is called. This method should create the toolkit widget and assign it to the 'widget' attribute. """ ...
python
def create_shape(self): """ Create the toolkit shape for the proxy object. This method is called during the top-down pass, just before the 'init_shape()' method is called. This method should create the toolkit widget and assign it to the 'widget' attribute. """ ...
[ "def", "create_shape", "(", "self", ")", ":", "d", "=", "self", ".", "declaration", "if", "d", ".", "shape1", "and", "d", ".", "shape2", ":", "self", ".", "shape", "=", "self", ".", "_do_operation", "(", "d", ".", "shape1", ",", "d", ".", "shape2",...
Create the toolkit shape for the proxy object. This method is called during the top-down pass, just before the 'init_shape()' method is called. This method should create the toolkit widget and assign it to the 'widget' attribute.
[ "Create", "the", "toolkit", "shape", "for", "the", "proxy", "object", ".", "This", "method", "is", "called", "during", "the", "top", "-", "down", "pass", "just", "before", "the", "init_shape", "()", "method", "is", "called", ".", "This", "method", "should"...
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/examples/occ_viewer/occ/occ_algo.py#L87-L99
frmdstryr/enamlx
enamlx/widgets/graphics_view.py
GraphicsItem.show
def show(self): """ Ensure the widget is shown. Calling this method will also set the widget visibility to True. """ self.visible = True if self.proxy_is_active: self.proxy.ensure_visible()
python
def show(self): """ Ensure the widget is shown. Calling this method will also set the widget visibility to True. """ self.visible = True if self.proxy_is_active: self.proxy.ensure_visible()
[ "def", "show", "(", "self", ")", ":", "self", ".", "visible", "=", "True", "if", "self", ".", "proxy_is_active", ":", "self", ".", "proxy", ".", "ensure_visible", "(", ")" ]
Ensure the widget is shown. Calling this method will also set the widget visibility to True.
[ "Ensure", "the", "widget", "is", "shown", ".", "Calling", "this", "method", "will", "also", "set", "the", "widget", "visibility", "to", "True", "." ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/widgets/graphics_view.py#L448-L454
frmdstryr/enamlx
enamlx/widgets/graphics_view.py
GraphicsItem.hide
def hide(self): """ Ensure the widget is hidden. Calling this method will also set the widget visibility to False. """ self.visible = False if self.proxy_is_active: self.proxy.ensure_hidden()
python
def hide(self): """ Ensure the widget is hidden. Calling this method will also set the widget visibility to False. """ self.visible = False if self.proxy_is_active: self.proxy.ensure_hidden()
[ "def", "hide", "(", "self", ")", ":", "self", ".", "visible", "=", "False", "if", "self", ".", "proxy_is_active", ":", "self", ".", "proxy", ".", "ensure_hidden", "(", ")" ]
Ensure the widget is hidden. Calling this method will also set the widget visibility to False.
[ "Ensure", "the", "widget", "is", "hidden", ".", "Calling", "this", "method", "will", "also", "set", "the", "widget", "visibility", "to", "False", "." ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/widgets/graphics_view.py#L456-L462
frmdstryr/enamlx
enamlx/widgets/graphics_view.py
GraphicsView.get_item_at
def get_item_at(self, *args, **kwargs): """ Return the items at the given position """ return self.proxy.get_item_at(coerce_point(*args, **kwargs))
python
def get_item_at(self, *args, **kwargs): """ Return the items at the given position """ return self.proxy.get_item_at(coerce_point(*args, **kwargs))
[ "def", "get_item_at", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "proxy", ".", "get_item_at", "(", "coerce_point", "(", "*", "args", ",", "*", "*", "kwargs", ")", ")" ]
Return the items at the given position
[ "Return", "the", "items", "at", "the", "given", "position" ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/widgets/graphics_view.py#L795-L797
frmdstryr/enamlx
enamlx/widgets/graphics_view.py
GraphicsView.center_on
def center_on(self, item): """ Center on the given item or point. """ if not isinstance(item, GraphicsItem): item = coerce_point(item) self.proxy.center_on(item)
python
def center_on(self, item): """ Center on the given item or point. """ if not isinstance(item, GraphicsItem): item = coerce_point(item) self.proxy.center_on(item)
[ "def", "center_on", "(", "self", ",", "item", ")", ":", "if", "not", "isinstance", "(", "item", ",", "GraphicsItem", ")", ":", "item", "=", "coerce_point", "(", "item", ")", "self", ".", "proxy", ".", "center_on", "(", "item", ")" ]
Center on the given item or point.
[ "Center", "on", "the", "given", "item", "or", "point", "." ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/widgets/graphics_view.py#L803-L807
frmdstryr/enamlx
enamlx/core/middleware.py
_custom_token_stream
def _custom_token_stream(self): """ A wrapper for the BaseEnamlLexer's make_token_stream which allows the stream to be customized by adding "token_stream_processors". A token_stream_processor is a generator function which takes the token_stream as it's single input argument and yields each process...
python
def _custom_token_stream(self): """ A wrapper for the BaseEnamlLexer's make_token_stream which allows the stream to be customized by adding "token_stream_processors". A token_stream_processor is a generator function which takes the token_stream as it's single input argument and yields each process...
[ "def", "_custom_token_stream", "(", "self", ")", ":", "token_stream", "=", "default_make_token_stream", "(", "self", ")", "for", "processor", "in", "_token_stream_processors", ":", "token_stream", "=", "processor", "(", "token_stream", ")", "return", "token_stream" ]
A wrapper for the BaseEnamlLexer's make_token_stream which allows the stream to be customized by adding "token_stream_processors". A token_stream_processor is a generator function which takes the token_stream as it's single input argument and yields each processed token as it's output. Each token...
[ "A", "wrapper", "for", "the", "BaseEnamlLexer", "s", "make_token_stream", "which", "allows", "the", "stream", "to", "be", "customized", "by", "adding", "token_stream_processors", ".", "A", "token_stream_processor", "is", "a", "generator", "function", "which", "takes...
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/core/middleware.py#L15-L27
frmdstryr/enamlx
enamlx/core/middleware.py
convert_enamldef_def_to_func
def convert_enamldef_def_to_func(token_stream): """ A token stream processor which processes all enaml declarative functions to allow using `def` instead of `func`. It does this by transforming DEF tokens to NAME within enamldef blocks and then changing the token value to `func`. Notes -...
python
def convert_enamldef_def_to_func(token_stream): """ A token stream processor which processes all enaml declarative functions to allow using `def` instead of `func`. It does this by transforming DEF tokens to NAME within enamldef blocks and then changing the token value to `func`. Notes -...
[ "def", "convert_enamldef_def_to_func", "(", "token_stream", ")", ":", "in_enamldef", "=", "False", "depth", "=", "0", "for", "tok", "in", "token_stream", ":", "if", "tok", ".", "type", "==", "'ENAMLDEF'", ":", "in_enamldef", "=", "True", "elif", "tok", ".", ...
A token stream processor which processes all enaml declarative functions to allow using `def` instead of `func`. It does this by transforming DEF tokens to NAME within enamldef blocks and then changing the token value to `func`. Notes ------ Use this at your own risk! This was a feature...
[ "A", "token", "stream", "processor", "which", "processes", "all", "enaml", "declarative", "functions", "to", "allow", "using", "def", "instead", "of", "func", ".", "It", "does", "this", "by", "transforming", "DEF", "tokens", "to", "NAME", "within", "enamldef",...
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/core/middleware.py#L65-L95
frmdstryr/enamlx
enamlx/widgets/abstract_item_view.py
AbstractItemView.child_added
def child_added(self, child): """ Reset the item cache when a child is added """ super(AbstractItemView, self).child_added(child) self.get_member('_items').reset(self)
python
def child_added(self, child): """ Reset the item cache when a child is added """ super(AbstractItemView, self).child_added(child) self.get_member('_items').reset(self)
[ "def", "child_added", "(", "self", ",", "child", ")", ":", "super", "(", "AbstractItemView", ",", "self", ")", ".", "child_added", "(", "child", ")", "self", ".", "get_member", "(", "'_items'", ")", ".", "reset", "(", "self", ")" ]
Reset the item cache when a child is added
[ "Reset", "the", "item", "cache", "when", "a", "child", "is", "added" ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/widgets/abstract_item_view.py#L189-L192
frmdstryr/enamlx
enamlx/widgets/abstract_item_view.py
AbstractItemView.child_removed
def child_removed(self, child): """ Reset the item cache when a child is removed """ super(AbstractItemView, self).child_removed(child) self.get_member('_items').reset(self)
python
def child_removed(self, child): """ Reset the item cache when a child is removed """ super(AbstractItemView, self).child_removed(child) self.get_member('_items').reset(self)
[ "def", "child_removed", "(", "self", ",", "child", ")", ":", "super", "(", "AbstractItemView", ",", "self", ")", ".", "child_removed", "(", "child", ")", "self", ".", "get_member", "(", "'_items'", ")", ".", "reset", "(", "self", ")" ]
Reset the item cache when a child is removed
[ "Reset", "the", "item", "cache", "when", "a", "child", "is", "removed" ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/widgets/abstract_item_view.py#L194-L197
frmdstryr/enamlx
enamlx/widgets/abstract_item.py
AbstractWidgetItemGroup.child_added
def child_added(self, child): """ Reset the item cache when a child is added """ super(AbstractWidgetItemGroup, self).child_added(child) self.get_member('_items').reset(self)
python
def child_added(self, child): """ Reset the item cache when a child is added """ super(AbstractWidgetItemGroup, self).child_added(child) self.get_member('_items').reset(self)
[ "def", "child_added", "(", "self", ",", "child", ")", ":", "super", "(", "AbstractWidgetItemGroup", ",", "self", ")", ".", "child_added", "(", "child", ")", "self", ".", "get_member", "(", "'_items'", ")", ".", "reset", "(", "self", ")" ]
Reset the item cache when a child is added
[ "Reset", "the", "item", "cache", "when", "a", "child", "is", "added" ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/widgets/abstract_item.py#L78-L81
frmdstryr/enamlx
enamlx/widgets/abstract_item.py
AbstractWidgetItemGroup.child_removed
def child_removed(self, child): """ Reset the item cache when a child is removed """ super(AbstractWidgetItemGroup, self).child_removed(child) self.get_member('_items').reset(self)
python
def child_removed(self, child): """ Reset the item cache when a child is removed """ super(AbstractWidgetItemGroup, self).child_removed(child) self.get_member('_items').reset(self)
[ "def", "child_removed", "(", "self", ",", "child", ")", ":", "super", "(", "AbstractWidgetItemGroup", ",", "self", ")", ".", "child_removed", "(", "child", ")", "self", ".", "get_member", "(", "'_items'", ")", ".", "reset", "(", "self", ")" ]
Reset the item cache when a child is removed
[ "Reset", "the", "item", "cache", "when", "a", "child", "is", "removed" ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/widgets/abstract_item.py#L83-L86
frmdstryr/enamlx
enamlx/widgets/abstract_item.py
AbstractWidgetItem._update_proxy
def _update_proxy(self, change): """ An observer which sends state change to the proxy. """ if change['name'] in ['row', 'column']: super(AbstractWidgetItem, self)._update_proxy(change) else: self.proxy.data_changed(change)
python
def _update_proxy(self, change): """ An observer which sends state change to the proxy. """ if change['name'] in ['row', 'column']: super(AbstractWidgetItem, self)._update_proxy(change) else: self.proxy.data_changed(change)
[ "def", "_update_proxy", "(", "self", ",", "change", ")", ":", "if", "change", "[", "'name'", "]", "in", "[", "'row'", ",", "'column'", "]", ":", "super", "(", "AbstractWidgetItem", ",", "self", ")", ".", "_update_proxy", "(", "change", ")", "else", ":"...
An observer which sends state change to the proxy.
[ "An", "observer", "which", "sends", "state", "change", "to", "the", "proxy", "." ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/widgets/abstract_item.py#L136-L142
frmdstryr/enamlx
enamlx/qt/qt_console.py
QtConsole.init_signal
def init_signal(self): """allow clean shutdown on sigint""" signal.signal(signal.SIGINT, lambda sig, frame: self.exit(-2)) # need a timer, so that QApplication doesn't block until a real # Qt event fires (can require mouse movement) # timer trick from http://stackoverflow.co...
python
def init_signal(self): """allow clean shutdown on sigint""" signal.signal(signal.SIGINT, lambda sig, frame: self.exit(-2)) # need a timer, so that QApplication doesn't block until a real # Qt event fires (can require mouse movement) # timer trick from http://stackoverflow.co...
[ "def", "init_signal", "(", "self", ")", ":", "signal", ".", "signal", "(", "signal", ".", "SIGINT", ",", "lambda", "sig", ",", "frame", ":", "self", ".", "exit", "(", "-", "2", ")", ")", "# need a timer, so that QApplication doesn't block until a real\r", "# Q...
allow clean shutdown on sigint
[ "allow", "clean", "shutdown", "on", "sigint" ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_console.py#L84-L95
frmdstryr/enamlx
examples/occ_viewer/occ/shape.py
Shape._update_position
def _update_position(self, change): """ Keep position in sync with x,y,z """ if change['type']!='update': return pt = gp_Pnt(self.x,self.y,self.z) if not pt.IsEqual(self.position,self.tolerance): self.position = pt
python
def _update_position(self, change): """ Keep position in sync with x,y,z """ if change['type']!='update': return pt = gp_Pnt(self.x,self.y,self.z) if not pt.IsEqual(self.position,self.tolerance): self.position = pt
[ "def", "_update_position", "(", "self", ",", "change", ")", ":", "if", "change", "[", "'type'", "]", "!=", "'update'", ":", "return", "pt", "=", "gp_Pnt", "(", "self", ".", "x", ",", "self", ".", "y", ",", "self", ".", "z", ")", "if", "not", "pt"...
Keep position in sync with x,y,z
[ "Keep", "position", "in", "sync", "with", "x", "y", "z" ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/examples/occ_viewer/occ/shape.py#L229-L235
frmdstryr/enamlx
examples/occ_viewer/occ/shape.py
Shape._update_xyz
def _update_xyz(self, change): """ Keep x,y,z in sync with position """ self.x,self.y,self.z = self.position.X(),self.position.Y(),self.position.Z()
python
def _update_xyz(self, change): """ Keep x,y,z in sync with position """ self.x,self.y,self.z = self.position.X(),self.position.Y(),self.position.Z()
[ "def", "_update_xyz", "(", "self", ",", "change", ")", ":", "self", ".", "x", ",", "self", ".", "y", ",", "self", ".", "z", "=", "self", ".", "position", ".", "X", "(", ")", ",", "self", ".", "position", ".", "Y", "(", ")", ",", "self", ".", ...
Keep x,y,z in sync with position
[ "Keep", "x", "y", "z", "in", "sync", "with", "position" ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/examples/occ_viewer/occ/shape.py#L238-L240
frmdstryr/enamlx
examples/occ_viewer/occ/shape.py
Shape._update_state
def _update_state(self, change): """ Keep position and direction in sync with axis """ self._block_updates = True try: self.position = self.axis.Location() self.direction = self.axis.Direction() finally: self._block_updates = False
python
def _update_state(self, change): """ Keep position and direction in sync with axis """ self._block_updates = True try: self.position = self.axis.Location() self.direction = self.axis.Direction() finally: self._block_updates = False
[ "def", "_update_state", "(", "self", ",", "change", ")", ":", "self", ".", "_block_updates", "=", "True", "try", ":", "self", ".", "position", "=", "self", ".", "axis", ".", "Location", "(", ")", "self", ".", "direction", "=", "self", ".", "axis", "....
Keep position and direction in sync with axis
[ "Keep", "position", "and", "direction", "in", "sync", "with", "axis" ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/examples/occ_viewer/occ/shape.py#L249-L256
frmdstryr/enamlx
enamlx/qt/qt_plot_area.py
AbstractQtPlotItem._refresh_multi_axis
def _refresh_multi_axis(self): """ If linked axis' are used, setup and link them """ d = self.declaration #: Create a separate viewbox self.viewbox = pg.ViewBox() #: If this is the first nested plot, use the parent right axis _plots = [c for c in self.pa...
python
def _refresh_multi_axis(self): """ If linked axis' are used, setup and link them """ d = self.declaration #: Create a separate viewbox self.viewbox = pg.ViewBox() #: If this is the first nested plot, use the parent right axis _plots = [c for c in self.pa...
[ "def", "_refresh_multi_axis", "(", "self", ")", ":", "d", "=", "self", ".", "declaration", "#: Create a separate viewbox", "self", ".", "viewbox", "=", "pg", ".", "ViewBox", "(", ")", "#: If this is the first nested plot, use the parent right axis", "_plots", "=", "["...
If linked axis' are used, setup and link them
[ "If", "linked", "axis", "are", "used", "setup", "and", "link", "them" ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_plot_area.py#L174-L204
frmdstryr/enamlx
enamlx/qt/qt_plot_area.py
AbstractQtPlotItem.set_range_x
def set_range_x(self,val): """ Set visible range of x data. Note: Padding must be 0 or it will create an infinite loop """ d = self.declaration if d.auto_range[0]: return self.widget.setXRange(*val,padding=0)
python
def set_range_x(self,val): """ Set visible range of x data. Note: Padding must be 0 or it will create an infinite loop """ d = self.declaration if d.auto_range[0]: return self.widget.setXRange(*val,padding=0)
[ "def", "set_range_x", "(", "self", ",", "val", ")", ":", "d", "=", "self", ".", "declaration", "if", "d", ".", "auto_range", "[", "0", "]", ":", "return", "self", ".", "widget", ".", "setXRange", "(", "*", "val", ",", "padding", "=", "0", ")" ]
Set visible range of x data. Note: Padding must be 0 or it will create an infinite loop
[ "Set", "visible", "range", "of", "x", "data", ".", "Note", ":", "Padding", "must", "be", "0", "or", "it", "will", "create", "an", "infinite", "loop" ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_plot_area.py#L319-L328
frmdstryr/enamlx
enamlx/qt/qt_plot_area.py
AbstractQtPlotItem.set_range_y
def set_range_y(self,val): """ Set visible range of y data. Note: Padding must be 0 or it will create an infinite loop """ d = self.declaration if d.auto_range[1]: return self.widget.setYRange(*val,padding=0)
python
def set_range_y(self,val): """ Set visible range of y data. Note: Padding must be 0 or it will create an infinite loop """ d = self.declaration if d.auto_range[1]: return self.widget.setYRange(*val,padding=0)
[ "def", "set_range_y", "(", "self", ",", "val", ")", ":", "d", "=", "self", ".", "declaration", "if", "d", ".", "auto_range", "[", "1", "]", ":", "return", "self", ".", "widget", ".", "setYRange", "(", "*", "val", ",", "padding", "=", "0", ")" ]
Set visible range of y data. Note: Padding must be 0 or it will create an infinite loop
[ "Set", "visible", "range", "of", "y", "data", ".", "Note", ":", "Padding", "must", "be", "0", "or", "it", "will", "create", "an", "infinite", "loop" ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_plot_area.py#L330-L339
frmdstryr/enamlx
enamlx/qt/qt_plot_area.py
AbstractQtPlotItem.on_resized
def on_resized(self): """ Update linked views """ d = self.declaration if not self.is_root and d.parent.multi_axis: if self.viewbox: self.viewbox.setGeometry(self.widget.vb.sceneBoundingRect()) self.viewbox.linkedViewChanged(self.widget.vb,self.viewbox...
python
def on_resized(self): """ Update linked views """ d = self.declaration if not self.is_root and d.parent.multi_axis: if self.viewbox: self.viewbox.setGeometry(self.widget.vb.sceneBoundingRect()) self.viewbox.linkedViewChanged(self.widget.vb,self.viewbox...
[ "def", "on_resized", "(", "self", ")", ":", "d", "=", "self", ".", "declaration", "if", "not", "self", ".", "is_root", "and", "d", ".", "parent", ".", "multi_axis", ":", "if", "self", ".", "viewbox", ":", "self", ".", "viewbox", ".", "setGeometry", "...
Update linked views
[ "Update", "linked", "views" ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_plot_area.py#L352-L358
frmdstryr/enamlx
enamlx/widgets/tree_view.py
TreeViewItem._get_columns
def _get_columns(self): """ List of child TreeViewColumns including this item as the first column """ return [self] + [c for c in self.children if isinstance(c, TreeViewColumn)]
python
def _get_columns(self): """ List of child TreeViewColumns including this item as the first column """ return [self] + [c for c in self.children if isinstance(c, TreeViewColumn)]
[ "def", "_get_columns", "(", "self", ")", ":", "return", "[", "self", "]", "+", "[", "c", "for", "c", "in", "self", ".", "children", "if", "isinstance", "(", "c", ",", "TreeViewColumn", ")", "]" ]
List of child TreeViewColumns including this item as the first column
[ "List", "of", "child", "TreeViewColumns", "including", "this", "item", "as", "the", "first", "column" ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/widgets/tree_view.py#L90-L95
frmdstryr/enamlx
enamlx/widgets/tree_view.py
TreeViewItem._update_rows
def _update_rows(self): """ Update the row and column numbers of child items. """ for row, item in enumerate(self._items): item.row = row # Row is the Parent item item.column = 0 for column, item in enumerate(self._columns): item.row = self.row # Ro...
python
def _update_rows(self): """ Update the row and column numbers of child items. """ for row, item in enumerate(self._items): item.row = row # Row is the Parent item item.column = 0 for column, item in enumerate(self._columns): item.row = self.row # Ro...
[ "def", "_update_rows", "(", "self", ")", ":", "for", "row", ",", "item", "in", "enumerate", "(", "self", ".", "_items", ")", ":", "item", ".", "row", "=", "row", "# Row is the Parent item", "item", ".", "column", "=", "0", "for", "column", ",", "item",...
Update the row and column numbers of child items.
[ "Update", "the", "row", "and", "column", "numbers", "of", "child", "items", "." ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/widgets/tree_view.py#L110-L118
frmdstryr/enamlx
enamlx/qt/qt_abstract_item_view.py
QAbstractAtomItemModel.setDeclaration
def setDeclaration(self, declaration): """ Set the declaration this model will use for rendering the the headers. """ assert isinstance(declaration.proxy, ProxyAbstractItemView), \ "The model declaration must be a QtAbstractItemView subclass. " \ "Got {]...
python
def setDeclaration(self, declaration): """ Set the declaration this model will use for rendering the the headers. """ assert isinstance(declaration.proxy, ProxyAbstractItemView), \ "The model declaration must be a QtAbstractItemView subclass. " \ "Got {]...
[ "def", "setDeclaration", "(", "self", ",", "declaration", ")", ":", "assert", "isinstance", "(", "declaration", ".", "proxy", ",", "ProxyAbstractItemView", ")", ",", "\"The model declaration must be a QtAbstractItemView subclass. \"", "\"Got {]\"", ".", "format", "(", "...
Set the declaration this model will use for rendering the the headers.
[ "Set", "the", "declaration", "this", "model", "will", "use", "for", "rendering", "the", "the", "headers", "." ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_abstract_item_view.py#L42-L51
frmdstryr/enamlx
enamlx/qt/qt_abstract_item_view.py
QAbstractAtomItemModel.data
def data(self, index, role): """ Retrieve the data for the item at the given index """ item = self.itemAt(index) if not item: return None d = item.declaration if role == Qt.DisplayRole: return d.text elif role == Qt.ToolTipRole: ...
python
def data(self, index, role): """ Retrieve the data for the item at the given index """ item = self.itemAt(index) if not item: return None d = item.declaration if role == Qt.DisplayRole: return d.text elif role == Qt.ToolTipRole: ...
[ "def", "data", "(", "self", ",", "index", ",", "role", ")", ":", "item", "=", "self", ".", "itemAt", "(", "index", ")", "if", "not", "item", ":", "return", "None", "d", "=", "item", ".", "declaration", "if", "role", "==", "Qt", ".", "DisplayRole", ...
Retrieve the data for the item at the given index
[ "Retrieve", "the", "data", "for", "the", "item", "at", "the", "given", "index" ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_abstract_item_view.py#L53-L82
frmdstryr/enamlx
enamlx/qt/qt_abstract_item_view.py
QAbstractAtomItemModel.setData
def setData(self, index, value, role=Qt.EditRole): """ Set the data for the item at the given index to the given value. """ item = self.itemAt(index) if not item: return False d = item.declaration if role == Qt.CheckStateRole: checked = va...
python
def setData(self, index, value, role=Qt.EditRole): """ Set the data for the item at the given index to the given value. """ item = self.itemAt(index) if not item: return False d = item.declaration if role == Qt.CheckStateRole: checked = va...
[ "def", "setData", "(", "self", ",", "index", ",", "value", ",", "role", "=", "Qt", ".", "EditRole", ")", ":", "item", "=", "self", ".", "itemAt", "(", "index", ")", "if", "not", "item", ":", "return", "False", "d", "=", "item", ".", "declaration", ...
Set the data for the item at the given index to the given value.
[ "Set", "the", "data", "for", "the", "item", "at", "the", "given", "index", "to", "the", "given", "value", "." ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_abstract_item_view.py#L109-L127
frmdstryr/enamlx
enamlx/qt/qt_abstract_item_view.py
QAbstractAtomItemModel.headerData
def headerData(self, index, orientation, role): """ QHeaderView respects the following item data roles: TextAlignmentRole, DisplayRole, FontRole, DecorationRole, ForegroundRole, BackgroundRole. """ ...
python
def headerData(self, index, orientation, role): """ QHeaderView respects the following item data roles: TextAlignmentRole, DisplayRole, FontRole, DecorationRole, ForegroundRole, BackgroundRole. """ ...
[ "def", "headerData", "(", "self", ",", "index", ",", "orientation", ",", "role", ")", ":", "d", "=", "self", ".", "declaration", "if", "orientation", "==", "Qt", ".", "Horizontal", "and", "role", "==", "Qt", ".", "DisplayRole", ":", "try", ":", "return...
QHeaderView respects the following item data roles: TextAlignmentRole, DisplayRole, FontRole, DecorationRole, ForegroundRole, BackgroundRole.
[ "QHeaderView", "respects", "the", "following", "item", "data", "roles", ":", "TextAlignmentRole", "DisplayRole", "FontRole", "DecorationRole", "ForegroundRole", "BackgroundRole", "." ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_abstract_item_view.py#L129-L151
frmdstryr/enamlx
enamlx/qt/qt_abstract_item_view.py
QtAbstractItemView.init_signals
def init_signals(self): """ Connect signals """ self.widget.activated.connect(self.on_item_activated) self.widget.clicked.connect(self.on_item_clicked) self.widget.doubleClicked.connect(self.on_item_double_clicked) self.widget.entered.connect(self.on_item_entered) self.wi...
python
def init_signals(self): """ Connect signals """ self.widget.activated.connect(self.on_item_activated) self.widget.clicked.connect(self.on_item_clicked) self.widget.doubleClicked.connect(self.on_item_double_clicked) self.widget.entered.connect(self.on_item_entered) self.wi...
[ "def", "init_signals", "(", "self", ")", ":", "self", ".", "widget", ".", "activated", ".", "connect", "(", "self", ".", "on_item_activated", ")", "self", ".", "widget", ".", "clicked", ".", "connect", "(", "self", ".", "on_item_clicked", ")", "self", "....
Connect signals
[ "Connect", "signals" ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_abstract_item_view.py#L211-L226
frmdstryr/enamlx
enamlx/qt/qt_abstract_item_view.py
QtAbstractItemView.set_items
def set_items(self, items): """ Defer until later so the view is only updated after all items are added. """ self._pending_view_refreshes +=1 timed_call(self._pending_timeout, self._refresh_layout)
python
def set_items(self, items): """ Defer until later so the view is only updated after all items are added. """ self._pending_view_refreshes +=1 timed_call(self._pending_timeout, self._refresh_layout)
[ "def", "set_items", "(", "self", ",", "items", ")", ":", "self", ".", "_pending_view_refreshes", "+=", "1", "timed_call", "(", "self", ".", "_pending_timeout", ",", "self", ".", "_refresh_layout", ")" ]
Defer until later so the view is only updated after all items are added.
[ "Defer", "until", "later", "so", "the", "view", "is", "only", "updated", "after", "all", "items", "are", "added", "." ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_abstract_item_view.py#L274-L280
frmdstryr/enamlx
enamlx/qt/qt_abstract_item_view.py
QtAbstractItemView._refresh_layout
def _refresh_layout(self): """ This queues and batches model changes so that the layout is only refreshed after the `_pending_timeout` expires. This prevents the UI from refreshing when inserting or removing a large number of items until the operation is complete. """ ...
python
def _refresh_layout(self): """ This queues and batches model changes so that the layout is only refreshed after the `_pending_timeout` expires. This prevents the UI from refreshing when inserting or removing a large number of items until the operation is complete. """ ...
[ "def", "_refresh_layout", "(", "self", ")", ":", "self", ".", "_pending_view_refreshes", "-=", "1", "if", "self", ".", "_pending_view_refreshes", "==", "0", ":", "try", ":", "self", ".", "model", ".", "layoutChanged", ".", "emit", "(", ")", "self", ".", ...
This queues and batches model changes so that the layout is only refreshed after the `_pending_timeout` expires. This prevents the UI from refreshing when inserting or removing a large number of items until the operation is complete.
[ "This", "queues", "and", "batches", "model", "changes", "so", "that", "the", "layout", "is", "only", "refreshed", "after", "the", "_pending_timeout", "expires", ".", "This", "prevents", "the", "UI", "from", "refreshing", "when", "inserting", "or", "removing", ...
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_abstract_item_view.py#L392-L407
frmdstryr/enamlx
enamlx/qt/qt_tree_view.py
QAtomTreeModel.index
def index(self, row, column, parent): """ The index should point to the corresponding QtControl in the enaml object hierarchy. """ item = parent.internalPointer() #: If the parent is None d = self.declaration if item is None else item.declaration if row < len(d._...
python
def index(self, row, column, parent): """ The index should point to the corresponding QtControl in the enaml object hierarchy. """ item = parent.internalPointer() #: If the parent is None d = self.declaration if item is None else item.declaration if row < len(d._...
[ "def", "index", "(", "self", ",", "row", ",", "column", ",", "parent", ")", ":", "item", "=", "parent", ".", "internalPointer", "(", ")", "#: If the parent is None", "d", "=", "self", ".", "declaration", "if", "item", "is", "None", "else", "item", ".", ...
The index should point to the corresponding QtControl in the enaml object hierarchy.
[ "The", "index", "should", "point", "to", "the", "corresponding", "QtControl", "in", "the", "enaml", "object", "hierarchy", "." ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_tree_view.py#L46-L59
frmdstryr/enamlx
enamlx/qt/qt_tree_view.py
QtTreeViewItem._default_view
def _default_view(self): """ If this is the root item, return the parent which must be a TreeView, otherwise return the parent Item's view. """ parent = self.parent() if isinstance(parent, QtTreeView): return parent return parent.view
python
def _default_view(self): """ If this is the root item, return the parent which must be a TreeView, otherwise return the parent Item's view. """ parent = self.parent() if isinstance(parent, QtTreeView): return parent return parent.view
[ "def", "_default_view", "(", "self", ")", ":", "parent", "=", "self", ".", "parent", "(", ")", "if", "isinstance", "(", "parent", ",", "QtTreeView", ")", ":", "return", "parent", "return", "parent", ".", "view" ]
If this is the root item, return the parent which must be a TreeView, otherwise return the parent Item's view.
[ "If", "this", "is", "the", "root", "item", "return", "the", "parent", "which", "must", "be", "a", "TreeView", "otherwise", "return", "the", "parent", "Item", "s", "view", "." ]
train
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_tree_view.py#L230-L238
LasLabs/python-five9
five9/models/web_connector.py
WebConnector.search
def search(cls, five9, filters): """Search for a record on the remote and return the results. Args: five9 (five9.Five9): The authenticated Five9 remote. filters (dict): A dictionary of search parameters, keyed by the name of the field to search. This should confo...
python
def search(cls, five9, filters): """Search for a record on the remote and return the results. Args: five9 (five9.Five9): The authenticated Five9 remote. filters (dict): A dictionary of search parameters, keyed by the name of the field to search. This should confo...
[ "def", "search", "(", "cls", ",", "five9", ",", "filters", ")", ":", "return", "cls", ".", "_name_search", "(", "five9", ".", "configuration", ".", "getWebConnectors", ",", "filters", ")" ]
Search for a record on the remote and return the results. Args: five9 (five9.Five9): The authenticated Five9 remote. filters (dict): A dictionary of search parameters, keyed by the name of the field to search. This should conform to the schema defined in ...
[ "Search", "for", "a", "record", "on", "the", "remote", "and", "return", "the", "results", "." ]
train
https://github.com/LasLabs/python-five9/blob/ef53160d6658604524a2577391280d2b4501a7ce/five9/models/web_connector.py#L146-L158
LasLabs/python-five9
five9/models/base_model.py
BaseModel.read
def read(cls, five9, external_id): """Return a record singleton for the ID. Args: five9 (five9.Five9): The authenticated Five9 remote. external_id (mixed): The identified on Five9. This should be the value that is in the ``__uid_field__`` field on the record. ...
python
def read(cls, five9, external_id): """Return a record singleton for the ID. Args: five9 (five9.Five9): The authenticated Five9 remote. external_id (mixed): The identified on Five9. This should be the value that is in the ``__uid_field__`` field on the record. ...
[ "def", "read", "(", "cls", ",", "five9", ",", "external_id", ")", ":", "results", "=", "cls", ".", "search", "(", "five9", ",", "{", "cls", ".", "__uid_field__", ":", "external_id", "}", ")", "if", "not", "results", ":", "return", "None", "return", "...
Return a record singleton for the ID. Args: five9 (five9.Five9): The authenticated Five9 remote. external_id (mixed): The identified on Five9. This should be the value that is in the ``__uid_field__`` field on the record. Returns: BaseModel: The reco...
[ "Return", "a", "record", "singleton", "for", "the", "ID", "." ]
train
https://github.com/LasLabs/python-five9/blob/ef53160d6658604524a2577391280d2b4501a7ce/five9/models/base_model.py#L55-L69
LasLabs/python-five9
five9/models/base_model.py
BaseModel.update
def update(self, data): """Update the current memory record with the given data dict. Args: data (dict): Data dictionary to update the record attributes with. """ for key, value in data.items(): setattr(self, key, value)
python
def update(self, data): """Update the current memory record with the given data dict. Args: data (dict): Data dictionary to update the record attributes with. """ for key, value in data.items(): setattr(self, key, value)
[ "def", "update", "(", "self", ",", "data", ")", ":", "for", "key", ",", "value", "in", "data", ".", "items", "(", ")", ":", "setattr", "(", "self", ",", "key", ",", "value", ")" ]
Update the current memory record with the given data dict. Args: data (dict): Data dictionary to update the record attributes with.
[ "Update", "the", "current", "memory", "record", "with", "the", "given", "data", "dict", "." ]
train
https://github.com/LasLabs/python-five9/blob/ef53160d6658604524a2577391280d2b4501a7ce/five9/models/base_model.py#L86-L93
LasLabs/python-five9
five9/models/base_model.py
BaseModel._call_and_serialize
def _call_and_serialize(cls, method, data, refresh=False): """Call the remote method with data, and optionally refresh. Args: method (callable): The method on the Authenticated Five9 object that should be called. data (dict): A data dictionary that will be passed...
python
def _call_and_serialize(cls, method, data, refresh=False): """Call the remote method with data, and optionally refresh. Args: method (callable): The method on the Authenticated Five9 object that should be called. data (dict): A data dictionary that will be passed...
[ "def", "_call_and_serialize", "(", "cls", ",", "method", ",", "data", ",", "refresh", "=", "False", ")", ":", "method", "(", "data", ")", "if", "refresh", ":", "return", "cls", ".", "read", "(", "method", ".", "__self__", ",", "data", "[", "cls", "."...
Call the remote method with data, and optionally refresh. Args: method (callable): The method on the Authenticated Five9 object that should be called. data (dict): A data dictionary that will be passed as the first and only position argument to ``method``...
[ "Call", "the", "remote", "method", "with", "data", "and", "optionally", "refresh", "." ]
train
https://github.com/LasLabs/python-five9/blob/ef53160d6658604524a2577391280d2b4501a7ce/five9/models/base_model.py#L104-L124
LasLabs/python-five9
five9/models/base_model.py
BaseModel._get_name_filters
def _get_name_filters(cls, filters): """Return a regex filter for the UID column only.""" filters = filters.get(cls.__uid_field__) if not filters: filters = '.*' elif not isinstance(filters, string_types): filters = r'(%s)' % ('|'.join(filters)) return fil...
python
def _get_name_filters(cls, filters): """Return a regex filter for the UID column only.""" filters = filters.get(cls.__uid_field__) if not filters: filters = '.*' elif not isinstance(filters, string_types): filters = r'(%s)' % ('|'.join(filters)) return fil...
[ "def", "_get_name_filters", "(", "cls", ",", "filters", ")", ":", "filters", "=", "filters", ".", "get", "(", "cls", ".", "__uid_field__", ")", "if", "not", "filters", ":", "filters", "=", "'.*'", "elif", "not", "isinstance", "(", "filters", ",", "string...
Return a regex filter for the UID column only.
[ "Return", "a", "regex", "filter", "for", "the", "UID", "column", "only", "." ]
train
https://github.com/LasLabs/python-five9/blob/ef53160d6658604524a2577391280d2b4501a7ce/five9/models/base_model.py#L127-L134
LasLabs/python-five9
five9/models/base_model.py
BaseModel._get_non_empty_dict
def _get_non_empty_dict(cls, mapping): """Return the mapping without any ``None`` values (recursive).""" res = {} for key, value in mapping.items(): if hasattr(value, 'items'): value = cls._get_non_empty_dict(value) elif isinstance(value, list): ...
python
def _get_non_empty_dict(cls, mapping): """Return the mapping without any ``None`` values (recursive).""" res = {} for key, value in mapping.items(): if hasattr(value, 'items'): value = cls._get_non_empty_dict(value) elif isinstance(value, list): ...
[ "def", "_get_non_empty_dict", "(", "cls", ",", "mapping", ")", ":", "res", "=", "{", "}", "for", "key", ",", "value", "in", "mapping", ".", "items", "(", ")", ":", "if", "hasattr", "(", "value", ",", "'items'", ")", ":", "value", "=", "cls", ".", ...
Return the mapping without any ``None`` values (recursive).
[ "Return", "the", "mapping", "without", "any", "None", "values", "(", "recursive", ")", "." ]
train
https://github.com/LasLabs/python-five9/blob/ef53160d6658604524a2577391280d2b4501a7ce/five9/models/base_model.py#L137-L147
LasLabs/python-five9
five9/models/base_model.py
BaseModel._get_non_empty_list
def _get_non_empty_list(cls, iter): """Return a list of the input, excluding all ``None`` values.""" res = [] for value in iter: if hasattr(value, 'items'): value = cls._get_non_empty_dict(value) or None if value is not None: res.append(val...
python
def _get_non_empty_list(cls, iter): """Return a list of the input, excluding all ``None`` values.""" res = [] for value in iter: if hasattr(value, 'items'): value = cls._get_non_empty_dict(value) or None if value is not None: res.append(val...
[ "def", "_get_non_empty_list", "(", "cls", ",", "iter", ")", ":", "res", "=", "[", "]", "for", "value", "in", "iter", ":", "if", "hasattr", "(", "value", ",", "'items'", ")", ":", "value", "=", "cls", ".", "_get_non_empty_dict", "(", "value", ")", "or...
Return a list of the input, excluding all ``None`` values.
[ "Return", "a", "list", "of", "the", "input", "excluding", "all", "None", "values", "." ]
train
https://github.com/LasLabs/python-five9/blob/ef53160d6658604524a2577391280d2b4501a7ce/five9/models/base_model.py#L150-L158
LasLabs/python-five9
five9/models/base_model.py
BaseModel._name_search
def _name_search(cls, method, filters): """Helper for search methods that use name filters. Args: method (callable): The Five9 API method to call with the name filters. filters (dict): A dictionary of search parameters, keyed by the name of the fi...
python
def _name_search(cls, method, filters): """Helper for search methods that use name filters. Args: method (callable): The Five9 API method to call with the name filters. filters (dict): A dictionary of search parameters, keyed by the name of the fi...
[ "def", "_name_search", "(", "cls", ",", "method", ",", "filters", ")", ":", "filters", "=", "cls", ".", "_get_name_filters", "(", "filters", ")", "return", "[", "cls", ".", "deserialize", "(", "cls", ".", "_zeep_to_dict", "(", "row", ")", ")", "for", "...
Helper for search methods that use name filters. Args: method (callable): The Five9 API method to call with the name filters. filters (dict): A dictionary of search parameters, keyed by the name of the field to search. This should conform to the ...
[ "Helper", "for", "search", "methods", "that", "use", "name", "filters", "." ]
train
https://github.com/LasLabs/python-five9/blob/ef53160d6658604524a2577391280d2b4501a7ce/five9/models/base_model.py#L161-L177
LasLabs/python-five9
five9/models/base_model.py
BaseModel._zeep_to_dict
def _zeep_to_dict(cls, obj): """Convert a zeep object to a dictionary.""" res = serialize_object(obj) res = cls._get_non_empty_dict(res) return res
python
def _zeep_to_dict(cls, obj): """Convert a zeep object to a dictionary.""" res = serialize_object(obj) res = cls._get_non_empty_dict(res) return res
[ "def", "_zeep_to_dict", "(", "cls", ",", "obj", ")", ":", "res", "=", "serialize_object", "(", "obj", ")", "res", "=", "cls", ".", "_get_non_empty_dict", "(", "res", ")", "return", "res" ]
Convert a zeep object to a dictionary.
[ "Convert", "a", "zeep", "object", "to", "a", "dictionary", "." ]
train
https://github.com/LasLabs/python-five9/blob/ef53160d6658604524a2577391280d2b4501a7ce/five9/models/base_model.py#L180-L184
LasLabs/python-five9
five9/models/base_model.py
BaseModel.__check_field
def __check_field(self, key): """Raises a KeyError if the field doesn't exist.""" if not self._props.get(key): raise KeyError( 'The field "%s" does not exist on "%s"' % ( key, self.__class__.__name__, ), )
python
def __check_field(self, key): """Raises a KeyError if the field doesn't exist.""" if not self._props.get(key): raise KeyError( 'The field "%s" does not exist on "%s"' % ( key, self.__class__.__name__, ), )
[ "def", "__check_field", "(", "self", ",", "key", ")", ":", "if", "not", "self", ".", "_props", ".", "get", "(", "key", ")", ":", "raise", "KeyError", "(", "'The field \"%s\" does not exist on \"%s\"'", "%", "(", "key", ",", "self", ".", "__class__", ".", ...
Raises a KeyError if the field doesn't exist.
[ "Raises", "a", "KeyError", "if", "the", "field", "doesn", "t", "exist", "." ]
train
https://github.com/LasLabs/python-five9/blob/ef53160d6658604524a2577391280d2b4501a7ce/five9/models/base_model.py#L206-L213
LasLabs/python-five9
five9/five9.py
Five9.supervisor
def supervisor(self): """Return an authenticated connection for use, open new if required. Returns: SupervisorWebService: New or existing session with the Five9 Statistics API. """ supervisor = self._cached_client('supervisor') if not self._api_supervisor...
python
def supervisor(self): """Return an authenticated connection for use, open new if required. Returns: SupervisorWebService: New or existing session with the Five9 Statistics API. """ supervisor = self._cached_client('supervisor') if not self._api_supervisor...
[ "def", "supervisor", "(", "self", ")", ":", "supervisor", "=", "self", ".", "_cached_client", "(", "'supervisor'", ")", "if", "not", "self", ".", "_api_supervisor_session", ":", "self", ".", "_api_supervisor_session", "=", "self", ".", "__create_supervisor_session...
Return an authenticated connection for use, open new if required. Returns: SupervisorWebService: New or existing session with the Five9 Statistics API.
[ "Return", "an", "authenticated", "connection", "for", "use", "open", "new", "if", "required", "." ]
train
https://github.com/LasLabs/python-five9/blob/ef53160d6658604524a2577391280d2b4501a7ce/five9/five9.py#L48-L60
LasLabs/python-five9
five9/five9.py
Five9.create_mapping
def create_mapping(record, keys): """Create a field mapping for use in API updates and creates. Args: record (BaseModel): Record that should be mapped. keys (list[str]): Fields that should be mapped as keys. Returns: dict: Dictionary with keys: ...
python
def create_mapping(record, keys): """Create a field mapping for use in API updates and creates. Args: record (BaseModel): Record that should be mapped. keys (list[str]): Fields that should be mapped as keys. Returns: dict: Dictionary with keys: ...
[ "def", "create_mapping", "(", "record", ",", "keys", ")", ":", "ordered", "=", "OrderedDict", "(", ")", "field_mappings", "=", "[", "]", "for", "key", ",", "value", "in", "record", ".", "items", "(", ")", ":", "ordered", "[", "key", "]", "=", "value"...
Create a field mapping for use in API updates and creates. Args: record (BaseModel): Record that should be mapped. keys (list[str]): Fields that should be mapped as keys. Returns: dict: Dictionary with keys: * ``field_mappings``: Field mappings as r...
[ "Create", "a", "field", "mapping", "for", "use", "in", "API", "updates", "and", "creates", "." ]
train
https://github.com/LasLabs/python-five9/blob/ef53160d6658604524a2577391280d2b4501a7ce/five9/five9.py#L68-L97
LasLabs/python-five9
five9/five9.py
Five9.parse_response
def parse_response(fields, records): """Parse an API response into usable objects. Args: fields (list[str]): List of strings indicating the fields that are represented in the records, in the order presented in the records.:: [ ...
python
def parse_response(fields, records): """Parse an API response into usable objects. Args: fields (list[str]): List of strings indicating the fields that are represented in the records, in the order presented in the records.:: [ ...
[ "def", "parse_response", "(", "fields", ",", "records", ")", ":", "data", "=", "[", "i", "[", "'values'", "]", "[", "'data'", "]", "for", "i", "in", "records", "]", "return", "[", "{", "fields", "[", "idx", "]", ":", "row", "for", "idx", ",", "ro...
Parse an API response into usable objects. Args: fields (list[str]): List of strings indicating the fields that are represented in the records, in the order presented in the records.:: [ 'number1', 'number2', ...
[ "Parse", "an", "API", "response", "into", "usable", "objects", "." ]
train
https://github.com/LasLabs/python-five9/blob/ef53160d6658604524a2577391280d2b4501a7ce/five9/five9.py#L100-L150
LasLabs/python-five9
five9/five9.py
Five9.create_criteria
def create_criteria(cls, query): """Return a criteria from a dictionary containing a query. Query should be a dictionary, keyed by field name. If the value is a list, it will be divided into multiple criteria as required. """ criteria = [] for name, value in query.items(...
python
def create_criteria(cls, query): """Return a criteria from a dictionary containing a query. Query should be a dictionary, keyed by field name. If the value is a list, it will be divided into multiple criteria as required. """ criteria = [] for name, value in query.items(...
[ "def", "create_criteria", "(", "cls", ",", "query", ")", ":", "criteria", "=", "[", "]", "for", "name", ",", "value", "in", "query", ".", "items", "(", ")", ":", "if", "isinstance", "(", "value", ",", "list", ")", ":", "for", "inner_value", "in", "...
Return a criteria from a dictionary containing a query. Query should be a dictionary, keyed by field name. If the value is a list, it will be divided into multiple criteria as required.
[ "Return", "a", "criteria", "from", "a", "dictionary", "containing", "a", "query", "." ]
train
https://github.com/LasLabs/python-five9/blob/ef53160d6658604524a2577391280d2b4501a7ce/five9/five9.py#L153-L171
LasLabs/python-five9
five9/five9.py
Five9._get_authenticated_client
def _get_authenticated_client(self, wsdl): """Return an authenticated SOAP client. Returns: zeep.Client: Authenticated API client. """ return zeep.Client( wsdl % quote(self.username), transport=zeep.Transport( session=self._get_authent...
python
def _get_authenticated_client(self, wsdl): """Return an authenticated SOAP client. Returns: zeep.Client: Authenticated API client. """ return zeep.Client( wsdl % quote(self.username), transport=zeep.Transport( session=self._get_authent...
[ "def", "_get_authenticated_client", "(", "self", ",", "wsdl", ")", ":", "return", "zeep", ".", "Client", "(", "wsdl", "%", "quote", "(", "self", ".", "username", ")", ",", "transport", "=", "zeep", ".", "Transport", "(", "session", "=", "self", ".", "_...
Return an authenticated SOAP client. Returns: zeep.Client: Authenticated API client.
[ "Return", "an", "authenticated", "SOAP", "client", "." ]
train
https://github.com/LasLabs/python-five9/blob/ef53160d6658604524a2577391280d2b4501a7ce/five9/five9.py#L173-L184
LasLabs/python-five9
five9/five9.py
Five9._get_authenticated_session
def _get_authenticated_session(self): """Return an authenticated requests session. Returns: requests.Session: Authenticated session for use. """ session = requests.Session() session.auth = self.auth return session
python
def _get_authenticated_session(self): """Return an authenticated requests session. Returns: requests.Session: Authenticated session for use. """ session = requests.Session() session.auth = self.auth return session
[ "def", "_get_authenticated_session", "(", "self", ")", ":", "session", "=", "requests", ".", "Session", "(", ")", "session", ".", "auth", "=", "self", ".", "auth", "return", "session" ]
Return an authenticated requests session. Returns: requests.Session: Authenticated session for use.
[ "Return", "an", "authenticated", "requests", "session", "." ]
train
https://github.com/LasLabs/python-five9/blob/ef53160d6658604524a2577391280d2b4501a7ce/five9/five9.py#L186-L194
LasLabs/python-five9
five9/five9.py
Five9.__create_supervisor_session
def __create_supervisor_session(self, supervisor): """Create a new session on the supervisor service. This is required in order to use most methods for the supervisor, so it is called implicitly when generating a supervisor session. """ session_params = { 'forceLogou...
python
def __create_supervisor_session(self, supervisor): """Create a new session on the supervisor service. This is required in order to use most methods for the supervisor, so it is called implicitly when generating a supervisor session. """ session_params = { 'forceLogou...
[ "def", "__create_supervisor_session", "(", "self", ",", "supervisor", ")", ":", "session_params", "=", "{", "'forceLogoutSession'", ":", "self", ".", "force_logout_session", ",", "'rollingPeriod'", ":", "self", ".", "rolling_period", ",", "'statisticsRange'", ":", "...
Create a new session on the supervisor service. This is required in order to use most methods for the supervisor, so it is called implicitly when generating a supervisor session.
[ "Create", "a", "new", "session", "on", "the", "supervisor", "service", "." ]
train
https://github.com/LasLabs/python-five9/blob/ef53160d6658604524a2577391280d2b4501a7ce/five9/five9.py#L204-L222
LasLabs/python-five9
five9/environment.py
Api.model
def model(method): """Use this to decorate methods that expect a model.""" def wrapper(self, *args, **kwargs): if self.__model__ is None: raise ValidationError( 'You cannot perform CRUD operations without selecting a ' 'model first.', ...
python
def model(method): """Use this to decorate methods that expect a model.""" def wrapper(self, *args, **kwargs): if self.__model__ is None: raise ValidationError( 'You cannot perform CRUD operations without selecting a ' 'model first.', ...
[ "def", "model", "(", "method", ")", ":", "def", "wrapper", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "__model__", "is", "None", ":", "raise", "ValidationError", "(", "'You cannot perform CRUD operations without sele...
Use this to decorate methods that expect a model.
[ "Use", "this", "to", "decorate", "methods", "that", "expect", "a", "model", "." ]
train
https://github.com/LasLabs/python-five9/blob/ef53160d6658604524a2577391280d2b4501a7ce/five9/environment.py#L12-L21
LasLabs/python-five9
five9/environment.py
Api.recordset
def recordset(method): """Use this to decorate methods that expect a record set.""" def wrapper(self, *args, **kwargs): if self.__records__ is None: raise ValidationError( 'There are no records in the set.', ) return method(self...
python
def recordset(method): """Use this to decorate methods that expect a record set.""" def wrapper(self, *args, **kwargs): if self.__records__ is None: raise ValidationError( 'There are no records in the set.', ) return method(self...
[ "def", "recordset", "(", "method", ")", ":", "def", "wrapper", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "__records__", "is", "None", ":", "raise", "ValidationError", "(", "'There are no records in the set.'", ","...
Use this to decorate methods that expect a record set.
[ "Use", "this", "to", "decorate", "methods", "that", "expect", "a", "record", "set", "." ]
train
https://github.com/LasLabs/python-five9/blob/ef53160d6658604524a2577391280d2b4501a7ce/five9/environment.py#L24-L32
LasLabs/python-five9
five9/environment.py
Environment.create
def create(self, data, refresh=False): """Create the data on the remote, optionally refreshing.""" self.__model__.create(self.__five9__, data) if refresh: return self.read(data[self.__model__.__name__]) else: return self.new(data)
python
def create(self, data, refresh=False): """Create the data on the remote, optionally refreshing.""" self.__model__.create(self.__five9__, data) if refresh: return self.read(data[self.__model__.__name__]) else: return self.new(data)
[ "def", "create", "(", "self", ",", "data", ",", "refresh", "=", "False", ")", ":", "self", ".", "__model__", ".", "create", "(", "self", ".", "__five9__", ",", "data", ")", "if", "refresh", ":", "return", "self", ".", "read", "(", "data", "[", "sel...
Create the data on the remote, optionally refreshing.
[ "Create", "the", "data", "on", "the", "remote", "optionally", "refreshing", "." ]
train
https://github.com/LasLabs/python-five9/blob/ef53160d6658604524a2577391280d2b4501a7ce/five9/environment.py#L90-L96
LasLabs/python-five9
five9/environment.py
Environment.new
def new(self, data): """Create a new memory record, but do not create on the remote.""" data = self.__model__._get_non_empty_dict(data) return self.__class__( self.__five9__, self.__model__, records=[self.__model__.deserialize(data)], )
python
def new(self, data): """Create a new memory record, but do not create on the remote.""" data = self.__model__._get_non_empty_dict(data) return self.__class__( self.__five9__, self.__model__, records=[self.__model__.deserialize(data)], )
[ "def", "new", "(", "self", ",", "data", ")", ":", "data", "=", "self", ".", "__model__", ".", "_get_non_empty_dict", "(", "data", ")", "return", "self", ".", "__class__", "(", "self", ".", "__five9__", ",", "self", ".", "__model__", ",", "records", "="...
Create a new memory record, but do not create on the remote.
[ "Create", "a", "new", "memory", "record", "but", "do", "not", "create", "on", "the", "remote", "." ]
train
https://github.com/LasLabs/python-five9/blob/ef53160d6658604524a2577391280d2b4501a7ce/five9/environment.py#L99-L106
LasLabs/python-five9
five9/environment.py
Environment.search
def search(self, filters): """Search Five9 given a filter. Args: filters (dict): A dictionary of search strings, keyed by the name of the field to search. Returns: Environment: An environment representing the recordset. """ records = self...
python
def search(self, filters): """Search Five9 given a filter. Args: filters (dict): A dictionary of search strings, keyed by the name of the field to search. Returns: Environment: An environment representing the recordset. """ records = self...
[ "def", "search", "(", "self", ",", "filters", ")", ":", "records", "=", "self", ".", "__model__", ".", "search", "(", "self", ".", "__five9__", ",", "filters", ")", "return", "self", ".", "__class__", "(", "self", ".", "__five9__", ",", "self", ".", ...
Search Five9 given a filter. Args: filters (dict): A dictionary of search strings, keyed by the name of the field to search. Returns: Environment: An environment representing the recordset.
[ "Search", "Five9", "given", "a", "filter", "." ]
train
https://github.com/LasLabs/python-five9/blob/ef53160d6658604524a2577391280d2b4501a7ce/five9/environment.py#L125-L138
LasLabs/python-five9
five9/models/disposition.py
Disposition.create
def create(cls, five9, data, refresh=False): """Create a record on Five9. Args: five9 (five9.Five9): The authenticated Five9 remote. data (dict): A data dictionary that can be fed to ``deserialize``. refresh (bool, optional): Set to ``True`` to get the record data ...
python
def create(cls, five9, data, refresh=False): """Create a record on Five9. Args: five9 (five9.Five9): The authenticated Five9 remote. data (dict): A data dictionary that can be fed to ``deserialize``. refresh (bool, optional): Set to ``True`` to get the record data ...
[ "def", "create", "(", "cls", ",", "five9", ",", "data", ",", "refresh", "=", "False", ")", ":", "return", "cls", ".", "_call_and_serialize", "(", "five9", ".", "configuration", ".", "createDisposition", ",", "data", ",", "refresh", ",", ")" ]
Create a record on Five9. Args: five9 (five9.Five9): The authenticated Five9 remote. data (dict): A data dictionary that can be fed to ``deserialize``. refresh (bool, optional): Set to ``True`` to get the record data from Five9 before returning the record. ...
[ "Create", "a", "record", "on", "Five9", "." ]
train
https://github.com/LasLabs/python-five9/blob/ef53160d6658604524a2577391280d2b4501a7ce/five9/models/disposition.py#L84-L100
LasLabs/python-five9
five9/models/disposition.py
Disposition.search
def search(cls, five9, filters): """Search for a record on the remote and return the results. Args: five9 (five9.Five9): The authenticated Five9 remote. filters (dict): A dictionary of search parameters, keyed by the name of the field to search. This should confo...
python
def search(cls, five9, filters): """Search for a record on the remote and return the results. Args: five9 (five9.Five9): The authenticated Five9 remote. filters (dict): A dictionary of search parameters, keyed by the name of the field to search. This should confo...
[ "def", "search", "(", "cls", ",", "five9", ",", "filters", ")", ":", "return", "cls", ".", "_name_search", "(", "five9", ".", "configuration", ".", "getDispositions", ",", "filters", ")" ]
Search for a record on the remote and return the results. Args: five9 (five9.Five9): The authenticated Five9 remote. filters (dict): A dictionary of search parameters, keyed by the name of the field to search. This should conform to the schema defined in ...
[ "Search", "for", "a", "record", "on", "the", "remote", "and", "return", "the", "results", "." ]
train
https://github.com/LasLabs/python-five9/blob/ef53160d6658604524a2577391280d2b4501a7ce/five9/models/disposition.py#L103-L115
tonioo/sievelib
sievelib/managesieve.py
authentication_required
def authentication_required(meth): """Simple class method decorator. Checks if the client is currently connected. :param meth: the original called method """ def check(cls, *args, **kwargs): if cls.authenticated: return meth(cls, *args, **kwargs) raise Error("Authentic...
python
def authentication_required(meth): """Simple class method decorator. Checks if the client is currently connected. :param meth: the original called method """ def check(cls, *args, **kwargs): if cls.authenticated: return meth(cls, *args, **kwargs) raise Error("Authentic...
[ "def", "authentication_required", "(", "meth", ")", ":", "def", "check", "(", "cls", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "cls", ".", "authenticated", ":", "return", "meth", "(", "cls", ",", "*", "args", ",", "*", "*", "kwargs...
Simple class method decorator. Checks if the client is currently connected. :param meth: the original called method
[ "Simple", "class", "method", "decorator", "." ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/managesieve.py#L58-L71
tonioo/sievelib
sievelib/managesieve.py
Client.__read_block
def __read_block(self, size): """Read a block of 'size' bytes from the server. An internal buffer is used to read data from the server. If enough data is available from it, we return that data. Eventually, we try to grab the missing part from the server for Client.read_timeout ...
python
def __read_block(self, size): """Read a block of 'size' bytes from the server. An internal buffer is used to read data from the server. If enough data is available from it, we return that data. Eventually, we try to grab the missing part from the server for Client.read_timeout ...
[ "def", "__read_block", "(", "self", ",", "size", ")", ":", "buf", "=", "b\"\"", "if", "len", "(", "self", ".", "__read_buffer", ")", ":", "limit", "=", "(", "size", "if", "size", "<=", "len", "(", "self", ".", "__read_buffer", ")", "else", "len", "...
Read a block of 'size' bytes from the server. An internal buffer is used to read data from the server. If enough data is available from it, we return that data. Eventually, we try to grab the missing part from the server for Client.read_timeout seconds. If no data can be retrie...
[ "Read", "a", "block", "of", "size", "bytes", "from", "the", "server", "." ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/managesieve.py#L103-L134
tonioo/sievelib
sievelib/managesieve.py
Client.__read_line
def __read_line(self): """Read one line from the server. An internal buffer is used to read data from the server (blocks of Client.read_size bytes). If the buffer is not empty, we try to find an entire line to return. If we failed, we try to read new content from the server for...
python
def __read_line(self): """Read one line from the server. An internal buffer is used to read data from the server (blocks of Client.read_size bytes). If the buffer is not empty, we try to find an entire line to return. If we failed, we try to read new content from the server for...
[ "def", "__read_line", "(", "self", ")", ":", "ret", "=", "b\"\"", "while", "True", ":", "try", ":", "pos", "=", "self", ".", "__read_buffer", ".", "index", "(", "CRLF", ")", "ret", "=", "self", ".", "__read_buffer", "[", ":", "pos", "]", "self", "....
Read one line from the server. An internal buffer is used to read data from the server (blocks of Client.read_size bytes). If the buffer is not empty, we try to find an entire line to return. If we failed, we try to read new content from the server for Client.read_timeout secon...
[ "Read", "one", "line", "from", "the", "server", "." ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/managesieve.py#L136-L181
tonioo/sievelib
sievelib/managesieve.py
Client.__read_response
def __read_response(self, nblines=-1): """Read a response from the server. In the usual case, we read lines until we find one that looks like a response (OK|NO|BYE\s*(.+)?). If *nblines* > 0, we read excactly nblines before returning. :param nblines: number of lines to read (d...
python
def __read_response(self, nblines=-1): """Read a response from the server. In the usual case, we read lines until we find one that looks like a response (OK|NO|BYE\s*(.+)?). If *nblines* > 0, we read excactly nblines before returning. :param nblines: number of lines to read (d...
[ "def", "__read_response", "(", "self", ",", "nblines", "=", "-", "1", ")", ":", "resp", ",", "code", ",", "data", "=", "(", "b\"\"", ",", "None", ",", "None", ")", "cpt", "=", "0", "while", "True", ":", "try", ":", "line", "=", "self", ".", "__...
Read a response from the server. In the usual case, we read lines until we find one that looks like a response (OK|NO|BYE\s*(.+)?). If *nblines* > 0, we read excactly nblines before returning. :param nblines: number of lines to read (default : -1) :rtype: tuple :return...
[ "Read", "a", "response", "from", "the", "server", "." ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/managesieve.py#L183-L217
tonioo/sievelib
sievelib/managesieve.py
Client.__prepare_args
def __prepare_args(self, args): """Format command arguments before sending them. Command arguments of type string must be quoted, the only exception concerns size indication (of the form {\d\+?}). :param args: list of arguments :return: a list for transformed arguments ...
python
def __prepare_args(self, args): """Format command arguments before sending them. Command arguments of type string must be quoted, the only exception concerns size indication (of the form {\d\+?}). :param args: list of arguments :return: a list for transformed arguments ...
[ "def", "__prepare_args", "(", "self", ",", "args", ")", ":", "ret", "=", "[", "]", "for", "a", "in", "args", ":", "if", "isinstance", "(", "a", ",", "six", ".", "binary_type", ")", ":", "if", "self", ".", "__size_expr", ".", "match", "(", "a", ")...
Format command arguments before sending them. Command arguments of type string must be quoted, the only exception concerns size indication (of the form {\d\+?}). :param args: list of arguments :return: a list for transformed arguments
[ "Format", "command", "arguments", "before", "sending", "them", "." ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/managesieve.py#L219-L237
tonioo/sievelib
sievelib/managesieve.py
Client.__send_command
def __send_command( self, name, args=None, withcontent=False, extralines=None, nblines=-1): """Send a command to the server. If args is not empty, we concatenate the given command with the content of this list. If extralines is not empty, they are sent one by one...
python
def __send_command( self, name, args=None, withcontent=False, extralines=None, nblines=-1): """Send a command to the server. If args is not empty, we concatenate the given command with the content of this list. If extralines is not empty, they are sent one by one...
[ "def", "__send_command", "(", "self", ",", "name", ",", "args", "=", "None", ",", "withcontent", "=", "False", ",", "extralines", "=", "None", ",", "nblines", "=", "-", "1", ")", ":", "tosend", "=", "name", ".", "encode", "(", "\"utf-8\"", ")", "if",...
Send a command to the server. If args is not empty, we concatenate the given command with the content of this list. If extralines is not empty, they are sent one by one to the server. (CLRF are automatically appended to them) We wait for a response just after the command has be...
[ "Send", "a", "command", "to", "the", "server", "." ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/managesieve.py#L239-L278
tonioo/sievelib
sievelib/managesieve.py
Client.__parse_error
def __parse_error(self, text): """Parse an error received from the server. if text corresponds to a size indication, we grab the remaining content from the server. Otherwise, we try to match an error of the form \(\w+\)?\s*".+" On succes, the two public members errcode and err...
python
def __parse_error(self, text): """Parse an error received from the server. if text corresponds to a size indication, we grab the remaining content from the server. Otherwise, we try to match an error of the form \(\w+\)?\s*".+" On succes, the two public members errcode and err...
[ "def", "__parse_error", "(", "self", ",", "text", ")", ":", "m", "=", "self", ".", "__size_expr", ".", "match", "(", "text", ")", "if", "m", "is", "not", "None", ":", "self", ".", "errcode", "=", "b\"\"", "self", ".", "errmsg", "=", "self", ".", ...
Parse an error received from the server. if text corresponds to a size indication, we grab the remaining content from the server. Otherwise, we try to match an error of the form \(\w+\)?\s*".+" On succes, the two public members errcode and errmsg are filled with the parsing re...
[ "Parse", "an", "error", "received", "from", "the", "server", "." ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/managesieve.py#L296-L322
tonioo/sievelib
sievelib/managesieve.py
Client._plain_authentication
def _plain_authentication(self, login, password, authz_id=b""): """SASL PLAIN authentication :param login: username :param password: clear password :return: True on success, False otherwise. """ if isinstance(login, six.text_type): login = login.encode("utf-8...
python
def _plain_authentication(self, login, password, authz_id=b""): """SASL PLAIN authentication :param login: username :param password: clear password :return: True on success, False otherwise. """ if isinstance(login, six.text_type): login = login.encode("utf-8...
[ "def", "_plain_authentication", "(", "self", ",", "login", ",", "password", ",", "authz_id", "=", "b\"\"", ")", ":", "if", "isinstance", "(", "login", ",", "six", ".", "text_type", ")", ":", "login", "=", "login", ".", "encode", "(", "\"utf-8\"", ")", ...
SASL PLAIN authentication :param login: username :param password: clear password :return: True on success, False otherwise.
[ "SASL", "PLAIN", "authentication" ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/managesieve.py#L324-L339
tonioo/sievelib
sievelib/managesieve.py
Client._login_authentication
def _login_authentication(self, login, password, authz_id=""): """SASL LOGIN authentication :param login: username :param password: clear password :return: True on success, False otherwise. """ extralines = [b'"%s"' % base64.b64encode(login.encode("utf-8")), ...
python
def _login_authentication(self, login, password, authz_id=""): """SASL LOGIN authentication :param login: username :param password: clear password :return: True on success, False otherwise. """ extralines = [b'"%s"' % base64.b64encode(login.encode("utf-8")), ...
[ "def", "_login_authentication", "(", "self", ",", "login", ",", "password", ",", "authz_id", "=", "\"\"", ")", ":", "extralines", "=", "[", "b'\"%s\"'", "%", "base64", ".", "b64encode", "(", "login", ".", "encode", "(", "\"utf-8\"", ")", ")", ",", "b'\"%...
SASL LOGIN authentication :param login: username :param password: clear password :return: True on success, False otherwise.
[ "SASL", "LOGIN", "authentication" ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/managesieve.py#L341-L354
tonioo/sievelib
sievelib/managesieve.py
Client._digest_md5_authentication
def _digest_md5_authentication(self, login, password, authz_id=""): """SASL DIGEST-MD5 authentication :param login: username :param password: clear password :return: True on success, False otherwise. """ code, data, challenge = \ self.__send_command("AUTHENTI...
python
def _digest_md5_authentication(self, login, password, authz_id=""): """SASL DIGEST-MD5 authentication :param login: username :param password: clear password :return: True on success, False otherwise. """ code, data, challenge = \ self.__send_command("AUTHENTI...
[ "def", "_digest_md5_authentication", "(", "self", ",", "login", ",", "password", ",", "authz_id", "=", "\"\"", ")", ":", "code", ",", "data", ",", "challenge", "=", "self", ".", "__send_command", "(", "\"AUTHENTICATE\"", ",", "[", "b\"DIGEST-MD5\"", "]", ","...
SASL DIGEST-MD5 authentication :param login: username :param password: clear password :return: True on success, False otherwise.
[ "SASL", "DIGEST", "-", "MD5", "authentication" ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/managesieve.py#L356-L380
tonioo/sievelib
sievelib/managesieve.py
Client.__authenticate
def __authenticate(self, login, password, authz_id=b"", authmech=None): """AUTHENTICATE command Actually, it is just a wrapper to the real commands (one by mechanism). We try all supported mechanisms (from the strongest to the weakest) until we find one supported by the server. ...
python
def __authenticate(self, login, password, authz_id=b"", authmech=None): """AUTHENTICATE command Actually, it is just a wrapper to the real commands (one by mechanism). We try all supported mechanisms (from the strongest to the weakest) until we find one supported by the server. ...
[ "def", "__authenticate", "(", "self", ",", "login", ",", "password", ",", "authz_id", "=", "b\"\"", ",", "authmech", "=", "None", ")", ":", "if", "\"SASL\"", "not", "in", "self", ".", "__capabilities", ":", "raise", "Error", "(", "\"SASL not supported by the...
AUTHENTICATE command Actually, it is just a wrapper to the real commands (one by mechanism). We try all supported mechanisms (from the strongest to the weakest) until we find one supported by the server. Then we try to authenticate (only once). :param login: username ...
[ "AUTHENTICATE", "command" ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/managesieve.py#L382-L418
tonioo/sievelib
sievelib/managesieve.py
Client.__starttls
def __starttls(self, keyfile=None, certfile=None): """STARTTLS command See MANAGESIEVE specifications, section 2.2. :param keyfile: an eventual private key to use :param certfile: an eventual certificate to use :rtype: boolean """ if not self.has_tls_support(): ...
python
def __starttls(self, keyfile=None, certfile=None): """STARTTLS command See MANAGESIEVE specifications, section 2.2. :param keyfile: an eventual private key to use :param certfile: an eventual certificate to use :rtype: boolean """ if not self.has_tls_support(): ...
[ "def", "__starttls", "(", "self", ",", "keyfile", "=", "None", ",", "certfile", "=", "None", ")", ":", "if", "not", "self", ".", "has_tls_support", "(", ")", ":", "raise", "Error", "(", "\"STARTTLS not supported by the server\"", ")", "code", ",", "data", ...
STARTTLS command See MANAGESIEVE specifications, section 2.2. :param keyfile: an eventual private key to use :param certfile: an eventual certificate to use :rtype: boolean
[ "STARTTLS", "command" ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/managesieve.py#L420-L441
tonioo/sievelib
sievelib/managesieve.py
Client.get_sieve_capabilities
def get_sieve_capabilities(self): """Returns the SIEVE extensions supported by the server. They're read from server capabilities. (see the CAPABILITY command) :rtype: string """ if isinstance(self.__capabilities["SIEVE"], six.string_types): self.__capabiliti...
python
def get_sieve_capabilities(self): """Returns the SIEVE extensions supported by the server. They're read from server capabilities. (see the CAPABILITY command) :rtype: string """ if isinstance(self.__capabilities["SIEVE"], six.string_types): self.__capabiliti...
[ "def", "get_sieve_capabilities", "(", "self", ")", ":", "if", "isinstance", "(", "self", ".", "__capabilities", "[", "\"SIEVE\"", "]", ",", "six", ".", "string_types", ")", ":", "self", ".", "__capabilities", "[", "\"SIEVE\"", "]", "=", "self", ".", "__cap...
Returns the SIEVE extensions supported by the server. They're read from server capabilities. (see the CAPABILITY command) :rtype: string
[ "Returns", "the", "SIEVE", "extensions", "supported", "by", "the", "server", "." ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/managesieve.py#L473-L483
tonioo/sievelib
sievelib/managesieve.py
Client.connect
def connect( self, login, password, authz_id=b"", starttls=False, authmech=None): """Establish a connection with the server. This function must be used. It read the server capabilities and wraps calls to STARTTLS and AUTHENTICATE commands. :param login: username...
python
def connect( self, login, password, authz_id=b"", starttls=False, authmech=None): """Establish a connection with the server. This function must be used. It read the server capabilities and wraps calls to STARTTLS and AUTHENTICATE commands. :param login: username...
[ "def", "connect", "(", "self", ",", "login", ",", "password", ",", "authz_id", "=", "b\"\"", ",", "starttls", "=", "False", ",", "authmech", "=", "None", ")", ":", "try", ":", "self", ".", "sock", "=", "socket", ".", "create_connection", "(", "(", "s...
Establish a connection with the server. This function must be used. It read the server capabilities and wraps calls to STARTTLS and AUTHENTICATE commands. :param login: username :param password: clear password :param starttls: use a TLS connection or not :param authmech...
[ "Establish", "a", "connection", "with", "the", "server", "." ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/managesieve.py#L485-L511
tonioo/sievelib
sievelib/managesieve.py
Client.capability
def capability(self): """Ask server capabilities. See MANAGESIEVE specifications, section 2.4 This command does not affect capabilities recorded by this client. :rtype: string """ code, data, capabilities = ( self.__send_command("CAPABILITY", withcontent=Tru...
python
def capability(self): """Ask server capabilities. See MANAGESIEVE specifications, section 2.4 This command does not affect capabilities recorded by this client. :rtype: string """ code, data, capabilities = ( self.__send_command("CAPABILITY", withcontent=Tru...
[ "def", "capability", "(", "self", ")", ":", "code", ",", "data", ",", "capabilities", "=", "(", "self", ".", "__send_command", "(", "\"CAPABILITY\"", ",", "withcontent", "=", "True", ")", ")", "if", "code", "==", "\"OK\"", ":", "return", "capabilities", ...
Ask server capabilities. See MANAGESIEVE specifications, section 2.4 This command does not affect capabilities recorded by this client. :rtype: string
[ "Ask", "server", "capabilities", "." ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/managesieve.py#L520-L532