filesystem.py

Go to the documentation of this file.
00001 # Copyright 2005, 2006  Timo Savola
00002 #
00003 # This program is free software; you can redistribute it and/or modify
00004 # it under the terms of the GNU Lesser General Public License as published
00005 # by the Free Software Foundation; either version 2.1 of the License, or
00006 # (at your option) any later version.
00007 
00008 import os
00009 import gobject
00010 
00011 import project
00012 
00013 class Controller (project.ControllerExtension):
00014         rules = None
00015 
00016         def __init__(self, path):
00017                 project.ControllerExtension.__init__(self)
00018                 self.root = path
00019 
00020         def make_file(self, name, control=False):
00021                 path = self._get_path(name)
00022                 file = open(path, 'w')
00023                 file.close()
00024 
00025         def make_directory(self, name, control=False):
00026                 path = self._get_path(name)
00027                 os.mkdir(path)
00028 
00029         def remove(self, name, control=False):
00030                 path = self._get_path(name)
00031                 if os.path.isdir(path):
00032                         os.rmdir(path)
00033                 else:
00034                         os.remove(path)
00035 
00036         def rename(self, old_name, new_name, control=False):
00037                 old_path = self._get_path(old_name)
00038                 new_path = self._get_path(new_name)
00039                 os.rename(old_path, new_path)
00040 
00041         def clone(self, old_name, new_name, control=False):
00042                 old_path = self._get_path(old_name)
00043                 new_path = self._get_path(new_name)
00044                 project.copy_hierarchy(old_path, new_path)
00045 
00046         def _get_path(self, name):
00047                 return os.path.join(self.root, name)
00048 
00049 gobject.type_register(Controller)

Generated on Thu Jan 18 09:47:40 2007 for Encode by  doxygen 1.4.7