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

gEDA-cvs: geda_manager.git: branch: master updated (5f84798d93c9d617f91bf0de6486d033e984490c)



The branch, master has been updated
       via  5f84798d93c9d617f91bf0de6486d033e984490c (commit)
      from  6a65dad7a28d60377548009e3e0f7f11733ebd11 (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            |   68 +++++++++++++++++----------------
 src/processdependencyevent.py |   12 +++--
 src/utils.py                  |   86 +++++++++++++++++-----------------------
 3 files changed, 79 insertions(+), 87 deletions(-)


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

commit 5f84798d93c9d617f91bf0de6486d033e984490c
Author: Newell Jensen <jensen@xxxxxxxxxxxxxxx>
Date:   Thu Aug 21 22:18:28 2008 -0700

    Routine checkin.  Trying to get this done.

:100644 100644 8dee2d4... 23d9721... M	src/gedamanager.py
:100644 100644 dc4d542... 95ddb90... M	src/processdependencyevent.py
:100644 100644 6e35fac... 1e846b3... M	src/utils.py

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

commit 5f84798d93c9d617f91bf0de6486d033e984490c
Author: Newell Jensen <jensen@xxxxxxxxxxxxxxx>
Date:   Thu Aug 21 22:18:28 2008 -0700

    Routine checkin.  Trying to get this done.

diff --git a/src/gedamanager.py b/src/gedamanager.py
index 8dee2d4..23d9721 100644
--- a/src/gedamanager.py
+++ b/src/gedamanager.py
@@ -45,6 +45,7 @@ class gEDAManager:
        # Initialize gEDA Manager
         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()        
         if self.settings.project != None:
             self.project = Project(self.settings.project)
         else:
@@ -54,8 +55,9 @@ class gEDAManager:
         self.project.connect('opened', self.cb_project_opened)
         self.project.connect('created', self.cb_project_created)
         # Set up the project's dependency dictionary
-        self.project.dependency_dict = {}
-        self.utils = Utils()
+        if self.project.dependency_dict == None:
+            print 'project dependency_dict is null'
+            self.project.dependency_dict = {}
         gtk.gdk.threads_init()
         gtk.gdk.threads_enter()
         self.dependencyloop = DependencyLoop(self)
@@ -692,7 +694,7 @@ class gEDAManager:
         @param menuitem that threw the event.
         @param data optional to pass in.
         """
-        self.output_textbuffer.insert(self.output_textiter, self.utils.get_time() + ':\n' + 'Exiting gEDA Manager.\n')        
+        self.output_textbuffer.insert(self.output_textiter, self.utils.get_time() + ':\n' + 'Exiting gEDA Manager.\n')
         self.project.save()
         self.save_settings()
         self.write_logs()
@@ -931,7 +933,7 @@ class gEDAManager:
         dialog.destroy()
 
 
-    @exceptions
+    #@exceptions
     def cb_add_copy_dependency(self, menuitem, data=None):
         """!
         Event occurs when the user wants to add a source to the project
@@ -975,48 +977,48 @@ class gEDAManager:
         response = dialog.run()
         if response == gtk.RESPONSE_OK:
             directory = filebutton.get_filename()
-            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
                 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(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.
+#                quit = True
                 for row in self.sources:
-                    # Get the filename of the node
+                    # Get the gtk.TreeIter for the directory 
                     if row[2] == directory:
-                        print 'holy shit!!!'
-                        row_iter = row.iterchildren() # This will be True for the root
+                        row_iter = row.iter
+                        # Add the new folder to project file list
+                        self.utils.update_file_list(self)
+                        break
                 if row_iter == None:
-                    self.errors_textbuffer.insert(self.errors_textiter, directory + " is not present in the project's directory structure.\n")
+                    self.errors_textbuffer.insert(self.errors_textiter, self.utils.get_time() + ':\n' + directory + " is not present in the project's directory structure.\nWhen adding a dependency the target directory must be in the project.\n")
+                    dialog.destroy()
                     return
-                
-                # Copy the filepath to the chosen directory
-                # Also update the sources with the proper node
-                files = os.listdir(directory)
-                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' + filename + ' is already present in the directory - ' + directory + '.\n')
-                # Add the new file as a dependency for the selected 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))                
+                    # Copy the filepath to the chosen directory
+                    # Also update the sources with the proper node
+                    files = os.listdir(directory)
+                    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' + filename + ' is already present in the directory - ' + directory + '.\n')
+                    # add new file to the dependency_dict                
+                    self.utils.add_to_dependency_dict(self, filename)
+                    # Add the new file as a dependency for the selected file
+                    # and make sure that it is in the dependency_dict
+                    parent_file = self.utils.get_node_name(selected_node)
+                    self.utils.add_to_dependency_dict(self, parent_file)                
+                    self.project.dependency_dict[parent_file].append((True, filename))
+                    self.utils.update_file_list(self)
 
         dialog.destroy()
         
@@ -1294,12 +1296,12 @@ class gEDAManager:
         Event handlder when the form is closed in any fashion.
         @param event that was thrown.
         """
-        self.output_textbuffer.insert(self.output_textiter, self.utils.get_time() + ':\nExiting gEDA Manager.\n')        
+        self.output_textbuffer.insert(self.output_textiter, self.utils.get_time() + ':\nExiting gEDA Manager.\n')
         self.project.save()
         self.save_settings()
         self.write_logs()
         self.kill_processes()
-        self.dependencyloop.kill_thread()        
+        self.dependencyloop.kill_thread()
 
 
     ########################################################
diff --git a/src/processdependencyevent.py b/src/processdependencyevent.py
index dc4d542..95ddb90 100644
--- a/src/processdependencyevent.py
+++ b/src/processdependencyevent.py
@@ -41,7 +41,7 @@ class ProcessDependencyEvent(ProcessEvent):
         """
         self.g = gedamanager
 
-        
+
     def process_IN_MODIFY(self, event):
         """!
         Method to process the IN_MODIFY event from the pyinotify module
@@ -49,8 +49,10 @@ class ProcessDependencyEvent(ProcessEvent):
         project's filesystem.
         """
         # Call method to set the status of the dependent files recursively
-        name = self.g.utils.get_node_name(event.pathname)
-        print 'name process_IN_MODIFY:',name
-        if name in self.g.project.dependency_dict:
-            self.g.utils.update_dependency_dict(self.g.project.dependency_dict[name])
+        filename = self.g.utils.get_node_name(event.pathname)
+        print 'filename in process catcher:',filename
+        print 'dependency_dict in process catcher:',self.g.project.dependency_dict
+        if filename in self.g.project.dependency_dict:
+            self.g.utils.update_dependency_dict(self.g, filename)
+            print 'catching event'
 
diff --git a/src/utils.py b/src/utils.py
index 6e35fac..1e846b3 100644
--- a/src/utils.py
+++ b/src/utils.py
@@ -129,11 +129,14 @@ class Utils:
         """ Method returns a string of the current time. """
         return time.asctime(time.localtime(time.time()))
 
+
     def get_node_name(self, path):
         """!
-        Method to return the node name from the path.
-        @param path to the node.
-        @return name of the node without an extension.
+        Method to return the node name from the path
+        @param path: path to the node
+        @type path: string
+        @return filename: name of the node without an extension
+        @type filename: string
         """
         if '/' in path:
             return path.split('/')[-1]
@@ -158,37 +161,28 @@ class Utils:
     def get_status_image(self, gedamanager, selected_node, process_ext):
         """!
         Method to get the status image for the process.
-        @param gedamanager is the current gEDAManager instance.
-        @param selected_node is the currently selected node in the 'Sources' tree view.
-        @param process_ext is the type of file that is having its status set (updated/outdated)
-        @return an IconTheme image from the self.icon_lut structure.
+        @param gedamanager: current gEDAManager instance
+        @type gedamanager: gEDAManager
+        @param selected_node: currently selected node in the 'Sources' tree view.
+        @type selected_node: string
+        @param process_ext: type of file that is having its status set (updated/outdated)
+        @type process_ext: string
+        @return icon: icon from the self.icon_lut structure
+        @type icon: gtk.IconTheme
         """
         g = gedamanager
-        name = self.get_node_name(selected_node)
+        filename = self.get_node_name(selected_node)
         icon = gtk.IconTheme()        
-        if name in g.project.dependency_dict:
-            dependent_files = g.project.dependency_dict[name]
-            for tup in dependent_files:
+        if filename in g.project.dependency_dict:
+            for tup in g.project.dependency_dict[filename]:
                 if tup[0] and tup[1].endswith(process_ext):
+                    print tup[1], ' is updated'
                     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)
                     
 
     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):
