Пример #1
0
 def _do_list_categories(self, mlist, k, subcat=None):
     is_converted = bool(getattr(mlist, 'use_dollar_strings', False))
     info = mlist.GetConfigInfo(k, subcat)
     label, gui = mlist.GetConfigCategories()[k]
     if info is None:
         return
     for data in info[1:]:
         if not isinstance(data, tuple):
             continue
         varname = data[0]
         # Variable could be volatile
         if varname.startswith('_'):
             continue
         vtype = data[1]
         # Munge the value based on its type
         value = None
         if hasattr(gui, 'getValue'):
             value = gui.getValue(mlist, vtype, varname, data[2])
         if value is None:
             value = getattr(mlist, varname)
         # Do %-string to $-string conversions if the list hasn't already
         # been converted.
         if varname == 'use_dollar_strings':
             continue
         if not is_converted and varname in DOLLAR_STRINGS:
             value = Utils.to_dollar(value)
         widget_type = TYPES[vtype]
         if isinstance(value, list):
             self._push_element('option', name=varname, type=widget_type)
             for v in value:
                 self._element('value', v)
             self._pop_element('option')
         else:
             self._element('option', value, name=varname, type=widget_type)
Пример #2
0
 def _do_list_categories(self, mlist, k, subcat=None):
     is_converted = bool(getattr(mlist, 'use_dollar_strings', False))
     info = mlist.GetConfigInfo(k, subcat)
     label, gui = mlist.GetConfigCategories()[k]
     if info is None:
         return
     for data in info[1:]:
         if not isinstance(data, tuple):
             continue
         varname = data[0]
         # Variable could be volatile
         if varname.startswith('_'):
             continue
         vtype = data[1]
         # Munge the value based on its type
         value = None
         if hasattr(gui, 'getValue'):
             value = gui.getValue(mlist, vtype, varname, data[2])
         if value is None:
             value = getattr(mlist, varname)
         # Do %-string to $-string conversions if the list hasn't already
         # been converted.
         if varname == 'use_dollar_strings':
             continue
         if not is_converted and varname in DOLLAR_STRINGS:
             value = Utils.to_dollar(value)
         widget_type = TYPES[vtype]
         if isinstance(value, list):
             self._push_element('option', name=varname, type=widget_type)
             for v in value:
                 self._element('value', v)
             self._pop_element('option')
         else:
             self._element('option', value, name=varname, type=widget_type)
Пример #3
0
def convert(mlist):
    for attr in ('msg_header', 'msg_footer', 'digest_header', 'digest_footer',
                 'autoresponse_postings_text', 'autoresponse_admin_text',
                 'autoresponse_request_text'):
        s = getattr(mlist, attr)
        t = Utils.to_dollar(s)
        setattr(mlist, attr, t)
    mlist.use_dollar_strings = 1
    print(C_('Saving list'))
    mlist.Save()
Пример #4
0
def convert(mlist):
    for attr in ('msg_header', 'msg_footer', 'digest_header', 'digest_footer',
                 'autoresponse_postings_text', 'autoresponse_admin_text',
                 'autoresponse_request_text'):
        s = getattr(mlist, attr)
        t = Utils.to_dollar(s)
        setattr(mlist, attr, t)
    mlist.use_dollar_strings = 1
    print _('Saving list')
    mlist.Save()
Пример #5
0
 def _convertString(self, mlist, property, alloweds, val, doc):
     # Is the list using $-strings?
     dollarp = getattr(mlist, 'use_dollar_strings', 0)
     if dollarp:
         ids = Utils.dollar_identifiers(val)
     else:
         # %-strings
         ids = Utils.percent_identifiers(val)
     # Here's the list of allowable interpolations
     for allowed in alloweds:
         if ids.has_key(allowed):
             del ids[allowed]
     if ids:
         # What's left are not allowed
         badkeys = ids.keys()
         badkeys.sort()
         bad = BADJOINER.join(badkeys)
         doc.addError(_(
             """The following illegal substitution variables were
             found in the <code>%(property)s</code> string:
             <code>%(bad)s</code>
             <p>Your list may not operate properly until you correct this
             problem."""), tag=_('Warning: '))
         return val
     # Now if we're still using %-strings, do a roundtrip conversion and
     # see if the converted value is the same as the new value.  If not,
     # then they probably left off a trailing `s'.  We'll warn them and use
     # the corrected string.
     if not dollarp:
         fixed = Utils.to_percent(Utils.to_dollar(val))
         if fixed <> val:
             doc.addError(_(
                 """Your <code>%(property)s</code> string appeared to
                 have some correctable problems in its new value.
                 The fixed value will be used instead.  Please
                 double check that this is what you intended.
                 """))
             return fixed
     return val
Пример #6
0
 def _convertString(self, mlist, property, alloweds, val, doc):
     # Is the list using $-strings?
     dollarp = getattr(mlist, 'use_dollar_strings', 0)
     if dollarp:
         ids = Utils.dollar_identifiers(val)
     else:
         # %-strings
         ids = Utils.percent_identifiers(val)
     # Here's the list of allowable interpolations
     for allowed in alloweds:
         if allowed in ids:
             del ids[allowed]
     if ids:
         # What's left are not allowed
         badkeys = list(ids.keys())
         badkeys.sort()
         bad = BADJOINER.join(badkeys)
         doc.addError(_("""The following illegal substitution variables were
             found in the <code>%(property)s</code> string:
             <code>%(bad)s</code>
             <p>Your list may not operate properly until you correct this
             problem."""),
                      tag=_('Warning: '))
         return val
     # Now if we're still using %-strings, do a roundtrip conversion and
     # see if the converted value is the same as the new value.  If not,
     # then they probably left off a trailing `s'.  We'll warn them and use
     # the corrected string.
     if not dollarp:
         fixed = Utils.to_percent(Utils.to_dollar(val))
         if fixed != val:
             doc.addError(
                 _("""Your <code>%(property)s</code> string appeared to
                 have some correctable problems in its new value.
                 The fixed value will be used instead.  Please
                 double check that this is what you intended.
                 """))
             return fixed
     return val