gantt_project_maker package

Submodules

gantt_project_maker.colors module

Definition of CBS rbg colors. Based on the color rgb definitions from the cbs LaTeX template

gantt_project_maker.colors.color_to_hex(color: str)[source]

Convert a named color into a hex code with a leading #

gantt_project_maker.colors.hex_number_to_hex_hash(hex_number)[source]
Parameters:

hex_number – int or str Hexadecimal representation of a color, with or without a leading #

Returns: str

Hexadecimal color with a leading #

gantt_project_maker.colors.set_custom_colors(custom_colors)[source]

Set the hex colors defined in the dictionary to the global variable CUSTOM_COLORS_HEX

gantt_project_maker.excelwriter module

Functions and classes for writing the Excel fields

class gantt_project_maker.excelwriter.WorkBook(workbook)[source]

Bases: object

A class to hold all the Excel styles

Parameters:

workbook – the Excel workbook to work on

workbook

workbook

left_align_italic

None

left_align_italic_large

None

left_align_italic_large_ul

None

left_align_helvetica

None

left_align_helvetica_bold

None

left_align_bold

None

left_align_bold_large

None

left_align

None

left_align_large_wrap

None

left_align_large_wrap_top

None

left_align_wrap

None

left_align_large

None

right_align

None

header_format

None

title_format

None

section_heading

None

footer_format

None

merge_format

None

date_format

None

number_format

None

add_styles()[source]

function to add the styles

add_styles()[source]

Add the Excel styles to the workbook

gantt_project_maker.excelwriter.indent(line, n_char=5)[source]

Add an indent with white spaces at the beginning of the line

Parameters:
  • line (str) – line to add a spacing to

  • n_char (int) – Number of spaces to add

Returns:

line with added spacing at the start of the line

Return type:

str

gantt_project_maker.excelwriter.is_contributor(project, resource, is_contributing=False)[source]

check if resource is contributor of the project :param project: :param resource: :param is_contributing: bool

Returns:

gantt_project_maker.excelwriter.project_to_period_label(project: type) str[source]

Take the start and end dates of the project and convert to a period label, like 24Q1 (first quarter of 2024) or 24Q324Q4 (third and last quarter of 2024)

Parameters:

project (Project) – Project class with start_date and end_date methods

Returns:

label of the period, such as 24Q3 or 24Q3/25Q1

Return type:

str

gantt_project_maker.excelwriter.spacing(n_char=5)[source]

Create spacing of n_char characters

Parameters:

n_char (int) – Number of white spaces

Returns:

string of n_char spaces

Return type:

str

gantt_project_maker.excelwriter.update_width(label: str, max_width)[source]

Update the width of a label based on the current maximum width

Parameters:
  • label (str) – Current label

  • max_width (int) – Current maximum width of the labels

Returns:

New maximum width

Return type:

int

gantt_project_maker.excelwriter.write_header(header_info, workbook, worksheet, character_width, wb, column_widths, row_index)[source]

Write the header of an Excel sheet

Parameters:
  • header_info (dict) – The header infor of this sheet

  • workbook (WorkBook) – The Excel workbook

  • worksheet (str) – The name of the sheet

  • character_width (float) – The width of the characters

  • wb (workbook) – The object to the workbook

  • column_widths (dict) – The columns widths for this sheet

  • row_index (int) – start writing at this row

gantt_project_maker.excelwriter.write_project(project: type, header_info: dict, workbook: type, resource: type, worksheet, character_width: float, wb, row_index: int, level: int, total_hours: int | None = None)[source]

Write the project to a sheet

Parameters:
  • project (Project) – The gantt chart project

  • header_info (dict) – The header of the Excel file

  • workbook (WorkBook) – The Excel workbook

  • resource (Resource) – if given, filter tasks on resource

  • worksheet (Worksheet) – The Excel worksheet

  • character_width (float) – The width of the fixed columns

  • wb (object) – The workbook object to

  • row_index (int) – The index of the current row

  • level (int) – The level of the indent

  • total_hours (int, optional) – Total of hours written on this project so ware

Returns:

current row index, current project level, current total hours so fare

Return type:

row_index, level, total_hours

