[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: geda_manager.git: branch: master updated (6a65dad7a28d60377548009e3e0f7f11733ebd11)



The branch, master has been updated
       via  6a65dad7a28d60377548009e3e0f7f11733ebd11 (commit)
      from  81e3f4a2b5353ee0fb2a32bf02d6f106dd4b2ad0 (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/gedamanager.py    |  127 ++++++++++++++++++++++++--------------
 src/lib/decorators.py |   13 ++--
 src/newproject.py     |   24 ++++---
 src/project.py        |   40 ++++++------
 src/utils.py          |  165 ++++++++++++++++++++++++++++++++++---------------
 5 files changed, 236 insertions(+), 133 deletions(-)


=================
 Commit Messages
=================

commit 6a65dad7a28d60377548009e3e0f7f11733ebd11
Author: Newell Jensen <jensen@xxxxxxxxxxxxxxx>
Date:   Wed Aug 20 02:03:51 2008 -0700

    Fixed some nasty bug fixes.

:100644 100644 ee54744... 8dee2d4... M	src/gedamanager.py
:100644 100644 c5fa5e2... 9bbfea3... M	src/lib/decorators.py
:100644 100644 daf080e... 96fd769... M	src/newproject.py
:100644 100644 4a2c634... 762dbf2... M	src/project.py
:100644 100644 c159c31... 6e35fac... M	src/utils.py

=========
 Changes
=========

commit 6a65dad7a28d60377548009e3e0f7f11733ebd11
Author: Newell Jensen <jensen@xxxxxxxxxxxxxxx>
Date:   Wed Aug 20 02:03:51 2008 -0700

    Fixed some nasty bug fixes.

diff --git a/src/gedamanager.py b/src/gedamanager.py
index ee54744..8dee2d4 100644
--- a/src/gedamanager.py
+++ b/src/gedamanager.py
@@ -429,10 +429,9 @@ class gEDAManager:
         self.sources.clear()
         
         # Parent Folder
-        name = self.project.name
         icon = gtk.IconTheme()
         image = icon.load_icon(self.utils.icon_lut['project'], 22, 0)
-        parent = self.sources.append(None, [image, name, self.project.directory])
+        parent = self.sources.append(None, [image, self.project.name, self.project.directory])
 
         # Child Node
         icon = gtk.IconTheme()
@@ -756,6 +755,7 @@ class gEDAManager:
         self.set_sources_tree_to_new_project()
 
 
+    @exceptions
     def cb_preferences(self, menuitem, data=None):
         """!
         Event occurs when the user wants to add a source to the project
@@ -823,6 +823,7 @@ class gEDAManager:
             self.settings.editor = new_text
 
 
+    @exceptions
     def cb_new_source(self, menuitem, data=None):
         """!
         Event occurs when the user wants to add a source to the project
@@ -892,15 +893,21 @@ class gEDAManager:
         dialog.destroy()
 
         if new_text:
-            print self.newsource
-            print new_text
-        else:
-            print 'empty'
-
-        # Now call the program with the new file
-        # Check to see if there is already an instance open
-        # Add this file to the dependency dictionary
-        # Add this file to the project's file_list
+            # Get the selected_node for the folder to add to            
+            selection = self.sources_tree.get_selection()
+            model, selection_iter = selection.get_selected()
+            selected_node = self.sources.get_value(selection_iter, 2)
+            # Get the type of extension for the program to call
+            if '.' in new_text: # user may have overriden extension
+                ext = self.utils.get_node_ext(new_text)
+            else: # Need to find out what extension from the highlighted node
+                ext = self.newsource[self.newsource.find('.')+1:self.newsource.find(')')]
+            # Make sure a file with the same name doesn't already exist
+            filepath = selected_node + '/' + new_text + '.' + ext
+            filename = new_text + '.' + ext
+            self.utils.update_file_list(self, 3, filepath)
+            self.utils.run_command(self, filepath, None, ext)
+            
 
     @exceptions
     def cb_add_copy_source(self, menuitem, data=None):
@@ -919,10 +926,8 @@ class gEDAManager:
         self.file_filters(dialog)
         response = dialog.run()
         if response == gtk.RESPONSE_OK:
-            filename = dialog.get_filename()
-            name = self.utils.get_node_name(filename)
-            self.utils.update_file_list(self, 0, filename)
-            self.utils.add_to_dependency_dict(self, name)
+            filepath = dialog.get_filename()
+            self.utils.update_file_list(self, 0, filepath)
         dialog.destroy()
 
 
@@ -970,35 +975,49 @@ class gEDAManager:
         response = dialog.run()
         if response == gtk.RESPONSE_OK:
             directory = filebutton.get_filename()
-            new_file = embed_fc.get_filename()
-            if new_file != None:
-                
-                # add new file to the dependency_dict
-                self.utils.add_to_dependency_dict(self, directory + '/' + new_file)
+            print 'directory:',directory
+            filepath = embed_fc.get_filename()
+            print 'filepath:',filepath
+            if filepath != None:
                 # Find out what file it is so we can pick an icon for it
-                name = self.utils.get_node_name(new_file)        
+                filename = self.utils.get_node_name(filepath)
+                print 'filename:',filename                
+                # add new file to the dependency_dict                
+                self.utils.add_to_dependency_dict(filename)                
                 icon = gtk.IconTheme()
-                image = icon.load_icon(self.utils.icon_lut[self.utils.get_node_ext(name)], 22, 0)
+                image = icon.load_icon(self.utils.icon_lut[self.utils.get_node_ext(filename)], 22, 0)
 
+                # We can't call update file list because the currently selected
+                # node (a file) is not the one that we want to put it
+                # under ( whic is some folder). Thus, we need to find the iter
+                # for the directory chosen.
                 for row in self.sources:
-                    # Get the name of the node
+                    # Get the filename of the node
                     if row[2] == directory:
+                        print 'holy shit!!!'
                         row_iter = row.iterchildren() # This will be True for the root
-                    else:
-                        self.errors_textbuffer.insert(self.errors_textiter, directory + " is not present in the project's directory structure.\n")
-                        return
-
-                # Copy the new_file to the chosen directory
+                if row_iter == None:
+                    self.errors_textbuffer.insert(self.errors_textiter, directory + " is not present in the project's directory structure.\n")
+                    return
+                
+                # Copy the filepath to the chosen directory
                 # Also update the sources with the proper node
                 files = os.listdir(directory)
-                if name not in files:
-                    os.system('cp ' + new_file + ' ' + directory)
-                    self.sources.append(row_iter, [image, name, path])
-                    self.output_textbuffer.insert(self.output_textiter, self.utils.get_time() + ':\n' + 'Added copy of source - ' + new_file + ' - to ' + directory + '.\n')
+                if filename not in files:
+                    os.system('cp ' + filepath + ' ' + directory)
+                    self.sources.append(row_iter, [image, filename, filepath])
+                    self.output_textbuffer.insert(self.output_textiter, self.utils.get_time() + ':\n' + 'Added copy of source - ' + filepath + ' - to ' + directory + '.\n')
                 else:
-                    self.output_textbuffer.insert(self.output_textiter, self.utils.get_time() + ':\n' + name + ' is already present in the directory - ' + directory + '.\n')
+                    self.output_textbuffer.insert(self.output_textiter, self.utils.get_time() + ':\n' + filename + ' is already present in the directory - ' + directory + '.\n')
                 # Add the new file as a dependency for the selected file
-                self.project.dependency_dict[selected_node].append((True, new_file))
+                print 'holla'
+                parent_file = self.utils.get_node_name(selected_node)
+                print 'parent_file:',parent_file
+                if parent_file not in self.project.dependency_dict:
+                    self.project.dependency_dict[parent_file] = []
+
+                self.project.dependency_dict[parent_file].append((True, filename))                
+
         dialog.destroy()
         
 
@@ -1038,32 +1057,46 @@ class gEDAManager:
         dialog.run()
         text = entry.get_text()
         dialog.destroy()
-        path = selected_node + '/' + text
-
+        filepath = selected_node + '/' + text
+
+        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]
+                    
         # See if this directory already exists
-        if os.path.exists(path): # delete directory recursively
-            shutil.rmtree(path)
+        if os.path.exists(filepath): # delete directory recursively
+            print 'before'
+            os.path.walk(filepath, delete_dependency_dict_entry, None)
+            print 'after'
+            shutil.rmtree(filepath)
             flag = True
             i = 0
             while flag:
                 child_iter = self.sources.iter_nth_child(selection_iter, i)
                 child_node = self.sources.get_value(child_iter, 2)
-                if child_node == path:
+                if child_node == filepath:
                     if child_iter != None:
                         flag = self.sources.remove(child_iter)
                         if flag: # break out if flag is true
                             flag = False
                 i = i + 1
-        os.mkdir(path)
+        os.mkdir(filepath)
         
-        name = self.utils.get_node_name(path)
+        filename = self.utils.get_node_name(filepath)
         # Find out what file it is so we can pick an icon for it
         icon = gtk.IconTheme()
-        image = icon.load_icon(self.utils.icon_lut[self.utils.get_node_ext(name)], 22, 0)
-        self.sources.append(selection_iter, [image, name, path])
+        image = icon.load_icon(self.utils.icon_lut[self.utils.get_node_ext(filename)], 22, 0)
+        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, widget):
         """!
         Event occurs when the user chooses to delete a folder from the project.
@@ -1167,15 +1200,15 @@ class gEDAManager:
         model, selection_iter = selection.get_selected()
         if selection_iter != None:
             selected_node = self.sources.get_value(selection_iter, 2)
-            name = self.utils.get_node_name(selected_node)
-            if '.' in name and not name.endswith('.gm'):
+            filename = self.utils.get_node_name(selected_node)
+            if '.' in filename and not filename.endswith('.gm'):
                 # Logic to call function to find what type of file it is
                 # and then to populate the according tree view
-                ext = name.split('.')[-1]
+                ext = filename.split('.')[-1]
                 self.utils.get_processes_tree(self, selected_node, ext, None, True)
                 # Update 'Processes: ' for the 'Processes' tree
                 column = self.processes_tree.get_column(0)
-                column.set_title('Processes for: ' + name)
+                column.set_title('Processes for: ' + filename)
                 column = self.processes_tree.get_column(2)
                 column.set_title('status')
                 
diff --git a/src/lib/decorators.py b/src/lib/decorators.py
index c5fa5e2..9bbfea3 100644
--- a/src/lib/decorators.py
+++ b/src/lib/decorators.py
@@ -23,7 +23,8 @@
 #Library file for decorators
 #@author Newell Jensen
 
-from src.gedamanager import *
+import sys, time
+
 
 def exceptions(func):
     """!
