Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(1)  |  Call(0)  |  Derive(0)  |  Import(1)
name = translate(name, input_namespace, output_namespace, session={backend.create_session()})

Translate from one namespace to another.

Parameters
----------
name : str
    input name
input_namespace : str
    namespace to translate from (must be a known namespace)(more...)

        def translate(name, input_namespace, output_namespace, session=None):
    '''
    name = translate(name, input_namespace, output_namespace, session={backend.create_session()})

    Translate from one namespace to another.

    Parameters
    ----------
    name : str
        input name
    input_namespace : str
        namespace to translate from (must be a known namespace)
    output_namespace : str
        namespace to translate to (must be a known namespace)
    session : SQLAlchemy sesion object
        SQLAlchemy session to use (default: call backend.create_session())

    Returns
    -------
    name : str or None
        result of translation or None if not found.
    '''
    if session is None:
        session = waldo.backend.create_session()
    verify_namespace(input_namespace)
    verify_namespace(output_namespace)
    trans = session.query(Translation).filter(
                    and_(Translation.input_namespace == input_namespace,
                    Translation.input_name == name,
                    Translation.output_namespace ==  output_namespace)).first()
    if trans is None:
        if input_namespace == output_namespace:
            return name
        return None
    return trans.output_name
        


src/w/a/waldo-0.1/waldo/translations/__init__.py   waldo(Download)
from .services import translate