Пример #1
0
    ### configuration
    config = ConfigManager(core='data\\config.json')

    ### sort input files

    files = sorted(argv[1:])

    ### load first
    data = nicejson.load(files[0])

    ### append remainder

    for path in files[1:]:
        week = nicejson.load(path)
        for i in week:
            data[i] = week[i]

    ### output

    for day in data:
        for event in data[day]['classes']:
            event['begin'] = time_24(event['begin'])
            event['end'] = time_24(event['end'])

    output_path = 'schedule.json'
    nicejson.dump(data, output_path)
    uxcore.display_success_standard(output_path)
except:
    log_path = uxcore.write_log('merge', files=files)
    uxcore.display_error_standard(log_path)
Пример #2
0
 def save(self):
     for attr in self.cfg_files:
         path = self.cfg_files[attr]
         if (attr in self.cfg_data):
             nicejson.dump(self.cfg_data[attr], path)
Пример #3
0
    ### record learned behavior

    config.save()

    ### move/delete CSV
    try:
        if config.core['csv_action'] == 1:
            newpath = os.path.split(argv[1])
            newpath = os.path.join(newpath[0], config.core['csv_folder'],
                                   newpath[1])
            os.rename(argv[1], newpath)
        elif config.core['csv_action'] == 2:
            os.remove(argv[1])
    except:
        pass

    ### output

    for day in week:
        for event in week[day]['classes']:
            event['begin'] = time_12(event['begin'], time_mode)
            event['end'] = time_12(event['end'], time_mode)

    output_path = '{}.json'.format(firstday)
    nicejson.dump(week, output_path)
    uxcore.display_success_standard(output_path)
except:
    log_path = uxcore.write_log('conv', files=[argv[1]])
    uxcore.display_error_standard(log_path)
Пример #4
0
 def execute(self):
     log_data = maintlib.produce_log('update:collect',
                                     self.paths,
                                     exception=False)
     nicejson.dump(log_data, self.output_path)
Пример #5
0
                        if time >= (x[0] - sm) and time <= (x[1] + em)
                    ])
                    if stuff > f:
                        f = stuff
                fitness[(sm, em)] = f
        good = {x: fitness[x] for x in fitness if fitness[x] <= 13}
        sel = []
        for x in good:
            val = abs(0.5 - x[1] / (x[0] - 59.)) - 2 * (x[0] > 60) - 2 * (
                x[0] > 90) - x[0] / 30. - x[1] / 30.
            sel += [(x, val)]
        sel.sort(key=lambda x: x[1])
        week[i]["start_margin"] = sel[0][0][0]
        week[i]["end_margin"] = sel[0][0][1]

    ### output

    time_mode = config.core['time_mode']

    for day in week:
        for event in week[day]['classes']:
            event['begin'] = time_12(event['begin'], time_mode)
            event['end'] = time_12(event['end'], time_mode)

    nicejson.dump(week, argv[1])
    output_path = os.path.split(argv[1])[-1]
    uxcore.display_success_standard(output_path)
except:
    log_path = uxcore.write_log('trim', files=[argv[1]])
    uxcore.display_error_standard(log_path)