semvec/pypi-packages huggingface dataset:
tokenmanager 0.0.1
Simple token manager for token-based REST APIs
License: BSD
Keywords: token manager rest api development helper utility

tokenmanager
============

Very simple. You have tokens for all your REST APIs. This library
manages them.

What is this for?
-----------------

In my own work, I find myself having to code up a solution to the
problem: "I need to connect to this REST API, but I don't want to have
the token saved in my code repo." The solutions often involve either
sourcing bash scripts with environment variables or saving some
out-of-repo config file with the needed token.

The goal of this library is to provide a dead simple solution. Create
a "dot" file (``~/.tokenmanager.yml``) with all of your tokens that
you can read from / write to when necessary.

Installation
------------

* Install using ``pip``::

    pip install tokenmanager

* Initialize the ``.tokenmanager.yml`` file in your home directory::

    python -m tokenmanager -i

Usage
-----

To add tokens, specify them using YAML syntax::

    service_a: 239e896bfe6f3b7705696c8cef84832e760b689a9633c454432fc407cb7a17af
    service_b: 18c553b119e52cb7d1ab93699865dab38d02d09d13b453258edf859ec075d9d9
    digitalocean:
      app1: a1e1c084540b51b33af3c6b63d48ede2937c8df92f7e6e3beb1f630ac750b851
      app2: 03593464105708646cc04d847ffc81c5b7775c462f68b573f2aff5d933635e17
    twilio:
      sid: WF32428983a878dv89df9xcfjn8d983298
      token: 0b51b33af3c6b63d48ede2937c8df92f
      number: '+12825552341'

To access them from Python::

    >>> tokens = tokenmanager.get_tokens()
    >>> tokens.service_a
    '239e896bfe6f3b7705696c8cef84832e760b689a9633c454432fc407cb7a17af'
    >>> tokens.digitalocean.app1
    'a1e1c084540b51b33af3c6b63d48ede2937c8df92f7e6e3beb1f630ac750b851'

To use from bash::

    $ python -m tokenmanager service_a
    239e896bfe6f3b7705696c8cef84832e760b689a9633c454432fc407cb7a17af
    $ python -m tokenmanager digitalocean.app1
    a1e1c084540b51b33af3c6b63d48ede2937c8df92f7e6e3beb1f630ac750b851
libparsing 0.9.2
Python wrapper for libparsing, a PEG-based parsing library written in C
License: BSD
Keywords: parsing PEG grammar libparsing

``libparsing`` is a parsing element grammar (PEG) library written in C
with *Python bindings*. It offers good performance while allowing for a
lot of flexibility. It is mainly intended to be used to create
programming languages and software engineering tools.

As opposed to more traditional parsing techniques, the grammar is not
compiled but constructed using an API that allows for the dynamic update
of the grammar.

The parser does not do any tokeninzation, instead, an input stream is
consumed and parsing elements are dynamically asked to match the next
element of it. Once parsing elements match, the resulting matched input
is processed and an action is triggered.

``libparsing`` supports the following features:

-  *backtracking*, ie. going back in the input stream if a match is not
   found
-  *cherry-picking*, ie. skipping unrecognized input
-  *contextual rules*, ie. a rule that will match or not depending on
   external variables

Parsing elements are usually slower than compiled or FSM-based parsers
as they trade performance for flexibility. It's probably not a great
idea to use ``libparsing`` if the parsing has to happen as fast as
possible (ie. a protocol implementation), but it is a great use for
programming languages, as it opens up the door to dynamic syntax
plug-ins and multiple language embedding.

If you're interested in PEG, you can start reading Brian Ford's original
article. Projects such as PEG/LEG by Ian Piumarta
http://piumarta.com/software/peg/ ,OMeta by Alessandro Warth
http://www.tinlizzie.org/ometa/ or Haskell's Parsec library
https://www.haskell.org/haskellwiki/Parsec are of particular interest in
the field.

Here is a short example of what creating a simple grammar looks like in
Python:

::

    g = Grammar()
    s = g.symbols
    g.token("WS",       "\s+")
    g.token("NUMBER",   "\d+(\.\d+)?")
    g.token("VARIABLE", "\w+")
    g.token("OPERATOR", "[\/\+\-\*]")
    g.group("Value",     s.NUMBER, s.VARIABLE)
    g.rule("Suffix",     s.OPERATOR._as("operator"), s.Value._as("value"))
    g.rule("Expression", s.Value, s.Suffix.zeroOrMore())
    g.axiom(s.Expression)
    g.skip(s.WS)
    match = g.parseString("10 + 20 / 5")

and the equivalent code in C

::

    Grammar* g = Grammar_new()
    SYMBOL(WS,         TOKEN("\\s+"))
    SYMBOL(NUMBER,     TOKEN("\\d+(\\.\\d+)?"))
    SYMBOL(VARIABLE,   TOKEN("\\w+"))
    SYMBOL(OPERATOR,   GROUP("[\\/\\+\\-\\*]"))
    SYMBOL(Value,      GOUP(_S(NUMBER), _S(VARIABLE)))
    SYMBOL(Suffix,     RULE(_AS(_S(OPERATOR), "operator"), _AS(_S(Value), "value")))
    SYMBOL(Expression, RULE(_S(Value), _MO(Suffix))
    g->axiom = s_Expression;
    g->skip(s_WS);
    Grammar_prepare(g);
    Match* match = Grammar_parseString(g, "10 + 20 / 5")