[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: geda_manager.git: branch: master updated (169d6296eb29864f63e53f02aa2362df972550a1)
The branch, master has been updated
via 169d6296eb29864f63e53f02aa2362df972550a1 (commit)
from ada59c0179fe56f9b959f18966ed639b16f3ccc2 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
=========
Summary
=========
src/dependencyloop.py | 9 +-
src/gedamanager.py | 33 ++----
src/gsch2pcb.py | 245 ++++++++++++++++++++++++++---------------
src/newproject.py | 4 +-
src/processdependencyevent.py | 4 +-
src/utils.py | 241 ++++++++++++++++++++++++++--------------
6 files changed, 331 insertions(+), 205 deletions(-)
=================
Commit Messages
=================
commit 169d6296eb29864f63e53f02aa2362df972550a1
Author: Newell Jensen <jensen@xxxxxxxxxxxxxxx>
Date: Sat Aug 30 04:47:18 2008 -0700
Checking in code. Dependency changes, gsch2pcb workflow, etc.
:100644 100644 84ec9ca... 2bdb508... M src/dependencyloop.py
:100644 100644 8c90012... 1ba4392... M src/gedamanager.py
:100644 100644 1596144... c6bf288... M src/gsch2pcb.py
:100644 100644 c355427... db38bc0... M src/newproject.py
:100644 100644 8b12455... 0d83377... M src/processdependencyevent.py
:100644 100644 5f6c536... 98b5603... M src/utils.py
=========
Changes
=========
commit 169d6296eb29864f63e53f02aa2362df972550a1
Author: Newell Jensen <jensen@xxxxxxxxxxxxxxx>
Date: Sat Aug 30 04:47:18 2008 -0700
Checking in code. Dependency changes, gsch2pcb workflow, etc.
diff --git a/src/dependencyloop.py b/src/dependencyloop.py
index 84ec9ca..2bdb508 100644
--- a/src/dependencyloop.py
+++ b/src/dependencyloop.py
@@ -51,19 +51,20 @@ class DependencyLoop:
self.threaded_notifier.start()
# start watching the project's directory recursively
+ self.wdd = None
if self.g.project.directory != None:
self.wdd = self.watch_manager.add_watch(self.g.project.directory, IN_MODIFY, rec=True)
- def swith_projects(self):
+ def switch_projects(self):
"""
Method to switch which directory is being watched for events.
This method will be called when projects are changed, etc.
"""
- # TODO --I will need to call this when a project is renamed.
-
+ print 'SWITCHING PROJECTS'
# Takes care of subdirectories
- self.watch_manager.rm_watch(self.wdd.values())
+ if self.wdd != None:
+ self.watch_manager.rm_watch(self.wdd.values())
# Now add a new watch to the new project
# This line probable doesn't do anything for me
if self.g.project.directory != None:
diff --git a/src/gedamanager.py b/src/gedamanager.py
index 8c90012..1ba4392 100644
--- a/src/gedamanager.py
+++ b/src/gedamanager.py
@@ -42,7 +42,9 @@ class gEDAManager:
"""
def __init__(self):
""" gEDAManager Constructor. """
- # Initialize gEDA Manager
+
+ # Initialize gEDA Manager
+ self.depnum = 0
self.no_project_name = 'No project loaded...\n\n Select:\n Project->Open Project\n or Project->New Project'
self.settings = Settings()
self.utils = Utils()
@@ -556,10 +558,6 @@ class gEDAManager:
@param parent_path is a parameter to help in writing the paths
to the self.sources gtk.TreeStore object
"""
- print 'Loading Dependencies'
- print 'dep_dict:',dep_dict
- print 'parent_path:',parent_path
- print 'parent:',parent
for key, value in dep_dict.iteritems():
# filepath
if parent_path != None:
@@ -841,6 +839,7 @@ class gEDAManager:
@param widget that threw the event.
@param event that was thrown.
"""
+ self.dependencyloop.switch_projects()
self.output_textbuffer.insert(self.output_textiter, self.utils.get_time() + ':\n' + 'Project ' + self.project.name + ' opened.\n')
self.set_menu_defaults()
self.set_sources_tree_to_project()
@@ -853,6 +852,7 @@ class gEDAManager:
@param widget that threw the event.
@param event that was thrown.
"""
+ self.dependencyloop.switch_projects()
self.output_textbuffer.insert(self.output_textiter, self.utils.get_time() + ':\nProject ' + self.project.name + ' created.\n')
self.set_menu_defaults()
self.set_sources_tree_to_new_project()
@@ -1164,9 +1164,6 @@ class gEDAManager:
def delete_dependency_dict_entry(arg, dirname, filenames):
""" function to delete the filenames from the dependency_dict """
- print 'filenames:',filenames
- print 'dirname:',dirname
- print 'arg:',arg
for f in filenames:
if f in self.project.dependency_dict and list(self.utils.flatten(self.project.file_list)).count(f) == 1:
del self.project.dependency_dict[f]
@@ -1197,7 +1194,7 @@ class gEDAManager:
self.sources.append(selection_iter, [image, filename, filepath])
# Add the new folder to project file list
self.utils.update_file_list(self)
-
+
## @exceptions
## def cb_delete_folder(self, action):
@@ -1368,13 +1365,9 @@ class gEDAManager:
# then a reordering took place but nothing happended.
# We want to ignore this case.
- if len(self.dependencies) != self.depnum:
- print 'len(self.dependencies):',len(self.dependencies)
+# if len(self.dependencies) != self.depnum:
+# print 'len(self.dependencies):',len(self.dependencies)
- print 'path:',path
- print '_iter:',_iter
- print 'model[path]:',model[path]
- print 'model[path][0]:',model[path][0]
# This last print statement give me the file that was moved
# Path gives me where it was moved to.
# We can check for a match when iterating through, and if the path
@@ -1382,21 +1375,15 @@ class gEDAManager:
if len(self.dependencies) <= self.depnum:
# Iterate over the whole tree and create the project.depedency_dict
for i, row in enumerate(self.dependencies):
- print 'i:',i
- print 'row[0]:',row[0]
- if row[0] == model[path][0]:
- print 'We have a match'
if i < self.depnum:
for r in row:
- print 'r:',r
row_iter = row.iterchildren()
try:
for z in row_iter.next():
- print 'z:',z
+ pass
except:
pass
# Need to update the dependency_dict -- put here
- print 'self.project.dependency_dict:',self.project.dependency_dict
def cb_switch_page(self, notebook, page, page_num):
@@ -1410,7 +1397,7 @@ class gEDAManager:
"""!
Method to update the dependency_dict ... this is really a helper
"""
- lst = []
+ lst = [True]
try:
for row in row_iter.next():
baby_row_iter = row.iterchildren()
diff --git a/src/gsch2pcb.py b/src/gsch2pcb.py
index 1596144..c6bf288 100644
--- a/src/gsch2pcb.py
+++ b/src/gsch2pcb.py
@@ -51,15 +51,15 @@ class Gsch2pcb:
def response_to_dialog_project(entry, dialog, response):
dialog.response(response)
-
- directory_entry = gtk.Entry()
- directory_entry.set_text(os.getcwd())
- directory_entry.show()
-
- def cb_filebutton_selection_changed(filechooser, directory_entry):
+ def cb_directory_selection_changed(filechooser, directory_entry):
self.directory = self.filebutton.get_filename()
directory_entry.set_text(self.directory)
+ def cb_project_selection_changed(filechooser, project_entry):
+ self.projectpath = self.projectfile.get_filename()
+ self.project_entry.set_text(self.projectpath)
+
+
self.dialog = gtk.MessageDialog(self.g.window,
(gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT),
gtk.MESSAGE_OTHER,
@@ -71,43 +71,53 @@ class Gsch2pcb:
# Target Directory
hbox = gtk.HBox()
hbox.show()
+ directory_entry = gtk.Entry()
+ directory_entry.set_text(os.getcwd())
+ directory_entry.show()
+ directory_entry.connect('activate', response_to_dialog_directory, self.dialog, gtk.RESPONSE_OK)
self.filebutton = gtk.FileChooserButton('Target Directory')
self.filebutton.show()
self.filebutton.connect('selection-changed',
- cb_filebutton_selection_changed, directory_entry)
+ cb_directory_selection_changed, directory_entry)
self.filebutton.set_local_only(True)
self.filebutton.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
hbox.pack_end(self.filebutton)
- directory_entry.connect('activate', response_to_dialog_directory, self.dialog, gtk.RESPONSE_OK)
hbox.pack_end(directory_entry)
label = gtk.Label('Target Directory:')
label.show()
hbox.pack_end(label)
self.dialog.vbox.pack_end(hbox, True, True, 0)
- # PCB name
+ # PCB name
hbox = gtk.HBox()
hbox.show()
- name_entry = gtk.Entry()
- name_entry.show()
- name_entry.connect('activate', response_to_dialog_name, self.dialog, gtk.RESPONSE_OK)
- hbox.pack_end(name_entry)
+ self.name_entry = gtk.Entry()
+ self.name_entry.show()
+ self.name_entry.connect('activate', response_to_dialog_name, self.dialog, gtk.RESPONSE_OK)
+ hbox.pack_end(self.name_entry)
label = gtk.Label('PCB Name (extension will be provided):')
label.show()
hbox.pack_end(label)
self.dialog.vbox.pack_end(hbox, True, True, 0)
- # Project file
- hbox = gtk.HBox()
- hbox.show()
- self.project_entry = gtk.Entry()
- self.project_entry.show()
- self.project_entry.connect('activate', response_to_dialog_project, self.dialog, gtk.RESPONSE_OK)
- hbox.pack_end(self.project_entry)
- label = gtk.Label('Project file (use full paths for schematics):')
- label.show()
- hbox.pack_end(label)
- self.dialog.vbox.pack_end(hbox, True, True, 0)
+## # Project file
+## hbox = gtk.HBox()
+## hbox.show()
+## self.project_entry = gtk.Entry()
+## self.project_entry.show()
+## self.project_entry.connect('activate', response_to_dialog_project, self.dialog, gtk.RESPONSE_OK)
+## self.projectfile = gtk.FileChooserButton('PCB Name')
+## self.projectfile.show()
+## self.projectfile.connect('selection-changed',
+## cb_project_selection_changed, self.project_entry)
+## self.projectfile.set_local_only(True)
+## self.projectfile.set_action(gtk.FILE_CHOOSER_ACTION_OPEN)
+## hbox.pack_end(self.projectfile)
+## hbox.pack_end(self.project_entry)
+## label = gtk.Label('Project file (use full paths for schematics):')
+## label.show()
+## hbox.pack_end(label)
+## self.dialog.vbox.pack_end(hbox, True, True, 0)
# Schematic selections
scrolled_window = gtk.ScrolledWindow()
@@ -117,8 +127,6 @@ class Gsch2pcb:
# Get schematics in project no matter what directory
# They must be listed in the sources tree view though
self.schematics = self.get_schematics()
- print 'self.schematics:',self.schematics
- print 'len of self.schematics:', len(self.schematics)
self.schematics_tree = gtk.TreeView(self.schematics)
self.schematics_tree.show()
column = gtk.TreeViewColumn('File', gtk.CellRendererText(), text=1)
@@ -132,16 +140,16 @@ class Gsch2pcb:
scrolled_window.add(self.schematics_tree)
self.dialog.vbox.pack_end(scrolled_window, True, True, 0)
- # Radio buttons
- self.project_radio_button = gtk.RadioButton(None, 'Use project file')
- self.project_radio_button.connect('toggled', self.cb_rdobutton_toggled, 'Use project file')
- self.dialog.vbox.pack_end(self.project_radio_button, True, True, 0)
- self.project_radio_button.show()
- self.schematics_radio_button = gtk.RadioButton(self.project_radio_button, 'Select schematics from project')
- self.schematics_radio_button.set_active(True)
- self.schematics_radio_button.connect('toggled', self.cb_rdobutton_toggled, 'Select schematics from project')
- self.dialog.vbox.pack_end(self.schematics_radio_button, True, True, 0)
- self.schematics_radio_button.show()
+## # Radio buttons
+## self.project_radio_button = gtk.RadioButton(None, 'Use project file')
+## self.project_radio_button.connect('toggled', self.cb_rdobutton_toggled, 'Use project file')
+## self.dialog.vbox.pack_end(self.project_radio_button, True, True, 0)
+## self.project_radio_button.show()
+## self.schematics_radio_button = gtk.RadioButton(self.project_radio_button, 'Select schematics from project')
+## self.schematics_radio_button.set_active(True)
+## self.schematics_radio_button.connect('toggled', self.cb_rdobutton_toggled, 'Select schematics from project')
+## self.dialog.vbox.pack_end(self.schematics_radio_button, True, True, 0)
+## self.schematics_radio_button.show()
self.dialog.show()
response = self.dialog.run()
@@ -151,23 +159,26 @@ class Gsch2pcb:
schematics = ''
self.in_project = False
- # Schematics or Project
- if self.schematics_radio_button.get_active():
- # Iterate over the gtk.TreeModel
- for row in self.schematics:
- if row[2]:
- # Add the schematic to the schematic_list
- print 'adding row[1]:',row[1]
- schematics_list.append(row[1])
- schematics += row[1] + ' '
- if not schematics_list:
- message = 'At least one schematic must be chosen.\n'
- else:
- project = self.project_entry.get_text()
- if project == '' or project == None:
- message += 'Full path to project file must be specified.\n'
+## # Schematics or Project
+## if self.schematics_radio_button.get_active():
+ # Iterate over the gtk.TreeModel
+ for row in self.schematics:
+ if row[2]:
+ # Add the schematic to the schematic_list
+ schematics_list.append(row[1])
+ schematics += row[1] + ' '
+ if not schematics_list:
+ message = 'At least one schematic must be chosen.\n'
+## else:
+## if self.projectpath == '' or self.projectpath == None:
+## message += 'Full path to project file must be specified.\n'
- name = name_entry.get_text()
+## if self.project_radio_button.get_active():
+## # Check to see if there is projectpath
+## if self.projectpath == None or self.projectpath == '':
+## message += 'You must specify a project path if using a project file.\n'
+## else:
+ name = self.name_entry.get_text()
if name == '' or name == None:
message += 'A name for the PCB must be specified.\n'
@@ -179,7 +190,6 @@ class Gsch2pcb:
# If so, set in_project flag to true
os.path.walk(self.directory, self.directory_match, None)
- print 'message:',message
if message != '':
msg = message.rpartition('\n')[0]
dm = gtk.MessageDialog(self.g.window,
@@ -192,23 +202,86 @@ class Gsch2pcb:
dm.run()
dm.destroy()
else:
- # Call the code to run the gsch2pcb workflow
- if self.schematics_radio_button.get_active():
- subproc = Popen(['gsch2pcb', '-v','-v','-o',name,schematics])
- else:
- subproc = Popen(['gsch2pcb', '-v','-v',project])
-
- if in_project:
- print 'This is in the projects directory'
+ # Steps
+ # 1) Get list of files in the target directory and put them in
+ # a list
+ # 2) Run the process
+ # 3) Get the list of files in target now
+ # 4) Subtract old from new to get added files
+ # 5) Add files to tree view (only ones I want)
+ # 6) Add these files to the dependency dict
+ files_before = os.listdir(self.directory)
+ subproc = Popen(['gsch2pcb', '-v','-v','-o',name,schematics]).wait()
+ files_after = os.listdir(self.directory)
+ files = []
+ for f in files_after:
+ if f not in files_before:
+ files.append(f)
+
+## # Call the code to run the gsch2pcb workflow
+## if self.schematics_radio_button.get_active():
+## subproc = Popen(['gsch2pcb', '-v','-v','-o',name,schematics])
+## else:
+
+## subproc = Popen(['gsch2pcb', '-v','-v',self.projectpath])
+
+ if self.in_project:
# Add it to the sources tree view
- # Need to see what the selection_iter is and its parent
+ icon = gtk.IconTheme()
selection = self.g.sources_tree.get_selection()
model, selection_iter = selection.get_selected()
parent_iter = self.g.sources.iter_parent(selection_iter)
-# selected_node = self.g.sources.get_value(selection_iter, 2)
-# self.g.sources.append(parent_iter
- # be added to the file_list or dependency_dict or the treeview.
-
+ wanted = ['pcb','new.pcb','net']
+ new_files = []
+ new_files.append(True)
+ for f in files:
+ if f.endswith('new.pcb'):
+ ext = 'new.pcb'
+ else:
+ ext = f.split('.')[-1]
+ if ext in wanted:
+ image = icon.load_icon(self.g.utils.icon_lut[ext], 22, 0)
+ self.g.sources.append(parent_iter, [image, f, self.directory + '/' + f])
+ # add new file to the dependency_dict
+ if f not in self.g.project.dependency_dict:
+ self.g.project.dependency_dict[f] = [True]
+
+ new_files.append(f)
+ for sch in self.schematics:
+ if sch[0] not in self.g.project.dependency_dict[sch[0]]:
+ self.g.project.dependency_dict[sch[0]] = new_files
+ else:
+ self.g.project.dependency_dict[sch[0]][0] = True
+ for f in new_files:
+ self.g.project.dependency_dict[sch[0]].append(f)
+## new_list = []
+## for sch in self.schematics:
+## lst = []
+## lst.append(True)
+## lst.append(sch[0])
+## new_list.append(lst)
+## if f not in self.g.project.dependency_dict:
+## self.g.project.dependency_dict[f] = new_list
+## else:
+## # Add to the value that is already there
+## for lst in new_list:
+## print 'lst in new_list:',lst
+## self.g.project.dependency_dict[f].append(lst)
+ # Update project by saving it
+ self.g.utils.update_file_list(self.g)
+
+## for lst in gedamanager.project.dependency_dict[filename]:
+## print lst, ' for updating lst'
+## lst[0] = False
+## new_list.append(lst)
+## if filename not in g.project.dependency_dict:
+## g.project.dependency_dict[filename] = []
+## print 'new_list:', new_list
+## gedamanager.project.dependency_dict[filename] = new_list
+
+
+
+
self.dialog.destroy()
@@ -234,23 +307,26 @@ class Gsch2pcb:
model[path][2] = not model[path][2]
- def cb_rdobutton_toggled(self, widget, data=None):
- """!
- Event handler for the radio buttons.
- @param widget the gtk.RadioButton that threw the event
- @param data option user paramater
- """
- print "%s was toggled %s" % (data, ("OFF", "ON")[widget.get_active()])
- if data == 'Use project file' and widget.get_active():
- # Make the self.schematics_tree insensitive
- self.schematics_tree.set_sensitive(False)
- self.project_entry.set_sensitive(True)
- else:
- self.schematics_tree.set_sensitive(True)
- self.project_entry.set_sensitive(False)
+## def cb_rdobutton_toggled(self, widget, data=None):
+## """!
+## Event handler for the radio buttons.
+## @param widget the gtk.RadioButton that threw the event
+## @param data option user paramater
+## """
+## print "%s was toggled %s" % (data, ("OFF", "ON")[widget.get_active()])
+## if data == 'Use project file' and widget.get_active():
+## # Make the self.schematics_tree insensitive
+## self.schematics_tree.set_sensitive(False)
+## self.name_entry.set_sensitive(False)
+## self.project_entry.set_sensitive(True)
+## self.projectfile.set_sensitive(True)
+## else:
+## self.schematics_tree.set_sensitive(True)
+## self.name_entry.set_sensitive(True)
+## self.project_entry.set_sensitive(False)
+## self.projectfile.set_sensitive(False)
-
def get_schematics(self):
"""!
Method to get to populate the gtk.TreeStore object self.schematics
@@ -261,7 +337,6 @@ class Gsch2pcb:
lst = self.search(self.g.sources, self.match_func, (1, '.sch'))
if lst != None:
for f in lst:
- print 'f:',f
self.schematics.append(None, [f[1], f[2], True])
return self.schematics
@@ -276,7 +351,6 @@ class Gsch2pcb:
@return True if match, otherwise False
"""
column, key = data
- print 'row[column]:',row[column]
return row[column].endswith(key)
@@ -290,20 +364,15 @@ class Gsch2pcb:
@return lst list of gtk.TreeModelRow objects
"""
if not rows:
- print 'returning rows None'
return None
for row in rows:
if func(row, data):
- print 'we have a match!'
if lst == None:
lst = []
lst.append(row)
- print 'searching recursively'
lst = self.search(row.iterchildren(), func, data, lst)
if lst:
- print 'lst:',lst
return lst
else:
- print 'returning None'
return None
diff --git a/src/newproject.py b/src/newproject.py
index c355427..db38bc0 100644
--- a/src/newproject.py
+++ b/src/newproject.py
@@ -285,8 +285,8 @@ class NewProject:
# Set new project attributes
self.project.name = self.get_filename().split('.')[0]
self.project.directory = self.get_path() + '/' + self.project.name.split('.')[0]
- self.project.dependency_dict = {self.project.name + '.gm': [], 'output.log': [], 'error.log': []}
- self.project.file_list = [self.project.name, [self.project.name + '.gm', 'output.log', 'error.log']]
+ self.project.dependency_dict = {self.project.name + '.gm': [True], 'output.log': [True], 'error.log': [True]}
+ self.project.file_list = [self.project.name, [self.project.name + '.gm', 'output.log', 'error.log']]
# Remove directories with imported remove_tree
if self.confirm_overwrite.get_active():
shutil.rmtree(self.project.directory)
diff --git a/src/processdependencyevent.py b/src/processdependencyevent.py
index 8b12455..0d83377 100644
--- a/src/processdependencyevent.py
+++ b/src/processdependencyevent.py
@@ -51,7 +51,7 @@ class ProcessDependencyEvent(ProcessEvent):
# Call method to set the status of the dependent files recursively
filename = self.g.utils.get_node_name(event.pathname)
if filename != None and self.g.project.dependency_dict != None:
+ print 'filename in process catcher:',filename
if filename in self.g.project.dependency_dict:
- self.g.utils.update_dependency_dict(self.g, filename)
- print 'catching event for file:',filename
+ self.g.utils.update_dependency_dict(self.g, filename, True)
diff --git a/src/utils.py b/src/utils.py
index 5f6c536..98b5603 100644
--- a/src/utils.py
+++ b/src/utils.py
@@ -177,24 +177,24 @@ class Utils:
return 'folder'
- def get_status_image(self, gedamanager, selected_node, process_ext):
+ def get_status_image(self, gedamanager, selected_node):
"""!
Method to get the status image for the process.
@param gedamanager the current gEDAManager instance
@param selected_node the currently selected node in the 'Sources' tree view.
- @param process_ext the type of file that is having its status set (updated/outdated)
@return icon the icon from the self.icon_lut structure
"""
g = gedamanager
filename = self.get_node_name(selected_node)
icon = gtk.IconTheme()
if filename in g.project.dependency_dict:
- for lst in g.project.dependency_dict[filename]:
- if lst[0] and lst[1].endswith(process_ext):
- print lst[1], ' is updated'
+ # Check its status
+ if g.project.dependency_dict[filename] != None:
+ if g.project.dependency_dict[filename][0]:
return icon.load_icon(self.icon_lut['updated'], 22, 0)
- # If nothing found in the loop, then it is outdated
- return icon.load_icon(self.icon_lut['outdated'], 22, 0)
+ else:
+ # If nothing found in the loop, then it is outdated
+ return icon.load_icon(self.icon_lut['outdated'], 22, 0)
def flatten(self, lst):
@@ -211,6 +211,63 @@ class Utils:
@exceptions
+ def is_filename_in_dependencies(self, gedamanager, filename, delete=False):
+ """!
+ Method to determine if the given filename is in the project's
+ dependencies.
+ @param gedamanager current gEDAManager instance
+ @param filename name of the file under investigation
+ @return True or False
+ """
+ # TODO -- this still needs fixing for the delete part
+ # Need to iterate through to see if the filename is in the tree
+ if filename != None:
+ for row in gedamanager.dependencies:
+ if row[0] == filename:
+ if delete:
+ pass
+ #del gedamanager.dependencies[row],
+ return True
+ row_iter = row.iterchildren()
+ if row_iter != None: # We have children in this row
+ child_list = self.child_recurse(row_iter, 0)
+ if child_list != None:
+ child_list = [x for x in child_list if x != None]
+ for x in child_list:
+ if x == filename:
+ if delete:
+ pass
+ #del gedamanager.dependencies[x]
+ #gedamanager.dependencies.remove(iter_remove)
+ return True
+ return False
+
+
+ def child_recurse(self, row_iter, index):
+ """!
+ Method to iterate recursively over child nodes.
+ @param row_iter is the gtk.TreeModelRowIter object
+ @param index is the index of the row to add to the returned list
+ @return list of child nodes
+ """
+ child_list = []
+ while True:
+ try:
+ child_row = row_iter.next()
+ child_list.append(child_row[index])
+ child_row_iter = child_row.iterchildren()
+ if child_row_iter != None:
+ child_list.append(self.child_recurse(child_row_iter, index))
+ except StopIteration:
+ break
+ for x in child_list:
+ if x == None:
+ child_list.remove(x)
+ if child_list != []:
+ return child_list
+
+
+ @exceptions
def update_file_list(self, gedamanager, index=None, filepath=None):
"""!
Method to update the gEDA Manager's project file list any time
@@ -222,28 +279,6 @@ class Utils:
@param filepath of the source to copy
"""
g = gedamanager
- def child_recurse(row_iter):
- """!
- Internal function to iterate recursively over child nodes.
- @param row_iter is the gtk.TreeModelRowIter object.
- @return a list of child nodes.
- """
- child_list = []
- while True:
- try:
- child_row = row_iter.next()
- child_list.append(child_row[1])
- child_row_iter = child_row.iterchildren()
- if child_row_iter != None:
- child_list.append(child_recurse(child_row_iter))
- except StopIteration:
- break
- for x in child_list:
- if x == None:
- child_list.remove(x)
- if child_list != []:
- return child_list
-
selection = g.sources_tree.get_selection()
model, selection_iter = selection.get_selected()
if selection_iter == None:
@@ -256,7 +291,9 @@ class Utils:
icon = gtk.IconTheme()
image = icon.load_icon(self.icon_lut[self.get_node_ext(filename)], 22, 0)
path = selected_node + '/' + filename
-
+
+
+ print 'g.projec.file_list before:',g.project.file_list
if index == 0:
# Logic here for copying the file to the selected_node's folder
# First check that a file with the same name does not exist
@@ -265,16 +302,21 @@ class Utils:
os.system('cp ' + filepath + ' ' + selected_node)
g.sources.append(selection_iter, [image, filename, path])
g.output_textbuffer.insert(g.output_textiter, self.get_time() + ':\n' + 'Added copy of source:' + filepath + ' to ' + selected_node + '.\n')
+ # Add to the dependency tree
+ if not self.is_filename_in_dependencies(g, filename):
+ g.dependencies.append(None, [filename, path])
+ # Add to the dependency_dict if not in there
if filename not in g.project.dependency_dict:
- g.project.dependency_dict[filename] = []
+ g.project.dependency_dict[filename] = [True]
elif filepath == selected_node + '/' + filename:
g.sources.append(selection_iter, [image, filename, path])
g.output_textbuffer.insert(g.output_textiter, self.get_time() + ':\n' + 'Added copy of source:' + filepath + ' to project.\n')
if filename not in g.project.dependency_dict:
- g.project.dependency_dict[filename] = []
+ g.project.dependency_dict[filename] = [True]
else:
g.output_textbuffer.insert(g.output_textiter, self.get_time() + ':\n' + filename + ' is already present in the directory: ' + selected_node + '.\n')
elif index == 1:
+ # This is currently not implemented -- TODO delete this
# Logic here to delete the selected file
f = os.path.exists(selected_node)
if f:
@@ -285,6 +327,7 @@ class Utils:
if node in g.project.dependency_dict and list(self.flatten(g.project.file_list)).count(node) == 1:
del g.project.dependency_dict[node]
elif index == 2:
+ # This is currently not implemented -- TODO delete this
# Logic here to delete the folder
exists = os.path.exists(selected_node)
if exists: # delete directory recursively
@@ -301,26 +344,37 @@ class Utils:
os.system('touch ' + filepath)
g.sources.append(selection_iter, [image, filename, filepath])
g.output_textbuffer.insert(g.output_textiter, self.get_time() + ':\n' + 'Added new source:' + filepath + ' to ' + selected_node + '.\n')
+ # Add to the dependency tree
+ if not self.is_filename_in_dependencies(g, filename):
+ g.dependencies.append(None, [filename, path])
+ # Add to the dependency_dict if not in there
if filename not in g.project.dependency_dict:
- g.project.dependency_dict[filename] = []
+ g.project.dependency_dict[filename] = [True]
else:
g.output_textbuffer.insert(g.output_textiter, self.get_time() + ':\n' + filename + ' is already present in the directory: ' + selected_node + '.\n')
elif index == 4:
# Logic here to remove a source
# Remove from tree view
g.sources.remove(selection_iter)
- # Remove from dependency list
+ # Remove from dependency tree
+ if self.is_filename_in_dependencies(g, filename, True):
+ g.output_textbuffer.insert(g.output_textiter, self.get_time() + ':\nRemoved ' + selected_node + ' from dependencies tree.\n')
+ # Remove from dependency_dict
if filename in g.project.dependency_dict:
del g.project.dependency_dict[filename]
g.output_textbuffer.insert(g.output_textiter, self.get_time() + ':\nRemoved ' + selected_node + ' from project.\n')
elif index == 5:
# Logic here to remove a folder
for f in os.listdir(selected_node):
+ # Remove from dependency tree
+ if self.is_filename_in_dependencies(g, filename, True):
+ g.output_textbuffer.insert(g.output_textiter, self.get_time() + ':\nRemoved ' + selected_node + ' from dependencies tree.\n')
+ # Remove from dependency_dict
if f in g.project.dependency_dict and list(self.flatten(g.project.file_list)).count(f) == 1:
del g.project.dependency_dict[f]
g.sources.remove(selection_iter)
g.output_textbuffer.insert(g.output_textiter, self.get_time() + ':\nRemoved ' + selected_node + ' from project.\n')
-
+
# Create Project's File List
g.project.file_list = []
for row in g.sources:
@@ -329,17 +383,26 @@ class Utils:
g.project.file_list.append(row[1])
row_iter = row.iterchildren() # This will be True for the root
if row_iter != None: # We have children in this row
- child_list = child_recurse(row_iter)
- for x in child_list:
- if x == None:
- child_list.remove(None)
- g.project.file_list.append(child_list)
-
+ print 'going into child_list'
+ child_list = self.child_recurse(row_iter, 1)
+ print 'child_list:',child_list
+ if child_list != None:
+ for x in child_list:
+ if x == None:
+ child_list.remove(None)
+ g.project.file_list.append(child_list)
+
+ print 'g.projec.file_list after:',g.project.file_list
+
+ # Now save the project since the new update file_list is made
g.project.save()
+ # Expand the 'Sources' tree view
g.sources_tree.expand_all()
+ # Create a new dependency loop
+ g.dependencyloop.switch_projects()
- @exceptions
+ #@exceptions
def get_processes_tree(self, gedamanager, selected_node=None, ext=None, folder=None, clear=None):
"""!
Method to populate the 'Processes' tree view in the gEDA Manager.
@@ -394,14 +457,14 @@ class Utils:
# PCB
image = icon.load_icon(self.icon_lut['g2p'], 22, 0)
- status_image = self.get_status_image(g, selected_node, 'pcb')
- g.processes.append(create_pcb, ['gsch2pcb workflow', image, status_image])
+ #status_image = self.get_status_image(g, selected_node, 'pcb')
+ g.processes.append(create_pcb, ['gsch2pcb workflow', image, None])#status_image])
# Netlists
image = icon.load_icon(self.icon_lut['net'], 22, 0)
gnetlist = g.processes.append(create_netlist, ['gnetlist', image, None])
for netlist in sorted(self.netlists):
- status_image = self.get_status_image(g, selected_node, netlist)
+ status_image = self.get_status_image(g, selected_node)
g.processes.append(gnetlist, [netlist, None, status_image])
# Modify attributes
@@ -413,20 +476,23 @@ class Utils:
g.processes.append(modify_attributes, ['gattrib', image, None])
elif ext == 'pcb':
+ # gsch2pcb
+ status_image = self.get_status_image(g, selected_node)
+ export = g.processes.append(None, ['gsch2pcb', None, status_image])
# Export
export = g.processes.append(None, ['Export', None, None])
- status_image = self.get_status_image(g, selected_node, 'gbr')
+ status_image = self.get_status_image(g, selected_node)
gerber = g.processes.append(export, ['RS-274X (Gerber) file(s)', None, status_image])
# May need to add for bom1 and bom2
- status_image = self.get_status_image(g, selected_node, 'bom')
+ status_image = self.get_status_image(g, selected_node)
bom = g.processes.append(export, ['Bill of Materials (BOM) file(s)', None, status_image])
- status_image = self.get_status_image(g, selected_node, 'em')
+ status_image = self.get_status_image(g, selected_node)
nelma = g.processes.append(export, ['Numerical analysis (Nelma) file(s)', None, status_image])
- status_image = self.get_status_image(g, selected_node, 'png')
+ status_image = self.get_status_image(g, selected_node)
png = g.processes.append(export, ['GIF/JPEG/PNG file(s)', None, status_image])
- status_image = self.get_status_image(g, selected_node, 'ps')
+ status_image = self.get_status_image(g, selected_node)
ps = g.processes.append(export, ['Postscript file(s)', None, status_image])
- status_image = self.get_status_image(g, selected_node, 'eps')
+ status_image = self.get_status_image(g, selected_node)
eps = g.processes.append(export, ['Encapsulated Postscript file(s)', None, status_image])
# Print
_print = g.processes.append(None, ['Print (lpr)', None, None])
@@ -507,13 +573,13 @@ class Utils:
selection = g.sources_tree.get_selection()
model, selection_iter = selection.get_selected()
highlighted_source = g.sources.get_value(selection_iter, 2)
- name = self.get_node_name(highlighted_source)
- if name not in g.project.dependency_dict:
- g.project.dependency_dict[name] = []
+ filename = self.get_node_name(highlighted_source)
+ if filename not in g.project.dependency_dict:
+ g.project.dependency_dict[filename] = [True]
self.run_command(g, selected_node, highlighted_source)
- @exceptions
+ #@exceptions
def run_command(self, gedamanager, filepath, highlighted_source=None, ext=None):
"""!
Method to run commands for 'Processes' and 'Sources'.
@@ -524,14 +590,20 @@ class Utils:
@param ext is the extension of the selected file
"""
g = gedamanager
- print 'filepath:',filepath
files = ['net','log','bom','bom1','bom2','v','vhd','gm','txt']
# Sources
if ext != None:
os.chdir(filepath.rpartition('/')[0])
if ext == 'sch' or ext == 'sym':
if g.tools['sch'] == None or g.tools['sch'].poll() == 0:
- g.tools['sch'] = Popen(['gschem', filepath], stdin=PIPE)
+ g.tools['sch'] = Popen(['gschem', filepath], stdin=PIPE, stdout=PIPE)
+# Popen(['gschem', filepath], stdin=PIPE, stdout=PIPE)
+## stdout = g.tools['sch'].communicate()[0]
+## print 'stdout:',stdout
+## child_stdout = g.tools['sch'].stdout
+## print 'child_stdout:', child_stdout
+## for f in child_stdout.readline():
+## print 'child_stdout line:',f
elif g.tools['sch'].poll() == None: # Process is still running
# Let's try to open a file
try:
@@ -551,13 +623,8 @@ class Utils:
g.tools['gerbv'] = Popen(['gerbv', filepath])
elif g.tools['gerbv'].poll() == None: # Process is still running
print 'gerbv is open'
- if (ext in files or ext in self.configfiles) and g.settings.editor != None:
- # Need to put some logic here to make sure it is a valid program
- if g.tools['editor'] == None or g.tools['editor'].poll() == 0:
- g.tools['editor'] = Popen([g.settings.editor, filepath])
- elif g.tools['editor'].poll() == None: # Process is still running
- pass
- elif g.settings.editor == None:
+ elif (ext in files or ext in self.configfiles):
+ if g.settings.editor == None:
dialog = gtk.MessageDialog(g.window,
(gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT),
gtk.MESSAGE_INFO,
@@ -567,6 +634,13 @@ class Utils:
dialog.show()
response = dialog.run()
dialog.destroy()
+
+ # Need to put some logic here to make sure it is a valid program
+ elif g.tools['editor'] == None or g.tools['editor'].poll() == 0:
+ g.tools['editor'] = Popen([g.settings.editor, filepath])
+ elif g.tools['editor'].poll() == None: # Process is still running
+ print 'editor in use'
+ pass
else: # Processes
os.chdir(highlighted_source.rpartition('/')[0])
@@ -578,7 +652,6 @@ class Utils:
# and whether or not it is currently running (GUI only)
# Netlists
- print 'program:',program
if program in self.netlists: # use gnetlist
subproc = Popen(['gnetlist', '-v','-g',program,highlighted_source])
elif program == 'ghdl-compile':
@@ -602,36 +675,32 @@ class Utils:
# Call new class logic to go through the workflow
self.gsch2pcb = Gsch2pcb(g, highlighted_source)
pass
+ elif progarm == 'gsch2pcb':
+ pass
+## schematics = []
+
+## subproc = Popen(['gsch2pcb', '-v','-v','-o',name,schematics]).wait()
+## files_after = os.listdir(self.directory)
+## files = []
+## for f in files_after:
+## if f not in files_before:
+## files.append(f)
+
else:
- print 'program:',program
subproc = Popen([program, highlighted_source])
-
- @exceptions
- def update_dependency_dict(self, gedamanager, filename):
+ def update_dependency_dict(self, gedamanager, filename, flag=False):
"""!
Method to update the dependencies for filename.
@param gedamanager of the current gEDAManager instance
@param filename of the file that will have its dependencies updated
"""
# We just need to create a new list and set that as the value
- print 'UPDATING'
- new_list = []
- for lst in gedamanager.project.dependency_dict[filename]:
- print lst, ' for updating lst'
- lst[0] = False
- new_list.append(lst)
- # Now set the new_list as the value for filename
- print 'new_list:', new_list
- gedamanager.project.dependency_dict[filename] = new_list
-
- # Below is commented out because it was causing an infinite loop
- # since saving the project updates the project.gm file
-
-## # Update the project by saving it
-## gedamanager.project.save()
-
+ gedamanager.project.dependency_dict[filename][0] = flag
+ for x in gedamanager.project.dependency_dict[filename][1:]:
+ # recure over files and make out of date
+ self.update_dependency_dict(gedamanager, x, False)
def add_to_dependency_dict(self, gedamanager, filename):
"""!
@@ -642,5 +711,5 @@ class Utils:
g = gedamanager
# add file to the dependency_dict
if filename not in g.project.dependency_dict:
- g.project.dependency_dict[filename] = []
+ g.project.dependency_dict[filename] = [True]
_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs