예제 #1
0
def run():
    """
    Usage:
      {program} import --kind=<kind> <file> [--force]
      {program} --version
      {program} (-h | --help)

    Options:
      <kind>        One of country, ipc, cpc
      <file>        Path to import file

    Miscellaneous options:
      --debug                   Enable debug messages
      --version                 Show version information
      -h --help                 Show this screen

    Examples:

      # Import country to id map
      patzilla-sip import --kind=country /tmp/ccids.xlsx

      # Import IPC class to id map
      patzilla-sip import --kind=ipc /tmp/ipcids.xlsx

      # Import CPC class to id map
      patzilla-sip import --kind=cpc /tmp/IPC_CPC.csv

    """

    # Use generic commandline options schema and amend with current program name
    commandline_schema = run.__doc__.format(program=APP_NAME)

    # Read commandline options
    options = docopt(commandline_schema, version=APP_NAME + ' ' + __version__)

    # Start logging subsystem
    boot_logging(options)

    # Boot Pyramid to access the database
    configfile = os.environ['PATZILLA_CONFIG']

    # TODO: Currently, this is a full bootstrap. It can be trimmed down to database setup only.
    env = setup_commandline_pyramid(configfile)

    # Clean option names
    options = normalize_docopt_options(options)

    # Debugging
    #print('options: {}'.format(options))

    if options['import']:
        kind = options['kind']
        filepath = options['file']
        force = options['force']
        if kind == 'country':
            import_countries(filepath, force=force)
        elif kind == 'ipc':
            import_ipc_classes(filepath, force=force)
        elif kind == 'cpc':
            import_cpc_classes(filepath, force=force)
예제 #2
0
def usercmd():
    """
    Usage:
      {program} add [options]
      {program} import <csv-file>

      {program} --version
      {program} (-h | --help)

    User add options:
      --fullname=<fullname>             Full user name, e.g. "Max M. Mustermann"
      --username=<username>             Username / Email address, e.g. [email protected]
      --password=<password>             Password
      --tags=<tags>                     Tags to apply to this user. e.g. "trial"
      --modules=<modules>               Modules to enable for this user. e.g. "keywords-user, family-citations"
      --organization=<organization>     Organization name
      --homepage=<homepage>             Homepage URL
      --phone=<phone>                   Phone number

    Miscellaneous options:
      --debug                   Enable debug messages
      --version                 Show version information
      -h --help                 Show this screen

    Examples:

      # Configure path to application configuration
      export PATZILLA_CONFIG=/path/to/patzilla.ini

      # Simple add
      patzilla-user add --fullname "John Doe" --username "*****@*****.**" --password "john123"

      # Add user, enabling some modules
      patzilla-user add \
        --fullname "Max Mustermann" --username "*****@*****.**" --password "max987" \
        --tags "demo" --modules "keywords-user, family-citations"

    """

    # Use generic commandline options schema and amend with current program name
    commandline_schema = usercmd.__doc__.format(program='patzilla-user')

    # Read commandline options
    options = docopt(commandline_schema, version=APP_NAME + ' ' + __version__)

    # Start logging subsystem
    boot_logging(options)

    # Boot Pyramid to access the database
    configfile = os.environ['PATZILLA_CONFIG']

    # TODO: Currently, this is a full bootstrap. It can be trimmed down to database setup only.
    env = setup_commandline_pyramid(configfile)
    #logger = logging.getLogger(__name__)

    # Clean option names
    options = normalize_docopt_options(options)

    # Debugging
    #print('Options:\n{}'.format(pformat(options)))

    if options['add']:
        user = create_user(options)
        if not user:
            sys.exit(1)

    elif options['import']:

        csvfile_path = options['csv-file']
        field_blacklist = ['phone']

        with open(csvfile_path) as csvfile:
            reader = csv.DictReader(csvfile)
            for row in reader:

                # Remove blacklisted fields
                for blackfield in field_blacklist:
                    if blackfield in row:
                        del row[blackfield]

                create_user(row)
예제 #3
0
    Synopsis
    ========
    ::

        export PATZILLA_CONFIG=patzilla/config/development-local.ini

        python patzilla/access/dpma/depatisconnect.py
        python patzilla/access/dpma/depatisconnect.py | jq --raw-output '.xml'
        python patzilla/access/dpma/depatisconnect.py | jq .
        python patzilla/access/dpma/depatisconnect.py | jq --raw-output '.xml' | xmllint --format -
    """

    from patzilla.util.web.pyramid.commandline import setup_commandline_pyramid
    configfile = os.environ['PATZILLA_CONFIG']

    env = setup_commandline_pyramid(configfile)
    logger = logging.getLogger(__name__)

    # Populate archive_service_baseurl again because "includeme" runs in a different thread
    registry = env['registry']
    archive_service_baseurl = registry.datasource_settings.datasource.depatisconnect.api_uri
    if archive_service_baseurl.startswith('https'):
        use_https = True

    #response = depatisconnect_abstracts('DE19653398A1', 'DE')
    #response = depatisconnect_description('DE19653398A1')

    #response = depatisconnect_abstracts('DE0001301607B', 'DE')
    #response = depatisconnect_description('DE1301607B')
    #response = depatisconnect_description('DE7909160U1')
    #response = depatisconnect_abstracts('DE7909160U1', 'DE')