diff --git a/src/ReportBase/_DocReportDialog.py b/src/ReportBase/_DocReportDialog.py index 1c245f481..ce2a616d1 100644 --- a/src/ReportBase/_DocReportDialog.py +++ b/src/ReportBase/_DocReportDialog.py @@ -168,8 +168,8 @@ class DocReportDialog(ReportDialog): ext = "" else: spath = self.get_default_directory() - base = self.get_default_basename() - spath = os.path.normpath("%s/%s.%s" % (spath, base, ext)) + base = "%s.%s" % (self.raw_name, ext) + spath = os.path.normpath(os.path.join(spath, base)) self.target_fileentry.set_filename(spath) def setup_report_options_frame(self): diff --git a/src/ReportBase/_GraphvizReportDialog.py b/src/ReportBase/_GraphvizReportDialog.py index 612700aaf..b21b92e5b 100644 --- a/src/ReportBase/_GraphvizReportDialog.py +++ b/src/ReportBase/_GraphvizReportDialog.py @@ -1090,8 +1090,8 @@ class GraphvizReportDialog(ReportDialog): ext = "" else: spath = self.get_default_directory() - base = self.get_default_basename() - spath = os.path.normpath("%s/%s%s" % (spath, base, ext)) + base = "%s.%s" % (self.raw_name, ext) + spath = os.path.normpath(os.path.join(spath, base)) self.target_fileentry.set_filename(spath) def setup_report_options_frame(self): diff --git a/src/ReportBase/_ReportDialog.py b/src/ReportBase/_ReportDialog.py index 219891f67..486ed262b 100644 --- a/src/ReportBase/_ReportDialog.py +++ b/src/ReportBase/_ReportDialog.py @@ -179,25 +179,6 @@ class ReportDialog(ManagedWindow.ManagedWindow): category = standalone_categories[self.category] return "%s - %s - GRAMPS" % (name, category) - #------------------------------------------------------------------------ - # - # Customization hooks for subclasses - # - #------------------------------------------------------------------------ - def get_stylesheet_savefile(self): - """Where should new styles for this report be saved? This is - the name of an XML file that will be located in the ~/.gramps - directory. This file does not have to exist; it will be - created when needed. All subclasses should probably override - this function.""" - return "basic_report.xml" - - def get_default_basename(self): - """What should the default name be? - """ - spath = self.options.handler.get_stylesheet_savefile() - return spath.split('.')[0] - #------------------------------------------------------------------------ # # Functions related to extending the options @@ -443,7 +424,7 @@ class ReportDialog(ManagedWindow.ManagedWindow): #------------------------------------------------------------------------ def setup_init(self): # add any elements that we are going to need: - hid = self.get_stylesheet_savefile() + hid = self.style_name if hid[-4:] == ".xml": hid = hid[0:-4] self.target_fileentry = FileEntry(hid, _("Save As")) diff --git a/src/ReportBase/_ReportOptions.py b/src/ReportBase/_ReportOptions.py index d7bd0ea78..7251cad09 100644 --- a/src/ReportBase/_ReportOptions.py +++ b/src/ReportBase/_ReportOptions.py @@ -633,7 +633,8 @@ class OptionHandler(_Options.OptionHandler): def get_stylesheet_savefile(self): """Where to save user defined styles for this report.""" - return "%s.xml" % self.module_name + filename = "%s.xml" % self.module_name + return os.path.join(const.HOME_DIR, filename) def get_default_stylesheet_name(self): return self.style_name diff --git a/src/gen/plug/docgen/stylesheet.py b/src/gen/plug/docgen/stylesheet.py index 1dd7a0486..9ac8f1569 100644 --- a/src/gen/plug/docgen/stylesheet.py +++ b/src/gen/plug/docgen/stylesheet.py @@ -43,7 +43,6 @@ def escxml(string): # GRAMPS modules # #------------------------------------------------------------------------- -import const from gen.plug.utils import gformat, gfloat from paragraphstyle import ParagraphStyle from fontstyle import FontStyle @@ -103,7 +102,7 @@ class StyleSheetList(object): """ defstyle.set_name('default') self.map = { "default" : defstyle } - self.file = os.path.join(const.HOME_DIR, filename) + self.__file = filename self.parse() def delete_style_sheet(self, name): @@ -149,7 +148,7 @@ class StyleSheetList(object): """ Saves the current StyleSheet definitions to the associated file. """ - xml_file = open(self.file,"w") + xml_file = open(self.__file,"w") xml_file.write("\n") xml_file.write('\n') @@ -200,10 +199,10 @@ class StyleSheetList(object): Loads the StyleSheets from the associated file, if it exists. """ try: - if os.path.isfile(self.file): + if os.path.isfile(self.__file): parser = make_parser() parser.setContentHandler(SheetParser(self)) - the_file = open(self.file) + the_file = open(self.__file) parser.parse(the_file) the_file.close() except (IOError,OSError,SAXParseException): diff --git a/src/gen/plug/utils.py b/src/gen/plug/utils.py index a1e0be57a..eb2443001 100644 --- a/src/gen/plug/utils.py +++ b/src/gen/plug/utils.py @@ -24,6 +24,13 @@ General utility functions usefull for the generic plugin system """ +#------------------------------------------------------------------------- +# +# Standard Python modules +# +#------------------------------------------------------------------------- +import locale + def gfloat(val): """Convert to floating number, taking care of possible locale differences. diff --git a/src/plugins/BookReport.py b/src/plugins/BookReport.py index 9f4242aec..e66a17193 100644 --- a/src/plugins/BookReport.py +++ b/src/plugins/BookReport.py @@ -1143,10 +1143,6 @@ class BookReportDialog(DocReportDialog): def get_header(self, name): return _("GRAMPS Book") - def get_stylesheet_savefile(self): - """Needed solely for forming sane filename for the output.""" - return "book.xml" - def make_doc_menu(self, active=None): """Build a menu of document types that are appropriate for this text report. This menu will be generated based upon