Add manifest to manifest
[gpytage.git] / datastore.py
blob22624264fc8fc4358dc67008ef3db6d08421cc3d
1 #!/usr/bin/env python
3 # GPytage datastore.py module
5 ############################################################################
6 # Copyright (C) 2008 by Kenneth Prugh #
7 # ken69267@gmail.com #
8 # #
9 # This program is free software; you can redistribute it and#or modify #
10 # it under the terms of the GNU General Public License as published by #
11 # the Free Software Foundation under version 2 of the license. #
12 # #
13 # This program is distributed in the hope that it will be useful, #
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
16 # GNU General Public License for more details. #
17 # #
18 # You should have received a copy of the GNU General Public License #
19 # along with this program; if not, write to the #
20 # Free Software Foundation, Inc., #
21 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
22 ############################################################################
24 import pygtk; pygtk.require("2.0")
25 import gtk
26 from helper import folder_scan, folder_walk, scan_contents
27 from config import config_files
29 datastore = gtk.TreeStore(str, str, bool, str) #stores the main files
31 #19:33 < Zalamander> Ken69267 use a dictionary to map the names to created
32 #lists. "d = {}; for name in list: d[name] = [1,2,3,4,5]" values will be in the dict.
34 def create_lists():
35 parent_folder, simple_files = folder_scan()
36 global lists
37 lists = {}
38 for i in simple_files:
39 lists[i] = gtk.ListStore(str, str, bool, str)
40 data = scan_contents(i)
41 for row in data:
42 try:
43 col1 = row[0].rstrip() #strips \n
44 except:
45 col1 = None
46 try:
47 col2 = row[1].rstrip() # not all files have 2 cols
48 except:
49 col2 = None
50 lists[i].append([col1, col2, True, i])
52 for i in parent_folder:
53 parent = i
54 sub_folders = folder_walk(i)
55 for i in sub_folders:
56 lists[i] = gtk.ListStore(str, str, bool, str)
57 sub_file_path = parent + '/' + i
58 data = scan_contents(sub_file_path)
59 for row in data:
60 try:
61 col1 = row[0].rstrip() #strips \n
62 except:
63 col1 = None
64 try:
65 col2 = row[1].rstrip() # not all files have 2 cols
66 except:
67 col2 = None
68 lists[i].append([col1, col2, True, parent])
69 return lists
71 def create_treeiter():#create the parent/main files
72 parent_folder, simple_files = folder_scan()
73 #parent_files = self.folder_walk(parent_folder)
74 for i in simple_files: #needs no sub main rows just data
75 siter = datastore.append(None, [i, None, False, i])
76 for i in parent_folder: #parent_folders is list of folders such as package.keywords
77 #i is a dir such as package.keywords
78 pfolder = i
79 piter = datastore.append(None, [i, None, False, i])
80 complex_files = folder_walk(i) #this needs to return list files in dir
81 for i in complex_files: #"simple files"
82 name = i #folder name being iterated
83 citer = datastore.append(piter, [i, None, False, pfolder])