[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: geda_manager.git: branch: master updated (0724a1f602ebebbdc4d28eb4a900043c50570070)
The branch, master has been updated
via 0724a1f602ebebbdc4d28eb4a900043c50570070 (commit)
from c9bcd4d5b91340221264ea51b46285957fb07b7e (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 | 7 +-
src/gedamanager.py | 202 +++++++++++++++++++++--------------------
src/newproject.py | 2 +-
src/processdependencyevent.py | 30 ++++++-
src/project.py | 14 ++--
src/utils.py | 70 +++++++++-----
6 files changed, 188 insertions(+), 137 deletions(-)
=================
Commit Messages
=================
commit 0724a1f602ebebbdc4d28eb4a900043c50570070
Author: Newell Jensen <jensen@xxxxxxxxxxxxxxx>
Date: Fri Oct 10 17:50:36 2008 -0700
Some major changes are under way. Revamping the entire sources tree to directlyreflect what is on the HDD for the project. This enables syncing of the embedded terminal as well as moving and deleting of files easily.
:100644 100644 75b840a... 9d0187e... M src/dependencyloop.py
:100644 100644 4483f8f... dbf8cde... M src/gedamanager.py
:100644 100644 21d3549... 8cce638... M src/newproject.py
:100644 100644 3d39b2c... b48806d... M src/processdependencyevent.py
:100644 100644 8d4f006... 28a3275... M src/project.py
:100644 100644 1060ee9... 7a4dbab... M src/utils.py
=========
Changes
=========
commit 0724a1f602ebebbdc4d28eb4a900043c50570070
Author: Newell Jensen <jensen@xxxxxxxxxxxxxxx>
Date: Fri Oct 10 17:50:36 2008 -0700
Some major changes are under way. Revamping the entire sources tree to directlyreflect what is on the HDD for the project. This enables syncing of the embedded terminal as well as moving and deleting of files easily.
diff --git a/src/dependencyloop.py b/src/dependencyloop.py
index 75b840a..9d0187e 100644
--- a/src/dependencyloop.py
+++ b/src/dependencyloop.py
@@ -52,8 +52,9 @@ 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
if self.g.project.directory != None:
- self.wdd = self.watch_manager.add_watch(self.g.project.directory, IN_MODIFY, rec=True)
+ self.wdd = self.watch_manager.add_watch(self.g.project.directory, mask, rec=True)
def switch_projects(self):
@@ -66,9 +67,9 @@ class DependencyLoop:
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
+ mask = IN_MODIFY | IN_CREATE | IN_DELETE | IN_MOVED_FROM
if self.g.project.directory != None:
- self.wdd = self.watch_manager.add_watch(self.g.project.directory, IN_MODIFY, rec=True)
+ self.wdd = self.watch_manager.add_watch(self.g.project.directory, mask, rec=True)
def kill_thread(self):
diff --git a/src/gedamanager.py b/src/gedamanager.py
index 4483f8f..dbf8cde 100644
--- a/src/gedamanager.py
+++ b/src/gedamanager.py
@@ -441,16 +441,17 @@ class gEDAManager:
if not self.project.clean:
self.project.save()
self.project.open(path)
- self.output_textbuffer.insert(self.output_textiter, self.utils.get_time() + ':\n' + 'Project set to ' + self.project.name + '\n')
+ self.output_textbuffer.insert(self.output_textiter, self.utils.get_time() + ':\n' + 'Project set to ' + self.project.name + '\n')
+ self.dependencyloop.switch_projects()
def set_sources_tree_to_project(self):
""" Method to set the tree to current project object. """
self.sources.clear()
- if self.project.file_list != None:
- self.load_sources_tree(self.project.file_list)
- self.sources_tree.expand_all()
+ if self.project.name != None:
+ self.load_sources_tree()
+ self.sources_tree.expand_all()
def set_dependencies_tree_to_project(self):
@@ -466,28 +467,6 @@ class gEDAManager:
self.dependencies.connect('row-changed', self.cb_row_changed)
- def set_sources_tree_to_new_project(self):
- """ Method to set the tree to newly created project object. """
-
- self.sources.clear()
-
- # Parent Folder
- icon = gtk.IconTheme()
- image = icon.load_icon(self.utils.icon_lut['project'], 22, 0)
- parent = self.sources.append(None, [image, self.project.name, self.project.directory])
-
- # Child Node
- image = icon.load_icon(self.utils.icon_lut['gm'], 22, 0)
- project_file_path = self.project.directory + '/' + self.project.name + '.gm'
- self.sources.append(parent, [image, self.project.name + '.gm', project_file_path])
- image = icon.load_icon(self.utils.icon_lut['log'], 22, 0)
- output_log_path = self.project.directory + '/output.log'
- self.sources.append(parent, [image, 'output.log', output_log_path])
- errors_log_path = self.project.directory + '/error.log'
- self.sources.append(parent, [image, 'error.log', errors_log_path])
- self.sources_tree.expand_all()
-
-
def set_dependencies_tree_to_new_project(self):
""" Method to set the tree to newly created project object. """
@@ -502,42 +481,75 @@ class gEDAManager:
self.dependencies.connect('row-changed', self.cb_row_changed)
- def load_sources_tree(self, file_list, parent=None, parent_path=None):
- """!
- Method to the load the tree -- recursively.
- @param file_list list of paths in the project's file_list
- @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
+ def load_sources_tree(self):
"""
- # parent == None is for the 'Project' node
- icon = gtk.IconTheme() # The icon used throughout the function
- if parent == None:
- image = icon.load_icon(self.utils.icon_lut['project'], 22, 0)
- n_parent = self.sources.append(None, [image, file_list[0], self.project.directory])
- parent = n_parent # parent used below
- file_list = file_list[1] # Now pointing to the nested list
-
- # In the file_list we have folders, nodes --> lists to recurse over
- for index, f in enumerate(file_list):
- if (index + 1) < len(file_list): # Check for folder
- if isinstance(file_list[index+1], list):
- if parent_path != None:
- file_path = parent_path + '/' + f
- else:
- file_path = self.project.directory + '/' + f
- image = icon.load_icon(self.utils.icon_lut['folder'], 22, 0)
- n_parent = self.sources.append(parent, [image, f, file_path])
- continue # jump to next iterator
- if isinstance(f, list): # Check for lists and use recursion
- self.load_sources_tree(f, n_parent, file_path)
- else: # We have a node
- if parent_path != None:
- file_path = parent_path + '/' + f
+ Method to the load the 'Sources' TreeView from the
+ directory structure of the project.
+ """
+ # 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:
- file_path = self.project.directory + '/' + f
- image = icon.load_icon(self.utils.icon_lut[self.utils.get_filename_ext(f)], 22, 0)
- n_parent = self.sources.append(parent, [image, f, file_path])
+ 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])
+ except KeyError:
+ node = self.sources.append(None, [image, folder, root])
+ for f in files:
+ 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()
+
+
+## def load_sources_tree(self, file_list, parent=None, parent_path=None):
+## """!
+## Method to the load the tree -- recursively.
+## @param file_list list of paths in the project's file_list
+## @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
+## """
+## # parent == None is for the 'Project' node
+## icon = gtk.IconTheme() # The icon used throughout the function
+## if parent == None:
+## image = icon.load_icon(self.utils.icon_lut['project'], 22, 0)
+## n_parent = self.sources.append(None, [image, file_list[0], self.project.directory])
+## parent = n_parent # parent used below
+## file_list = file_list[1] # Now pointing to the nested list
+
+## # In the file_list we have folders, nodes --> lists to recurse over
+## for index, f in enumerate(file_list):
+## if (index + 1) < len(file_list): # Check for folder
+## if isinstance(file_list[index+1], list):
+## if parent_path != None:
+## file_path = parent_path + '/' + f
+## else:
+## file_path = self.project.directory + '/' + f
+## image = icon.load_icon(self.utils.icon_lut['folder'], 22, 0)
+## n_parent = self.sources.append(parent, [image, f, file_path])
+## continue # jump to next iterator
+## if isinstance(f, list): # Check for lists and use recursion
+## self.load_sources_tree(f, n_parent, file_path)
+## else: # We have a node
+## if parent_path != None:
+## file_path = parent_path + '/' + f
+## else:
+## file_path = self.project.directory + '/' + f
+## image = icon.load_icon(self.utils.icon_lut[self.utils.get_filename_ext(f)], 22, 0)
+## n_parent = self.sources.append(parent, [image, f, file_path])
def load_dependencies_tree(self, dep_dict, parent=None, parent_path=None, number=None):
@@ -810,6 +822,7 @@ class gEDAManager:
self.set_sources_tree_to_project()
self.set_dependencies_tree_to_project()
+
def cb_project_saved(self, widget, event):
"""!
Event occurs when a Project object is saved.
@@ -829,7 +842,6 @@ class gEDAManager:
@param widget widget that threw the event
@param event 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()
@@ -842,10 +854,9 @@ class gEDAManager:
@param widget widget that threw the event
@param event 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()
+ self.set_sources_tree_to_project()
self.set_dependencies_tree_to_new_project()
@exceptions
@@ -1057,43 +1068,36 @@ class gEDAManager:
hbox.pack_end(entry)
dialog.vbox.pack_end(hbox, True, True, 0)
dialog.show()
- dialog.run()
- text = entry.get_text()
+ response = dialog.run()
+ text = entry.get_text()
+ 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 """
+ 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(filepath): # delete directory recursively
+ os.path.walk(filepath, delete_dependency_dict_entry, None)
+ shutil.rmtree(filepath)
+ flag = True
+ i = 0
+ while flag:
+ child_iter = self.sources.iter_nth_child(selection_iter, i)
+ if child_iter != None:
+ child_node = self.sources.get_value(child_iter, 2)
+ if child_node == filepath:
+ flag = self.sources.remove(child_iter)
+ if flag: # break out if flag is true
+ flag = False
+ else:
+ break
+ i = i + 1
+ os.mkdir(filepath)
dialog.destroy()
- filepath = selected_node + '/' + text
-
- def delete_dependency_dict_entry(arg, dirname, filenames):
- """ function to delete the filenames from the dependency_dict """
- 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(filepath): # delete directory recursively
- os.path.walk(filepath, delete_dependency_dict_entry, None)
- shutil.rmtree(filepath)
- flag = True
- i = 0
- while flag:
- child_iter = self.sources.iter_nth_child(selection_iter, i)
- if child_iter != None:
- child_node = self.sources.get_value(child_iter, 2)
- if child_node == filepath:
- flag = self.sources.remove(child_iter)
- if flag: # break out if flag is true
- flag = False
- else:
- break
- i = i + 1
- os.mkdir(filepath)
-
- filename = self.utils.get_filename_from_filepath(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_filename_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)
def open_in_editor(self, action):
diff --git a/src/newproject.py b/src/newproject.py
index 21d3549..8cce638 100644
--- a/src/newproject.py
+++ b/src/newproject.py
@@ -286,7 +286,7 @@ class NewProject:
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.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 3d39b2c..b48806d 100644
--- a/src/processdependencyevent.py
+++ b/src/processdependencyevent.py
@@ -48,11 +48,39 @@ class ProcessDependencyEvent(ProcessEvent):
@param event current IN_MODIFY event that was caught for the
project's filesystem
"""
- # Call method to set the status of the dependent files recursively
+ print 'processing in modify'
filename = self.g.utils.get_filename_from_filepath(event.pathname)
+ self.g.load_sources_tree()
if filename != None and self.g.project.dependency_dict != None:
if filename in self.g.project.dependency_dict:
print 'filename in process catcher:',filename
self.g.utils.update_dependency_dict(self.g, filename, True)
self.g.utils.update_file_list(self.g)
+
+ def process_IN_DELETE(self, event):
+ print 'processing delete'
+ filename = self.g.utils.get_filename_from_filepath(event.pathname)
+ self.g.load_sources_tree()
+ self.g.dependencyloop.switch_projects()
+
+
+ def process_IN_CREATE(self, event):
+ print 'processing create'
+ filename = self.g.utils.get_filename_from_filepath(event.pathname)
+ self.g.load_sources_tree()
+ self.g.dependencyloop.switch_projects()
+
+
+ def process_IN_MOVED_FROM(self, event):
+ print 'processing move from'
+ filename = self.g.utils.get_filename_from_filepath(event.pathname)
+ self.g.load_sources_tree()
+ self.g.dependencyloop.switch_projects()
+
+
+
+
+
+
+
diff --git a/src/project.py b/src/project.py
index 8d4f006..28a3275 100644
--- a/src/project.py
+++ b/src/project.py
@@ -73,16 +73,16 @@ 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.file_list = data['file_list']
self.dependency_dict = data['dependency_dict']
stream.close()
elif not project:
- self.file_list = None
+ #self.file_list = None
self.dependency_dict = None
else:
self.name = None
self.directory = None
- self.file_list = None
+ #self.file_list = None
self.dependency_dict = None
self.clean = False
@@ -94,7 +94,7 @@ class Project(gobject.GObject):
"""
self.name = None
self.directory = None
- self.file_list = None
+ #self.file_list = None
self.dependency_dict = None
self.emit('closed', True)
@@ -117,9 +117,9 @@ class Project(gobject.GObject):
filepath = self.directory + '/' + self.name + '.gm'
try:
stream = file(filepath, 'w')
- yaml.dump({'project': filepath, 'file_list': self.file_list,
+ yaml.dump({'project': filepath,
'dependency_dict': self.dependency_dict},
- stream, default_flow_style=False)
+ stream, default_flow_style=False)#'file_list': self.file_list,
stream.close()
except IOError:
print 'IOError:', sys.exc_info()[0]
@@ -138,7 +138,7 @@ class Project(gobject.GObject):
try:
stream = file(filepath, 'r')
for data in yaml.load_all(stream):
- self.file_list = data['file_list']
+ #self.file_list = data['file_list']
self.dependency_dict = data['dependency_dict']
self.clean = True
self.emit('opened', True)
diff --git a/src/utils.py b/src/utils.py
index 1060ee9..7a4dbab 100644
--- a/src/utils.py
+++ b/src/utils.py
@@ -162,19 +162,22 @@ class Utils:
else:
return ''
-
- def get_filename_ext(self, filepath):
+ def load_image(self, filepath):
"""!
- Method to return the extension for the path.
+ Method to load the image for filepath.
@param filepath filepath for the node file
- @return ext the extension of the node
+ @return icon_lut value for the filepath type
"""
if '.' in filepath:
- return filepath.split('.')[-1]
+ ext = filepath.split('.')[-1]
+ if ext not in self.icon_lut:
+ return self.icon_lut['other']
+ else:
+ return self.icon_lut[ext]
elif filepath in self.configfiles:
- return 'config'
+ return self.icon_lut['config']
else:
- return 'folder'
+ return self.icon_lut['folder']
def get_status_image(self, gedamanager, selected_node):
@@ -289,11 +292,11 @@ class Utils:
else:
filename = self.get_filename_from_filepath(selected_node) # Folders
icon = gtk.IconTheme()
- image = icon.load_icon(self.icon_lut[self.get_filename_ext(filename)], 22, 0)
+ image = icon.load_icon(self.load_image(filename), 22, 0)
path = selected_node + '/' + filename
- print 'g.projec.file_list before:',g.project.file_list
+# 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
@@ -370,30 +373,30 @@ class Utils:
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:
+# 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:
- # 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
- if row_iter != None: # We have children in this row
- child_list = self.child_recurse(row_iter, 1)
- if child_list != None:
- for x in child_list:
- if x == None:
- child_list.remove(None)
- g.project.file_list.append(child_list)
+## g.project.file_list = []
+## for row in g.sources:
+## # 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
+## if row_iter != None: # We have children in this row
+## child_list = self.child_recurse(row_iter, 1)
+## if child_list != None:
+## for x in child_list:
+## if x == None:
+## child_list.remove(None)
+## g.project.file_list.append(child_list)
# Expand the 'Sources' tree view
g.sources_tree.expand_all()
# Create a new dependency loop
- g.dependencyloop.switch_projects()
+# g.dependencyloop.switch_projects()
# Now save the project since the new update file_list is made
g.project.save()
@@ -429,7 +432,7 @@ class Utils:
extensions = []
for f in files:
if not f.endswith(('~','-')):
- ext = self.get_filename_ext(f)
+ ext = f.split('.')[-1]
if ext not in extensions:
extensions.append(ext)
for ext in extensions:
@@ -655,7 +658,16 @@ class Utils:
if not g.project.dependency_dict[filename][0]:
print 'We are in'
files_before = os.listdir(highlighted_source.rpartition('/')[0])
- schematics_list = [x for x in g.project.dependency_dict[filename][1:] if x.endswith('.sch')]
+ schematics_list = []
+# schematics_list = [x for x in g.project.dependency_dict[filename][1:] if x.endswith('.sch')]
+ for x in g.project.dependency_dict:
+ if x.endswith('.sch'):
+ for y in g.project.dependency_dict[x]:
+ if y == filename:
+ print 'Fuck yeah'
+ # Add to list
+ schematics_list.append(x)
+
print 'g.project.dependency_dict[filename][1:]:',g.project.dependency_dict[filename][1:]
print 'g.project.dependency_dict:',g.project.dependency_dict
print 'schematics_list:',schematics_list
@@ -692,6 +704,11 @@ class Utils:
# 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
+ g.project.dependency_dict[filename][0] = True
+
else:
print 'program: (process no name)',program
subproc = Popen([program, highlighted_source])
@@ -703,6 +720,7 @@ class Utils:
@param gedamanager current gEDAManager instance
@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:
_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs