コード例 #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
@author: dreymond
"""

import json
import os
import sys
import cPickle as pickle
#import bs4
from P2N_Lib import UrlInventorBuild, UrlApplicantBuild, UrlIPCRBuild, UrlPatent, LoadBiblioFile, RenderTemplate
from P2N_Config import LoadConfig

import datetime
aujourd = datetime.date.today()

configFile = LoadConfig()
requete = configFile.requete
ndf = configFile.ndf
Gather = configFile.GatherContent
GatherBiblio = configFile.GatherBiblio
GatherPatent = configFile.GatherPatent
GatherFamilly = configFile.GatherFamilly
IsEnableScript = configFile.FormateExportDataTable

#should set a working dir one upon a time... done it is temporPath
ListBiblioPath = configFile.ResultBiblioPath
temporPath = configFile.temporPath
ResultPathContent = configFile.ResultPath

if IsEnableScript and GatherFamilly:
    rep = ndf.replace('Families', '')
コード例 #3
0
ファイル: FusionImages.py プロジェクト: Patent2net/P2N
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']
        for patent in 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
        RenderTemplate(
            'ModeleImages.html',
            output_path + '/index' + prefix + '.html',
            request=expression.replace('"', ''),
            gallery=gallery,
            json=json.dumps(gallery),
        )