Modify find/split operations to work on Python 2 and 3

Python 3 only accepts certain syntaxes for find & split.
Thankfully, it's possible to use them in Python 2, so rework
it so we can use the same syntax for both.
This is not detected or fixed by futurize, sadly
(a problem true for many other situations).

Signed-off-by: David A. Wheeler <dwheeler@dwheeler.com>
This commit is contained in:
David A. Wheeler 2017-08-12 21:12:54 -04:00
parent 8fee8a34bd
commit 05c238acc6
1 changed files with 2 additions and 2 deletions

View File

@ -1602,8 +1602,8 @@ def expand_ruleset(ruleset):
# Note that this "for" loop modifies the ruleset while it's iterating,
# so we *must* convert the keys into a list before iterating.
for rule in list(ruleset.keys()):
if string.find(rule, "|") != -1: # We found a rule to expand.
for newrule in string.split(rule, "|"):
if "|" in rule: # We found a rule to expand.
for newrule in rule.split("|"):
if newrule in ruleset:
print("Error: Rule %s, when expanded, overlaps %s" % (
rule, newrule))