@@ -45,15 +46,15 @@ def exceptions(func):
                 try:
                     f = func(*args)
                 except IOError:
-                    arg.errors_textbuffer.insert(arg.errors_textiter, 'IOError: ' +  str(sys.exc_info()) + ' ' + str(func) + '.\n')
+                    arg.errors_textbuffer.insert(arg.errors_textiter, time.asctime(time.localtime(time.time())) + ':\nIOError- ' +  str(sys.exc_info()) + ' ' + str(func) + '.\n')
                 except OSError:
-                    arg.errors_textbuffer.insert(arg.errors_textiter, 'OSError: ' +  str(sys.exc_info()) + ' ' + str(func) + '.\n')
+                    arg.errors_textbuffer.insert(arg.errors_textiter, time.asctime(time.localtime(time.time())) + ':\nOSError- ' +  str(sys.exc_info()) + ' ' + str(func) + '.\n')
                 except IndexError:
-                    arg.errors_textbuffer.insert(arg.errors_textiter, 'IndexError: ' +  str(sys.exc_info()) + ' ' + str(func) + '.\n')
+                    arg.errors_textbuffer.insert(arg.errors_textiter, time.asctime(time.localtime(time.time())) + ':\nIndexError- ' +  str(sys.exc_info()) + ' ' + str(func) + '.\n')
                 except TypeError:
