Ignore:
Timestamp:
24 Sep 2014, 13:26:30 (10 years ago)
Author:
uli
Message:

pep8.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/utils/utils.py

    r11804 r11814  
    2929from waeup.kofa.utils.helpers import get_sorted_preferred
    3030
    31 def send_mail(from_name,from_addr,rcpt_name,rcpt_addr,subject,body,config):
     31
     32def send_mail(from_name, from_addr,
     33              rcpt_name, rcpt_addr,
     34              subject, body, config):
    3235    """Wrapper for the real SMTP functionality in :mod:`waeup.kofa.smtp`.
    3336
     
    3942    return True
    4043
     44
    4145#: A list of phone prefixes (order num, country, prefix).
    4246#: Items with same order num will be sorted alphabetically.
     
    4448INT_PHONE_PREFIXES = [
    4549    (99, _('Germany'), '49'),
    46     ( 1, _('Nigeria'), '234'),
     50    (1, _('Nigeria'), '234'),
    4751    (99, _('U.S.'), '1'),
    4852    ]
    4953
    50 def sorted_phone_prefixes(data = INT_PHONE_PREFIXES, request=None):
     54
     55def sorted_phone_prefixes(data=INT_PHONE_PREFIXES, request=None):
    5156    """Sorted tuples of phone prefixes.
    5257
     
    6772            for x, y, z in data]
    6873    return tuple([
    69         ('%s (+%s)' % (x[1],x[2]), '+%s' % x[2])
     74        ('%s (+%s)' % (x[1], x[2]), '+%s' % x[2])
    7075        for x in sorted(data)
    7176        ])
     77
    7278
    7379class KofaUtils(grok.GlobalUtility):
     
    8288
    8389    PREFERRED_LANGUAGES_DICT = {
    84         'en':(1, u'English'),
    85         'fr':(2, u'Français'),
    86         'de':(3, u'Deutsch'),
    87         'ha':(4, u'Hausa'),
    88         'yo':(5, u'Yoruba'),
    89         'ig':(6, u'Igbo'),
     90        'en': (1, u'English'),
     91        'fr': (2, u'Français'),
     92        'de': (3, u'Deutsch'),
     93        'ha': (4, u'Hausa'),
     94        'yo': (5, u'Yoruba'),
     95        'ig': (6, u'Igbo'),
    9096        }
    9197
     
    179185
    180186    MODE_GROUPS = {
    181         'All':('all',),
    182         'Undergraduate Full-Time':('ug_ft',),
    183         'Undergraduate Part-Time':('ug_pt',),
    184         'Postgraduate Full-Time':('pg_ft',),
    185         'Postgraduate Part-Time':('pg_pt',),
     187        'All': ('all',),
     188        'Undergraduate Full-Time': ('ug_ft',),
     189        'Undergraduate Part-Time': ('ug_pt',),
     190        'Postgraduate Full-Time': ('pg_ft',),
     191        'Postgraduate Part-Time': ('pg_pt',),
    186192        }
    187193
     
    200206        }
    201207
    202     def sendContactForm(self,from_name,from_addr,rcpt_name,rcpt_addr,
    203                 from_username,usertype,portal,body,subject):
     208    def sendContactForm(self, from_name, from_addr, rcpt_name, rcpt_addr,
     209                        from_username, usertype, portal, body, subject):
    204210        """Send an email with data provided by forms.
    205211        """
     
    212218${e}
    213219""")
    214         text = _(text,
    215             mapping = {
    216             'a':from_name,
    217             'b':from_username,
    218             'c':usertype,
    219             'd':portal,
    220             'e':body})
     220        text = _(text, mapping={
     221            'a': from_name,
     222            'b': from_username,
     223            'c': usertype,
     224            'd': portal,
     225            'e': body})
    221226        body = translate(text, 'waeup.kofa',
    222227            target_language=self.PORTAL_LANGUAGE)
     
    224229            return False
    225230        return send_mail(
    226             from_name,from_addr,rcpt_name,rcpt_addr,subject,body,config)
     231            from_name, from_addr, rcpt_name, rcpt_addr,
     232            subject, body, config)
    227233
    228234    @property
     
    232238        return pytz.utc
    233239
    234     def fullname(self,firstname,lastname,middlename=None):
     240    def fullname(self, firstname, lastname, middlename=None):
    235241        """Full name constructor.
    236242        """
     
    240246        else:
    241247            name = '%s %s' % (firstname, lastname)
    242         return string.capwords(name.replace('-',' - ')).replace(' - ','-')
    243 
     248        return string.capwords(
     249            name.replace('-', ' - ')).replace(' - ', '-')
    244250
    245251    def genPassword(self, length=8, chars=string.letters + string.digits):
     
    247253        """
    248254        return ''.join([r().choice(chars) for i in range(length)])
    249 
    250255
    251256    def sendCredentials(self, user, password=None, url_info=None, msg=None):
     
    280285        rcpt_name = user.title
    281286        rcpt_addr = user.email
    282         text = _(text,
    283             mapping = {
    284             'a':rcpt_name,
    285             'b':msg,
    286             'c':config.name,
    287             'd':user.name,
    288             'e':password,
    289             'f':url_info})
     287        text = _(text, mapping={
     288            'a': rcpt_name,
     289            'b': msg,
     290            'c': config.name,
     291            'd': user.name,
     292            'e': password,
     293            'f': url_info})
    290294
    291295        body = translate(text, 'waeup.kofa',
    292296            target_language=self.PORTAL_LANGUAGE)
    293297        return send_mail(
    294             from_name,from_addr,rcpt_name,rcpt_addr,subject,body,config)
     298            from_name, from_addr, rcpt_name, rcpt_addr,
     299            subject, body, config)
    295300
    296301    def getPaymentItem(self, payment):
Note: See TracChangeset for help on using the changeset viewer.