gantt_project_maker.excelwriter.write_project_to_excel(project: type, writer: type, sheet_name: str, resource: type | None = None, header_info: dict | None = None, column_widths: dict | None = None, character_width: float = 1.0, row_index: int = 0, header: bool = True)[source]

Write a multi index data frame to an Excel file with format

Parameters:
  • project (dict) – Main project

  • writer (obj) – Excel writer

  • sheet_name (str) – Name of the sheet

  • resource (obj) – Resource to filter on. If none, do not filter

  • column_widths (dict) – Fix width of these columns.

  • header_info (dict) – Information on the header

  • character_width (float) – Width of one character. Default = 0.7

  • row_index (int) – start writing at this row

  • header (bool) – write the header,

gantt_project_maker.excelwriter.write_resource(project: type, header_info: dict, workbook: type, worksheet, character_width: float, wb, row_index: int, level: int)[source]

Write the project to a sheet

Parameters:
  • project (Project) – The gantt chart project

  • header_info (dict) – The header of the Excel file

  • workbook (WorkBook) – The Excel workbook

  • worksheet (Worksheet) – The Excel worksheet

  • character_width (float) – The width of the fixed columns

  • wb (object) – The workbook object to

  • row_index (int) – The index of the current row

  • level (int) – The level of the indent

Returns:

gantt_project_maker.excelwriter.write_value_to_named_cell(writer: type, sheet_name: str, header_info: dict, row_index: int, value: int, column_key: str, cell_format: str | None = None)[source]

Write a line with the number of hours to the Excel file

Parameters:
  • writer (obj) – Excel writer

  • sheet_name (str) – Name of the sheet

  • header_info (dict) – Information on the header

  • row_index (int) – start writing at this row

  • value (str) – Number of hours to write to the ‘hours’ column

  • column_key (str) – write to this column

  • cell_format (str) – format of the column

gantt_project_maker.gantt module

This is a python class to create gantt chart using SVG

Author: Alexandre Norman - norman at xael.org

Contributors:

  • Sébastien NOBILI - pipoprods at free.fr

Modified by:

  • Eelco van Vliet

class gantt_project_maker.gantt.GroupOfResources(name, fullname=None)[source]

Bases: object

Class for grouping resources

add_resource(resource)[source]

Add a resource to the group of resources

Keyword arguments: resource – Resource object

add_task(task)[source]

Tell the resource that we have assigned a task

Keyword arguments: task – Task object

add_vacations(dfrom, dto=None)[source]

Add vacations to a resource beginning at [dfrom] to [dto] (included). If [dto] is not defined, vacation will be for [dfrom] day only

Keyword arguments: dfrom – datetime.date beginning of vacation dto – datetime.date end of vacation

is_available(date_to_check)[source]

Returns True if any resource is available at a given date, False if not. Availability is tasks from the global VACATIONS and resource’s ones.

Parameters:

date_to_check (object) – date day to look for

is_vacant(from_date: date, to_date: date)[source]

Check if any resource from the group is unallocated between for a given timeframe. Returns a list of available ressource names.

Parameters:
  • from_date (date) – First day

  • to_date (date) – Last day

nb_elements()[source]

Returns the number of resources

search_for_task_conflicts(all_tasks=False)[source]

Returns a dictionary 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

class gantt_project_maker.gantt.Milestone(name, start=None, depends_of=None, color=None, fullname=None, display=True, parent=None)[source]

Bases: Task

Class for manipulating Milestones

check_conflicts_between_task_and_resources_vacations()[source]

Displays a warning for each conflict between milestones and vacation of resources affected to the milestone

And returns a dictionary for resource vacation conflicts

csv(csv=None)[source]

Create CSV output from milestones

Keyword arguments: csv – None, dymmy object

property end_date

Returns the last day of the milestone, either the one which was given at milestone creation or the one calculated after checking dependencies

get_resources()[source]

Returns Resources used in the milestone

svg(prev_y=0, start=None, end=None, planning_start=None, planning_end=None, color=None, level=None, scale='d', title_align_on_left=False, offset=0)[source]

Return SVG for drawing this milestone.

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 planning_start – datetime.date start date of planning planning_end – datetime.date end date of planning color – string of color for drawing the project level – int, indentation level of the project, not used here scale – drawing scale (d: days, w: weeks, m: months, q: quarterly) title_align_on_left – boolean, align milestone title on left offset – X offset from image border to start of drawing zone

