# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
+from __future__ import print_function
+
import re
import string
-import xreadlines
from util import *
def expand_conds(l):
def expand_one(m):
if m.group(1) == "?":
- if macros.has_key(m.group(2)):
+ if m.group(2) in macros:
return m.group(3)
else:
- if not macros.has_key(m.group(2)):
+ if not m.group(2) in macros:
return m.group(3)
return ""
macro_rx = re.compile(r"%\{([a-zA-Z0-9_+]+)\}")
def expand_macros(l):
def expand_one(m):
- if macros.has_key(m.group(1)):
- return string.strip(macros[m.group(1)])
+ if m.group(1) in macros:
+ return macros[m.group(1)].strip()
else:
return m.group(0) # don't change
build_req = []
f = open(spec)
- for l in xreadlines.xreadlines(f):
- l = string.strip(l)
+ for l in f:
+ l = l.strip()
if l == "%changelog": break
# %bcond_with..
if m:
bcond = m.group(2)
if m.group(1) == "with":
- if macros.has_key("_with_%s" % bcond):
+ if "_with_%s" % bcond in macros:
macros["with_%s" % bcond] = 1
else:
- if not macros.has_key("_without_%s" % bcond):
+ if not "_without_%s" % bcond in macros:
macros["with_%s" % bcond] = 1
continue
msg("spec error (%s): %s\n" % (spec, l))
for x in build_req:
- print x
+ print(x)