* [gentoo-commits] proj/R_overlay:master commit in: roverlay/ebuild/
@ 2012-06-29 22:48 99% André Erdmann
0 siblings, 0 replies; 1+ results
From: André Erdmann @ 2012-06-29 22:48 UTC (permalink / raw
To: gentoo-commits
commit: 7bfe60ae3fee591b2476af9a2a0a34ccb2e298e6
Author: André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Fri Jun 29 22:22:30 2012 +0000
Commit: André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Fri Jun 29 22:22:30 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=7bfe60ae
ebuild variables: remove syntax-violating quotes
* this removes quote chars from var values
* also added the possibility to choose between ' and "
modified: roverlay/ebuild/abstractcomponents.py
---
roverlay/ebuild/abstractcomponents.py | 38 ++++++++++++++++++++++++++++++--
1 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/roverlay/ebuild/abstractcomponents.py b/roverlay/ebuild/abstractcomponents.py
index 5437dfc..f943948 100644
--- a/roverlay/ebuild/abstractcomponents.py
+++ b/roverlay/ebuild/abstractcomponents.py
@@ -31,6 +31,7 @@ class ListValue ( object ):
self.indent_lines = True
# only used in multi line mode
self.append_indented_newline = True
+ self.insert_leading_newline = False
self.val_join = ' '
@@ -84,13 +85,21 @@ class ListValue ( object ):
def to_str ( self ):
"""Returns a string representing this ListValue."""
if len ( self.value ) == 0:
+ # empty value
ret = ""
elif len ( self.value ) == 1:
+ # one value
ret = str ( self.value [0] )
elif self.single_line:
+ # several values in a single line
ret = self.val_join.join ( self.value )
else:
- ret = self.line_join.join ( ( self.value ) )
+ if self.insert_leading_newline:
+ ret = '\n' + self.val_indent
+ ret += self.line_join.join ( ( self.value ) )
+ else:
+ ret = self.line_join.join ( ( self.value ) )
+
if self.append_indented_newline:
ret += self.var_indent + '\n'
@@ -103,7 +112,9 @@ class ListValue ( object ):
class EbuildVar ( object ):
"""An ebuild variable."""
- def __init__ ( self, name, value, priority ):
+ QUOTE_CHARS = "\"\'"
+
+ def __init__ ( self, name, value, priority, param_expansion=True ):
"""Initializes an EbuildVar.
arguments:
@@ -116,6 +127,8 @@ class EbuildVar ( object ):
self.priority = priority
self.value = value
self.set_level ( 0 )
+ self.use_param_expansion = param_expansion
+ self.print_empty_var = False
def set_level ( self, level ):
"""Sets the indention level."""
@@ -138,5 +151,24 @@ class EbuildVar ( object ):
else:
return True
+ def _quote_value ( self ):
+ q = '"' if self.use_param_expansion else "'"
+ if hasattr ( self, '_get_value_str' ):
+ vstr = self._get_value_str()
+ else:
+ vstr = str ( self.value )
+ # removing all quote chars from values,
+ # the "constructed" {R,}DEPEND/R_SUGGESTS/IUSE vars don't use them
+ # and DESCRIPTION/SRC_URI don't need them
+ return q + vstr.strip ( EbuildVar.QUOTE_CHARS ) + q
+
def __str__ ( self ):
- return '%s%s="%s"' % ( self.indent, self.name, self.value )
+ valstr = self._quote_value()
+ if len ( valstr ) > 2 or self.print_empty_var:
+ return '%s%s=%s' % ( self.indent, self.name, valstr )
+ else:
+ # empty string 'cause var is not set
+ # -> Ebuilder ignores this var
+ # this filters out the result of strip(QUOTE_CHARS) for values that
+ # contain only quote chars
+ return ""
^ permalink raw reply related [relevance 99%]
Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2012-06-29 22:48 99% [gentoo-commits] proj/R_overlay:master commit in: roverlay/ebuild/ André Erdmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox