Skip to content

Commit

Permalink
Minor changes, mostly whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
balshetzer committed Apr 25, 2013
1 parent bff42fa commit 4a7ba12
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 87 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
include README.txt LICENSE.txt
include README.rst LICENSE.txt
recursive-include plover/assets *
recursive-include application *
2 changes: 1 addition & 1 deletion application/plover
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ except plover.oslayer.processlock.LockNotAcquiredException:
show_error('Error', 'Another instance of Plover is already running.')
except:
show_error('Unexpected error', traceback.format_exc())
os._exit(1)
os._exit(1)
83 changes: 38 additions & 45 deletions plover/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@

"""Configuration, initialization, and control of the Plover steno pipeline.
This module's single class, StenoEngine, encapsulates the
configuration, initialization, and control (starting and stopping) of
a complete stenographic processing pipeline, from reading stroke keys
from a stenotype machine to outputting translated English text to the
screen. Configuration parameters are read from a user-editable
configuration file. In addition, application log files are maintained
by this module. This module does not provide a graphical user
This module's single class, StenoEngine, encapsulates the configuration,
initialization, and control (starting and stopping) of a complete stenographic
processing pipeline, from reading stroke keys from a stenotype machine to
outputting translated English text to the screen. Configuration parameters are
read from a user-editable configuration file. In addition, application log files
are maintained by this module. This module does not provide a graphical user
interface.
"""
Expand Down Expand Up @@ -45,8 +44,8 @@ def __repr__(self):
def check_steno_config(config_params):
"""This will do several check on the given configuration
This method can be used in StenoEngine's __init__ method, but also
when exiting the configuration dialog.
This method can be used in StenoEngine's __init__ method, but also when
exiting the configuration dialog.
@return: a tuple composed of:
- a list of configuration errors
Expand Down Expand Up @@ -96,43 +95,40 @@ def check_steno_config(config_params):
return errors, (machine_type, user_dictionary)


class StenoEngine:
class StenoEngine(object):
"""Top-level class for using a stenotype machine for text input.
This class combines all the non-GUI pieces needed to use a
stenotype machine as a general purpose text entry device in an X11
environment. The entire pipeline consists of the following elements:
This class combines all the non-GUI pieces needed to use a stenotype machine
as a general purpose text entry device in an X11 environment. The entire
pipeline consists of the following elements:
machine: Typically an instance of the Stenotype class from one of
the submodules of plover.machine. This object is responsible for
monitoring a particular type of hardware for stenotype output and
passing that output on to the translator.
machine: Typically an instance of the Stenotype class from one of the
submodules of plover.machine. This object is responsible for monitoring a
particular type of hardware for stenotype output and passing that output on
to the translator.
translator: Typically an instance of the plover.steno.Translator
class. This object converts raw steno keys into strokes and
strokes into translations. The translation objects are then passed
on to the formatter.
translator: Typically an instance of the plover.steno.Translator class. This
object converts raw steno keys into strokes and strokes into translations.
The translation objects are then passed on to the formatter.
formatter: Typically an instance of the
plover.formatting.Formatter class. This object converts
translation objects into printable English text that can be
displayed to the user. Orthographic and lexical rules, such as
capitalization at the beginning of a sentence and pluralizing a
word, are taken care of here. The formatted text is then passed on
to the output.
formatter: Typically an instance of the plover.formatting.Formatter class.
This object converts translation objects into printable English text that
can be displayed to the user. Orthographic and lexical rules, such as
capitalization at the beginning of a sentence and pluralizing a word, are
taken care of here. The formatted text is then passed on to the output.
output: Typically an instance of the
plover.oslayer.keyboardcontrol.KeyboardEmulation class. This object
displays text on the screen.
plover.oslayer.keyboardcontrol.KeyboardEmulation class. This object displays
text on the screen.
In addition to the above pieces, a logger records timestamped
strokes and translations. Many of these pieces can be configured
by the user via a configuration file, which is by default located
at ~/.config/plover/plover.cfg and will be automatically generated
with reasonable default values if it doesn't already exist.
In addition to the above pieces, a logger records timestamped strokes and
translations. Many of these pieces can be configured by the user via a
configuration file, which is by default located at
~/.config/plover/plover.cfg and will be automatically generated with
reasonable default values if it doesn't already exist.
In general, the only methods of interest in an instance of this
class are start and stop.
In general, the only methods of interest in an instance of this class are
start and stop.
"""

Expand Down Expand Up @@ -215,9 +211,7 @@ def __init__(self, engine_command_callback):
auto_start = self.config.getboolean(conf.MACHINE_CONFIG_SECTION,
conf.MACHINE_AUTO_START_OPTION)
self.set_is_running(auto_start)




# Start the machine monitoring for steno strokes.
self.machine.start_capture()

Expand All @@ -237,11 +231,10 @@ def set_is_running(self, value):
def destroy(self):
"""Halts the stenography capture-translate-format-display pipeline.
Calling this method causes all worker threads involved to
terminate. This method should be called at least once if the
start method had been previously called. Calling this method
more than once or before the start method has been called has
no effect.
Calling this method causes all worker threads involved to terminate.
This method should be called at least once if the start method had been
previously called. Calling this method more than once or before the
start method has been called has no effect.
"""
if self.machine:
Expand Down
44 changes: 20 additions & 24 deletions plover/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@

# Dictionary constants.
JSON_EXTENSION = '.json'
ALTERNATIVE_ENCODING = 'latin-1'

# Logging constants.
LOG_EXTENSION = '.log'
Expand Down Expand Up @@ -80,13 +79,12 @@ def import_named_module(name, module_dictionary):
name -- A string that serves as a key to a Python module.
module_dictionary -- A dictionary containing name-module key
pairs. Both name and module are strings; name is an arbitrary
string and module is a string that specifies a module that can be
imported.
module_dictionary -- A dictionary containing name-module key pairs. Both
name and module are strings; name is an arbitrary string and module is a
string that specifies a module that can be imported.
Returns the references module, or None if the name is not a key in
the module_dictionary.
Returns the references module, or None if the name is not a key in the
module_dictionary.
"""
mod_name = module_dictionary.get(name, None)
Expand All @@ -103,8 +101,8 @@ def import_named_module(name, module_dictionary):
def get_config():
"""Return Plover's ConfigParser object.
If the given configuration file does not exist, a default
configuration file is created.
If the given configuration file does not exist, a default configuration file
is created.
"""
config_dir = CONFIG_DIR
Expand Down Expand Up @@ -139,8 +137,8 @@ def verify_config(config):
config -- A ConfigParser.RawConfigParser object.
Returns True if all parameters were found. Otherwise returns False
and adds default values for all parameters.
Returns True if all parameters were found. Otherwise returns False and adds
default values for all parameters.
"""
config_file = CONFIG_FILE
Expand Down Expand Up @@ -174,16 +172,14 @@ def get_serial_params(section, config):
Arguments:
section -- A string representing the section name containing the
parameters of interest.
section -- A string representing the section name containing the parameters
of interest.
config -- The ConfigParser object containing the parameters of
interest.
config -- The ConfigParser object containing the parameters of interest.
If config does not contain section, then a the default
serial.Serial parameters are returned. If not all parameters are
included in the section, then default values for the missing
parameters are used in their place.
If config does not contain section, then a the default serial.Serial
parameters are returned. If not all parameters are included in the section,
then default values for the missing parameters are used in their place.
"""
serial_params = {}
Expand Down Expand Up @@ -225,12 +221,12 @@ def set_serial_params(serial_port, section, config):
Arguments:
serial_port -- A serial.Serial object or an object with the same
constructor parameters. The parameters of this object will be
written to the configuration. If None, no action is taken.
serial_port -- A serial.Serial object or an object with the same constructor
parameters. The parameters of this object will be written to the
configuration. If None, no action is taken.
section -- A string representing the section name in which to
write the serial port parameters.
section -- A string representing the section name in which to write the
serial port parameters.
config -- The ConfigParser object containing to which to write.
Expand Down
7 changes: 3 additions & 4 deletions plover/gui/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@
class ConfigurationDialog(wx.Dialog):
"""A GUI for viewing and editing Plover configuration files.
Changes to the configuration file are saved when the GUI is
closed. Changes will take effect the next time the configuration
file is read by the application, which is typically after an
application restart.
Changes to the configuration file are saved when the GUI is closed. Changes
will take effect the next time the configuration file is read by the
application, which is typically after an application restart.
"""
def __init__(self, config_file,
Expand Down
5 changes: 2 additions & 3 deletions plover/gui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@

"""The main graphical user interface.
Plover's graphical user interface is a simple task bar icon that
pauses and resumes stenotype translation and allows for application
configuration.
Plover's graphical user interface is a simple task bar icon that pauses and
resumes stenotype translation and allows for application configuration.
"""

Expand Down
11 changes: 5 additions & 6 deletions plover/gui/serial_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,11 @@ def __init__(self,
Arguments:
serial -- A serial.Serial object or an object with the same
constructor parameters. This object determines the initial
values of the configuration interface. This is also the object
to which the configuration values are written when pressing
the OK button. The object is not changed if the Cancel button
is pressed.
serial -- A serial.Serial object or an object with the same constructor
parameters. This object determines the initial values of the
configuration interface. This is also the object to which the
configuration values are written when pressing the OK button. The object
is not changed if the Cancel button is pressed.
parent -- See wx.Dialog.
Expand Down
2 changes: 1 addition & 1 deletion plover/steno_dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,4 @@ def h(pairs):
try:
return json.loads(data, object_pairs_hook=h)
except UnicodeDecodeError:
return json.loads(data, conf.ALTERNATIVE_ENCODING, object_pairs_hook=h)
return json.loads(data, 'latin-1', object_pairs_hook=h)
2 changes: 1 addition & 1 deletion run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

if __name__ == '__main__':
suite = unittest.defaultTestLoader.discover(os.path.dirname(__file__))
unittest.TextTestRunner().run(suite)
unittest.TextTestRunner().run(suite)
2 changes: 1 addition & 1 deletion windows/pyinstaller.spec
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ exe = EXE(pyz,
debug=False,
strip=None,
upx=True,
console=False ,
console=False,
icon='plover.ico')

0 comments on commit 4a7ba12

Please sign in to comment.