How to use the clldutils.misc.encoded function in clldutils

To help you get started, we’ve selected a few clldutils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github clld / clld / src / clld / lib / rdf.py View on Github external
def convert(string, from_, to_):
    if from_ == to_:
        return encoded(string)
    assert from_ in FORMATS and (to_ is None or to_ in FORMATS)
    g = Graph()
    g.parse(io.BytesIO(encoded(string)), format=from_)
    if to_ is None:
        return g
    out = io.BytesIO()
    g.serialize(out, format=to_)
    out.seek(0)
    return out.read()
github clld / clld / src / clld / lib / coins.py View on Github external
def _encoded(value):
    if not isinstance(value, bytes) and not isinstance(value, str):
        value = '%s' % value
    return encoded(value)
github clld / clld / src / clld / lib / bibutils.py View on Github external
def convert(string, from_, to_=None):
    assert from_ in FORMATS and (to_ is None or to_ in FORMATS)

    res = pipe('%s2xml -i utf8 -o utf8' % from_, encoded(string))
    if to_:
        res = pipe('xml2%s -i utf8 -o utf8' % to_, res)
    return res.decode('utf8')
github clld / clld / src / clld / lib / bibutils.py View on Github external
def pipe(cmd, input_):
    proc = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE, shell=True)
    return proc.communicate(encoded(input_))[0]
github clld / clld / src / clld / lib / rdf.py View on Github external
def convert(string, from_, to_):
    if from_ == to_:
        return encoded(string)
    assert from_ in FORMATS and (to_ is None or to_ in FORMATS)
    g = Graph()
    g.parse(io.BytesIO(encoded(string)), format=from_)
    if to_ is None:
        return g
    out = io.BytesIO()
    g.serialize(out, format=to_)
    out.seek(0)
    return out.read()