-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
ENH: ease Permissions readability/writability #2397
Conversation
Issue due to unclosure of temporary file closes py-pdf#2394
if permissions_code is None: | ||
permissions_code = cast( | ||
int, | ||
cast(DictionaryObject, self.trailer[TK.ENCRYPT]).get("/P", -1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use self._encryption.P
here?
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2397 +/- ##
==========================================
+ Coverage 94.35% 94.39% +0.04%
==========================================
Files 43 43
Lines 7577 7599 +22
Branches 1519 1529 +10
==========================================
+ Hits 7149 7173 +24
+ Misses 265 264 -1
+ Partials 163 162 -1 ☔ View full report in Codecov by Sentry. |
@@ -1065,7 +1065,9 @@ def encrypt( | |||
user_password: str, | |||
owner_password: Optional[str] = None, | |||
use_128bit: bool = True, | |||
permissions_flag: UserAccessPermissions = ALL_DOCUMENT_PERMISSIONS, | |||
permissions_flag: Union[ | |||
UserAccessPermissions, Dict[str, bool] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we really complicate this API further? We cannot we just provide a convenience method on UserAccessPermissions
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd also prefer not to add the string versions here. I regret adding them in the first place 🙈
Just as a note: As mentioned in #2391 (comment), I have a corresponding POC here as well and just want to do it in one clean commit, thus did not yet create a PR myself until I am in office again - the advantage would be that it relies on the |
closes #2391
still test to be added