public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "André Erdmann" <dywi@mailerd.de>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/R_overlay:master commit in: roverlay/rpackage/
Date: Thu, 25 Apr 2013 16:44:19 +0000 (UTC)	[thread overview]
Message-ID: <1366901617.920071a4b355cc4c58d76dd8b0d00554decc84f2.dywi@gentoo> (raw)

commit:     920071a4b355cc4c58d76dd8b0d00554decc84f2
Author:     André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Thu Apr 25 14:53:37 2013 +0000
Commit:     André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Thu Apr 25 14:53:37 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=920071a4

descriptionreader: dont append empty lines

DescriptionReader will no longer add empty (whitespace-only) lines
to data fields like Depends, ...

---
 roverlay/rpackage/descriptionreader.py |   41 +++++++++++++++++++++++--------
 1 files changed, 30 insertions(+), 11 deletions(-)

diff --git a/roverlay/rpackage/descriptionreader.py b/roverlay/rpackage/descriptionreader.py
index 567fa1e..029244e 100644
--- a/roverlay/rpackage/descriptionreader.py
+++ b/roverlay/rpackage/descriptionreader.py
@@ -232,12 +232,12 @@ class DescriptionReader ( object ):
 			if sys.version_info >= ( 3, ):
 				# decode lines,
 				#  encoding is unknown, could be ascii/iso8859*/utf8/<other>
-				read_lines = tuple (
+				read_lines = [
 					strutil.bytes_try_decode ( l ).rstrip() for l in fh.readlines()
-				)
+				]
 			else:
 				# python2 shouldn't need special decoding
-				read_lines = tuple ( l.rstrip() for l in fh.readlines() )
+				read_lines = [ l.rstrip() for l in fh.readlines() ]
 
 		finally:
 			if 'fh' in locals() and fh: fh.close()
@@ -342,21 +342,31 @@ class DescriptionReader ( object ):
 								'already been catched in DescriptionField...'
 							)
 
-						if field_context in raw:
+						new_value   = line_components [2].strip()
+						field_value = raw.get ( field_context, None )
+
+						if not new_value:
+							# add nothing but create field if it does not exist
+							if field_value is None:
+								raw [field_context] = []
+
+						elif field_value is None:
+							# create a new empty list for this field_context
+							# and add values to read_data
+							raw [field_context] = [ new_value ]
+
+						elif field_value:
 							# some packages have multiple Title fields
 							# warn about that 'cause it could lead to confusing
 							# ebuild/metadata output
 							self.logger.warning (
-								"field {f} redefined!".format ( f=field_context )
+								"field redefinition: {f!r}".format ( f=field_context )
 							)
 
-							raw [field_context].append ( sline )
+							field_value.append ( new_value )
 
 						else:
-							# add values to read_data, no need to check
-							#  line_components [2] 'cause [1] was a true str
-							# create a new empty list for this field_context
-							raw[field_context] = [ line_components [2].lstrip() ]
+							field_value.append ( new_value )
 
 				else:
 					# reaching this branch means that
@@ -383,7 +393,16 @@ class DescriptionReader ( object ):
 
 		# -- end for --
 
-		return raw
+		if raw:
+			return raw
+		elif non_ascii_warned:
+			return None
+		else:
+			# empty desc_data!
+			return raw
+
+		# Alternatively, always return None if raw is empty
+		#return raw or None
 	# --- end of _get_raw_data (...) ---
 
 	def run ( self ):


             reply	other threads:[~2013-04-25 16:44 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-25 16:44 André Erdmann [this message]
  -- strict thread matches above, loose matches on Subject: below --
2014-02-16  1:35 [gentoo-commits] proj/R_overlay:master commit in: roverlay/rpackage/ Benda XU
2013-08-21 13:51 André Erdmann
2013-08-21 13:51 André Erdmann
2013-08-20 21:46 André Erdmann
2013-07-25 13:28 André Erdmann
2013-07-25 13:25 André Erdmann
2013-07-25  8:47 André Erdmann
2013-07-25  8:47 André Erdmann
2013-07-23 18:34 [gentoo-commits] proj/R_overlay:gsoc13/next " André Erdmann
2013-07-23 18:34 ` [gentoo-commits] proj/R_overlay:master " André Erdmann
2013-07-11 16:29 André Erdmann
2013-02-09 20:45 André Erdmann
2012-08-07  8:50 André Erdmann
2012-07-30  8:52 André Erdmann
2012-07-06 22:19 André Erdmann
2012-07-03 17:48 André Erdmann
2012-07-02 16:52 André Erdmann
2012-06-29 22:48 André Erdmann
2012-06-28 15:55 André Erdmann
2012-06-28 15:55 André Erdmann
2012-06-27 14:46 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=1366901617.920071a4b355cc4c58d76dd8b0d00554decc84f2.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