1 |
commit: 503c1170043d7a59ff39741ca740361340c9d508 |
2 |
Author: Andre Erdmann <dywi <AT> mailerd <DOT> de> |
3 |
AuthorDate: Sat May 26 13:13:45 2012 +0000 |
4 |
Commit: André Erdmann <dywi <AT> mailerd <DOT> de> |
5 |
CommitDate: Sat May 26 13:13:45 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=503c1170 |
7 |
|
8 |
roverlay, ebuildcreator: minor changes |
9 |
|
10 |
--- |
11 |
roverlay/ebuildcreator.py | 80 ++++++++++++++++++++++++++------------------ |
12 |
1 files changed, 47 insertions(+), 33 deletions(-) |
13 |
|
14 |
diff --git a/roverlay/ebuildcreator.py b/roverlay/ebuildcreator.py |
15 |
index 442382e..fa648b8 100644 |
16 |
--- a/roverlay/ebuildcreator.py |
17 |
+++ b/roverlay/ebuildcreator.py |
18 |
@@ -31,23 +31,23 @@ class Ebuild: |
19 |
"""Initializes an empty Ebuild. This is an object that can be used to |
20 |
create text lines for an ebuild file.""" |
21 |
|
22 |
- self.name = '' |
23 |
- self.version = '' |
24 |
- self.origin = '' |
25 |
- self.pkg_file = '' |
26 |
- self.depend = '' |
27 |
- self.rdepend = '' |
28 |
- self.rsuggests = '' |
29 |
- self.description = '' |
30 |
+ #self.name = '' |
31 |
+ #self.version = '' |
32 |
+ #self.origin = '' |
33 |
+ #self.pkg_file = '' |
34 |
+ #self.depend = '' |
35 |
+ #self.rdepend = '' |
36 |
+ #self.rsuggests = '' |
37 |
+ #self.description = '' |
38 |
|
39 |
# temporary var |
40 |
- self.TODO = '' |
41 |
+ #self.TODO = '' |
42 |
|
43 |
# this will be a list of str when exported data have been calculated |
44 |
self._ebuild_export = None |
45 |
|
46 |
@classmethod |
47 |
- def get_ebuild ( self, force_update=False ): |
48 |
+ def get_ebuild ( self, description_data, force_update=False ): |
49 |
""" |
50 |
Wrapper function that returns ebuild 'export' data. |
51 |
This is a list of str that has no newline chars at the end of each str. |
52 |
@@ -57,7 +57,7 @@ class Ebuild: |
53 |
|
54 |
""" |
55 |
if force_update or (self._ebuild_export is None): |
56 |
- self._ebuild_export = self._make_export() |
57 |
+ self._ebuild_export = self._make_export ( description_data ) |
58 |
|
59 |
return self._ebuild_export |
60 |
|
61 |
@@ -98,10 +98,31 @@ class Ebuild: |
62 |
# catch failure |
63 |
return False |
64 |
|
65 |
+ @classmethod |
66 |
+ def _make_ebuild_lines ( self, ebuild_content ): |
67 |
+ ebuild_export = [] |
68 |
+ last_line_empty = False |
69 |
+ line = None |
70 |
+ |
71 |
+ # remove repeated newlines ('repoman sez: ...') |
72 |
+ for line in ebuild_content: |
73 |
+ line = line.rstrip() |
74 |
+ if line: |
75 |
+ last_line_empty = False |
76 |
+ elif not last_line_empty: |
77 |
+ last_line_empty = True |
78 |
+ else: |
79 |
+ continue |
80 |
+ |
81 |
+ ebuild_export.append ( line ) |
82 |
+ |
83 |
+ del last_line_empty, line |
84 |
+ return ebuild_content |
85 |
+ |
86 |
|
87 |
|
88 |
@staticmethod |
89 |
- def _get_fileheader ( ebuild_header_file=None ): |
90 |
+ def _get_ebuild_header ( ebuild_header_file=None ): |
91 |
"""Reads and returns the content of an ebuild header file. |
92 |
This is a normal file that can be included in ebuilds. |
93 |
Every header file will only be read on first access, it's content will |
94 |
@@ -152,7 +173,7 @@ class Ebuild: |
95 |
return indent_level * EBUILD_INDENT + varname + '""' |
96 |
|
97 |
@classmethod |
98 |
- def _make_export ( self, ebuild_header=None ): |
99 |
+ def _make_export ( self, description_data, ebuild_header=None ): |
100 |
"""Creates ebuild data that can be written into stdout or a file |
101 |
|
102 |
arguments: |
103 |
@@ -163,13 +184,21 @@ class Ebuild: |
104 |
|
105 |
# this method is todo |
106 |
|
107 |
+ if not isinstance (description_data, dict): |
108 |
+ #todo |
109 |
+ raise Exception ( "bad description data" ) |
110 |
+ |
111 |
errors = dict() |
112 |
|
113 |
- ebuild_content = _get_fileheader ( ebuild_header ) |
114 |
+ ebuild_content = Ebuild._get_ebuild_header ( ebuild_header ) |
115 |
|
116 |
# repeated and leading empty lines will be removed later |
117 |
ebuild_content.append ( "" ) |
118 |
|
119 |
+ # the code below this line does not work |
120 |
+ return |
121 |
+ #raise Exception ( "under construction ..." ) |
122 |
+ |
123 |
if self.pkg_file: |
124 |
ebuild_content.append ( _make_var ( "PKG_FILE" , self.pkg_file ) ) |
125 |
else: |
126 |
@@ -225,27 +254,10 @@ class Ebuild: |
127 |
raise Exception ( "^^^missing components for ebuild^^^" ) |
128 |
#return None |
129 |
|
130 |
- ebuild_export = [] |
131 |
- last_line_empty = False |
132 |
- line = None |
133 |
- |
134 |
- # remove repeated newlines ('repoman sez: ...') |
135 |
- for line in ebuild_content: |
136 |
- line = line.rstrip() |
137 |
- if line: |
138 |
- last_line_empty = False |
139 |
- elif not last_line_empty: |
140 |
- last_line_empty = True |
141 |
- else: |
142 |
- continue |
143 |
- |
144 |
- ebuild_export.append ( line ) |
145 |
- |
146 |
- |
147 |
- del last_line_empty, line, ebuild_content |
148 |
- return ebuild_export |
149 |
+ return self._make_ebuild_lines ( ebuild_content ) |
150 |
|
151 |
class EbuildCreator: |
152 |
+# could move this to Ebuild |
153 |
|
154 |
@classmethod |
155 |
def __init__ ( self, description_data ): |
156 |
@@ -290,6 +302,8 @@ class EbuildCreator: |
157 |
|
158 |
# <dep resolution here?> |
159 |
|
160 |
+ ebuild.get_ebuild ( self._description_data ) |
161 |
+ |
162 |
# todo |
163 |
return None |