-                    arg.errors_textbuffer.insert(arg.errors_textiter, 'TypeError: ' +  str(sys.exc_info()) + ' ' + str(func) + '.\n')                                        
+                    arg.errors_textbuffer.insert(arg.errors_textiter, time.asctime(time.localtime(time.time())) + ':\nTypeError- ' +  str(sys.exc_info()) + ' ' + str(func) + '.\n')                                        
                 except:
-                    arg.errors_textbuffer.insert(arg.errors_textiter, 'Unexpected error: ' +  str(sys.exc_info()) + ' ' + str(func) + '.\n')            
+                    arg.errors_textbuffer.insert(arg.errors_textiter, time.asctime(time.localtime(time.time())) + ':\nUnexpected error- ' +  str(sys.exc_info()) + ' ' + str(func) + '.\n')            
                     raise
                 return f
             
diff --git a/src/newproject.py b/src/newproject.py
index daf080e..96fd769 100644
--- a/src/newproject.py
+++ b/src/newproject.py
@@ -214,15 +214,15 @@ class NewProject:
             already exists.
             @return returns a list
             """
-            name = self.get_filename().split('.')[0]
-            f = os.path.exists(self.get_path() + '/' + name)
+            filename = self.get_filename().split('.')[0]
+            f = os.path.exists(self.get_path() + '/' + filename)
             new_directory = []
             overwrite_list = []
             
             if f:
-                overwrite_list.append(name)                
+                overwrite_list.append(filename)                
             else:
-                new_directory.append(name)
+                new_directory.append(filename)
             return [new_directory, overwrite_list]
 
 
@@ -325,22 +325,26 @@ class NewProject:
 
     def get_path(self):
         """!
