Skip to content

Commit b48bc23

Browse files
committed
Auto-format with isort
Used command: ``` isort --line-length=80 --extend-skip-glob='*/_vendor' \ --profile=black --project=securesystemslib . ``` Signed-off-by: Lukas Puehringer <[email protected]>
1 parent 8531f7d commit b48bc23

34 files changed

+204
-243
lines changed

securesystemslib/ecdsa_keys.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,15 @@
3434
CRYPTO = True
3535
NO_CRYPTO_MSG = "ECDSA key support requires the cryptography library"
3636
try:
37+
from cryptography.exceptions import InvalidSignature, UnsupportedAlgorithm
3738
from cryptography.hazmat.backends import default_backend
38-
from cryptography.hazmat.primitives import hashes
39+
from cryptography.hazmat.primitives import hashes, serialization
3940
from cryptography.hazmat.primitives.asymmetric import ec
40-
41-
from cryptography.hazmat.primitives import serialization
42-
43-
from cryptography.hazmat.primitives.serialization import load_pem_public_key
4441
from cryptography.hazmat.primitives.serialization import (
4542
load_pem_private_key,
43+
load_pem_public_key,
4644
)
4745

48-
from cryptography.exceptions import InvalidSignature, UnsupportedAlgorithm
49-
5046
_SCHEME_HASHER = {
5147
"ecdsa-sha2-nistp256": ec.ECDSA(hashes.SHA256()),
5248
"ecdsa-sha2-nistp384": ec.ECDSA(hashes.SHA384()),
@@ -56,8 +52,7 @@
5652
CRYPTO = False
5753

5854
# Perform object format-checking and add ability to handle/raise exceptions.
59-
from securesystemslib import exceptions
60-
from securesystemslib import formats
55+
from securesystemslib import exceptions, formats
6156

6257
_SUPPORTED_ECDSA_SCHEMES = ["ecdsa-sha2-nistp256"]
6358

securesystemslib/ed25519_keys.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,22 +64,20 @@
6464
NACL = True
6565
NO_NACL_MSG = "ed25519 key support requires the nacl library"
6666
try:
67-
from nacl.encoding import RawEncoder
68-
from nacl.signing import SigningKey, VerifyKey
69-
7067
# avoid conflicts with own exceptions of same name
7168
from nacl import exceptions as nacl_exceptions
69+
from nacl.encoding import RawEncoder
70+
from nacl.signing import SigningKey, VerifyKey
7271
except ImportError:
7372
NACL = False
7473

74+
from securesystemslib import exceptions, formats
75+
7576
# The optimized pure Python implementation of Ed25519. If
7677
# PyNaCl cannot be imported and an attempt to use is made in this module, a
7778
# 'securesystemslib.exceptions.UnsupportedLibraryError' exception is raised.
7879
from securesystemslib._vendor.ed25519 import ed25519 as python_ed25519
7980

80-
from securesystemslib import exceptions
81-
from securesystemslib import formats
82-
8381
# Supported ed25519 signing schemes: 'ed25519'. The pure Python implementation
8482
# (i.e., ed25519') and PyNaCl (i.e., 'nacl', libsodium + Python bindings)
8583
# modules are currently supported in the creation of 'ed25519' signatures.

securesystemslib/gpg/common.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,38 @@
1717
call them.
1818
1919
"""
20-
import struct
2120
import binascii
22-
import logging
2321
import collections
22+
import logging
23+
import struct
2424

2525
from securesystemslib import formats
2626
from securesystemslib.gpg import util as gpg_util
27-
from securesystemslib.gpg.exceptions import (
28-
PacketVersionNotSupportedError,
29-
SignatureAlgorithmNotSupportedError,
30-
KeyNotFoundError,
31-
PacketParsingError,
32-
)
3327
from securesystemslib.gpg.constants import (
28+
FULL_KEYID_SUBPACKET,
29+
KEY_EXPIRATION_SUBPACKET,
3430
PACKET_TYPE_PRIMARY_KEY,
35-
PACKET_TYPE_USER_ID,
36-
PACKET_TYPE_USER_ATTR,
37-
PACKET_TYPE_SUB_KEY,
3831
PACKET_TYPE_SIGNATURE,
39-
SUPPORTED_PUBKEY_PACKET_VERSIONS,
40-
SIGNATURE_TYPE_BINARY,
41-
SIGNATURE_TYPE_CERTIFICATES,
42-
SIGNATURE_TYPE_SUB_KEY_BINDING,
43-
SUPPORTED_SIGNATURE_PACKET_VERSIONS,
44-
FULL_KEYID_SUBPACKET,
32+
PACKET_TYPE_SUB_KEY,
33+
PACKET_TYPE_USER_ATTR,
34+
PACKET_TYPE_USER_ID,
4535
PARTIAL_KEYID_SUBPACKET,
36+
PRIMARY_USERID_SUBPACKET,
4637
SHA1,
4738
SHA256,
4839
SHA512,
49-
KEY_EXPIRATION_SUBPACKET,
50-
PRIMARY_USERID_SUBPACKET,
5140
SIG_CREATION_SUBPACKET,
41+
SIGNATURE_TYPE_BINARY,
42+
SIGNATURE_TYPE_CERTIFICATES,
43+
SIGNATURE_TYPE_SUB_KEY_BINDING,
44+
SUPPORTED_PUBKEY_PACKET_VERSIONS,
45+
SUPPORTED_SIGNATURE_PACKET_VERSIONS,
46+
)
47+
from securesystemslib.gpg.exceptions import (
48+
KeyNotFoundError,
49+
PacketParsingError,
50+
PacketVersionNotSupportedError,
51+
SignatureAlgorithmNotSupportedError,
5252
)
5353
from securesystemslib.gpg.handlers import (
5454
SIGNATURE_HANDLERS,

securesystemslib/gpg/dsa.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@
2626
except ImportError:
2727
CRYPTO = False
2828

29-
from securesystemslib import exceptions
30-
from securesystemslib import formats
31-
from securesystemslib.gpg.exceptions import PacketParsingError
29+
from securesystemslib import exceptions, formats
3230
from securesystemslib.gpg import util as gpg_util
31+
from securesystemslib.gpg.exceptions import PacketParsingError
3332

3433

3534
def create_pubkey(pubkey_info):

securesystemslib/gpg/eddsa.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,17 @@
1818
"""
1919
import binascii
2020

21-
from securesystemslib import exceptions
22-
from securesystemslib import formats
21+
from securesystemslib import exceptions, formats
2322
from securesystemslib.gpg import util as gpg_util
2423
from securesystemslib.gpg.exceptions import PacketParsingError
2524

2625
CRYPTO = True
2726
NO_CRYPTO_MSG = "EdDSA key support for GPG requires the cryptography library"
2827
try:
28+
from cryptography.exceptions import InvalidSignature
2929
from cryptography.hazmat.primitives.asymmetric import (
3030
ed25519 as pyca_ed25519,
3131
)
32-
from cryptography.exceptions import InvalidSignature
3332
except ImportError:
3433
CRYPTO = False
3534

securesystemslib/gpg/functions.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,21 @@
1818
import logging
1919
import time
2020

21-
from securesystemslib import exceptions
22-
from securesystemslib import formats
21+
from securesystemslib import exceptions, formats, process
2322
from securesystemslib.gpg.common import (
2423
get_pubkey_bundle,
2524
parse_signature_packet,
2625
)
27-
from securesystemslib.gpg.exceptions import CommandError, KeyExpirationError
2826
from securesystemslib.gpg.constants import (
2927
FULLY_SUPPORTED_MIN_VERSION,
28+
NO_GPG_MSG,
29+
SHA256,
3030
gpg_export_pubkey_command,
3131
gpg_sign_command,
3232
have_gpg,
33-
NO_GPG_MSG,
34-
SHA256,
3533
)
34+
from securesystemslib.gpg.exceptions import CommandError, KeyExpirationError
3635
from securesystemslib.gpg.handlers import SIGNATURE_HANDLERS
37-
38-
from securesystemslib import process
3936
from securesystemslib.gpg.rsa import CRYPTO
4037

4138
log = logging.getLogger(__name__)

securesystemslib/gpg/handlers.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
the signature verification and key parsing.
1717
"""
1818

19-
from securesystemslib.gpg import rsa
20-
from securesystemslib.gpg import dsa
21-
from securesystemslib.gpg import eddsa
19+
from securesystemslib.gpg import dsa, eddsa, rsa
2220

2321
# See section 9.1. (public-key algorithms) of RFC4880 (-bis8)
2422
SUPPORTED_SIGNATURE_ALGORITHMS = {

securesystemslib/gpg/rsa.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,13 @@
1919
CRYPTO = True
2020
NO_CRYPTO_MSG = "RSA key support for GPG requires the cryptography library"
2121
try:
22-
from cryptography.hazmat.primitives.asymmetric import rsa
23-
from cryptography.hazmat import backends
24-
from cryptography.hazmat.primitives.asymmetric import padding
25-
from cryptography.hazmat.primitives.asymmetric import utils
2622
from cryptography.exceptions import InvalidSignature
23+
from cryptography.hazmat import backends
24+
from cryptography.hazmat.primitives.asymmetric import padding, rsa, utils
2725
except ImportError:
2826
CRYPTO = False
2927

30-
from securesystemslib import exceptions
31-
from securesystemslib import formats
28+
from securesystemslib import exceptions, formats
3229
from securesystemslib.gpg import util as gpg_util
3330
from securesystemslib.gpg.exceptions import PacketParsingError
3431

securesystemslib/gpg/util.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@
1414
<Purpose>
1515
general-purpose utilities for binary data handling and pgp data parsing
1616
"""
17-
import struct
1817
import binascii
19-
import re
20-
import logging
2118
import dataclasses
22-
19+
import logging
20+
import re
21+
import struct
2322

2423
CRYPTO = True
2524
NO_CRYPTO_MSG = "gpg.utils requires the cryptography library"
@@ -30,8 +29,7 @@
3029
CRYPTO = False
3130

3231
# pylint: disable=wrong-import-position
33-
from securesystemslib import exceptions
34-
from securesystemslib import process
32+
from securesystemslib import exceptions, process
3533
from securesystemslib.gpg import constants
3634
from securesystemslib.gpg.exceptions import PacketParsingError
3735

securesystemslib/hash.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@
2424

2525
import hashlib
2626

27-
from securesystemslib import exceptions
28-
from securesystemslib import formats
27+
from securesystemslib import exceptions, formats
2928
from securesystemslib.storage import FilesystemBackend
3029

31-
3230
DEFAULT_CHUNK_SIZE = 4096
3331
DEFAULT_HASH_ALGORITHM = "sha256"
3432
DEFAULT_HASH_LIBRARY = "hashlib"
@@ -37,9 +35,10 @@
3735

3836
# If `pyca_crypto` is installed, add it to supported libraries
3937
try:
38+
import binascii
39+
4040
from cryptography.hazmat.backends import default_backend
4141
from cryptography.hazmat.primitives import hashes as _pyca_hashes
42-
import binascii
4342

4443
# Dictionary of `pyca/cryptography` supported hash algorithms.
4544
PYCA_DIGEST_OBJECTS_CACHE = {

securesystemslib/interface.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,25 @@
2020
'securesystemslib/README' for the complete guide to using 'interface.py'.
2121
"""
2222

23-
import os
24-
import sys
2523
import getpass
24+
import json
2625
import logging
26+
import os
27+
import sys
2728
import tempfile
28-
import json
2929

30-
from securesystemslib import exceptions
31-
from securesystemslib import formats
32-
from securesystemslib import keys
33-
from securesystemslib import settings
34-
from securesystemslib import util
30+
from securesystemslib import (
31+
KEY_TYPE_ECDSA,
32+
KEY_TYPE_ED25519,
33+
KEY_TYPE_RSA,
34+
exceptions,
35+
formats,
36+
keys,
37+
settings,
38+
util,
39+
)
3540
from securesystemslib.storage import FilesystemBackend
3641

37-
from securesystemslib import KEY_TYPE_RSA, KEY_TYPE_ED25519, KEY_TYPE_ECDSA
38-
3942
logger = logging.getLogger(__name__)
4043

4144
try:

securesystemslib/keys.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,19 @@
5050
# Required for hexadecimal conversions. Signatures and public/private keys are
5151
# hexlified.
5252
import binascii
53-
5453
import logging
5554

56-
from securesystemslib import ecdsa_keys
57-
from securesystemslib import ed25519_keys
58-
from securesystemslib import exceptions
59-
from securesystemslib import formats
60-
from securesystemslib import rsa_keys
61-
from securesystemslib import settings
62-
from securesystemslib import util
55+
from securesystemslib import (
56+
ecdsa_keys,
57+
ed25519_keys,
58+
exceptions,
59+
formats,
60+
rsa_keys,
61+
settings,
62+
util,
63+
)
6364
from securesystemslib.hash import digest
6465

65-
6666
# The hash algorithm to use in the generation of keyids.
6767
_KEY_ID_HASH_ALGORITHM = "sha256"
6868

securesystemslib/process.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,16 @@
2121
- provide a special `run_duplicate_streams` function
2222
2323
"""
24-
import os
25-
import sys
2624
import io
27-
import tempfile
2825
import logging
29-
import time
26+
import os
3027
import shlex
3128
import subprocess
29+
import sys
30+
import tempfile
31+
import time
3232

33-
from securesystemslib import formats
34-
from securesystemslib import settings
33+
from securesystemslib import formats, settings
3534

3635
DEVNULL = subprocess.DEVNULL
3736
PIPE = subprocess.PIPE

0 commit comments

Comments
 (0)