]> sigrok.org Git - sigrok-meter.git/commitdiff
Minor cosmetics, typo fixes.
authorUwe Hermann <redacted>
Thu, 20 Nov 2014 19:36:55 +0000 (20:36 +0100)
committerUwe Hermann <redacted>
Thu, 20 Nov 2014 21:56:32 +0000 (22:56 +0100)
datamodel.py
mainwindow.py
qtcompat.py
samplingthread.py
sigrok-meter

index 6e254f3998057655b502385f6b495b1f0b862bf2..a7757e62dadebc76c6e90395e3a20623f7381fe2 100644 (file)
@@ -89,11 +89,11 @@ class MeasurementDataModel(QtGui.QStandardItemModel):
         return '{:f}'.format(mag)
 
     def getItem(self, device, channel):
         return '{:f}'.format(mag)
 
     def getItem(self, device, channel):
-        '''Returns the item for the device + channel combination from the model,
-        or creates a new item if no existing one matches.'''
+        '''Return the item for the device + channel combination from the
+        model, or create a new item if no existing one matches.'''
 
 
-        # unique identifier for the device + channel
-        # TODO: isn't there something better?
+        # Unique identifier for the device + channel.
+        # TODO: Isn't there something better?
         uid = (
             device.vendor,
             device.model,
         uid = (
             device.vendor,
             device.model,
@@ -102,15 +102,15 @@ class MeasurementDataModel(QtGui.QStandardItemModel):
             channel.index
         )
 
             channel.index
         )
 
-        # find the correct item in the model
+        # Find the correct item in the model.
         for row in range(self.rowCount()):
             item = self.item(row)
             rid = item.data(MeasurementDataModel._idRole)
         for row in range(self.rowCount()):
             item = self.item(row)
             rid = item.data(MeasurementDataModel._idRole)
-            rid = tuple(rid) # PySide returns a list
+            rid = tuple(rid) # PySide returns a list.
             if uid == rid:
                 return item
 
             if uid == rid:
                 return item
 
-        # nothing found, create a new item
+        # Nothing found, create a new item.
         desc = '{} {}, channel "{}"'.format(
                 device.vendor, device.model, channel.name)
 
         desc = '{} {}, channel "{}"'.format(
                 device.vendor, device.model, channel.name)
 
@@ -123,7 +123,7 @@ class MeasurementDataModel(QtGui.QStandardItemModel):
 
     @QtCore.Slot(object, object, object)
     def update(self, device, channel, data):
 
     @QtCore.Slot(object, object, object)
     def update(self, device, channel, data):
-        '''Updates the data for the device (+channel) with the most recent
+        '''Update the data for the device (+channel) with the most recent
         measurement from the given payload.'''
 
         item = self.getItem(device, channel)
         measurement from the given payload.'''
 
         item = self.getItem(device, channel)
@@ -141,7 +141,7 @@ class MultimeterDelegate(QtGui.QStyledItemDelegate):
     '''Delegate to show the data items from a MeasurementDataModel.'''
 
     def __init__(self, parent, font):
     '''Delegate to show the data items from a MeasurementDataModel.'''
 
     def __init__(self, parent, font):
-        '''Initializes the delegate.
+        '''Initialize the delegate.
 
         :param font: Font used for the description text, the value is drawn
                      with a slightly bigger and bold variant of the font.
 
         :param font: Font used for the description text, the value is drawn
                      with a slightly bigger and bold variant of the font.
@@ -177,7 +177,7 @@ class MultimeterDelegate(QtGui.QStyledItemDelegate):
         value, unit = index.data(QtCore.Qt.DisplayRole)
         desc = index.data(MeasurementDataModel.descRole)
 
         value, unit = index.data(QtCore.Qt.DisplayRole)
         desc = index.data(MeasurementDataModel.descRole)
 
-        # description in the top left corner
+        # Description in the top left corner.
         painter.setFont(self._nfont)
         p = options.rect.topLeft()
         p += QtCore.QPoint(self._nfontheight, 2 * self._nfontheight)
         painter.setFont(self._nfont)
         p = options.rect.topLeft()
         p += QtCore.QPoint(self._nfontheight, 2 * self._nfontheight)
