mirror of
https://github.com/gryf/fs-uae-wrapper.git
synced 2025-12-19 20:38:06 +01:00
Refactor wrapper modules to have a main class with the same name
This commit is contained in:
@@ -11,13 +11,13 @@ from fs_uae_wrapper import base
|
||||
from fs_uae_wrapper import utils
|
||||
|
||||
|
||||
class Archive(base.ArchiveBase):
|
||||
class Wrapper(base.ArchiveBase):
|
||||
"""
|
||||
Class for performing extracting archive, copying emulator files, and
|
||||
cleaning it back again
|
||||
"""
|
||||
def __init__(self, conf_file, fsuae_options, configuration):
|
||||
super(Archive, self).__init__(conf_file, fsuae_options, configuration)
|
||||
super(Wrapper, self).__init__(conf_file, fsuae_options, configuration)
|
||||
self.archive_type = None
|
||||
|
||||
def run(self):
|
||||
@@ -29,7 +29,7 @@ class Archive(base.ArchiveBase):
|
||||
- run the emulation
|
||||
- optionally make archive save state
|
||||
"""
|
||||
if not super(Archive, self).run():
|
||||
if not super(Wrapper, self).run():
|
||||
return False
|
||||
|
||||
if not self._extract():
|
||||
@@ -78,7 +78,7 @@ class Archive(base.ArchiveBase):
|
||||
def run(config_file, fsuae_options, configuration):
|
||||
"""Run fs-uae with provided config file and options"""
|
||||
|
||||
runner = Archive(config_file, fsuae_options, configuration)
|
||||
runner = Wrapper(config_file, fsuae_options, configuration)
|
||||
try:
|
||||
return runner.run()
|
||||
finally:
|
||||
|
||||
@@ -11,7 +11,7 @@ name.
|
||||
from fs_uae_wrapper import base
|
||||
|
||||
|
||||
class CD32(base.ArchiveBase):
|
||||
class Wrapper(base.ArchiveBase):
|
||||
"""
|
||||
Class for performing extracting archive, copying emulator files, and
|
||||
cleaning it back again
|
||||
@@ -28,7 +28,7 @@ class CD32(base.ArchiveBase):
|
||||
- run the emulation
|
||||
- archive save state
|
||||
"""
|
||||
super(CD32, self).run()
|
||||
super(Wrapper, self).run()
|
||||
if not self._validate_options():
|
||||
return False
|
||||
|
||||
@@ -51,7 +51,7 @@ class CD32(base.ArchiveBase):
|
||||
def run(config_file, fsuae_options, configuration):
|
||||
"""Run fs-uae with provided config file and options"""
|
||||
|
||||
runner = CD32(config_file, fsuae_options, configuration)
|
||||
runner = Wrapper(config_file, fsuae_options, configuration)
|
||||
try:
|
||||
return runner.run()
|
||||
finally:
|
||||
|
||||
@@ -4,7 +4,7 @@ Wrapper module with preserved save state in archive file.
|
||||
from fs_uae_wrapper import base
|
||||
|
||||
|
||||
class SaveState(base.Base):
|
||||
class Wrapper(base.Base):
|
||||
"""
|
||||
Preserve save state.
|
||||
"""
|
||||
@@ -16,8 +16,7 @@ class SaveState(base.Base):
|
||||
parameters
|
||||
configuration: is config dictionary created out of config file
|
||||
"""
|
||||
super(SaveState, self).__init__(conf_file, fsuae_options,
|
||||
configuration)
|
||||
super(Wrapper, self).__init__(conf_file, fsuae_options, configuration)
|
||||
self.arch_filepath = None
|
||||
self.all_options['wrapper_save_state'] = '1'
|
||||
|
||||
@@ -31,7 +30,7 @@ class SaveState(base.Base):
|
||||
- run the emulation
|
||||
- optionally make archive save state
|
||||
"""
|
||||
if not super(SaveState, self).run():
|
||||
if not super(Wrapper, self).run():
|
||||
return False
|
||||
|
||||
self._load_save()
|
||||
@@ -52,7 +51,7 @@ class SaveState(base.Base):
|
||||
def run(config_file, fsuae_options, configuration):
|
||||
"""Run fs-uae with provided config file and options"""
|
||||
|
||||
runner = SaveState(config_file, fsuae_options, configuration)
|
||||
runner = Wrapper(config_file, fsuae_options, configuration)
|
||||
try:
|
||||
return runner.run()
|
||||
finally:
|
||||
|
||||
@@ -30,7 +30,7 @@ class TestArchive(TestCase):
|
||||
def test_validate_options(self, which):
|
||||
which.return_value = 'unrar'
|
||||
|
||||
arch = archive.Archive('Config.fs-uae', utils.CmdOption(), {})
|
||||
arch = archive.Wrapper('Config.fs-uae', utils.CmdOption(), {})
|
||||
self.assertFalse(arch._validate_options())
|
||||
arch.all_options = {'wrapper': 'archive'}
|
||||
|
||||
@@ -42,7 +42,7 @@ class TestArchive(TestCase):
|
||||
|
||||
@mock.patch('tempfile.mkdtemp')
|
||||
@mock.patch('fs_uae_wrapper.path.which')
|
||||
@mock.patch('fs_uae_wrapper.archive.Archive._make_archive')
|
||||
@mock.patch('fs_uae_wrapper.archive.Wrapper._make_archive')
|
||||
@mock.patch('fs_uae_wrapper.base.ArchiveBase._save_save')
|
||||
@mock.patch('fs_uae_wrapper.base.ArchiveBase._get_saves_dir')
|
||||
@mock.patch('fs_uae_wrapper.base.ArchiveBase._run_emulator')
|
||||
@@ -61,7 +61,7 @@ class TestArchive(TestCase):
|
||||
make_arch.return_value = False
|
||||
which.return_value = 'rar'
|
||||
|
||||
arch = archive.Archive('Config.fs-uae', utils.CmdOption(), {})
|
||||
arch = archive.Wrapper('Config.fs-uae', utils.CmdOption(), {})
|
||||
self.assertFalse(arch.run())
|
||||
|
||||
arch.all_options = {'wrapper': 'archive',
|
||||
@@ -103,7 +103,7 @@ class TestArchive(TestCase):
|
||||
title.return_value = ''
|
||||
carch.return_value = False
|
||||
|
||||
arch = archive.Archive('Config.fs-uae', utils.CmdOption(), {})
|
||||
arch = archive.Wrapper('Config.fs-uae', utils.CmdOption(), {})
|
||||
arch.dir = self.dirname
|
||||
arch.arch_filepath = os.path.join(self.dirname, 'foo.tgz')
|
||||
arch.all_options = {}
|
||||
|
||||
@@ -30,7 +30,7 @@ class TestCD32(TestCase):
|
||||
save_state.return_value = False
|
||||
which.return_value = 'unrar'
|
||||
|
||||
acd32 = cd32.CD32('Config.fs-uae', utils.CmdOption(), {})
|
||||
acd32 = cd32.Wrapper('Config.fs-uae', utils.CmdOption(), {})
|
||||
self.assertFalse(acd32.run())
|
||||
|
||||
acd32.all_options = {'wrapper': 'cd32',
|
||||
|
||||
@@ -42,7 +42,7 @@ class TestSaveState(TestCase):
|
||||
save_state.return_value = False
|
||||
which.return_value = 'rar'
|
||||
|
||||
arch = savestate.SaveState('Config.fs-uae', utils.CmdOption(), {})
|
||||
arch = savestate.Wrapper('Config.fs-uae', utils.CmdOption(), {})
|
||||
self.assertFalse(arch.run())
|
||||
|
||||
arch.all_options = {'wrapper': 'savestate',
|
||||
@@ -69,7 +69,7 @@ class TestSaveState(TestCase):
|
||||
def test_validate_options(self, which):
|
||||
which.return_value = 'unrar'
|
||||
|
||||
arch = savestate.SaveState('Config.fs-uae', utils.CmdOption(), {})
|
||||
arch = savestate.Wrapper('Config.fs-uae', utils.CmdOption(), {})
|
||||
self.assertFalse(arch._validate_options())
|
||||
|
||||
arch.all_options['wrapper'] = 'savestate'
|
||||
|
||||
Reference in New Issue
Block a user