2 from model.project import Project
3 #from project_file import ProjectFile
5 from log.logging import logger
7 return os.path.splitext(path)[1]=='.prj'
11 class ProjectsDirectory:
12 def __init__(self,projects):
13 self.projects = projects
14 self.projects.observers.append(self)
15 self.projects.reread = self.read
19 def add_directory(self,directory,recursive = False):
20 self.directories[directory] = recursive
23 for p in range(0,self.num_elements):
25 self.num_elements -= 1
26 for directory,recursive in self.directories.items():
27 self.read_directory(directory,recursive)
29 def read_directory(self,directory,recursive=False):
30 for f in list_dir(directory,recursive=recursive,filter=is_project):
32 p,actions,infos = project_file.read(f)
33 # if not p in self.projects:
34 self.projects.append(p)
35 self.num_elements += 1
36 logger.log(u'Read project %s, actions %s, infos %s'%(p,actions,infos))
41 # logger.log(u'Result %s'%repr(p))
43 def notify(self,projects,attribute,new=None,old=None):
44 logger.log(repr(type(projects)))
45 # p_rep = repr(projects)
46 # a_rep = repr(attribute)
48 # logger.log(u"ProjectsDirectory notified of %s | %s | %s"%(p_rep,a_rep,n_rep))
49 if attribute == 'add_item':
50 p_file = project_file.ProjectFile(new)
51 new.observers.append(p_file)