mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-08-07 06:42:56 +03:00
@@ -32,7 +32,7 @@ class Setting:
|
|||||||
present in mbedtls_config.h but commented out.
|
present in mbedtls_config.h but commented out.
|
||||||
* section: the name of the section that contains this symbol.
|
* section: the name of the section that contains this symbol.
|
||||||
"""
|
"""
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods, too-many-arguments
|
||||||
def __init__(self, active, name, value='', section=None, configfile=None):
|
def __init__(self, active, name, value='', section=None, configfile=None):
|
||||||
self.active = active
|
self.active = active
|
||||||
self.name = name
|
self.name = name
|
||||||
@@ -57,6 +57,7 @@ class Config:
|
|||||||
name to become set.
|
name to become set.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# pylint: disable=unused-argument
|
||||||
def __init__(self, **kw):
|
def __init__(self, **kw):
|
||||||
self.settings = {}
|
self.settings = {}
|
||||||
|
|
||||||
@@ -399,8 +400,8 @@ class ConfigFile(metaclass=ABCMeta):
|
|||||||
filename = candidate
|
filename = candidate
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
raise Exception(name + ' configuration file not found',
|
raise ValueError(f'{name} configuration file not found: '
|
||||||
default_path)
|
f'{filename if filename else default_path}')
|
||||||
|
|
||||||
self.filename = filename
|
self.filename = filename
|
||||||
self.templates = []
|
self.templates = []
|
||||||
@@ -599,9 +600,9 @@ class CryptoConfig(Config):
|
|||||||
|
|
||||||
def set(self, name, value=None):
|
def set(self, name, value=None):
|
||||||
if name in UNSUPPORTED_FEATURE:
|
if name in UNSUPPORTED_FEATURE:
|
||||||
raise ValueError('Feature is unsupported: \'{}\''.format(name))
|
raise ValueError(f'Feature is unsupported: \'{name}\'')
|
||||||
if name in UNSTABLE_FEATURE:
|
if name in UNSTABLE_FEATURE:
|
||||||
raise ValueError('Feature is unstable: \'{}\''.format(name))
|
raise ValueError(f'Feature is unstable: \'{name}\'')
|
||||||
|
|
||||||
if name not in self.settings:
|
if name not in self.settings:
|
||||||
self.crypto_config.templates.append((name, '', '#define ' + name + ' ' + '1'))
|
self.crypto_config.templates.append((name, '', '#define ' + name + ' ' + '1'))
|
||||||
@@ -637,6 +638,7 @@ class MultiConfig(MbedtlsConfig, CryptoConfig):
|
|||||||
def set(self, name, value=None):
|
def set(self, name, value=None):
|
||||||
super(self._get_related_config(name), self).set(name, value)
|
super(self._get_related_config(name), self).set(name, value)
|
||||||
|
|
||||||
|
# pylint: disable=arguments-renamed
|
||||||
def write(self, mbedtls_file=None, crypto_file=None):
|
def write(self, mbedtls_file=None, crypto_file=None):
|
||||||
"""Write the whole configuration to the file it was read from.
|
"""Write the whole configuration to the file it was read from.
|
||||||
|
|
||||||
@@ -650,6 +652,7 @@ class MultiConfig(MbedtlsConfig, CryptoConfig):
|
|||||||
return self.settings[name].configfile
|
return self.settings[name].configfile
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
#pylint: disable=too-many-statements
|
||||||
def main():
|
def main():
|
||||||
"""Command line mbedtls_config.h manipulation tool."""
|
"""Command line mbedtls_config.h manipulation tool."""
|
||||||
parser = argparse.ArgumentParser(description="""
|
parser = argparse.ArgumentParser(description="""
|
||||||
|
Reference in New Issue
Block a user