From f616a8db0636239dd70c5089bd6b9096d415e9fa Mon Sep 17 00:00:00 2001 From: gryf Date: Tue, 27 Dec 2016 19:57:34 +0100 Subject: [PATCH] Removed bloated class and replace it with pure functions in 'plain' module --- fs_uae_wrapper/plain.py | 45 +++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/fs_uae_wrapper/plain.py b/fs_uae_wrapper/plain.py index da11661..b1aa737 100644 --- a/fs_uae_wrapper/plain.py +++ b/fs_uae_wrapper/plain.py @@ -8,33 +8,20 @@ import subprocess import sys -class Plain(object): - """Class for run fs-uae""" - - def run(self, conf_file, fs_uae_options): - """ - Run the emulation. - conf_file is a path to the configuration, - fs_uae_options is a list contains tokenized options to be passed to - fs-uae - """ - try: - subprocess.call(['fs-uae'] + [conf_file] + fs_uae_options) - except subprocess.CalledProcessError: - sys.stderr.write('Warning: fs-uae returned non 0 exit code\n') - return False - return True - - def clean(self): - """In this class, do nothing on exit""" - return - - -def run(config_file, fs_uae_options, _, unused): - """Run fs-uae with provided config file and options""" - - runner = Plain() +def run_plain(conf_file, fs_uae_options): + """ + Run the emulation. + conf_file is a path to the configuration, + fs_uae_options is an dict-like object which contains commandline options to + be passed to fs-uae + """ try: - return runner.run(config_file, fs_uae_options) - finally: - runner.clean() + subprocess.call(['fs-uae'] + [conf_file] + fs_uae_options.list()) + except subprocess.CalledProcessError: + sys.stderr.write('Warning: fs-uae returned non 0 exit code\n') + return True + + +def run(config_file, fs_uae_options, _): + """Run fs-uae with provided config file and options""" + return run_plain(config_file, fs_uae_options)