diff options
| author | Yaakov M. Nemoy <loupgaroublond@gmail.com> | 2009-01-15 18:08:22 -0500 |
|---|---|---|
| committer | Yaakov M. Nemoy <loupgaroublond@gmail.com> | 2009-01-15 18:08:22 -0500 |
| commit | 401c14d76893579ce2af6e7018ec4140a3541cf1 (patch) | |
| tree | c957fd77ac4ef2dbc80c2a90e3a2600c8f7b74bb /modules/directory.py | |
| parent | 6f22d71cf8218abff64773545456fa6084ed2096 (diff) | |
| download | fedora-devshell-401c14d76893579ce2af6e7018ec4140a3541cf1.tar.gz fedora-devshell-401c14d76893579ce2af6e7018ec4140a3541cf1.tar.xz fedora-devshell-401c14d76893579ce2af6e7018ec4140a3541cf1.zip | |
Convert Directory to a metaclassed object to handle registration with dirfactory and other administrative details
Diffstat (limited to 'modules/directory.py')
| -rw-r--r-- | modules/directory.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/modules/directory.py b/modules/directory.py index 22cdec5..31c864c 100644 --- a/modules/directory.py +++ b/modules/directory.py @@ -19,6 +19,8 @@ from __future__ import with_statement +import base.dirfactory as dirfactory + from configobj import ConfigObj from os import makedirs, getcwd, listdir from os.path import abspath, join, split, splitext, basename, exists, dirname @@ -27,12 +29,17 @@ from base.base import log from base.module import Module from base.util import pwd, copytree -from modules.dirfactory import DirFactory +class MetaDirectory(type): + def __init__(cls, name, bases, attrs): + t = name.lower() + cls._type = t + dirfactory.register(cls, t) + class Directory(Module): '''a generic base class for any module that has to maintain state on the file system in a directory ''' - _type = 'directory' + __metaclass__ = MetaDirectory def __init__(self, name=None): ''' initializer |
