-
-
Notifications
You must be signed in to change notification settings - Fork 54
/
_private.py
70 lines (58 loc) · 2.52 KB
/
_private.py
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
import argparse
import sys
from configparser import ConfigParser
from typing import Any, Type
import cargo
from ...command import Command
from ...components.activities import Activities, activities
from ...components.add_entry import AddEntry
from ...components.commands import Commands
from ...components.config import config
from ...components.config_dirname import ConfigDirname, config_dirname
from ...components.config_filename import ConfigFilename, config_filename
from ...components.data_dirname import DataDirname, data_dirname
from ...components.data_filename import DataFilename, data_filename
from ...components.default_config import DefaultConfig
from ...components.entries import Entries, entries
from ...components.entry_lines import EntryLines
from ...components.entry_parser import EntryParser
from ...components.local_timezone import LocalTimezone, local_timezone
from ...components.now import Now, now
from ...components.output import Output
from ...components.parse_args import parse_args
from ...components.report_args import ReportArgs, csv_section_name_to_csv_section, report_args # noqa
from ...components.report_model import ReportModel
from ...components.report_model.model import report
from ...components.timezone_config import TimezoneConfig, timezone_config
from ...report.csv_view import CSVReportView
def create_container():
_container = cargo.containers.Standard()
_container[Activities] = activities
_container[AddEntry] = AddEntry
_container[argparse.Namespace] = parse_args
_container[Commands] = []
_container[ConfigParser] = config
_container[ConfigDirname] = config_dirname
_container[ConfigFilename] = config_filename
_container[DataDirname] = data_dirname
_container[DataFilename] = data_filename
_container[DefaultConfig] = DefaultConfig
_container[Entries] = entries
_container[EntryParser] = EntryParser
_container[EntryLines] = EntryLines
_container[LocalTimezone] = local_timezone
_container[Now] = now
_container[Output] = sys.stdout
_container[ReportArgs] = report_args
_container[ReportModel] = report
_container[TimezoneConfig] = timezone_config
_container[CSVReportView] = CSVReportView
return _container
def register_command(command: Command):
commands[command.name] = command
container[Commands].append(command)
container[command.handler_class] = command.handler_class
def register_component(interface: Type, constructor: Any):
container[interface] = constructor
commands = {}
container = create_container()