Skip to content
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

Closed
wants to merge 6 commits into from

Conversation

pubpub-zz
Copy link
Collaborator

@pubpub-zz pubpub-zz commented Jan 6, 2024

closes #2391

still test to be added

if permissions_code is None:
permissions_code = cast(
int,
cast(DictionaryObject, self.trailer[TK.ENCRYPT]).get("/P", -1)
Copy link
Collaborator

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?

Copy link

codecov bot commented Jan 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (b256965) 94.35% compared to head (312f92d) 94.39%.

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.
📢 Have feedback on the report? Share it here.

@@ -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]
Copy link
Collaborator

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?

Copy link
Member

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 🙈

@stefan6419846
Copy link
Collaborator

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 UserAccessPermissions enumeration directly and thus avoids doing the manual mapping as required for now.

@pubpub-zz pubpub-zz closed this Jan 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PDF permission retrieval
3 participants