Exemple #1
0
    def read(self):
        if not self.initially_read:
            predefined_profiles = self.profiles
        else:
            predefined_profiles = ()

        self.profiles = ProfileList(DefaultProfile(self.fields.name_value_dict)) # TODO: remove static options

        static_options, profiles = self.backend_instance.read()

        for field_name, value in static_options.iteritems():
            setattr(self, field_name, value)

        active_profile = 0
        for profile in flatten((profiles, predefined_profiles)):
            position = profile.pop('position')
            self.profiles.insert(position, profile, overwrite=True)
            if profile.pop('selected', False):
                active_profile = position

        self.use_profile(active_profile)

        self.initially_read = True
Exemple #2
0
def days_in_month(year, month):
    """
    Returns how many days the given month has.
    """
    monthdays = calendar.monthcalendar(year, month)
    return len(filter(lambda x: x > 0, flatten(monthdays)))