diff options
| author | John Estabrook <jestabro@vyos.io> | 2024-06-23 16:33:01 -0500 | 
|---|---|---|
| committer | John Estabrook <jestabro@vyos.io> | 2024-06-26 15:45:19 -0500 | 
| commit | ed0cb7ffc2c627b9de96d64b45c7978c3bce7ed3 (patch) | |
| tree | 5bd993c113cb4bf42440febcf764ef7ebf38bac1 /python/vyos/component_version.py | |
| parent | 08d4fcbc6243022cda0e889d99817d8e4e0ead78 (diff) | |
| download | vyos-1x-ed0cb7ffc2c627b9de96d64b45c7978c3bce7ed3.tar.gz vyos-1x-ed0cb7ffc2c627b9de96d64b45c7978c3bce7ed3.zip  | |
migration: T6007: remove obsoleted
Diffstat (limited to 'python/vyos/component_version.py')
| -rw-r--r-- | python/vyos/component_version.py | 123 | 
1 files changed, 0 insertions, 123 deletions
diff --git a/python/vyos/component_version.py b/python/vyos/component_version.py index 1513ac5ed..6db1768d3 100644 --- a/python/vyos/component_version.py +++ b/python/vyos/component_version.py @@ -205,126 +205,3 @@ def add_system_version(config_str: str = None, out_file: str = None):          version_info.write(out_file)      else:          sys.stdout.write(version_info.write_string()) - -def from_string(string_line, vintage='vyos'): -    """ -    Get component version dictionary from string. -    Return empty dictionary if string contains no config information -    or raise error if component version string malformed. -    """ -    version_dict = {} - -    if vintage == 'vyos': -        if re.match(r'// vyos-config-version:.+', string_line): -            if not re.match(r'// vyos-config-version:\s+"([\w,-]+@\d+:)+([\w,-]+@\d+)"\s*', string_line): -                raise ValueError(f"malformed configuration string: {string_line}") - -            for pair in re.findall(r'([\w,-]+)@(\d+)', string_line): -                version_dict[pair[0]] = int(pair[1]) - -    elif vintage == 'vyatta': -        if re.match(r'/\* === vyatta-config-version:.+=== \*/$', string_line): -            if not re.match(r'/\* === vyatta-config-version:\s+"([\w,-]+@\d+:)+([\w,-]+@\d+)"\s+=== \*/$', string_line): -                raise ValueError(f"malformed configuration string: {string_line}") - -            for pair in re.findall(r'([\w,-]+)@(\d+)', string_line): -                version_dict[pair[0]] = int(pair[1]) -    else: -        raise ValueError("Unknown config string vintage") - -    return version_dict - -def from_file(config_file_name=DEFAULT_CONFIG_PATH, vintage='vyos'): -    """ -    Get component version dictionary parsing config file line by line -    """ -    with open(config_file_name, 'r') as f: -        for line_in_config in f: -            version_dict = from_string(line_in_config, vintage=vintage) -            if version_dict: -                return version_dict - -    # no version information -    return {} - -def from_system(): -    """ -    Get system component version dict. -    """ -    return component_version() - -def format_string(ver: dict) -> str: -    """ -    Version dict to string. -    """ -    keys = list(ver) -    keys.sort() -    l = [] -    for k in keys: -        v = ver[k] -        l.append(f'{k}@{v}') -    sep = ':' -    return sep.join(l) - -def version_footer(ver: dict, vintage='vyos') -> str: -    """ -    Version footer as string. -    """ -    ver_str = format_string(ver) -    release = get_version() -    if vintage == 'vyos': -        ret_str = (f'// Warning: Do not remove the following line.\n' -                +  f'// vyos-config-version: "{ver_str}"\n' -                +  f'// Release version: {release}\n') -    elif vintage == 'vyatta': -        ret_str = (f'/* Warning: Do not remove the following line. */\n' -                +  f'/* === vyatta-config-version: "{ver_str}" === */\n' -                +  f'/* Release version: {release} */\n') -    else: -        raise ValueError("Unknown config string vintage") - -    return ret_str - -def system_footer(vintage='vyos') -> str: -    """ -    System version footer as string. -    """ -    ver_d = from_system() -    return version_footer(ver_d, vintage=vintage) - -def write_version_footer(ver: dict, file_name, vintage='vyos'): -    """ -    Write version footer to file. -    """ -    footer = version_footer(ver=ver, vintage=vintage) -    if file_name: -        with open(file_name, 'a') as f: -            f.write(footer) -    else: -        sys.stdout.write(footer) - -def write_system_footer(file_name, vintage='vyos'): -    """ -    Write system version footer to file. -    """ -    ver_d = from_system() -    return write_version_footer(ver_d, file_name=file_name, vintage=vintage) - -def remove_footer(file_name): -    """ -    Remove old version footer. -    """ -    for line in fileinput.input(file_name, inplace=True): -        if re.match(r'/\* Warning:.+ \*/$', line): -            continue -        if re.match(r'/\* === vyatta-config-version:.+=== \*/$', line): -            continue -        if re.match(r'/\* Release version:.+ \*/$', line): -            continue -        if re.match('// vyos-config-version:.+', line): -            continue -        if re.match('// Warning:.+', line): -            continue -        if re.match('// Release version:.+', line): -            continue -        sys.stdout.write(line)  | 
