예제 #1
0
def main(args):
    """Main method."""
    collection = AugustinsMetadataCollection()
    csv_file = 'AugustinsMetadata.csv'
    collection.retrieve_metadata_from_csv(csv_file, delimiter=';')

    alignment_template = 'User:Jean-Frédéric/AlignmentRow'.encode('utf-8')

    if args.prepare_alignment:
        for key, value in collection.count_metadata_values().items():
            collection.write_dict_as_wiki(value, key, 'wiki',
                                          alignment_template)

    if args.post_process:
        mapping_fields = ['ARTSIT', 'DATE', 'MEDIUM']
        collection.retrieve_metadata_alignments(mapping_fields,
                                                alignment_template)
        mapping_methods = {};
        reader = collection.post_process_collection(mapping_methods)
        template_name = 'Commons:Musée des Augustins/Ingestion'.encode('utf-8')
        front_titlefmt = ""
        variable_titlefmt = "%(ARTIST)s - %(TITLE)s"
        rear_titlefmt = " - Musée des Augustins - %(ACCESSION NUMBER)s"
        uploadBot = DataIngestionBot(reader=iter(collection.records),
                                     front_titlefmt=front_titlefmt,
                                     rear_titlefmt=rear_titlefmt,
                                     variable_titlefmt=variable_titlefmt,
                                     pagefmt=template_name)

    if args.upload:
        uploadBot.doSingle()
    elif args.dry_run:
        uploadBot.dry_run()
예제 #2
0
def main(args):
    """Main method."""
    collection = AugustinsMetadataCollection()
    csv_file = 'AugustinsMetadata.csv'
    collection.retrieve_metadata_from_csv(csv_file, delimiter=';')

    alignment_template = 'User:Jean-Frédéric/AlignmentRow'.encode('utf-8')

    if args.prepare_alignment:
        for key, value in collection.count_metadata_values().items():
            collection.write_dict_as_wiki(value, key, 'wiki',
                                          alignment_template)

    if args.post_process:
        mapping_fields = ['ARTSIT', 'DATE', 'MEDIUM']
        collection.retrieve_metadata_alignments(mapping_fields,
                                                alignment_template)
        mapping_methods = {}
        reader = collection.post_process_collection(mapping_methods)
        template_name = 'Commons:Musée des Augustins/Ingestion'.encode(
            'utf-8')
        front_titlefmt = ""
        variable_titlefmt = "%(ARTIST)s - %(TITLE)s"
        rear_titlefmt = " - Musée des Augustins - %(ACCESSION NUMBER)s"
        uploadBot = DataIngestionBot(reader=iter(collection.records),
                                     front_titlefmt=front_titlefmt,
                                     rear_titlefmt=rear_titlefmt,
                                     variable_titlefmt=variable_titlefmt,
                                     pagefmt=template_name)

    if args.upload:
        uploadBot.doSingle()
    elif args.dry_run:
        uploadBot.dry_run()
예제 #3
0
def main(args):
    """Main method."""
    collection = ChamplitteMetadataCollection()
    #    csv_file = 'DV5_M0354_2006_9.csv'
    csv_file = "2006_7.csv"
    collection.retrieve_metadata_from_csv(csv_file, delimiter=",")

    alignment_template = "User:Jean-Frédéric/AlignmentRow".encode("utf-8")

    if args.prepare_alignment:
        for key, value in collection.count_metadata_values().items():
            collection.write_dict_as_wiki(value, key, "wiki", alignment_template)

    if args.post_process:
        mapping_fields = []
        mapper = commonprocessors.retrieve_metadata_alignments(mapping_fields, alignment_template)

        mapping_methods = {
            #'JOCONDE_TECH': commonprocessors.map_and_apply_technique(separator=";"),
            "JOCONDE_DIMS": (commonprocessors.process_DIMS, {}),
            "JOCONDE_DOMN": commonprocessors.split_and_keep_as_list(separator=";"),
            "JOCONDE_DESC": commonprocessors.wrap_with_template(template="fr"),
            "JOCONDE_REF": commonprocessors.wrap_within_pattern(pattern="{{online databases|{{Joconde|%s}}}}"),
            "JOCONDE_DACQ": commonprocessors.wrap_within_pattern(
                pattern="{{ProvenanceEvent|time=%s|type=acquisition|newowner=Musées de la Haute-Saône}}"
            ),
            "JOCONDE_PERI": (commonprocessors.look_for_date, {}),
        }
        categories_counter, categories_count_per_file = collection.post_process_collection(mapping_methods)
        # metadata.categorisation_statistics(categories_counter, categories_count_per_file)

    template_name = "User:Jean-Frédéric/Champlitte/Ingestion".encode("utf-8")
    front_titlefmt = ""
    # variable_titlefmt = "%(JOCONDE_TITR)s (%(JOCONDE_DENO)s)"
    variable_titlefmt = "%(JOCONDE_DENO)s"
    rear_titlefmt = " - Musées de la Haute-Saône - %(JOCONDE_REF)s"
    reader = iter(collection.records)
    string = StringIO()
    collection.write_metadata_to_xml(string)
    print string.getvalue()
    uploadBot = DataIngestionBot(
        reader=reader,
        front_titlefmt=front_titlefmt,
        rear_titlefmt=rear_titlefmt,
        variable_titlefmt=variable_titlefmt,
        pagefmt=template_name,
        subst=False,
        verifyDescription=True,
    )
    if args.upload:
        uploadBot.doSingle()
    elif args.dry_run:
        uploadBot.dry_run()
예제 #4
0
파일: MH_IDF.py 프로젝트: JeanFred/MH_IDF
def main(args):
    """Main method."""
    collection = MHIDFMetadataCollection()
#    csv_file = 'photographies-serie-monuments-historiques-1851-a-1914.csv'
    csv_file = 'error.csv'    
    collection.retrieve_metadata_from_csv(csv_file, delimiter=';')
    alignment_template = 'User:Jean-Frédéric/AlignmentRow'.encode('utf-8')

    if args.prepare_alignment:
        for key, value in collection.count_metadata_values().items():
            collection.write_dict_as_wiki(value, key, 'wiki',
                                          alignment_template)

    if args.post_process:
        mapping_fields = ['autp', 'datpv', 'edif', 'lieucor']
        mapper = commonprocessors.retrieve_metadata_alignments(mapping_fields,
                                                               alignment_template)
        mapping_methods = {
            'wgs84': commonprocessors.split_and_keep_as_list(separator=','),
            'lbase': look_for_MH_titles(separator=';'),
            'autp': (commonprocessors.process_with_alignment, {'mapper': mapper}),
            'datpv': (commonprocessors.process_with_alignment, {'mapper': mapper}),
            'edif': (commonprocessors.process_with_alignment, {'mapper': mapper}),
            'lieucor': (commonprocessors.process_with_alignment, {'mapper': mapper}),
            'insee': insee_to_commonscat(),
            }
        categories_counter, categories_count_per_file = collection.post_process_collection(mapping_methods)
        print metadata.categorisation_statistics(categories_counter, categories_count_per_file)

        reader = iter(collection.records)
        template_name = 'User:Jean-Frédéric/MH_IDF/Ingestion'.encode('utf-8')
        uploadBot = DataIngestionBot(reader=reader,
                                     front_titlefmt=front_titlefmt,
                                     rear_titlefmt=rear_titlefmt,
                                     variable_titlefmt=variable_titlefmt,
                                     pagefmt=template_name)

    if args.upload:
        uploadBot.doSingle()
    elif args.dry_run:
        string = StringIO()
        collection.write_metadata_to_xml(string)
        print string.getvalue()