コード例 #1
0
ファイル: morphemelanguagemodels.py プロジェクト: FieldDB/old
def get_data_for_new_edit(GET_params):
    """Return the data needed to create a new morpheme language model or edit one."""
    model_name_map = {'corpora': 'Corpus', 'morphologies': 'Morphology'}
    getter_map = {
        'corpora': h.get_mini_dicts_getter('Corpus'),
        'morphologies': h.get_mini_dicts_getter('Morphology'),
        'toolkits': lambda: h.language_model_toolkits
    }
    mandatory_attributes = ['toolkits']
    return h.get_data_for_new_action(GET_params, getter_map, model_name_map, mandatory_attributes)
コード例 #2
0
ファイル: morphologicalparsers.py プロジェクト: jrwdunham/old
def get_data_for_new_edit(GET_params):
    """Return the data needed to create a new morphological parser or edit one."""
    model_name_map = {
        'morpheme_language_models': 'MorphemeLanguageModel',
        'phonologies': 'Phonology',
        'morphologies': 'Morphology'
    }
    getter_map = {
        'morpheme_language_models': h.get_mini_dicts_getter('MorphemeLanguageModel'),
        'phonologies': h.get_mini_dicts_getter('Phonology'),
        'morphologies': h.get_mini_dicts_getter('Morphology')
    }
    return h.get_data_for_new_action(GET_params, getter_map, model_name_map)
コード例 #3
0
ファイル: corpora.py プロジェクト: jrwdunham/old
def get_data_for_new_edit(GET_params):
    """Return the data needed to create a new corpus or edit one."""
    mandatory_attributes = ['corpus_formats']
    model_name_map = {
        'form_searches': 'FormSearch',
        'users': 'User',
        'tags': 'Tag'
    }
    getter_map = {
        'form_searches': h.get_mini_dicts_getter('FormSearch'),
        'users': h.get_mini_dicts_getter('User'),
        'tags': h.get_mini_dicts_getter('Tag'),
        'corpus_formats': lambda: h.corpus_formats.keys()
    }
    return h.get_data_for_new_action(GET_params, getter_map, model_name_map, mandatory_attributes)
コード例 #4
0
ファイル: applicationsettings.py プロジェクト: jrwdunham/old
def get_new_application_settings_data(GET_params):
    """Return the data necessary to create a new application settings or update an existing one.
    
    :param GET_params: the ``request.GET`` dictionary-like object generated by
        Pylons which contains the query string parameters of the request.
    :returns: A dictionary whose values are lists of objects needed to create or
        update application settings.

    If ``GET_params`` has no keys, then return all required data.  If
    ``GET_params`` does have keys, then for each key whose value is a non-empty
    string (and not a valid ISO 8601 datetime) add the appropriate list of
    objects to the return dictionary.  If the value of a key is a valid ISO 8601
    datetime string, add the corresponding list of objects *only* if the
    datetime does *not* match the most recent ``datetime_modified`` value of the
    resource.  That is, a non-matching datetime indicates that the requester has
    out-of-date data.

    """

    # model_name_map maps param names to the OLD model objects from which they are
    # derived.
    model_name_map = {
        'users': 'User',
        'orthographies': 'Orthography',
        'languages': 'Language'
    }

    # getter_map maps param names to getter functions that retrieve the
    # appropriate data from the db.
    getter_map = {
        'users': h.get_mini_dicts_getter('User'),
        'orthographies': h.get_mini_dicts_getter('Orthography'),
        'languages': h.get_languages
    }

    result = h.get_data_for_new_action(GET_params, getter_map, model_name_map)

    return result
コード例 #5
0
ファイル: morphologies.py プロジェクト: jrwdunham/old
def get_data_for_new_edit(GET_params):
    """Return the data needed to create a new morphology or edit one."""
    model_name_map = {'corpora': 'Corpus'}
    getter_map = {'corpora': h.get_mini_dicts_getter('Corpus')}
    return h.get_data_for_new_action(GET_params, getter_map, model_name_map)