Gentoo Archives: gentoo-commits

From: "André Erdmann" <dywi@×××××××.de>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/R_overlay:master commit in: roverlay/rpackage/
Date: Mon, 30 Jul 2012 08:53:51
Message-Id: 1343231321.4a1edc718a09b2ce5499753c7d3bbb47d837b1ed.dywi@gentoo
1 commit: 4a1edc718a09b2ce5499753c7d3bbb47d837b1ed
2 Author: André Erdmann <dywi <AT> mailerd <DOT> de>
3 AuthorDate: Wed Jul 25 15:48:41 2012 +0000
4 Commit: André Erdmann <dywi <AT> mailerd <DOT> de>
5 CommitDate: Wed Jul 25 15:48:41 2012 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=4a1edc71
7
8 workaround for Z compressed files
9
10 ---
11 roverlay/rpackage/descriptionreader.py | 48 +++++++++++++++++++++----------
12 1 files changed, 32 insertions(+), 16 deletions(-)
13
14 diff --git a/roverlay/rpackage/descriptionreader.py b/roverlay/rpackage/descriptionreader.py
15 index bfb50bb..52e9d2e 100644
16 --- a/roverlay/rpackage/descriptionreader.py
17 +++ b/roverlay/rpackage/descriptionreader.py
18 @@ -208,17 +208,16 @@ class DescriptionReader ( object ):
19
20 if tarfile.is_tarfile ( filepath ):
21 # filepath is a tarball, open tar handle + file handle
22 - th = tarfile.open ( filepath, 'r' )
23 + th = tarfile.open ( filepath, mode='r' )
24 if pkg_name:
25 - fh = th.extractfile ( os.path.join (
26 - pkg_name,
27 - config.get ( 'DESCRIPTION.file_name' )
28 - ) )
29 + fh = th.extractfile (
30 + pkg_name + os.path.sep + config.get ( 'DESCRIPTION.file_name' )
31 + )
32 else:
33 fh = th.extractfile ( config.get ( 'DESCRIPTION.file_name' ) )
34
35 else:
36 - # open file handle only
37 + # open file handle only (!! .Z compressed tar files, FIXME)
38 fh = open ( filepath, 'r' )
39
40
41 @@ -270,6 +269,8 @@ class DescriptionReader ( object ):
42
43 comment_chars = config.get ( 'DESCRIPTION.comment_chars', '#' )
44
45 + non_ascii_warned = False
46 +
47 for line in desc_lines:
48 field_context_ref = None
49
50 @@ -347,11 +348,25 @@ class DescriptionReader ( object ):
51 # reaching this branch means that
52 # (a) line has no leading whitespace
53 # (b) line has no separator (:)
54 - # this should not occur in description files (bad syntax?)
55 - self.logger.warning (
56 - "Unexpected line in description file: '%s'."
57 - % line_components [0]
58 - )
59 + # this should not occur in description files (bad syntax,
60 + # unknown compression (.Z!))
61 +
62 + # !!! FIXME: handle .Z files properly or at least
63 + # deny to read them
64 + # remove non ascii-chars (could confuse the terminal)
65 + ascii_str = util.ascii_filter ( line_components [0] )
66 + if len ( ascii_str ) == len ( line_components [0] ):
67 + self.logger.warning (
68 + "Unexpected line in description file: {!r}.".format (
69 + line_components [0]
70 + ) )
71 + elif not non_ascii_warned:
72 + # probably compressed text
73 + self.logger.warning (
74 + 'Unexpected non-ascii line in description '
75 + 'file (compressed text?)!'
76 + )
77 + non_ascii_warned = True
78
79 # -- end for --
80
81 @@ -383,14 +398,15 @@ class DescriptionReader ( object ):
82
83 if read_data is None:
84 self.logger.warning (
85 - "Failed to read file '%s'." % self.fileinfo ['package_file']
86 - )
87 + "Failed to read file {f!r}.".format (
88 + f=self.fileinfo ['package_file']
89 + ) )
90
91 elif self._verify_read_data ( read_data ):
92 self.logger.debug (
93 - "Successfully read file '%s' with data = %s."
94 - % ( self.fileinfo ['package_file'], read_data )
95 - )
96 + "Successfully read file {f} with data = {d}.".format (
97 + f=self.fileinfo ['package_file'], d=read_data
98 + ) )
99 self.desc_data = read_data
100
101 # else have log entries from _verify()