gantt (version 0.3.9)
index
/usr/src/RPM/BUILD/python-module-gantt-0.3.10/gantt/gantt.py

gantt.py - version and date, see below
 
This is a python class to create gantt chart using SVG
 
 
Author : Alexandre Norman - norman at xael.org
Licence : GPL v3 or any later version
 
 
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
 
You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

 
Modules
       
datetime
logging
svgwrite
sys

 
Classes
       
builtins.object
GroupOfResources
Project
Resource
Task

 
class GroupOfResources(builtins.object)
    Class for grouping resources
 
  Methods defined here:
__init__(self, name, fullname=None)
Init a group of resource resource
 
Keyword arguments:
name -- name given to the resource (id)
fullname -- long name given to the resource
add_resource(self, resource)
Add a resource to the group of resources
 
Keyword arguments:
resource -- Resource object
add_task(self, task)
Tell the resource that we have assigned a task
 
Keyword arguments:
task -- Task object
add_vacations(self, dfrom, dto=None)
Add vacations to a resource begining at [dfrom] to [dto] (included). If
[dto] is not defined, vacation will be for [dfrom] day only
 
Keyword arguments:
dfrom -- datetime.date begining of vacation
dto -- datetime.date end of vacation of vacation
is_available(self, date)
Returns True if any resource is available at given date, False if not.
Availibility is taken from the global VACATIONS and resource's ones.
 
Keyword arguments:
date -- datetime.date day to look for
is_vacant(self, from_date, to_date)
Check if any resource from the group is unallocated between for a given timeframe.
Returns a list of available ressource name.
 
Keyword arguments:
from_date -- first day
to_date --  last day
nb_elements(self)
Returns the number of resources
search_for_task_conflicts(self, all_tasks=False)
Returns a dictionnary of all days (datetime.date) containing for each
overcharged day the list of task for this day.
 
It examines all resources member and group tasks.
 
Keyword arguments:
all_tasks -- if True return all tasks for all days, not just overcharged days

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class Project(builtins.object)
    Class for handling projects
 
  Methods defined here:
__init__(self, name='', color=None)
Initialize project with a given name and color for all tasks
 
Keyword arguments:
name -- string, name of the project
color -- color for all tasks of the project
add_task(self, task)
Add a Task to the ProjectTask can also be a subproject
 
Keyword arguments:
task -- Task or Project object
end_date(self)
Returns last day of the project
get_resources(self)
Returns Resources used in the project
get_tasks(self)
Returns flat list of Tasks used in the Project and subproject
is_in_project(self, task)
Return True if the given Task is in the project, False if not
 
Keyword arguments:
task -- Task object
make_svg_for_resources(self, filename, today=None, start=None, end=None, resources=None, one_line_for_tasks=False, filter='')
Draw resources affectation and output it to filename. If start or end are
given, use them as reference, otherwise use project first and last day
 
And returns to a dictionnary of dictionnaries for vacation and task
conflicts for resources
 
Keyword arguments:
filename -- string, filename to save to
today -- datetime.date of day marked as a reference
start -- datetime.date of first day to draw
end -- datetime.date of last day to draw
resources -- list of Resource to check, default all
one_line_for_tasks -- use only one line to display all tasks ?
filter -- display only those tags
make_svg_for_tasks(self, filename, today=None, start=None, end=None)
Draw gantt of tasks and output it to filename. If start or end are
given, use them as reference, otherwise use project first and last day
 
Keyword arguments:
filename -- string, filename to save to
today -- datetime.date of day marked as a reference
start -- datetime.date of first day to draw
end -- datetime.date of last day to draw
nb_elements(self)
Returns the number of tasks included in the project or subproject
start_date(self)
Returns first day of the project
svg(self, prev_y=0, start=None, end=None, color=None, level=0)
Return (SVG code, number of lines drawn) for the project. Draws all
tasks and add project name with a purple bar on the left side.
 
Keyword arguments:
prev_y -- int, line to start to draw
start -- datetime.date of first day to draw
end -- datetime.date of last day to draw
color -- string of color for drawing the project
level -- int, indentation level of the project
svg_dependencies(self, prj)
Draws svg dependencies between tasks according to coordinates cached
when drawing tasks
 
Keyword arguments:
prj -- Project object to check against

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class Resource(builtins.object)
    Class for handling resources assigned to tasks
 
  Methods defined here:
