aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeebs <seebs@seebs.net>2016-12-12 14:19:53 -0600
committerSeebs <seebs@seebs.net>2016-12-12 14:20:52 -0600
commitda64740b6c5ffc26e58cedb85c91432b6e425527 (patch)
tree8289ccb54ddb17c9176d9f2e88551017da93cbe1
parent029b4a7ef9a610eb2b6ded59156f26266b946995 (diff)
downloadpseudo-da64740b6c5ffc26e58cedb85c91432b6e425527.tar.gz
pseudo-da64740b6c5ffc26e58cedb85c91432b6e425527.tar.bz2
pseudo-da64740b6c5ffc26e58cedb85c91432b6e425527.zip
Python scripts are now compatible with both version of python, 2 and 3.
Helped-by: Damien Riegel <damien.riegel@savoirfairelinux.com> Helped-by: Alexandre Leblanc <alexandre.leblanc@savoirfairelinux.com> Signed-off-by: Gaël PORTAY <gael.portay@savoirfairelinux.com> Signed-off-by: Seebs <seebs@seebs.net>
-rw-r--r--ChangeLog.txt2
-rwxr-xr-xmaketables135
-rwxr-xr-xmakewrappers8
3 files changed, 75 insertions, 70 deletions
diff --git a/ChangeLog.txt b/ChangeLog.txt
index 8b06716..f8406e3 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -1,6 +1,8 @@
2016-12-12:
* (seebs) contributed fix to makewrappers (fix space/tab issues)
* (seebs) contributed fixes for Python 3 print support
+ * (seebs) contributed fixes for Python 3 support
+ * All of these from: Gaël PORTAY <gael.portay@savoirfairelinux.com>
2016-11-23:
* (seebs) actually wait on server shutdown for pseudo -S [cmd]
diff --git a/maketables b/maketables
index 0726485..f74f2b1 100755
--- a/maketables
+++ b/maketables
@@ -51,6 +51,7 @@ value. (This is for consistency with C array bounds.)
import glob
import sys
import string
+import os
from templatefile import TemplateFile
class DataType:
@@ -58,74 +59,74 @@ class DataType:
def __init__(self, path):
"""read the first line of path, then make tuples of the rest"""
- source = file(path)
- definition = source.readline().rstrip()
- self.name, qualifiers = string.split(definition, ': ', 2)
- if '; ' in qualifiers:
- self.prefix, columns = string.split(qualifiers, '; ')
- else:
- self.prefix = qualifiers
- columns = []
- self.flags = False
- if len(columns):
- self.columns = []
- columns = string.split(columns, ', ')
- for col in columns:
- indexed = False
- if col.startswith("FLAGS"):
- print("Flags: set for %s" % self.name)
- self.flags = True
+ with open(path,'r') as source:
+ definition = source.readline().rstrip()
+ self.name, qualifiers = definition.split(': ', 2)
+ if '; ' in qualifiers:
+ self.prefix, columns = qualifiers.split('; ')
+ else:
+ self.prefix = qualifiers
+ columns = []
+ self.flags = False
+ if len(columns):
+ self.columns = []
+ columns = columns.split(', ')
+ for col in columns:
+ indexed = False
+ if col.startswith("FLAGS"):
+ print("Flags: set for %s" % self.name)
+ self.flags = True
+ continue
+ if col.startswith("INDEXED "):
+ col = col[8:]
+ indexed = True
+ if "=" in col:
+ name, default = col.split(' = ')
+ else:
+ name, default = col, ""
+ if " " in name:
+ words = name.split(' ')
+ name = words[-1]
+ del words[-1]
+ type = ' '.join(words)
+ else:
+ type = "char *"
+ self.columns.append({"indexed":indexed, "type":type, "name":name, "value":default})
+ else:
+ self.columns = []
+ self.data = []
+ self.comments = []
+ index = 1
+ for line in source.readlines():
+ item = {}
+ if line.startswith('#'):
+ self.comments.append(line.rstrip().replace('#', ''))
continue
- if col.startswith("INDEXED "):
- col = col[8:]
- indexed = True
- if "=" in col:
- name, default = string.split(col, ' = ')
- else:
- name, default = col, ""
- if " " in name:
- words = string.split(name, ' ')
- name = words[-1]
- del words[-1]
- type = ' '.join(words)
- else:
- type = "char *"
- self.columns.append({"indexed":indexed, "type":type, "name":name, "value":default})
- else:
- self.columns = []
- self.data = []
- self.comments = []
- index = 1
- for line in source.readlines():
- item = {}
- if line.startswith('#'):
- self.comments.append(line.rstrip().replace('#', ''))
- continue
- # first entry on the line is the "real" name/id, following hunks
- # are additional columns
- cols = string.split(line.rstrip(), ', ')
- item["name"] = cols.pop(0)
- item["upper"] = item["name"].replace('-', '_').upper()
- column_list = []
- for col in self.columns:
- if len(cols) > 0:
- value = cols.pop(0)
- if col["indexed"]:
- if not "max" in col:
- col["max"] = value
- if value > col["max"]:
- col["max"] = value
- if not "min" in col:
- col["min"] = value
- if value < col["min"]:
- col["min"] = value
- column_list.append({"name":col["name"], "value":value})
- else:
- column_list.append({"name":col["name"], "value":col["value"]})
- item["cols"] = column_list
- item["index"] = index
- index = index + 1
- self.data.append(item)
+ # first entry on the line is the "real" name/id, following hunks
+ # are additional columns
+ cols = line.rstrip().split(', ')
+ item["name"] = cols.pop(0)
+ item["upper"] = item["name"].replace('-', '_').upper()
+ column_list = []
+ for col in self.columns:
+ if len(cols) > 0:
+ value = cols.pop(0)
+ if col["indexed"]:
+ if not "max" in col:
+ col["max"] = value
+ if value > col["max"]:
+ col["max"] = value
+ if not "min" in col:
+ col["min"] = value
+ if value < col["min"]:
+ col["min"] = value
+ column_list.append({"name":col["name"], "value":value})
+ else:
+ column_list.append({"name":col["name"], "value":col["value"]})
+ item["cols"] = column_list
+ item["index"] = index
+ index = index + 1
+ self.data.append(item)
def __getitem__(self, key):
"""Make this object look like a dict for Templates to use"""
diff --git a/makewrappers b/makewrappers
index bac856b..ff08ba0 100755
--- a/makewrappers
+++ b/makewrappers
@@ -453,6 +453,8 @@ additional ports to include.
"""
def __init__(self, port, sources):
+ if type(port) is not str:
+ port = str(port, encoding="ascii")
self.name = port
self.subports = []
self.preports = []
@@ -483,7 +485,7 @@ additional ports to include.
if retcode:
raise Exception("preports script failed for port %s" % self.name)
- for preport in string.split(portlist):
+ for preport in portlist.split():
next = Port(preport, sources)
self.preports.append(next)
@@ -494,7 +496,7 @@ additional ports to include.
if retcode:
raise Exception("subports script failed for port %s" % self.name)
- for subport in string.split(portlist):
+ for subport in portlist.split():
next = Port(subport, sources)
self.subports.append(next)
@@ -519,7 +521,7 @@ additional ports to include.
return mergedfuncs
def define(self):
- return '#define PSEUDO_PORT_%s 1' % string.upper(self.name).replace('/', '_')
+ return '#define PSEUDO_PORT_%s 1' % self.name.upper().replace('/', '_')
def portdeps(self):
deps = []