├── brain_dump ├── __init__.py ├── cli │ ├── __init__.py │ ├── wisemapping_wxml2xml.py │ ├── graphviz_md2png.py │ └── wisemapping_md2xml.py ├── parsers │ ├── __init__.py │ ├── pseudo_markdown.py │ └── indented_text_graph.py ├── wisemapping_xml.py ├── graphviz.py └── twilio_webhook_gitdb_app.py ├── pytest.ini ├── .gitignore ├── .pylintrc ├── examples ├── seasons.md ├── basic.md ├── icons.md └── welcome.md ├── .travis.yml ├── .pre-commit-config.yaml ├── pyproject.toml ├── CHANGELOG.md ├── tests ├── test_indented_text_graph_parser.py ├── test_wisemapping_xml.py └── test_pseudo_markdown_parser.py ├── README.md ├── poetry.lock └── LICENSE.txt /brain_dump/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /brain_dump/cli/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /brain_dump/parsers/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pytest.ini: -------------------------------------------------------------------------------- 1 | [pytest] 2 | python_paths = . 3 | addopts = --cov=brain_dump --cov-report=term-missing 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__/ 2 | *.pyc 3 | *.dot 4 | *.png 5 | *.xml 6 | 7 | .eggs/ 8 | *.egg-info/ 9 | 10 | /build/ 11 | /dist/ 12 | 13 | /.cache/ 14 | /.coverage 15 | -------------------------------------------------------------------------------- /.pylintrc: -------------------------------------------------------------------------------- 1 | [MESSAGES CONTROL] 2 | disable = import-error, line-too-long, missing-docstring, multiple-imports, protected-access, too-many-arguments, too-many-locals, ungrouped-imports -------------------------------------------------------------------------------- /examples/seasons.md: -------------------------------------------------------------------------------- 1 | Winter 2 | december 3 | january 4 | february 5 | Spring 6 | march 7 | april 8 | may 9 | Summer 10 | june 11 | july 12 | august 13 | Autumn 14 | september 15 | october 16 | november 17 | -------------------------------------------------------------------------------- /examples/basic.md: -------------------------------------------------------------------------------- 1 | Markdown styles 2 | Font styles 3 | **bold** 4 | __italic__ 5 | __**bold italic**__ 6 | Hyperlinks 7 | [My blog](https://chezsoi.org/lucas/blog) 8 | ![](https://chezsoi.org/lucas/blog/content/images/2014/Jul/bw-2.jpg) 9 | 10 | -------------------------------------------------------------------------------- /brain_dump/cli/wisemapping_wxml2xml.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | import xml.dom.minidom, sys 4 | 5 | 6 | def main(): 7 | with open(sys.argv[1]) as xml_file: 8 | tree = xml.dom.minidom.parseString(xml_file.read()) 9 | xml_map = tree.getElementsByTagName('xml')[0].childNodes[0].wholeText 10 | pretty_xml = xml.dom.minidom.parseString(xml_map).toprettyxml(indent=' ') 11 | print(pretty_xml) 12 | 13 | 14 | if __name__ == '__main__': 15 | main() 16 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: 3 | - "3.6" 4 | - "3.7-dev" 5 | install: 6 | - curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python 7 | - $HOME/.poetry/bin/poetry install 8 | addons: 9 | apt: 10 | packages: 11 | - graphviz 12 | script: 13 | - pre-commit run --all-files 14 | - wisemapping_md2xml examples/basic.md 15 | - wisemapping_md2xml examples/icons.md 16 | - wisemapping_md2xml examples/welcome.md 17 | - graphviz_md2png examples/seasons.md 18 | notifications: 19 | email: 20 | on_success: never -------------------------------------------------------------------------------- /examples/icons.md: -------------------------------------------------------------------------------- 1 | Icons 2 | chart_pie !icon=chart_pie 3 | bomb !icon=bomb 4 | face_smile !icon=face_smile 5 | object_cake !cion=object_cake 6 | object_house !icon=object_house 7 | object_key !icon=object_key 8 | object_magnifier !icon=object_magnifier 9 | object_music !icon=object_music 10 | object_star !icon=object_star 11 | object_wizard !icon=object_wizard 12 | sign_cancel !icon=sign_cancel 13 | sign_closed !icon=sign_closed 14 | sign_exclamation !icon=sign_exclamation 15 | sign_help !icon=sign_help 16 | sign_info !icon=sign_info 17 | sign_stop !icon=sign_stop 18 | sign_warning !icon=sign_warning 19 | ... 20 | 21 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: git://github.com/pre-commit/pre-commit-hooks 3 | rev: v2.2.1 4 | hooks: 5 | - id: check-merge-conflict 6 | - id: debug-statements 7 | - id: double-quote-string-fixer 8 | - id: trailing-whitespace 9 | args: 10 | - --no-markdown-linebreak-ext 11 | - repo: git://github.com/Lucas-C/pre-commit-hooks 12 | rev: v1.1.6 13 | hooks: 14 | - id: remove-crlf 15 | - id: remove-tabs 16 | - repo: git://github.com/pre-commit/mirrors-pylint 17 | rev: v2.3.1 18 | hooks: 19 | - id: pylint 20 | args: 21 | - --rcfile=.pylintrc 22 | - --reports=no 23 | files: ^brain_dump/.+\.py$ 24 | - repo: local 25 | hooks: 26 | - id: py.test 27 | name: py.test 28 | language: system 29 | entry: sh -c py.test 30 | files: '' 31 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | # Minimum requirements for the build system to execute (PEP 518) 3 | requires = ["setuptools", "wheel"] # PEP 508 specifications. 4 | 5 | [tool.poetry] 6 | name = 'brain_dump' 7 | version = '1.1.5' 8 | description = 'Tools to generate mindmaps compatible from markdown-like text files, either as PNG with graphviz or as wisemapping-compatible XMLs' 9 | readme = 'README.md' 10 | authors = ['Lucas Cimon'] 11 | repository = 'http://github.com/Lucas-C/brain_dump' 12 | license = 'GPL-3.0' 13 | keywords = ['mindmap', 'graph', 'markdown', 'graphviz', 'parser'] 14 | 15 | [tool.poetry.dependencies] 16 | python = '^3.6' 17 | pydot = '*' 18 | pyparsing = '*' 19 | 20 | [tool.poetry.dev-dependencies] 21 | coverage = '*' 22 | pre-commit = '*' 23 | pytest = '*' 24 | pytest-cov = '*' 25 | pytest-pythonpath = '*' 26 | 27 | [tool.poetry.scripts] 28 | graphviz_md2png = 'brain_dump.cli.graphviz_md2png:main' 29 | wisemapping_md2xml = 'brain_dump.cli.wisemapping_md2xml:main' 30 | wisemapping_wxml2xml = 'brain_dump.cli.wisemapping_wxml2xml:main' 31 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. 3 | 4 | The format is based on [Keep a Changelog](http://keepachangelog.com/) 5 | and this project adheres to [Semantic Versioning](http://semver.org/). 6 | 7 | ## [1.1.5] - 2018-10-24 8 | ### Fixed 9 | - ModuleNotFoundError: No module named 'brain_dump.cli' - cf. https://github.com/Lucas-C/brain_dump/issues/2 10 | 11 | ## [1.1.4] - 2018-10-18 12 | ### Fixed 13 | - ModuleNotFoundError: No module named 'brain_dump.cli' - cf. https://github.com/Lucas-C/brain_dump/issues/2 14 | 15 | ## [1.1.3] - 2017-09-23 16 | ### Fixed 17 | - import fix in `twilio_webhook_gitdb_app.py` 18 | - using current directory as `git` repo in `twilio_webhook_gitdb_app.py`. 19 | 20 | ## [1.1.2] - 2017-09-23 21 | ### Fixed 22 | Future-proof: migrated most stuff from `setup.py` to `setup.cfg` 23 | 24 | ## [1.1.1] - 2017-09-22 25 | ### Fixed 26 | Minor doc & compatibility fixes 27 | 28 | ## [1.1.0] - 2017-09-22 29 | ### Fixed 30 | Rebranding as `brain_dump` 31 | 32 | ## [1.0.0] - 2017-09-22 33 | Initial publish version 34 | -------------------------------------------------------------------------------- /brain_dump/cli/graphviz_md2png.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | import argparse, shutil, subprocess, sys 4 | 5 | from brain_dump.graphviz import create_solarized_mindmap_img 6 | 7 | 8 | def main(argv=None): 9 | twopi_cmd_path = shutil.which('twopi') 10 | if not twopi_cmd_path: 11 | raise EnvironmentError('"twopi" command not available') 12 | print('Using command:', subprocess.check_output([twopi_cmd_path, '-V'], stderr=subprocess.STDOUT).decode('utf8'), end='', file=sys.stderr) 13 | args = parse_args(argv) 14 | create_solarized_mindmap_img(**args.__dict__) 15 | 16 | def parse_args(argv=None): 17 | parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, fromfile_prefix_chars='@') 18 | parser.add_argument('--layout', default='twopi', choices=('dot', 'fdp', 'neato', 'sfdp', 'twopi'), help=' ') 19 | parser.add_argument('--font', default='arial') 20 | parser.add_argument('--gen-dot-file', action='store_true') 21 | parser.add_argument('--hide-branches-from-id', type=int) 22 | parser.add_argument('--root-label') 23 | parser.add_argument('input_filepath') 24 | return parser.parse_args(argv) 25 | 26 | 27 | if __name__ == '__main__': 28 | main() 29 | -------------------------------------------------------------------------------- /examples/welcome.md: -------------------------------------------------------------------------------- 1 | Welcome To WiseMapping 2 | Try it Now! 3 | Double Click 4 | INS to insert 5 | Drag map to move 6 | Productivity !icon=chart_bar 7 | Share your ideas !icon=bulb_light_on 8 | ![](http://localhost:8000/wise-editor/src/main/webapp/images/logo-small.png) 9 | Brainstorming 10 | Visual 11 | Mind Mapping 12 | Share with Collegues 13 | Online 14 | Anyplace, Anytime 15 | Free!!! 16 | Web 2.0 Tool 17 | Collaborate 18 | No plugin required !icon=conn_disconnect 19 | Share 20 | Easy to use 21 | Features 22 | [Links to Sites](http://www.digg.com) 23 | Fonts 24 | Topic Color 25 | Topic Shapes 26 | Icons !icon=object_rainbow 27 | History Changes !icon=arrowc_turn_left 28 | -------------------------------------------------------------------------------- /brain_dump/cli/wisemapping_md2xml.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | import argparse 4 | 5 | from brain_dump.parsers.indented_text_graph import parse as parse_text_graph 6 | from brain_dump.wisemapping_xml import recursively_print_map 7 | 8 | 9 | PALETTES = { 10 | 'dark-solarized': ( # from http://ethanschoonover.com/solarized 11 | '#b58900', # yellow 12 | '#cb4b16', # orange 13 | '#6c71c4', # violet 14 | '#dc323f', # red 15 | '#268bd2', # blue 16 | '#d33682', # magenta 17 | '#2aa198', # cyan 18 | '#859900', # green 19 | '#939393', # grey 20 | ) 21 | } 22 | 23 | def main(argv=None): 24 | args = parse_args(argv) 25 | args.palette = None if args.palette == 'none' else PALETTES[args.palette] 26 | with open(args.input_filepath, encoding='utf8') as text_file: 27 | graph = parse_text_graph(text_file.read()) 28 | recursively_print_map(graph, args) 29 | 30 | def parse_args(argv=None): 31 | parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, fromfile_prefix_chars='@') 32 | parser.add_argument('--name', default='mindmap') 33 | parser.add_argument('--default-img-size', default='80,43') 34 | parser.add_argument('--shrink', action='store_true') 35 | parser.add_argument('--no-shrinking-edges', action='store_false', dest='shrinking_edges') 36 | parser.add_argument('--palette', choices=list(PALETTES.keys()) + ['none'], default='dark-solarized') 37 | parser.add_argument('--font-color', default='white') 38 | parser.add_argument('input_filepath') 39 | return parser.parse_args(argv) 40 | 41 | 42 | if __name__ == '__main__': 43 | main() 44 | -------------------------------------------------------------------------------- /tests/test_indented_text_graph_parser.py: -------------------------------------------------------------------------------- 1 | # USAGE: py.test tests/test_indented_text_graph_parser.py 2 | 3 | from brain_dump.parsers.indented_text_graph import parse as parse_graph 4 | 5 | import pytest 6 | 7 | 8 | @pytest.mark.parametrize('input_filepath', [ 9 | 'examples/basic.md', 10 | 'examples/icons.md', 11 | 'examples/welcome.md', 12 | ]) 13 | def test_parsing_file(input_filepath): 14 | with open(input_filepath) as txt_file: 15 | text = txt_file.read() 16 | if text[-1] == '\n': 17 | text = text[:-1] 18 | graph = parse_graph(text) 19 | out = [l.rstrip() for l in str(graph).splitlines()] 20 | expected = [l.rstrip() for l in text.splitlines()] 21 | from difflib import context_diff 22 | print('\n'.join(context_diff(expected, out))) 23 | assert out == expected 24 | 25 | text = 'A\n 1\n 2\nB\n 3\n é' 26 | graph_root = parse_graph(text) 27 | print(graph_root) 28 | assert len(graph_root.children) == 2 29 | assert len(graph_root.children[0].children) == 2 30 | assert graph_root.children[0].children[0].depth == 2 31 | parse_graph(text + '\n') 32 | parse_graph('A\n 1\nB A') 33 | try: 34 | parse_graph('') 35 | assert False 36 | except ValueError: 37 | pass 38 | try: 39 | parse_graph('\n\n') 40 | assert False 41 | except ValueError: 42 | pass 43 | try: 44 | parse_graph(' A') 45 | assert False 46 | except ValueError: 47 | pass 48 | try: 49 | parse_graph('A\n B') 50 | assert False 51 | except ValueError: 52 | pass 53 | try: 54 | parse_graph('A\n B') 55 | assert False 56 | except ValueError: 57 | pass 58 | print('All tests passed') 59 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![pypi\_version\_img](https://img.shields.io/pypi/v/brain_dump.svg?style=flat)](https://pypi.python.org/pypi/brain_dump) [![pypi\_license\_img](https://img.shields.io/pypi/l/brain_dump.svg?style=flat)](https://pypi.python.org/pypi/brain_dump) [![travis\_build\_status](https://travis-ci.org/Lucas-C/brain_dump.svg?branch=master)](https://travis-ci.org/Lucas-C/brain_dump) [![snyk\_deps\_status](https://snyk.io/test/github/lucas-c/brain_dump/badge.svg)](https://snyk.io/test/github/lucas-c/brain_dump) 2 | 3 | Tools to generate mindmaps compatible from markdown-like text files, 4 | either as PNG with graphviz or as wisemapping-compatible XMLs. 5 | 6 | A viewer for those can be found here: 7 | 8 | Also include a [Twilio]() webhook that can 9 | receive updates for such markdown-like mindmap files, stored in git. 10 | 11 | For more information, I wrote some [blog posts]() 12 | explaining the role of those scripts. 13 | 14 | Usage 15 | ===== 16 | 17 | wisemapping_md2xml examples/welcome.md > welcome.xml 18 | 19 | graphviz_md2png examples/seasons.md 20 | 21 | Deployment 22 | ========== 23 | 24 | `upstart` job using `pew` & `uwsgi`: `/etc/init/brain_dump.conf` 25 | 26 | start on startup 27 | 28 | script 29 | set -o errexit -o nounset -o xtrace 30 | cd /path/to/git/dir 31 | exec >> upstart-stdout.log 32 | exec 2>> upstart-stderr.log 33 | date 34 | APP_SCRIPT=$(dirname $(pew-in brain_dump python -c 'import brain_dump; print(brain_dump.__file__)'))/twilio_webhook_gitdb_app.py 35 | LANG=fr_FR.UTF-8 pew-in brain_dump uwsgi --buffer-size 8000 --http :8087 --manage-script-name --mount /webhook=$APP_SCRIPT 36 | end script 37 | 38 | Changelog 39 | ========= 40 | 41 | 42 | 43 | Contributing 44 | ============ 45 | 46 | pip install -r dev-requirements 47 | pre-commit install 48 | 49 | The 2nd command install the [pre-commit hooks](http://pre-commit.com) 50 | 51 | To only execute a single unit test: 52 | 53 | py.test -k 'test_topic_from_line[toto-expected_topic0]' 54 | -------------------------------------------------------------------------------- /tests/test_wisemapping_xml.py: -------------------------------------------------------------------------------- 1 | # USAGE: py.test tests/test_wisemapping_xml.py 2 | 3 | from brain_dump.wisemapping_xml import topic_from_line, Topic 4 | 5 | import pytest 6 | 7 | 8 | @pytest.mark.parametrize(('line', 'expected_topic'), [ 9 | ('toto', Topic(text='toto', link=None, icons=(), attrs='', id=0, see=[])), 10 | ('[Framindmap](https://framindmap.org)', Topic(text='Framindmap', link='https://framindmap.org', icons=(), attrs='', id=0, see=[])), 11 | ('![coucou](http://website.com/favicon.ico)', Topic(text='coucou', link=None, icons=(), attrs='image=":http://website.com/favicon.ico" shape="image"', id=0, see=[])), 12 | ('!toto', Topic(text='!toto', link=None, icons=(), attrs='', id=0, see=[])), 13 | ('Productivity !icon=chart_bar ', Topic(text='Productivity', link=None, icons=('chart_bar',), attrs='bgColor="#d9b518" fontStyle=";;#104f11;;;"', id=0, see=[])), 14 | ('**toto**', Topic(text='toto', link=None, icons=(), attrs='fontStyle=";;;bold;;"', id=0, see=[])), 15 | ('__toto__', Topic(text='toto', link=None, icons=(), attrs='fontStyle=";;;;italic;"', id=0, see=[])), 16 | ('__**toto**__', Topic(text='toto', link=None, icons=(), attrs='fontStyle=";;;bold;italic;"', id=0, see=[])), 17 | ('**__toto__**', Topic(text='toto', link=None, icons=(), attrs='fontStyle=";;;bold;italic;"', id=0, see=[])), 18 | ('toto !icon=ahoy', Topic(text='toto', link=None, icons=('ahoy',), attrs='', id=0, see=[])), 19 | ('!icon=A toto !icon=B', Topic(text='toto', link=None, icons=('A', 'B'), attrs='', id=0, see=[])), 20 | ('![toto](http://website.com/favicon.ico 600x0400)', Topic(text='toto', link=None, icons=(), attrs='image="600x400:http://website.com/favicon.ico" shape="image"', id=0, see=[])), 21 | ('[x] toto', Topic(text='toto', link=None, icons=('tick_tick',), attrs='', id=0, see=[])), 22 | ('toto (see: "a ")', Topic(text='toto', link=None, icons=(), attrs='', id=0, see=['a'])), 23 | # TODO: require support for https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/text-decoration in mindplot/src/main/javascript/Topic.js line 356 & web2d/src/main/javascript/Text.js line 48 24 | ('~~toto~~', Topic(text='toto', link=None, icons=(), attrs='', id=0, see=[])), 25 | ]) 26 | def test_topic_from_line(line, expected_topic): 27 | assert topic_from_line(line) == expected_topic 28 | -------------------------------------------------------------------------------- /tests/test_pseudo_markdown_parser.py: -------------------------------------------------------------------------------- 1 | # USAGE: py.test tests/test_pseudo_markdown_parser.py 2 | 3 | from brain_dump.parsers.pseudo_markdown import LineGrammar 4 | 5 | import pytest 6 | 7 | 8 | @pytest.mark.parametrize('kwargs', [ 9 | dict(line='[Framindmap](https://framindmap.org)', text='Framindmap', url='https://framindmap.org'), 10 | dict(line='![coucou](http://website.com/favicon.ico)', text='coucou', url='http://website.com/favicon.ico', is_img=True), 11 | dict(line='![](http://website.com/favicon.ico 600x0400)', text='', url='http://website.com/favicon.ico', is_img=True, img_dims=(600, 400)), 12 | dict(line='!toto', text='!toto'), 13 | dict(line='Productivity !icon=chart_bar ', 14 | text='Productivity', icons=('chart_bar',), attrs='fontStyle=";;#104f11;;;" bgColor="#d9b518"'), 15 | dict(line='**toto**', text='toto', is_bold=True), 16 | dict(line='__toto__', text='toto', is_italic=True), 17 | dict(line='__**toto**__', text='toto', is_bold=True, is_italic=True), 18 | dict(line='**__toto__**', text='toto', is_bold=True, is_italic=True), 19 | dict(line='~~toto~~', text='toto', is_striked=True), 20 | dict(line='toto !icon=ahoy', text='toto', icons=('ahoy',)), 21 | dict(line='!icon=A toto !icon=B', text='toto', icons=('A','B')), 22 | dict(line='[ ] toto', text='toto', has_checkbox=True, is_checked=False), 23 | dict(line='[x] toto', text='toto', has_checkbox=True, is_checked=True), 24 | dict(line='toto (see: "a\\"","b,c")', text='toto', see=['a"','b,c']), 25 | ]) 26 | def test_parser(kwargs): 27 | parser_assertions(**kwargs) 28 | 29 | def parser_assertions(line, text, url='', icons=(), attrs='', is_bold=False, is_italic=False, is_striked=False, is_img=False, img_dims=None, has_checkbox=False, is_checked=False, see=''): 30 | parsed_line = LineGrammar.parseString(line, parseAll=True) 31 | print(parsed_line.dump()) 32 | assert (parsed_line.text or [''])[0].strip() == text, parsed_line.text 33 | assert bool(parsed_line.is_bold) == is_bold 34 | assert bool(parsed_line.is_italic) == is_italic 35 | assert bool(parsed_line.is_striked) == is_striked 36 | assert parsed_line.url == url 37 | assert bool(parsed_line.is_img) == is_img 38 | if img_dims or parsed_line.img_width or parsed_line.img_height: 39 | assert (int(parsed_line.img_width), int(parsed_line.img_height)) == img_dims 40 | assert bool(parsed_line.has_checkbox) == has_checkbox 41 | assert bool(parsed_line.is_checked) == is_checked 42 | assert tuple(parsed_line.icons) == icons 43 | assert parsed_line.attrs == attrs 44 | assert list(parsed_line.see) == list(see) 45 | -------------------------------------------------------------------------------- /brain_dump/parsers/pseudo_markdown.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | # pylint: disable=expression-not-assigned,invalid-name 4 | 5 | from pyparsing import CharsNotIn, Forward, Keyword, Literal, OneOrMore, Optional, QuotedString, Suppress, Token, White, Word, ZeroOrMore, delimitedList, nums, printables, ParseException 6 | 7 | 8 | class StopOnSuffix(Token): # inspired by CharsNotIn 9 | def __init__(self, suffixes): 10 | super().__init__() 11 | self.skipWhitespace = False 12 | self.suffixes = set(suffixes) 13 | self.name = self.__class__.__name__ 14 | self.mayReturnEmpty = True 15 | self.mayIndexError = False 16 | 17 | def parseImpl(self, instring, loc, doActions=True): 18 | if self._suffix_match(instring, loc): 19 | raise ParseException(instring, loc, '{} early stop : token starts with suffix'.format(self.name), self) 20 | start = loc 21 | maxlen = len(instring) 22 | loc += 1 23 | while loc < maxlen and not self._suffix_match(instring, loc): 24 | loc += 1 25 | return loc, instring[start:loc] 26 | 27 | def _suffix_match(self, instring, loc): 28 | for suffix in self.suffixes: 29 | suffix_length = len(suffix) 30 | if suffix == instring[loc:loc+suffix_length]: 31 | return True 32 | return False 33 | 34 | Bold = Suppress(Literal('**')) 35 | Italic = Suppress(Literal('__')) 36 | Striked = Suppress(Literal('~~')) 37 | Text = OneOrMore(Word(printables)) 38 | 39 | StyledText = Forward() 40 | BoldText = (Bold + StyledText + Bold)('is_bold') 41 | ItalicText = (Italic + StyledText + Italic)('is_italic') 42 | StrikedText = (Striked + StyledText + Striked)('is_striked') 43 | StyledText << (BoldText | ItalicText | StrikedText | StopOnSuffix(['**', '__', '~~', '!icon=', '']).setResultsName('attrs') + Literal('-->') 56 | 57 | Url = CharsNotIn(') ')('url') 58 | ImgDimensions = Word(nums)('img_width') + Literal('x') + Word(nums)('img_height') 59 | Link = Optional(Literal('!'))('is_img') + Literal('[') + Optional(StopOnSuffix(['](']).setResultsName('text', listAllMatches=True)) + Literal('](') + Url + Optional(ImgDimensions) + Literal(')') 60 | 61 | LineGrammar = Optional(Checkbox) + ZeroOrMore(Icon | XMLAttrs) + (Link | TextGrammar) + ZeroOrMore(Icon | XMLAttrs) + Optional(See) 62 | -------------------------------------------------------------------------------- /brain_dump/parsers/indented_text_graph.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | import sys 4 | 5 | 6 | def parse(text, root_label=None): 7 | if not text: 8 | raise ValueError('Empty graph') 9 | if text[-1] == '\n': 10 | text = text[:-1] 11 | root = GraphNode.create_root(root_label) 12 | last_nodes_per_depth = {0: root} 13 | last_node = None 14 | for i, line in enumerate(text.splitlines()): 15 | line = line.rstrip() 16 | value = line.lstrip() 17 | if not value: 18 | raise ValueError('Line {} is empty'.format(i + 1)) 19 | indent = len(line) - len(value) 20 | if indent % 4 != 0: 21 | raise ValueError('Incorrect indentation on line {}: not a mutiple of 4 spaces'.format(i + 1)) 22 | depth = 1 + indent / 4 23 | if last_node: 24 | if last_node.depth + 1 < depth: 25 | raise ValueError('Incorrect indentation on line {}: too much indent compared to previous line'.format(i + 1)) 26 | else: 27 | if depth != 1: 28 | raise ValueError('Incorrect indentation on line {}: first line must not have any indent'.format(i + 1)) 29 | parent_node = last_nodes_per_depth[depth - 1] 30 | last_node = parent_node.add_child(value) 31 | last_nodes_per_depth[last_node.depth] = last_node 32 | return root.set_single_child_as_root() 33 | 34 | 35 | class GraphNode: 36 | ROOT_DEFAULT_NAME = '<[root]>' 37 | 38 | @classmethod 39 | def create_root(cls, content): 40 | return cls(content or cls.ROOT_DEFAULT_NAME, parent=None, branch_id=0, known_contents=set()) 41 | 42 | def __init__(self, content, parent, branch_id=None, known_contents=None): 43 | self.content = content 44 | self.parent = parent 45 | self.children = [] 46 | self._branch_id = branch_id 47 | self._last_branch_id = branch_id 48 | self._known_contents = known_contents 49 | 50 | def add_child(self, content): 51 | while content and content in self.known_contents: 52 | print('Duplicate content found: {}. Using workaround'.format(content), file=sys.stderr) 53 | content = content + ' ' 54 | self.known_contents.add(content) 55 | branch_id = None if self.parent else self.incr_last_branch_id() 56 | child = self.__class__(content, parent=self, branch_id=branch_id) 57 | self.children.append(child) 58 | return child 59 | 60 | def set_single_child_as_root(self): 61 | assert not self.parent, 'This should only be called on a graph root' 62 | if self.content != self.ROOT_DEFAULT_NAME or len(self.children) != 1: 63 | return self 64 | old_root = self 65 | new_root = old_root.children[0] 66 | new_root._known_contents = old_root._known_contents 67 | new_root.parent = None 68 | new_root._reset_branch_ids() 69 | return new_root 70 | 71 | def _reset_branch_ids(self): 72 | assert not self.parent, 'This should only be called on a graph root' 73 | self._branch_id = 0 74 | self._last_branch_id = 0 75 | for child in self.children: 76 | child._branch_id = self.incr_last_branch_id() 77 | 78 | @property 79 | def branch_id(self): 80 | node = self 81 | while node._branch_id is None and node.parent: 82 | node = node.parent 83 | return node._branch_id 84 | 85 | @property 86 | def known_contents(self): 87 | node = self 88 | while node._known_contents is None and node.parent: 89 | node = node.parent 90 | return node._known_contents 91 | 92 | @property 93 | def depth(self): 94 | depth = 0 95 | node = self 96 | while node.parent: 97 | node = node.parent 98 | depth += 1 99 | return depth 100 | 101 | @property 102 | def height(self): 103 | if not self.children: 104 | return 1 105 | return 1 + max(child.height for child in self.children) 106 | 107 | def incr_last_branch_id(self): 108 | node = self 109 | while node._last_branch_id is None and node.parent: 110 | node = node.parent 111 | node._last_branch_id += 1 112 | return node._last_branch_id 113 | 114 | def __str__(self, indent=''): 115 | should_indent = self.content and self.content != self.ROOT_DEFAULT_NAME 116 | out = indent + self.content + '\n' if should_indent else '' 117 | if should_indent: 118 | indent += ' ' 119 | for child in self.children: 120 | out += child.__str__(indent) 121 | return out 122 | 123 | def __iter__(self): 124 | yield self 125 | for child in self.children: 126 | yield from child 127 | -------------------------------------------------------------------------------- /brain_dump/wisemapping_xml.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | from collections import namedtuple 4 | from itertools import count 5 | from xml.sax.saxutils import quoteattr 6 | 7 | from .parsers.pseudo_markdown import LineGrammar # require pyparsing 8 | 9 | Topic = namedtuple('Topic', ('text', 'id', 'link', 'icons', 'attrs', 'see')) 10 | 11 | 12 | def recursively_print_map(graph, args): 13 | print(''.format(args.name)) 14 | topics = list(extract_and_print_topics(graph, args, height=graph.height, counter=count())) 15 | topics_ids_per_text = {topic.text:topic.id for topic in topics} 16 | for topic in topics: 17 | for dest_topic_text in topic.see: 18 | dest_id = topics_ids_per_text[dest_topic_text] 19 | print(''.format(topic.id, dest_id)) 20 | print('') 21 | 22 | def extract_and_print_topics(node, args, height, counter, indent='', branch_id=None, order=None): 23 | indent += ' ' 24 | attrs = {} 25 | if order is None: 26 | attrs['central'] = 'true' 27 | else: 28 | attrs['order'] = order 29 | if branch_id is None: 30 | branch_id = order 31 | if args.shrink: 32 | attrs['shrink'] = 'true' 33 | # pylint: disable=stop-iteration-return 34 | topic = topic_from_line(node.content, 35 | tid=next(counter), 36 | edge_colors=args.palette, 37 | edge_width=2+2*(height-indent.count(' ')) if args.shrinking_edges else None, 38 | branch_id=branch_id, 39 | default_attrs=attrs, 40 | default_img_size=args.default_img_size, 41 | font_color=args.font_color) 42 | print('{}'.format(indent, topic.attrs, quoteattr(topic.text), topic.id)) 43 | if topic.link: 44 | print('{} '.format(indent, topic.link)) 45 | for icon in topic.icons: 46 | print('{} '.format(indent, icon)) 47 | yield topic 48 | for child_order, child in enumerate(node.children): 49 | yield from extract_and_print_topics(child, args, height=height, counter=counter, indent=indent, branch_id=branch_id, order=child_order) 50 | print('{}'.format(indent)) 51 | 52 | def topic_from_line(text_line, tid=0, edge_width=None, edge_colors=None, branch_id=None, default_attrs=None, default_img_size='', font_color=''): 53 | parsed_line = LineGrammar.parseString(text_line, parseAll=True) 54 | link = parsed_line.url 55 | attrs = {} 56 | if default_attrs: 57 | attrs.update(default_attrs) 58 | for key_value in parsed_line.attrs.split(): 59 | key, value = key_value.split('=') 60 | attrs[key.strip()] = value.strip()[1:-1] 61 | if parsed_line.is_img: 62 | attrs['shape'] = 'image' 63 | img_size = '{}x{}'.format(int(parsed_line.img_width), int(parsed_line.img_height)) if parsed_line.img_width and parsed_line.img_height else default_img_size 64 | attrs['image'] = '{}:{}'.format(img_size, link) 65 | link = None 66 | set_font_style_attr(attrs, parsed_line, font_color) 67 | if branch_id is not None: 68 | if edge_colors: 69 | attrs['edgeStrokeColor'] = edge_colors[branch_id % len(edge_colors)] 70 | if edge_width is not None: 71 | attrs['edgeStrokeWidth'] = edge_width 72 | attrs = ' '.join('{}="{}"'.format(k, v) for k, v in sorted(attrs.items())) 73 | icons = tuple(parsed_line.icons) 74 | if parsed_line.has_checkbox: 75 | icons = icons + ('tick_tick' if parsed_line.is_checked else 'tick_cross',) 76 | see = [dest_text.strip() for dest_text in list(parsed_line.see)] 77 | return Topic(text=(parsed_line.text or [''])[0].strip(), id=tid, link=link or None, icons=icons, attrs=attrs, see=see) 78 | 79 | def set_font_style_attr(attrs, parsed_line, default_font_color): 80 | font_size, font_family, font_color, bold, italic = '', '', '', '', '' 81 | if 'fontStyle' in attrs: 82 | font_size, font_family, font_color, bold, italic, _ = attrs['fontStyle'].split(';') 83 | if not font_color: 84 | font_color = default_font_color 85 | is_bold, is_italic, _ = bool(parsed_line.is_bold), bool(parsed_line.is_italic), bool(parsed_line.is_striked) 86 | if is_bold: 87 | bold = 'bold' 88 | if is_italic: 89 | italic = 'italic' 90 | if font_size or font_family or font_color or bold or italic: 91 | # cf. https://bitbucket.org/wisemapping/wisemapping-open-source/src/master/mindplot/src/main/javascript/persistence/XMLSerializer_Pela.js?at=develop&fileviewer=file-view-default#XMLSerializer_Pela.js-281 92 | attrs['fontStyle'] = '{};{};{};{};{};'.format(font_size, font_family, font_color, bold, italic) 93 | -------------------------------------------------------------------------------- /brain_dump/graphviz.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | # INSTALL: apt install graphviz / apt-cyg install graphviz (Cygwin) 4 | # pip install pydot 5 | # -> note: this dependancy could easily be removed as generating a .dot graph from a GraphNode 6 | # and calling twopi should be straightfoward, and allow to display stderr warnings like 'Pango-WARNING **: failed to choose a font, expect ugly output' 7 | # CYGWIN: I had an issue where symptoms were: no characaters rendered, only squares; a Pango-WARNING in twopi stderr; fc-list output empty 8 | # -> solution was to configure fontconfig to use the Windows fonts: 9 | # apt-cyg install xorg-x11-fonts-Type1 fontconfig 10 | # cat </etc/fonts/local.conf 11 | # 12 | # 13 | # 14 | # /c/Windows/Fonts 15 | # 16 | # EOF 17 | # fc-cache --verbose 18 | # fc-list 19 | # POTENTIAL EXTRA FEATURES: support for basic bold/italic Markdown markup: http://stackoverflow.com/a/30200953/636849 20 | 21 | import locale, pydot, sys 22 | from .parsers.indented_text_graph import parse as parse_text_graph 23 | 24 | 25 | def create_solarized_mindmap_img(input_filepath, layout='twopi', font='arial', hide_branches_from_id=None, gen_dot_file=False, root_label=None): 26 | assert locale.getdefaultlocale()[1] == 'UTF-8' # needed to print 'Duplicate content' warning without error and to bypass pydot Dot.write default raw formatting on line 1769 27 | with open(input_filepath) as txt_file: 28 | text = txt_file.read() 29 | outfile_basename = input_filepath.rsplit('.', 1)[0] 30 | theme = DarkSolarizedTheme(layout=layout, font=font) 31 | graph = parse_text_graph(text, root_label=root_label) 32 | create_mindmap(graph, outfile_basename, theme=theme, hide_branches_from_id=hide_branches_from_id, gen_dot_file=gen_dot_file) 33 | 34 | def create_mindmap(graph, outfile_basename, theme, hide_branches_from_id=None, gen_dot_file=False): 35 | graph_height = graph.height 36 | pygraph = pydot.Dot(root=graph.content, **theme.graph_style) 37 | for node in graph: 38 | content = pydot.quote_if_necessary(node.content) # avoid erroneous pydot 'port' detection + workaround this: https://github.com/erocarrera/pydot/issues/187 39 | pygraph.add_node(pydot.Node(content, **theme.node_style(node, graph_height, hide_branches_from_id))) 40 | if node.parent: 41 | parent_content = node.parent.content if ':' not in node.parent.content else '"{}"'.format(node.parent.content) 42 | pygraph.add_edge(pydot.Edge(parent_content, content, **theme.edge_style(node, graph_height, hide_branches_from_id))) 43 | if gen_dot_file: 44 | dot_outfile = '{}.dot'.format(outfile_basename) 45 | print('Generating', dot_outfile, file=sys.stderr) 46 | pygraph.write(dot_outfile, prog='twopi') 47 | png_outfile = '{}.png'.format(outfile_basename) 48 | print('Generating', png_outfile, file=sys.stderr) 49 | pygraph.write_png(png_outfile, prog='twopi') 50 | 51 | 52 | class DarkSolarizedTheme: 53 | DARKGREYBLUE = '#012b37' 54 | # Palette from http://ethanschoonover.com/solarized 55 | YELLOW = '#b58900' 56 | ORANGE = '#cb4b16' 57 | VIOLET = '#6c71c4' 58 | RED = '#dc323f' 59 | BLUE = '#268bd2' 60 | MAGENTA = '#d33682' 61 | CYAN = '#2aa198' 62 | GREEN = '#859900' 63 | GREY = '#939393' 64 | 65 | EDGE_COLORS = [YELLOW, ORANGE, VIOLET, RED, BLUE, MAGENTA, CYAN, GREEN, GREY] 66 | 67 | def __init__(self, layout, font): 68 | self.graph_style = dict( 69 | layout=layout, 70 | overlap='false', 71 | splines='curved', 72 | fontname=font, 73 | bgcolor=self.DARKGREYBLUE, 74 | ) 75 | 76 | def edge_style(self, dest_node, graph_height, hide_branches_from_id=None): 77 | color = self.graph_style['bgcolor'] if hide_branches_from_id is not None and dest_node.branch_id >= hide_branches_from_id \ 78 | else self.EDGE_COLORS[dest_node.branch_id % len(self.EDGE_COLORS)] 79 | return dict( 80 | color=color, 81 | dir='none', 82 | penwidth=2 * (2 + graph_height - dest_node.depth), 83 | ) 84 | 85 | def node_style(self, node, graph_height, hide_branches_from_id=None): 86 | color = self.graph_style['bgcolor'] if hide_branches_from_id is not None and node.branch_id >= hide_branches_from_id \ 87 | else 'white' 88 | label = node.content.strip() if node.content and node.content != node.ROOT_DEFAULT_NAME else '' 89 | return dict( 90 | group=node.branch_id, 91 | shape='plaintext', 92 | label=label, 93 | fontcolor=color, 94 | fontsize=2 * (16 + graph_height - node.depth), 95 | fontname=self.graph_style['fontname'], # not inherited by default 96 | ) 97 | -------------------------------------------------------------------------------- /brain_dump/twilio_webhook_gitdb_app.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Asumptions: 4 | # - the directory when this app is launched contains: 5 | # * a git repo 6 | # * a versionned `brain_dump.txt` file 7 | # - GIT_CMD_PATH exists 8 | 9 | # Typical use case scenario: 10 | # curl -v -XPOST -F Body=Foo $ENDPOINT 11 | # curl -v -XPOST -F Body=Foo$'\n'Bar $ENDPOINT 12 | # curl -v -XPOST -F Body=Foo $ENDPOINT 13 | # curl -v -XPOST -F Body=Foo.Foo$'\n'Bar $ENDPOINT 14 | 15 | import cgi, html, logging, logging.handlers, os, shlex, subprocess, traceback 16 | from contextlib import contextmanager 17 | from threading import Lock 18 | from brain_dump.parsers.indented_text_graph import parse as parse_text_graph 19 | try: 20 | from urlparse import parse_qsl 21 | except ImportError: 22 | from urllib.parse import parse_qsl 23 | 24 | ROOT_DIR = os.getcwd() 25 | LOG_FILE = os.path.join(ROOT_DIR, __file__.replace('.py', '.log')) 26 | LOG_FORMAT = '%(asctime)s - %(process)s [%(levelname)s] %(filename)s %(lineno)d %(message)s' 27 | TXT_DB_FILEPATH = os.path.join(ROOT_DIR, 'brain_dump.txt') 28 | GIT_CMD_PATH = '/usr/bin/git' 29 | 30 | 31 | def configure_logger(): 32 | logger = logging.getLogger(__name__) 33 | logger.setLevel(logging.DEBUG) 34 | file_handler = logging.handlers.RotatingFileHandler(LOG_FILE, maxBytes=1024**2, backupCount=10) 35 | file_handler.setFormatter(logging.Formatter(LOG_FORMAT)) 36 | logger.addHandler(file_handler) 37 | return logger 38 | 39 | def log(msg, lvl=logging.INFO): 40 | with _LOGGER_LOCK: 41 | _LOGGER.log(lvl, msg) 42 | 43 | _LOGGER = configure_logger() 44 | _LOGGER_LOCK = Lock() 45 | _TXT_DB_LOCK = Lock() 46 | log('Starting. Txt db file: {} Log file: {}'.format(TXT_DB_FILEPATH, LOG_FILE)) 47 | 48 | 49 | def application(env, start_response): 50 | path = env.get('PATH_INFO', '') 51 | method = env['REQUEST_METHOD'] 52 | query_params = parse_query_string(env['QUERY_STRING']) 53 | form = pop_form(env) 54 | log('Handling request: {} "{}" with query_params: "{}", form: "{}"'.format(method, path, query_params, form)) 55 | http_return_code = '200 OK' 56 | # pylint: disable=broad-except 57 | try: 58 | response = handle_request(method, path, query_params, form) 59 | except Exception: 60 | error_msg = traceback.format_exc() 61 | log('[ERROR] : {}'.format(error_msg), logging.ERROR) 62 | http_return_code = '500 Internal Server Error' 63 | response = html.escape(error_msg) 64 | start_response(http_return_code, [('Content-Type', 'application/xml')]) 65 | return [wrap_in_twiml(response).encode('utf8')] 66 | 67 | def wrap_in_twiml(msg): 68 | response = '' + msg + '' if msg else '' 69 | return '' + response + '' 70 | 71 | def pop_form(env): 72 | """ 73 | Should be called only ONCE because reading env['wsgi.input'] will empty the stream, 74 | hence we pop the value 75 | """ 76 | if 'wsgi.input' not in env: 77 | return None 78 | post_env = env.copy() 79 | post_env['QUERY_STRING'] = '' 80 | form = cgi.FieldStorage( 81 | fp=env.pop('wsgi.input'), 82 | environ=post_env, 83 | keep_blank_values=True 84 | ) 85 | return {k: form[k].value for k in form} 86 | 87 | def parse_query_string(query_string): 88 | qprm = dict(parse_qsl(query_string, True)) 89 | return {k: qprm[k] for k in qprm} 90 | 91 | def handle_request(method, path, query_params, form): 92 | assert method == 'POST' 93 | assert path == '/' 94 | assert not query_params 95 | assert 'Body' in form 96 | text = form['Body'] 97 | key, new_value = text.split('\n', 1) if '\n' in text else (text, '') 98 | key, new_value = key.strip(), new_value.strip() 99 | if not new_value: # => simple RETRIEVE request 100 | log('GET key="{}"'.format(key)) 101 | current_value = db_get(key) 102 | if not current_value: 103 | current_value = 'UNDEFINED' 104 | log('-> ' + str(current_value)) 105 | return key + '\n' + current_value 106 | log('PUT key="{}":value="{}"'.format(key, new_value)) 107 | db_put(key, *new_value.splitlines()) 108 | return None 109 | 110 | def db_get(key): 111 | graph = read_graph_from_txt_db() 112 | node = get_node_with_content(graph, key) 113 | if node: 114 | return '\n'.join(child.content for child in node.children) 115 | return None 116 | 117 | def db_put(key, *values): 118 | git('pull') 119 | with fetch_graph() as node: 120 | for key_frag in key.split('.'): 121 | matching_node = get_node_with_content(node, key_frag) 122 | if matching_node: 123 | node = matching_node 124 | else: 125 | node = node.add_child(key_frag) 126 | for value in values: 127 | if not get_node_with_content(node, value): 128 | node.add_child(value) 129 | git('commit', '-m', key + ': ' + '\n'.join(values), TXT_DB_FILEPATH) 130 | git('push') 131 | 132 | def git(*args): 133 | log(subprocess.check_output((GIT_CMD_PATH,) + shlex.quote(args), stderr=subprocess.STDOUT).decode('utf8')) 134 | 135 | @contextmanager 136 | def fetch_graph(): 137 | with _TXT_DB_LOCK: 138 | graph = read_graph_from_txt_db() 139 | yield graph 140 | write_graph_to_txt_db(graph) 141 | 142 | def get_node_with_content(graph, content): 143 | return next((node for node in graph.children if node.content == content), None) 144 | 145 | def read_graph_from_txt_db(): 146 | with open(TXT_DB_FILEPATH, encoding='utf8') as txt_file: 147 | return parse_text_graph(txt_file.read()) 148 | 149 | def write_graph_to_txt_db(graph): 150 | with open(TXT_DB_FILEPATH, 'wb') as txt_file: 151 | txt_file.write(str(graph).encode('utf8')) 152 | -------------------------------------------------------------------------------- /poetry.lock: -------------------------------------------------------------------------------- 1 | [[package]] 2 | category = "dev" 3 | description = "A few extensions to pyyaml." 4 | name = "aspy.yaml" 5 | optional = false 6 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" 7 | version = "1.2.0" 8 | 9 | [package.dependencies] 10 | pyyaml = "*" 11 | 12 | [[package]] 13 | category = "dev" 14 | description = "Atomic file writes." 15 | name = "atomicwrites" 16 | optional = false 17 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" 18 | version = "1.3.0" 19 | 20 | [[package]] 21 | category = "dev" 22 | description = "Classes Without Boilerplate" 23 | name = "attrs" 24 | optional = false 25 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" 26 | version = "19.1.0" 27 | 28 | [[package]] 29 | category = "dev" 30 | description = "Validate configuration and produce human readable error messages." 31 | name = "cfgv" 32 | optional = false 33 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" 34 | version = "1.6.0" 35 | 36 | [package.dependencies] 37 | six = "*" 38 | 39 | [[package]] 40 | category = "dev" 41 | description = "Cross-platform colored terminal text." 42 | marker = "sys_platform == \"win32\"" 43 | name = "colorama" 44 | optional = false 45 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" 46 | version = "0.4.1" 47 | 48 | [[package]] 49 | category = "dev" 50 | description = "Code coverage measurement for Python" 51 | name = "coverage" 52 | optional = false 53 | python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*, <4" 54 | version = "4.5.3" 55 | 56 | [[package]] 57 | category = "dev" 58 | description = "File identification library for Python" 59 | name = "identify" 60 | optional = false 61 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" 62 | version = "1.4.1" 63 | 64 | [[package]] 65 | category = "dev" 66 | description = "Read metadata from Python packages" 67 | name = "importlib-metadata" 68 | optional = false 69 | python-versions = ">=2.7,!=3.0,!=3.1,!=3.2,!=3.3" 70 | version = "0.9" 71 | 72 | [package.dependencies] 73 | zipp = ">=0.3.2" 74 | 75 | [[package]] 76 | category = "dev" 77 | description = "Read resources from Python packages" 78 | marker = "python_version < \"3.7\"" 79 | name = "importlib-resources" 80 | optional = false 81 | python-versions = ">=2.7,!=3.0,!=3.1,!=3.2,!=3.3" 82 | version = "1.0.2" 83 | 84 | [[package]] 85 | category = "dev" 86 | description = "More routines for operating on iterables, beyond itertools" 87 | marker = "python_version > \"2.7\"" 88 | name = "more-itertools" 89 | optional = false 90 | python-versions = ">=3.4" 91 | version = "7.0.0" 92 | 93 | [[package]] 94 | category = "dev" 95 | description = "Node.js virtual environment builder" 96 | name = "nodeenv" 97 | optional = false 98 | python-versions = "*" 99 | version = "1.3.3" 100 | 101 | [[package]] 102 | category = "dev" 103 | description = "plugin and hook calling mechanisms for python" 104 | name = "pluggy" 105 | optional = false 106 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" 107 | version = "0.9.0" 108 | 109 | [[package]] 110 | category = "dev" 111 | description = "A framework for managing and maintaining multi-language pre-commit hooks." 112 | name = "pre-commit" 113 | optional = false 114 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" 115 | version = "1.15.2" 116 | 117 | [package.dependencies] 118 | "aspy.yaml" = "*" 119 | cfgv = ">=1.4.0" 120 | identify = ">=1.0.0" 121 | importlib-metadata = "*" 122 | nodeenv = ">=0.11.1" 123 | pyyaml = "*" 124 | six = "*" 125 | toml = "*" 126 | virtualenv = ">=15.2" 127 | 128 | [package.dependencies.importlib-resources] 129 | python = "<3.7" 130 | version = "*" 131 | 132 | [[package]] 133 | category = "dev" 134 | description = "library with cross-python path, ini-parsing, io, code, log facilities" 135 | name = "py" 136 | optional = false 137 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" 138 | version = "1.8.0" 139 | 140 | [[package]] 141 | category = "main" 142 | description = "Python interface to Graphviz's Dot" 143 | name = "pydot" 144 | optional = false 145 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" 146 | version = "1.4.1" 147 | 148 | [package.dependencies] 149 | pyparsing = ">=2.1.4" 150 | 151 | [[package]] 152 | category = "main" 153 | description = "Python parsing module" 154 | name = "pyparsing" 155 | optional = false 156 | python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" 157 | version = "2.4.0" 158 | 159 | [[package]] 160 | category = "dev" 161 | description = "pytest: simple powerful testing with Python" 162 | name = "pytest" 163 | optional = false 164 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" 165 | version = "4.4.1" 166 | 167 | [package.dependencies] 168 | atomicwrites = ">=1.0" 169 | attrs = ">=17.4.0" 170 | colorama = "*" 171 | pluggy = ">=0.9" 172 | py = ">=1.5.0" 173 | setuptools = "*" 174 | six = ">=1.10.0" 175 | 176 | [package.dependencies.more-itertools] 177 | python = ">2.7" 178 | version = ">=4.0.0" 179 | 180 | [[package]] 181 | category = "dev" 182 | description = "Pytest plugin for measuring coverage." 183 | name = "pytest-cov" 184 | optional = false 185 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" 186 | version = "2.6.1" 187 | 188 | [package.dependencies] 189 | coverage = ">=4.4" 190 | pytest = ">=3.6" 191 | 192 | [[package]] 193 | category = "dev" 194 | description = "pytest plugin for adding to the PYTHONPATH from command line or configs." 195 | name = "pytest-pythonpath" 196 | optional = false 197 | python-versions = "*" 198 | version = "0.7.3" 199 | 200 | [package.dependencies] 201 | pytest = ">=2.5.2" 202 | 203 | [[package]] 204 | category = "dev" 205 | description = "YAML parser and emitter for Python" 206 | name = "pyyaml" 207 | optional = false 208 | python-versions = "*" 209 | version = "5.1" 210 | 211 | [[package]] 212 | category = "dev" 213 | description = "Python 2 and 3 compatibility utilities" 214 | name = "six" 215 | optional = false 216 | python-versions = ">=2.6, !=3.0.*, !=3.1.*" 217 | version = "1.12.0" 218 | 219 | [[package]] 220 | category = "dev" 221 | description = "Python Library for Tom's Obvious, Minimal Language" 222 | name = "toml" 223 | optional = false 224 | python-versions = "*" 225 | version = "0.10.0" 226 | 227 | [[package]] 228 | category = "dev" 229 | description = "Virtual Python Environment builder" 230 | name = "virtualenv" 231 | optional = false 232 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" 233 | version = "16.5.0" 234 | 235 | [[package]] 236 | category = "dev" 237 | description = "Pathlib-compatible object wrapper for zip files" 238 | name = "zipp" 239 | optional = false 240 | python-versions = ">=2.7" 241 | version = "0.3.3" 242 | 243 | [metadata] 244 | content-hash = "09fbc24aae512353005866f46470567f6b03d16c6fa10e3a1287f47dbabbd15d" 245 | python-versions = '^3.6' 246 | 247 | [metadata.hashes] 248 | "aspy.yaml" = ["ae249074803e8b957c83fdd82a99160d0d6d26dff9ba81ba608b42eebd7d8cd3", "c7390d79f58eb9157406966201abf26da0d56c07e0ff0deadc39c8f4dbc13482"] 249 | atomicwrites = ["03472c30eb2c5d1ba9227e4c2ca66ab8287fbfbbda3888aa93dc2e28fc6811b4", "75a9445bac02d8d058d5e1fe689654ba5a6556a1dfd8ce6ec55a0ed79866cfa6"] 250 | attrs = ["69c0dbf2ed392de1cb5ec704444b08a5ef81680a61cb899dc08127123af36a79", "f0b870f674851ecbfbbbd364d6b5cbdff9dcedbc7f3f5e18a6891057f21fe399"] 251 | cfgv = ["6e9f2feea5e84bc71e56abd703140d7a2c250fc5ba38b8702fd6a68ed4e3b2ef", "e7f186d4a36c099a9e20b04ac3108bd8bb9b9257e692ce18c8c3764d5cb12172"] 252 | colorama = ["05eed71e2e327246ad6b38c540c4a3117230b19679b875190486ddd2d721422d", "f8ac84de7840f5b9c4e3347b3c1eaa50f7e49c2b07596221daec5edaabbd7c48"] 253 | coverage = ["0c5fe441b9cfdab64719f24e9684502a59432df7570521563d7b1aff27ac755f", "2b412abc4c7d6e019ce7c27cbc229783035eef6d5401695dccba80f481be4eb3", "3684fabf6b87a369017756b551cef29e505cb155ddb892a7a29277b978da88b9", "39e088da9b284f1bd17c750ac672103779f7954ce6125fd4382134ac8d152d74", "3c205bc11cc4fcc57b761c2da73b9b72a59f8d5ca89979afb0c1c6f9e53c7390", "42692db854d13c6c5e9541b6ffe0fe921fe16c9c446358d642ccae1462582d3b", "465ce53a8c0f3a7950dfb836438442f833cf6663d407f37d8c52fe7b6e56d7e8", "48020e343fc40f72a442c8a1334284620f81295256a6b6ca6d8aa1350c763bbe", "4ec30ade438d1711562f3786bea33a9da6107414aed60a5daa974d50a8c2c351", "5296fc86ab612ec12394565c500b412a43b328b3907c0d14358950d06fd83baf", "5f61bed2f7d9b6a9ab935150a6b23d7f84b8055524e7be7715b6513f3328138e", "6899797ac384b239ce1926f3cb86ffc19996f6fa3a1efbb23cb49e0c12d8c18c", "68a43a9f9f83693ce0414d17e019daee7ab3f7113a70c79a3dd4c2f704e4d741", "6b8033d47fe22506856fe450470ccb1d8ba1ffb8463494a15cfc96392a288c09", "7ad7536066b28863e5835e8cfeaa794b7fe352d99a8cded9f43d1161be8e9fbd", "7bacb89ccf4bedb30b277e96e4cc68cd1369ca6841bde7b005191b54d3dd1034", "839dc7c36501254e14331bcb98b27002aa415e4af7ea039d9009409b9d2d5420", "8e679d1bde5e2de4a909efb071f14b472a678b788904440779d2c449c0355b27", "8f9a95b66969cdea53ec992ecea5406c5bd99c9221f539bca1e8406b200ae98c", "932c03d2d565f75961ba1d3cec41ddde00e162c5b46d03f7423edcb807734eab", "93f965415cc51604f571e491f280cff0f5be35895b4eb5e55b47ae90c02a497b", "988529edadc49039d205e0aa6ce049c5ccda4acb2d6c3c5c550c17e8c02c05ba", "998d7e73548fe395eeb294495a04d38942edb66d1fa61eb70418871bc621227e", "9de60893fb447d1e797f6bf08fdf0dbcda0c1e34c1b06c92bd3a363c0ea8c609", "9e80d45d0c7fcee54e22771db7f1b0b126fb4a6c0a2e5afa72f66827207ff2f2", "a545a3dfe5082dc8e8c3eb7f8a2cf4f2870902ff1860bd99b6198cfd1f9d1f49", "a5d8f29e5ec661143621a8f4de51adfb300d7a476224156a39a392254f70687b", "a9abc8c480e103dc05d9b332c6cc9fb1586330356fc14f1aa9c0ca5745097d19", "aca06bfba4759bbdb09bf52ebb15ae20268ee1f6747417837926fae990ebc41d", "bb23b7a6fd666e551a3094ab896a57809e010059540ad20acbeec03a154224ce", "bfd1d0ae7e292105f29d7deaa9d8f2916ed8553ab9d5f39ec65bcf5deadff3f9", "c22ab9f96cbaff05c6a84e20ec856383d27eae09e511d3e6ac4479489195861d", "c62ca0a38958f541a73cf86acdab020c2091631c137bd359c4f5bddde7b75fd4", "c709d8bda72cf4cd348ccec2a4881f2c5848fd72903c185f363d361b2737f773", "c968a6aa7e0b56ecbd28531ddf439c2ec103610d3e2bf3b75b813304f8cb7723", "ca58eba39c68010d7e87a823f22a081b5290e3e3c64714aac3c91481d8b34d22", "df785d8cb80539d0b55fd47183264b7002077859028dfe3070cf6359bf8b2d9c", "f406628ca51e0ae90ae76ea8398677a921b36f0bd71aab2099dfed08abd0322f", "f46087bbd95ebae244a0eda01a618aff11ec7a069b15a3ef8f6b520db523dcf1", "f8019c5279eb32360ca03e9fac40a12667715546eed5c5eb59eb381f2f501260", "fc5f4d209733750afd2714e9109816a29500718b32dd9a5db01c0cb3a019b96a"] 254 | identify = ["244e7864ef59f0c7c50c6db73f58564151d91345cd9b76ed793458953578cadd", "8ff062f90ad4b09cfe79b5dfb7a12e40f19d2e68a5c9598a49be45f16aba7171"] 255 | importlib-metadata = ["46fc60c34b6ed7547e2a723fc8de6dc2e3a1173f8423246b3ce497f064e9c3de", "bc136180e961875af88b1ab85b4009f4f1278f8396a60526c0009f503a1a96ca"] 256 | importlib-resources = ["6e2783b2538bd5a14678284a3962b0660c715e5a0f10243fd5e00a4b5974f50b", "d3279fd0f6f847cced9f7acc19bd3e5df54d34f93a2e7bb5f238f81545787078"] 257 | more-itertools = ["2112d2ca570bb7c3e53ea1a35cd5df42bb0fd10c45f0fb97178679c3c03d64c7", "c3e4748ba1aad8dba30a4886b0b1a2004f9a863837b8654e7059eebf727afa5a"] 258 | nodeenv = ["ad8259494cf1c9034539f6cced78a1da4840a4b157e23640bc4a0c0546b0cb7a"] 259 | pluggy = ["19ecf9ce9db2fce065a7a0586e07cfb4ac8614fe96edf628a264b1c70116cf8f", "84d306a647cc805219916e62aab89caa97a33a1dd8c342e87a37f91073cd4746"] 260 | pre-commit = ["2576a2776098f3902ef9540a84696e8e06bf18a337ce43a6a889e7fa5d26c4c5", "82f2f2d657d7f9280de9f927ae56886d60b9ef7f3714eae92d12713cd9cb9e11"] 261 | py = ["64f65755aee5b381cea27766a3a147c3f15b9b6b9ac88676de66ba2ae36793fa", "dc639b046a6e2cff5bbe40194ad65936d6ba360b52b3c3fe1d08a82dd50b5e53"] 262 | pydot = ["67be714300c78fda5fd52f79ec994039e3f76f074948c67b5ff539b433ad354f", "d49c9d4dd1913beec2a997f831543c8cbd53e535b1a739e921642fe416235f01"] 263 | pyparsing = ["1873c03321fc118f4e9746baf201ff990ceb915f433f23b395f5580d1840cb2a", "9b6323ef4ab914af344ba97510e966d64ba91055d6b9afa6b30799340e89cc03"] 264 | pytest = ["3773f4c235918987d51daf1db66d51c99fac654c81d6f2f709a046ab446d5e5d", "b7802283b70ca24d7119b32915efa7c409982f59913c1a6c0640aacf118b95f5"] 265 | pytest-cov = ["0ab664b25c6aa9716cbf203b17ddb301932383046082c081b9848a0edf5add33", "230ef817450ab0699c6cc3c9c8f7a829c34674456f2ed8df1fe1d39780f7c87f"] 266 | pytest-pythonpath = ["63fc546ace7d2c845c1ee289e8f7a6362c2b6bae497d10c716e58e253e801d62"] 267 | pyyaml = ["1adecc22f88d38052fb787d959f003811ca858b799590a5eaa70e63dca50308c", "436bc774ecf7c103814098159fbb84c2715d25980175292c648f2da143909f95", "460a5a4248763f6f37ea225d19d5c205677d8d525f6a83357ca622ed541830c2", "5a22a9c84653debfbf198d02fe592c176ea548cccce47553f35f466e15cf2fd4", "7a5d3f26b89d688db27822343dfa25c599627bc92093e788956372285c6298ad", "9372b04a02080752d9e6f990179a4ab840227c6e2ce15b95e1278456664cf2ba", "a5dcbebee834eaddf3fa7366316b880ff4062e4bcc9787b78c7fbb4a26ff2dd1", "aee5bab92a176e7cd034e57f46e9df9a9862a71f8f37cad167c6fc74c65f5b4e", "c51f642898c0bacd335fc119da60baae0824f2cde95b0330b56c0553439f0673", "c68ea4d3ba1705da1e0d85da6684ac657912679a649e8868bd850d2c299cce13", "e23d0cc5299223dcc37885dae624f382297717e459ea24053709675a976a3e19"] 268 | six = ["3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c", "d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73"] 269 | toml = ["229f81c57791a41d65e399fc06bf0848bab550a9dfd5ed66df18ce5f05e73d5c", "235682dd292d5899d361a811df37e04a8828a5b1da3115886b73cf81ebc9100e", "f1db651f9657708513243e61e6cc67d101a39bad662eaa9b5546f789338e07a3"] 270 | virtualenv = ["15ee248d13e4001a691d9583948ad3947bcb8a289775102e4c4aa98a8b7a6d73", "bfc98bb9b42a3029ee41b96dc00a34c2f254cbf7716bec824477b2c82741a5c4"] 271 | zipp = ["55ca87266c38af6658b84db8cfb7343cdb0bf275f93c7afaea0d8e7a209c7478", "682b3e1c62b7026afe24eadf6be579fb45fec54c07ea218bded8092af07a68c4"] 272 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . --------------------------------------------------------------------------------