@@ -185,14 +185,14 @@ class MultimeterDelegate(QtGui.QStyledItemDelegate):
 
         painter.setFont(self._bfont)
 
 
         painter.setFont(self._bfont)
 
-        # value about in the center
+        # Value about in the center.
         p = options.rect.center()
         p += QtCore.QPoint(-3 * self._space_width, self._nfontheight)
         rect = QtCore.QRect(0, 0, self._value_width, 2 * self._nfontheight)
         rect.moveCenter(p)
         painter.drawText(rect, QtCore.Qt.AlignRight, value)
 
         p = options.rect.center()
         p += QtCore.QPoint(-3 * self._space_width, self._nfontheight)
         rect = QtCore.QRect(0, 0, self._value_width, 2 * self._nfontheight)
         rect.moveCenter(p)
         painter.drawText(rect, QtCore.Qt.AlignRight, value)
 
-        # unit right of the value
+        # Unit right of the value.
         rect.moveLeft(rect.right())
         rect.adjust(self._space_width, 0, 0, 0)
         painter.drawText(rect, QtCore.Qt.AlignLeft, unit)
         rect.moveLeft(rect.right())
         rect.adjust(self._space_width, 0, 0, 0)
         painter.drawText(rect, QtCore.Qt.AlignLeft, unit)
index 06a958ed1d35a9d05b3671588d3e9f50eafda269..2af07b2a0018bf31b821a9a268e7fa802b03c297 100644 (file)
@@ -66,7 +66,7 @@ class MainWindow(QtGui.QMainWindow):
 
     def setup_ui(self):
         self.setWindowTitle('sigrok-meter')
 
     def setup_ui(self):
         self.setWindowTitle('sigrok-meter')
-        # resizing the listView below will increase this again
+        # Resizing the listView below will increase this again.
         self.resize(10, 10)
 
         p = os.path.abspath(os.path.dirname(__file__))
         self.resize(10, 10)
 
         p = os.path.abspath(os.path.dirname(__file__))
@@ -114,12 +114,13 @@ class MainWindow(QtGui.QMainWindow):
     def show_about(self):
         text = textwrap.dedent('''\
             <div align="center">
     def show_about(self):
         text = textwrap.dedent('''\
             <div align="center">
-                <b>sigrok-meter</b><br/>
-                0.1.0<br/>
-                Using libsigrok {} (lib version {}).<br/>
+                <b>sigrok-meter 0.1.0</b><br/><br/>
+                Using libsigrok {} (lib version {}).<br/><br/>
                 <a href='http://www.sigrok.org'>
                          http://www.sigrok.org</a><br/>
                 <br/>
                 <a href='http://www.sigrok.org'>
                          http://www.sigrok.org</a><br/>
                 <br/>
+                License: GNU GPL, version 3 or later<br/>
+                <br/>
                 This program comes with ABSOLUTELY NO WARRANTY;<br/>
                 for details visit
                 <a href='http://www.gnu.org/licenses/gpl.html'>
                 This program comes with ABSOLUTELY NO WARRANTY;<br/>
                 for details visit
                 <a href='http://www.gnu.org/licenses/gpl.html'>
@@ -137,8 +138,7 @@ class MainWindow(QtGui.QMainWindow):
 
     @QtCore.Slot(object, int, int)
     def modelRowsInserted(self, parent, start, end):
 
     @QtCore.Slot(object, int, int)
     def modelRowsInserted(self, parent, start, end):
-        '''Resizes the list view to the size of the content.'''
-
+        '''Resize the list view to the size of the content.'''
         rows = self.model.rowCount()
         dh = self.delegate.sizeHint().height()
         self.listView.setMinimumHeight(dh * rows)
         rows = self.model.rowCount()
         dh = self.delegate.sizeHint().height()
         self.listView.setMinimumHeight(dh * rows)
index 1457615c8ba249152801e233e679a6418b1d9e74..f5c1f19a5de7b3bc65c98d82ee259d5221278055 100644 (file)
@@ -42,7 +42,7 @@ def load_modules(force_pyside):
             _QtCore.Signal = _QtCore.pyqtSignal
             _QtCore.Slot = _QtCore.pyqtSlot
         except:
             _QtCore.Signal = _QtCore.pyqtSignal
             _QtCore.Slot = _QtCore.pyqtSlot
         except:
-            sys.stderr.write('import of PyQt4 failed, using PySide\n')
+            sys.stderr.write('Import of PyQt4 failed, using PySide,\n')
             import PySide.QtCore as _QtCore
             import PySide.QtGui as _QtGui
 
             import PySide.QtCore as _QtCore
             import PySide.QtGui as _QtGui
 
index 2c686223c0e81c9373c0e1e8c1ba9a609ebfa3b2..017f895a7a25c8471a028e58bde6fb2db8398b03 100644 (file)
@@ -27,7 +27,7 @@ QtCore = qtcompat.QtCore
 QtGui = qtcompat.QtGui
 
 class SamplingThread(QtCore.QObject):
 QtGui = qtcompat.QtGui
 
 class SamplingThread(QtCore.QObject):
-    '''A class that handles the reception of sigrok packets in the background.'''
+    '''Class that handles the reception of sigrok packets in the background.'''
 
     class Worker(QtCore.QObject):
         '''Helper class that does the actual work in another thread.'''
 
     class Worker(QtCore.QObject):
         '''Helper class that does the actual work in another thread.'''
@@ -47,7 +47,7 @@ class SamplingThread(QtCore.QObject):
             self.sampling = False
 
         def parse_configstring(self, cs):
             self.sampling = False
 
         def parse_configstring(self, cs):
-            '''Dissects a config string and returns the options as a
+            '''Dissect a config string and return the options as a
             dictionary.'''
 
             def parse_option(k, v):
             dictionary.'''
 
             def parse_option(k, v):
@@ -78,7 +78,7 @@ class SamplingThread(QtCore.QObject):
             return dict(opts)
 
         def parse_driverstring(self, ds):
             return dict(opts)
 
         def parse_driverstring(self, ds):
-            '''Dissects the driver string and returns a tuple consiting of
+            '''Dissect the driver string and return a tuple consisting of
             the driver name and the options (as a dictionary).'''
 
             m = re.match('(?P<name>[^:]+)(?P<opts>(:[^:=]+=[^:=]+)*)$', ds)
             the driver name and the options (as a dictionary).'''
 
             m = re.match('(?P<name>[^:]+)(?P<opts>(:[^:=]+=[^:=]+)*)$', ds)
@@ -92,11 +92,11 @@ class SamplingThread(QtCore.QObject):
         def start_sampling(self):
             devices = []
             for (ds, cs) in self.drivers:
         def start_sampling(self):
             devices = []
             for (ds, cs) in self.drivers:
-                # process driver string
+                # Process driver string.
                 try:
                     (name, opts) = self.parse_driverstring(ds)
                     if not name in self.context.drivers:
                 try:
                     (name, opts) = self.parse_driverstring(ds)
                     if not name in self.context.drivers:
-                        raise RuntimeError('No driver called "{}".'.format(name))
+                        raise RuntimeError('No driver named "{}".'.format(name))
 
                     driver = self.context.drivers[name]
                     devs = driver.scan(**opts)
 
                     driver = self.context.drivers[name]
                     devs = driver.scan(**opts)
@@ -109,7 +109,7 @@ class SamplingThread(QtCore.QObject):
                         'Error processing driver string:\n{}'.format(e))
                     return
 
                         'Error processing driver string:\n{}'.format(e))
                     return
 
-                # process configuration string
+                # Process configuration string.
                 try:
                     cfgs = self.parse_configstring(cs)
                     for k, v in cfgs.items():
                 try:
                     cfgs = self.parse_configstring(cs)
                     for k, v in cfgs.items():
@@ -157,13 +157,13 @@ class SamplingThread(QtCore.QObject):
             # TODO: find a device with multiple channels in one packet
             channel = packet.payload.channels[0]
 
             # TODO: find a device with multiple channels in one packet
             channel = packet.payload.channels[0]
 
-            # the most recent value
+            # The most recent value.
             value = packet.payload.data[0][-1]
 
             self.measured.emit(device, channel,
                     (value, packet.payload.unit, packet.payload.mq_flags))
 
             value = packet.payload.data[0][-1]
 
             self.measured.emit(device, channel,
                     (value, packet.payload.unit, packet.payload.mq_flags))
 
-    # signal used to start the worker across threads
+    # Signal used to start the worker across threads.
     _start_signal = QtCore.Signal()
 
     def __init__(self, context, drivers):
     _start_signal = QtCore.Signal()
 
     def __init__(self, context, drivers):
@@ -175,18 +175,18 @@ class SamplingThread(QtCore.QObject):
 
         self._start_signal.connect(self.worker.start_sampling)
 
 
         self._start_signal.connect(self.worker.start_sampling)
 
-        # expose the signals of the worker
+        # Expose the signals of the worker.
         self.measured = self.worker.measured
         self.error = self.worker.error
 
         self.thread.start()
 
     def start(self):
         self.measured = self.worker.measured
         self.error = self.worker.error
 
         self.thread.start()
 
     def start(self):
-        '''Starts sampling'''
+        '''Start sampling.'''
         self._start_signal.emit()
 
     def stop(self):
         self._start_signal.emit()
 
     def stop(self):
-        '''Stops sampling and the background thread.'''
+        '''Stop sampling and stop the background thread.'''
         self.worker.stop_sampling()
         self.thread.quit()
         self.thread.wait()
         self.worker.stop_sampling()
         self.thread.quit()
         self.thread.wait()
index ffda9471f41bf00b4ea4be7b3fe6e7c9aae45b79..884ad2d08781a187db2f83f67615484166061ca8 100755 (executable)
@@ -1,5 +1,4 @@
 #!/usr/bin/env python
 #!/usr/bin/env python
-
 ##
 ## This file is part of the sigrok-meter project.
 ##
 ##
 ## This file is part of the sigrok-meter project.
 ##
@@ -37,7 +36,7 @@ def parse_cli():
             CONFIG is applied to the nth DRIVER. If there are more drivers
             than configs, the remaining drivers use the default configuration.
 
             CONFIG is applied to the nth DRIVER. If there are more drivers
             than configs, the remaining drivers use the default configuration.
 
-            examples:
+            Examples:
 
               %(prog)s --driver tecpel-dmm-8061-ser:conn=/dev/ttyUSB0
 
 
               %(prog)s --driver tecpel-dmm-8061-ser:conn=/dev/ttyUSB0
 
@@ -67,13 +66,13 @@ def parse_cli():
     args = parser.parse_args()
 
     if len(args.config) > len(args.driver):
     args = parser.parse_args()
 
     if len(args.config) > len(args.driver):
-        sys.exit('error: more configurations than drivers given')
+        sys.exit('Error: More configurations than drivers given.')
 
 
-    # merge drivers and configurations into a list of tuples
+    # Merge drivers and configurations into a list of tuples.
     setattr(args, 'drivers', [])
     if not args.driver:
         args.drivers = default_drivers
     setattr(args, 'drivers', [])
     if not args.driver:
         args.drivers = default_drivers
-        sys.stderr.write('no driver given, using demo driver\n')
+        sys.stderr.write('No driver given, using demo driver.\n')
     if args.driver:
         args.config.extend([''] * (len(args.driver) - len(args.config)))
         args.drivers = zip(args.driver, args.config)
     if args.driver:
         args.config.extend([''] * (len(args.driver) - len(args.config)))
         args.drivers = zip(args.driver, args.config)
@@ -96,7 +95,7 @@ if __name__ == '__main__':
         loglevel = sr.LogLevel.get(args.loglevel)
         context.log_level = loglevel
     except:
         loglevel = sr.LogLevel.get(args.loglevel)
         context.log_level = loglevel
     except:
-        sys.exit('error: invalid log level')
+        sys.exit('Error: invalid log level.')
 
     app = QtGui.QApplication([])
     s = mainwindow.MainWindow(context, args.drivers)
 
     app = QtGui.QApplication([])
     s = mainwindow.MainWindow(context, args.drivers)