svg_dependencies(prj)[source]

Draws svg dependencies between milestone and project according to coordinates cached when drawing milestones

Keyword arguments: prj – Project object to check against

class gantt_project_maker.gantt.MySVGWriteDrawingWrapper(filename='noname.svg', size=('100%', '100%'), **extra)[source]

Bases: Drawing

Hack to allow using a file descriptor as filename

save(width='100%', height='100%')[source]

Write the XML string to filename.

class gantt_project_maker.gantt.Project(name='', color=None, side_bar_color=None, project_start=None, project_end=None, font=None)[source]

Bases: object

Class for handling projects

add_task(task)[source]

Add a Task to the Project. Task can also be a subproject

Keyword arguments: task – Task or Project object

csv(csv=None)[source]

Create CSV output from projects

Keyword arguments: csv – string, filename to save to OR file object OR None

property end_date

Returns last day of the project

get_resources()[source]

Returns Resources used in the project

get_tasks()[source]

Returns flat list of Tasks used in the Project and subproject

is_in_project(task)[source]

Return True if the given Task is in the project, False if not

Keyword arguments: task – Task object

make_svg_for_resources(filename: str, today: date | None = None, start: date | None = None, end: date | None = None, resources: list | None = None, one_line_for_tasks: bool = False, tag_filter: str = '', scale: str = 'd', title_align_on_left: bool = False, offset: float = 0, color_per_taks: bool = False)[source]

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 dictionary of dictionaries for vacation and task conflicts for resources

Parameters:
  • color_per_taks (bool) – Use color per task

  • filename (str) – filename to save to OR file object

  • today (date) – Day marked as a reference

  • start (date) – First day to draw

  • end (date) – Last day to draw

  • resources (list)

  • one_line_for_tasks (bool) – Use only one line to display all tasks ?

  • tag_filter (bool) – Display only those tags

  • scale (str) – Drawing scale (d: days, w: weeks, m: months, q: quarterly)

  • title_align_on_left (bool) – Align task title on left

  • offset (float) – X offset from image border to start of drawing zone

make_svg_for_tasks(filename, today=None, start=None, end=None, margin_left=None, margin_right=None, scale='d', title_align_on_left=False, offset=0)[source]

Draw gantt of tasks and output it to filename.

Parameters:
  • filename (str) – Filename to save to OR file object

  • today (date) – Date of day marked as a reference

  • start (date) – The first day to draw

  • end (date) – The last day to draw

  • margin_left (int) – Number of week to add to the grid before the project start

  • margin_right (int) – Number of week to add to the grid after the project end

  • scale (str) – drawing scale (d: days, w: weeks, m: months, q: quarterly)

  • title_align_on_left (bool) – Align task title on left

  • offset (float) – X offset from image border to start of drawing zone

Notes

  • If start or end are given, use them as reference, otherwise use project first and last day

nb_elements()[source]

Returns the number of tasks included in the project or subproject

property start_date

Returns first day of the project

svg(prev_y=0, start=None, end=None, planning_start=None, planning_end=None, color=None, level=0, scale='d', title_align_on_left=False, offset=0)[source]

Draw all tasks and add project name with a purple bar on the left side.

Parameters:
  • prev_y (int) – Line to start to draw

  • start (date) – First day to draw

  • end (date) – Last day to draw

  • planning_start (date) – not used here

  • planning_end (date) – not used here

  • color (str) – Color for drawing the project

  • level (int) – Indentation level of the project

  • scale (str) – Drawing scale (d: days, w: weeks, m: months, q: quarterly)

  • title_align_on_left (bool) – Align task title on left

  • offset (float) – X offset from image border to start of drawing zone

Returns:

SVG code and number of lines drawn for the project.

Return type:

svg, int

svg_dependencies(prj)[source]

Draws svg dependencies between tasks according to coordinates cached when drawing tasks

Keyword arguments: prj – Project object to check against

class gantt_project_maker.gantt.Resource(name, fullname=None, color=None)[source]

Bases: object

Class for handling resources assigned to tasks

Parameters:
  • name (str) – Name given to the resource (id)

  • fullname (str) – Long name given to the resource

  • color (str) – Color used to represent the resource in the resources’ overview

add_group(group_of_resources)[source]

Tell the resource it belongs to a GroupOfResources

Parameters:

group_of_resources (GroupOfResources) – The GroupOfResources to which a resource belongs to

add_task(task, hours_for_resource=None)[source]

Tell the resource that we have assigned a task

Parameters:
  • task (Task) – The task object to add

  • hours_for_resource (int) – The number of hours to assign to the task for this resource

add_vacations(from_date: date, to_date: date | None = None)[source]

Add vacations to a resource beginning at from_date to to_date (included). If to_date is not defined, vacation will be for from_data day only

Parameters:
  • from_date (date) – Beginning of vacation

  • to_date (date) – End of vacation

is_available(date_of_this_day)[source]

Returns True if the resource is available at given date, False if not. Availability is tasks from the global VACATIONS and resource’s ones.

Parameters:

date_of_this_day (date) – Day to look for

is_vacant(from_date, to_date)[source]

Check if the resource is unallocated between for a given timeframe. Returns True if the resource is free, False otherwise

Parameters:
  • from_date (date) – First day

  • to_date (date) – Last day

nb_elements()[source]

Returns the number of resources, 1 here

search_for_task_conflicts(all_tasks=False)[source]

Returns a dictionary 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

class gantt_project_maker.gantt.Task(name: str, start: date | None = None, stop: date | None = None, duration: int | None = None, depends_of: list | None = None, resources: list | None = None, percent_done: int = 0, color: str | None = None, fullname: str | None = None, display: bool = True, state: str = '', owner: str = '', parent: str = '')[source]

Bases: object

Class for manipulating Tasks

Notes

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.

Parameters:
  • name (str) – name of the task (id)

  • fullname (str) – Long name given to the resource

  • start (date) – First day of the task, default None

  • stop (date) – Last day of the task, default None

  • duration (int) – Duration of the task, default None

  • depends_of (list|None) – Tasks which are parents of this one, default None

  • resources (list|None) – Resources assigned to the task, default None

  • percent_done (int) – Percent of achievement, default 0

  • color (str, html color) – default None

  • display (bool) – Display this task, default True

  • state (str) – State of the task

  • owner (str) – Owner of the task

  • parent (str) – Parent of the task

add_depends(depends_of)[source]

Adds dependency to a task

Parameters:

depends_of (list) – Task which are parents of this one

check_conflicts_between_task_and_resources_vacations()[source]

Displays a warning for each conflict between tasks and vacation of resources affected to the task

And returns a dictionary for resource vacation conflicts

csv(csv=None)[source]

Create CSV output from tasks

Keyword arguments: csv – None, dymmy object

depends_of: list
property end_date

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()[source]

Returns Resources used in the task

is_in_project(task)[source]

Return True if the given Task is itself… (lazy coding ;)

Keyword arguments: task – Task object

nb_elements()[source]

Returns the number of task, 1 here

set_end_date(end_date)[source]

Set a end date, overriding the previous end date :param end_date: End date :type end_date: datetime

property start
property start_date

Returns the first day of the task, either the one which was given at task creation or the one calculated after checking dependencies

property stop
svg(prev_y: int = 0, start: date | None = None, end: date | None = None, planning_start: date | None = None, planning_end: date | None = None, color: str | None = None, level: int | None = None, scale: str = 'd', title_align_on_left: bool = False, offset: float = 0)[source]

Get the SVG for drawing this task.

Parameters:
  • prev_y (int) – line to start to draw

  • start (date) – First day to draw

  • end (date) – Last day to draw

  • planning_start (date) – Not used here

  • planning_end (date) – Not used here

  • color (str) – color for drawing the project

  • level (int) – Indentation level of the project, not used here

  • scale (str) – Drawing scale (d: days, w: weeks, m: months, q: quarterly)

  • title_align_on_left (bool) – align task title on left

  • offset (float) – X offset from image border to start of drawing zone

Returns:

the svg containter with the start line

Return type:

Container, number of lines

svg_dependencies(prj)[source]

Draws svg dependencies between task and project according to coordinates cached when drawing tasks

Keyword arguments: prj – Project object to check against

gantt_project_maker.gantt.add_vacations(start_date: date, end_date: date | None = None)[source]

