Ejemplo n.º 1
0
def _task_submit_elaborate_specific_parameter(key, value, opts, args):
    """
    Given the string key it checks it's meaning, eventually using the
    value. Usually, it fills some key in the options dict.
    It must return True if it has elaborated the key, False, if it doesn't
    know that key.
    """

    if key in ("--repair-personid",):
        bibtask.task_set_option("repair_pid", True)

    elif key in ("--fast-update-personid",):
        bibtask.task_set_option("fast_update_personid", True)

    elif key in ("--personid-gc",):
        bibtask.task_set_option("personid_gc", True)

    elif key in ("--record-ids", '-r'):
        if value.count("="):
            value = value[1:]
        value = value.split(",")
        bibtask.task_set_option("record_ids", value)

    elif key in ("--all-records",):
        bibtask.task_set_option("all_records", True)

    else:
        return False

    return True
Ejemplo n.º 2
0
def _task_submit_elaborate_specific_parameter(key, value, opts, args):
    """Given the string key it checks it's meaning, eventually using the
    value. Usually it fills some key in the options dict.
    It must return True if it has elaborated the key, False, if it doesn't
    know that key.
    eg:
    if key in ('-n', '--number'):
        bibtask.task_get_option(\1) = value
        return True
    return False
    """
    # Recid option
    if key in ("-i", "--recid"):
        try:
            value = int(value)
        except ValueError:
            bibtask.write_message("The value specified for --recid must be a "
                                  "valid integer, not '%s'." % value,
                                  stream=sys.stderr,
                                  verbose=0)
        if not _recid_exists(value):
            bibtask.write_message("ERROR: '%s' is not a valid record ID." %
                                  value,
                                  stream=sys.stderr,
                                  verbose=0)
            return False
        recids = bibtask.task_get_option('recids')
        if recids is None:
            recids = []
        recids.append(value)
        bibtask.task_set_option('recids', recids)

    # Collection option
    elif key in ("-c", "--collection"):
        if not _collection_exists(value):
            bibtask.write_message("ERROR: '%s' is not a valid collection." %
                                  value,
                                  stream=sys.stderr,
                                  verbose=0)
            return False
        collections = bibtask.task_get_option("collections")
        collections = collections or []
        collections.append(value)
        bibtask.task_set_option("collections", collections)

    # Taxonomy option
    elif key in ("-k", "--taxonomy"):
        if not _ontology_exists(value):
            bibtask.write_message("ERROR: '%s' is not a valid taxonomy name." %
                                  value,
                                  stream=sys.stderr,
                                  verbose=0)
            return False
        bibtask.task_set_option("taxonomy", value)
    elif key in ("-f", "--force"):
        bibtask.task_set_option("force", True)
    else:
        return False

    return True
def _task_submit_elaborate_specific_parameter(key, value, opts, args):
    """
    Given the string key it checks it's meaning, eventually using the
    value. Usually, it fills some key in the options dict.
    It must return True if it has elaborated the key, False, if it doesn't
    know that key.
    """
    if key in ("--all",):
        bibtask.task_set_option("all_pids", True)
    elif key in ("--mp",):
        bibtask.task_set_option("mp", True)
    else:
        return False

    return True
def _task_submit_elaborate_specific_parameter(key, value, opts, args):
    """
    Given the string key it checks it's meaning, eventually using the
    value. Usually, it fills some key in the options dict.
    It must return True if it has elaborated the key, False, if it doesn't
    know that key.
    """
    if key in ("--all", ):
        bibtask.task_set_option("all_pids", True)
    elif key in ("--mp", ):
        bibtask.task_set_option("mp", True)
    else:
        return False

    return True
