Esempio n. 1
0
def get_changes_config(changes_path):
    '''
    Given the path of the changes configuration
    '''
    blocks = csv_to_blocks(path=changes_path, separator="\t")
    return blocks[0]['values']
Esempio n. 2
0
    try:
        if args.format == "csv-blocks" or args.format == "tsv-blocks":
            separator = {"csv-blocks": ",", "tsv-blocks": "\t"}[args.format]
            if os.path.isdir(args.input_path):
                if not os.path.exists(args.output_path):
                    os.makedirs(args.output_path)
                i = 0
                files = sorted([
                    name for name in os.listdir(args.input_path)
                    if os.path.isfile(os.path.join(args.input_path, name))
                ])
                for name in files:
                    print("importing %s" % name)
                    file_path = os.path.join(args.input_path, name)
                    blocks = csv_to_blocks(path=file_path, separator=separator)
                    election = blocks_to_election(blocks, config,
                                                  args.add_to_id)

                    if not args.admin_format:
                        output_path = os.path.join(
                            args.output_path,
                            str(election['id']) + ".config.json")
                    else:
                        output_path = os.path.join(args.output_path,
                                                   str(i) + ".json")
                        auth_config_path = os.path.join(
                            args.output_path,
                            str(i) + ".config.json")
                        auth_config = config['authapi']['event_config']
                        with open(auth_config_path,