@@ -196,22 +190,6 @@ class Utils:
             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, filepath=None):
@@ -595,16 +573,27 @@ class Utils:
 
 
     @exceptions
-    def update_dependency_dict(self, dependent_list):
+    def update_dependency_dict(self, gedamanager, filename):
         """!
-        Method to update the dependencies for filename.
-        @param dependent_list is the list of files to iterate over.
+        Method to update the dependencies for filename
+        @param gedamanager: current gEDAManager instance
+        @type gedamanager: gEDAManager
+        @param filename: file that will have its dependencies updated
+        @type filename: string
         """
-        # Iterate over the list
-        for f in dependent_list:
-            # Call the method to make the action that updates the icon
-            print 'update_dependency_dict since a file in the dependency_dict was written'
-
+        # We just need to create a new list and set that as the value
+        print 'UPDATING'
+        new_list = []
+        for tup in gedamanager.project.dependency_dict[filename]:
+            print tup, ' for updating tup'
+            tup[0] = False
+            new_list.append(tup)
+        # Now set the new_list as the value for filename
+        print 'new_list:', new_list
+        gedamanager.project.dependency_dict[filename] = new_list
+        # Update the project by saving it
+        gedamanager.project.save()
+            
         
     def add_to_dependency_dict(self, gedamanager, filename):
         """!
@@ -618,5 +607,4 @@ class Utils:
         # add file to the dependency_dict
         if filename not in g.project.dependency_dict:
             g.project.dependency_dict[filename] = []
-            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