Gentoo Archives: gentoo-commits

From: "André Erdmann" <dywi@×××××××.de>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/R_overlay:gsoc13/next commit in: roverlay/
Date: Wed, 05 Jun 2013 18:08:48
Message-Id: 1370455121.6614a65b9d90716e1648529900cc2241981d5dab.dywi@gentoo
1 commit: 6614a65b9d90716e1648529900cc2241981d5dab
2 Author: André Erdmann <dywi <AT> mailerd <DOT> de>
3 AuthorDate: Wed Jun 5 17:58:41 2013 +0000
4 Commit: André Erdmann <dywi <AT> mailerd <DOT> de>
5 CommitDate: Wed Jun 5 17:58:41 2013 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=6614a65b
7
8 packageinfo: add support for lazy actions
9
10 This feature is disabled because it's not used and would therefore only add
11 overhead.
12
13 ---
14 roverlay/packageinfo.py | 41 +++++++++++++++++++++++++++++++++++------
15 1 file changed, 35 insertions(+), 6 deletions(-)
16
17 diff --git a/roverlay/packageinfo.py b/roverlay/packageinfo.py
18 index c7c71eb..5962867 100644
19 --- a/roverlay/packageinfo.py
20 +++ b/roverlay/packageinfo.py
21 @@ -45,10 +45,19 @@ from roverlay.rpackage import descriptionreader
22 # * src_uri -- SRC_URI for a package
23 # * version -- tuple containing a package's version
24 #
25 -
26 #
27 -# FIXME/TOOD: don't overwrite name (package rules are applied _before_ reading
28 -# desc data)
29 +# Info (keys) that are created before applying package rules:
30 +#
31 +# * distdir
32 +# * origin
33 +# * package_{file{,name},name}
34 +# * name (package_name)
35 +# * src_uri (src_uri_base)
36 +#
37 +# "Foreign" info keys (never set or modified here):
38 +#
39 +# * category
40 +# * src_uri_dest
41 #
42
43 LOGGER = logging.getLogger ( 'PackageInfo' )
44 @@ -116,7 +125,7 @@ class PackageInfo ( object ):
45 self.overlay_package_ref = None
46 self.logger = LOGGER
47 #self._evars = dict()
48 - #self.lazy_actions = list()
49 + #self._lazy_actions = list()
50 #(or set(), but list preserves order for actions with the same condition)
51
52 self.update ( **initial_info )
53 @@ -129,13 +138,28 @@ class PackageInfo ( object ):
54 arguments:
55 * lazy_action --
56 """
57 - raise NotImplementedError ( "method stub" )
58 + raise NotImplementedError ( "lazy actions are disabled." )
59 + if hasattr ( self, '_lazy_actions' ):
60 + self._lazy_actions.append ( lazy_action )
61 + else:
62 + self._lazy_actions = [ lazy_action ]
63 # --- end of attach_lazy_action (...) ---
64
65 def apply_lazy_actions ( self ):
66 """Tries to apply all attached (lazy) actions.
67 Removes actions that have been applied."""
68 - raise NotImplementedError ( "method stub" )
69 + raise NotImplementedError ( "lazy actions are disabled." )
70 + if hasattr ( self, '_lazy_actions' ):
71 + retry_later = list()
72 + for action in self._lazy_actions:
73 + if not action.try_apply_action ( self ):
74 + retry_later.append ( action )
75 +
76 + if retry_later:
77 + self._lazy_actions = retry_later
78 + else:
79 + del self._lazy_actions
80 + # -- end if;
81 # --- end of apply_lazy_actions (...) ---
82
83 def set_readonly ( self, immediate=False, final=False ):
84 @@ -529,6 +553,11 @@ class PackageInfo ( object ):
85 "in _update(): unknown info key {}!".format ( key )
86 )
87 # -- end for;
88 +
89 + # FIXME (if needed):
90 + # the package rule parser doesn't create lazy actions, currently,
91 + # so calling apply_lazy_actions() would do nothing
92 + ##self.apply_lazy_actions()
93 # --- end of _update (...) ---
94
95 def _use_filename ( self, _filename ):