GithubHelp home page GithubHelp logo

chadiem / trello_2_any Goto Github PK

View Code? Open in Web Editor NEW

This project forked from trello-apps/trello_2_any

0.0 3.0 0.0 13 KB

Convert trello boards to any text format (markdown, asciidoc, Atlassian Confluence, ...) Edit

Python 100.00%

trello_2_any's Introduction

Trello 2 Any

Getting started

Install via setup.py

cd trello_2_any/
python setup.py install # or pip install .

Or, clone the repository from git and add its path to PYTHONPATH

$ git clone https://github.com/aayoubi/trello_2_any.git

$ export PYTHONPATH=trello_2_any/:$PYTHONPATH

$ python trello_2_any/bin/sample.py -h
usage: sample.py [-h] -c CLIENT_API_KEY -t TOKEN -b BOARD_ID

optional arguments:
  -h, --help            show this help message and exit
  -c CLIENT_API_KEY, --client-api-key CLIENT_API_KEY
                        your app's client api key
  -t TOKEN, --token TOKEN
                        your app's access token
  -b BOARD_ID, --board-id BOARD_ID
                        your trello board id

Access Tokens

In order to be able to access your Trello's boards, first you need to generate an access token.

  1. Go to https://trello.com/app-key, and retrieve your application key.
  2. Run ./bin/generate_access_token.py as described below and open the link it prints.
$ python bin/generate_access_token.py -h
usage: generate_access_token.py [-h] -c CLIENT_API_KEY -a APP_NAME
                                [-e EXPIRATION] [-w]

optional arguments:
  -h, --help            show this help message and exit
  -c CLIENT_API_KEY, --client-api-key CLIENT_API_KEY
                        your app's client api key
  -a APP_NAME, --app-name APP_NAME
                        your app's name
  -e EXPIRATION, --expiration EXPIRATION
                        the token's expiration, defaults to 30days
  -w, --write-access    the token has write access


$ python ./bin/generate_access_token.py --client-api-key <my_app_key> --app-name TEST
Access the following link to generate your access token:
https://trello.com/1/authorize?key=my_app_key&name=TEST&expiration=30days&response_type=token&scope=read
  1. Copy the generated token to someplace safe!

Available Transformers

  • Markdown
  • AsciiDoc
  • Atlassian Confluence

Sample

The following will retrieve all Trello lists from a given Trello board, and print it to stdout using a specific transformer:

trello = TrelloApi(args['client_api_key'])
trello.set_token(args['token'])
extraction = TrelloExtraction(trello, args['board_id'])
print(extraction.apply_transformer(MarkdownTransformer()))

Jinja2 Templating

You can also apply a Jinja2 template to render the board items.

The rendering is called with the following context:

  • {'title', board_name, 'board_lists': board_lists}
    • board_lists is a list of List = namedtuple('List', ['id', 'name', 'cards'])
    • cards is a list of Card = namedtuple('Card', ['id', 'name', 'comments', 'voters'])
    • comments is a list of Comment = namedtuple('Comment', ['text', 'author'])
    • voters is a list of strings containing the full name of each voter

An example is given in bin/jinja_template.py.

extraction = TrelloExtraction(trello, args['board_id'])

template = '''
# {{ title }}

{% for board_list in board_lists %}
## {{ board_list.name }}
    {% for card in board_list.cards %}
- {{ card.name }}
        {% if card.comments %}
            {% for comment in card.comments %}
    - comment by {{ comment.author }}: {{ comment.text }}
            {% endfor %}
        {% endif %}
        {% if card.voters %}
    - {{ card.voters|length }} vote(s), by: {{ card.voters | join(', ') }}
        {% endif %}
    {% endfor %}

{% endfor %}
'''
extraction.apply_template(jinja2.Template(template,
                                          trim_blocks=True,
                                          lstrip_blocks=True))

Compatibility

It is compatible with both python 2.7+ and python 3.4+. Py3 requires the installation of trello3 which is not available on pypi.

trello_2_any's People

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.