File size: 1,664 Bytes
4cf88e8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from typing import Dict

from config import config


def create_msg_from(logs: [Dict], docs) -> str:
    log_messages = []
    log_msg = config['log_msg']
    docs_seen = []
    msg = ''
    for doc in docs:
        for log in logs:
            if doc.name in log.keys():
                log = log[doc.name]
                if 'suppressed_styles' in log.keys():
                    if log['suppressed_styles']:
                        msg = log_msg['suppressed_styles']
                        for style_name in log['suppressed_styles']:
                            msg += "  -   " + style_name + "\n"
                    if log['modified_styles']:
                        msg += log_msg['modified_styles']
                        for style, log_s in log['modified_styles']:
                            msg += log_msg['modified_style'] + style + "\n"
                            for modif, _ in log_s:
                                msg += log_msg[modif] + ' '
                            msg += '\n'
                    if log['added_styles']:
                        msg += log_msg['added_styles']
                        for style_name in log['added_styles']:
                            msg += "  -   " + style_name + "\n"
                if 'style_mapping' in log.keys():
                    msg = log['style_mapping']
                if msg:
                    if doc not in docs_seen:
                        msg = log_msg['document'] + doc.name + '\n' + msg
                        docs_seen.append(doc)
                    log_messages.append(msg)
                    msg = ''
    log_messages_str = '\n'.join(log_messages)
    return log_messages_str