Add vacations to a resource beginning at start_date to end_date (included). If end_date is not defined, vacation will be for start_date day only

Parameters:
  • start_date (date) – Beginning of a vacation

  • end_date – (date): End of a vacation

gantt_project_maker.gantt.define_font_attributes(fill: str = 'black', stroke: str = 'black', stroke_width: float = 0, font_family: str = 'Verdana', font_weight: str = 'normal', font_size: int = 15)[source]

Define font attributes

Parameters:
  • fill (str) – Fill color. Defaults to ‘black’

  • stroke (str) – Stroke color. Defaults to ‘black’

  • stroke_width (float) – stroke width. Defaults to 0

  • font_family (str) – Font family. Defaults to ‘Verdana’

  • font_weight (str) – Font weight. Defaults to ‘normal’

  • font_size (int) – Font size. Defaults to ‘15’

gantt_project_maker.gantt.define_not_worked_days(list_of_days)[source]

Define specific days off

Keyword arguments: list_of_days – list of integer (0: Monday … 6: Sunday) - default [5, 6]

gantt_project_maker.gantt.get_font_attributes(fill=None, stroke=None, stroke_width=None, font_family=None, font_weight=None, font_size=None)[source]

Return dictionary of font attributes

gantt_project_maker.gantt.init_log_to_sysout(level=20)[source]

Init global variable __LOG__ used for logging purpose

Keyword arguments: level – logging level (from logging.debug to logging.critical)

gantt_project_maker.gantt.task_within_range(task: ~gantt_project_maker.gantt.Task, planning_start: <module 'datetime' from '/home/docs/.asdf/installs/python/3.10.14/lib/python3.10/datetime.py'>, planning_end: <module 'datetime' from '/home/docs/.asdf/installs/python/3.10.14/lib/python3.10/datetime.py'>)[source]

Check if the task is in the range of the planning

Parameters:
  • task (object) – The task

  • planning_start (datetime) – Start of the planning

  • planning_end (datetime) – End of the planning

Returns:

True if the task is in range

Return type:

bool

gantt_project_maker.main module

This is the main start-up file of the project planner

gantt_project_maker.main.check_if_items_are_available(requested_items: list, available_items: dict, label: str = '')[source]

Check is the passed items in the list are available in the keys of the dictionary

Args: requested_items (list): All requested items in the list available_items (dict): The dictionary with the keys for which the check is performed label (str, optional): Used for information to the screen

gantt_project_maker.main.get_employee_name(employees_info, employee)[source]

get the full name of the employee from the settings file

gantt_project_maker.main.get_info_from_file_or_settings(settings, key)[source]

Get the information directly from the settings or from a separate file if a filename is given :param settings: Settings file :type settings: dict :param key: Key of the settings file we want to read :type key: str

Returns:

Structure with information from the settings or separate file

Return type:

dict

gantt_project_maker.main.get_pasted_employees(args_employee, employees_info)[source]

get the list of full names or requested employees and return as a comma separated string

gantt_project_maker.main.get_projects_from_arguments(projects_args) list[source]

Get the projects from the command line arguments and return a list

Parameters:

projects_args (list or None) – The list of projects may contain comma-separated values

Returns:

The list of projects

Return type:

list or None

gantt_project_maker.main.main(args)[source]

Wrapper allowing: func:postal_code2nuts to be called with string arguments in a CLI fashion

Instead of returning the value from: func:postal_code2nuts, it prints the result to the stdout in a nicely formatted message.

Parameters:

args (List[str]) – command line parameters as a list of strings (for example, ["--verbose", "42"]).

gantt_project_maker.main.make_banner(width=80) None[source]

Make a banner with the start time :param width: Width of the banner. :type width: int, optional :param Defaults to 80:

gantt_project_maker.main.parse_args(args)[source]

Parse command line parameters

Parameters:

args (List[str]) – command line parameters as a list of strings (for example, ["--help"]).

Returns:

argparse.Namespace: command line parameters namespace

Return type:

obj

gantt_project_maker.main.run()[source]

Calls: func:main passing the CLI arguments extracted from: obj:sys.argv

This function can be used as an entry point to create console scripts with setuptools.

gantt_project_maker.main.setup_logging(loglevel: int)[source]

