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

gEDA-cvs: branch: master updated (rel_0.1.2-2-g8fe2dae)



The branch, master has been updated
       via  8fe2dae043955e3dd36a02c091527befa0624430 (commit)
      from  18e9c086ba540ba10e9ed358c2a4b738ba2526f6 (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
=========

 lib/xgsch2pcb/gsch2pcbproject.py |   36 +++++++++++++++++++++++++++++++-----
 1 files changed, 31 insertions(+), 5 deletions(-)


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

commit 8fe2dae043955e3dd36a02c091527befa0624430
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Sun Jun 1 13:45:38 2008 +0100

    Ignore unknown config file options, and re-emit them when saving
    
    This allows .gsch2pcb file options which aren't directly supported
    by xgsch2pcb (including comments) to be read and re-saved without
    breaking the file.

:100644 100644 61996d5... 989e30d... M	lib/xgsch2pcb/gsch2pcbproject.py

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

commit 8fe2dae043955e3dd36a02c091527befa0624430
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Sun Jun 1 13:45:38 2008 +0100

    Ignore unknown config file options, and re-emit them when saving
    
    This allows .gsch2pcb file options which aren't directly supported
    by xgsch2pcb (including comments) to be read and re-saved without
    breaking the file.

diff --git a/lib/xgsch2pcb/gsch2pcbproject.py b/lib/xgsch2pcb/gsch2pcbproject.py
index 61996d5..989e30d 100644
--- a/lib/xgsch2pcb/gsch2pcbproject.py
+++ b/lib/xgsch2pcb/gsch2pcbproject.py
@@ -34,13 +34,14 @@ class Gsch2PCBProject(gobject.GObject):
                               gobject.TYPE_NONE,
                               (gobject.TYPE_STRING, )),
                    }
-                   
+
     def __init__(self, filename=None, output_name=None):
         gobject.GObject.__init__(self)
 
         self.filename = filename
         self.dirty = False
         self.pages = []
+        self.lines = []
 
         if output_name != None:
             self.output_name = output_name
@@ -68,17 +69,24 @@ class Gsch2PCBProject(gobject.GObject):
 
         fp = open(fromfile, 'rb')
         for line in fp:
+            self.lines.append(line)
             parts = line.strip().split(None, 1)
             opt = parts[0]
-            if opt == 'schematics':
+
+            # Skip blank lines and comment lines (like gsch2pcb)
+            if not opt or opt[0] == '#' or opt[0] == '/' or opt[0] == ';':
+                pass
+            # Pick out the list of schematics
+            elif opt == 'schematics':
                 if len(parts) > 1:
                     self.pages = parts[1].split()
                 else:
                     self.pages = []
+            # Pick out the output filename
             elif opt == 'output-name':
                 self.output_name = parts[1]
             else:
-                raise Exception, 'Unsupported project file option: %s' % line
+                print 'Warning: Unsupported project file line "%s"' % line.strip()
         fp.close()
         if fromfile == self.filename:
             self.set_dirty(False)
@@ -89,9 +97,27 @@ class Gsch2PCBProject(gobject.GObject):
         if destfile == None:
             raise Exception, 'No filename specified for project'
 
+        emitted_schematics = False
+        emitted_output_name = False
+
         fp = open(destfile, 'wb')
-        fp.write('schematics %s\n' % ' '.join(self.pages))
-        fp.write('output-name %s\n' % self.output_name)
+        for line in self.lines:
+            parts = line.strip().split(None, 1)
+            opt = parts[0]
+            if opt == 'schematics':
+                fp.write('schematics %s\n' % ' '.join(self.pages))
+                emitted_schematics = True
+            elif opt == 'output-name':
+                fp.write('output-name %s\n' % self.output_name)
+                emitted_output_name = True
+            else:
+                fp.write(line)
+
+        if not emitted_schematics:
+            fp.write('schematics %s\n' % ' '.join(self.pages))
+        if not emitted_output_name:
+            fp.write('output-name %s\n' % self.output_name)
+
         fp.close()
         if destfile == self.filename:
             self.set_dirty(False)




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