3 # GPytage helper.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 ############################################################################
25 import pygtk
; pygtk
.require("2.0")
27 from config
import get_config_path
, config_files
32 """ Return files and directories in the portage config path """
33 config_path
= get_config_path()
36 for i
in config_files
:
37 result
= os
.path
.isdir(config_path
+i
)
40 elif(os
.access(config_path
+i
, os
.F_OK
)):
43 print "%s DOES NOT EXIST" % i
48 """ Return list of files in specified directory """
49 config_path
= get_config_path()
51 for i
in os
.listdir(config_path
+dir):
56 """ Perform a revert, load saved data """
58 datastore
.datastore
.clear()
59 for name
, store
in datastore
.lists
.iteritems():
61 datastore
.create_treeiter()
62 datastore
.create_lists()
63 from window
import title
66 def scan_contents(arg
):
67 """ Return data in specified file """
68 config_path
= get_config_path()
71 f
=open(config_path
+arg
, 'r')
72 contents
= f
.readlines()
74 except IOError: #needed or everything breaks
75 print 'HELPER: scan_contents(); Warning: Critical file %s%s not found' % (config_path
, arg
)
77 data
= [] #list of list: eg [['python','x86']]
79 if i
.startswith('#'): #don't split if its a comment
84 return data
#return the master list of lists