__init__(self, name, fullname=None)
Init a resource
 
Keyword arguments:
name -- name given to the resource (id)
fullname -- long name given to the resource
add_group(self, groupofresources)
Tell the resource it belongs to a GroupOfResources
 
Keyword arguments:
groupofresources -- GroupOfResources
add_task(self, task)
Tell the resource that we have assigned a task
 
Keyword arguments:
task -- Task object
add_vacations(self, dfrom, dto=None)
Add vacations to a resource begining at [dfrom] to [dto] (included). If
[dto] is not defined, vacation will be for [dfrom] day only
 
Keyword arguments:
dfrom -- datetime.date begining of vacation
dto -- datetime.date end of vacation of vacation
is_available(self, date)
Returns True if the resource is available at given date, False if not.
Availibility is taken from the global VACATIONS and resource's ones.
 
Keyword arguments:
date -- datetime.date day to look for
is_vacant(self, from_date, to_date)
Check if the resource is unallocated between for a given timeframe.
Returns True if the resource is free, False otherwise
 
Keyword arguments:
from_date -- first day
to_date --  last day
nb_elements(self)
Returns the number of resources, 1 here
search_for_task_conflicts(self, all_tasks=False)
Returns a dictionnary of all days (datetime.date) containing for each
overcharged day the list of task for this day.
 
Keyword arguments:
all_tasks -- if True return all tasks for all days, not just overcharged days

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class Task(builtins.object)
    Class for manipulating Tasks
 
  Methods defined here:
__init__(self, name, start=None, stop=None, duration=None, depends_of=None, resources=None, percent_done=0, color=None, fullname=None, display=True)
Initialize task object. Two of start, stop or duration may be given.
This task can rely on other task and will be completed with resources.
If percent done is given, a progress bar will be included on the task.
If color is specified, it will be used for the task.
 
Keyword arguments:
name -- name of the task (id)
fullname -- long name given to the resource
start -- datetime.date, first day of the task, default None
stop -- datetime.date, last day of the task, default None
duration -- int, duration of the task, default None
depends_of -- list of Task which are parents of this one, default None
resources -- list of Resources assigned to the task, default None
percent_done -- int, percent of achievment, default 0
color -- string, html color, default None
display -- boolean, display this task, default True
add_depends(self, depends_of)
Adds dependency to a task
 
Keyword arguments:
depends_of -- list of Task which are parents of this one
check_conflicts_between_task_and_resources_vacations(self)
Displays a warning for each conflict between tasks and vacation of
resources affected to the task
 
And returns a dictionnary for resource vacation conflicts
end_date(self)
Returns the last day of the task, either the one which was given at task
creation or the one calculated after checking dependencies
get_resources(self)
Returns Resources used in the task
is_in_project(self, task)
Return True if the given Task is itself... (lazy coding ;)
 
Keyword arguments:
task -- Task object
nb_elements(self)
Returns the number of task, 1 here
start_date(self)
Returns the first day of the task, either the one which was given at
task creation or the one calculated after checking dependencies
svg(self, prev_y=0, start=None, end=None, color=None, level=None)
Return SVG for drawing this task.
 
Keyword arguments:
prev_y -- int, line to start to draw
start -- datetime.date of first day to draw
end -- datetime.date of last day to draw
color -- string of color for drawing the project
level -- int, indentation level of the project, not used here
svg_dependencies(self, prj)
Draws svg dependencies between task and project according to coordinates
cached when drawing tasks
 
Keyword arguments:
prj -- Project object to check against

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
Functions
       
add_vacations(start_date, end_date=None)
Add vacations to a resource begining at [start_date] to [end_date]
(included). If [end_date] is not defined, vacation will be for [start_date]
day only
 
Keyword arguments:
start_date -- datetime.date begining of vacation
end_date -- datetime.date end of vacation of vacation
init_log_to_sysout(level=20)
Init global variable __LOG__ used for logging purpose
 
Keyword arguments:
level -- logging level (from logging.debug to logging.critical)

 
Data
        NOT_WORKED_DAYS = [5, 6]
VACATIONS = []
__LOG__ = <logging.Logger object>
__last_modification__ = '2015.01.30'
cm = <svgwrite.Unit object>
mm = <svgwrite.Unit object>

 
Author
        Alexandre Norman (norman at xael.org)