Skip to content

Commit 5467ca1

Browse files
committed
Dealt with reviewers issues.
1 parent aaf9832 commit 5467ca1

File tree

4 files changed

+27
-11
lines changed

4 files changed

+27
-11
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ exclude_lines = [
2222

2323
[tool.poetry]
2424
name = "cryptojwt"
25-
version = "1.4.2"
25+
version = "1.5.0"
2626
description = "Python implementation of JWT, JWE, JWS and JWK"
2727
authors = ["Roland Hedberg <roland@catalogix.se>"]
2828
license = "Apache-2.0"

src/cryptojwt/key_bundle.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import time
77
from datetime import datetime
88
from functools import cmp_to_key
9+
from typing import List
910
from typing import Optional
1011

1112
import requests
@@ -751,7 +752,7 @@ def difference(self, bundle):
751752

752753
return [k for k in self._keys if k not in bundle]
753754

754-
def dump(self, cutoff: Optional[list] = None):
755+
def dump(self, exclude_attribute: Optional[List[str]] = None):
755756
_keys = []
756757
for _k in self._keys:
757758
_ser = _k.to_dict()
@@ -782,6 +783,10 @@ def dump(self, cutoff: Optional[list] = None):
782783
if self.source:
783784
res["source"] = self.source
784785

786+
if exclude_attribute:
787+
for attr in exclude_attribute:
788+
del res[attr]
789+
785790
return res
786791

787792
def load(self, spec):

src/cryptojwt/key_issuer.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import json
22
import logging
33
import os
4+
from typing import List
45
from typing import Optional
56

67
from requests import request
@@ -351,18 +352,17 @@ def __len__(self):
351352
nr += len(kb)
352353
return nr
353354

354-
def dump(self, exclude=None, cutoff: Optional[list] = None) -> dict:
355+
def dump(self, exclude_attribute: Optional[List[str]] = None) -> dict:
355356
"""
356357
Returns the content as a dictionary.
357358
358-
:param exclude: Issuer that should not be include in the dump
359-
:param cutoff: List of attribute name for objects that should be ignored.
359+
:param exclude_attribute: List of attribute names for objects that should be ignored.
360360
:return: A dictionary
361361
"""
362362

363363
_bundles = []
364364
for kb in self._bundles:
365-
_bundles.append(kb.dump(cutoff=cutoff))
365+
_bundles.append(kb.dump(exclude_attribute=exclude_attribute))
366366

367367
info = {
368368
"name": self.name,
@@ -373,6 +373,12 @@ def dump(self, exclude=None, cutoff: Optional[list] = None) -> dict:
373373
"remove_after": self.remove_after,
374374
"httpc_params": self.httpc_params,
375375
}
376+
377+
# remove after the fact
378+
if exclude_attribute:
379+
for attr in exclude_attribute:
380+
del info[attr]
381+
376382
return info
377383

378384
def load(self, info):

src/cryptojwt/key_jar.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -626,12 +626,17 @@ def copy(self):
626626
def __len__(self):
627627
return len(self._issuers)
628628

629-
def dump(self, exclude: Optional[bool] = None, cutoff: Optional[list] = None) -> dict:
629+
def dump(
630+
self,
631+
exclude_issuer: Optional[List[str]] = None,
632+
exclude_attribute: Optional[List[str]] = None,
633+
) -> dict:
630634
"""
631635
Returns the key jar content as dictionary
632636
633-
:param cutoff: list of attribute names that should be ignored when dumping.
634-
:type cutoff: list
637+
:param exclude_issuer: A list of issuers you don't want included.
638+
:param exclude_attribute: list of attribute names that should be ignored when dumping.
639+
:type exclude_attribute: list
635640
:return: A dictionary
636641
"""
637642

@@ -645,9 +650,9 @@ def dump(self, exclude: Optional[bool] = None, cutoff: Optional[list] = None) ->
645650

646651
_issuers = {}
647652
for _id, _issuer in self._issuers.items():
648-
if exclude and _issuer.name in exclude:
653+
if exclude_issuer and _issuer.name in exclude_issuer:
649654
continue
650-
_issuers[_id] = _issuer.dump(cutoff=cutoff)
655+
_issuers[_id] = _issuer.dump(exclude_attribute=exclude_attribute)
651656
info["issuers"] = _issuers
652657

653658
return info

0 commit comments

Comments
 (0)