Setup basic logging

Parameters:

loglevel (int) – minimum loglevel for emitting messages

gantt_project_maker.project_classes module

Class files for the gantt-project-maker project

class gantt_project_maker.project_classes.BasicElement(label, project_leader_key=None, start=None, dependent_of=None, color=None, project_color=None, detail=False, display=True, dayfirst=False, variables_info=None, parent=None)[source]

Bases: StartEndBase

class gantt_project_maker.project_classes.Employee(label: str, full_name: str | None = None, vacations: dict | None = None, color: str | None = None)[source]

Bases: object

Class holding information about one employee

Parameters:
  • label (str) – Label of the employee

  • full_name (str, optional) – Full name of the employee

  • vacations (dict, optional) – Dictionary of the vacations.

  • None (Defaults to)

  • color (str) – Color of the employee

class gantt_project_maker.project_classes.EmployeesContributingToTask[source]

Bases: object

Class holding all employees attached to a task with the number of hours

resources

all the gantt.Resources object

Type:

dict

hours

All the hours per resource working on this taks

Type:

dict

add_resource(employee, resource, hours=None)[source]

Add a resource to the list.

Parameters:
  • employee (str) – Key of the employee to add

  • resource (Resource) – resource to add

  • hours (float) – number of hours to add

get_resources()[source]

Retrieve a list of all the resources working on this task

Returns:

list of resources

class gantt_project_maker.project_classes.ProjectMileStone(label, project_leader_key=None, start=None, dependent_of=None, color=None, project_color=None, detail=False, display=True, dayfirst=True, variables_info=None, parent=None)[source]

Bases: BasicElement

add_milestone() Milestone[source]

Create a Milestone and add it to the planning

Returns:

Milestone of this project

Return type:

ProjectMileStone

class gantt_project_maker.project_classes.ProjectPlanner(programma_title: str | None = None, vacations_title: str | None = None, programma_color: str | None = None, vacation_color: str | None = None, output_file_name: Path | None = None, planning_start: datetime | None = None, planning_end: datetime | None = None, weeks_margin_left: int | None = None, weeks_margin_right: int | None = None, today: datetime | None = None, dayfirst: bool = False, scale: str | None = None, period_info: dict | None = None, excel_info: dict | None = None, details: bool | None = None, filter_employees: list | None = None, save_svg_as_pdf: bool = False, collaps_tasks: bool = False, periods: list | None = None, tasks_id: str = 'task', employee_id: str = 'employee', owner_id: str = 'owner', contributor_id: str = 'contributor', progress_file_info: dict | None = None)[source]

Bases: object

ProjectPlanner is class to handle the project planning and generate the output

Parameters:
  • programma_title (str, optional) – Main titel of the whole project

  • vacations_title (str, optional) – Title of the vacations project

  • programma_color (str, optional) – First color of the bar

  • output_file_name (str, optional) – Base name of the output files

  • planning_start (datetime, optional) – Start of the program

  • planning_end (datetime, optional) – End of the program

  • weeks_margin_left (int, optional) – Shift the end of the planning so many weeks to the left without adding projects

  • weeks_margin_right (int, optional) – Shift the end of the planning so many weeks to the right without adding projects

  • today (datetime, optional) – Today’s date

  • dayfirst (bool, optional) – Parse date with the day first. Defaults to False

  • scale (str, optional) – Which scale is used for the output

  • period_info (dict, optional) – Information on the periods output

  • excel_info (dict, optional) – Information on the Excel output

  • details (bool, optional) – If true, include the details to the programs

  • filter_employees (list, optional) – If not None, only add task to which employees in this list contribute

tasks_per_resource

Dataframe with tasks per resource

Type:

DataFrame

add_employees(employees_info: dict)[source]

Add the employees with their vacations

static add_global_information(fill='black', stroke='black', stroke_width=0, font_family='Verdana')[source]

Set global pen properties

Parameters:
  • fill (str, optional) – The fill color. Defaults to ‘black’.

  • stroke (str, optional) – The stroke color. Default to ‘black’

  • stroke_width (int, optional) – The stroke width. Default to 0

  • font_family (str, optional) – The font type. Defaults to ‘Verdana’

add_tasks_and_milestones(tasks_and_milestones=None, tasks_and_milestones_info=None, variables_info=None)[source]

