コード例 #1
0
def run():

    # Bootstrap logging
    boot_logging()

    # Load configuration
    configFile = LoadConfig()

    # Run this step only if enabled
    if configFile.FormateExportCountryCartography:

        # Get some paths from configuration
        storage_path = configFile.ResultBiblioPath
        output_path = configFile.ResultPath

        # Compute prefixes
        prefixes = [""]
        if configFile.GatherFamilly:
            prefixes.append("Families")

        # Build maps for all prefixes
        for prefix in prefixes:

            # Status message
            label = label_from_prefix(prefix)
            logger.info(
                "Generating maps about patent issuing countries for {}. ".
                format(label))

            # Compute storage slot
            storage_name = prefix + configFile.ndf

            # Generate map
            generate_map(storage_path, storage_name, output_path)

        # Due to limit of D3, countries resources are necessary placed
        # in same working directory... other solution is to start an http server
        # http://stackoverflow.com/questions/17077931/d3-samples-in-a-microsoft-stack

        # Clone required resources into result directory
        shutil.copy('countries.json',
                    os.path.join(output_path, "countries.json"))
コード例 #2
0
ファイル: FusionImages.py プロジェクト: Patent2net/P2N-v3
def run():

    # Bootstrap logging
    boot_logging()

    # Load configuration
    config = LoadConfig()

    # Run this only if enabled
    if not config.GatherImages:
        return

    # Get some information from configuration
    expression = config.requete
    storage_basedir = config.ResultBiblioPath
    storage_dirname = config.ndf
    output_path = config.ResultPathImages

    # Compute prefixes
    prefixes = [""]
    if config.GatherFamilly:
        prefixes.append("Families")

    # Build maps for all prefixes
    for prefix in prefixes:

        # Status message
        label = label_from_prefix(prefix)
        logger.info("Generating gallery of drawings for {}. ".format(label))

        # Compute storage slot using prefix and DataDirectory
        # e.g. "Lentille" vs. "FamiliesLentille"
        storage_name = prefix + storage_dirname

        # Load bibliographic data
        biblio_file = LoadBiblioFile(storage_basedir, storage_name)

        # Generate thumbnails
        gallery = []
        patents = biblio_file['brevets']
        cpt = 0
        for patent in patents:
            cpt + 1
            AnnonceProgres(Appli='p2n_image',
                           valMax=100,
                           valActu=90 + cpt * 10 / len(patents))
            patent_label = get_patent_label(patent)
            i = 1
            logger.info('Processing patent {}'.format(patent_label))
            path_img_base = '{}//{}-{}.tiff'.format(output_path, patent_label,
                                                    '{}')
            path = path_img_base.format(i)
            while os.path.exists(path):
                thumb, orig, tiff = generate_thumbnails(path)
                gallery.append({
                    "_id": '{}-{}'.format(patent_label, i),
                    'thumb': thumb,
                    'orig': orig,
                    'label': patent['title'],
                    'ipcr7': patent['IPCR7'],
                    'code': patent_label,
                    'tiff': tiff,
                })
                i += 1
                path = path_img_base.format(i)

        # Render gallery
        AnnonceProgres(Appli='p2n_image', valMax=100, valActu=100)
        RenderTemplate(
            'ModeleImages.html',
            output_path + '/index' + prefix + '.html',
            request=expression.replace('"', ''),
            gallery=gallery,
            json=json.dumps(gallery),
        )