[Pkg-bitcoin-commits] [python-quamash] 07/269: updated and normalized description

Jonas Smedegaard dr at jones.dk
Fri Nov 24 11:26:10 UTC 2017


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository python-quamash.

commit b9e8bcb9b09026bfc40519bfb4826a5a849794dd
Author: Mark Harviston <mark.harviston at gmail.com>
Date:   Tue Jun 11 20:15:23 2013 -0700

    updated and normalized description
---
 README              |  4 +--
 quamash/__init__.py | 78 +++++++++++++++++++++++++++--------------------------
 2 files changed, 42 insertions(+), 40 deletions(-)

diff --git a/README b/README
index 20d7beb..b894600 100644
--- a/README
+++ b/README
@@ -1,8 +1,8 @@
 =======
 Quamash
 =======
-Implementation of PEP 3156 Event-Loop with Qt
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Implementation of the PEP 3156 Event-Loop with Qt
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 :author: Mark Harviston <mark.harviston at gmail.com>
 
 Usage
diff --git a/quamash/__init__.py b/quamash/__init__.py
index 38dc333..9374fb1 100644
--- a/quamash/__init__.py
+++ b/quamash/__init__.py
@@ -3,7 +3,7 @@
 # © 2013 Mark Harviston <mark.harviston at gmail.com>
 # BSD License
 """
-PEP
+Implementation of the PEP 3156 Event-Loop with Qt
 """
 __author__ = 'Mark Harviston <mark.harviston at gmail.com>'
 __version__ = '0.1'
@@ -86,6 +86,44 @@ class QThreadExecutor(QtCore.QObject):
 		self.shutdown()
 
 
+def easycallback(fn):
+	"""
+	Decorator that wraps a callback in a signal, and packs & unpacks arguments,
+	Makes the wrapped function effectively threadsafe. If you call the function
+	from one thread, it will be executed in the thread the QObject has affinity
+	with.
+
+	Remember: only objects that inherit from QObject can support signals/slots
+
+	>>> class MyObject(QObject):
+	>>>     @easycallback
+	>>>     def mycallback(self):
+	>>>         dostuff()
+	>>>
+	>>> myobject = MyObject()
+	>>>
+	>>> @task
+	>>> def mytask():
+	>>>     myobject.mycallback()
+	>>>
+	>>> loop = QEventLoop()
+	>>> with loop:
+	>>>     loop.call_soon(mytask)
+	>>>     loop.run_forever()
+	"""
+	signal = QtCore.pyqtSignal(object, tuple, dict)
+
+	def out_wrapper(self, args, kwargs):
+		return fn(self, *args, **kwargs)
+
+	@wraps(fn)
+	def in_wrapper(self, *args, **kwargs):
+		return signal.emit(self, args, kwargs)
+
+	signal.connect(out_wrapper)
+	return in_wrapper
+
+
 class QEventLoop(QtCore.QObject, GuiEventLoop):
 	"""
 	Implementation of tulip event loop that uses the Qt Event loop
@@ -153,6 +191,7 @@ class QEventLoop(QtCore.QObject, GuiEventLoop):
 		super().stop()
 		self.app.exit()
 
+
 class Cancellable(object):
 	def __init__(self, timer, loop):
 		self.timer = timer
@@ -161,40 +200,3 @@ class Cancellable(object):
 	def cancel(self):
 		self.loop.remove(timer)
 		return self.timer.stop()
-
-def easycallback(fn):
-	"""
-	Decorator that wraps a callback in a signal, and packs & unpacks arguments,
-	Makes the wrapped function effectively threadsafe. If you call the function
-	from one thread, it will be executed in the thread the QObject has affinity
-	with.
-
-	Remember: only objects that inherit from QObject can support signals/slots
-
-	>>> class MyObject(QObject):
-	>>>     @easycallback
-	>>>     def mycallback(self):
-	>>>         dostuff()
-	>>>
-	>>> myobject = MyObject()
-	>>>
-	>>> @task
-	>>> def mytask():
-	>>>     myobject.mycallback()
-	>>>
-	>>> loop = QEventLoop()
-	>>> with loop:
-	>>>     loop.call_soon(mytask)
-	>>>     loop.run_forever()
-	"""
-	signal = QtCore.pyqtSignal(object, tuple, dict)
-
-	def out_wrapper(self, args, kwargs):
-		return fn(self, *args, **kwargs)
-
-	@wraps(fn)
-	def in_wrapper(self, *args, **kwargs):
-		return signal.emit(self, args, kwargs)
-
-	signal.connect(out_wrapper)
-	return in_wrapper

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-bitcoin/python-quamash.git



More information about the Pkg-bitcoin-commits mailing list