1 |
commit: c7143074312b3fb5a497c3729a1b4bac8a23a5a3 |
2 |
Author: André Erdmann <dywi <AT> mailerd <DOT> de> |
3 |
AuthorDate: Thu Jun 28 13:21:01 2012 +0000 |
4 |
Commit: André Erdmann <dywi <AT> mailerd <DOT> de> |
5 |
CommitDate: Thu Jun 28 13:21:01 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=c7143074 |
7 |
|
8 |
DescriptionReader: write description files |
9 |
|
10 |
* the DescriptionReader is now able to write the description |
11 |
lines from an R package to a text file. |
12 |
This is optional and disabled unless DESCRIPTION_DIR is set in the config |
13 |
file. |
14 |
|
15 |
modified: .gitignore |
16 |
modified: R-overlay.conf |
17 |
modified: roverlay/config/entrymap.py |
18 |
modified: roverlay/rpackage/descriptionreader.py |
19 |
|
20 |
--- |
21 |
.gitignore | 1 + |
22 |
R-overlay.conf | 2 ++ |
23 |
roverlay/config/entrymap.py | 12 ++++++++++++ |
24 |
roverlay/rpackage/descriptionreader.py | 27 ++++++++++++++++++++++++++- |
25 |
4 files changed, 41 insertions(+), 1 deletions(-) |
26 |
|
27 |
diff --git a/.gitignore b/.gitignore |
28 |
index c412f0b..7b3f583 100644 |
29 |
--- a/.gitignore |
30 |
+++ b/.gitignore |
31 |
@@ -20,3 +20,4 @@ roverlay.log |
32 |
|
33 |
/distfiles-root/ |
34 |
/overlay-root/ |
35 |
+/desc-files/ |
36 |
|
37 |
diff --git a/R-overlay.conf b/R-overlay.conf |
38 |
index 3a84234..b6eb8d9 100644 |
39 |
--- a/R-overlay.conf |
40 |
+++ b/R-overlay.conf |
41 |
@@ -26,3 +26,5 @@ ECLASS = eclass/R-packages.eclass |
42 |
REPO_CONFIG = repo.list |
43 |
|
44 |
DISTFILES = distfiles-root |
45 |
+ |
46 |
+DESCRIPTION_DIR = desc-files |
47 |
|
48 |
diff --git a/roverlay/config/entrymap.py b/roverlay/config/entrymap.py |
49 |
index 2cb7077..4179c4f 100644 |
50 |
--- a/roverlay/config/entrymap.py |
51 |
+++ b/roverlay/config/entrymap.py |
52 |
@@ -128,4 +128,16 @@ CONFIG_ENTRY_MAP = dict ( |
53 |
|
54 |
# --- dependency resolution |
55 |
|
56 |
+ # == description reader == |
57 |
+ |
58 |
+ # * for debugging |
59 |
+ # if set: write _all_ description files to dir/<package_filename> |
60 |
+ description_descfiles_dir = dict ( |
61 |
+ path = [ 'DESCRIPTION', 'descfiles_dir' ], |
62 |
+ value_type = 'fs_abs:fs_dir', |
63 |
+ ), |
64 |
+ |
65 |
+ # * alias |
66 |
+ description_dir = 'description_descfiles_dir', |
67 |
+ |
68 |
) |
69 |
|
70 |
diff --git a/roverlay/rpackage/descriptionreader.py b/roverlay/rpackage/descriptionreader.py |
71 |
index 03ec30a..8aa35b3 100644 |
72 |
--- a/roverlay/rpackage/descriptionreader.py |
73 |
+++ b/roverlay/rpackage/descriptionreader.py |
74 |
@@ -5,13 +5,16 @@ |
75 |
import re |
76 |
import tarfile |
77 |
import os.path |
78 |
+import time |
79 |
|
80 |
-from roverlay import config |
81 |
+from roverlay import config, util |
82 |
from roverlay.rpackage import descriptionfields |
83 |
|
84 |
class DescriptionReader ( object ): |
85 |
"""Description Reader""" |
86 |
|
87 |
+ WRITE_DESCFILES_DIR = config.get ( 'DESCRIPTION.descfiles_dir', None ) |
88 |
+ |
89 |
def __init__ ( self, package_info, logger, read_now=False ): |
90 |
"""Initializes a DESCRIPTION file reader.""" |
91 |
|
92 |
@@ -25,6 +28,14 @@ class DescriptionReader ( object ): |
93 |
self.logger = logger.getChild ( 'desc_reader' ) |
94 |
self.desc_data = None |
95 |
|
96 |
+ if DescriptionReader.WRITE_DESCFILES_DIR is not None: |
97 |
+ self.write_desc_file = os.path.join ( |
98 |
+ DescriptionReader.WRITE_DESCFILES_DIR, |
99 |
+ '%s_%s.desc' % ( |
100 |
+ self.fileinfo ['name'], self.fileinfo ['ebuild_verstr'] |
101 |
+ ) |
102 |
+ ) |
103 |
+ |
104 |
|
105 |
if read_now: |
106 |
self.run() |
107 |
@@ -219,6 +230,20 @@ class DescriptionReader ( object ): |
108 |
if not th is None: th.close() |
109 |
del fh, th |
110 |
|
111 |
+ if hasattr ( self, 'write_desc_file' ): |
112 |
+ try: |
113 |
+ util.dodir ( DescriptionReader.WRITE_DESCFILES_DIR ) |
114 |
+ fh = open ( self.write_desc_file, 'w' ) |
115 |
+ fh.write ( |
116 |
+ '=== This is debug output (%s) ===\n' |
117 |
+ % time.strftime ( '%F %H:%M:%S' ) |
118 |
+ ) |
119 |
+ fh.write ( '\n'.join ( read_lines ) ) |
120 |
+ fh.write ( '\n' ) |
121 |
+ finally: |
122 |
+ if 'fh' in locals() and fh: fh.close() |
123 |
+ |
124 |
+ |
125 |
return read_lines |
126 |
|
127 |
# --- end of get_desc_from_file (...) --- |