-        Method to get path of new project.
-        @return path for file.
+        Method to get path of new project
+        @return filepath: filepath from the filebutton
+        @type filepath: string
         """
-        path = self.filebutton.get_filename()
-        return path
+        filepath = self.filebutton.get_filename()
+        return filepath
+
 
     def get_filename(self):
         """!
-        Method to get file name of the new project.
-        @return file name.
+        Method to get file name of the new project
+        @return filename: filename for the new project file
+        @type filename: string
         """
         filename = self.filename.get_text()
         if not filename.endswith('.gm'):
             filename += '.gm'
         return filename
 
+
     def main(self):
         """ Method starts the main loop for gtk. """
         gtk.main()
diff --git a/src/project.py b/src/project.py
index 4a2c634..762dbf2 100644
--- a/src/project.py
+++ b/src/project.py
@@ -50,28 +50,28 @@ class Project(gobject.GObject):
                     }
 
     
-    def __init__(self, path=None):
+    def __init__(self, filepath=None):
         """ Default Constructor. """
         gobject.GObject.__init__(self)
 
-        if path != None:
+        if filepath != None:
             try:
-                self.name = path.rsplit('/')[-1].split('.')[0]
-                self.directory = path.rpartition('/')[0]
+                self.name = filepath.rsplit('/')[-1].split('.')[0]
+                self.directory = filepath.rpartition('/')[0]
                 # open up project file
-                project = yaml.load(open(path))
+                project = yaml.load(open(filepath))
             except IOError:
                 project = 0
             except yaml.YAMLError, exc:
                 if hasattr(exc, 'problem_mark'):
                     mark = exc.problem_mark
-                    print 'There is an error in the' + path  + 'file.\n'
+                    print 'There is an error in the' + filepath  + 'file.\n'
                     print "Error position: (%s:%s)" % (mark.line+1, mark.column+1)
                     exit(-1)
 
             if project:
                 # parse the config object and get list of apps
-                stream = file(path, 'r')
+                stream = file(filepath, 'r')
                 for data in yaml.load_all(stream):
                     self.file_list = data['file_list']
                     self.dependency_dict = data['dependency_dict']
@@ -109,15 +109,16 @@ class Project(gobject.GObject):
 
 
     def save(self, silent=None):
-        """
-        Method to save the project file and then emit the
-        'saved' signal if succesful.
+        """!
+        Method to save the project file and then emit the 'saved' signal if succesful
+        @param silent: flag for whether or not the 'saved' signal should be emitted
+        @type silent: bool
         """
         if self.name != None and self.directory != None:
-            path = self.directory + '/' + self.name + '.gm'
+            filepath = self.directory + '/' + self.name + '.gm'
             try:
