This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
''' | |
Задание 26.1 | |
Изменить класс Topology из задания 25.1x. | |
Добавить метод, который позволит выполнять сложение двух объектов (экземпляров) Topology. | |
В результате сложения должен возвращаться новый экземпляр класса Topology. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
''' | |
Задание 9.4 | |
Создать функцию, которая обрабатывает конфигурационный файл коммутатора | |
и возвращает словарь: | |
* Все команды верхнего уровня (глобального режима конфигурации), будут ключами. | |
* Если у команды верхнего уровня есть подкоманды, они должны быть в значении у соответствующего ключа, в виде списка (пробелы в начале строки можно оставлять). | |
* Если у команды верхнего уровня нет подкоманд, то значение будет пустым списком |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def generate_config_dict(filename): | |
''' | |
''' | |
config_dict = {} | |
with open(filename, 'r') as f: | |
for line in f: | |
if not line.startswith('!') and not ignore_command(line, ignore) and not line.startswith(' '): | |
keyword = line.rstrip() | |
elif not line.startswith('!') and not ignore_command(line, ignore): |