You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As I understand, almost all Curtail logic is tightly coupled with its UI in CurtailWindow and CurtailPrefsWindow. Compressor class is not good too because it mixes JPEG and PNG compression steps and adding more types will not be easy in the future. How about reworking Curtail architecture to something like this:
Some examples and explanations:
Abstract Compressor consists of abstract compress method and abstract get_mime_type class method that indicates what types can be compressed with it. All concrete compressors inherit from it.
All compression operations are handled through Compression Manager. It owns a registry of compressors that could be used. When passed a file, it automatically chooses which compressor to use based on input file mime type and launches its compress method in a separate process. It also handles compression errors. EDIT: I can't yet describe how exactly the manager should notify the main window about compression completion.
classCompressionManager:
def__init__(self, settings_manager):
self.settings=settings_managerself.compressors= {}
defregister_compressor(self, ConcreteCompressor):
mime_type=ConcreteCompressor.get_mime_type()
ifmime_typenotinself.compressors:
self.compressors[mime_type] =ConcreteCompressor(self.settings)
defcompress(self, file_in, file_out):
file_mime_type=get_file_mime_type(file_in)
try:
# Should be launched in a separate processself.compressors[file_mime_type].compress(file_in, file_out)
exceptKeyError:
# No suitable compressor
...
exceptCompressionError:
# Internal compression error
...
# manager = CompressionManager(settings_manager)# manager.register_compressor(JPEGCompressor)# manager.compress("hello.jpg", "world.jpg") -> ok, has suitable compressor# manager.compress("hello.tiff", "world.tiff") -> no suitable compressor
Input Checker is a small helper class (or function) to preprocess/prevalidate incoming filenames, for example for their existence, and pass them to the Manager. To be defined.
All settings related operations and errors are handled by Settings Manager. Also it can have some kind of access control so for example Compression Manager have access to getters, but not setters. To be defined.
The text was updated successfully, but these errors were encountered:
Thank you for taking the time to think about a new structure. You are right about the fact that it will become necessary. I think that this will be for this summer... I keep this in mind and and I'll probably need some advice! :)
As I understand, almost all Curtail logic is tightly coupled with its UI in CurtailWindow and CurtailPrefsWindow. Compressor class is not good too because it mixes JPEG and PNG compression steps and adding more types will not be easy in the future. How about reworking Curtail architecture to something like this:
Some examples and explanations:
compress
method and abstractget_mime_type
class method that indicates what types can be compressed with it. All concrete compressors inherit from it.compress
method in a separate process. It also handles compression errors. EDIT: I can't yet describe how exactly the manager should notify the main window about compression completion.Input Checker is a small helper class (or function) to preprocess/prevalidate incoming filenames, for example for their existence, and pass them to the Manager. To be defined.
All settings related operations and errors are handled by Settings Manager. Also it can have some kind of access control so for example Compression Manager have access to getters, but not setters. To be defined.
The text was updated successfully, but these errors were encountered: