-
Notifications
You must be signed in to change notification settings - Fork 182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rename "common" to "document" & simplify "new window" window logic #208
Conversation
6c615a2
to
c20021b
Compare
I was getting errors with the last commit when we ran the cli without a full path. This is now fixed.
|
a9afa8d
to
38d65c6
Compare
I'm testing out this PR in order to see if #204 is resolved, and I have some quick questions:
|
I think it would be logged on the terminal from which you launch dangerzone. But I've also had issues where exceptions are consumed somewhere along the codepath. It could be that.
So two windows get open when only one should open? Or that part is working?
Yes, that is #205 which was present in linux in 0.3.1. This is fixed in the other PR, I think. |
It might be that I'm testing it out by running the
I meant that this part is working correctly, yes.
Oh, I thought that #205 was affecting windows that closed due to conversion completion, not due to a user action. Ok, then we'll see this later on. |
That issue happened because it would close the application as soon as the first document was converted, regardless of whether any other was in progress.
Well, I've been testing this mostly by running from the |
Also, I see the following commits:
Might if I make their names a bit more consistent, such as "Rename X module/class to Y"? |
@apyrgio I have addressed all comments in the parallel branch simplify-common-2 |
@deeplow Thanks a lot for the changes. I'll take a look and report back. |
I have done some changes of my own, based on the above discussion, which you can find on the |
Whoops. I have accidentally deleted this while trying to force push and I see no way to reopen this via the UI. |
38d65c6
to
de19114
Compare
34b6031
to
7f583c6
Compare
@apyrgio I think the last thing missing is you changing your author email, if you so desire. |
Interesting. Mypy is throwing some errors but it doesn't throw them on my system.
|
It looks like this happening because some of CI doesn't have python3.10 version running. We might have moved too soon with #161. |
7f583c6
to
51205d4
Compare
Rebased and ready to be merged. Can I merge it @apyrgio? |
Gimme a bit to take a last look, and running the unit tests on Windows. Also, we need to squash "FIXUP" commits, since they pollute the history. |
51205d4
to
f8f01d3
Compare
Done |
Rename the `common` module and `common.Common` class to `document` and `document.Document` respectively. Also, rename the variables that hold instances of this class. This change reflects the fact that the class is responsible for tracking the state of the document. When we add bulk document conversion, allowing us to keep track of a document's state will be key. This name change is a step towards that.
I'm doing some final changes (proper author attribution to some of the commits), and I'm testing on a Windows machine. I'll ping you when you can rebase, sign, and merge. |
Avoid setting document's filename via document.filename and instead do it via object instantiation where possible. Incidentally this has to change some window logic. When select_document() is called it no longer checks if there is already an open window with no document selected yet. The user can open as many windows with unselected documents as they want.
Rename select_document() to new_window() to better encapsulate the fact that this function is opening a new Dangerzone window.
Factor out the filename validation logic and move it into the Document class. Previously, the filename validation logic was scattered across the CLI and GUI code. Also, introduce a new errors.py module whose purpose is to handle document-related errors, by providing: * A special exception for them (DocumentFilenameExcpetion) * A decorator that handles DocumentFilenameException, logs it and the underlying cause, and exits the program gracefully.
Implement Click's callback interface and create validators for the input/output filenames, using the logic from the Document class. This way, we can catch user errors as early as possible.
0fbb274
to
e2c9a9c
Compare
Make the Document class always resolve relative input/output file paths, which are usually passed as arguments by users. Previously, resolving relative filepaths was a job left to the instantiators of the Document class. This was error-prone since this conversion must happen in all the places where we instantiated the Document class.
Let the Document class suggest the default filename for the safe PDF, based on the provided input filename, appended with the extension `-safe.pdf`. Previously, this logic was copy-pasted throughout the code, which made it difficult to maintain.
Rename the `global_common` module and `global_common.GlobalCommon` class to `logic` and `logic.Dangerzone` respectively. Also rename variables that hold instances of this class. This change is part of the initial refactor to make the Dangerzone class handle the core logic of the Dangerzone project.
Rename the `gui.common` module and `gui.common.GuiCommon` class to `gui.logic` and `gui.logic.DangerzoneGui` respectively. We keep as is the original names of the variables that hold instances of this class, since they will change in subsequent commits. This change is part of the initial refactor to make the DangerzoneGui class handle the GUI logic of the Dangerzone project.
Simplify state sharing by having all dangerzone core logic in one single class instead of two.
e2c9a9c
to
3376b57
Compare
I've updated the branch with the following changes:
|
Simplify code logic for creating and handling documents through the renaming of
Common
class toDocumentHolder
and associated simplifications.When we support bulk document conversion we'll need to keep track of each document's state. This refactor opens way for that. A document holder does not represent a document in itself (e.g. can be instantiated without a document) but stores the input name, output name, and in the future possibly the conversion progress.
Clarification renames: some of the names were changed to better reflect the classes' or files' purpose.
common.py::Common
->document.py::DocumentHandler
global_common.py::GlobalCommon
->logic.py::DangerzoneCore
gui/common.py::GuiCommon
->gui/common.py::DangerzoneGui
Associated logic simplication:
DocumentHandler
, when a new filename is added, throwing anDocumentFilenameException
if that validation fails. (code was previously duplicated ingui_main
andcli_main
).DocumentHandler
instantiation)now when the users click new window, it simply opens a new window without extra validation to see if any window is already open and doesn't have a document associated to it.
And lastly, it adds unit tests for
document.py
(100% coverage)