]> TLD Linux GIT Repositories - tld-builder.git/blobdiff - TLD_Builder/get_br.py
- python 3.x fixes
[tld-builder.git] / TLD_Builder / get_br.py
index 1f69394c31f60b354e4e42dadaf17781e7fd7b2b..867e233af1cf1383447bd7256139ca0a18e61df2 100644 (file)
@@ -1,8 +1,9 @@
 # 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 *
 
 
@@ -12,10 +13,10 @@ def get_build_requires(spec, bconds_with, bconds_without):
     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 ""
 
@@ -28,8 +29,8 @@ def get_build_requires(spec, bconds_with, bconds_without):
     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
 
@@ -61,8 +62,8 @@ def get_build_requires(spec, bconds_with, bconds_without):
     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..
@@ -70,10 +71,10 @@ def get_build_requires(spec, bconds_with, bconds_without):
         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
 
@@ -100,4 +101,4 @@ def get_build_requires(spec, bconds_with, bconds_without):
                     msg("spec error (%s): %s\n" % (spec, l))
 
     for x in build_req:
-        print x
+        print(x)