-
Notifications
You must be signed in to change notification settings - Fork 0
/
romance_dawn.py
69 lines (56 loc) · 1.75 KB
/
romance_dawn.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
# Main script to track the Chapter release
# Module importation
import os.path
import yaml
# la creme de la creme
from logbook import Logbook
# Logging
import logging
log = logging.getLogger(__name__)
# =============================================================================
def romance_dawn(
punk_records: str,
) -> None:
"""
Main function with the whole structure of the activity:
1. Read configuration file
2. Read logbook with all the locally logged chapters
3. Update logbook with the latest information online
4. Flow control
INPUTS
punk_records :: configuration file in yaml format
OUTPUT
None
"""
# Abs path for the configuration file
conf_file = os.path.normpath(
os.path.join(
os.path.dirname(__file__),
punk_records
)
)
# Read configuration file
log.debug(f'Reading configuration file: {os.path.basename(conf_file)}')
with open(conf_file, 'r') as file:
conf = yaml.safe_load(file)
# Init logbook
logbook = Logbook(
logbook_file=conf['logbook']['logbook']
)
log.info('Starting our adventure!')
logbook.update(
url=conf['online']['base_url'] + conf['online']['manga_url'],
cooldown=conf['flow']['cooldown'],
max_count=conf['flow']['max_count']
)
# =============================================================================
if __name__ == '__main__':
# Set up logging
from odensJournal import log_setup
log_setup()
log.info('*** PROGRAM START ***')
romance_dawn(
punk_records='punk_records.yml'
)
log.info('*** END OF PROGRAM ***')
# =============================================================================