1 |
commit: e84a14f48da56aeaa015941cc1965ce7d805db38 |
2 |
Author: André Erdmann <dywi <AT> mailerd <DOT> de> |
3 |
AuthorDate: Sun Jan 27 18:58:32 2013 +0000 |
4 |
Commit: André Erdmann <dywi <AT> mailerd <DOT> de> |
5 |
CommitDate: Mon Jan 28 23:33:10 2013 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=e84a14f4 |
7 |
|
8 |
fixes for multiple Manifest implementations |
9 |
|
10 |
* roverlay/config/const.py: |
11 |
Added key 'OVERLAY.manifest_implementation' with value 'default' |
12 |
|
13 |
* roverlay/overlay/category.py: |
14 |
typo fixes, some commented code removed |
15 |
|
16 |
* roverlay/overlay/pkgdir/__init__.py: |
17 |
also accept the module name of a manifest implementation |
18 |
|
19 |
--- |
20 |
roverlay/config/const.py | 5 +++-- |
21 |
roverlay/overlay/category.py | 8 +++----- |
22 |
roverlay/overlay/pkgdir/__init__.py | 26 +++++++++++++++++++------- |
23 |
3 files changed, 25 insertions(+), 14 deletions(-) |
24 |
|
25 |
diff --git a/roverlay/config/const.py b/roverlay/config/const.py |
26 |
index 132125a..6eb30e6 100644 |
27 |
--- a/roverlay/config/const.py |
28 |
+++ b/roverlay/config/const.py |
29 |
@@ -46,8 +46,9 @@ _CONSTANTS = dict ( |
30 |
), |
31 |
|
32 |
OVERLAY = dict ( |
33 |
- name = 'R_Overlay', |
34 |
- category = 'sci-R', |
35 |
+ name = 'R_Overlay', |
36 |
+ category = 'sci-R', |
37 |
+ manifest_implementation = 'default', |
38 |
), |
39 |
) |
40 |
|
41 |
|
42 |
diff --git a/roverlay/overlay/category.py b/roverlay/overlay/category.py |
43 |
index 9090bb7..01c1776 100644 |
44 |
--- a/roverlay/overlay/category.py |
45 |
+++ b/roverlay/overlay/category.py |
46 |
@@ -139,7 +139,7 @@ class Category ( object ): |
47 |
if unsafe: |
48 |
try: |
49 |
return bool ( |
50 |
- next ( iter ( self._subdirs.value ) ).MANIFEST_THREADSAFE |
51 |
+ next ( iter ( self._subdirs.values() ) ).MANIFEST_THREADSAFE |
52 |
) |
53 |
except StopIteration: |
54 |
return True |
55 |
@@ -202,7 +202,7 @@ class Category ( object ): |
56 |
pkg = q.get_nowait() |
57 |
# remove manifest writing from threaded writing since it's |
58 |
# single-threaded |
59 |
- pkg.write ( write_manifest=False, **write_kw ) |
60 |
+ pkg.write ( **write_kw ) |
61 |
except queue.Empty: |
62 |
break |
63 |
except Exception as e: |
64 |
@@ -237,12 +237,10 @@ class Category ( object ): |
65 |
manifest_threadsafe = self.supports_threadsafe_manifest_writing ( |
66 |
unsafe=True |
67 |
) |
68 |
-# manifest_threadsafe = True |
69 |
+ |
70 |
write_queue = queue.Queue() |
71 |
for package in self._subdirs.values(): |
72 |
write_queue.put_nowait ( package ) |
73 |
-# if not package.MANIFEST_THREADSAFE: |
74 |
-# manifest_threadsafe = False |
75 |
|
76 |
write_kwargs ['write_manifest'] = ( |
77 |
write_manifest and manifest_threadsafe |
78 |
|
79 |
diff --git a/roverlay/overlay/pkgdir/__init__.py b/roverlay/overlay/pkgdir/__init__.py |
80 |
index e4ebffa..e140ef7 100644 |
81 |
--- a/roverlay/overlay/pkgdir/__init__.py |
82 |
+++ b/roverlay/overlay/pkgdir/__init__.py |
83 |
@@ -1,4 +1,4 @@ |
84 |
-# R overlay -- overlay package, package directory (<??>) |
85 |
+# R overlay -- overlay package, package directory |
86 |
# -*- coding: utf-8 -*- |
87 |
# Copyright (C) 2012 André Erdmann <dywi@×××××××.de> |
88 |
# Distributed under the terms of the GNU General Public License; |
89 |
@@ -24,16 +24,24 @@ _PACKAGE_DIR_IMPLEMENTATIONS = { |
90 |
'default' : 'packagedir_ebuildmanifest', |
91 |
'external:ebuild' : 'packagedir_ebuildmanifest', |
92 |
# 'external:portage' : 'packagedir_portagemanifest', |
93 |
-# 'internal' : NotImplemented, |
94 |
} |
95 |
|
96 |
def _configure(): |
97 |
- mf_impl = roverlay.config.get ( |
98 |
- 'OVERLAY.manifest_implementation', |
99 |
- _PACKAGE_DIR_IMPLEMENTATIONS ['default'] |
100 |
- ) |
101 |
+ """Determines which Manifest implementation to use and sets the |
102 |
+ _package_dir_module, _package_dir_class variables accordingly. |
103 |
+ """ |
104 |
+ |
105 |
+ mf_impl = roverlay.config.get_or_fail ( 'OVERLAY.manifest_implementation' ) |
106 |
|
107 |
- pkgdir_impl = _PACKAGE_DIR_IMPLEMENTATIONS.get ( mf_impl, None ) |
108 |
+ # also accept the internal (module) name of the manifest implementation |
109 |
+ pkgdir_impl = ( |
110 |
+ _PACKAGE_DIR_IMPLEMENTATIONS.get ( mf_impl, None ) |
111 |
+ or ( |
112 |
+ mf_impl |
113 |
+ if mf_impl in _PACKAGE_DIR_IMPLEMENTATIONS.values() |
114 |
+ else None |
115 |
+ ) |
116 |
+ ) |
117 |
|
118 |
if pkgdir_impl is not None: |
119 |
global _package_dir_module |
120 |
@@ -58,11 +66,15 @@ def _configure(): |
121 |
# --- end of configure (...) --- |
122 |
|
123 |
def get_class(): |
124 |
+ """Returns the configured PackageDir class.""" |
125 |
if _package_dir_class is None: |
126 |
_configure() |
127 |
return _package_dir_class |
128 |
# --- end of get_class (...) --- |
129 |
|
130 |
def create ( *args, **kwargs ): |
131 |
+ """Returns a new PackageDir object by calling the constructor |
132 |
+ of the configured PackageDir class (as returned by get_class()). |
133 |
+ """ |
134 |
return get_class() ( *args, **kwargs ) |
135 |
# --- end of create (...) --- |