1 |
commit: 78675495ed708852d5771ebd98aec38d0c2ed6ab |
2 |
Author: André Erdmann <dywi <AT> mailerd <DOT> de> |
3 |
AuthorDate: Wed Jan 30 19:57:42 2013 +0000 |
4 |
Commit: André Erdmann <dywi <AT> mailerd <DOT> de> |
5 |
CommitDate: Wed Jan 30 20:00:33 2013 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=78675495 |
7 |
|
8 |
packageinfo: update_unsafe(), add ebuild variables |
9 |
|
10 |
new function update_unsafe() that simply adds information to a PackageInfo |
11 |
instance without locking or checking for writability. |
12 |
|
13 |
added EVAR* key that can be used to add per-package ebuild variables (evar) |
14 |
|
15 |
--- |
16 |
roverlay/packageinfo.py | 45 ++++++++++++++++++++++++++++++++++++--------- |
17 |
1 files changed, 36 insertions(+), 9 deletions(-) |
18 |
|
19 |
diff --git a/roverlay/packageinfo.py b/roverlay/packageinfo.py |
20 |
index f4b7c9e..438433c 100644 |
21 |
--- a/roverlay/packageinfo.py |
22 |
+++ b/roverlay/packageinfo.py |
23 |
@@ -357,6 +357,17 @@ class PackageInfo ( object ): |
24 |
self.set_readonly() |
25 |
# --- end of update_now (...) --- |
26 |
|
27 |
+ def update_unsafe ( self, **info ): |
28 |
+ """Updates the package info data without retrieving any locks or |
29 |
+ checking writability. |
30 |
+ Meant for usage with "package actions" (packagerules module). |
31 |
+ |
32 |
+ arguments: |
33 |
+ * **info -- |
34 |
+ """ |
35 |
+ self._update ( info ) |
36 |
+ # --- end of update_unsafe (...) --- |
37 |
+ |
38 |
def update ( self, **info ): |
39 |
"""Uses **info to update the package info data. |
40 |
|
41 |
@@ -369,13 +380,27 @@ class PackageInfo ( object ): |
42 |
# nothing to do |
43 |
return |
44 |
|
45 |
- initial = len ( self._info ) == 0 |
46 |
- |
47 |
# remove_auto has to be the last action (keyword order is not "stable") |
48 |
remove_auto = info.pop ( 'remove_auto', None ) |
49 |
|
50 |
self._writelock_acquire() |
51 |
|
52 |
+ self._update ( info ) |
53 |
+ |
54 |
+ if remove_auto: |
55 |
+ self._remove_auto ( remove_auto ) |
56 |
+ |
57 |
+ self._update_lock.release() |
58 |
+ # --- end of update (**kw) --- |
59 |
+ |
60 |
+ def _update ( self, info ): |
61 |
+ """Updates self._info using the given info dict. |
62 |
+ |
63 |
+ arguments: |
64 |
+ * info -- |
65 |
+ """ |
66 |
+ initial = len ( self._info ) == 0 |
67 |
+ |
68 |
for key, value in info.items(): |
69 |
|
70 |
if key in self.__class__._UPDATE_KEYS_SIMPLE: |
71 |
@@ -384,6 +409,13 @@ class PackageInfo ( object ): |
72 |
elif initial and key in self.__class__._UPDATE_KEYS_SIMPLE_INITIAL: |
73 |
self [key] = value |
74 |
|
75 |
+ elif key[:4] == 'EVAR': |
76 |
+ if 'EVAR' in self._info: |
77 |
+ self._info ['EVAR'].add ( value ) |
78 |
+ else: |
79 |
+ # set or dict? |
80 |
+ self._info ['EVAR'] = set ( ( value, ) ) |
81 |
+ |
82 |
elif key in self.__class__._UPDATE_KEYS_FILTER_NONE: |
83 |
if value is not None: |
84 |
self [key] = value |
85 |
@@ -416,15 +448,10 @@ class PackageInfo ( object ): |
86 |
|
87 |
else: |
88 |
self.logger.error ( |
89 |
- "in update(): unknown info key {}!".format ( key ) |
90 |
+ "in _update(): unknown info key {}!".format ( key ) |
91 |
) |
92 |
# -- end for; |
93 |
- |
94 |
- if remove_auto: |
95 |
- self._remove_auto ( remove_auto ) |
96 |
- |
97 |
- self._update_lock.release() |
98 |
- # --- end of update (**kw) --- |
99 |
+ # --- end of _update (...) --- |
100 |
|
101 |
def _use_filename ( self, _filename ): |
102 |
"""auxiliary method for update(**kw) |