Пример #1
0
 def _current_str_list(self, pref=""):
     """Generates a list of strings formatted for displaying current value.
     Assumes that PhycasTablePrinter._reset_term_width has been called 
     more recently than the last terminal width change)."""
     if pref:
         dpref = pref + "."
     else:
         dpref = ""
     v = None
     fn = self._getFilename()
     if fn:
         if self._is_active:
             v = str_value_for_user(fn)
         else:
             v = "<silenced>"
     opts_help = [PhycasTablePrinter.format_help("%s" %pref, v)]
     if fn:
         if self.prefix:
             opts_help.append(PhycasTablePrinter.format_help("%sprefix" % dpref, str_value_for_user(self.prefix)))
         if self.filename:
             opts_help.append(PhycasTablePrinter.format_help("%sfilename" % dpref, str_value_for_user(self.filename)))
         opts_help.append(PhycasTablePrinter.format_help("%smode" % dpref, str(self.mode)))
         if len(self._valid_formats) > 1:
             opts_help.append(PhycasTablePrinter.format_help("%s.format" % dpref, FileFormats.to_str(self.format)))
     if self._options:
         opts_help.extend(self._options._current_str_list(pref))
     return opts_help
Пример #2
0
 def _write_latex_item(self, out, pref="", cmdname=""): 
     """Generates a list of strings formatted for displaying help
     Assumes that PhycasTablePrinter._reset_term_width has been called 
     more recently than the last terminal width change)."""
     if pref:
         dpref = _escape_for_latex(pref + ".")
     else:
         dpref = ""
         
     out.write("\index{%s!%s}\item[\\bftt  %s] %s\n" % (cmdname,  _escape_for_latex(pref), _escape_for_latex(pref), _escape_for_latex(self._help_str)))
     fmt_def = " (default :%s)"
     d = self.prefix and (fmt_def % _escape_for_latex(repr(self.filename))) or ""
     out.write("\index{%s!%sprefix}\item[\\bftt  %sprefix] %s%s\n" % (cmdname, dpref, dpref, "file prefix (appropriate suffix will be added)", d))
     d = self.filename and (fmt_def % _escape_for_latex(repr(self.filename))) or ""
     out.write("\index{%s!%sfilename}\item[\\bftt  %sfilename] %s%s\n" % (cmdname, dpref, dpref, "The full file name. Specifying this field preempts `prefix` setting.", d))
     d = _escape_for_latex(self.mode)
     out.write("\index{%s!%smode}\item[\\bftt  %smode] %s%s\n" % (cmdname, dpref, dpref, 
                                                _escape_for_latex('Controls the behavior when the file is present. Valid settings are %s. ADD_NUMBER indicates that a number will be added to the end of the file name (or prefix) to make the name unique' % self._getValidModeNames()),
                                                d))
     if len(self._valid_formats) > 1:
         d = _escape_for_latex(FileFormats.to_str(self.format))
         h = _escape_for_latex('Format of the file valid settings are %s' % self._getValidFormatNames())
         out.write("\index{%s!%smode}\item[\\bftt  %smode] %s%s\n" % (cmdname, dpref, dpref, h, d))
     if self._options:
         self._options._write_latex_item(out, pref, cmdname)
Пример #3
0
 def _getValidFormatNames(self):
     v = self._valid_formats
     n = [FileFormats.to_str(i) for i in v]
     lv = len(v)
     if lv == 0:
         return None
     if lv == 1:
         return n[0]
     if lv == 2:
         return "%s or %s" % (n[0], n[1])
     return "%s, or %s" % (", ".join(n[0:-1]), n[-1])