aboutsummaryrefslogtreecommitdiff
path: root/sgdfi/_dbs/_event.py
blob: b25c27a7499b09ddd4d7760fe155d7372c44cd49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env python3
#******************************************************************************
# Copyright (C) 2018 Thomas Touhey <thomas@touhey.fr>
# This file is part of the sgdfi project, which is MIT-licensed.
#******************************************************************************
""" Event type reference for SGDFi. """

from enum import Enum as _Enum, unique as _unique

__all__ = ["EventType", "EventTypeData"]

@_unique
class EventType(_Enum):
	""" The default type (unknown). """
	UNKNOWN = 0

	""" Sortie journée. """
	DAY = 1

	""" Réunion demi-journée. """
	HALF = 2

	""" Week-End. """
	WEEKEND = 3

	""" Réunion de travail. """
	WORK_MEETING = 4

	""" Camp Année. """
	YEAR_CAMP = 5

	""" Camp Été. """
	CAMP = 6

	""" Extrajob. """
	EXTRAJOB = 7

# Each entry in `_EventTypeData` has the following fields:
# - Full type name.
# - Abbreviated type name for XLS exports.

_EventTypeData = {
	EventType.DAY: ("Sortie Journée", ""),
	EventType.HALF: ("Réunion Demi-Journée", "DemJour"),
	EventType.WEEKEND: ("Week-End", "WE"),
	EventType.WORK_MEETING: ("Réunion de travail", "RéuTrav"),
	EventType.YEAR_CAMP: ("Camp Année", ""),
	EventType.CAMP: ("Camp Eté", ""),
	EventType.EXTRAJOB: ("Extrajob", ""),
}

# Make the leads.

_EventTypeLeads = {}
_EventTypeLeads.update({full.strip().casefold(): i \
	for i, (full, abbr) in _EventTypeData.items()})
_EventTypeLeads.update({abbr.strip().casefold(): i \
	for i, (full, abbr) in _EventTypeData.items()})

# Define the data class.

class EventTypeData:
	""" The event type data. """

	def __init__(self, value):
		def isid(value):
			try:
				EventType(value)
			except ValueError:
				return False
			return True

		# TODO

# End of file.