1 |
commit: 1ec0b070a11e10b8111538a8b8bdb865497bc82f |
2 |
Author: Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com> |
3 |
AuthorDate: Thu Aug 1 11:32:06 2013 +0000 |
4 |
Commit: Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com> |
5 |
CommitDate: Thu Aug 1 11:32:06 2013 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=1ec0b070 |
7 |
|
8 |
g_sorcery/ebuild: Docstrings added |
9 |
|
10 |
--- |
11 |
g_sorcery/ebuild.py | 48 +++++++++++++++++++++++++++++++++++++++++++++++- |
12 |
1 file changed, 47 insertions(+), 1 deletion(-) |
13 |
|
14 |
diff --git a/g_sorcery/ebuild.py b/g_sorcery/ebuild.py |
15 |
index 0c720a6..a1bd6b8 100644 |
16 |
--- a/g_sorcery/ebuild.py |
17 |
+++ b/g_sorcery/ebuild.py |
18 |
@@ -46,6 +46,15 @@ class EbuildGenerator(object): |
19 |
return ebuild |
20 |
|
21 |
def process_ebuild_data(self, ebuild_data): |
22 |
+ """ |
23 |
+ A hook allowing changing ebuild_data before ebuild generation. |
24 |
+ |
25 |
+ Args: |
26 |
+ ebuild_data: Dictinary with ebuild data. |
27 |
+ |
28 |
+ Returns: |
29 |
+ Dictinary with ebuild data. |
30 |
+ """ |
31 |
return ebuild_data |
32 |
|
33 |
def process(self, ebuild, ebuild_data): |
34 |
@@ -89,7 +98,7 @@ class EbuildGenerator(object): |
35 |
|
36 |
def postprocess(self, ebuild, ebuild_data): |
37 |
""" |
38 |
- Hook to be overriden. |
39 |
+ A hook for changing of a generated ebuild. |
40 |
|
41 |
Args: |
42 |
ebuild: Ebuild source as a list of strings. |
43 |
@@ -141,6 +150,27 @@ class EbuildGeneratorFromFile(EbuildGenerator): |
44 |
|
45 |
|
46 |
class DefaultEbuildGenerator(EbuildGenerator): |
47 |
+ """ |
48 |
+ Default ebuild generator. |
49 |
+ |
50 |
+ Takes a layout dictinary that describes ebuild structure and generates |
51 |
+ an ebuild temlate basing on it. |
52 |
+ |
53 |
+ Layout has entries for vars and inherited eclasses. Each entry is a list. |
54 |
+ Entries are processed in the following order: |
55 |
+ |
56 |
+ vars_before_inherit |
57 |
+ inherit |
58 |
+ vars_after_inherit |
59 |
+ vars_after_description |
60 |
+ vars_after_keywords |
61 |
+ |
62 |
+ inherit entry is just a list of eclass names. |
63 |
+ vars* entries are lists of variables in tw0 possible formats: |
64 |
+ 1. A string with variable name |
65 |
+ 2. A tuple (varname, value) |
66 |
+ Variable names are automatically transformed to the upper-case. |
67 |
+ """ |
68 |
def __init__(self, package_db, layout): |
69 |
super(DefaultEbuildGenerator, self).__init__(package_db) |
70 |
self.template = ["# automatically generated by g-sorcery", |
71 |
@@ -182,6 +212,12 @@ class DefaultEbuildGenerator(EbuildGenerator): |
72 |
|
73 |
|
74 |
def _append_vars_to_template(self, variables): |
75 |
+ """ |
76 |
+ Add a list of variables to the end of template. |
77 |
+ |
78 |
+ Args: |
79 |
+ variables: List of variables. |
80 |
+ """ |
81 |
VAR_NAME = 0 |
82 |
VAR_VALUE = 1 |
83 |
|
84 |
@@ -193,4 +229,14 @@ class DefaultEbuildGenerator(EbuildGenerator): |
85 |
|
86 |
|
87 |
def get_template(self, package, ebuild_data): |
88 |
+ """ |
89 |
+ Generate ebuild template. |
90 |
+ |
91 |
+ Args: |
92 |
+ package: package_db.Package instance. |
93 |
+ ebuild_data: Dictionary with ebuild data. |
94 |
+ |
95 |
+ Returns: |
96 |
+ Ebuild template. |
97 |
+ """ |
98 |
return self.template |