Make all tasks en milestones

add_vacations(vacations_info)[source]

Add all the vacations

Parameters:

vacations_info (dict) – information of the vacations

export_to_excel(excel_output_directory: Path, excel_output_formats: list | None = None) None[source]

Write planning to an Excel file

Parameters:
  • excel_output_directory (Path) – Output directory of the Excel files

  • excel_output_formats (list) – List of Excel files to export as defined in the settings file.

get_dependencies(dependencies: str | dict) list[source]

Retrieve all dependencies

Parameters:

dependencies (str or dict) – In case the dependency is a string, there is only one. This will be obtained from the dict. The dependencies may also be stored in a dict. In that case, we retrieve them per item

Return type:

List of dependencies

get_dependency(key: str) Resource[source]

Search the object to which the dependency ‘key’ refers to

Parameters:

key (str) – Key of the dictionary to which the dependency refers to

Returns:

Object to which the key refers to.

Return type:

gantt.Resource

get_employees(employees: str | list | dict) EmployeesContributingToTask[source]

Turn a list of employees-strings into a list of employees gantt.Resource objects

Parameters:

employees (str, list, or dict) –

List of employees or, in case just one employee is given, a string. Now, also a dict can be defined

to add a number of hours for an employee to work on the task

Returns:

EmployeesContributingToTask

Return type:

object holding all employees

make_projects(project_leader_key, subprojects_info, subprojects_title, subprojects_selection, subprojects_color=None, variables_info=None)[source]

Create all the projects given in subprojects_info

Parameters:
  • project_leader_key (str) – The key of the project leader

  • subprojects_info (dict) – information per subproject

  • subprojects_title (dict) – Title of the subprojects

  • subprojects_selection (list) – List of the subprojects to include at the main level

  • subprojects_color (str, optional) – Color of the projects. Defaults to None

  • variables_info (dict, optional) – variables which can be used as replacements over the subprojects. Defaults to None

make_task_or_milestone(project_leader_key: str | None = None, task_properties: dict | None = None, project_color=None, variables_info=None, parent=None) ProjectTask | ProjectMileStone[source]

Add all the general tasks and milestones

Parameters:
  • project_leader_key (str) – The key of the project leader

  • task_properties (dict) – Dictionary with tasks or milestones

  • project_color (str) – Color of the parent project

  • variables_info – (dict, optional): Dictionary with variable information to replace strings. Default to None

Return type:

Task or milestone

write_excel_for_contributors(excel_file, header_info, summation_info=None, column_widths=None)[source]

A writer for the project plan of all contributors, one sheet per employee

Parameters:
  • excel_file (Path) – The filename of the Excel file

  • header_info (dict) – info for the header

  • summation_info (dict, optional) – info for the summation. Defaults to None

  • column_widths (dict, optional) – Fix width of specified columns

Returns:

write_excel_for_leaders(excel_file, header_info, column_widths)[source]

A writer for the project plan of all employees, one sheet per employee

Parameters:
  • excel_file (Path) – The filename of the Excel file

  • header_info (dict) – Information about the header of the Excel file

  • column_widths (dict) – Fix width of specified columns

Returns:

write_planning(planning_output_directory, resource_output_directory, vacations_output_directory, write_resources=False, write_vacations=False, periods=None, suffix=None)[source]

Write the planning to the output definitions

Args: planning_output_directory (Path): Output directory of the svg files of the planning resource_output_directory (Path): Output directory of the svg files of the resources vacations_output_directory (Path): Output directory of the svg files of the vacations write_resources (bool, optional): Write the resource’s file as well. Default to False write_vacations (bool, optional): Write the vacation file as well. Default to False periods (list, optional): Periods we want to add. If None, add all periods. Default to None (all periods) suffix (str, optional): Add a suffix to the final filename. Defaults to None

class gantt_project_maker.project_classes.ProjectTask(label, project_leader_key=None, start=None, end=None, duration=None, employees=None, dependent_of=None, color=None, project_color=None, detail=False, display=True, dayfirst=True, variables_info=None, parent=None)[source]

Bases: BasicElement

add_task() Task[source]

Add a task to the gantt charts :returns: Task to add the task to the gantt charts

