diff options
author | 2005-07-21 19:50:51 +0000 | |
---|---|---|
committer | 2005-07-21 19:50:51 +0000 | |
commit | 1d80bbb6ab614763daec7df7d086d05c5d897181 (patch) | |
tree | 74870854bbdc7f1221fd81dd9496b71429e6152e | |
parent | whee. (diff) | |
download | portage-cvs-1d80bbb6ab614763daec7df7d086d05c5d897181.tar.gz portage-cvs-1d80bbb6ab614763daec7df7d086d05c5d897181.tar.bz2 portage-cvs-1d80bbb6ab614763daec7df7d086d05c5d897181.zip |
basic contents objs.
-rw-r--r-- | portage/contents/__init__.py | 0 | ||||
-rw-r--r-- | portage/contents/fs.py | 76 |
2 files changed, 76 insertions, 0 deletions
diff --git a/portage/contents/__init__.py b/portage/contents/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/portage/contents/__init__.py diff --git a/portage/contents/fs.py b/portage/contents/fs.py new file mode 100644 index 0000000..a78768b --- /dev/null +++ b/portage/contents/fs.py @@ -0,0 +1,76 @@ +# Copyright 2004-2005 Gentoo Foundation +# Author(s): Brian Harring (ferringb@gentoo.org) +# License: GPL2 +# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/portage/contents/fs.py,v 1.1 2005/07/21 19:50:51 ferringb Exp $ + + +# goofy set of classes representating the fs objects portage knows of. + +_base_slots = ("location", "mtime", "perms", "uid", "gid") + +#try: +# import selinux +# _base_slots.append("selinux_label") +# +#except ImportError: +# pass + +class fsBase(object): + __slots__=tuple(_base_slots) + if "selinux_label" in _base_slots: + def __init__(self, location, mtime=None, perms=-1, uid=-1, gid=-1): + self.location = location +# if selinux_label: self.selinux_label = selinux_label + if mtime: self.mtime = mtime + if perms: self.perms = perms + if uid: self.uid = uid + if gid: self.gid = gid + else: + def __init__(self, location, mtime=None, perms=-1, uid=-1, gid=-1): + self.location = str(location) + if mtime: self.mtime = mtime + if perms: self.perms = perms + if uid: self.uid = uid + if gid: self.gid = gid + + def __setattr__(self, key, value): + try: + getattr(self, key) + raise Exception("non modifiable") + except AttributeError: + object.__setattr__(self, key, value) + + + +class fsFile(fsBase): + __slots__ = fsBase.__slots__ + ("md5", "size",) + def __init__(self, location, md5=None, size=0,**kwargs): + fsBase.__init__(self,location,**kwargs) + self.md5 = md5 + self.size = size + + def __repr__(self): return "file:%s" % self.location + +class fsDir(fsBase): + __slots__ = fsBase.__slots__ + + def __repr__(self): return "dir:%s" % self.location + +class fsLink(fsBase): + __slots__ = fsBase.__slots__ + ("target",) + def __init__(self, location, target, **kwargs): + fsBase.__init__(self,location,**kwargs) + self.target = target + + def __repr__(self): return "symlink:%s->%s" % (self.location, self.target) + +class fsDev(fsBase): + __slots__ = fsBase.__slots__ + + def __repr__(self): return "device:%s" % self.location + + +class fsFifo(fsBase): + __slots__ = fsBase.__slots__ + def __repr__(self): return "fifo:%s" % self.location + |