0003033: const dependence in gen/plug/docgen stylesheet

svn: r12608
This commit is contained in:
Brian Matherly 2009-06-02 11:50:17 +00:00
parent a0b1965c24
commit 4ca984bd2f
7 changed files with 18 additions and 34 deletions

View File

@ -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):

View File

@ -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):

View File

@ -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"))

View File

@ -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

View File

@ -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("<?xml version=\"1.0\"?>\n")
xml_file.write('<stylelist>\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):

View File

@ -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.

View File

@ -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