3 # GPytage datastore.py module
5 ############################################################################
6 # Copyright (C) 2008 by Kenneth Prugh #
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. #
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. #
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")
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.
35 parent_folder
, simple_files
= folder_scan()
38 for i
in simple_files
:
39 lists
[i
] = gtk
.ListStore(str, str, bool, str)
40 data
= scan_contents(i
)
43 col1
= row
[0].rstrip() #strips \n
47 col2
= row
[1].rstrip() # not all files have 2 cols
50 lists
[i
].append([col1
, col2
, True, i
])
52 for i
in parent_folder
:
54 sub_folders
= folder_walk(i
)
56 lists
[i
] = gtk
.ListStore(str, str, bool, str)
57 sub_file_path
= parent
+ '/' + i
58 data
= scan_contents(sub_file_path
)
61 col1
= row
[0].rstrip() #strips \n
65 col2
= row
[1].rstrip() # not all files have 2 cols
68 lists
[i
].append([col1
, col2
, True, parent
])
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
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
])