class gantt_project_maker.project_classes.StartEndBase(start: str, end: str | None = None, dayfirst=False, variables_info=None)[source]

Bases: object

Basis van alle classes met een begin- en einddatum.

class gantt_project_maker.project_classes.Vacation(start, end=None, employee=None, dayfirst=False)[source]

Bases: StartEndBase

add_vacation()[source]

Add common or employee vacations

gantt_project_maker.project_classes.add_vacation_employee(employee: Resource, vacations: dict) dict[source]

Add the vacations of an employee

Parameters:
  • employee (Resource) – The employee for whom you want to add the vacation

  • vacations (dict) – A dictionary with items per vacation. Per vacation, you need a start and an end

Returns:

Dictionary with the vacations.

Return type:

dict

gantt_project_maker.project_classes.check_if_employee_in_contributing(filter_employees: list, contributing_employees: list) bool[source]

Check if any of the employees given in filter_employees is in contributing to this taks

gantt_project_maker.project_classes.extend_suffix(output_filename: Path, extensions: list | str)[source]

Add an extra suffix to the base filename

Parameters:
  • output_filename (Path) – Base filename

  • extensions (str or list) – Extra suffixes to add

Returns:

New filename with extra suffix

Return type:

Path

gantt_project_maker.project_classes.get_contributors_from_resources(projects_employee_global, contributors, all_resources)[source]

Get the contributors of this Task based on the global resources

Parameters:
  • projects_employee_global

  • contributors

  • all_resources (dict)

Returns:

contributors

Return type:

list

gantt_project_maker.project_classes.get_contributors_task(task, contributors)[source]

Get a list of contributors working on this Task based on the task resources.

Parameters:
  • task

  • contributors

Returns:

contributors

Return type:

list

gantt_project_maker.project_classes.get_nearest_saturday(date)[source]

Get the nearest Saturday with respect to ‘date’

Parameters:

date (datetime.date) – The reference date

Returns:

Nearest Saturday with respect to the reference date

Return type:

datetime.date

gantt_project_maker.project_classes.insert_variables(line: str, variables_info: dict | None = None)[source]

Replace variables inserted as {{ variable_name }} in line by the variables defined in variable_ifo

Parameters:
  • line (str) – Line to replace the variables with

  • variables_info (dict, optional) – variables to replace. Defaults to None, which leaves the whole line intact

Returns:

Line with variables replaced

Return type:

str

gantt_project_maker.project_classes.parse_date(date_in: str | datetime, date_default: str | None = None, dayfirst=False) date[source]

Lees de date_string en parse de datum

Parameters:
  • date_in (str) – Datum representatie

  • date_default – Als de date_string None is deze default waarde genomen.

  • dayfirst (bool) – Set the day first, e.g. 25-12-2023

Returns:

Datum

Return type:

datetime.date()

gantt_project_maker.utils module

Some utility functions

gantt_project_maker.utils.check_if_date(value: str)[source]

Check if an argument is a valid date :param value: date/time string :type value: str

Returns:

Date/time string

Return type:

str

Raises:

ArgumentTypeError – raised in case the value string is not a valid date/time string

gantt_project_maker.utils.deep_copy_dict(properties: dict) dict[source]

Create a deep copy of a nested dictionary

Parameters:

properties (dict) – The dictionary to copy

Returns:

New dictionary with the new values

Return type:

dict

gantt_project_maker.utils.get_task_contribution(name, task, owner_id) dict[source]

Taks contribution

Parameters:
  • name (str) – Name of the task to process.

  • task (Task) – Task instance

  • owner_id (str) – Owner key of the task

Returns:

task contribution of the resource

Return type:

dict

gantt_project_maker.utils.is_valid_date(label: str)[source]

Check is a label is a valid date

Parameters:

label (str) – a string value. In case a number is passed, it is casted into a string

Returns:

True if label is a valid date

Return type:

bool

gantt_project_maker.utils.is_valid_int(label: str)[source]

Check is label is a valid integer

Parameters:

label (str) – label to validate

Returns:

True if a valid number

Return type:

bool

gantt_project_maker.utils.is_valid_number(label: str)[source]

Check is label is a valid number

Parameters:

label (str) – label to validate

Returns:

True if a valid number

Return type:

bool

Module contents