aboutsummaryrefslogtreecommitdiff
path: root/sgdfi/_dbs
diff options
context:
space:
mode:
authorThomas "Cakeisalie5" Touhey <thomas@touhey.fr>2018-10-07 01:03:57 +0200
committerThomas "Cakeisalie5" Touhey <thomas@touhey.fr>2018-10-07 01:03:57 +0200
commit45365f0d5eeccdeb4e1b15d38149a5f75ad655c9 (patch)
tree4e5d08455b8d84a136b6f159454da9b4615e70a0 /sgdfi/_dbs
parentaacdcf1e860c9afc687b868dc7417307e75efc8a (diff)
Wrote the README, working on the interface.
Diffstat (limited to 'sgdfi/_dbs')
-rw-r--r--sgdfi/_dbs/_event.py75
1 files changed, 75 insertions, 0 deletions
diff --git a/sgdfi/_dbs/_event.py b/sgdfi/_dbs/_event.py
new file mode 100644
index 0000000..74ae749
--- /dev/null
+++ b/sgdfi/_dbs/_event.py
@@ -0,0 +1,75 @@
+#!/usr/bin/env python3
+#******************************************************************************
+# Copyright (C) 2018 Thomas "Cakeisalie5" 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.