Skip to content

Commit 61bcca9

Browse files
committed
feat: python2 -> python3
1 parent 52abf46 commit 61bcca9

File tree

11 files changed

+152
-136
lines changed

11 files changed

+152
-136
lines changed

generate.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import logging
77
import os
88
import platform
9-
import re
109
import sqlite3
1110
import sys
1211
import yaml
@@ -17,7 +16,6 @@
1716
from lib import networks
1817
from lib import packages
1918
from lib import processor
20-
from lib import statistics
2119
from lib import tables
2220

2321
def generate(database, manifest_file, seatmap_file,
@@ -27,7 +25,7 @@ def generate(database, manifest_file, seatmap_file,
2725
# Create fresh database file
2826
logging.debug('Checking if database file %s exists', database)
2927
has_previous_db = False
30-
previous_statistics = None
28+
before = {}
3129
if os.path.isfile(database):
3230
logging.debug(
3331
'Found existing database file %s, gathering stats before deleting',
@@ -87,6 +85,7 @@ def generate(database, manifest_file, seatmap_file,
8785

8886
# Parse ipplan
8987
logging.debug('Parsing lines in %s', ipplan)
88+
lines = []
9089
try:
9190
with open(ipplan, 'r') as f:
9291
lines = f.readlines()
@@ -110,7 +109,7 @@ def generate(database, manifest_file, seatmap_file,
110109
logging.debug('Parsing manifest file as JSON')
111110
try:
112111
with open(manifest_file, 'r') as f:
113-
manifest = yaml.safe_load(f.read())
112+
manifest = json.load(f)
114113
except Exception as e:
115114
logging.error(
116115
'Could not parse manifest file %s as JSON: %s',
@@ -149,6 +148,7 @@ def generate(database, manifest_file, seatmap_file,
149148
sys.exit(9)
150149
logging.debug('Found seatmap file \'%s\'', seatmap_file)
151150
logging.debug('Parsing seatmap file as JSON')
151+
seatmap = {}
152152
try:
153153
with open(seatmap_file, 'r') as f:
154154
seatmap = json.loads(f.read())

lib/diff.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import re
21
import sys
32

43

@@ -61,10 +60,6 @@ def _print(color, msg, output):
6160

6261

6362
def compare_states(before, after, logging, output=sys.stdout, limit=10000):
64-
# Did we detect _any_ changes?
65-
changed = False
66-
67-
# Any new tables?
6863
tables_before = set(before['tables'])
6964
tables_after = set(after['tables'])
7065
dropped_tables = tables_before - tables_after
@@ -73,12 +68,10 @@ def compare_states(before, after, logging, output=sys.stdout, limit=10000):
7368
output.write('Dropped %d table(s):' % (len(dropped_tables)))
7469
for dropped_table in dropped_tables:
7570
_print(bcolors.FAIL, dropped_table, output)
76-
changed = True
7771
if len(new_tables) > 0:
7872
output.write('Added %d table(s):' % (len(new_tables)))
7973
for added_table in new_tables:
8074
_print(bcolors.OKGREEN, added_table, output)
81-
changed = True
8275

8376
# We can only do diff magic on tables that were in both databases
8477
tables = tables_after.intersection(tables_before)
@@ -93,7 +86,6 @@ def compare_states(before, after, logging, output=sys.stdout, limit=10000):
9386
delta_count = count_after - count_before
9487
if delta_count != 0:
9588
logging.info('%s %d' % (table, delta_count))
96-
changed = True
9789
removed_objects = objects_before - objects_after
9890
added_objects = objects_after - objects_before
9991
if len(removed_objects) > 0:

lib/firewall.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def prefetch_node_and_services(self):
7777

7878
self.node_services = dict()
7979
self.service_nodes = dict()
80-
for access, access_key in access_to_sql_map.iteritems():
80+
for access, access_key in access_to_sql_map.items():
8181
# TODO(bluecmd): These are deprecated in favor of packages
8282
# We should emit warnings in the presubmit hook to make sure
8383
# people are not using these
@@ -90,14 +90,14 @@ def prefetch_node_and_services(self):
9090
for node, service in explicit:
9191
self.register_service(access, node, service)
9292

93-
for node, packset in self.nodes.iteritems():
93+
for node, packset in self.nodes.items():
9494
for package_name in packset:
9595
package = self.packages[package_name] or {}
9696
for service in set(package.get(access, [])):
9797
self.register_service(access, node, service)
9898

9999
# Prune redundant flows (hosts that share the network flows)
100-
for node, services in self.node_services[access].iteritems():
100+
for node in self.node_services[access].iteritems():
101101
if node not in self.netmap:
102102
continue
103103
parent = self.node_services[access].get(self.netmap[node])

0 commit comments

Comments
 (0)