├── .hgignore ├── MANIFEST.in ├── Makefile ├── README.md ├── README.txt ├── TODOLIST.org ├── example.py ├── gantt ├── __init__.py ├── gantt.py └── test_gantt.py ├── gpl-3.0.txt ├── org2gantt ├── Orgnode.py ├── README.org ├── example.org ├── org2gantt.py └── taskjuggler.org ├── requirements-dev.in ├── requirements-dev.txt ├── requirements.in ├── requirements.txt ├── setup.py └── tox.ini /.hgignore: -------------------------------------------------------------------------------- 1 | syntax: glob 2 | *.pyc 3 | *~ 4 | .~lock.*# 5 | .#* 6 | *.deb 7 | README.txt 8 | MANIFEST 9 | build/* 10 | dist/* 11 | web 12 | web_upper 13 | gantt.html 14 | CHANGELOG 15 | python_gantt.egg-info/* 16 | python-gantt-[0-9].?.?/* 17 | org2gantt/*.svg 18 | *.svg 19 | gantt.egg-info/* 20 | htmlcov/* 21 | .tox/* 22 | docs/* 23 | 24 | syntax: regexp 25 | (.*/)?\#[^/]*\#$ 26 | (.*/)?\#[^/]*$ 27 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | #include *.txt 2 | include CHANGELOG 3 | include MANIFEST.in 4 | include Makefile 5 | include gpl-3.0.txt 6 | include setup.py 7 | include README.md 8 | include README.txt 9 | include requirements.txt 10 | include gantt/gantt.py 11 | include gantt/test_gantt.py 12 | include gantt/__init__.py 13 | include org2gantt/org2gantt.py 14 | include org2gantt/Orgnode.py 15 | include org2gantt/README.org 16 | include org2gantt/example.org 17 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # python-gantt Makefile 2 | 3 | VERSION=$(shell $(PYTHON) setup.py --version) 4 | ARCHIVE=$(shell $(PYTHON) setup.py --fullname) 5 | PYTHON=python3.4 6 | PANDOC=~/.cabal/bin/pandoc 7 | 8 | install: 9 | @$(PYTHON) setup.py install 10 | 11 | check_version_consistency: 12 | SETUPVERSION=$(shell python setup.py --version 2> /dev/null) 13 | PYTHOVERSION=$(shell python -c 'import gantt; print(gantt.__version__)') 14 | ifneq ($(shell python setup.py --version 2> /dev/null), $(shell python -c 'import gantt; print(gantt.__version__)')) 15 | $(error VERSION INCONSISTENCY between setup.py and gantt/gantt.py) 16 | endif 17 | 18 | archive: doc readme changelog 19 | @$(PYTHON) setup.py sdist 20 | @echo Archive is create and named dist/$(ARCHIVE).tar.gz 21 | @echo -n md5sum is : 22 | @md5sum dist/$(ARCHIVE).tar.gz 23 | 24 | license: 25 | @$(PYTHON) setup.py --license 26 | 27 | readme: 28 | @$(PANDOC) -f org -t markdown_github org2gantt/README.org -o org2gantt/README.txt 29 | @$(PANDOC) -f markdown -t rst README.md -o README.txt 30 | 31 | changelog: 32 | @hg shortlog |~/.cabal/bin/pandoc -f org -t plain > CHANGELOG 33 | 34 | 35 | test: 36 | nosetests gantt 37 | export PYTHONPATH=$(shell pwd)/gantt; $(PYTHON) org2gantt/org2gantt.py org2gantt/example.org -r -g test.py 38 | export PYTHONPATH=$(shell pwd)/gantt; $(PYTHON) test.py 39 | rm test.py 40 | 41 | tox: 42 | tox 43 | 44 | toxtest: 45 | nosetests gantt 46 | export PYTHONPATH=$(shell pwd)/gantt; $(PYTHON) org2gantt/org2gantt.py org2gantt/example.org -r -g test.py 47 | export PYTHONPATH=$(shell pwd)/gantt; $(PYTHON) test.py 48 | rm test.py 49 | 50 | conformity: 51 | pyflakes org2gantt/org2gantt.py 52 | pyflakes gantt/gantt.py 53 | flake8 org2gantt/org2gantt.py 54 | flake8 gantt/gantt.py 55 | 56 | 57 | pipregister: 58 | $(PYTHON) setup.py register 59 | 60 | register: 61 | $(PYTHON) setup.py sdist upload --identity="Alexandre Norman" --sign --quiet 62 | 63 | doc: 64 | @pydoc -w gantt/gantt.py 65 | 66 | web: 67 | @cp dist/$(ARCHIVE).tar.gz web2/ 68 | @m4 -DVERSION=$(VERSION) -DMD5SUM=$(shell md5sum dist/$(ARCHIVE).tar.gz |cut -d' ' -f1) -DDATE=$(shell date +%Y-%m-%d) web2/index.md.m4 > web2/index.md 69 | @m4 -DVERSION=$(VERSION) -DMD5SUM=$(shell md5sum dist/$(ARCHIVE).tar.gz |cut -d' ' -f1) -DDATE=$(shell date +%Y-%m-%d) web2/index-en.md.m4 > web2/index-en.md 70 | @bash -c 'source /usr/local/bin/virtualenvwrapper.sh; workon xael.org; make ftp_upload' 71 | 72 | hgcommit: 73 | @hg commit 74 | @hg tag $(VERSION) -f 75 | @hg push 76 | 77 | 78 | release: check_version_consistency tox doc changelog hgcommit register web 79 | 80 | 81 | .PHONY: web 82 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Python-Gantt # 2 | 3 | Python-Gantt make possible to easily draw gantt charts from Python. 4 | Output format is SVG. 5 | 6 | You can see output examples here : http://xael.org/pages/python-gantt-en.html 7 | 8 | ## Installation ## 9 | 10 | ### Requirements ### 11 | 12 | This projects needs the following libraries: 13 | 14 | * svgwrite see https://bitbucket.org/mozman/svgwrite/ 15 | * dateutil see https://labix.org/python-dateutil 16 | 17 | ### Additionnal requirements ### 18 | 19 | For using org2gantt script, the following libraries is needed: 20 | 21 | * clize, see https://github.com/epsy/clize 22 | 23 | 24 | ### Installation ### 25 | 26 | 27 | ``` 28 | python setup.py install 29 | ``` 30 | 31 | 32 | ## Example ## 33 | 34 | 35 | ``` 36 | #!/usr/bin/env python3 37 | # -*- coding: utf-8 -*- 38 | 39 | import datetime 40 | import gantt 41 | 42 | # Change font default 43 | gantt.define_font_attributes(fill='black', stroke='black', stroke_width=0, font_family="Verdana") 44 | 45 | # Add vacations for everyone 46 | gantt.add_vacations(datetime.date(2014, 12, 25)) 47 | gantt.add_vacations(datetime.date(2015, 1, 1)) 48 | gantt.add_vacations(datetime.date(2015, 1, 13)) 49 | 50 | # Create two resources 51 | rANO = gantt.Resource('ANO') 52 | rJLS = gantt.Resource('JLS') 53 | 54 | # Add vacations for one lucky resource 55 | rANO.add_vacations( 56 | dfrom=datetime.date(2014, 12, 29), 57 | dto=datetime.date(2015, 1, 4) 58 | ) 59 | rANO.add_vacations( 60 | dfrom=datetime.date(2015, 1, 6), 61 | dto=datetime.date(2015, 1, 8) 62 | ) 63 | 64 | # Test if this resource is avalaible for some dates 65 | print(rANO.is_available(datetime.date(2015, 1, 5))) 66 | print(rANO.is_available(datetime.date(2015, 1, 8))) 67 | print(rANO.is_available(datetime.date(2015, 1, 6))) 68 | print(rANO.is_available(datetime.date(2015, 1, 2))) 69 | print(rANO.is_available(datetime.date(2015, 1, 1))) 70 | 71 | 72 | # Create some tasks 73 | t1 = gantt.Task(name='tache1', start=datetime.date(2014, 12, 25), duration=4, percent_done=44, resources=[rANO], color="#FF8080") 74 | t2 = gantt.Task(name='tache2', start=datetime.date(2014, 12, 28), duration=6, resources=[rJLS]) 75 | t7 = gantt.Task(name='tache7', start=datetime.date(2014, 12, 28), duration=5, percent_done=50) 76 | t3 = gantt.Task(name='tache3', start=datetime.date(2014, 12, 25), duration=4, depends_of=[t1, t7, t2], resources=[rJLS]) 77 | t4 = gantt.Task(name='tache4', start=datetime.date(2015, 01, 01), duration=4, depends_of=t1, resources=[rJLS]) 78 | t5 = gantt.Task(name='tache5', start=datetime.date(2014, 12, 23), duration=3) 79 | t6 = gantt.Task(name='tache6', start=datetime.date(2014, 12, 25), duration=4, depends_of=t7, resources=[rANO]) 80 | t8 = gantt.Task(name='tache8', start=datetime.date(2014, 12, 25), duration=4, depends_of=t7, resources=[rANO, rJLS]) 81 | 82 | 83 | # Create a project 84 | p1 = gantt.Project(name='Projet 1') 85 | 86 | # Add tasks to this project 87 | p1.add_task(t1) 88 | p1.add_task(t7) 89 | p1.add_task(t2) 90 | p1.add_task(t3) 91 | p1.add_task(t5) 92 | p1.add_task(t8) 93 | 94 | 95 | 96 | # Create another project 97 | p2 = gantt.Project(name='Projet 2', color='#FFFF40') 98 | 99 | # Add tasks to this project 100 | p2.add_task(t2) 101 | p2.add_task(t4) 102 | 103 | 104 | # Create another project 105 | p = gantt.Project(name='Gantt') 106 | # wich contains the first two projects 107 | # and a single task 108 | p.add_task(p1) 109 | p.add_task(p2) 110 | p.add_task(t6) 111 | 112 | 113 | # Test cases for milestones 114 | # Create another project 115 | ptcm = gantt.Project(name='Test case for milestones') 116 | 117 | tcm11 = gantt.Task(name='tcm11', start=datetime.date(2014, 12, 25), duration=4) 118 | tcm12 = gantt.Task(name='tcm12', start=datetime.date(2014, 12, 26), duration=5) 119 | ms1 = gantt.Milestone(name=' ', depends_of=[tcm11, tcm12]) 120 | tcm21 = gantt.Task(name='tcm21', start=datetime.date(2014, 12, 30), duration=4, depends_of=[ms1]) 121 | tcm22 = gantt.Task(name='tcm22', start=datetime.date(2014, 12, 30), duration=6, depends_of=[ms1]) 122 | ms2 = gantt.Milestone(name='MS2', depends_of=[ms1, tcm21, tcm22]) 123 | tcm31 = gantt.Task(name='tcm31', start=datetime.date(2014, 12, 30), duration=6, depends_of=[ms2]) 124 | ms3 = gantt.Milestone(name='MS3', depends_of=[ms1]) 125 | 126 | 127 | ptcm.add_task(tcm11) 128 | ptcm.add_task(tcm12) 129 | ptcm.add_task(ms1) 130 | ptcm.add_task(tcm21) 131 | ptcm.add_task(tcm22) 132 | ptcm.add_task(ms2) 133 | ptcm.add_task(tcm31) 134 | ptcm.add_task(ms3) 135 | 136 | 137 | p.add_task(ptcm) 138 | 139 | 140 | ##########################$ MAKE DRAW ############### 141 | p.make_svg_for_tasks(filename='test_full.svg', today=datetime.date(2014, 12, 31), start=datetime.date(2014,8, 22), end=datetime.date(2015, 01, 14)) 142 | p.make_svg_for_tasks(filename='test_full2.svg', today=datetime.date(2014, 12, 31)) 143 | p.make_svg_for_tasks(filename='test.svg', today=datetime.date(2014, 12, 31), start=datetime.date(2015, 01, 3), end=datetime.date(2015, 01, 06)) 144 | p1.make_svg_for_tasks(filename='test_p1.svg', today=datetime.date(2014, 12, 31)) 145 | p2.make_svg_for_tasks(filename='test_p2.svg', today=datetime.date(2014, 12, 31)) 146 | p.make_svg_for_resources(filename='test_resources.svg', today=datetime.date(2014, 12, 31), resources=[rANO, rJLS]) 147 | p.make_svg_for_tasks(filename='test_weekly.svg', today=datetime.date(2014, 12, 31), scale=gantt.DRAW_WITH_WEEKLY_SCALE) 148 | ##########################$ /MAKE DRAW ############### 149 | ``` 150 | 151 | 152 | 153 | 154 | ## Licence ## 155 | 156 | GPL v3 or any later version 157 | 158 | 159 | ## Author ## 160 | 161 | Alexandre Norman (norman at xael.org) -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | Python-Gantt 2 | ============ 3 | 4 | | Python-Gantt make possible to easily draw gantt charts from Python. 5 | | Output format is SVG. 6 | 7 | Installation 8 | ------------ 9 | 10 | Requirements 11 | ~~~~~~~~~~~~ 12 | 13 | This projects needs the following libraries: 14 | 15 | - svgwrite see https://bitbucket.org/mozman/svgwrite/ 16 | - dateutil see https://labix.org/python-dateutil 17 | 18 | Additionnal requirements 19 | ~~~~~~~~~~~~~~~~~~~~~~~~ 20 | 21 | For using org2gantt script, the following libraries is needed: 22 | 23 | - clize, see https://github.com/epsy/clize 24 | 25 | Installation 26 | ~~~~~~~~~~~~ 27 | 28 | :: 29 | 30 | python setup.py install 31 | 32 | Example 33 | ------- 34 | 35 | :: 36 | 37 | #!/usr/bin/env python3 38 | # -*- coding: utf-8 -*- 39 | 40 | import datetime 41 | import gantt 42 | 43 | # Change font default 44 | gantt.define_font_attributes(fill='black', stroke='black', stroke_width=0, font_family="Verdana") 45 | 46 | # Add vacations for everyone 47 | gantt.add_vacations(datetime.date(2014, 12, 25)) 48 | gantt.add_vacations(datetime.date(2015, 1, 1)) 49 | gantt.add_vacations(datetime.date(2015, 1, 13)) 50 | 51 | # Create two resources 52 | rANO = gantt.Resource('ANO') 53 | rJLS = gantt.Resource('JLS') 54 | 55 | # Add vacations for one lucky resource 56 | rANO.add_vacations( 57 | dfrom=datetime.date(2014, 12, 29), 58 | dto=datetime.date(2015, 1, 4) 59 | ) 60 | rANO.add_vacations( 61 | dfrom=datetime.date(2015, 1, 6), 62 | dto=datetime.date(2015, 1, 8) 63 | ) 64 | 65 | # Test if this resource is avalaible for some dates 66 | print(rANO.is_available(datetime.date(2015, 1, 5))) 67 | print(rANO.is_available(datetime.date(2015, 1, 8))) 68 | print(rANO.is_available(datetime.date(2015, 1, 6))) 69 | print(rANO.is_available(datetime.date(2015, 1, 2))) 70 | print(rANO.is_available(datetime.date(2015, 1, 1))) 71 | 72 | 73 | # Create some tasks 74 | t1 = gantt.Task(name='tache1', start=datetime.date(2014, 12, 25), duration=4, percent_done=44, resources=[rANO], color="#FF8080") 75 | t2 = gantt.Task(name='tache2', start=datetime.date(2014, 12, 28), duration=6, resources=[rJLS]) 76 | t7 = gantt.Task(name='tache7', start=datetime.date(2014, 12, 28), duration=5, percent_done=50) 77 | t3 = gantt.Task(name='tache3', start=datetime.date(2014, 12, 25), duration=4, depends_of=[t1, t7, t2], resources=[rJLS]) 78 | t4 = gantt.Task(name='tache4', start=datetime.date(2015, 01, 01), duration=4, depends_of=t1, resources=[rJLS]) 79 | t5 = gantt.Task(name='tache5', start=datetime.date(2014, 12, 23), duration=3) 80 | t6 = gantt.Task(name='tache6', start=datetime.date(2014, 12, 25), duration=4, depends_of=t7, resources=[rANO]) 81 | t8 = gantt.Task(name='tache8', start=datetime.date(2014, 12, 25), duration=4, depends_of=t7, resources=[rANO, rJLS]) 82 | 83 | 84 | # Create a project 85 | p1 = gantt.Project(name='Projet 1') 86 | 87 | # Add tasks to this project 88 | p1.add_task(t1) 89 | p1.add_task(t7) 90 | p1.add_task(t2) 91 | p1.add_task(t3) 92 | p1.add_task(t5) 93 | p1.add_task(t8) 94 | 95 | 96 | 97 | # Create another project 98 | p2 = gantt.Project(name='Projet 2', color='#FFFF40') 99 | 100 | # Add tasks to this project 101 | p2.add_task(t2) 102 | p2.add_task(t4) 103 | 104 | 105 | # Create another project 106 | p = gantt.Project(name='Gantt') 107 | # wich contains the first two projects 108 | # and a single task 109 | p.add_task(p1) 110 | p.add_task(p2) 111 | p.add_task(t6) 112 | 113 | 114 | # Test cases for milestones 115 | # Create another project 116 | ptcm = gantt.Project(name='Test case for milestones') 117 | 118 | tcm11 = gantt.Task(name='tcm11', start=datetime.date(2014, 12, 25), duration=4) 119 | tcm12 = gantt.Task(name='tcm12', start=datetime.date(2014, 12, 26), duration=5) 120 | ms1 = gantt.Milestone(name=' ', depends_of=[tcm11, tcm12]) 121 | tcm21 = gantt.Task(name='tcm21', start=datetime.date(2014, 12, 30), duration=4, depends_of=[ms1]) 122 | tcm22 = gantt.Task(name='tcm22', start=datetime.date(2014, 12, 30), duration=6, depends_of=[ms1]) 123 | ms2 = gantt.Milestone(name='MS2', depends_of=[ms1, tcm21, tcm22]) 124 | tcm31 = gantt.Task(name='tcm31', start=datetime.date(2014, 12, 30), duration=6, depends_of=[ms2]) 125 | ms3 = gantt.Milestone(name='MS3', depends_of=[ms1]) 126 | 127 | 128 | ptcm.add_task(tcm11) 129 | ptcm.add_task(tcm12) 130 | ptcm.add_task(ms1) 131 | ptcm.add_task(tcm21) 132 | ptcm.add_task(tcm22) 133 | ptcm.add_task(ms2) 134 | ptcm.add_task(tcm31) 135 | ptcm.add_task(ms3) 136 | 137 | 138 | p.add_task(ptcm) 139 | 140 | 141 | ##########################$ MAKE DRAW ############### 142 | p.make_svg_for_tasks(filename='test_full.svg', today=datetime.date(2014, 12, 31), start=datetime.date(2014,8, 22), end=datetime.date(2015, 01, 14)) 143 | p.make_svg_for_tasks(filename='test_full2.svg', today=datetime.date(2014, 12, 31)) 144 | p.make_svg_for_tasks(filename='test.svg', today=datetime.date(2014, 12, 31), start=datetime.date(2015, 01, 3), end=datetime.date(2015, 01, 06)) 145 | p1.make_svg_for_tasks(filename='test_p1.svg', today=datetime.date(2014, 12, 31)) 146 | p2.make_svg_for_tasks(filename='test_p2.svg', today=datetime.date(2014, 12, 31)) 147 | p.make_svg_for_resources(filename='test_resources.svg', today=datetime.date(2014, 12, 31), resources=[rANO, rJLS]) 148 | p.make_svg_for_tasks(filename='test_weekly.svg', today=datetime.date(2014, 12, 31), scale=gantt.DRAW_WITH_WEEKLY_SCALE) 149 | ##########################$ /MAKE DRAW ############### 150 | 151 | Licence 152 | ------- 153 | 154 | GPL v3 or any later version 155 | 156 | Author 157 | ------ 158 | 159 | Alexandre Norman (norman at xael.org) 160 | -------------------------------------------------------------------------------- /TODOLIST.org: -------------------------------------------------------------------------------- 1 | #+TITLE: TODOLIST 2 | #+STARTUP: overview logdone hidestars 3 | #+DRAWERS: PROPERTIES NOTE LOGBOOK 4 | #+OPTIONS: ^:{} 5 | #+SEQ_TODO: TODO(t) STARTED(s) WAITING(w) SOMEDAY(y) | DONE(d) CANCELED(c) 6 | * DONE installation bug : 7 | - State "DONE" from "TODO" [2015-01-07 Wed 19:22] 8 | - Note taken on [2015-01-06 mar. 18:19] \\ 9 | pandoc could be installed as a binary 10 | - Note taken on [2015-01-06 mar. 17:13] \\ 11 | Add README.txt to the distribution 12 | #+begin_src shell-script 13 | $ sudo python setup.py install 14 | Traceback (most recent call last): 15 | File "setup.py", line 32, in 16 | long_description=open('README.txt').read(), 17 | IOError: [Errno 2] No such file or directory: 'README.txt' 18 | AN05392S@U1404:/media/sf_Personnel/ESPACE_KM/python-gantt 19 | #+end_src 20 | * DONE Group of tasks + inheritance for members if not overided (duration, resources, ordered) 21 | CLOSED: [2015-01-09 Fri 23:08] 22 | - Group have children 23 | - Task do not have children 24 | * DONE Bugs : Empty lines in project when not on screen 25 | - State "DONE" from "TODO" [2015-01-09 Fri 22:41] 26 | * DONE :no_gantt: tag inheritance 27 | CLOSED: [2015-01-10 Sat 10:20] 28 | * DONE Support common tags with http://orgmode.org/worg/org-tutorials/org-taskjuggler.html 29 | CLOSED: [2015-01-11 Sun 10:26] 30 | ** DONE Resources ID 31 | ** DONE Task ID 32 | - State "DONE" from "TODO" [2015-01-06 mar. 17:04] 33 | ** DONE Dependencies 34 | - State "DONE" from "TODO" [2015-01-09 Fri 22:40] 35 | - The ORDERED property which allows you to state that the child tasks have to be 36 | completed in the order they appear (top most first). 37 | - The BLOCKER property which allows you to state that a task depends on either a 38 | previous sibling ("previous-sibling") or any other task by stating the task_id 39 | property of the predecessor 40 | ** DONE Group of resources 41 | CLOSED: [2015-01-11 Sun 10:25] 42 | *** DONE for each group, check that nb of assigned task <= nb of members 43 | CLOSED: [2015-01-11 Sun 10:25] 44 | in example : tasks 11, 2, 7, 10 45 | * TODO check for orgfile consistency and error reporting 46 | ** TODO missing mandatory properties 47 | - [ ] Effort 48 | - [ ] task_id 49 | - [ ] resource_id 50 | - [X] scheduling / dependencies / deadline / effort 51 | ** DONE duplicate ID on resources 52 | - State "DONE" from "TODO" [2015-01-06 mar. 17:40] 53 | ** DONE duplicate ID on tasks 54 | - State "DONE" from "TODO" [2015-01-06 mar. 17:40] 55 | * DONE make a function to get if a resource or a resource in a group is available on a timeframe 56 | CLOSED: [2015-01-11 Sun 20:08] 57 | maybe a shell ? or option for the generated script ? 58 | * STARTED let change scale (display of weeks instead of days) 59 | ** DONE Week 60 | ** DONE Month 61 | ** TODO Vacations are only drawn for daily scale 62 | ** TODO Quaterly 63 | * SOMEDAY Support repetitive vacations (ie SCHEDULED DATE +1w or ++1w, +1y) 64 | use yield ? 65 | * DONE disconnect blocker assignation from task creation 66 | CLOSED: [2015-01-11 Sun 10:49] 67 | in order to have a task defined after. 68 | * DONE option to align task titles on the left 69 | CLOSED: [2015-06-06 Sat 23:54] 70 | > just an additional recommendation: For longer Task titles, they don't fit well into the barchart itself. 71 | > This is in particular the case when times are short (few months in my case). It would be therefore best, 72 | > if all Task names would be simply aligned as a list left to the actual diagram (like a row label). 73 | > Hope you understand what I mean. 74 | * TODO is there a way to adapt the font properties of the Task descriptions? 75 | * STARTED Milestones 76 | is there a way to specify a special class of Tasks, namely a milestone? 77 | Typically these are shown as diamonds. 78 | 79 | Started : a milestone is on 3 lines. 80 | ** TODO duration of 1 is a problem for linked tasks (one day is lost) 81 | ** TODO draw dependency lines using blank lines before and after 82 | - for milestone itself 83 | - for task depending on milestone 84 | * TODO change to the code for the horizontal alignment of the text 85 | I changed "tx = 5" to "tx = 20". I would suggest to make this horizontal offset 86 | an attribute of the project class. Then one can specify it as a property of each 87 | project. 88 | * TODO mode for showing critical path and tasks that can be moved without incidence 89 | exemple : http://www.4csys.com/images/gantt_chart_2.jpg / http://www.4csys.com/gantt_chart.htm 90 | -------------------------------------------------------------------------------- /example.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | import datetime 5 | import gantt 6 | 7 | import logging 8 | gantt.init_log_to_sysout(level=logging.CRITICAL) 9 | 10 | # Change font default 11 | gantt.define_font_attributes(fill='black', stroke='black', stroke_width=0, font_family="Verdana") 12 | 13 | # Add vacations for everyone 14 | gantt.add_vacations(datetime.date(2014, 12, 25)) 15 | gantt.add_vacations(datetime.date(2015, 1, 1)) 16 | gantt.add_vacations(datetime.date(2015, 1, 13)) 17 | 18 | # Create two resources 19 | rANO = gantt.Resource('ANO') 20 | rJLS = gantt.Resource('JLS') 21 | 22 | # Add vacations for one lucky resource 23 | rANO.add_vacations( 24 | dfrom=datetime.date(2014, 12, 29), 25 | dto=datetime.date(2015, 1, 4) 26 | ) 27 | rANO.add_vacations( 28 | dfrom=datetime.date(2015, 1, 6), 29 | dto=datetime.date(2015, 1, 8) 30 | ) 31 | 32 | # Test if this resource is avalaible for some dates 33 | print(rANO.is_available(datetime.date(2015, 1, 5))) 34 | print(rANO.is_available(datetime.date(2015, 1, 8))) 35 | print(rANO.is_available(datetime.date(2015, 1, 6))) 36 | print(rANO.is_available(datetime.date(2015, 1, 2))) 37 | print(rANO.is_available(datetime.date(2015, 1, 1))) 38 | 39 | 40 | # Create some tasks 41 | t1 = gantt.Task(name='task1', start=datetime.date(2014, 12, 25), duration=4, percent_done=44, resources=[rANO], color="#FF8080") 42 | t2 = gantt.Task(name='task2', start=datetime.date(2014, 12, 28), duration=6, resources=[rJLS]) 43 | t7 = gantt.Task(name='task7', start=datetime.date(2014, 12, 28), duration=5, percent_done=50) 44 | t3 = gantt.Task(name='task3', start=datetime.date(2014, 12, 25), duration=4, depends_of=[t1, t7, t2], resources=[rJLS]) 45 | t4 = gantt.Task(name='task4', start=datetime.date(2015, 01, 01), duration=4, depends_of=t1, resources=[rJLS]) 46 | t5 = gantt.Task(name='task5', start=datetime.date(2014, 12, 23), duration=3) 47 | t6 = gantt.Task(name='task6', start=datetime.date(2014, 12, 25), duration=4, depends_of=t7, resources=[rANO]) 48 | t8 = gantt.Task(name='task8', start=datetime.date(2014, 12, 25), duration=4, depends_of=t7, resources=[rANO, rJLS]) 49 | 50 | 51 | # Create a project 52 | p1 = gantt.Project(name='Project 1') 53 | 54 | # Add tasks to this project 55 | p1.add_task(t1) 56 | p1.add_task(t7) 57 | p1.add_task(t2) 58 | p1.add_task(t3) 59 | p1.add_task(t5) 60 | p1.add_task(t8) 61 | 62 | 63 | 64 | # Create another project 65 | p2 = gantt.Project(name='Project 2', color='#FFFF40') 66 | 67 | # Add tasks to this project 68 | p2.add_task(t2) 69 | p2.add_task(t4) 70 | 71 | 72 | # Create another project 73 | p = gantt.Project(name='Gantt') 74 | # wich contains the first two projects 75 | # and a single task 76 | p.add_task(p1) 77 | p.add_task(p2) 78 | p.add_task(t6) 79 | 80 | 81 | 82 | # Test cases for milestones 83 | # Create another project 84 | ptcm = gantt.Project(name='Test case for milestones') 85 | 86 | tcm11 = gantt.Task(name='tcm11', start=datetime.date(2014, 12, 25), duration=4) 87 | tcm12 = gantt.Task(name='tcm12', start=datetime.date(2014, 12, 26), duration=5) 88 | ms1 = gantt.Milestone(name=' ', depends_of=[tcm11, tcm12]) 89 | tcm21 = gantt.Task(name='tcm21', start=datetime.date(2014, 12, 30), duration=4, depends_of=[ms1]) 90 | tcm22 = gantt.Task(name='tcm22', start=datetime.date(2014, 12, 30), duration=6, depends_of=[ms1]) 91 | ms2 = gantt.Milestone(name='MS2', depends_of=[ms1, tcm21, tcm22]) 92 | tcm31 = gantt.Task(name='tcm31', start=datetime.date(2014, 12, 30), duration=6, depends_of=[ms2]) 93 | ms3 = gantt.Milestone(name='MS3', depends_of=[ms1]) 94 | 95 | 96 | ptcm.add_task(tcm11) 97 | ptcm.add_task(tcm12) 98 | ptcm.add_task(ms1) 99 | ptcm.add_task(tcm21) 100 | ptcm.add_task(tcm22) 101 | ptcm.add_task(ms2) 102 | ptcm.add_task(tcm31) 103 | ptcm.add_task(ms3) 104 | 105 | 106 | p.add_task(ptcm) 107 | 108 | ##########################$ MAKE DRAW ############### 109 | p.make_svg_for_tasks(filename='test_full.svg', today=datetime.date(2014, 12, 31), start=datetime.date(2014,12, 15), end=datetime.date(2015, 01, 14)) 110 | p.make_svg_for_tasks(filename='test_full2.svg', today=datetime.date(2014, 12, 31)) 111 | p.make_svg_for_tasks(filename='test.svg', today=datetime.date(2014, 12, 31), start=datetime.date(2015, 01, 3), end=datetime.date(2015, 01, 06)) 112 | p1.make_svg_for_tasks(filename='test_p1.svg', today=datetime.date(2014, 12, 31)) 113 | p2.make_svg_for_tasks(filename='test_p2.svg', today=datetime.date(2014, 12, 31)) 114 | p.make_svg_for_resources(filename='test_resources.svg', today=datetime.date(2014, 12, 31), resources=[rANO, rJLS]) 115 | p.make_svg_for_tasks(filename='test_weekly.svg', today=datetime.date(2014, 12, 31), scale=gantt.DRAW_WITH_WEEKLY_SCALE) 116 | ##########################$ /MAKE DRAW ############### 117 | -------------------------------------------------------------------------------- /gantt/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | python-gantt - 2015.01.04 6 | 7 | python-gantt is a python library which helps to draw gantt charts. 8 | 9 | 10 | Author : 11 | 12 | * Alexandre Norman - norman@xael.org 13 | 14 | 15 | Licence : GPL v3 or any later version 16 | 17 | 18 | This program is free software: you can redistribute it and/or modify 19 | it under the terms of the GNU General Public License as published by 20 | the Free Software Foundation, either version 3 of the License, or 21 | any later version. 22 | 23 | This program is distributed in the hope that it will be useful, 24 | but WITHOUT ANY WARRANTY; without even the implied warranty of 25 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 26 | GNU General Public License for more details. 27 | 28 | You should have received a copy of the GNU General Public License 29 | along with this program. If not, see . 30 | """ 31 | 32 | from .gantt import * 33 | from .gantt import __author__ 34 | from .gantt import __version__ 35 | from .gantt import __last_modification__ 36 | -------------------------------------------------------------------------------- /gantt/test_gantt.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | import gantt 5 | import datetime 6 | import os 7 | import logging 8 | 9 | from nose.tools import assert_equals 10 | from nose import with_setup 11 | 12 | 13 | def setup(): 14 | gantt.init_log_to_sysout(level=logging.CRITICAL) 15 | return 16 | 17 | 18 | #def test_flatten(): 19 | # assert_equals(gantt._flatten([1, [2, 3], [[4, 5], 6]]), [1, 2, 3, 4, 5, 6]) 20 | # return 21 | 22 | 23 | def test_add_vacations_1(): 24 | gantt.add_vacations(datetime.date(2015, 1, 1)) 25 | gantt.add_vacations(datetime.date(2014, 12, 25)) 26 | # test global vacations 27 | assert_equals(gantt.VACATIONS, [datetime.date(2015, 1, 1), datetime.date(2014, 12, 25)]) 28 | return 29 | 30 | 31 | def test_add_vacations_2(): 32 | gantt.add_vacations(datetime.date(2013, 12, 25), datetime.date(2013, 12, 27)) 33 | # test global vacations 34 | assert datetime.date(2013, 12, 25) in gantt.VACATIONS 35 | assert datetime.date(2013, 12, 26) in gantt.VACATIONS 36 | assert datetime.date(2013, 12, 27) in gantt.VACATIONS 37 | assert datetime.date(2013, 12, 28) not in gantt.VACATIONS 38 | assert datetime.date(2013, 12, 24) not in gantt.VACATIONS 39 | return 40 | 41 | 42 | def test_Resources(): 43 | rANO = gantt.Resource('ANO') 44 | rANO.add_vacations( 45 | dfrom=datetime.date(2015, 2, 2), 46 | dto=datetime.date(2015, 2, 4) 47 | ) 48 | # test global vacations 49 | assert_equals(rANO.is_available(datetime.date(2015, 1, 1)), False) 50 | # test resource vacations 51 | assert_equals(rANO.is_available(datetime.date(2015, 2, 1)), True) 52 | assert_equals(rANO.is_available(datetime.date(2015, 2, 2)), False) 53 | assert_equals(rANO.is_available(datetime.date(2015, 2, 3)), False) 54 | assert_equals(rANO.is_available(datetime.date(2015, 2, 3)), False) 55 | assert_equals(rANO.is_available(datetime.date(2015, 2, 5)), True) 56 | 57 | # Second resource 58 | rJLS = gantt.Resource('JLS') 59 | return 60 | 61 | 62 | def test_Tasks(): 63 | tSADU = gantt.Task(name='tache SADU', start=datetime.date(2014, 12, 25), duration=4) 64 | assert_equals((tSADU.start_date(), tSADU.end_date()), (datetime.date(2014, 12, 26), datetime.date(2014, 12, 31))) 65 | assert_equals(tSADU.nb_elements(), 1) 66 | 67 | tSAST = gantt.Task(name='tache SAST', start=datetime.date(2014, 12, 25), stop=datetime.date(2014, 12, 31)) 68 | assert_equals((tSAST.start_date(), tSAST.end_date()), (datetime.date(2014, 12, 26), datetime.date(2014, 12, 31))) 69 | 70 | tDUST = gantt.Task(name='tache DUST', stop=datetime.date(2014, 12, 31), duration=4) 71 | assert_equals((tDUST.start_date(), tDUST.end_date()), (datetime.date(2014, 12, 26), datetime.date(2014, 12, 31))) 72 | 73 | tDUSTSADU = gantt.Task(name='tache DUST SADU', start=datetime.date(2015, 1, 1), duration=4, depends_of=[tDUST]) 74 | assert_equals((tDUSTSADU.start_date(), tDUSTSADU.end_date()), (datetime.date(2015, 1, 2), datetime.date(2015, 1, 7))) 75 | 76 | tDUSTSAST = gantt.Task(name='tache DUST SAST', start=datetime.date(2015, 1, 1), stop=datetime.date(2015, 1, 7), depends_of=[tDUST]) 77 | assert_equals((tDUSTSAST.start_date(), tDUSTSAST.end_date()), (datetime.date(2015, 1, 2), datetime.date(2015, 1, 7))) 78 | 79 | tDUSTDUST = gantt.Task(name='tache DUST DUST', stop=datetime.date(2015, 1, 7), duration=9, depends_of=[tDUST]) 80 | assert_equals((tDUSTDUST.start_date(), tDUSTDUST.end_date()), (datetime.date(2015, 1, 2), datetime.date(2015, 1, 7))) 81 | 82 | tDUSTDUST2 = gantt.Task(name='tache DUST DUST2', stop=datetime.date(2015, 1, 10), duration=2, depends_of=[tDUST]) 83 | assert_equals((tDUSTDUST2.start_date(), tDUSTDUST2.end_date()), (datetime.date(2015, 1, 8), datetime.date(2015, 1, 9))) 84 | 85 | 86 | tSADUSADU = gantt.Task(name='tache SADU SADU', start=datetime.date(2015, 1, 1), duration=4, depends_of=[tSADU]) 87 | assert_equals((tSADUSADU.start_date(), tSADUSADU.end_date()), (datetime.date(2015, 1, 2), datetime.date(2015, 1, 7))) 88 | 89 | tSADUSAST = gantt.Task(name='tache SADU SAST', start=datetime.date(2015, 1, 1), stop=datetime.date(2015, 1, 7), depends_of=[tSADU]) 90 | assert_equals((tSADUSAST.start_date(), tSADUSAST.end_date()), (datetime.date(2015, 1, 2), datetime.date(2015, 1, 7))) 91 | 92 | tSADUDUST = gantt.Task(name='tache SADU DUST', stop=datetime.date(2015, 1, 7), duration=9, depends_of=[tSADU]) 93 | assert_equals((tSADUDUST.start_date(), tSADUDUST.end_date()), (datetime.date(2015, 1, 2), datetime.date(2015, 1, 7))) 94 | 95 | tSADUDUST2 = gantt.Task(name='tache SADU DUST2', stop=datetime.date(2015, 1, 10), duration=2, depends_of=[tSADU]) 96 | assert_equals((tSADUDUST2.start_date(), tSADUDUST2.end_date()), (datetime.date(2015, 1, 8), datetime.date(2015, 1, 9))) 97 | 98 | 99 | 100 | tSASTSADU = gantt.Task(name='tache SAST SADU', start=datetime.date(2015, 1, 1), duration=4, depends_of=[tSAST]) 101 | assert_equals((tSASTSADU.start_date(), tSASTSADU.end_date()), (datetime.date(2015, 1, 2), datetime.date(2015, 1, 7))) 102 | 103 | tSASTSAST = gantt.Task(name='tache SAST SAST', start=datetime.date(2015, 1, 1), stop=datetime.date(2015, 1, 7), depends_of=[tSAST]) 104 | assert_equals((tSASTSAST.start_date(), tSASTSAST.end_date()), (datetime.date(2015, 1, 2), datetime.date(2015, 1, 7))) 105 | 106 | tSASTDUST = gantt.Task(name='tache SAST DUST', stop=datetime.date(2015, 1, 7), duration=9, depends_of=[tSAST]) 107 | assert_equals((tSASTDUST.start_date(), tSASTDUST.end_date()), (datetime.date(2015, 1, 2), datetime.date(2015, 1, 7))) 108 | 109 | tSASTDUST2 = gantt.Task(name='tache SAST DUST2', stop=datetime.date(2015, 1, 10), duration=2, depends_of=[tSAST]) 110 | assert_equals((tSASTDUST2.start_date(), tSASTDUST2.end_date()), (datetime.date(2015, 1, 8), datetime.date(2015, 1, 9))) 111 | 112 | 113 | tBUG = gantt.Task(name='tBUG', start=datetime.date(2015, 1, 9), duration=7) 114 | assert_equals((tBUG.start_date(), tBUG.end_date()), (datetime.date(2015, 1, 9), datetime.date(2015, 1, 19))) 115 | 116 | tBUG2 = gantt.Task(name='tBUG2', start=datetime.date(2015, 1, 10), duration=7) 117 | assert_equals((tBUG2.start_date(), tBUG2.end_date()), (datetime.date(2015, 1, 12), datetime.date(2015, 1, 20))) 118 | 119 | 120 | p1 = gantt.Project(name='Projet 1') 121 | 122 | assert_equals(p1.nb_elements(), 0) 123 | 124 | p1.add_task(tSADU) 125 | p1.add_task(tSAST) 126 | p1.add_task(tDUST) 127 | p1.add_task(tDUSTSADU) 128 | p1.add_task(tDUSTSAST) 129 | p1.add_task(tDUSTDUST) 130 | p1.add_task(tDUSTDUST2) 131 | 132 | p1.add_task(tSADUSADU) 133 | p1.add_task(tSADUSAST) 134 | p1.add_task(tSADUDUST) 135 | p1.add_task(tSADUDUST2) 136 | 137 | p1.add_task(tSASTSADU) 138 | p1.add_task(tSASTSAST) 139 | p1.add_task(tSASTDUST) 140 | p1.add_task(tSASTDUST2) 141 | 142 | assert_equals(p1.is_in_project(tBUG), False) 143 | 144 | p1.add_task(tBUG) 145 | 146 | assert_equals(p1.is_in_project(tBUG), True) 147 | 148 | p1.add_task(tBUG2) 149 | 150 | assert_equals(p1.nb_elements(), 17) 151 | 152 | assert_equals(p1.start_date(), datetime.date(2014, 12, 26)) 153 | assert_equals(p1.end_date(), datetime.date(2015, 1, 20)) 154 | 155 | 156 | p1.make_svg_for_tasks(filename='./h.svg', today=datetime.date(2014, 12, 31)) 157 | assert os.path.isfile('./h.svg') 158 | 159 | 160 | assert_equals(p1.get_resources(), []) 161 | assert_equals(len(p1.get_tasks()), 17) 162 | return 163 | 164 | -------------------------------------------------------------------------------- /gpl-3.0.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 | . 675 | -------------------------------------------------------------------------------- /org2gantt/Orgnode.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2010 Charles Cave 2 | # 3 | # Permission is hereby granted, free of charge, to any person 4 | # obtaining a copy of this software and associated documentation 5 | # files (the "Software"), to deal in the Software without 6 | # restriction, including without limitation the rights to use, copy, 7 | # modify, merge, publish, distribute, sublicense, and/or sell copies 8 | # of the Software, and to permit persons to whom the Software is 9 | # furnished to do so, subject to the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be 12 | # included in all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 18 | # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 19 | # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | 23 | # Program written by Charles Cave (charlesweb@optusnet.com.au) 24 | # February - March 2009 25 | # Version 2 - June 2009 26 | # Added support for all tags, TODO priority and checking existence of a tag 27 | # Version 3 - Januany 2015 28 | # Added support for Python 3 (Alexandre Norman) 29 | # More information at 30 | # http://members.optusnet.com.au/~charles57/GTD 31 | 32 | """ 33 | The Orgnode module consists of the Orgnode class for representing a 34 | headline and associated text from an org-mode file, and routines for 35 | constructing data structures of these classes. 36 | """ 37 | 38 | import re, sys 39 | import datetime 40 | 41 | def makelist(filename): 42 | """ 43 | Read an org-mode file and return a list of Orgnode objects 44 | created from this file. 45 | """ 46 | ctr = 0 47 | 48 | try: 49 | f = open(filename, 'r') 50 | except IOError: 51 | print("Unable to open file {0}".format(filename)) 52 | print("Program terminating.") 53 | sys.exit(1) 54 | 55 | todos = dict() # populated from #+SEQ_TODO line 56 | todos['TODO'] = '' # default values 57 | todos['DONE'] = '' # default values 58 | level = 0 59 | heading = "" 60 | bodytext = "" 61 | tag1 = "" # The first tag enclosed in :: 62 | alltags = [] # list of all tags in headline 63 | sched_date = '' 64 | deadline_date = '' 65 | nodelist = [] 66 | propdict = dict() 67 | 68 | for line in f: 69 | ctr += 1 70 | hdng = re.search('^(\*+)\s(.*?)\s*$', line) 71 | if hdng: 72 | if heading: # we are processing a heading line 73 | thisNode = Orgnode(level, heading, bodytext, tag1, alltags) 74 | if sched_date: 75 | thisNode.setScheduled(sched_date) 76 | sched_date = "" 77 | if deadline_date: 78 | thisNode.setDeadline(deadline_date) 79 | deadline_date = '' 80 | thisNode.setProperties(propdict) 81 | nodelist.append( thisNode ) 82 | propdict = dict() 83 | level = hdng.group(1) 84 | heading = hdng.group(2) 85 | bodytext = "" 86 | tag1 = "" 87 | alltags = [] # list of all tags in headline 88 | 89 | # if heading.split()[-1][0] == heading.split()[-1][-1] == ':': 90 | # alltags = heading.split()[-1][1:-1].split(':') 91 | # heading = ' '.join(heading.split()[0:-1]) 92 | tagsrch = re.search('(.*?)\s*:([A-Za-z0-9].*?):(.*?)$',heading) 93 | if tagsrch: 94 | heading = tagsrch.group(1) 95 | tag1 = tagsrch.group(2) 96 | alltags.append(tag1) 97 | tag2 = tagsrch.group(3) 98 | if tag2: 99 | for t in tag2.split(':'): 100 | if t != '': alltags.append(t) 101 | else: # we are processing a non-heading line 102 | if line[:10] == '#+SEQ_TODO': 103 | kwlist = re.findall('([A-Z]+)\(', line) 104 | for kw in kwlist: todos[kw] = "" 105 | 106 | if line[:1] != '#': 107 | bodytext = bodytext + line 108 | 109 | if re.search(':PROPERTIES:', line): continue 110 | if re.search(':END:', line): continue 111 | prop_srch = re.search('^\s*:(.*?):\s*(.*?)\s*$', line) 112 | if prop_srch: 113 | propdict[prop_srch.group(1)] = prop_srch.group(2) 114 | continue 115 | sd_re = re.search('SCHEDULED:\s+<([0-9]+)\-([0-9]+)\-([0-9]+)', line) 116 | if sd_re: 117 | sched_date = datetime.date(int(sd_re.group(1)), 118 | int(sd_re.group(2)), 119 | int(sd_re.group(3)) ) 120 | dd_re = re.search('DEADLINE:\s*<(\d+)\-(\d+)\-(\d+)', line) 121 | if dd_re: 122 | deadline_date = datetime.date(int(dd_re.group(1)), 123 | int(dd_re.group(2)), 124 | int(dd_re.group(3)) ) 125 | 126 | # write out last node 127 | thisNode = Orgnode(level, heading, bodytext, tag1, alltags) 128 | thisNode.setProperties(propdict) 129 | if sched_date: 130 | thisNode.setScheduled(sched_date) 131 | if deadline_date: 132 | thisNode.setDeadline(deadline_date) 133 | nodelist.append( thisNode ) 134 | 135 | # using the list of TODO keywords found in the file 136 | # process the headings searching for TODO keywords 137 | for n in nodelist: 138 | h = n.Heading() 139 | todoSrch = re.search('([A-Z]+)\s(.*?)$', h) 140 | if todoSrch: 141 | if todoSrch.group(1) in todos: 142 | n.setHeading( todoSrch.group(2) ) 143 | n.setTodo ( todoSrch.group(1) ) 144 | prtysrch = re.search('^\[\#(A|B|C)\] (.*?)$', n.Heading()) 145 | if prtysrch: 146 | n.setPriority(prtysrch.group(1)) 147 | n.setHeading(prtysrch.group(2)) 148 | 149 | return nodelist 150 | 151 | ###################### 152 | class Orgnode(object): 153 | """ 154 | Orgnode class represents a headline, tags and text associated 155 | with the headline. 156 | """ 157 | def __init__(self, level, headline, body, tag, alltags): 158 | """ 159 | Create an Orgnode object given the parameters of level (as the 160 | raw asterisks), headline text (including the TODO tag), and 161 | first tag. The makelist routine postprocesses the list to 162 | identify TODO tags and updates headline and todo fields. 163 | """ 164 | self.level = len(level) 165 | self.headline = headline 166 | self.body = body 167 | self.tag = tag # The first tag in the list 168 | self.tags = dict() # All tags in the headline 169 | self.todo = "" 170 | self.prty = "" # empty of A, B or C 171 | self.scheduled = "" # Scheduled date 172 | self.deadline = "" # Deadline date 173 | self.properties = dict() 174 | for t in alltags: 175 | self.tags[t] = '' 176 | 177 | # Look for priority in headline and transfer to prty field 178 | 179 | def Heading(self): 180 | """ 181 | Return the Heading text of the node without the TODO tag 182 | """ 183 | return self.headline 184 | 185 | def setHeading(self, newhdng): 186 | """ 187 | Change the heading to the supplied string 188 | """ 189 | self.headline = newhdng 190 | 191 | def Body(self): 192 | """ 193 | Returns all lines of text of the body of this node except the 194 | Property Drawer 195 | """ 196 | return self.body 197 | 198 | def Level(self): 199 | """ 200 | Returns an integer corresponding to the level of the node. 201 | Top level (one asterisk) has a level of 1. 202 | """ 203 | return self.level 204 | 205 | def Priority(self): 206 | """ 207 | Returns the priority of this headline: 'A', 'B', 'C' or empty 208 | string if priority has not been set. 209 | """ 210 | return self.prty 211 | 212 | def setPriority(self, newprty): 213 | """ 214 | Change the value of the priority of this headline. 215 | Values values are '', 'A', 'B', 'C' 216 | """ 217 | self.prty = newprty 218 | 219 | def Tag(self): 220 | """ 221 | Returns the value of the first tag. 222 | For example, :HOME:COMPUTER: would return HOME 223 | """ 224 | return self.tag 225 | 226 | def Tags(self): 227 | """ 228 | Returns a list of all tags 229 | For example, :HOME:COMPUTER: would return ['HOME', 'COMPUTER'] 230 | """ 231 | return self.tags.keys() 232 | 233 | def hasTag(self, srch): 234 | """ 235 | Returns True if the supplied tag is present in this headline 236 | For example, hasTag('COMPUTER') on headling containing 237 | :HOME:COMPUTER: would return True. 238 | """ 239 | return srch in self.tags 240 | 241 | def setTag(self, newtag): 242 | """ 243 | Change the value of the first tag to the supplied string 244 | """ 245 | self.tag = newtag 246 | 247 | def setTags(self, taglist): 248 | """ 249 | Store all the tags found in the headline. The first tag will 250 | also be stored as if the setTag method was called. 251 | """ 252 | for t in taglist: 253 | self.tags[t] = '' 254 | 255 | def Todo(self): 256 | """ 257 | Return the value of the TODO tag 258 | """ 259 | return self.todo 260 | 261 | def setTodo(self, value): 262 | """ 263 | Set the value of the TODO tag to the supplied string 264 | """ 265 | self.todo = value 266 | 267 | def setProperties(self, dictval): 268 | """ 269 | Sets all properties using the supplied dictionary of 270 | name/value pairs 271 | """ 272 | self.properties = dictval 273 | 274 | def Property(self, keyval): 275 | """ 276 | Returns the value of the requested property or null if the 277 | property does not exist. 278 | """ 279 | return self.properties.get(keyval, "") 280 | 281 | def setScheduled(self, dateval): 282 | """ 283 | Set the scheduled date using the supplied date object 284 | """ 285 | self.scheduled = dateval 286 | 287 | def Scheduled(self): 288 | """ 289 | Return the scheduled date object or null if nonexistent 290 | """ 291 | return self.scheduled 292 | 293 | def setDeadline(self, dateval): 294 | """ 295 | Set the deadline (due) date using the supplied date object 296 | """ 297 | self.deadline = dateval 298 | 299 | def Deadline(self): 300 | """ 301 | Return the deadline date object or null if nonexistent 302 | """ 303 | return self.deadline 304 | 305 | def __repr__(self): 306 | """ 307 | Print the level, heading text and tag of a node and the body 308 | text as used to construct the node. 309 | """ 310 | # This method is not completed yet. 311 | n = '' 312 | for i in range(0, self.level): 313 | n = n + '*' 314 | n = n + ' ' + self.todo + ' ' 315 | if self.prty: 316 | n = n + '[#' + self.prty + '] ' 317 | n = n + self.headline 318 | n = "%-60s " % n # hack - tags will start in column 62 319 | closecolon = '' 320 | for t in self.tags.keys(): 321 | n = n + ':' + t 322 | closecolon = ':' 323 | n = n + closecolon 324 | # Need to output Scheduled Date, Deadline Date, property tags The 325 | # following will output the text used to construct the object 326 | n = n + "\n" + self.body 327 | 328 | return n 329 | 330 | 331 | 332 | -------------------------------------------------------------------------------- /org2gantt/README.org: -------------------------------------------------------------------------------- 1 | #+TITLE: README.org 2 | #+STARTUP: showeverything logdone hidestars 3 | * How to make a Gantt graph from an Org-Mode project ? 4 | ** Follow the structure of the [[file:example.org][example.org]] file 5 | *** RESOURCES 6 | Resources are affected to tasks by using them as tags. Resource tag is defined 7 | by the property "resource_id". 8 | 9 | Each resource can contain a list of vacations which can take two forms : 10 | - single date such as [2014-12-30 mar.] 11 | - a timeframe such as [2014-12-30 mar.]--[2015-01-02 ven.], last day is included 12 | *** Group of resources 13 | Groups of resources are defined by the property "resource_id". 14 | Each resource which is a child of a group will be included in this group. 15 | *** VACATIONS 16 | Vacations item can contain a list of vacations which can take two forms : 17 | - single date such as [2014-12-25 jeu.] 18 | - a timeframe such as [2014-12-25 jeu.]--[2015-01-01 jeu.], last day is included 19 | Those vacations are for all resources. 20 | *** Projects 21 | Projects are level 1 items other than RESOURCES or VACATIONS. If they are 22 | tagged with the :no_gantt: tag, project will not be included. 23 | 24 | For each project, two SVG will be generated : 25 | - PROJECTNAME.svg : it contains the Gantt graph for the project 26 | - PROJECTNAME_resources.svg : it contains the graph for the resources 27 | affectation. 28 | 29 | For the whole projects, two graphs are generated : 30 | - project.svg 31 | - project_resources.svg 32 | 33 | Projects can have some properties : 34 | - the "ORDERED" property which allows you to state that the child tasks have to be 35 | completed in the order they appear (top most first). 36 | - the "color" property for defining a color for tasks in this project 37 | - the "task_id" property which will be the ID for the project. It must be uniq 38 | If not set, an uuid will be generated. 39 | 40 | Example : 41 | #+begin_src 42 | :PROPERTIES: 43 | :ORDERED: t 44 | :color: #ff8080 45 | :task_id: project_id 46 | :END: 47 | #+end_src 48 | *** Tasks 49 | Tasks are level 1 or 2 items. They depends from a project (level 1). 50 | Task ID is mandatory and is defined by the property "task_id". 51 | 52 | Timeframe is delimited by from two of the following criteria : 53 | - starting date : set by the SCHEDULED keyword followed by a date 54 | - duration : set as a property, keyword "Effort", duration is defined in days ! 55 | - ending date : set by the DEADLINE keyword followed by a date 56 | Or by : 57 | - dependencies to other task : set as a property, keyword "BLOCKERS" or tags. 58 | - duration : set as a property, keyword "Effort", duration is defined in days ! 59 | 60 | Other options are possible : 61 | - percent done : defined as a property, keyword "PercentDone" 62 | - dependencies : could be defined as a property, keyword "BLOCKERS". Multiples 63 | dependencies are separated by spaces. 64 | - the "color" property for defining a color for this task 65 | - the "task_id" property which will be the ID for this task. It must be uniq. If 66 | not set, an uuid will be generated. 67 | 68 | 69 | Resources are allocated to tasks either using tags (:resourceid:) or by 70 | using the property "allocate". 71 | 72 | Example : 73 | #+begin_src 74 | ** TODO Task :grp1: 75 | SCHEDULED: <2014-12-21 dim.> 76 | :PROPERTIES: 77 | :Effort: 6d 78 | :task_id: task2 79 | :BLOCKER: task1 task0 80 | :PercentDone: 40 81 | :color: #ff8080 82 | :END: 83 | #+end_src 84 | *** CONFIGURATION 85 | The gantt chart timeframe can be set using the item CONFIGURATION and the 86 | following properties : 87 | - start_date : first day of the chart (default begining of project) 88 | - end_date : last day of the chart (default end of project) 89 | - today : force today date (default is today) (iso format yyyy-mm-dd) 90 | start_date and end_date could be references to today's date in the form -1d, 91 | +2w or be a date (iso format yyyy-mm-dd) 92 | 93 | For resources chart, if set to "t", the property one_line_for_tasks puts all tasks on 94 | one line. 95 | 96 | TODO keywords must be defined by using #+SEQ_TODO. Otherwise only "TODO" and 97 | "DONE" are defined. 98 | 99 | For each keyword, a specific color could be defined by using the 100 | "color_{KEYWORD}" property. 101 | 102 | The property "ignore_tags" make org2gantt ignore thoses tags as resources 103 | allocation. 104 | 105 | Exemple : 106 | #+begin_src 107 | #+SEQ_TODO: TODO(t) STARTED(s) WAITING(w) | DONE(d) CANCELED(c) 108 | :PROPERTIES: 109 | :start_date: -5d 110 | :end_date: +5w 111 | :today: [2015-01-01 Thu] 112 | :one_line_for_tasks: nil 113 | :color_TODO: #FFFF90 114 | :color_DONE: #90FF90 115 | :color_STARTED: #FFA0FF 116 | :color_CANCELED: #FF9090 117 | :color_WAITING: #FFFF00 118 | :one_line_for_tasks: t 119 | :ignore_tags: WAITING IQ FORM APPR PPRD PRD 120 | :END: 121 | #+end_src 122 | ** Installation of the scripts 123 | You will need python (v2.7 or later) and some python modules : 124 | - clize : https://github.com/epsy/clize 125 | - Orgnode : http://members.optusnet.com.au/~charles57/GTD/orgnode.html 126 | - svgwrite : https://bitbucket.org/mozman/svgwrite/ 127 | and of course those scripts : 128 | - org2gantt.py : to transform org mode project file in my source code for my 129 | python gantt generator 130 | - gantt.py : to transform gantt source code in SVG. 131 | You can download them from http://xael.org/pages/python-gantt-en.html 132 | ** Running the scripts 133 | *** Transform org-mode file [[file:example.org][example.org]] in [[../example.py][example.py]] 134 | #+begin_src sh 135 | python org2gantt.py example.org -g example_gantt.py 136 | #+end_src 137 | You can check help for options : 138 | #+begin_src sh 139 | python org2gantt.py -h 140 | #+end_src 141 | #+begin_src sh 142 | Usage: org2gantt.py [OPTIONS] org 143 | 144 | org2gantt.py 145 | 146 | Positional arguments: 147 | org org-mode filename 148 | 149 | Options: 150 | -g, --gantt=STR output python-gantt filename (if not 151 | specified, code is directly 152 | executed)(default: ) 153 | -s, --start-date=STR force start date for output or used for 154 | checking resource availibility(default: ) 155 | -e, --end-date=STR force end date for output or used for 156 | checking resource availibility(default: ) 157 | -t, --today=STR force today date(default: ) 158 | -d, --debug debug 159 | -r, --resource=STR check resource availibility between 160 | start_date and end_date(default: ) 161 | -S, --svg=STR svg base name for files output(default: 162 | project) 163 | -h, --help Show this help 164 | -v, --version Show the version 165 | #+end_src 166 | *** Make SVG 167 | If the [[../example.py][example.py]] was generated, it should be straightaway : just launch 168 | it... 169 | #+begin_src sh 170 | python example_gantt.py 171 | #+end_src 172 | You should have now have those files : 173 | - project_1_resources.svg 174 | - project_1.svg 175 | - project_2_resources.svg 176 | - project_2.svg 177 | - project_resources.svg 178 | - project.svg 179 | There could be some warnings, read them, it should be easy to understand. 180 | ** Interpretate the graphs 181 | *** Project graph 182 | - Each project on the graph is named. A purple bar on the left groups all tasks. 183 | - The blue vertical bar is current date (today) 184 | - The gray days are either off work days (by default saturday and sundays) or [[*VACATIONS][VACATIONS]] 185 | **** Tasks 186 | - Each task is represented by an horizontal bar 187 | - Name of the task is on the upper left 188 | - Affected resources are on the bottom left 189 | - Dependencies between tasks are represented by dashed lines 190 | - If the task has a upper left blueish square, the means that begining date has 191 | been influenced by constraints (vacations, dependencies...) 192 | - If the task has a upper right blueish square, the means that ending date has 193 | been influenced by constraints (vacations, dependencies...) 194 | *** Resource graph 195 | - For each resource, a line contains all tasks affected for this resource 196 | - On the line above, there are some markers : 197 | - green half square when this resources is on vacations 198 | - red half square when this resources is overcharged (more than one task at a 199 | time). In the example, task 2 and 7 are overlapping on days 22/12 and 23/12. 200 | ** Licence: GPL v3 or any later version 201 | ** Author : Alexandre Norman (norman at xael.org) 202 | -------------------------------------------------------------------------------- /org2gantt/example.org: -------------------------------------------------------------------------------- 1 | #-*- mode: org; coding: utf-8-unix -*- 2 | * Configuration OrgMode :no_gantt: 3 | #+TITLE: example.org 4 | #+STARTUP: content logdone hidestars 5 | #+TAGS: ress1(1) ress2(2) ress3(3) grp1(g) 6 | #+TAGS: no_gantt(0) 7 | #+DRAWERS: PROPERTIES NOTE LOGBOOK 8 | #+OPTIONS: ^:{} 9 | #+EXCLUDE_TAGS: no_gantt 10 | #+SEQ_TODO: TODO(t) STARTED(s) WAITING(w) MILESTONE(m) | DONE(d) CANCELED(c) 11 | * CONFIGURATION 12 | :PROPERTIES: 13 | :start_date: -3w 14 | :end_date: +3w 15 | :today: [2015-01-01 Thu] 16 | :one_line_for_tasks: nil 17 | :color_TODO: #FFFF90 18 | :color_DONE: #90FF90 19 | :color_STARTED: #FFA0FF 20 | :color_CANCELED: #FF9090 21 | :color_WAITING: #FFFF00 22 | :END: 23 | * RESOURCES 24 | ** Group 1 25 | :PROPERTIES: 26 | :resource_id: grp1 27 | :END: 28 | - [2015-01-01 jeu.]--[2015-02-03 mar.] 29 | *** Resource 1 30 | :PROPERTIES: 31 | :resource_id: ress1 32 | :END: 33 | - [2015-01-05 lun.]--[2015-01-09 ven.] 34 | - [2015-01-15 jeu.]--[2015-01-18 dim.] 35 | - [2015-01-12 lun.] 36 | *** Resource 2 37 | :PROPERTIES: 38 | :resource_id: ress2 39 | :END: 40 | ** Resource 3 41 | :PROPERTIES: 42 | :resource_id: ress3 43 | :END: 44 | - [2014-12-17 Wed]--[2014-12-22 Mon] 45 | ** Group 2 46 | :PROPERTIES: 47 | :resource_id: grp2 48 | :END: 49 | *** Resource 4 50 | :PROPERTIES: 51 | :resource_id: ress4 52 | :END: 53 | ** Resource 5 54 | :PROPERTIES: 55 | :resource_id: ress5 56 | :END: 57 | * VACATIONS 58 | - [2015-01-01 jeu.] 59 | - [2014-12-25 jeu.] 60 | * Project 1 61 | :PROPERTIES: 62 | :ORDERED: nil 63 | :END: 64 | ** DONE Task 1 :ress1: 65 | SCHEDULED: <2014-12-15 lun.> 66 | :PROPERTIES: 67 | :Effort: 2d 68 | :task_id: task1 69 | :END: 70 | ** TODO Task 2 :grp1: 71 | SCHEDULED: <2014-12-21 dim.> 72 | :PROPERTIES: 73 | :Effort: 6d 74 | :task_id: task2 75 | :BLOCKER: task1 76 | :PercentDone: 40 77 | :END: 78 | ** TODO Task 3 :ress2: 79 | SCHEDULED: <2015-01-05 lun.> 80 | :PROPERTIES: 81 | :Effort: 3d 82 | :PercentDone: 50 83 | :task_id: task3 84 | :END: 85 | ** TODO Task 5 :ress3: 86 | DEADLINE: <2014-12-22 lun.> 87 | :PROPERTIES: 88 | :Effort: 3d 89 | :task_id: task5 90 | :END: 91 | ** MILESTONE Milestone 92 | :PROPERTIES: 93 | :BLOCKER: task1 task2 task3 task5 94 | :task_id: ms1 95 | :END: 96 | ** TODO Task 6 :ress3: 97 | SCHEDULED: <2014-12-26 ven.> DEADLINE: <2015-01-13 mar.> 98 | :PROPERTIES: 99 | :BLOCKER: task5 100 | :task_id: task6 101 | :END: 102 | ** TODO Task 4 :ress1: 103 | SCHEDULED: <2015-01-10 lun.> 104 | :PROPERTIES: 105 | :Effort: 4d 106 | :BLOCKER: task6 ms1 107 | :task_id: task4 108 | :END: 109 | * Project 2 110 | :PROPERTIES: 111 | :task_id: prj2 112 | :END: 113 | ** TODO Task 7 :ress2: 114 | DEADLINE: <2014-12-24 mer.> 115 | :PROPERTIES: 116 | :Effort: 6d 117 | :task_id: task7 118 | :END: 119 | ** TODO Task 8 :ress1: 120 | DEADLINE: <2015-01-10 sam.> SCHEDULED: <2014-12-31 mer.> 121 | :PROPERTIES: 122 | :task_id: task8 123 | :END: 124 | ** TODO Task 9 :ress2: 125 | SCHEDULED: <2015-01-09 ven.> 126 | :PROPERTIES: 127 | :Effort: 5d 128 | :BLOCKER: task7 task8 129 | :task_id: task9 130 | :END: 131 | ** TODO Task 10 :grp1: 132 | SCHEDULED: <2014-12-22 lun.> 133 | :PROPERTIES: 134 | :Effort: 3d 135 | :task_id: task10 136 | :END: 137 | ** TODO Task 11 :ress1: 138 | SCHEDULED: <2014-12-22 lun.> 139 | :PROPERTIES: 140 | :Effort: 3d 141 | :task_id: task11 142 | :END: 143 | ** TODO Task 12 :ress1: 144 | :PROPERTIES: 145 | :Effort: 3d 146 | :BLOCKER: task11 147 | :task_id: task12 148 | :END: 149 | * Project 3 150 | :PROPERTIES: 151 | :task_id: prj3 152 | :END: 153 | ** TODO Task 13 :ress1: 154 | :PROPERTIES: 155 | :Effort: 3d 156 | :BLOCKER: task12 157 | :task_id: task13 158 | :END: 159 | * Project 4 :ress2: 160 | :PROPERTIES: 161 | :ORDERED: t 162 | :color: #ff80Ff 163 | :task_id: prj4 164 | :END: 165 | ** TODO task 41 166 | SCHEDULED: <2015-01-01 Thu> 167 | :PROPERTIES: 168 | :Effort: 2d 169 | :task_id: task41 170 | :END: 171 | ** Project 4b :ress1: 172 | :PROPERTIES: 173 | :color: #4040ff 174 | :END: 175 | *** TODO task 4B1 176 | :PROPERTIES: 177 | :Effort: 2d 178 | :task_id: task4b1 179 | :END: 180 | *** TODO task 4B2 181 | :PROPERTIES: 182 | :Effort: 2d 183 | :task_id: task4b2 184 | :END: 185 | ** TODO task 42 186 | :PROPERTIES: 187 | :Effort: 4d 188 | :task_id: task42 189 | :END: 190 | * Sub tasks :ress1: 191 | :PROPERTIES: 192 | :ORDERED: t 193 | :END: 194 | ** TODO task alone 195 | SCHEDULED: <2014-12-17 Wed> 196 | :PROPERTIES: 197 | :Effort: 2d 198 | :allocate: ress3 ress1 199 | :END: 200 | *** TODO sub task alone :ress2: 201 | SCHEDULED: <2014-12-29 Mon> 202 | :PROPERTIES: 203 | :Effort: 3d 204 | :END: 205 | ** TODO task one week :ress2: 206 | SCHEDULED: <2015-01-06 Tue> 207 | :PROPERTIES: 208 | :Effort: 1w 209 | :END: 210 | * Test Group 211 | ** TODO task g1 :grp1: 212 | SCHEDULED: <2014-12-15 Mon> 213 | :PROPERTIES: 214 | :Effort: 1d 215 | :END: 216 | ** TODO task g2 :grp1: 217 | SCHEDULED: <2014-12-16 Tue> 218 | :PROPERTIES: 219 | :Effort: 1d 220 | :END: 221 | ** TODO task g2r2 :ress2: 222 | SCHEDULED: <2014-12-16 Tue> 223 | :PROPERTIES: 224 | :Effort: 1d 225 | :END: 226 | -------------------------------------------------------------------------------- /org2gantt/org2gantt.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | """ 4 | org2gantt.py - version and date, see below 5 | 6 | Author : Alexandre Norman - norman at xael.org 7 | Licence : GPL v3 or any later version 8 | 9 | 10 | This program is free software: you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | any later version. 14 | 15 | This program is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License 21 | along with this program. If not, see . 22 | """ 23 | 24 | 25 | __author__ = 'Alexandre Norman (norman at xael.org)' 26 | __version__ = '0.4.4' 27 | __last_modification__ = '2015.06.13' 28 | 29 | import copy 30 | import datetime 31 | import logging 32 | import os 33 | import sys 34 | import re 35 | import uuid 36 | 37 | ############################################################################ 38 | 39 | try: 40 | import clize 41 | except ImportError: 42 | print("This program uses clize. See : https://github.com/epsy/clize") 43 | sys.exit(1) 44 | 45 | ############################################################################ 46 | 47 | try: 48 | import Orgnode 49 | except ImportError: 50 | print("This program uses Orgnode. See : http://members.optusnet.com.au/~charles57/GTD/orgnode.html") 51 | sys.exit(1) 52 | 53 | 54 | import gantt 55 | 56 | ############################################################################ 57 | 58 | def __show_version__(name, **kwargs): 59 | """ 60 | Show version 61 | """ 62 | print("{0} version {1}".format(os.path.basename(name), __version__)) 63 | return True 64 | 65 | 66 | ############################################################################ 67 | 68 | def _iso_date_to_datetime(isodate): 69 | """ 70 | """ 71 | __LOG__.debug("_iso_date_to_datetime ({0})".format({'isodate':isodate})) 72 | y, m, d = isodate.split('-') 73 | if m[0] == '0': 74 | m = m[1] 75 | if d[0] == '0': 76 | d = d[1] 77 | return "datetime.date({0}, {1}, {2})".format(y, m, d) 78 | 79 | ############################################################################ 80 | 81 | __LOG__ = None 82 | LISTE_IGNORE_TAGS = [] 83 | LISTE_FILTER = [] 84 | 85 | ############################################################################ 86 | 87 | def _init_log_to_sysout(level=logging.INFO): 88 | """ 89 | Init global variable __LOG__ used for logging purpose 90 | 91 | Keyword arguments: 92 | level -- logging level (from logging.debug to logging.critical) 93 | """ 94 | global __LOG__ 95 | logger = logging.getLogger("org2gantt") 96 | logger.setLevel(level) 97 | fh = logging.StreamHandler() 98 | formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s') 99 | fh.setFormatter(formatter) 100 | logger.addHandler(fh) 101 | __LOG__ = logging.getLogger("org2gantt") 102 | return 103 | 104 | 105 | ############################################################################ 106 | 107 | def make_task_from_node(n, prop={}, prev_task=''): 108 | """ 109 | Returns (name, gantt_code, dependencies) where : 110 | name -- the name of the task 111 | gantt_code -- the python_gant code for generating the task 112 | dependencies -- the python_gant code for generation dependencies 113 | 114 | Keyword arguments: 115 | n -- node (as Orgnode node) 116 | prop -- dictionnary of inherited properties 117 | prev_task -- name of previous task (used if ORDERED is set) 118 | """ 119 | __LOG__.debug('make_task_from_node ({0})'.format({'n':n.headline, 'prop':prop, 'prev_task':prev_task})) 120 | gantt_code = '' 121 | 122 | try: 123 | name = n.properties['task_id'].strip() 124 | if name == '': 125 | name = str(uuid.uuid4()).replace('-', '_') 126 | except KeyError: 127 | name = str(uuid.uuid4()).replace('-', '_') 128 | 129 | if ' ' in name: 130 | __LOG__.critical('** Space in task_id: [{0}]'.format(name)) 131 | sys.exit(1) 132 | 133 | 134 | # check if we should filter this task from display 135 | global LISTE_FILTER 136 | display = True 137 | if len(LISTE_FILTER) > 0: 138 | __LOG__.critical('FILTER:{0}'.format(n.tags)) 139 | for x in n.tags: 140 | if x in LISTE_FILTER: 141 | __LOG__.critical('FILTER FOUND:{0}'.format(x)) 142 | break 143 | else: 144 | __LOG__.critical('FILTER_PROP:{0}'.format(prop['resources'])) 145 | if prop['resources'] is not None: 146 | for x in prop['resources'].replace('[','').replace(']','').split(','): 147 | if x in LISTE_FILTER: 148 | __LOG__.critical('FILTER FOUND:{0}'.format(x)) 149 | break 150 | else: 151 | display = False 152 | 153 | else: 154 | display = False 155 | 156 | 157 | fullname = n.headline.strip().replace("'", '_') 158 | start = end = duration = None 159 | if n.scheduled != '': 160 | start = "{0}".format(_iso_date_to_datetime(str(n.scheduled))) 161 | if n.deadline != '': 162 | end = "{0}".format(_iso_date_to_datetime(str(n.deadline))) 163 | if 'Effort' in n.properties: 164 | if 'w' in n.properties['Effort']: 165 | # convert duration from week to days 166 | nbweeks = int(n.properties['Effort'].replace('w', '')) 167 | # how much days in one normal week ? 168 | len_week = 7 - len(gantt.NOT_WORKED_DAYS) 169 | duration = nbweeks * len_week 170 | elif 'd' in n.properties['Effort']: 171 | duration = n.properties['Effort'].replace('d', '') 172 | else: 173 | __LOG__.warning('no known unit for duration ({0} / {1})'.format(fullname, n.properties['Effort'])) 174 | duration = n.properties['Effort'] 175 | 176 | if 'BLOCKER' in n.properties and n.properties['BLOCKER'].strip() == 'previous-sibling': 177 | depends_of = ['task_{0}'.format(prev_task)] 178 | else: 179 | try: 180 | depends = n.properties['BLOCKER'].split() 181 | except KeyError: 182 | depends_of = None 183 | else: # no exception raised 184 | depends_of = [] 185 | for d in depends: 186 | depends_of.append('task_{0}'.format(d)) 187 | 188 | if 'ordered'in prop and prop['ordered'] and prev_task is not None and prev_task != '': 189 | depends_of = ['task_{0}'.format(prev_task)] 190 | 191 | if depends_of is not None and len(depends_of) == 0: 192 | depends_of = None 193 | 194 | try: 195 | percentdone = n.properties['PercentDone'] 196 | except KeyError: 197 | percentdone = None 198 | 199 | if n.todo == 'DONE': 200 | if percentdone is not None or percentdone != '100': 201 | __LOG__.warning('** Task [{0}] marked as done but PercentDone is set to {1}'.format(name, percentdone)) 202 | percentdone = 100 203 | 204 | 205 | global LISTE_IGNORE_TAGS 206 | 207 | resst = [] 208 | 209 | # Resources as tag 210 | if len(n.tags) > 0: 211 | resst = [] 212 | # Filter tags to ignore 213 | for x in n.tags.keys(): 214 | if x not in LISTE_IGNORE_TAGS: 215 | resst.append(x) 216 | 217 | ress = "{0}".format(["{0}".format(x) for x in resst]).replace("'", "") 218 | # Resources as properties 219 | elif 'allocate' in n.properties: 220 | ress = "{0}".format(["{0}".format(x) for x in n.properties['allocate'].replace(",", " ").split()]).replace("'", "") 221 | else: 222 | try: 223 | ress = "{0}".format(["{0}".format(x.strip()) for x in prop['resources'].replace('[','').replace(']','').split(',') if x.strip() not in LISTE_IGNORE_TAGS]).replace("'", "") 224 | except KeyError: 225 | ress = None 226 | except TypeError: 227 | ress = None 228 | except AttributeError: 229 | ress = None 230 | 231 | 232 | # get color from task properties 233 | if 'color' in n.properties: 234 | color = "'{0}'".format(n.properties['color'].strip()) 235 | 236 | # inherits color if defined 237 | elif 'color' in prop and prop['color'] is not None and n.todo in prop['color'] and prop['color'][n.todo] is not None: 238 | color = "'{0}'".format(prop['color'][n.todo]) 239 | 240 | else: 241 | color = None 242 | 243 | 244 | 245 | if n.todo != 'MILESTONE': 246 | # check stops 247 | ends = (start, end, duration) 248 | nonecount = 0 249 | for e in ends: 250 | if e is None: 251 | nonecount += 1 252 | 253 | if nonecount !=1 and (duration is None or duration=='' or (duration != '' and depends_of is None)): 254 | __LOG__.critical('** Task "{0}" : no start, stop, duration or dependencies -> not included in gantt !'.format(fullname)) 255 | return None 256 | 257 | gantt_code += "task_{0} = gantt.Task(name='{1}', start={2}, stop={6}, duration={3}, resources={4}, depends_of={5}, percent_done={7}, fullname='{8}', color={9}, display={10}, state='{11}')\n".format(name, name, start, duration, ress, None, end, percentdone, fullname, color, display, n.todo) 258 | else: 259 | gantt_code += "task_{0} = gantt.Milestone(name='{1}', depends_of={2}, fullname='{3}', color={4}, display={5})\n".format(name, name, None, fullname, color, display) 260 | 261 | # store dependencies for later 262 | dependencies = str(depends_of).replace("'", "") 263 | 264 | return (name, gantt_code, dependencies) 265 | 266 | 267 | ############################################################################ 268 | 269 | @clize.clize( 270 | alias = { 271 | 'debug': ('d',), 272 | 'csv': ('c',), 273 | 'warning': ('w',), 274 | 'gantt': ('g',), 275 | 'svg': ('S',), 276 | 'resource': ('r',), 277 | 'availibility': ('a',), 278 | 'one_line_for_tasks': ('o',), 279 | 'start_date': ('s',), 280 | 'end_date': ('e',), 281 | 'today': ('t',), 282 | 'filter': ('f',), 283 | 'scale': ('k',), 284 | }, 285 | extra = ( 286 | clize.make_flag( 287 | source=__show_version__, 288 | names=('version', 'v'), 289 | help="Show the version", 290 | ), 291 | ) 292 | ) 293 | def __main__(org, csv='', gantt='', start_date='', end_date='', today='', debug=False, resource=False, svg='project', filter='', availibility='', warning=False, one_line_for_tasks=False, scale='d'): 294 | """ 295 | org2gantt.py 296 | 297 | org: org-mode filename 298 | 299 | gantt: output python-gantt filename (if not specified, code is directly executed) 300 | 301 | svg: svg base name for files output 302 | 303 | resource: generate resources graph 304 | 305 | availibility: check resource availibility between start_date and end_date 306 | 307 | one_line_for_tasks: generate graph for each resources with all tasks on the same line 308 | 309 | start_date: force start date for output or used for checking resource availibility (format : 'yyyy-mm-dd' or '-1w' (from today)) 310 | 311 | end_date: force end date for output or used for checking resource availibility (format : 'yyyy-mm-dd' or '+2d' (from today)) 312 | 313 | today: force today date (format : 'yyyy-mm-dd') 314 | 315 | filter: tag or list of tags separated by comas to filter 316 | 317 | scale: scale for the graph (d: days, w: weeks, m: months, q: quaterly) 318 | 319 | csv: filename for csv output 320 | 321 | debug: debug 322 | 323 | warning: set warning level for creating gantt 324 | 325 | Example : 326 | python org2gantt.py TEST.org 327 | 328 | Written by : Alexandre Norman 329 | """ 330 | 331 | gantt_code = """#!/usr/bin/env python3 332 | # -*- coding: utf-8 -*- 333 | 334 | import datetime 335 | import gantt 336 | """ 337 | 338 | global __LOG__ 339 | if debug: 340 | _init_log_to_sysout(logging.DEBUG) 341 | gantt_code += "\nimport logging\ngantt.init_log_to_sysout(level=logging.DEBUG)\n" 342 | elif warning: 343 | _init_log_to_sysout(logging.WARNING) 344 | gantt_code += "\nimport logging\ngantt.init_log_to_sysout(level=logging.WARNING)" 345 | else: 346 | _init_log_to_sysout() 347 | gantt_code += "\nimport logging\ngantt.init_log_to_sysout(level=logging.CRITICAL)" 348 | 349 | if not os.path.isfile(org): 350 | __LOG__.error('** File do not exist : {0}'.format(org)) 351 | sys.exit(1) 352 | 353 | # load orgfile 354 | nodes = Orgnode.makelist(org) 355 | 356 | __LOG__.debug('_analyse_nodes ({0})'.format({'nodes':nodes})) 357 | 358 | # Get all todo items 359 | LISTE_TODOS = {'TODO':None, 'DONE':None, 'MILESTONE':None} 360 | with open(org) as f: 361 | for line in f.readlines(): 362 | if line[:10] == '#+SEQ_TODO': 363 | kwlist = re.findall('([A-Z]+)\(', line) 364 | for kw in kwlist: 365 | LISTE_TODOS[kw] = None 366 | 367 | # Find CONFIGURATION in heading 368 | n_configuration = None 369 | for n in nodes: 370 | if n.headline.strip() == "CONFIGURATION": 371 | n_configuration = n 372 | 373 | planning_start_date = None 374 | planning_end_date = None 375 | planning_today_date = _iso_date_to_datetime(str(datetime.date.today())) 376 | my_today = datetime.date.today() 377 | bar_color = {'TODO':'#FFFF90'} 378 | 379 | if one_line_for_tasks and not resource: 380 | __LOG__.critical('option one_line_for_tasks must be used in conjonction with resource graph generation') 381 | sys.exit(-1) 382 | 383 | 384 | global LISTE_IGNORE_TAGS 385 | LISTE_IGNORE_TAGS = [] 386 | 387 | # List of tag to filter 388 | global LISTE_FILTER 389 | if filter != '': 390 | LISTE_FILTER = filter.split(',') 391 | 392 | __LOG__.debug('LISTE_FILTER : {0}'.format(LISTE_FILTER)) 393 | 394 | # Generate code for configuration 395 | if n_configuration is not None: 396 | for t in LISTE_TODOS: 397 | if 'color_{0}'.format(t) in n_configuration.properties: 398 | bar_color[t] = n_configuration.properties['color_{0}'.format(t)].strip() 399 | 400 | if 'ignore_tags' in n_configuration.properties: 401 | LISTE_IGNORE_TAGS = n_configuration.properties['ignore_tags'].split() 402 | 403 | if not one_line_for_tasks and ('one_line_for_tasks' in n_configuration.properties and n_configuration.properties['one_line_for_tasks'].strip() == 't'): 404 | one_line_for_tasks = True 405 | 406 | if today != '': 407 | planning_today_date = _iso_date_to_datetime(today) 408 | y, m, d = today.split('-') 409 | my_today = datetime.date(int(y), int(m), int(d)) 410 | 411 | elif 'today' in n_configuration.properties: 412 | dates = re.findall('[1-9][0-9]{3}-[0-9]{2}-[0-9]{2}', n_configuration.properties['today']) 413 | if len(dates) == 1: 414 | planning_today_date = _iso_date_to_datetime(dates[0]) 415 | y, m, d = dates[0].split('-') 416 | my_today = datetime.date(int(y), int(m), int(d)) 417 | 418 | if start_date != '': 419 | dates = re.findall('[1-9][0-9]{3}-[0-9]{2}-[0-9]{2}', start_date) 420 | if len(dates) == 1: 421 | y, m, d = start_date.split('-') 422 | planning_start_date = _iso_date_to_datetime(start_date) 423 | elif start_date.startswith('-') or start_date.startswith('+'): 424 | sign = start_date[0] 425 | qte = int(start_date[1:-1]) 426 | what = start_date[-1] 427 | 428 | sign = -1*(sign=='-') + 1*(sign=='+') 429 | if what == 'd': 430 | planning_start_date = _iso_date_to_datetime(str(my_today + datetime.timedelta(days=qte*sign))) 431 | elif what == 'w': 432 | planning_start_date = _iso_date_to_datetime(str(my_today + datetime.timedelta(weeks=qte*sign))) 433 | else: 434 | __LOG__.critical('Unknown start date format : "{0}". Valid format are yyyy-mm-dd or [-+]x[dw]'.format(start_date)) 435 | sys.exit(-1) 436 | 437 | elif 'start_date' in n_configuration.properties: 438 | # find date and use it 439 | dates = re.findall('[1-9][0-9]{3}-[0-9]{2}-[0-9]{2}', n_configuration.properties['start_date']) 440 | if len(dates) == 1: 441 | planning_start_date = _iso_date_to_datetime(dates[0]) 442 | # find +1m 443 | elif n_configuration.properties['start_date'].startswith('-') or n_configuration.properties['start_date'].startswith('+'): 444 | sign = n_configuration.properties['start_date'][0] 445 | qte = int(n_configuration.properties['start_date'][1:-1]) 446 | what = n_configuration.properties['start_date'][-1] 447 | 448 | sign = -1*(sign=='-') + 1*(sign=='+') 449 | if what == 'd': 450 | planning_start_date = _iso_date_to_datetime(str(my_today + datetime.timedelta(days=qte*sign))) 451 | elif what == 'w': 452 | planning_start_date = _iso_date_to_datetime(str(my_today + datetime.timedelta(weeks=qte*sign))) 453 | else: 454 | __LOG__.critical('Unknown start date format : "{0}". Valid format are yyyy-mm-dd or [-+]x[dw]'.format(start_date)) 455 | sys.exit(-1) 456 | 457 | 458 | if end_date != '': 459 | dates = re.findall('[1-9][0-9]{3}-[0-9]{2}-[0-9]{2}', end_date) 460 | if len(dates) == 1: 461 | y, m, d = end_date.split('-') 462 | planning_end_date = _iso_date_to_datetime(end_date) 463 | # find +1m 464 | elif end_date.startswith('-') or end_date.startswith('+'): 465 | sign = end_date[0] 466 | qte = int(end_date[1:-1]) 467 | what = end_date[-1] 468 | 469 | sign = -1*(sign=='-') + 1*(sign=='+') 470 | if what == 'd': 471 | planning_end_date = _iso_date_to_datetime(str(my_today + datetime.timedelta(days=qte*sign))) 472 | elif what == 'w': 473 | planning_end_date = _iso_date_to_datetime(str(my_today + datetime.timedelta(weeks=qte*sign))) 474 | else: 475 | __LOG__.critical('Unknown end date format : "{0}". Valid format are yyyy-mm-dd or [-+]x[dw]'.format(end_date)) 476 | sys.exit(-1) 477 | 478 | elif 'end_date' in n_configuration.properties: 479 | # find date and use it 480 | dates = re.findall('[1-9][0-9]{3}-[0-9]{2}-[0-9]{2}', n_configuration.properties['end_date']) 481 | if len(dates) == 1: 482 | planning_end_date = _iso_date_to_datetime(dates[0]) 483 | # find +1m 484 | elif n_configuration.properties['end_date'].startswith('-') or n_configuration.properties['end_date'].startswith('+'): 485 | sign = n_configuration.properties['end_date'][0] 486 | qte = int(n_configuration.properties['end_date'][1:-1]) 487 | what = n_configuration.properties['end_date'][-1] 488 | 489 | sign = -1*(sign=='-') + 1*(sign=='+') 490 | if what == 'd': 491 | planning_end_date = _iso_date_to_datetime(str(my_today + datetime.timedelta(days=qte*sign))) 492 | elif what == 'w': 493 | planning_end_date = _iso_date_to_datetime(str(my_today + datetime.timedelta(weeks=qte*sign))) 494 | else: 495 | __LOG__.critical('Unknown end date format : "{0}". Valid format are yyyy-mm-dd or [-+]x[dw]'.format(end_date)) 496 | sys.exit(-1) 497 | 498 | 499 | 500 | if eval(planning_end_date) <= eval(planning_start_date): 501 | __LOG__.critical('planning_end_date [{0}] is before planning_start_date [{1}]...'.format(planning_end_date, planning_start_date)) 502 | sys.exit(-1) 503 | 504 | 505 | if scale != '': 506 | scale_ref = { 507 | 'd': 'DRAW_WITH_DAILY_SCALE', 508 | 'w': 'DRAW_WITH_WEEKLY_SCALE', 509 | 'm': 'DRAW_WITH_MONTHLY_SCALE', 510 | 'q': 'DRAW_WITH_QUATERLY_SCALE', 511 | } 512 | try: 513 | scale_name = scale_ref[scale] 514 | except KeyError: 515 | __LOG__.critical('unknown scale {0}'.format(scale)) 516 | sys.exit(-1) 517 | else: 518 | __LOG__.info('drawing with scale : {0}'.format(scale_name)) 519 | else: 520 | scale_name = 'DRAW_WITH_DAILY_SCALE' 521 | 522 | 523 | 524 | __LOG__.debug('List of ignored tags : {0}'.format(LISTE_IGNORE_TAGS)) 525 | 526 | 527 | # Find RESOURCES in heading 528 | n_resources = [] 529 | resources_id = [] 530 | found = False 531 | plevel = 0 532 | for n in nodes: 533 | if found == True and n.level > plevel: 534 | n_resources.append(n) 535 | elif found == True and n.level <= plevel: 536 | break 537 | if found == False and n.headline.strip() == "RESOURCES": 538 | found = True 539 | plevel = n.level 540 | 541 | # Generate code for resources 542 | gantt_code += "\n#### Resources \n" 543 | next_level = 0 544 | current_level = 0 545 | current_group = None 546 | 547 | for nr, r in enumerate(n_resources): 548 | r = n_resources[nr] 549 | 550 | rname = r.headline.strip().replace("'","_") 551 | try: 552 | rid = r.properties['resource_id'].strip() 553 | except KeyError: 554 | rid = 'r_'+str(uuid.uuid4()).replace('-', '_') 555 | 556 | if rid in resources_id: 557 | __LOG__.critical('** Duplicate resource_id: [{0}]'.format(rid)) 558 | sys.exit(1) 559 | 560 | resources_id.append(rid) 561 | 562 | if ' ' in rid: 563 | __LOG__.critical('** Space in resource_id: [{0}]'.format(rid)) 564 | sys.exit(1) 565 | 566 | new_group_this_turn = False 567 | 568 | current_level = r.level 569 | if nr < len(n_resources) - 2: 570 | next_level = n_resources[nr+1].level 571 | 572 | # Group mode 573 | if current_level < next_level: 574 | gantt_code += "{0} = gantt.GroupOfResources('{1}')\n".format(rid, rname) 575 | current_group = rid 576 | new_group_this_turn = True 577 | # Resource 578 | else: 579 | gantt_code += "{0} = gantt.Resource(name='{0}', fullname='{1}')\n".format(rid, rname) 580 | 581 | # Vacations in body of node 582 | for line in r.body.split('\n'): 583 | if line.startswith('-'): 584 | dates = re.findall('[1-9][0-9]{3}-[0-9]{2}-[0-9]{2}', line) 585 | if len(dates) == 2: 586 | start, end = dates 587 | gantt_code += "{0}.add_vacations(dfrom={1}, dto={2})\n".format(rid, _iso_date_to_datetime(start), _iso_date_to_datetime(end)) 588 | elif len(dates) == 1: 589 | start = dates[0] 590 | gantt_code += "{0}.add_vacations(dfrom={1})\n".format(rid, _iso_date_to_datetime(start)) 591 | 592 | else: 593 | if line != '' and not line.strip().startswith(':'): 594 | __LOG__.warning("Unknown resource line : {0}".format(line)) 595 | 596 | 597 | if new_group_this_turn == False and current_group is not None: 598 | gantt_code += "{0}.add_resource(resource={1})\n".format(current_group, rid) 599 | 600 | # end of group 601 | if current_level > next_level: 602 | current_group = None 603 | 604 | 605 | # Find VACATIONS in heading 606 | n_vacations = None 607 | for n in nodes: 608 | if n.headline.strip() == "VACATIONS": 609 | n_vacations = n 610 | 611 | # Generate code for vacations 612 | gantt_code += "\n#### Vacations \n" 613 | if n_vacations is not None: 614 | for line in n_vacations.body.split('\n'): 615 | if line.startswith('-'): 616 | dates = re.findall('[1-9][0-9]{3}-[0-9]{2}-[0-9]{2}', line) 617 | if len(dates) == 2: 618 | start, end = dates 619 | gantt_code += "gantt.add_vacations({0}, {1})\n".format(_iso_date_to_datetime(start), _iso_date_to_datetime(end)) 620 | elif len(dates) == 1: 621 | start = dates[0] 622 | gantt_code += "gantt.add_vacations({0})\n".format(_iso_date_to_datetime(start)) 623 | 624 | else: 625 | if line != '': 626 | __LOG__.warning("Unknown vacation line : {0}".format(line)) 627 | 628 | 629 | # Generate code for Projects 630 | gantt_code += "\n#### Projects \n" 631 | # Mother of all 632 | gantt_code += "project = gantt.Project(color='{0}')\n".format(bar_color['TODO']) 633 | 634 | prj_found = False 635 | tasks_name = [] 636 | # for inheriting project, ORDERED, color, resources 637 | prop_inherits = [] 638 | prev_task = None 639 | no_gantt_level = None 640 | late_dependencies = [] 641 | for nr, n in enumerate(nodes): 642 | n = nodes[nr] 643 | 644 | __LOG__.debug('Analysing {0}'.format(n.headline)) 645 | 646 | # it's a task / level 1 647 | if n.level == 1 \ 648 | and not n.headline.strip() in ('RESOURCES', 'VACATIONS', 'CONFIGURATION') \ 649 | and 'no_gantt' not in n.tags \ 650 | and n.todo in LISTE_TODOS: 651 | 652 | __LOG__.debug(' task / level 1') 653 | 654 | prop_inherits = [] 655 | prj_found = True 656 | prev_task = None 657 | no_gantt_level = None 658 | 659 | # Add task 660 | nt = make_task_from_node(n) 661 | if nt is None: 662 | continue 663 | name, code, dependencies = nt 664 | late_dependencies.append([name, dependencies]) 665 | 666 | if name in tasks_name: 667 | __LOG__.critical("Duplicate task id: {0}".format(name)) 668 | sys.exit(1) 669 | else: 670 | tasks_name.append(name) 671 | 672 | gantt_code += code 673 | gantt_code += "project.add_task(task_{0})\n".format(name) 674 | elif 'no_gantt' in n.tags: 675 | if no_gantt_level is not None and no_gantt_level > n.level: 676 | no_gantt_level = n.level 677 | __LOG__.debug('no_gantt_tag {0}'.format(n.level)) 678 | elif no_gantt_level is None: 679 | no_gantt_level = n.level 680 | __LOG__.debug('no_gantt_tag {0}'.format(n.level)) 681 | 682 | # new project heading 683 | # Not a task, it's a project 684 | # it should have children 685 | elif n.level >= 1 \ 686 | and not n.headline.strip() in ('RESOURCES', 'VACATIONS', 'CONFIGURATION') \ 687 | and 'no_gantt' not in n.tags \ 688 | and not n.todo in LISTE_TODOS: 689 | 690 | if no_gantt_level is not None and n.level > no_gantt_level: 691 | __LOG__.debug('no_gantt_tag {0}/{1}'.format(n.level, no_gantt_level)) 692 | continue 693 | else: 694 | __LOG__.debug('remove no_gantt_tag {0}/{1}'.format(n.level, no_gantt_level)) 695 | no_gantt_level = None 696 | 697 | if n.level == 1: 698 | __LOG__.debug('** cleanup prop_inherits') 699 | prev_task = None 700 | prop_inherits = [] 701 | 702 | if n.level > 1 and prj_found == False: 703 | __LOG__.debug(' do not keep') 704 | continue 705 | 706 | if len(prop_inherits) >= n.level: 707 | __LOG__.debug(' go one level up') 708 | prop_inherits = prop_inherits[:-1] 709 | 710 | 711 | __LOG__.debug(' new project heading') 712 | 713 | gantt_code += "###### Project {0} \n".format(n.headline.strip()) 714 | 715 | try: 716 | name = n.properties['task_id'].strip() 717 | except KeyError: 718 | name = str(uuid.uuid4()).replace('-', '_') 719 | 720 | 721 | __LOG__.debug('{0}'.format(prop_inherits)) 722 | 723 | if bar_color['TODO'] is not None: 724 | gantt_code += "project_{0} = gantt.Project(name='{1}', color='{2}')\n".format(name, n.headline.strip().replace("'", '_'), bar_color['TODO']) 725 | else: 726 | gantt_code += "project_{0} = gantt.Project(name='{1}', color=None)\n".format(name, n.headline.strip().replace("'", '_')) 727 | 728 | try: 729 | gantt_code += "project_{0}.add_task(project_{1})\n".format(prop_inherits[-1]['project_id'], name) 730 | except KeyError: 731 | gantt_code += "project.add_task(project_{0})\n".format(name) 732 | except IndexError: 733 | gantt_code += "project.add_task(project_{0})\n".format(name) 734 | 735 | if n.level == 1: 736 | prop_inherits = [] 737 | 738 | # Inherits ORDERED 739 | if 'ORDERED' in n.properties and n.properties['ORDERED'] == 't': 740 | ordered = True 741 | else: 742 | if len(prop_inherits) > 0: 743 | ordered = prop_inherits[-1]['ordered'] 744 | else: 745 | prev_task = None 746 | ordered = False 747 | 748 | color = copy.deepcopy(bar_color) 749 | # Inherits color 750 | if 'color' in n.properties: 751 | color['TODO'] = n.properties['color'] 752 | else: 753 | if len(prop_inherits) > 0: 754 | color['TODO'] = prop_inherits[-1]['color']['TODO'] 755 | else: 756 | color['TODO'] = bar_color['TODO'] 757 | 758 | 759 | 760 | # Inherits resources 761 | # Resources as tag 762 | if len(n.tags) > 0: 763 | # For inherit all tags 764 | #ress = "{0}".format(["{0}".format(x) for x in n.tags.keys() if x not in LISTE_IGNORE_TAGS]).replace("'", "") 765 | ress = "{0}".format(["{0}".format(x) for x in n.tags.keys()]).replace("'", "") 766 | # Resources as properties 767 | elif 'allocate' in n.properties: 768 | ress = "{0}".format(["{0}".format(x) for x in n.properties['allocate'].replace(",", " ").split()]).replace("'", "") 769 | else: 770 | try: 771 | ress = prop_inherits[-1]['resources'] 772 | except KeyError: 773 | ress = None 774 | except IndexError: 775 | ress = None 776 | 777 | 778 | prop_inherits.append({'ordered':ordered, 'color':color, 'project_id':name, 'resources':ress}) 779 | prj_found = True 780 | 781 | 782 | 783 | # It's a task 784 | elif n.level >= 1 \ 785 | and prj_found == True \ 786 | and not n.headline.strip() in ('RESOURCES', 'VACATIONS', 'CONFIGURATION') \ 787 | and 'no_gantt' not in n.tags \ 788 | and n.todo in LISTE_TODOS: 789 | 790 | __LOG__.debug(' new task under project {0}'.format(n.headline)) 791 | 792 | if n.level == 1: 793 | prev_task = None 794 | prop_inherits = [] 795 | __LOG__.debug(' clean prop_inherits') 796 | 797 | if no_gantt_level is not None and n.level > no_gantt_level: 798 | __LOG__.debug('no_gantt_tag {0}/{1}'.format(n.level, no_gantt_level)) 799 | continue 800 | else: 801 | __LOG__.debug('remove no_gantt_tag {0}/{1}'.format(n.level, no_gantt_level)) 802 | no_gantt_level = None 803 | 804 | 805 | if n.level > 1 and len(prop_inherits) < n.level - 1: 806 | __LOG__.critical('pb in structure : task "{0}" do not belong to a project but a task - possible inheritance problem'.format(n.headline)) 807 | 808 | 809 | if len(prop_inherits) >= n.level: 810 | __LOG__.debug(' go one level up') 811 | prop_inherits = prop_inherits[:-1] 812 | 813 | __LOG__.debug(' bar_color {0}'.format(bar_color)) 814 | 815 | # Add task 816 | if len(prop_inherits) > 0: 817 | nt = make_task_from_node(n, prop_inherits[-1], prev_task) 818 | if nt is None: 819 | continue 820 | name, code, dependencies = nt 821 | late_dependencies.append([name, dependencies]) 822 | else: 823 | nt = make_task_from_node(n, [], prev_task) 824 | if nt is None: 825 | continue 826 | name, code, dependencies = nt 827 | late_dependencies.append([name, dependencies]) 828 | 829 | 830 | if name in tasks_name: 831 | __LOG__.critical("Duplicate task id: {0}".format(name)) 832 | sys.exit(1) 833 | else: 834 | tasks_name.append(name) 835 | 836 | prev_task = name 837 | 838 | gantt_code += code 839 | #gantt_code += "project.add_task(task_{0})\n".format(name) 840 | 841 | try: 842 | gantt_code += "project_{0}.add_task(task_{1})\n".format(prop_inherits[-1]['project_id'], name) 843 | except KeyError: 844 | gantt_code += "project.add_task(task_{0})\n".format(name) 845 | except IndexError: 846 | gantt_code += "project.add_task(task_{0})\n".format(name) 847 | 848 | else: 849 | prj_found = False 850 | prop_inherits = [] 851 | 852 | __LOG__.debug(' nothing') 853 | 854 | 855 | gantt_code += "\n#### Dependencies \n" 856 | # Late dependencies 857 | for name, dep in late_dependencies: 858 | gantt_code += "task_{0}.add_depends(depends_of={1})\n".format(name, dep) 859 | 860 | 861 | if availibility == '': 862 | # Full project 863 | gantt_code += "\n#### Outputs \n" 864 | 865 | 866 | gantt_code += "project.make_svg_for_tasks(filename='{3}.svg', today={0}, start={1}, end={2}, scale=gantt.{4})\n".format(planning_today_date, planning_start_date, planning_end_date, svg, scale_name) 867 | # Generate resource graph 868 | if resource: 869 | gantt_code += "project.make_svg_for_resources(filename='{4}_resources.svg', today={0}, start={1}, end={2}, one_line_for_tasks={3}, filter='{5}', scale=gantt.{6})\n".format(planning_today_date, planning_start_date, planning_end_date, one_line_for_tasks, svg, filter, scale_name) 870 | 871 | else: 872 | gantt_code += "\n#### Check resource availibility \n" 873 | gantt_code += "print({0}.is_vacant(from_date={1}, to_date={2}))\n".format(availibility, planning_start_date, planning_end_date) 874 | 875 | 876 | 877 | if csv != '': 878 | gantt_code += "\n#### CSV Outputs \n" 879 | gantt_code += "project.csv('{0}')\n".format(csv) 880 | 881 | 882 | # write Gantt code 883 | if gantt == '': 884 | import gantt 885 | exec(gantt_code) 886 | else: 887 | open(gantt, 'w').write(gantt_code) 888 | 889 | 890 | 891 | 892 | __LOG__.debug("All done. Exiting.") 893 | 894 | return 895 | 896 | 897 | 898 | ############################################################################ 899 | 900 | 901 | 902 | # MAIN ------------------- 903 | if __name__ == '__main__': 904 | 905 | clize.run(__main__) 906 | sys.exit(0) 907 | 908 | 909 | ####################################################################### 910 | 911 | -------------------------------------------------------------------------------- /org2gantt/taskjuggler.org: -------------------------------------------------------------------------------- 1 | #+PROPERTY: Effort_ALL 2d 5d 10d 20d 30d 35d 50d 2 | #+PROPERTY: allocate_ALL dev doc test 3 | #+COLUMNS: %30ITEM(Task) %Effort %allocate %BLOCKER %ORDERED 4 | 5 | * Accounting Software 6 | 7 | ** Milestones 8 | *** TODO Project start 9 | SCHEDULED: <2015-01-09 Fri> 10 | :PROPERTIES: 11 | :task_id: start 12 | :Effort: 1d 13 | :END: 14 | 15 | *** TODO Technology Preview 16 | :PROPERTIES: 17 | :BLOCKER: back_end 18 | :Effort: 1d 19 | :END: 20 | 21 | *** TODO Beta version 22 | :PROPERTIES: 23 | :BLOCKER: alpha 24 | :Effort: 1d 25 | :END: 26 | 27 | *** TODO Ship Product to Customer 28 | :PROPERTIES: 29 | :BLOCKER: beta manual 30 | :Effort: 1d 31 | :END: 32 | 33 | ** TODO Specification 34 | :PROPERTIES: 35 | :Effort: 20d 36 | :BLOCKER: start 37 | :allocate: dev 38 | :END: 39 | 40 | ** Software Development 41 | :PROPERTIES: 42 | :ORDERED: t 43 | :BLOCKER: previous-sibling 44 | :priority: 1000 45 | :allocate: dev 46 | :END: 47 | 48 | *** TODO Database coupling 49 | :PROPERTIES: 50 | :Effort: 20d 51 | :END: 52 | 53 | *** TODO Back-End Functions 54 | :PROPERTIES: 55 | :Effort: 30d 56 | :task_id: back_end 57 | :END: 58 | 59 | *** TODO Graphical User Interface 60 | :PROPERTIES: 61 | :Effort: 35d 62 | :allocate: paul, seb 63 | :END: 64 | 65 | ** Software testing 66 | :PROPERTIES: 67 | :ORDERED: t 68 | :BLOCKER: previous-sibling 69 | :allocate: test 70 | :END: 71 | *** TODO Alpha Test 72 | :PROPERTIES: 73 | :Effort: 5d 74 | :task_id: alpha 75 | :END: 76 | 77 | *** TODO Beta Test 78 | :PROPERTIES: 79 | :Effort: 20d 80 | :task_id: beta 81 | :allocate: test, paul 82 | :END: 83 | 84 | ** TODO Manual 85 | :PROPERTIES: 86 | :Effort: 50d 87 | :task_id: manual 88 | :BLOCKER: start 89 | :allocate: doc 90 | :END: 91 | 92 | * RESOURCES 93 | ** Developers 94 | :PROPERTIES: 95 | :resource_id: dev 96 | :END: 97 | *** Paul Smith 98 | :PROPERTIES: 99 | :resource_id: paul 100 | :END: 101 | *** Sébastien Bono 102 | :PROPERTIES: 103 | :resource_id: seb 104 | :END: 105 | *** Klaus Müller 106 | 107 | ** Others 108 | *** Peter Murphy 109 | :PROPERTIES: 110 | :resource_id: doc 111 | :limits: { dailymax 6.4h } 112 | :END: 113 | *** Dim Sung 114 | :PROPERTIES: 115 | :resource_id: test 116 | :END: 117 | 118 | -------------------------------------------------------------------------------- /requirements-dev.in: -------------------------------------------------------------------------------- 1 | -r requirements.in 2 | recommonmark 3 | sphinx-autobuild 4 | sphinx 5 | tox -------------------------------------------------------------------------------- /requirements-dev.txt: -------------------------------------------------------------------------------- 1 | # 2 | # This file is autogenerated by pip-compile 3 | # Make changes in requirements-dev.in, then run this to update: 4 | # 5 | # pip-compile requirements-dev.in 6 | # 7 | alabaster==0.7.7 # via sphinx 8 | argh==0.26.1 # via sphinx-autobuild, watchdog 9 | argparse==1.4.0 # via dateutils 10 | babel==2.2.0 # via sphinx 11 | backports-abc==0.4 # via tornado 12 | clize==3.0 13 | commonmark==0.5.4 # via recommonmark 14 | dateutils==0.6.6 15 | docutils==0.12 # via recommonmark, sphinx 16 | jinja2==2.8 # via sphinx 17 | livereload==2.4.1 # via sphinx-autobuild 18 | markupsafe==0.23 # via jinja2 19 | pathtools==0.1.2 # via sphinx-autobuild, watchdog 20 | pluggy==0.3.1 # via tox 21 | py==1.4.31 # via tox 22 | pygments==2.1 # via sphinx 23 | pyparsing==2.0.7 # via svgwrite 24 | python-dateutil==2.4.2 # via dateutils 25 | pytz==2015.7 # via babel, dateutils 26 | pyyaml==3.11 # via sphinx-autobuild, watchdog 27 | recommonmark==0.4.0 28 | sigtools==1.0 # via clize 29 | six==1.10.0 # via clize, livereload, python-dateutil, sigtools, sphinx 30 | snowballstemmer==1.2.1 # via sphinx 31 | sphinx-autobuild==0.5.2 32 | sphinx-rtd-theme==0.1.9 # via sphinx 33 | sphinx==1.3.5 34 | svgwrite==1.1.6 35 | tornado==4.3 # via livereload, sphinx-autobuild 36 | tox==2.3.1 37 | virtualenv==14.0.5 # via tox 38 | watchdog==0.8.3 # via sphinx-autobuild 39 | -------------------------------------------------------------------------------- /requirements.in: -------------------------------------------------------------------------------- 1 | dateutils 2 | svgwrite 3 | clize 4 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | # 2 | # This file is autogenerated by pip-compile 3 | # Make changes in requirements.in, then run this to update: 4 | # 5 | # pip-compile requirements.in 6 | # 7 | argparse==1.4.0 # via dateutils 8 | clize==3.0 9 | dateutils==0.6.6 10 | funcsigs==0.4 # via sigtools 11 | pyparsing==2.0.7 # via svgwrite 12 | python-dateutil==2.4.2 # via dateutils 13 | pytz==2015.7 # via dateutils 14 | sigtools==1.0 # via clize 15 | six==1.10.0 # via clize, python-dateutil, sigtools 16 | svgwrite==1.1.6 17 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | #from distutils.core import setup, Extension 5 | 6 | from setuptools import setup, find_packages # Always prefer setuptools over distutils 7 | from codecs import open # To use a consistent encoding 8 | from os import path 9 | 10 | here = path.abspath(path.dirname(__file__)) 11 | 12 | # Get the long description from the relevant file 13 | with open(path.join(here, 'README.txt'), encoding='utf-8') as f: 14 | long_description = f.read() 15 | 16 | setup ( 17 | name = 'python-gantt', 18 | version = '0.5.0', 19 | author = 'Alexandre Norman', 20 | author_email = 'norman@xael.org', 21 | license ='gpl-3.0.txt', 22 | keywords="gantt, graphics, scheduling, project management", 23 | # Get more strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers 24 | platforms=[ 25 | "Operating System :: OS Independent", 26 | ], 27 | classifiers=[ 28 | "Development Status :: 5 - Production/Stable", 29 | "Programming Language :: Python", 30 | "Environment :: Console", 31 | "Intended Audience :: Developers", 32 | "Intended Audience :: End Users/Desktop", 33 | "License :: OSI Approved :: GNU General Public License (GPL)", 34 | "Operating System :: OS Independent", 35 | "Topic :: Multimedia :: Graphics :: Editors :: Vector-Based", 36 | "Topic :: Office/Business :: Scheduling", 37 | "Topic :: Scientific/Engineering :: Visualization", 38 | ], 39 | packages=['gantt'], 40 | url = 'http://xael.org/pages/python-gantt-en.html', 41 | bugtrack_url = 'https://bitbucket.org/xael/python-gantt', 42 | description = 'This is a python class to create gantt chart using SVG.', 43 | long_description=long_description, 44 | install_requires=[ 45 | 'svgwrite>=1.1.6', 46 | 'clize>=2.0', 47 | 'python-dateutil>=2.4' 48 | ], 49 | zip_safe = True, 50 | ) 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [base] 2 | # Let's configure base dependencies 3 | deps = 4 | flake8 5 | coverage 6 | nose 7 | clize 8 | argparse==1.4.0 # via dateutils 9 | backports-abc==0.4 # via tornado 10 | commonmark==0.5.4 # via recommonmark 11 | dateutils==0.6.6 12 | pyparsing==2.0.6 # via svgwrite 13 | python-dateutil==2.4.2 # via dateutils 14 | pytz==2015.7 # via babel, dateutils 15 | recommonmark==0.2.0 16 | six==1.10.0 # via livereload, python-dateutil, sphinx 17 | svgwrite==1.1.6 18 | 19 | 20 | [tox] 21 | # Here is the list of our environments 22 | envlist = 23 | py27, 24 | py34 25 | 26 | [testenv] 27 | # Install current package before testing 28 | usedevelop = True 29 | 30 | # Configure the actual testing command 31 | whitelist_externals = /usr/bin/make 32 | commands = 33 | make toxtest 34 | 35 | # Let's define specific dependencies for each environment 36 | [testenv:py27] 37 | basepython = python2.7 38 | deps = 39 | {[base]deps} 40 | 41 | [testenv:py34] 42 | basepython = python3.4 43 | deps = 44 | {[base]deps} --------------------------------------------------------------------------------