From 71062a6167f767e15a22ac10edd996b3cad667a3 Mon Sep 17 00:00:00 2001 From: "Jauhien Piatlicki (jauhien)" Date: Thu, 5 Sep 2013 13:54:12 +0200 Subject: variables without quotation in ebuild-generator --- g_sorcery/ebuild.py | 19 +++++++++++++------ gs_ctan/ebuild.py | 6 +++--- gs_elpa/ebuild.py | 4 ++-- gs_pypi/ebuild.py | 8 ++++---- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/g_sorcery/ebuild.py b/g_sorcery/ebuild.py index 36847f9..4c2e318 100644 --- a/g_sorcery/ebuild.py +++ b/g_sorcery/ebuild.py @@ -168,7 +168,10 @@ class DefaultEbuildGenerator(EbuildGenerator): inherit entry is just a list of eclass names. vars* entries are lists of variables in tw0 possible formats: 1. A string with variable name - 2. A tuple (varname, value) + 2. A dictinary with entries: + name: variable name + value: variable value + raw: if present, not quotation of value will be done Variable names are automatically transformed to the upper-case. """ def __init__(self, package_db, layout): @@ -218,15 +221,19 @@ class DefaultEbuildGenerator(EbuildGenerator): Args: variables: List of variables. """ - VAR_NAME = 0 - VAR_VALUE = 1 - for var in variables: if isinstance(var, basestring): self.template.append(var.upper() + '="%(' + var + ')s"') else: - self.template.append(var[VAR_NAME].upper() \ - + '="' + var[VAR_VALUE] + '"') + if "raw" in var: + quote = '' + else: + quote = '"' + if "value" in var: + self.template.append(var["name"].upper() \ + + '=' + quote + var["value"] + quote) + else: + self.template.append(var["name"].upper() + '=' + quote + '%(' + var["name"] + ')s' + quote) def get_template(self, package, ebuild_data): diff --git a/gs_ctan/ebuild.py b/gs_ctan/ebuild.py index d8b4f65..0dbb5a0 100644 --- a/gs_ctan/ebuild.py +++ b/gs_ctan/ebuild.py @@ -32,7 +32,7 @@ class CtanEbuildWithoutDigestGenerator(DefaultEbuildGenerator): inherit = ["gs-ctan"] vars_after_description = \ - ["homepage", ("src_uri", ""), "license"] + ["homepage", {"name" : "src_uri", "value" : ""}, "license"] vars_after_keywords = \ ["depend", "rdepend"] @@ -48,12 +48,12 @@ class CtanEbuildWithDigestGenerator(DefaultEbuildGenerator): def __init__(self, package_db): vars_before_inherit = \ - ["base_src_uri", "catalogue", "source_type", "realname", ("digest_sources", "yes")] + ["base_src_uri", "catalogue", "source_type", "realname", {"name" : "digest_sources", "value" : "yes"}] inherit = ["gs-ctan"] vars_after_description = \ - ["homepage", ("src_uri", "${BASE_SRC_URI}${CATALOGUE}${REALNAME}.${SOURCE_TYPE} -> ${P}.${SOURCE_TYPE}"), "license"] + ["homepage", {"name" : "src_uri", "value" : "${BASE_SRC_URI}${CATALOGUE}${REALNAME}.${SOURCE_TYPE} -> ${P}.${SOURCE_TYPE}"}, "license"] vars_after_keywords = \ ["depend", "rdepend"] diff --git a/gs_elpa/ebuild.py b/gs_elpa/ebuild.py index 460ccfa..d1d63f2 100644 --- a/gs_elpa/ebuild.py +++ b/gs_elpa/ebuild.py @@ -27,12 +27,12 @@ class ElpaEbuildWithDigestGenerator(DefaultEbuildGenerator): def __init__(self, package_db): vars_before_inherit = \ - ["repo_uri", "source_type", "realname", ("digest_sources", "yes")] + ["repo_uri", "source_type", "realname", {"name" : "digest_sources", "value" : "yes"}] inherit = ["g-sorcery", "gs-elpa"] vars_after_description = \ - ["homepage", ("src_uri", "${REPO_URI}${REALNAME}-${PV}.${SUFFIX}")] + ["homepage", {"name" : "src_uri", "value" : "${REPO_URI}${REALNAME}-${PV}.${SUFFIX}"}] vars_after_keywords = \ ["depend", "rdepend"] diff --git a/gs_pypi/ebuild.py b/gs_pypi/ebuild.py index 74ba910..d3f5342 100644 --- a/gs_pypi/ebuild.py +++ b/gs_pypi/ebuild.py @@ -24,8 +24,8 @@ class PypiEbuildWithoutDigestGenerator(DefaultEbuildGenerator): def __init__(self, package_db): vars_before_inherit = \ - [("repo_uri", 'http://pypi.python.org/packages/source/${PN:0:1}/${PN}/'), - ("sourcefile", '${P}.tar.gz'), "python_compat"] + [{"name" : "repo_uri", "value" : 'http://pypi.python.org/packages/source/${PN:0:1}/${PN}/'}, + {"name" : "sourcefile", "value" : '${P}.tar.gz'}, {"name" : "python_compat", "raw" : True}] inherit = ["gs-pypi"] @@ -43,13 +43,13 @@ class PypiEbuildWithDigestGenerator(DefaultEbuildGenerator): def __init__(self, package_db): vars_before_inherit = \ - [("digest_sources", "yes"), "python_compat"] + [{"name" : "digest_sources", "value" : "yes"}, {"name" : "python_compat", "raw" : True}] inherit = ["gs-pypi"] vars_after_description = \ ["homepage", - ("src_uri", 'http://pypi.python.org/packages/source/${PN:0:1}/${PN}/${P}.tar.gz')] + {"name" : "src_uri", "value" : 'http://pypi.python.org/packages/source/${PN:0:1}/${PN}/${P}.tar.gz'}] vars_after_keywords = \ [] -- cgit v1.2.3-65-gdbad