# Copyright 2005-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# Author(s): Brian Harring ([email protected])

import os as _os
import sys
from portage.cache import template
from portage import os

from portage.proxy.lazyimport import lazyimport
lazyimport(globals(),
	'portage.exception:PortageException',
	'portage.util:apply_permissions',
)
del lazyimport

if sys.hexversion >= 0x3000000:
	long = int

class FsBased(template.database):
	"""template wrapping fs needed options, and providing _ensure_access as a way to 
	attempt to ensure files have the specified owners/perms"""

	def __init__(self, *args, **config):

		for x, y in (("gid", -1), ("perms", -1)):
			if x in config:
				setattr(self, "_"+x, config[x])
				del config[x]
			else:
				setattr(self, "_"+x, y)
Exemple #2
0
# Copyright 2005-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# Author(s): Brian Harring ([email protected])

import os as _os
from portage.cache import template
from portage import os

from portage.proxy.lazyimport import lazyimport

lazyimport(
    globals(),
    "portage.exception:PortageException",
    "portage.util:apply_permissions,ensure_dirs",
)
del lazyimport


class FsBased(template.database):
    """template wrapping fs needed options, and providing _ensure_access as a way to
    attempt to ensure files have the specified owners/perms"""
    def __init__(self, *args, **config):

        for x, y in (("gid", -1), ("perms", 0o644)):
            if x in config:
                # Since Python 3.4, chown requires int type (no proxies).
                setattr(self, "_" + x, int(config[x]))
                del config[x]
            else:
                setattr(self, "_" + x, y)
        super(FsBased, self).__init__(*args, **config)