summaryrefslogtreecommitdiff
path: root/src/dh_xul-ext
diff options
context:
space:
mode:
Diffstat (limited to 'src/dh_xul-ext')
-rwxr-xr-xsrc/dh_xul-ext45
1 files changed, 24 insertions, 21 deletions
diff --git a/src/dh_xul-ext b/src/dh_xul-ext
index df9cb2b..844ef7b 100755
--- a/src/dh_xul-ext
+++ b/src/dh_xul-ext
@@ -112,9 +112,8 @@ def get_xul_apps(all_distros):
return xul_apps
-def get_supported_apps(script_name, xul_apps, install_rdf, package,
- verbose=False):
- # create array of id_max_min triples
+def _get_id_max_min_triple(install_rdf):
+ """create array of id_max_min triples"""
id_max_min = []
model = RDF.Model()
parser = RDF.Parser(name="rdfxml")
@@ -138,7 +137,11 @@ def get_supported_apps(script_name, xul_apps, install_rdf, package,
id_max_min.append ((target["id"].literal_value["string"],
target["max"].literal_value["string"],
target["min"].literal_value["string"]))
+ return id_max_min
+def get_supported_apps(script_name, xul_apps, install_rdf, package,
+ verbose=False):
+ id_max_min = _get_id_max_min_triple(install_rdf)
if verbose:
print "%s: %s supports %i XUL application(s):" % (script_name, package,
len(id_max_min))
@@ -148,7 +151,7 @@ def get_supported_apps(script_name, xul_apps, install_rdf, package,
# find supported apps/packages
supported_apps = list()
for xul_app in xul_apps:
- supported_app = filter(lambda x: x[0] == xul_app.get_id(), id_max_min)
+ supported_app = [x for x in id_max_min if x[0] == xul_app.get_id()]
if len(supported_app) == 1:
# package is supported by extension
(appid, max_version, min_version) = supported_app.pop()
@@ -175,14 +178,14 @@ def get_supported_apps(script_name, xul_apps, install_rdf, package,
def get_all_packages():
lines = open("debian/control").readlines()
- package_lines = filter(lambda x: x.find("Package:") >= 0, lines)
- packages = map(lambda x: x[x.find(":")+1:].strip(), package_lines)
+ package_lines = [x for x in lines if x.find("Package:") >= 0]
+ packages = [p[p.find(":")+1:].strip() for p in package_lines]
return packages
def get_source_package_name():
source = None
- f = open("debian/control")
- for line in f:
+ control_file = open("debian/control")
+ for line in control_file:
if line.startswith("Source:"):
source = line[line.find(":")+1:].strip()
break
@@ -190,7 +193,7 @@ def get_source_package_name():
def has_no_xpi_depends():
lines = open("debian/control").readlines()
- xpi_depends_lines = filter(lambda x: x.find("${xpi:Depends}") >= 0, lines)
+ xpi_depends_lines = [l for l in lines if l.find("${xpi:Depends}") >= 0]
return len(xpi_depends_lines) == 0
def get_provided_package_names(package, supported_apps):
@@ -201,7 +204,7 @@ def get_provided_package_names(package, supported_apps):
# check if MOZ_XPI_EXT_NAME is defined in debian/rules
lines = open("debian/rules").readlines()
- lines = filter(lambda x: x.find("MOZ_XPI_EXT_NAME") != -1, lines)
+ lines = [l for l in lines if l.find("MOZ_XPI_EXT_NAME") != -1]
if len(lines) > 0:
line = lines[-1]
ext_name = line[line.find("=")+1:].strip()
@@ -233,7 +236,7 @@ def find_install_rdfs(path):
if os.path.isdir(path):
# recursive walk
- content = map(lambda d: os.path.join(path, d), os.listdir(path))
+ content = [os.path.join(path, d) for d in os.listdir(path)]
install_rdfs = reduce(lambda x, d: x.union(find_install_rdfs(d)),
content, install_rdfs)
@@ -250,25 +253,25 @@ def generate_substvars(script_name, xul_apps, package, verbose=False):
print >> sys.stderr, ("%s: %s contains multiple install.rdf files. "
"That's not supported.") % (script_name, package)
basepath_len = len(os.path.realpath("debian/" + package))
- rdfs = map(lambda x: x[basepath_len:], install_rdfs)
+ rdfs = [x[basepath_len:] for x in install_rdfs]
print >> sys.stderr, "\n".join(rdfs)
sys.exit(MULTIPLE_INSTALL_RDFS)
install_rdf = install_rdfs.pop()
filename = "debian/" + package + ".substvars"
if os.path.exists(filename):
- f = open(filename)
- lines = f.readlines()
- f.close()
+ substvars_file = open(filename)
+ lines = substvars_file.readlines()
+ substvars_file.close()
else:
lines = list()
# remove existing varibles
- lines = filter(lambda s: not s.startswith("xpi:"), lines)
+ lines = [s for s in lines if not s.startswith("xpi:")]
supported_apps = get_supported_apps(script_name, xul_apps, install_rdf,
package, verbose)
- packages = map(lambda a: a.get_versioned_package(), supported_apps)
+ packages = [a.get_versioned_package() for a in supported_apps]
if has_no_xpi_depends():
# Use xpi:Recommends instead of xpi:Depends for backwards compatibility
print ("%s: Warning: Please add ${xpi:Depends} to Depends. Using only "
@@ -277,15 +280,15 @@ def generate_substvars(script_name, xul_apps, package, verbose=False):
else:
lines.append("xpi:Depends=" + " | ".join(packages) + "\n")
lines.append("xpi:Recommends=\n")
- packages = map(lambda a: a.get_package(), supported_apps)
+ packages = [a.get_package() for a in supported_apps]
lines.append("xpi:Enhances=" + ", ".join(sorted(packages)) + "\n")
packages = get_provided_package_names(package, supported_apps)
lines.append("xpi:Provides=" + ", ".join(sorted(packages)) + "\n")
# write new variables
- f = open(filename, "w")
- f.writelines(lines)
- f.close()
+ substvars_file = open(filename, "w")
+ substvars_file.writelines(lines)
+ substvars_file.close()
class UnknownOptionIgnoringOptionParser(optparse.OptionParser):