From: "André Erdmann" <dywi@mailerd.de>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/R_overlay:master commit in: roverlay/ebuild/
Date: Fri, 3 Aug 2012 13:38:13 +0000 (UTC) [thread overview]
Message-ID: <1343994011.846caaf50d5e7e3721af5e2480ff01f79a78775b.dywi@gentoo> (raw)
commit: 846caaf50d5e7e3721af5e2480ff01f79a78775b
Author: André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Fri Aug 3 11:40:11 2012 +0000
Commit: André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Fri Aug 3 11:40:11 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=846caaf5
add bash arrays to ebuild/abstractcomponents
---
roverlay/ebuild/abstractcomponents.py | 92 ++++++++++++++++++++++-----------
1 files changed, 61 insertions(+), 31 deletions(-)
diff --git a/roverlay/ebuild/abstractcomponents.py b/roverlay/ebuild/abstractcomponents.py
index 5326a8e..db0a632 100644
--- a/roverlay/ebuild/abstractcomponents.py
+++ b/roverlay/ebuild/abstractcomponents.py
@@ -14,7 +14,9 @@ def listlike ( ref ):
class ListValue ( object ):
"""An evar value with a list of elements."""
- def __init__ ( self, value, indent_level=1, empty_value=None ):
+ def __init__ ( self,
+ value, indent_level=1, empty_value=None, bash_array=False
+ ):
"""Initializes a ListValue.
arguments:
@@ -34,7 +36,9 @@ class ListValue ( object ):
self.indent_lines = True
# only used in multi line mode
self.append_indented_newline = True
- self.insert_leading_newline = False
+
+ self.is_bash_array = bash_array
+ self.insert_leading_newline = self.is_bash_array
self.val_join = ' '
@@ -73,7 +77,7 @@ class ListValue ( object ):
self.add_value ( value )
# --- end of set_value (...) ---
- def add_value ( self, value ):
+ def add ( self, value ):
"""Adds/Appends a value."""
if not self._accept_value ( value ):
pass
@@ -81,30 +85,49 @@ class ListValue ( object ):
self.value.extend ( value )
else:
self.value.append ( value )
- # --- end of add_value (...) ---
+ # --- end of add (...) ---
- add = add_value
+ add_value = add
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 )
+
+ value_count = len ( self.value )
+ if self.is_bash_array:
+ if value_count == 0:
+ # empty value
+ ret = "()"
+ elif value_count == 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 = "{intro}{values}{tail}{newline}".format (
+ intro = '(\n' + self.val_indent \
+ if self.insert_leading_newline else '( ',
+ values = self.line_join.join (
+ "'" + str ( x ) + "'" for x in self.value
+ ),
+ tail = '\n{indent})'.format ( indent=self.var_indent ),
+ newline = self.var_indent + '\n' \
+ if self.append_indented_newline else ''
+ )
else:
- if self.insert_leading_newline:
- ret = '\n' + self.val_indent
- ret += self.line_join.join ( ( self.value ) )
+ if value_count == 0:
+ ret = ""
+ elif value_count == 1:
+ ret = str ( self.value [0] )
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'
+ if self.append_indented_newline:
+ ret += self.var_indent + '\n'
return ret
# --- end of to_str (...) ---
@@ -126,12 +149,15 @@ class EbuildVar ( object ):
* priority -- used for sorting (e.g. 'R_SUGGESTS' before 'DEPEND'),
lower means higher priority
"""
- self.name = name
- self.priority = priority
- self.value = value
+ self.name = name
+ self.priority = priority
+ self.value = value
self.set_level ( 0 )
self.use_param_expansion = param_expansion
self.print_empty_var = False
+
+ if hasattr ( self.value, 'add' ):
+ self.add_value = self.value.add
# --- end of __init__ (...) ---
def set_level ( self, level ):
@@ -157,20 +183,24 @@ class EbuildVar ( object ):
# --- end of active (...) ---
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
- if len ( vstr ) == 0:
- return 2 * q
+ if self.use_param_expansion is None:
+ # value quoting / unquoting is disabled
+ return vstr
+
else:
- return q + EbuildVar.IGNORED_VALUE_CHARS.sub ( '', vstr ) + q
+ q = '"' if self.use_param_expansion else '"'
+ # 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
+ if len ( vstr ) == 0:
+ return 2 * q
+ else:
+ return q + EbuildVar.IGNORED_VALUE_CHARS.sub ( '', vstr ) + q
# --- end of _quote_value (...) ---
def __str__ ( self ):
next reply other threads:[~2012-08-03 13:38 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-03 13:38 André Erdmann [this message]
-- strict thread matches above, loose matches on Subject: below --
2023-08-01 3:38 [gentoo-commits] proj/R_overlay:master commit in: roverlay/ebuild/ Benda XU
2019-08-17 16:41 Benda XU
2013-09-05 15:43 André Erdmann
2013-08-28 9:38 André Erdmann
2013-08-23 13:52 André Erdmann
2013-07-29 8:55 André Erdmann
2013-07-25 16:39 André Erdmann
2013-07-25 13:25 André Erdmann
2013-07-25 8:06 André Erdmann
2013-07-25 8:06 André Erdmann
2013-07-10 16:16 André Erdmann
2013-07-10 8:26 [gentoo-commits] proj/R_overlay:gsoc13/next " André Erdmann
2013-07-10 16:16 ` [gentoo-commits] proj/R_overlay:master " André Erdmann
2013-06-19 18:58 [gentoo-commits] proj/R_overlay:gsoc13/next " André Erdmann
2013-06-19 18:59 ` [gentoo-commits] proj/R_overlay:master " André Erdmann
2013-06-05 18:08 [gentoo-commits] proj/R_overlay:gsoc13/next " André Erdmann
2013-06-13 16:34 ` [gentoo-commits] proj/R_overlay:master " André Erdmann
2013-04-25 16:44 André Erdmann
2013-04-25 16:44 André Erdmann
2013-01-30 20:16 André Erdmann
2013-01-30 20:16 André Erdmann
2013-01-30 20:16 André Erdmann
2013-01-30 20:16 André Erdmann
2012-08-09 9:26 André Erdmann
2012-08-07 8:50 André Erdmann
2012-08-03 13:38 André Erdmann
2012-08-02 15:14 André Erdmann
2012-08-02 15:14 André Erdmann
2012-07-30 8:52 [gentoo-commits] proj/R_overlay:overlay_wip " André Erdmann
2012-07-30 8:52 ` [gentoo-commits] proj/R_overlay:master " André Erdmann
2012-07-16 16:15 André Erdmann
2012-07-16 16:15 André Erdmann
2012-07-12 18:04 André Erdmann
2012-07-06 22:19 André Erdmann
2012-06-29 22:48 André Erdmann
2012-06-29 22:48 André Erdmann
2012-06-29 22:48 André Erdmann
2012-06-29 22:48 André Erdmann
2012-06-28 15:55 André Erdmann
2012-06-28 13:29 André Erdmann
2012-06-26 15:42 André Erdmann
2012-06-21 16:55 André Erdmann
2012-06-20 19:03 André Erdmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1343994011.846caaf50d5e7e3721af5e2480ff01f79a78775b.dywi@gentoo \
--to=dywi@mailerd.de \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox