コード例 #1
0
 def process_data(self, data):
     weekdays = []
     for name, values in data.iteritems():
         if name in self.DAY_NAMES:
             weekdays.append(
                 Weekday(name, data.description.values[0], int(values[0])))
         else:
             day_range = list(
                 filter(lambda element: element in name, self.DAY_NAMES))
             if len(day_range) > 1:
                 for day in self.weekdays_between(day_range[0],
                                                  day_range[1]):
                     weekdays.append(
                         Weekday(day, data.description.values[0],
                                 int(values[0])))
     return weekdays
コード例 #2
0
def main():

    file_path = Open(sys.argv[1])
    employee_data = file_path.open_json_file()
    time_sheet = TimeSheet(employee_data)
    weekday = Weekday(employee_data)
    saturday = Saturday(employee_data)
    sunday = Sunday(employee_data)

    pays = Counter(weekday.get_weekday_pay()) + Counter(saturday.get_saturday_pay()) + \
        Counter(sunday.get_sunday_pay())

    deposit = 0
    for value in pays.values():
        deposit += value

    pays['total_pay'] = round(deposit, 3)

    with open('data.json', 'w') as file:
        json.dump(pays, file)
コード例 #3
0
ファイル: test_weekday.py プロジェクト: tm-sol/DayParser
 def test_square_days_attr(self):
     self.assertTrue(hasattr(Weekday('mon', '', 1), 'square'))
     self.assertTrue(hasattr(Weekday('tue', '', 1), 'square'))
     self.assertTrue(hasattr(Weekday('wed', '', 1), 'square'))
     self.assertFalse(hasattr(Weekday('thu', '', 1), 'square'))
     self.assertFalse(hasattr(Weekday('fri', '', 1), 'square'))
コード例 #4
0
ファイル: test_weekday.py プロジェクト: tm-sol/DayParser
 def test_string_output_order(self):
     self.assertEqual(
         Weekday('mon', 'test', 1).__str__(),
         '{"day": "mon", "description": "test 1", "square": 1, "value": 1}')
コード例 #5
0
ファイル: test_weekday.py プロジェクト: tm-sol/DayParser
 def test_day_description_concatenation(self):
     self.assertEqual(Weekday('mon', 'test', 3).description, 'test 9')
     self.assertEqual(Weekday('fri', 'test', 3).description, 'test 6')
コード例 #6
0
ファイル: test_weekday.py プロジェクト: tm-sol/DayParser
 def test_day_double_value(self):
     self.assertEqual(Weekday('thu', '', 1).double, 2)
     self.assertEqual(Weekday('thu', '', 3).double, 6)
     self.assertEqual(Weekday('thu', '', -1).double, -2)
     self.assertEqual(Weekday('thu', '', 0).double, 0)
コード例 #7
0
ファイル: test_weekday.py プロジェクト: tm-sol/DayParser
 def test_day_square_value(self):
     self.assertEqual(Weekday('mon', '', 1).square, 1)
     self.assertEqual(Weekday('mon', '', 3).square, 9)
     self.assertEqual(Weekday('mon', '', -1).square, 1)
     self.assertEqual(Weekday('mon', '', 0).square, 0)