def get_data_per_day(self, worker_id, day):
        """return the calculated data(e.g. sums) of the worker with the id of `worker_id' on the day of `day'"""
        result = self.retrieve(worker_id, unicode(day))
        if not self.is_empty_row(row=result):
            lh_sum, waste_sum, assist_sum = 0, 0, 0

            for lh_key, ra_key in misc.take(SQLiteOperator._db_keys[:18], by=2):
                labor_hour, real_amount = map(result.__getitem__, (lh_key, ra_key))
                if labor_hour and real_amount:
                    labor_hour, real_amount = map(float, (labor_hour, real_amount))
                    if labor_hour:
                        lh_sum += real_amount / labor_hour
            lh_sum = round(lh_sum * 8, 1)

            for key in SQLiteOperator._db_keys[18:21]:
                waste = result[key]
                waste_sum += waste if waste else 0

            for key in SQLiteOperator._db_keys[21:23]:
                assist = result[key]
                assist_sum += assist if assist else 0

            labor_hour_aux_to = result['labor_hour_aux_to']
            labor_hour_aux_to = labor_hour_aux_to if labor_hour_aux_to else 0

            return lh_sum, labor_hour_aux_to, waste_sum, assist_sum

        return .0, 0, 0, 0
Beispiel #2
0
def feistel_s(plaintext_byte_s, keys_s):
    l, r = init_perm_b(plaintext_byte_s)

    for i in range(16):
        l, r = r, xor_s(l, f(r, keys_s[i]))
    l, r = r, l

    return map(lambda bits: "".join(bits), take(inverse_init_perm_b(l + r)))
def auto_gen(provider_class):
    for title, index in config.title_index_pairs:
        worker_dict = ExcelOperator(config.XLS_PATH).get_id_name_pairs(index)

        for num, d in enumerate(misc.take(worker_dict, by=43)):
            view = ViewWriter(provider_class(title, dict(d)))

            with open('%s%s.html' % (num, (title + provider_class.title_suffix).decode('utf-8')),
                      'w') as f:
                print >> f, view
Beispiel #4
0
    def gen_labor_hour_layout(self):
        h_layout = QHBoxLayout()
        h_layout.addStretch()
        for col_num, nums in enumerate(take(Form._pair_widget_range,
                                            by=3)):
            gl = QGridLayout()
            gl.addWidget(self.gen_label(u'班产'), 0, 0, Qt.AlignLeft)
            gl.addWidget(self.gen_label(u'数量'), 0, 1, Qt.AlignLeft)

            for cnt, num in enumerate(nums):
                def _(attr_prefix, col):
                    line_edit = self.produce_eligible_line_edit(True)
                    line_edit.name = attr_prefix + str(num)
                    gl.addWidget(line_edit, cnt + 1, col)
                    self.__setattr__(attr_prefix + str(num), line_edit)

                _(Form._labor_hour_prf, 0)
                _(Form._real_amount_prf, 1)
            h_layout.addLayout(gl)
            # if col_num < 2:
            h_layout.addStretch()

        return h_layout
Beispiel #5
0
    def gen_table_cont(self):
        return super(PerformanceDataProvider, self).table_cont.format(
            date_colspan=11,
            sums_colspan=2,
            title_colspan=15,
            table_title=self.table_title,
            table_headers=self.table_headers,
            table_rows_contents='\n'.join(self.gen_worker_rows())
        )



if __name__ == '__main__':
    config.db_path = '..\\this_month.db'
    for title, index in TITLE_INDEX_PAIRS:
        xls_obj = ExcelOperator('..\\data.xls')
        worker_dict = xls_obj.get_id_name_pairs(index)

        for num, d in enumerate(misc.take(worker_dict, by=43)):
            view = ViewWriter(PerformanceDataProvider(title,
                                                      dict(worker_dict),
                                                      dict(worker_dict),
                                                      dict(xls_obj.get_attended_days_count_pairs()),
                                                      dict(xls_obj.get_work_performance(config.p_index_offset + index))))

            with open('%s%s.html' % (num, title.decode('utf-8')), 'w') as f:
                print >> f, view