-                stream = file(path, 'w')
-                yaml.dump({'project': path, 'file_list': self.file_list,
+                stream = file(filepath, 'w')
+                yaml.dump({'project': filepath, 'file_list': self.file_list,
                            'dependency_dict': self.dependency_dict},
                       stream, default_flow_style=False)
                 stream.close()
@@ -128,15 +129,16 @@ class Project(gobject.GObject):
                 self.emit('saved', True)
 
 
-    def open(self, path):
+    def open(self, filepath):
         """!
-        Method to open up project from path and set as current project.
-        @param path is the path of the project file to open.
+        Method to open up project from path and set as current project
+        @param filepath: filepath of the project file to open
+        @type filepath: string
         """
-        self.name = path.rsplit('/')[-1].split('.')[0]
-        self.directory = path.rpartition('/')[0]
+        self.name = filepath.rsplit('/')[-1].split('.')[0]
+        self.directory = filepath.rpartition('/')[0]
         try:
-            stream = file(path, 'r')
+            stream = file(filepath, 'r')
             for data in yaml.load_all(stream):
                 self.file_list = data['file_list']
                 self.dependency_dict = data['dependency_dict']
diff --git a/src/utils.py b/src/utils.py
index c159c31..6e35fac 100644
--- a/src/utils.py
+++ b/src/utils.py
@@ -143,14 +143,16 @@ class Utils:
 
     def get_node_ext(self, path):
         """!
-        Method to return the extension for the path.
-        @param path to the node.
-        @return extension of the node.
+        Method to return the extension for the path
+        @param path: filepath for the node file
+        @type path: string
+        @return ext: extension of the node
+        @type ext: string
         """
         if '.' in path:
             return path.split('.')[-1]
         else:
-            return 'folder' 
+            return 'folder'
 
 
     def get_status_image(self, gedamanager, selected_node, process_ext):
@@ -173,15 +175,56 @@ class Utils:
         return icon.load_icon(self.icon_lut['outdated'], 22, 0)
                     
 
+    def flatten(self, lst):
+##         """!
+##         Method to see if filename is in the project's file_list (recursively)
+##         @param count: current count of how many times filename is in file_list
+##         @type count: int
+##         @param filename: filename for the file to check
+##         @type filename: string
+##         @param file_list: list to iterate over
+##         @type file_list: list
+##         @param keep_going: flag to set so we can break out of recursive function
+##         @type keep_going: bool
+##         @return boolean: boolean of true or false
+##         @type boolean: bool
+##         """
+        for elem in lst:
+            if type(elem) in (tuple, list):
+                for i in self.flatten(elem):
+                    yield i
+            else:
+                yield elem
+
+        
+##         print 'file_list:',file_list
+##         if keep_going:
+##             for f in file_list:
+##                 print 'f:',f
+##                 print 'filename:',filename
+##                 if f == filename:
+##                     count = count + 1
+##                     print 'count:',count
+##                     if count == 2:
+##                         keep_going = False
+##                         print 'keep_going False'
+##                         return keep_going
+##                 elif isinstance(f, list):
+##                     keep_going = self.walk_dependency_dict(count, filename, f, keep_going)
+##         return keep_going
+
     @exceptions
-    def update_file_list(self, gedamanager, index=None, filename=None):
+    def update_file_list(self, gedamanager, index=None, filepath=None):
         """!
         Method to update the gEDA Manager's project file list any time
         the 'Sources' tree view is changed.
-        @param gedamanager is the current gEDAManager instance.        
-        @param index (0 = add copy source, 1 = delete source,
+        @param gedamanager: The current gEDAManager instance
+        @type gedamanager: gEDAManager
+        @param index: (0 = add copy source, 1 = delete source,
         2 = delete folder)
-        @param filename is the filename of the source to copy.
+        @type index: int
+        @param filepath: filepath of the source to copy
+        @type filepath: string
         """
         g = gedamanager
         def child_recurse(row_iter):
@@ -211,51 +254,66 @@ class Utils:
         if selection_iter == None:
             selection_iter = g.sources.get_iter_first()
         selected_node = g.sources.get_value(selection_iter, 2)
-        if filename != None:
-            name = self.get_node_name(filename)
+        if filepath != None:
+            filename = self.get_node_name(filepath) # Files
         else:
-            name = self.get_node_name(selected_node)
+            filename = self.get_node_name(selected_node) # Folders
         icon = gtk.IconTheme()
-        image = icon.load_icon(self.icon_lut[self.get_node_ext(name)], 22, 0)
-        path = selected_node + '/' + name
+        image = icon.load_icon(self.icon_lut[self.get_node_ext(filename)], 22, 0)
+        path = selected_node + '/' + filename
+##         print 'path:',path
+##         print 'filepath:',filepath
+##         print 'filename:',filename
         
         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
             files = os.listdir(selected_node)
-            if name not in files:
-                os.system('cp ' + filename + ' ' + selected_node)
-                g.sources.append(selection_iter, [image, name, path])
-                g.output_textbuffer.insert(g.output_textiter, self.get_time() + ':\n' + 'Added copy of source:' + filename + ' to ' + selected_node + '.\n')
-                if name not in g.project.dependency_dict:
-                    g.project.dependency_dict[name] = []
+            if filename not in files:
+                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')
+                if filename not in g.project.dependency_dict:
+                    g.project.dependency_dict[filename] = []
             else:
-                g.output_textbuffer.insert(g.output_textiter, self.get_time() + ':\n' + name + ' is already present in the directory: ' + selected_node + '.\n')
+                g.output_textbuffer.insert(g.output_textiter, self.get_time() + ':\n' + filename + ' is already present in the directory: ' + selected_node + '.\n')
         elif index == 1:
             # Logic here to delete the selected file
             f = os.path.exists(selected_node)
             if f:
                 os.system('rm ' + selected_node)
                 g.sources.remove(selection_iter)
-                g.output_textbuffer.insert(g.output_textiter, self.get_time() + ':\n' + 'Deleted ' + selected_node + '.\n')
+                g.output_textbuffer.insert(g.output_textiter, self.get_time() + ':\nDeleted ' + selected_node + '.\n')
                 node = self.get_node_name(selected_node)
-                if node in g.project.dependency_dict:
+                print 'count:',list(self.flatten(g.project.file_list)).count(node)
+                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:
             # Logic here to delete the folder
-            f = os.path.exists(selected_node)
-            if f: # delete directory recursively
+            exists = os.path.exists(selected_node)
+            if exists: # delete directory recursively
                 for f in os.listdir(selected_node):
-                    if f in g.project.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]
                 os.system('rm -rf ' + selected_node)
                 g.sources.remove(selection_iter)
-                g.output_textbuffer.insert(g.output_textiter, 'Folder deleted: ' + selected_node + '.\n')
+                g.output_textbuffer.insert(g.output_textiter, self.get_time() + ':\nDeleted ' + selected_node + '.\n')
+        elif index == 3:
+            # Logic here to add a new source
+            files = os.listdir(selected_node)
+            if filename not in files:
+                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')
+                if filename not in g.project.dependency_dict:
+                    g.project.dependency_dict[filename] = []
+            else:
+                g.output_textbuffer.insert(g.output_textiter, self.get_time() + ':\n' + filename + ' is already present in the directory: ' + selected_node + '.\n')
 
         # Create Project's File List
         g.project.file_list = [] 
         for row in g.sources:
-            # Get the name of the node
+            # Get the filename of the node
             if row[2] == g.project.directory: # Project Folder
                 g.project.file_list.append(row[1])
             row_iter = row.iterchildren() # This will be True for the root
@@ -435,11 +493,11 @@ class Utils:
 
         
     @exceptions
-    def run_command(self, gedamanager, selected_node, highlighted_source=None, ext=None):
+    def run_command(self, gedamanager, filepath, highlighted_source=None, ext=None):
         """!
         Method to run commands for 'Processes' and 'Sources'.
         @param gedamanager is the current gEDAManager instance.
-        @param selected_node is the selected 'Sources' or 'Processes' node.
+        @param filepath is the selected 'Sources' or 'Processes' node.
         @param highlighted_source is the highlighted 'Sources' node that
         is being used for the current process.
         @param ext is the extension of the selected file.
@@ -450,7 +508,7 @@ class Utils:
         if ext != None:
             if ext == 'sch' or ext == 'sym':
                 if g.tools['sch'] == None or g.tools['sch'].poll() == 0:
-                    g.tools['sch'] = Popen(['gschem', selected_node], stdin=PIPE)
+                    g.tools['sch'] = Popen(['gschem', filepath], stdin=PIPE)
                 elif g.tools['sch'].poll() == None: # Process is still running
 ##                     pcb_instances = self.dbus_iface.ListQueuedOwners('org.seul.geda.gschem')
 ##                     for pcb in pcb_instances:
@@ -461,7 +519,7 @@ class Utils:
 ##                     self.pcb_actions_iface.ExecAction('Quit', self.empty_char_array)
                     # Let's try to open a file
                     try:
-                        st = os.stat(selected_node)
+                        st = os.stat(filepath)
                     except IOError:
                         print 'IOError'
                     else:
@@ -469,7 +527,7 @@ class Utils:
                         print 'file modified:', st[ST_MTIME]
             elif ext == 'pcb':
                 if g.tools['pcb'] == None or g.tools['pcb'].poll() == 0:
-                    g.tools['pcb'] = Popen(['pcb', selected_node])
+                    g.tools['pcb'] = Popen(['pcb', filepath])
                 elif g.tools['pcb'].poll() == None: # Process is still running
                     pcb_instances = self.dbus_iface.ListQueuedOwners('org.seul.geda.pcb')
                     for pcb in pcb_instances:
@@ -479,13 +537,13 @@ class Utils:
                     self.pcb_actions_iface.ExecAction('Quit', self.empty_char_array)
             elif ext == 'gbr':
                 if g.tools['gerbv'] == None or g.tools['gerbv'].poll() == 0:
-                    g.tools['gerbv'] = Popen(['gerbv', selected_node])
+                    g.tools['gerbv'] = Popen(['gerbv', filepath])
                 elif g.tools['gerbv'].poll() == None: # Process is still running
                     pass
             elif ext in files 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, selected_node])
+                    g.tools['editor'] = Popen([g.settings.editor, filepath])
                 elif g.tools['editor'].poll() == None: # Process is still running
                     pass
             elif g.settings.editor == None:
@@ -500,36 +558,39 @@ class Utils:
                 dialog.destroy()
 
         else: # Processes
+            # The filepath in this case is actually the program to run
+            # so we will make the substitution to make it clearer
+            
             # Call the function for the row that was double clicked
             # Need to figure out if the program to run will produce files
             # and whether or not it is currently running (GUI only)
 
-
             # Netlists
-            if selected_node in self.netlists: # use gnetlist
-                if selected_node == 'gnetlist':
+            program = filepath
+            if program in self.netlists: # use gnetlist
+                if program == 'gnetlist':
                     return
-                arg = '-v -g ' + selected_node + ' ' + highlighted_source
+                arg = '-v -g ' + program + ' ' + highlighted_source
                 subproc = Popen(['gnetlist', arg])
-            elif selected_node == 'ghdl-compile':
+            elif program == 'ghdl-compile':
                 pass
-            elif selected_node == 'ghdl-compile->gtkwave-simulate':
+            elif program == 'ghdl-compile->gtkwave-simulate':
                 pass
-            elif selected_node == 'icarus-compile':
+            elif program == 'icarus-compile':
                 pass
-            elif selected_node == 'icarus-compile->gtkwave-simulate':
-                #subproc = Popen([selected_node, highlighted_source])
+            elif program == 'icarus-compile->gtkwave-simulate':
+                #subproc = Popen([program, highlighted_source])
                 pass
-            elif selected_node == 'gattrib':
+            elif program == 'gattrib':
                 if g.tools['gattrib'] == None or g.tools['gattrib'].poll() == 0:
-                    g.tools['gattrib'] = Popen([selected_node, highlighted_source])
+                    g.tools['gattrib'] = Popen([program, highlighted_source])
                 elif g.tools['gattrib'].poll() == None: # Process is still running
                     pass
-            elif selected_node == 'gsymcheck':
+            elif program == 'gsymcheck':
                 arg = '-v ' + highlighted_source
-                subproc = Popen([selected_node, arg])
+                subproc = Popen([program, arg])
             else:
-                subproc = Popen([selected_node, highlighted_source])
+                subproc = Popen([program, highlighted_source])
                 
 
 
@@ -548,12 +609,14 @@ class Utils:
     def add_to_dependency_dict(self, gedamanager, filename):
         """!
         Method to add a file to the project's dependency_dict.
-        @param gedamanager is the current gEDAManager instance.
-        @param filename is the name of the file to add to the dependency_dict.
+        @param gedamanager: The current gEDAManager instance
+        @type gedamanager: gEDAManager
+        @param filename: filename is the name of the file to add to project.dependency_dict
+        @type filename: string
         """
         g = gedamanager
         # add file to the dependency_dict
         if filename not in g.project.dependency_dict:
             g.project.dependency_dict[filename] = []
-            print g.project.dependency_dict
+            print 'g.project.dependency_dict:', g.project.dependency_dict
 




_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs