From: Uwe Hermann Date: Thu, 20 Nov 2014 19:36:55 +0000 (+0100) Subject: Minor cosmetics, typo fixes. X-Git-Url: http://sigrok.org/gitweb/?p=sigrok-meter.git;a=commitdiff_plain;h=480cdb7bc04548aec46b7342d6fa1acafa60331c Minor cosmetics, typo fixes. --- diff --git a/datamodel.py b/datamodel.py index 6e254f3..a7757e6 100644 --- a/datamodel.py +++ b/datamodel.py @@ -89,11 +89,11 @@ class MeasurementDataModel(QtGui.QStandardItemModel): 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, @@ -102,15 +102,15 @@ class MeasurementDataModel(QtGui.QStandardItemModel): 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) - rid = tuple(rid) # PySide returns a list + rid = tuple(rid) # PySide returns a list. 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) @@ -123,7 +123,7 @@ class MeasurementDataModel(QtGui.QStandardItemModel): @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) @@ -141,7 +141,7 @@ class MultimeterDelegate(QtGui.QStyledItemDelegate): '''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. @@ -177,7 +177,7 @@ class MultimeterDelegate(QtGui.QStyledItemDelegate): 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) @@ -185,14 +185,14 @@ class MultimeterDelegate(QtGui.QStyledItemDelegate): 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) - # 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) diff --git a/mainwindow.py b/mainwindow.py index 06a958e..2af07b2 100644 --- a/mainwindow.py +++ b/mainwindow.py @@ -66,7 +66,7 @@ class MainWindow(QtGui.QMainWindow): 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__)) @@ -114,12 +114,13 @@ class MainWindow(QtGui.QMainWindow): def show_about(self): text = textwrap.dedent('''\
- sigrok-meter
- 0.1.0
- Using libsigrok {} (lib version {}).
+ sigrok-meter 0.1.0

+ Using libsigrok {} (lib version {}).

http://www.sigrok.org

+ License: GNU GPL, version 3 or later
+
This program comes with ABSOLUTELY NO WARRANTY;
for details visit @@ -137,8 +138,7 @@ class MainWindow(QtGui.QMainWindow): @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) diff --git a/qtcompat.py b/qtcompat.py index 1457615..f5c1f19 100644 --- a/qtcompat.py +++ b/qtcompat.py @@ -42,7 +42,7 @@ def load_modules(force_pyside): _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 diff --git a/samplingthread.py b/samplingthread.py index 2c68622..017f895 100644 --- a/samplingthread.py +++ b/samplingthread.py @@ -27,7 +27,7 @@ QtCore = qtcompat.QtCore 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.''' @@ -47,7 +47,7 @@ class SamplingThread(QtCore.QObject): 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): @@ -78,7 +78,7 @@ class SamplingThread(QtCore.QObject): 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[^:]+)(?P(:[^:=]+=[^:=]+)*)$', ds) @@ -92,11 +92,11 @@ class SamplingThread(QtCore.QObject): 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: - raise RuntimeError('No driver called "{}".'.format(name)) + raise RuntimeError('No driver named "{}".'.format(name)) 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 - # process configuration string + # Process configuration string. 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] - # 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)) - # 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): @@ -175,18 +175,18 @@ class SamplingThread(QtCore.QObject): 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): - '''Starts sampling''' + '''Start sampling.''' 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() diff --git a/sigrok-meter b/sigrok-meter index ffda947..884ad2d 100755 --- a/sigrok-meter +++ b/sigrok-meter @@ -1,5 +1,4 @@ #!/usr/bin/env python - ## ## 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. - examples: + Examples: %(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): - 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 - 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) @@ -96,7 +95,7 @@ if __name__ == '__main__': 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)