Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 276813 | Differences between
and this patch

Collapse All | Expand All

(-)a/pym/portage/__init__.py (-3 / +14 lines)
Lines 3-9 Link Here
3
# Distributed under the terms of the GNU General Public License v2
3
# Distributed under the terms of the GNU General Public License v2
4
# $Id$
4
# $Id$
5
5
6
7
VERSION="$Rev$"[6:-2] + "-svn"
6
VERSION="$Rev$"[6:-2] + "-svn"
8
7
9
# ===========================================================================
8
# ===========================================================================
Lines 206-219 class _unicode_module_wrapper(object): Link Here
206
	"""
205
	"""
207
	Wraps a module and wraps all functions with _unicode_func_wrapper.
206
	Wraps a module and wraps all functions with _unicode_func_wrapper.
208
	"""
207
	"""
209
	__slots__ = ('_mod', '_encoding', '_overrides')
208
	__slots__ = ('_mod', '_encoding', '_overrides', '_cache')
210
209
211
	def __init__(self, mod, encoding=_encodings['fs'], overrides=None):
210
	def __init__(self, mod, encoding=_encodings['fs'], overrides=None, cache=True):
212
		object.__setattr__(self, '_mod', mod)
211
		object.__setattr__(self, '_mod', mod)
213
		object.__setattr__(self, '_encoding', encoding)
212
		object.__setattr__(self, '_encoding', encoding)
214
		object.__setattr__(self, '_overrides', overrides)
213
		object.__setattr__(self, '_overrides', overrides)
214
		if cache:
215
			cache = {}
216
		else:
217
			cache = None
218
		object.__setattr__(self, '_cache', cache)
215
219
216
	def __getattribute__(self, attr):
220
	def __getattribute__(self, attr):
221
		cache = object.__getattribute__(self, '_cache')
222
		if cache is not None:
223
			result = cache.get(attr, None)
224
			if result is not None:
225
				return result
217
		result = getattr(object.__getattribute__(self, '_mod'), attr)
226
		result = getattr(object.__getattribute__(self, '_mod'), attr)
218
		encoding = object.__getattribute__(self, '_encoding')
227
		encoding = object.__getattribute__(self, '_encoding')
219
		overrides = object.__getattribute__(self, '_overrides')
228
		overrides = object.__getattribute__(self, '_overrides')
Lines 229-234 class _unicode_module_wrapper(object): Link Here
229
				encoding=encoding, overrides=overrides)
238
				encoding=encoding, overrides=overrides)
230
		elif hasattr(result, '__call__'):
239
		elif hasattr(result, '__call__'):
231
			result = _unicode_func_wrapper(result, encoding=encoding)
240
			result = _unicode_func_wrapper(result, encoding=encoding)
241
		if cache is not None:
242
			cache[attr] = result
232
		return result
243
		return result
233
244
234
import os as _os
245
import os as _os

Return to bug 276813