Author: esr
Date: Mon Oct 13 20:16:58 2008
New Revision: 30132

URL: http://svn.gna.org/viewcvs/wesnoth?rev=30132&view=rev
Log:
trackplacer: smarter defaulys for the write operation.

Modified:
    trunk/data/tools/trackplacer

Modified: trunk/data/tools/trackplacer
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/tools/trackplacer?rev=30132&r1=30131&r2=30132&view=diff
==============================================================================
--- trunk/data/tools/trackplacer (original)
+++ trunk/data/tools/trackplacer Mon Oct 13 20:16:58 2008
@@ -157,7 +157,7 @@
             try:
                 x = int(x)
                 y = int(y)
-            except ValuError:
+            except ValueError:
                 raise IOException("Invalid coordinate field.", fp.name, i+1)
             self.initial_track.append((tag, x, y))
         fp.close()
@@ -553,7 +553,13 @@
             w.run()
             w.destroy()
         else:
-            w = ModalFileSelector(default=self.last_read, legend="Save track 
to file")
+            dflt = None
+            if self.last_read:
+                if ext == ".trk":
+                    dflt = self.last_read
+                else:
+                    dflt = self.last_read.replace(".trk", ".cfg")
+            w = ModalFileSelector(default=dflt, legend="Save track to file")
             if not w.path.endswith(ext):
                 raise IOException("File must have a %s extension."%ext, w.path)
             if w.path != self.last_read and os.path.exists(w.path):
@@ -608,15 +614,16 @@
         elif opt in ('-v', '--verbose'):
             verbose=True
 
+    here = os.getcwd()
     if top:
         os.chdir(top)
     else:
         wesnoth.wmltools.pop_to_top("trackplacer")
     if arguments:
         try:
-            TrackEditor(path=arguments[0], verbose=verbose)
+            TrackEditor(path=os.path.join(here, arguments[0]), verbose=verbose)
         except IOException, e:
-            sys.stderr.write(e.message + "\n")
+            sys.stderr.write(('"%s", line %d: ' % (e.path, e.lineno)) + 
e.message + "\n")
     else:
         while True:
             try:


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to