get paid to paste

def expand_macro(self, formatter, name, content):

        # prepare options
        req = formatter.req
        options, query_args = parse_options(self.env.get_db_cnx(), content, copy.copy(DEFAULT_OPTIONS))

        if not options['startdate']:
            raise TracError("No start date specified!")

        # minimum time frame is one day
        if (options['startdate'] >= options['enddate']):
            options['enddate'] = options['startdate'] + timedelta(days=1)

        # consider user conditions
        original_query_args = copy.deepcopy(query_args)
        if options['condfield'] and options['cond']:
            query_args[options['condfield']] = options['cond']

        # calculate data
        timetable = self._calculate_timetable(options, query_args, req, self.estimation_field, 0)
        timetable_2 = {}
        
        # remove weekends
        if not options['weekends']:
            for date in timetable.keys():
                if date.weekday() >= 5:
                    del timetable[date]

        if (options['graph2_field']):
            # consider user conditions
            query_args = original_query_args
            if options['graph2_condfield'] and options['graph2_cond']:
                query_args[options['graph2_condfield']] = options['graph2_cond']

            # the estimation field will not be accumulated for the days when the ticket has been closed
            always_consider_value = 1
            if options['graph2_field'] == self.estimation_field:
                always_consider_value = 0

            # calculate data
            timetable_2 = self._calculate_timetable(options, query_args, req, options['graph2_field'], always_consider_value)
            # remove weekends
            if not options['weekends']:
                for date in timetable_2.keys():
                    if date.weekday() >= 5:
                        del timetable_2[date]

...snip...

Pasted: Jan 12, 2012, 3:09:15 pm
Views: 9