[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: geda_manager.git: branch: master updated (986e3d5ef078297f21398afe3d3c92beb49db37f)
The branch, master has been updated
via 986e3d5ef078297f21398afe3d3c92beb49db37f (commit)
from d18caabe27ee87e9a4d783e07af49e27c75ecfec (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 | 4 +-
src/gedamanager.py | 282 ++++++++++++++++++++++++----------------
src/newproject.py | 20 ++--
src/processdependencyevent.py | 30 ++++-
src/project.py | 35 +++---
src/utils.py | 121 ++++++------------
6 files changed, 265 insertions(+), 227 deletions(-)
=================
Commit Messages
=================
commit 986e3d5ef078297f21398afe3d3c92beb49db37f
Author: Newell Jensen <jensen@xxxxxxxxxxxxxxxx>
Date: Sun Dec 14 21:54:04 2008 -0800
Started work on getting the dependency tree sorted out.
Added some other support to the pyinotify thread to handle
the dependencies. Fixed some minor bugs and polished up code.
:100644 100644 2525a1c... 8488883... M src/dependencyloop.py
:100644 100644 d6b7d91... a316753... M src/gedamanager.py
:100644 100644 14352c7... 532d0d5... M src/newproject.py
:100644 100644 a926e57... 2badf5b... M src/processdependencyevent.py
:100644 100644 0225b3b... d1810c6... M src/project.py
:100644 100644 8c1ec60... 541d0d2... M src/utils.py
=========
Changes
=========
commit 986e3d5ef078297f21398afe3d3c92beb49db37f
Author: Newell Jensen <jensen@xxxxxxxxxxxxxxxx>
Date: Sun Dec 14 21:54:04 2008 -0800
Started work on getting the dependency tree sorted out.
Added some other support to the pyinotify thread to handle
the dependencies. Fixed some minor bugs and polished up code.
diff --git a/src/dependencyloop.py b/src/dependencyloop.py
index 2525a1c..8488883 100644
--- a/src/dependencyloop.py
+++ b/src/dependencyloop.py
@@ -51,7 +51,7 @@ class DependencyLoop:
self.threaded_notifier.start()
# start watching the project's directory recursively
self.wdd = None
- mask = IN_MODIFY | IN_CREATE | IN_DELETE | IN_MOVED_FROM
+ mask = IN_MODIFY | IN_CREATE | IN_DELETE | IN_MOVED_FROM | IN_MOVED_TO
if self.g.project.directory != None:
self.wdd = self.watch_manager.add_watch(self.g.project.directory, mask, rec=True)
@@ -65,7 +65,7 @@ class DependencyLoop:
if self.wdd != None:
self.watch_manager.rm_watch(self.wdd.values())
# Now add a new watch to the new project
- mask = IN_MODIFY | IN_CREATE | IN_DELETE | IN_MOVED_FROM
+ mask = IN_MODIFY | IN_CREATE | IN_DELETE | IN_MOVED_FROM | IN_MOVED_TO
if self.g.project.directory != None:
self.wdd = self.watch_manager.add_watch(self.g.project.directory, mask, rec=True)
diff --git a/src/gedamanager.py b/src/gedamanager.py
index d6b7d91..a316753 100644
--- a/src/gedamanager.py
+++ b/src/gedamanager.py
@@ -46,7 +46,7 @@ class gEDAManager:
""" gEDAManager Constructor. """
# Initialize gEDA Manager
- self.depnum = 0
+# 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()
@@ -247,6 +247,7 @@ class gEDAManager:
# Dependencies Tree View
self.dependencies_tree = gtk.TreeView(self.dependencies)
self.dependencies_tree.show()
+ self.dependencies.connect('row-changed', self.cb_row_changed)
# create the TreeViewColumn to display the data
column = gtk.TreeViewColumn('Files')
@@ -259,7 +260,7 @@ class gEDAManager:
column.set_sort_column_id(0)
self.dependencies_tree.append_column(column)
- # set some properties
+ # enable-tree-lines
self.sources_tree.set_property('enable-tree-lines', True)
self.processes_tree.set_property('enable-tree-lines', True)
self.dependencies_tree.set_property('enable-tree-lines', True)
@@ -271,8 +272,13 @@ class gEDAManager:
# Allow drag and drop reordering of rows
self.dependencies_tree.set_reorderable(True)
+ self.sources_tree.set_reorderable(True)
- # add the scrolling windows
+ # set tooltip columns
+ self.sources_tree.set_tooltip_column(2)
+ self.dependencies_tree.set_tooltip_column(1)
+
+ # add to the scrolling windows
scrolled_window_sources.add(self.sources_tree)
scrolled_window_processes.add(self.processes_tree)
scrolled_window_dependencies.add(self.dependencies_tree)
@@ -441,24 +447,20 @@ class gEDAManager:
self.sources.clear()
if self.project.name != None:
self.load_sources_tree()
- self.sources_tree.expand_all()
+ self.sources_tree.expand_all()
def set_dependencies_tree_to_project(self):
""" Method to set the tree to current project object. """
self.dependencies.clear()
- if self.project.dependency_dict != None:
- self.depnum = 0
- self.load_dependencies_tree(self.project.dependency_dict)
+ if self.project.dependency_list != None:
+ self.load_dependencies_tree()
self.dependencies_tree.expand_all()
- # Connect to the 'columns-changed' signal
- self.dependencies.connect('row-changed', self.cb_row_changed)
-
def set_dependencies_tree_to_new_project(self):
""" Method to set the tree to newly created project object. """
- self.dependencyloop.switch_projects()
+ #self.dependencyloop.switch_projects()
self.dependencies.clear()
# Parent Folder
project_path = self.project.directory + '/' + self.project.name
@@ -466,9 +468,6 @@ class gEDAManager:
output_file_path = self.project.directory + '/output.log'
error_file_path = self.project.directory + '/error.log'
- # Connect to the 'columns-changed' signal
- self.dependencies.connect('row-changed', self.cb_row_changed)
-
def load_sources_tree(self):
"""
@@ -479,59 +478,116 @@ class gEDAManager:
# Clear out the sources first
self.sources.clear()
# Start adding data to the Model
- if os.path.exists(self.project.directory):
- os.chdir(self.project.directory)
- node = None
- dictionary = {}
- icon = gtk.IconTheme() # The icon used throughout the function
- for root, dirs, files in os.walk(self.project.directory):
- if root == self.project.directory:
- image = icon.load_icon(self.utils.icon_lut['project'], 22, 0)
- else:
- image = icon.load_icon(self.utils.icon_lut['folder'], 22, 0)
+ if isinstance(self.project.directory, str):
+ if os.path.exists(self.project.directory):
+ os.chdir(self.project.directory)
+ node = None
+ dictionary = {}
+ icon = gtk.IconTheme() # The icon used throughout the function
+ for root, dirs, files in os.walk(self.project.directory):
+ if root == self.project.directory:
+ image = icon.load_icon(self.utils.icon_lut['project'], 22, 0)
+ else:
+ image = icon.load_icon(self.utils.icon_lut['folder'], 22, 0)
- folder = root.split('/')[-1]
- try:
- node = self.sources.append(dictionary[root], [image, folder, root])
-# node = self.sources.append(None, [image, folder, root])
- except KeyError:
- node = self.sources.append(None, [image, folder, root])
- for f in [name for dec,name in sorted((os.path.splitext(f)[1][1:],f) for f in files)]: # List expression sorts by file extension
- if not f.endswith(('~','-','#')):
- image = icon.load_icon(self.utils.load_image(f), 22, 0)
- self.sources.append(node, [image, f, os.path.join(root, f)])
- for d in dirs:
- dictionary[os.path.join(root, d)] = node
+ folder = root.split('/')[-1]
+ try:
+ node = self.sources.append(dictionary[root], [image, folder, root])
+ except KeyError:
+ node = self.sources.append(None, [image, folder, root])
+ for f in [name for dec,name in sorted((os.path.splitext(f)[1][1:],f) for f in files)]: # List expression sorts by file extension
+ if not f.endswith(('~','-','#')):
+ image = icon.load_icon(self.utils.load_image(f), 22, 0)
+ self.sources.append(node, [image, f, os.path.join(root, f)])
+ for d in dirs:
+ dictionary[os.path.join(root, d)] = node
- self.sources_tree.expand_all()
+ self.sources_tree.expand_all()
- def load_dependencies_tree(self, dep_dict, parent=None, parent_path=None, number=None):
+ def load_dependencies_tree(self):
"""!
Method to the load the dependencies tree
- @param dependency_dict project's dependency dictionary
- @param parent node to help setup the gtk.TreeView object
- @param parent_path parameter to help in writing the paths
- to the self.sources gtk.TreeStore object
"""
- for key, value in dep_dict.iteritems():
- # filepath
- if parent_path != None:
- filepath = parent_path + '/' + key
- else:
- filepath = self.project.directory + '/' + key
- # parent
- if parent != None:
- n_parent = self.dependencies.append(parent, [key, filepath])
- self.depnum += 1
- else:
- n_parent = self.dependencies.append(None, [key, filepath])
- self.depnum += 1
- # recurse
- if isinstance(value, dict):
- self.load_dependencies_tree(value, n_parent, filepath, self.depnum)
-
+ # Need to add checking for whether or not the filesystem still
+ # has the files before appending them to self.dependencies
+
+ # Either this or have a function that I call before this one that
+ # straightens it all out by going over the dependency_list and making
+ # sure that these files are the correct ones and if not it can call
+ # the functions remove/add/update_dependency() functions
+ def recurse_dependencies(dep_list, parent):
+ for value in dep_list:
+ filename = self.utils.get_filename_from_filepath(value)
+ n_parent = self.dependenices.append(parent, [filename, value])
+ # recurse
+ if self.project.dependency_list[value] != []:
+ recurse_dependencies(self.project.dependency_list[value], n_parent)
+
+ if self.dependencies != None:
+ self.dependencies.clear()
+ for key, value in self.project.dependency_list.iteritems():
+ filename = self.utils.get_filename_from_filepath(key)
+ n_parent = self.dependencies.append(None, [filename, key])
+ # recurse
+ if self.project.dependency_list[key] != []:
+ recurse_dependencies(value, n_parent)
+
+
+ def update_dependency(self, pathname, recurse=False):
+ # First, make sure that the file is already in the dependencies
+ if self.project.dependency_status != None:
+ try:
+ if not recurse:
+ self.project.dependency_status[pathname] = True
+ else:
+ self.project.dependency_status[pathname] = False
+ # recurse over the dependency_list
+ if self.project.dependency_list != None:
+ for value in self.project.dependency_list[pathname]:
+ self.update_dependency(value, True)
+ except KeyError:
+ print 'KeyError_update'
+ finally:
+ self.project.save()
+ self.load_dependencies_tree()
+
+
+ def add_dependency(self, pathname):
+ print 'in add_dependency'
+ try:
+ if self.project.dependency_list != None:
+ self.project.dependency_list[pathname] = []
+ if self.project.dependency_status != None:
+ self.project.dependency_status[pathname] = True
+ except KeyError:
+ print 'KeyError_add'
+ finally:
+ self.project.save()
+ self.load_dependencies_tree()
+
+
+ def remove_dependency(self, pathname, recurse=False):
+ # First, make sure that the file is already in the dependencies
+ if self.project.dependency_status != None:
+ if pathname in self.project.dependency_status:
+ try:
+ # iterate over the dependencies and flatten
+ for value in self.project.dependency_list[pathname]:
+ self.remove_dependency(value, True)
+ self.project.dependency_list[pathname] = []
+ except KeyError:
+ print 'KeyError_remove'
+ finally:
+ if not recurse:
+ del self.project.dependency_status[pathname]
+ del self.project.dependency_list[pathname]
+ else:
+ self.project.dependency_status[pathname] = False
+ self.project.save()
+ self.load_dependencies_tree()
+
def save_settings(self):
""" Method to save current settings to .gmrc file. """
@@ -542,7 +598,6 @@ class gEDAManager:
self.settings.create_config_file()
-
def get_processes_selected_node(self):
"""!
Method to get the selected node in the 'Processes' treeview.
@@ -749,6 +804,8 @@ class gEDAManager:
self.write_logs()
self.project.save()
self.project.close()
+ # clear the processes window
+ self.processes.clear()
def cb_project_closed(self, widget, event):
@@ -799,6 +856,7 @@ class gEDAManager:
self.set_sources_tree_to_project()
self.set_dependencies_tree_to_new_project()
+
@exceptions
def cb_preferences(self, menuitem, data=None):
"""!
@@ -953,7 +1011,7 @@ class gEDAManager:
# 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.update_file_list(self, 1, filepath)
self.utils.run_command(self, filepath, None, ext)
else:
dialog = gtk.MessageDialog(self.window,
@@ -1028,15 +1086,17 @@ class gEDAManager:
if response == gtk.RESPONSE_OK and text.strip() != '':
filepath = selected_node + '/' + text
- def delete_dependency_dict_entry(arg, dirname, filenames):
- """ function to delete the filenames from the dependency_dict """
+ def delete_dependency_list_entry(arg, dirname, filenames):
+ """ function to delete the filenames from the dependency_list """
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]
+ print 'looking to delete dependency'
+ if f in self.project.dependency_list and list(self.utils.flatten(self.project.file_list)).count(f) == 1:
+ print 'deleting dependency'
+ del self.project.dependency_list[f]
# See if this directory already exists
if os.path.exists(filepath): # delete directory recursively
- os.path.walk(filepath, delete_dependency_dict_entry, None)
+ os.path.walk(filepath, delete_dependency_list_entry, None)
shutil.rmtree(filepath)
flag = True
i = 0
@@ -1052,58 +1112,40 @@ class gEDAManager:
break
i = i + 1
os.mkdir(filepath)
-# self.load_sources_tree()
dialog.destroy()
@exceptions
def cb_delete(self, menuitem, data=None):
"""!
- Event handler for 'Delete'.
+ Event handler for 'Delete'. This method will delete the file from the
+ filesystem.
@param menuitem that threw the event.
@param data optional to pass in.
"""
- # Have a popup come up that asks them if they really want to do this
- # or not.
- # Just delete the file from the directory structure
selection = self.sources_tree.get_selection()
model, selection_iter = selection.get_selected()
if isinstance(selection_iter, gtk.TreeIter):
selected_node = self.sources.get_value(selection_iter, 2)
os.system('rm ' + selected_node)
self.output_textbuffer.insert(self.output_textiter, self.utils.get_time() + ':\nDeleted ' + selected_node + '.\n')
- # TODO
- # Commented out till I know what I am doing with the dependencies
- ## node = self.utils.get_filename_from_filepath(selected_node)
- ## if node in self.project.dependency_dict and list(self.utils.flatten(self.project.file_list)).count(node) == 1:
- ## del self.project.dependency_dict[node]
@exceptions
def cb_delete_folder(self, widget):
"""!
Event occurs when the user chooses to delete a folder from the project.
+ This method will delete the folder from the filesystem.
@param widget that threw the event.
"""
- # Just delete the folder from the directory structure
- # Have a popup come up that asks them if they really want to do
- # this or not.
selection = self.sources_tree.get_selection()
model, selection_iter = selection.get_selected()
if isinstance(selection_iter, gtk.TreeIter):
selected_node = self.sources.get_value(selection_iter, 2)
exists = os.path.exists(selected_node)
if exists: # delete directory recursively
- # TODO
- # The commented out section here is for the dependency tree
- # Until I get other things working better I will have this commented
- # out
- ## for f in os.listdir(selected_node):
- ## 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]
os.system('rm -rf ' + selected_node)
self.output_textbuffer.insert(self.output_textiter, self.utils.get_time() + ':\nDeleted ' + selected_node + '.\n')
-# self.load_sources_tree()
@exceptions
@@ -1159,20 +1201,13 @@ class gEDAManager:
if old_path == self.project.directory:
# Project Folder
os.rename(old_path, new_path)
- model[path][1] = new_text
- model[path][2] = new_path
project_file = new_path + '/' + self.project.name + '.gm'
os.remove(project_file)
self.project.directory = new_path
self.project.name = new_text
- self.project.file_list[0] = new_text
- self.project.file_list[1][0] = new_text + '.gm'
+ ## self.project.file_list[0] = new_text
+ ## self.project.file_list[1][0] = new_text + '.gm'
self.project.save()
-
- model[(0)][1] = new_text
- model[(0)][2] = new_path + '/' + new_text
- model[(0,0)][1] = new_text + '.gm'
- model[(0,0)][2] = new_path + '/' + new_text + '.gm'
self.output_textbuffer.insert(self.output_textiter, 'Project changed from ' + old_path + ' to ' + new_path + '.\n')
else:
# Regular folder
@@ -1260,24 +1295,42 @@ class gEDAManager:
self.processes.clear()
- @exceptions
- def cb_row_changed(self, model, path, _iter):
+ def cb_row_changed(self, model, path, iter):
"""!
Event occurs when the columns change in the dependencies treeview.
- @param widget widget that threw the event
+ @param model gtk.TreeStore model for the dependencies
"""
- if len(self.dependencies) <= self.depnum:
- # Iterate over the whole tree and create the project.depedency_dict
- for i, row in enumerate(self.dependencies):
- if i < self.depnum:
- for r in row:
- row_iter = row.iterchildren()
- try:
- for z in row_iter.next():
- pass
- except:
- pass
- # Need to update the dependency_dict -- put here
+ print 'starting cb_row_changed'
+ # We only want a file to appear once
+ def recurse_model(row_iter, row):
+ try:
+ for new_row in row_iter:
+ if new_row[1] not in files:
+ # new_dep_list[new_row[1]] = []
+ new_dep_list[row[1]].append(new_row[1])
+ files.append(new_row[1])
+ new_row_iter = new_row.iterchildren()
+ if new_row_iter != None:
+ recurse_model(new_row_iter, new_row)
+ except StopIteration:
+ print 'StopIteraion'
+ except:
+ print 'except:', sys.exc_info()[0]
+
+ files = []
+ new_dep_list = {}
+ for row in model:
+ if row[1] not in files:
+ new_dep_list[row[1]] = []
+ files.append(row[1])
+ row_iter = row.iterchildren()
+ if row_iter != None:
+ recurse_model(row_iter, row)
+
+
+ print 'files:',files
+ print 'new_dep_list:',new_dep_list
+ self.project.dependency_list = new_dep_list
@exceptions
@@ -1364,7 +1417,8 @@ class gEDAManager:
"""
self.dependencyloop.kill_thread()
self.output_textbuffer.insert(self.output_textiter, self.utils.get_time() + ':\nExiting gEDA Manager.\n')
- self.write_logs()
+ self.write_logs()
+ self.dependencies.emit('row-changed', None, None)
self.project.save()
self.save_settings()
self.kill_processes()
@@ -1378,6 +1432,7 @@ class gEDAManager:
self.dependencyloop.kill_thread()
self.output_textbuffer.insert(self.output_textiter, self.utils.get_time() + ':\nExiting gEDA Manager.\n')
self.write_logs()
+ self.dependencies.emit('row-changed', None, None)
self.project.save()
self.save_settings()
self.kill_processes()
@@ -1391,7 +1446,8 @@ class gEDAManager:
"""
self.dependencyloop.kill_thread()
self.output_textbuffer.insert(self.output_textiter, self.utils.get_time() + ':\nExiting gEDA Manager.\n')
- self.write_logs()
+ self.write_logs()
+ self.dependencies.emit('row-changed', None, None)
self.project.save()
self.save_settings()
self.kill_processes()
diff --git a/src/newproject.py b/src/newproject.py
index 14352c7..532d0d5 100644
--- a/src/newproject.py
+++ b/src/newproject.py
@@ -38,8 +38,7 @@ class NewProject:
@param gedamanager gEDAManager object that the new project is
called from
"""
- self.project = gedamanager.project
- self.manager = gedamanager
+ self.gedamanager = gedamanager
self.assistant = gtk.Assistant()
self.assistant.connect('close', self.cb_close)
self.assistant.connect('apply', self.cb_apply)
@@ -282,16 +281,17 @@ class NewProject:
"""
try:
# 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.file_list = [self.project.name, [self.project.name + '.gm', 'output.log', 'error.log']]
+ self.gedamanager.project.name = self.get_filename().split('.')[0]
+ self.gedamanager.project.directory = self.get_path() + '/' + self.gedamanager.project.name.split('.')[0]
+ self.gedamanager.project.dependency_list = {}
+ self.gedamanager.project.dependency_status = {}
# Remove directories with imported remove_tree
if self.confirm_overwrite.get_active():
- shutil.rmtree(self.project.directory)
+ shutil.rmtree(self.gedamanager.project.directory)
- os.mkdir(self.project.directory)
- self.project.create()
+ os.mkdir(self.gedamanager.project.directory)
+ self.gedamanager.project.create()
+ self.gedamanager.dependencyloop.switch_projects()
except IOError, (errno, strerror):
md = gtk.MessageDialog(self.assistant,
(gtk.DIALOG_MODAL |
@@ -305,7 +305,7 @@ class NewProject:
md.hide_all()
return
except:
- self.manager.errors_textbuffer.insert(g.errors_textiter, 'Unexpected error: ' + str(sys.exc_info()[0]) + '.\n')
+ self.gedamanager.errors_textbuffer.insert(g.errors_textiter, 'Unexpected error: ' + str(sys.exc_info()[0]) + '.\n')
md = gtk.MessageDialog(self.assistant,
(gtk.DIALOG_MODAL |
gtk.DIALOG_DESTROY_WITH_PARENT),
diff --git a/src/processdependencyevent.py b/src/processdependencyevent.py
index a926e57..2badf5b 100644
--- a/src/processdependencyevent.py
+++ b/src/processdependencyevent.py
@@ -46,9 +46,21 @@ class ProcessDependencyEvent(ProcessEvent):
@param event current event that was caught for the section of
filesystem under watch
"""
- filename = self.g.utils.get_filename_from_filepath(event.pathname)
self.g.load_sources_tree()
- self.g.dependencyloop.switch_projects()
+ # file extensions that should be ignored
+ if not event.pathname.endswith(('-','~','#','.save','.log','.gm')):
+ print event.maskname
+ print event.pathname
+ if event.maskname == 'IN_MODIFY':
+ self.g.update_dependency(event.pathname)
+ elif event.maskname == 'IN_DELETE':
+ self.g.remove_dependency(event.pathname)
+ elif event.maskname == 'IN_CREATE':
+ self.g.add_dependency(event.pathname)
+ elif event.maskname == 'IN_MOVED_FROM':
+ self.g.remove_dependency(event.pathname)
+ elif event.maskname == 'IN_MOVED_TO':
+ self.g.add_dependency(event.pathname)
def process_IN_MODIFY(self, event):
@@ -66,7 +78,7 @@ class ProcessDependencyEvent(ProcessEvent):
@param event current IN_DELETE event that was caught for the section of
filesystem under watch
"""
- gobject.idle_add(self.cb_main_thread, event)
+ gobject.idle_add(self.cb_main_thread, event)
def process_IN_CREATE(self, event):
@@ -75,7 +87,7 @@ class ProcessDependencyEvent(ProcessEvent):
@param event current IN_CREATE event that was caught for the section of
filesystem under watch
"""
- gobject.idle_add(self.cb_main_thread, event)
+ gobject.idle_add(self.cb_main_thread, event)
def process_IN_MOVED_FROM(self, event):
@@ -84,9 +96,17 @@ class ProcessDependencyEvent(ProcessEvent):
@param event current IN_MOVED_FROM event that was caught for the
section of filesystem under watch
"""
- gobject.idle_add(self.cb_main_thread, event)
+ gobject.idle_add(self.cb_main_thread, event)
+ def process_IN_MOVED_TO(self, event):
+ """!
+ Method to process the IN_MOVED_FROM event from the pyinotify module.
+ @param event current IN_MOVED_FROM event that was caught for the
+ section of filesystem under watch
+ """
+ gobject.idle_add(self.cb_main_thread, event)
+
diff --git a/src/project.py b/src/project.py
index 0225b3b..d1810c6 100644
--- a/src/project.py
+++ b/src/project.py
@@ -28,11 +28,11 @@ pygtk.require('2.0')
class Project(gobject.GObject):
"""
- Project class.
- This object has:
- -- name
- -- directory
- -- file_list (list paths to files)
+ The Project class contains
+ -- name (name of the project)
+ -- directory (root directory of the project)
+ -- dependency_list (dictionary of files and their dependencies)
+ -- dependnecy_status (dictionary of files and their updated/outdated status)
"""
__gsignals__ = {'closed': (gobject.SIGNAL_NO_RECURSE,
gobject.TYPE_NONE,
@@ -72,17 +72,17 @@ class Project(gobject.GObject):
# parse the config object and get list of apps
stream = file(filepath, 'r')
for data in yaml.load_all(stream):
- #self.file_list = data['file_list']
- self.dependency_dict = data['dependency_dict']
+ self.dependency_status = data['dependency_status']
+ self.dependency_list = data['dependency_list']
stream.close()
elif not project:
- #self.file_list = None
- self.dependency_dict = None
+ self.dependency_status = None
+ self.dependency_list = None
else:
self.name = None
self.directory = None
- #self.file_list = None
- self.dependency_dict = None
+ self.dependency_status = None
+ self.dependency_list = None
self.clean = False
@@ -93,8 +93,8 @@ class Project(gobject.GObject):
"""
self.name = None
self.directory = None
- #self.file_list = None
- self.dependency_dict = None
+ self.dependency_status = None
+ self.dependency_list = None
self.emit('closed', True)
@@ -117,8 +117,9 @@ class Project(gobject.GObject):
try:
stream = file(filepath, 'w')
yaml.dump({'project': filepath,
- 'dependency_dict': self.dependency_dict},
- stream, default_flow_style=False)#'file_list': self.file_list,
+ 'dependency_list': self.dependency_list,
+ 'dependency_status': self.dependency_status},
+ stream, default_flow_style=False)
stream.close()
except IOError:
print 'IOError:', sys.exc_info()[0]
@@ -137,8 +138,8 @@ class Project(gobject.GObject):
try:
stream = file(filepath, 'r')
for data in yaml.load_all(stream):
- #self.file_list = data['file_list']
- self.dependency_dict = data['dependency_dict']
+ self.dependency_status = data['dependency_status']
+ self.dependency_list = data['dependency_list']
self.clean = True
self.emit('opened', True)
except IOError:
diff --git a/src/utils.py b/src/utils.py
index 8c1ec60..541d0d2 100644
--- a/src/utils.py
+++ b/src/utils.py
@@ -199,23 +199,20 @@ class Utils:
return self.icon_lut['folder']
- def get_status_image(self, gedamanager, selected_node):
+ def get_status_image(self, gedamanager, highlighted_source):
"""!
Method to get the status image for the process.
@param gedamanager current gEDAManager instance
- @param selected_node currently selected node in the 'Sources' tree view.
+ @param highlighted_source currently selected node in the 'Sources' tree view.
@return icon from the self.icon_lut structure
"""
- filename = self.get_filename_from_filepath(selected_node)
icon = gtk.IconTheme()
- if filename in gedamanager.project.dependency_dict:
- # Check its status
- if gedamanager.project.dependency_dict[filename] != None:
- if gedamanager.project.dependency_dict[filename][0]:
+ if highlighted_source in gedamanager.project.dependency_status:
+ if gedamanager.project.dependency_status[highlighted_source] != None:
+ if gedamanager.project.dependency_status[highlighted_source]:
return icon.load_icon(self.icon_lut['updated'], 22, 0)
else:
- # If nothing found in the loop, then it is outdated
- return icon.load_icon(self.icon_lut['outdated'], 22, 0)
+ return icon.load_icon(self.icon_lut['outdated'], 22, 0)
def flatten(self, lst):
@@ -316,6 +313,8 @@ class Utils:
image = icon.load_icon(self.load_image(filename), 22, 0)
path = selected_node + '/' + filename
+ # Might want to extract this out to the gEDAManager class for
+ # consistency
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
@@ -323,40 +322,18 @@ class Utils:
if filename not in files:
os.system('cp ' + filepath + ' ' + selected_node)
gedamanager.output_textbuffer.insert(gedamanager.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(gedamanager, filename):
- self.dependencies.append(None, [filename, path])
- # Add to the dependency_dict if not in there
- if filename not in self.project.dependency_dict:
- self.project.dependency_dict[filename] = [True, [], []]
elif filepath == selected_node + '/' + filename:
gedamanager.output_textbuffer.insert(gedamanager.output_textiter, self.get_time() + ':\n' + 'Added copy of source:' + filepath + ' to project.\n')
- if filename not in self.project.dependency_dict:
- self.project.dependency_dict[filename] = [True, [], []]
else:
gedamanager.output_textbuffer.insert(gedamanager.output_textiter, self.get_time() + ':\n' + filename + ' is already present in the directory: ' + selected_node + '.\n')
- elif index == 3:
+ elif index == 1:
# Logic here to add a new source
files = os.listdir(selected_node)
if filename not in files:
os.system('touch ' + filepath)
gedamanager.output_textbuffer.insert(gedamanager.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(gedamanager, filename):
- gedamanager.dependencies.append(None, [filename, path])
- # Add to the dependency_dict if not in there
- if filename not in gedamanager.project.dependency_dict:
- gedamanager.project.dependency_dict[filename] = [True, [], []]
else:
gedamanager.output_textbuffer.insert(gedamanager.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
- if self.is_filename_in_dependencies(gedamanager, filename, True):
- gedamanager.output_textbuffer.insert(gedamanager.output_textiter, self.get_time() + ':\nRemoved ' + selected_node + ' from dependencies tree.\n')
- # Remove from dependency_dict
- if filename in gedamanager.project.dependency_dict:
- del gedamanager.project.dependency_dict[filename]
- gedamanager.output_textbuffer.insert(gedamanager.output_textiter, self.get_time() + ':\nRemoved ' + selected_node + ' from project.\n')
# Expand the 'Sources' tree view
gedamanager.sources_tree.expand_all()
@@ -364,7 +341,6 @@ class Utils:
gedamanager.project.save()
- @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.
@@ -510,7 +486,6 @@ class Utils:
self.run_command(gedamanager, selected_node, None, ext)
- @exceptions
def cb_processes_row_activated(self, widget, path, view_column, gedamanager):
"""!
Event occurs when 'row-activated' signal is emitted or a user double
@@ -527,9 +502,9 @@ class Utils:
model, selection_iter = selection.get_selected()
if isinstance(selection_iter, gtk.TreeIter):
highlighted_source = gedamanager.sources.get_value(selection_iter, 2)
- filename = self.get_filename_from_filepath(highlighted_source)
- if filename not in gedamanager.project.dependency_dict:
- gedamanager.project.dependency_dict[filename] = [True, [], []]
+ if highlighted_source not in gedamanager.project.dependency_list:
+ gedamanager.project.dependency_status[highlighted_source] = True
+ gedamanager.project.dependency_list[highlighted_source] = []
self.run_command(gedamanager, selected_node, highlighted_source)
@@ -613,22 +588,11 @@ class Utils:
elif program == 'gsch2pcb workflow':
self.gsch2pcb = Gsch2pcb(gedamanager, highlighted_source)
elif program == 'Update PCB (gsch2pcb)':
- filename = self.get_filename_from_filepath(highlighted_source)
# Only run if the highlighted_souce is outdated
- if not gedamanager.project.dependency_dict[filename][0]:
+ if not gedamanager.project.dependency_status[highlighted_source]:
files_before = os.listdir(highlighted_source.rpartition('/')[0])
schematics_list = []
-# schematics_list = [x for x in gedamanager.project.dependency_dict[filename][1:] if x.endswith('.sch')]
- for x in gedamanager.project.dependency_dict:
- if x.endswith('.sch'):
- for y in gedamanager.project.dependency_dict[x]:
- if y == filename:
- # Add to list
- schematics_list.append(x)
-
- print 'gedamanager.project.dependency_dict[filename][1:]:',gedamanager.project.dependency_dict[filename][1:]
- print 'gedamanager.project.dependency_dict:',gedamanager.project.dependency_dict
- print 'schematics_list:',schematics_list
+ # TODO
if schematics_list:
schematics = ''
for sch in schematics_list:
@@ -659,15 +623,12 @@ class Utils:
filepath = directory + '/' + f
image = icon.load_icon(self.icon_lut[ext], 22, 0)
# Don't think I need the below
- #gedamanager.sources.append(parent_iter, [image, f, filepath])
- gedamanager.dependencies.append(None, [f, filepath])
+# gedamanager.dependencies.append(None, [f, filepath])
# Need to see if there are any new files
new_files.append(f)
print 'new_files:',new_files
else:
print 'no new files'
- # Update the status of the PCB file
- gedamanager.project.dependency_dict[filename][0] = True
else:
self.cb_not_implemented(gedamanager)
@@ -675,32 +636,32 @@ class Utils:
## not be an actual program
## subproc = Popen([program, highlighted_source])
- def update_dependency_dict(self, gedamanager, filename, flag=False):
- """!
- Method to update the dependencies for filename.
- @param filename file that will have its dependencies updated
- or list of filenames that will have its dependencies updated
- @param flag sets status of filename
- """
- if isinstance(filename, list):
- for f in filename:
- gedamanager.project.dependency_dict[f][0] = flag
- for x in gedamanager.project.dependency_dict[f][1:]:
- self.update_dependency_dict(gedamanager, x, False)
- else:
- # We just need to create a new list and set that as the value
- gedamanager.project.dependency_dict[filename][0] = flag
- for x in gedamanager.project.dependency_dict[filename][1:]:
- # recurse over files and make out of date
- self.update_dependency_dict(gedamanager, x, False)
+ ## def update_dependency_list(self, gedamanager, filename, flag=False):
+ ## """!
+ ## Method to update the dependencies for filename.
+ ## @param filename file that will have its dependencies updated
+ ## or list of filenames that will have its dependencies updated
+ ## @param flag sets status of filename
+ ## """
+ ## if isinstance(filename, list):
+ ## for f in filename:
+ ## gedamanager.project.dependency_list[f][0] = flag
+ ## for x in gedamanager.project.dependency_list[f][1:]:
+ ## self.update_dependency_list(gedamanager, x, False)
+ ## else:
+ ## # We just need to create a new list and set that as the value
+ ## gedamanager.project.dependency_list[filename][0] = flag
+ ## for x in gedamanager.project.dependency_list[filename][1:]:
+ ## # recurse over files and make out of date
+ ## self.update_dependency_list(gedamanager, x, False)
- def add_to_dependency_dict(self, gedamanager, filename):
- """!
- Method to add a file to the project's dependency_dict.
- @param filename file to add to project.dependency_dict
- """
- # add file to the dependency_dict
- if filename not in gedamanager.project.dependency_dict:
- gedamanager.project.dependency_dict[filename] = [True, [], []]
+ ## def add_to_dependency_list(self, gedamanager, filename):
+ ## """!
+ ## Method to add a file to the project's dependency_list.
+ ## @param filename file to add to project.dependency_list
+ ## """
+ ## # add file to the dependency_list
+ ## if filename not in gedamanager.project.dependency_list:
+ ## gedamanager.project.dependency_list[filename] = [True, [], []]
_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs