mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-02-05 18:40:01 +00:00
Unify spacing
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
This commit is contained in:
parent
24d7cc71af
commit
a12ed6bcb7
@ -18,6 +18,7 @@ import sys
|
|||||||
|
|
||||||
from abc import ABCMeta
|
from abc import ABCMeta
|
||||||
|
|
||||||
|
|
||||||
class Setting:
|
class Setting:
|
||||||
"""Representation of one Mbed TLS mbedtls_config.h pr PSA crypto_config.h setting.
|
"""Representation of one Mbed TLS mbedtls_config.h pr PSA crypto_config.h setting.
|
||||||
|
|
||||||
@ -38,6 +39,7 @@ class Setting:
|
|||||||
self.section = section
|
self.section = section
|
||||||
self.configfile = configfile
|
self.configfile = configfile
|
||||||
|
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
"""Representation of the Mbed TLS and PSA configuration.
|
"""Representation of the Mbed TLS and PSA configuration.
|
||||||
|
|
||||||
@ -197,6 +199,7 @@ class Config:
|
|||||||
|
|
||||||
return self._get_configfile(name).filename
|
return self._get_configfile(name).filename
|
||||||
|
|
||||||
|
|
||||||
def is_full_section(section):
|
def is_full_section(section):
|
||||||
"""Is this section affected by "config.py full" and friends?
|
"""Is this section affected by "config.py full" and friends?
|
||||||
|
|
||||||
@ -445,6 +448,7 @@ def no_platform_adapter(adapter):
|
|||||||
return adapter(name, active, section)
|
return adapter(name, active, section)
|
||||||
return continuation
|
return continuation
|
||||||
|
|
||||||
|
|
||||||
class ConfigFile(metaclass=ABCMeta):
|
class ConfigFile(metaclass=ABCMeta):
|
||||||
"""Representation of a configuration file."""
|
"""Representation of a configuration file."""
|
||||||
|
|
||||||
@ -574,6 +578,7 @@ class ConfigFile(metaclass=ABCMeta):
|
|||||||
with open(filename, 'w', encoding='utf-8') as output:
|
with open(filename, 'w', encoding='utf-8') as output:
|
||||||
self.write_to_stream(settings, output)
|
self.write_to_stream(settings, output)
|
||||||
|
|
||||||
|
|
||||||
class MbedTLSConfigFile(ConfigFile):
|
class MbedTLSConfigFile(ConfigFile):
|
||||||
"""Representation of an MbedTLS configuration file."""
|
"""Representation of an MbedTLS configuration file."""
|
||||||
|
|
||||||
@ -589,6 +594,7 @@ class MbedTLSConfigFile(ConfigFile):
|
|||||||
super().__init__(self.default_path, 'Mbed TLS', filename)
|
super().__init__(self.default_path, 'Mbed TLS', filename)
|
||||||
self.current_section = 'header'
|
self.current_section = 'header'
|
||||||
|
|
||||||
|
|
||||||
class CryptoConfigFile(ConfigFile):
|
class CryptoConfigFile(ConfigFile):
|
||||||
"""Representation of a Crypto configuration file."""
|
"""Representation of a Crypto configuration file."""
|
||||||
|
|
||||||
@ -610,6 +616,7 @@ class CryptoConfigFile(ConfigFile):
|
|||||||
def __init__(self, filename=None):
|
def __init__(self, filename=None):
|
||||||
super().__init__(self.default_path, 'Crypto', filename)
|
super().__init__(self.default_path, 'Crypto', filename)
|
||||||
|
|
||||||
|
|
||||||
class MbedTLSConfig(Config):
|
class MbedTLSConfig(Config):
|
||||||
"""Representation of the Mbed TLS configuration.
|
"""Representation of the Mbed TLS configuration.
|
||||||
|
|
||||||
@ -635,6 +642,7 @@ class MbedTLSConfig(Config):
|
|||||||
|
|
||||||
super().set(name, value)
|
super().set(name, value)
|
||||||
|
|
||||||
|
|
||||||
class CryptoConfig(Config):
|
class CryptoConfig(Config):
|
||||||
"""Representation of the PSA crypto configuration.
|
"""Representation of the PSA crypto configuration.
|
||||||
|
|
||||||
@ -665,6 +673,7 @@ class CryptoConfig(Config):
|
|||||||
|
|
||||||
super().set(name, value)
|
super().set(name, value)
|
||||||
|
|
||||||
|
|
||||||
class CombinedConfig(Config):
|
class CombinedConfig(Config):
|
||||||
"""Representation of MbedTLS and PSA crypto configuration
|
"""Representation of MbedTLS and PSA crypto configuration
|
||||||
|
|
||||||
@ -768,49 +777,42 @@ class ConfigTool(metaclass=ABCMeta):
|
|||||||
def _common_parser_options(self, file_type):
|
def _common_parser_options(self, file_type):
|
||||||
"""Common parser options for config manipulation tool."""
|
"""Common parser options for config manipulation tool."""
|
||||||
|
|
||||||
self.parser.add_argument('--file', '-f',
|
self.parser.add_argument(
|
||||||
help="""File to read (and modify if requested).
|
'--file', '-f',
|
||||||
Default: {}.
|
help="""File to read (and modify if requested). Default: {}.
|
||||||
""".format(file_type.default_path))
|
""".format(file_type.default_path))
|
||||||
self.parser.add_argument('--force', '-o',
|
self.parser.add_argument(
|
||||||
|
'--force', '-o',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help="""For the set command, if SYMBOL is not
|
help="""For the set command, if SYMBOL is not present, add a definition for it.""")
|
||||||
present, add a definition for it.""")
|
self.parser.add_argument(
|
||||||
self.parser.add_argument('--write', '-w', metavar='FILE',
|
'--write', '-w',
|
||||||
|
metavar='FILE',
|
||||||
help="""File to write to instead of the input file.""")
|
help="""File to write to instead of the input file.""")
|
||||||
|
|
||||||
parser_get = self.subparsers.add_parser('get',
|
parser_get = self.subparsers.add_parser(
|
||||||
help="""Find the value of SYMBOL
|
'get',
|
||||||
and print it. Exit with
|
help="""Find the value of SYMBOL and print it. Exit with
|
||||||
status 0 if a #define for SYMBOL is
|
status 0 if a #define for SYMBOL is found, 1 otherwise.""")
|
||||||
found, 1 otherwise.
|
|
||||||
""")
|
|
||||||
parser_get.add_argument('symbol', metavar='SYMBOL')
|
parser_get.add_argument('symbol', metavar='SYMBOL')
|
||||||
parser_set = self.subparsers.add_parser('set',
|
parser_set = self.subparsers.add_parser(
|
||||||
help="""Set SYMBOL to VALUE.
|
'set',
|
||||||
If VALUE is omitted, just uncomment
|
help="""Set SYMBOL to VALUE. If VALUE is omitted, just uncomment
|
||||||
the #define for SYMBOL.
|
the #define for SYMBOL. Error out of a line defining
|
||||||
Error out of a line defining
|
SYMBOL (commented or not) is not found, unless --force is passed. """)
|
||||||
SYMBOL (commented or not) is not
|
|
||||||
found, unless --force is passed.
|
|
||||||
""")
|
|
||||||
parser_set.add_argument('symbol', metavar='SYMBOL')
|
parser_set.add_argument('symbol', metavar='SYMBOL')
|
||||||
parser_set.add_argument('value', metavar='VALUE', nargs='?',
|
parser_set.add_argument('value', metavar='VALUE', nargs='?', default='')
|
||||||
default='')
|
parser_set_all = self.subparsers.add_parser(
|
||||||
parser_set_all = self.subparsers.add_parser('set-all',
|
'set-all',
|
||||||
help="""Uncomment all #define
|
help="""Uncomment all #define whose name contains a match for REGEX.""")
|
||||||
whose name contains a match for
|
|
||||||
REGEX.""")
|
|
||||||
parser_set_all.add_argument('regexs', metavar='REGEX', nargs='*')
|
parser_set_all.add_argument('regexs', metavar='REGEX', nargs='*')
|
||||||
parser_unset = self.subparsers.add_parser('unset',
|
parser_unset = self.subparsers.add_parser(
|
||||||
help="""Comment out the #define
|
'unset',
|
||||||
for SYMBOL. Do nothing if none
|
help="""Comment out the #define for SYMBOL. Do nothing if none is present.""")
|
||||||
is present.""")
|
|
||||||
parser_unset.add_argument('symbol', metavar='SYMBOL')
|
parser_unset.add_argument('symbol', metavar='SYMBOL')
|
||||||
parser_unset_all = self.subparsers.add_parser('unset-all',
|
parser_unset_all = self.subparsers.add_parser(
|
||||||
help="""Comment out all #define
|
'unset-all',
|
||||||
whose name contains a match for
|
help="""Comment out all #define whose name contains a match for REGEX.""")
|
||||||
REGEX.""")
|
|
||||||
parser_unset_all.add_argument('regexs', metavar='REGEX', nargs='*')
|
parser_unset_all.add_argument('regexs', metavar='REGEX', nargs='*')
|
||||||
|
|
||||||
def custom_parser_options(self):
|
def custom_parser_options(self):
|
||||||
@ -861,41 +863,49 @@ class MbedTLSConfigTool(ConfigTool):
|
|||||||
def custom_parser_options(self):
|
def custom_parser_options(self):
|
||||||
"""Adds MbedTLS specific options for the parser."""
|
"""Adds MbedTLS specific options for the parser."""
|
||||||
|
|
||||||
self.parser.add_argument('--cryptofile', '-c',
|
self.parser.add_argument(
|
||||||
help="""Crypto file to read (and modify if requested).
|
'--cryptofile', '-c',
|
||||||
Default: {}.
|
help="""Crypto file to read (and modify if requested). Default: {}."""
|
||||||
""".format(CryptoConfigFile.default_path))
|
.format(CryptoConfigFile.default_path))
|
||||||
|
|
||||||
add_adapter('baremetal', baremetal_adapter,
|
self.add_adapter(
|
||||||
"""Like full, but exclude features that require platform
|
'baremetal', baremetal_adapter,
|
||||||
features such as file input-output.""")
|
"""Like full, but exclude features that require platform features
|
||||||
add_adapter('baremetal_size', baremetal_size_adapter,
|
such as file input-output.
|
||||||
"""Like baremetal, but exclude debugging features.
|
|
||||||
Useful for code size measurements.""")
|
|
||||||
add_adapter('full', full_adapter,
|
|
||||||
"""Uncomment most features.
|
|
||||||
Exclude alternative implementations and platform support
|
|
||||||
options, as well as some options that are awkward to test.
|
|
||||||
""")
|
""")
|
||||||
add_adapter('full_no_deprecated', no_deprecated_adapter(full_adapter),
|
self.add_adapter(
|
||||||
|
'baremetal_size', baremetal_size_adapter,
|
||||||
|
"""Like baremetal, but exclude debugging features. Useful for code size measurements.
|
||||||
|
""")
|
||||||
|
self.add_adapter(
|
||||||
|
'full', full_adapter,
|
||||||
|
"""Uncomment most features.
|
||||||
|
Exclude alternative implementations and platform support options, as well as
|
||||||
|
some options that are awkward to test.
|
||||||
|
""")
|
||||||
|
self.add_adapter(
|
||||||
|
'full_no_deprecated', no_deprecated_adapter(full_adapter),
|
||||||
"""Uncomment most non-deprecated features.
|
"""Uncomment most non-deprecated features.
|
||||||
Like "full", but without deprecated features.
|
Like "full", but without deprecated features.
|
||||||
""")
|
""")
|
||||||
add_adapter('full_no_platform', no_platform_adapter(full_adapter),
|
self.add_adapter(
|
||||||
"""Uncomment most non-platform features.
|
'full_no_platform', no_platform_adapter(full_adapter),
|
||||||
Like "full", but without platform features.
|
"""Uncomment most non-platform features. Like "full", but without platform features.
|
||||||
""")
|
""")
|
||||||
add_adapter('realfull', realfull_adapter,
|
self.add_adapter(
|
||||||
|
'realfull', realfull_adapter,
|
||||||
"""Uncomment all boolean #defines.
|
"""Uncomment all boolean #defines.
|
||||||
Suitable for generating documentation, but not for building.""")
|
Suitable for generating documentation, but not for building.
|
||||||
add_adapter('crypto', crypto_adapter(None),
|
""")
|
||||||
|
self.add_adapter(
|
||||||
|
'crypto', crypto_adapter(None),
|
||||||
"""Only include crypto features. Exclude X.509 and TLS.""")
|
"""Only include crypto features. Exclude X.509 and TLS.""")
|
||||||
add_adapter('crypto_baremetal', crypto_adapter(baremetal_adapter),
|
self.add_adapter(
|
||||||
"""Like baremetal, but with only crypto features,
|
'crypto_baremetal', crypto_adapter(baremetal_adapter),
|
||||||
excluding X.509 and TLS.""")
|
"""Like baremetal, but with only crypto features, excluding X.509 and TLS.""")
|
||||||
add_adapter('crypto_full', crypto_adapter(full_adapter),
|
self.add_adapter(
|
||||||
"""Like full, but with only crypto features,
|
'crypto_full', crypto_adapter(full_adapter),
|
||||||
excluding X.509 and TLS.""")
|
"""Like full, but with only crypto features, excluding X.509 and TLS.""")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user