Ejemplo n.º 5
0
def _task_submit_elaborate_specific_parameter(key, value, opts, args):
    """Given the string key it checks it's meaning, eventually using the
    value. Usually it fills some key in the options dict.
    It must return True if it has elaborated the key, False, if it doesn't
    know that key.
    eg:
    if key in ('-n', '--number'):
        bibtask.task_get_option(\1) = value
        return True
    return False
    """
    # Recid option
    if key in ("-i", "--recid"):
        try:
            value = int(value)
        except ValueError:
            bibtask.write_message("The value specified for --recid must be a "
                "valid integer, not '%s'." % value, stream=sys.stderr,
                verbose=0)
        if not _recid_exists(value):
            bibtask.write_message("ERROR: '%s' is not a valid record ID." % value,
                stream=sys.stderr, verbose=0)
            return False
        recids = bibtask.task_get_option('recids')
        if recids is None:
            recids = []
        recids.append(value)
        bibtask.task_set_option('recids', recids)

    # Collection option
    elif key in ("-c", "--collection"):
        if not _collection_exists(value):
            bibtask.write_message("ERROR: '%s' is not a valid collection." % value,
                stream=sys.stderr, verbose=0)
            return False
        collections = bibtask.task_get_option("collections")
        collections = collections or []
        collections.append(value)
        bibtask.task_set_option("collections", collections)

    # Taxonomy option
    elif key in ("-k", "--taxonomy"):
        if not _ontology_exists(value):
            bibtask.write_message("ERROR: '%s' is not a valid taxonomy name." % value,
                stream=sys.stderr, verbose=0)
            return False
        bibtask.task_set_option("taxonomy", value)
    elif key in ("-f", "--force"):
        bibtask.task_set_option("force", True)
    else:
        return False

    return True
def _task_submit_elaborate_specific_parameter(key, value, opts, args):
    """
    Given the string key it checks it's meaning, eventually using the
    value. Usually, it fills some key in the options dict.
    It must return True if it has elaborated the key, False, if it doesn't
    know that key.
    """
    if key in ("-n", "--lastname"):
        if value == "None," or value == "None":
            bibtask.write_message("The value specified for --lastname must "
                "be a valid name. Not '%s'." % value, stream=sys.stdout,
                verbose=0)
            return False

        bibtask.task_set_option('lastname', value)

    elif key in ("-a", "--process-all"):
        bibtask.task_set_option("process_all", True)

    elif key in ("-U", "--update-universe"):
        bibtask.task_set_option("update", True)

    elif key in ("-G", "--prepare-grid"):
        bibtask.task_set_option("prepare_grid", True)

    elif key in ("-R", "--load-grid-results"):
        bibtask.task_set_option("load_grid_results", True)

    elif key in ("-d", "--data-dir"):
        bibtask.task_set_option("data_dir", value)

    elif key in ("-p", "--prefix"):
        bibtask.task_set_option("prefix", value)

    elif key in ("-m", "--max-records"):
        bibtask.task_set_option("max_records", value)

    elif key in ("--update-cache",):
        bibtask.task_set_option("update_cache", True)

    elif key in ("--clean-cache",):
        bibtask.task_set_option("clean_cache", True)

    else:
        return False

    return True
def _task_submit_elaborate_specific_parameter(key, value, opts, args):
    """
    Given the string key it checks it's meaning, eventually using the
    value. Usually, it fills some key in the options dict.
    It must return True if it has elaborated the key, False, if it doesn't
    know that key.
    """
    if key in ("-n", "--lastname"):
        if value == "None," or value == "None":
            bibtask.write_message("The value specified for --lastname must "
                                  "be a valid name. Not '%s'." % value,
                                  stream=sys.stdout,
                                  verbose=0)
            return False

        bibtask.task_set_option('lastname', value)

    elif key in ("-a", "--process-all"):
        bibtask.task_set_option("process_all", True)

    elif key in ("-U", "--update-universe"):
        bibtask.task_set_option("update", True)

    elif key in ("-G", "--prepare-grid"):
        bibtask.task_set_option("prepare_grid", True)

    elif key in ("-R", "--load-grid-results"):
        bibtask.task_set_option("load_grid_results", True)

    elif key in ("-d", "--data-dir"):
        bibtask.task_set_option("data_dir", value)

    elif key in ("-p", "--prefix"):
        bibtask.task_set_option("prefix", value)

    elif key in ("-m", "--max-records"):
        bibtask.task_set_option("max_records", value)

    elif key in ("--update-cache", ):
        bibtask.task_set_option("update_cache", True)

    elif key in ("--clean-cache", ):
        bibtask.task_set_option("clean_cache", True)

    else:
        return False

    return True