This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example modified from: | |
# http://pysnippet.blogspot.com/2010/06/qsignalmapper-at-your-service.html | |
# | |
# Example showing how QSignalMapper can be used to manage an arbitrary | |
# numbers of parameterless signals and re-emit them with an argument | |
# identifying the sender. | |
# | |
# Each signal is associated in the QSignalMapper with either an int, | |
# QString, QObject or a QWidget which is passed as argument to the slot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Demonstration of ways to implement this API: | |
sanitize(unsanitized_input, ignored_words) | |
Related discussions: | |
- Modifying a list while looping over it: | |
- http://stackoverflow.com/questions/1207406/remove-items-from-a-list-while-iterating-in-python | |
- Remove all occurences of a value in a list: | |
- http://stackoverflow.com/questions/1157106/remove-all-occurences-of-a-value-from-a-python-list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fuzzyDictEqual(d1, d2, precision): | |
""" | |
Compare two dicts recursively (just as standard '==' except floating point | |
values are compared within given precision. | |
""" | |
if len(d1) != len(d2): | |
return False | |
for k, v in d1.iteritems(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##### Taken from https://github.com/bosswissam/pysize | |
import sys | |
def get_size(obj, seen=None): | |
"""Recursively finds size of objects""" | |
size = sys.getsizeof(obj) | |
if seen is None: | |
seen = set() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyCallable(object): | |
def __init__(self, urlparts, callable): | |
self.urlparts = urlparts | |
self.callable = callable | |
def __call__(self, **kwargs): | |
print kwargs | |
print self.urlparts | |
def __getattr__(self, name): | |
# Return a callable object of this same type so that you can just keep | |
# chaining together calls and just adding that missing attribute to the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from contextlib import contextmanager | |
@contextmanager | |
def slot_disconnected(signal, slot): | |
""" | |
Create context to perform operations with given slot disconnected from | |
given signal and automatically connected afterwards. | |
usage: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
C0102: Black listed name "%s" | |
C0103: Invalid %s name "%s" | |
C0111: Missing %s docstring | |
C0112: Empty %s docstring | |
C0121: Missing required attribute "%s" | |
C0202: Class method %s should have cls as first argument | |
C0203: Metaclass method %s should have mcs as first argument | |
C0204: Metaclass class method %s should have %s as first argument | |
C0301: Line too long (%s/%s) | |
C0302: Too many lines in module (%s) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Taken from | |
# https://github.com/MatthewMueller/dots/blob/master/os/osx/defaults.sh | |
echo "Expanding the save panel by default" | |
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true | |
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true | |
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint2 -bool true | |
echo "Enabling full keyboard access for all controls (e.g. enable Tab in modal dialogs)" | |
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a raw listing of the imports that take place dynamically by calling | |
# the pyqtgraph/__init__.py:importAll() in the following scenarios: | |
#importAll('graphicsItems', globals(), locals()) | |
#importAll('widgets', globals(), locals(), excludes=['MatplotlibWidget', 'RemoteGraphicsView']) | |
from .graphicsItems.ArrowItem import ArrowItem | |
from .graphicsItems.GraphicsWidgetAnchor import GraphicsWidgetAnchor | |
from .graphicsItems.GraphicsWidgetAnchor import Point | |
from .graphicsItems.GraphicsWidgetAnchor import QtCore |
NewerOlder