[hamster-applet] fixed bug 596638 with help from Marco Villegas - appending file extension to reports based on format



commit 754ad7f7bb5572a765f5fbbf5d2069f8603c47a7
Author: Toms Bauģis <toms baugis gmail com>
Date:   Tue Nov 17 09:07:38 2009 +0000

    fixed bug 596638 with help from Marco Villegas - appending file extension to reports based on format

 hamster/stats.py |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/hamster/stats.py b/hamster/stats.py
index e70efaf..4cf82cf 100644
--- a/hamster/stats.py
+++ b/hamster/stats.py
@@ -109,7 +109,7 @@ class ReportChooserDialog(gtk.Dialog):
     def show(self, start_date, end_date):
         #set suggested name to something readable, replace backslashes with dots
         #so the name is valid in linux
-        filename = "Time track %s - %s" % (start_date.strftime("%x").replace("/", "."),
+        filename = "Time track %s - %s." % (start_date.strftime("%x").replace("/", "."),
                                            end_date.strftime("%x").replace("/", "."))
         self.dialog.set_current_name(filename)
         
@@ -157,6 +157,12 @@ class ReportChooserDialog(gtk.Dialog):
             format = self.filters[self.dialog.get_filter()]
         path = self.dialog.get_filename()
         
+        # append correct extension if it is missing
+        # TODO - proper way would be to change extension on filter change
+        # only pointer in web is http://www.mail-archive.com/pygtk daa com au/msg08740.html
+        if path.endswith(".%s" % format) == False:
+            path = "%s.%s" % (path.rstrip("."), format)
+        
         categories = []
         for button in self.category_box.get_children():
             if button.get_active():



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