parametrization of the name matching dictionary

-names argument

Signed-off-by: Jean-Luc Auge <jeanluc.auge@orange.com>
This commit is contained in:
Jean-Luc Auge
2019-01-11 11:33:03 +01:00
parent c9106c3a6f
commit bc9eee326a
3 changed files with 7 additions and 5 deletions

View File

@@ -116,6 +116,7 @@ parser.add_argument('-pl', '--plot', action='store_true')
parser.add_argument('-v', '--verbose', action='count', default=0, help='increases verbosity for each occurence')
parser.add_argument('-l', '--list-nodes', action='store_true', help='list all transceiver nodes')
parser.add_argument('-po', '--power', default=0, help='channel ref power in dBm')
parser.add_argument('-names', '--names-matching', action='store_true', help='display network names that are closed matches')
#parser.add_argument('-plb', '--power-lower-bound', default=0, help='power sweep lower bound')
#parser.add_argument('-pub', '--power-upper-bound', default=1, help='power sweep upper bound')
parser.add_argument('filename', nargs='?', type=Path,
@@ -131,7 +132,7 @@ if __name__ == '__main__':
equipment = load_equipment(args.equipment)
# logger.info(equipment)
# print(args.filename)
network = load_network(args.filename, equipment)
network = load_network(args.filename, equipment, args.names_matching)
# print(network)
transceivers = {n.uid: n for n in network.nodes() if isinstance(n, Transceiver)}

View File

@@ -232,7 +232,7 @@ def sanity_check(nodes, links, nodes_by_city, links_by_city, eqpts_by_city):
n.node_type='ROADM'
return nodes, links
def convert_file(input_filename, filter_region=[]):
def convert_file(input_filename, names_matching=False, filter_region=[]):
nodes, links, eqpts = parse_excel(input_filename)
if filter_region:
@@ -264,7 +264,8 @@ def convert_file(input_filename, filter_region=[]):
if match_city.lower() == city.lower() and match_city != city:
city_match_dic[city].append(match_city)
#print(city_match_dic)
if names_matching:
print('\ncity match dictionary:',city_match_dic)
with open('name_match_dictionary.json', 'w', encoding='utf-8') as city_match_dic_file:
city_match_dic_file.write(dumps(city_match_dic, indent=2, ensure_ascii=False))

View File

@@ -24,11 +24,11 @@ from collections import namedtuple
logger = getLogger(__name__)
def load_network(filename, equipment):
def load_network(filename, equipment, name_matching = False):
json_filename = ''
if filename.suffix.lower() == '.xls':
logger.info('Automatically generating topology JSON file')
json_filename = convert_file(filename)
json_filename = convert_file(filename, name_matching)
elif filename.suffix.lower() == '.json':
json_filename = filename
else: