-
Notifications
You must be signed in to change notification settings - Fork 0
/
graph.py
851 lines (706 loc) · 26.3 KB
/
graph.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
from __future__ import annotations
from typing import Dict, Any, Union, List, Tuple
import logging
import warnings
import time
import copy
import os
# Needed for type checking
from typeguard import check_type
import numpy as np
import numpy.typing as npt
# General configs
# # Raise error whenever there is a mistake, even if not critical
MERCILESS = True
# # Writes graph on log whenever there is a change
VERBOSE = False
# Log configs
log_date = str(time.strftime("%d-%m-%y %H:%M:%S"))
log_dir = "logs/"
log_name = f"graphlog {log_date}.log"
print(f"Session log started at {log_dir}{log_name}")
# Warning configs
warnings.simplefilter("always")
# Import warning
warning = f" This library is a work in progress and may work unexpectedly"
warnings.warn(warning, ImportWarning)
# =============================================================================
# Sets up log
def start_log():
"""
Sets up log when import is made
"""
if not os.path.exists(log_dir):
os.mkdir(log_dir)
logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s',
datefmt="%d-%m-%y %H:%M:%S",
filename=f"{log_dir}{log_name}",
# filename=f"{log_dir}testlog.log",
filemode='w', level=logging.DEBUG)
# Handles errors and warning messages
def error_handler(message, type):
"""
Handles errors and warning messages, logging everything
When MERCILESS == True, raises an error
Args:
message (str): Message to be thrown
type (str): Error type to be thrown
Raises:
error: Error according to type
"""
if type == 'Runtime':
error = RuntimeError
warning = RuntimeWarning
if type == 'Type':
error = TypeError
warning = RuntimeWarning
if type == 'Index':
error = IndexError
warning = RuntimeWarning
if type == 'Key':
error = KeyError
warning = RuntimeWarning
warnings.warn(message, warning)
logging.warning(f" <'{type}Error'> {message}")
if MERCILESS:
logging.error(f" <'merciless == True'> Execution stopped")
raise error(message)
...
# Sets up log when import is made
def start_log():
if not os.path.exists(log_dir):
os.mkdir(log_dir)
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
datefmt="%d-%m-%y %H:%M:%S",
filename=f"{log_dir}{log_name}",
filemode='w', level=logging.DEBUG)
# Start classes
def start_classes():
"""
Start essential auxiliary classes at import
"""
Type()
Validator()
Node()
Converter()
Builder()
# Starts essential auxiliary classes
def start_classes():
Type()
Validator()
Node()
# =============================================================================
# Type class. Determines lib specific data types. Used in type checks
class Type():
"""
Type handler
Determines lib specific data types
Used in type checks
Each function checks a different type
Calls error handler whenever an inconsistency is found
Returns:
Bool: Whether input is of predetermined type
"""
@classmethod
def __init__(cls):
cls.idtype = int
cls.datatype = Any
cls.flagtype = Union[int, float, str]
cls.nodetype = Node
cls.weighttype = Union[int, float]
cls.nodelisttype = Dict[cls.idtype, cls.nodetype]
cls.edgelisttype = Dict[cls.idtype, cls.weighttype]
cls.adjmatrixtype = Union[List[List[Union[cls.weighttype, None]]],
npt.NDArray[npt.NDArray[Union[cls.weighttype, None]]]]
cls.adjlisttype = Union[List[List[Tuple[cls.idtype, cls.weighttype]]],
npt.NDArray[npt.NDArray[Tuple[cls.idtype, cls.weighttype]]]]
cls.adjdicttype = Dict[cls.idtype, Union[cls.edgelisttype, None]]
@ classmethod
def is_id(cls, id):
try:
check_type("id", id, cls.idtype)
if not id >= 0:
error_handler("Id out of bounds", "Key")
return True
except:
error_handler("Id failed type check", "Type")
return False
@ classmethod
def is_data(cls, data):
# equation = check_type("data", data, cls.datatype)
return True
@ classmethod
def is_flag(cls, flag):
try:
check_type("flag", flag, cls.flagtype)
return True
except:
error_handler("Flag failed type check", "Type")
return False
@ classmethod
def is_node(cls, node):
try:
check_type("node", node, cls.nodetype)
return True
except:
error_handler("Node failed type check", "Type")
return False
@ classmethod
def is_weight(cls, weight):
try:
check_type("weight", weight, cls.weighttype)
return True
except:
error_handler("Weight failed type check", "Type")
return False
@ classmethod
def is_nodelist(cls, nodelist):
try:
check_type("nodelist", nodelist, cls.nodelisttype)
for key, val in nodelist.items():
cls.is_id(key)
cls.is_node(val)
return True
except:
error_handler("nodelist failed type check", "Type")
return False
@ classmethod
def is_edgelist(cls, edgelist):
try:
check_type("edgelist", edgelist, cls.edgelisttype)
for key, weight in edgelist.items():
cls.is_id(key)
if weight != None:
cls.is_weight(weight)
return True
except:
error_handler("edgelist failed type check", "Type")
return False
@ classmethod
def is_adjmatrix(cls, adj_mat):
try:
check_type("adjmatrix", adj_mat, cls.adjmatrixtype)
mat_n = len(adj_mat)
for line in adj_mat:
if len(line) != mat_n:
error_handler("Adjmatrix not homogeneous", "Index")
return True
except:
error_handler("adjmatrix failed type check", "Type")
return False
@ classmethod
def is_adjlist(cls, adj_list):
try:
check_type("adjlist", adj_list, cls.adjlisttype)
return True
except:
error_handler("adjlist failed type check", "Type")
return False
@ classmethod
def is_adjdict(cls, adj_dict):
try:
check_type("adjdict", adj_dict, cls.adjdicttype)
return True
except:
error_handler("adjdict failed type check", "Type")
return False
# =============================================================================
# Node class. Creates node objects with data, flag and edges
class Node():
"""
Node class
Creates node objects with data, flag and edges
Creates empty edges as an empty dictionary when no edge is called
"""
def __init__(self,
data: Type.datatype = None,
flag: Type.flagtype = None,
edges: Type.edgelisttype = None):
"""
Initializes a node
Args:
data (Type.datatype, optional): Internal node data. Defaults to None.
flag (Type.flagtype, optional): Node flag. Defaults to None.
edges (Type.edgelisttype, optional): Node edges. Defaults to None.
"""
# your object
self.data = data
# int, float or str. May be used for node markings
self.flag = flag
# Dict{id : weight}
# Check and attribution necessary due to dictionary particulars
if edges == None:
edges = {}
self.edges = edges
def __len__(self):
return len(self.edges)
def set_data(self, data: Type.datatype):
raise NotImplementedError
def get_data(self):
raise NotImplementedError
def set_flag(self, flag: Type.flagtype):
raise NotImplementedError
def get_flag(self):
raise NotImplementedError
def set_edges(self):
raise NotImplementedError
# =============================================================================
# Graph class. Handles graphs and operations on them
class Graph():
"""
Graph class
Handles graphs and operations on them
Keeps object count
Keeps class specific toggles
"""
# Each graph has a specific class id for logging purposes
graph_count = 0
# Advanced settings. Only touch when sure
# Checks new graph by default. Can be toggled for performance
check_graph_at_initialization = True
# Raise exception whenever a mistake is made by default, whether fatal or not
def __init__(self, nodes: Type.nodelisttype = None):
"""
Initializes new graph objects and call validators
Calls class specific functions to deal with class attributes
Args:
nodes (Type.nodelisttype, optional): Dict {id: Node} of nodes. Defaults to None.
"""
# Dict{id : Node}
# Check and attribution necessary due to dictionary particulars
if nodes == None:
nodes = {}
# Sets graph id
self.graph_id = self.set_graph_id()
# Dict{id : Node}
self.nodes = nodes
# Registers last used id
self.last_id = self.size - 1
# Check whether starter graph is valid
if self.check_graph_at_initialization:
Validator.is_graph(self)
logging.info(
f" Graph #{self.graph_id} initialized with size {self.size}")
if VERBOSE:
logging.info(str(Converter.to_adjdict(self)))
def __len__(self):
return len(self.nodes)
@ property
def size(self):
return self.__len__()
@ classmethod
def set_graph_id(cls):
cls.graph_count += 1
return cls.graph_count - 1
# Adds edge source_id -> target_id with weight when applicable
def add_edge(self, source_id: Type.idtype,
target_id: Type.idtype,
weight: Type.weighttype = 0,
symmetric: bool = False):
"""
Adds edge source_id -> target_id with weight when applicable
Adds edge symmetrically (if (a,b) in edges, then (b, a) also in edges)) when toggled
Args:
source_id (Type.idtype): Edge origin node. Where edge is stored
target_id (Type.idtype): Edge target node. Key on edges in node[source_id]
weight (Type.weighttype, optional): Edge weight. Defaults to 0.
symmetric (bool, optional): Whether edge is to be added symmetrically. Defaults to False.
Returns:
Bool: Whether edge was added or not
"""
try:
Type.is_id(source_id)
Type.is_id(target_id)
Type.is_weight(weight)
if not isinstance(symmetric, bool):
error_handler("Symmetric is not bool", "Type")
if not (source_id in self.nodes and target_id in self.nodes):
error_handler("Edge id not found", "Key")
self.nodes[source_id].edges[target_id] = weight
logging.info(
f" Edge ({source_id}->{target_id} [{weight}]) added to graph #{self.graph_id}")
if VERBOSE:
logging.info(str(Converter.to_adjdict(self)))
if symmetric:
self.add_edge(target_id, source_id, weight)
return True
except:
error_handler("Edge's id(s) not in nodes", "Key")
return False
def remove_edge(self, source_id: Type.idtype, target_id: Type.idtype, symmetric: bool = False):
"""
Removes edge source_id -> target_id
Removes edge symmetrically (if (a,b) in edges, then (b, a) also in edges)) when toggled
Args:
source_id (Type.idtype): Edge origin node. Where edge is stored
target_id (Type.idtype): Edge target node. Key on edges in node[source_id]
symmetric (bool, optional): Whether edge is to be removed symmetrically. Defaults to False.
Returns:
Bool: Whether edge was removed or not
"""
try:
Type.is_id(source_id)
Type.is_id(target_id)
if not isinstance(symmetric, bool):
error_handler("Symmetric is not bool", "Type")
if not (source_id in self.nodes and target_id in self.nodes):
error_handler("Edge id not found", "Key")
if symmetric:
self.remove_edge(target_id, source_id)
node = self.nodes[source_id]
if node.edges:
if target_id in node.edges:
node.edges.pop(target_id)
logging.info(
f" Edge ({source_id}->{target_id}) removed from graph #{self.graph_id}")
if VERBOSE:
logging.info(str(Converter.to_adjdict(self)))
return True
error_handler("Edge not found", "Key")
except:
error_handler("Edge not found", "Key")
return False
# Adds nodes with data, flag and edges when applicable
def add_node(self, data: Type.datatype = None,
flag: Type.flagtype = None,
edges: Type.edgelist = None):
"""
Adds nodes with data, flag and edges when applicable
Args:
data (Type.datatype, optional): Node data. Defaults to None.
flag (Type.flagtype, optional): Node flag. Defaults to None.
edges (Type.edgelist, optional): Node edges. Defaults to None.
Returns:
Node: Returns added node object when valid
Bool: Returns False when failed adding node
"""
if edges == None:
edges = {}
new_node = Node(data, flag, edges)
new_id = self.last_id + 1
try:
Validator.check_node(new_node, self, _adding=True)
self.nodes[new_id] = new_node
self.last_id += 1
logging.info(f" Node #{new_id} added to graph #{self.graph_id}")
if VERBOSE:
logging.info(str(Converter.to_adjdict(self)))
return new_node
except:
error_handler("Node not valid. Was not added", "Key")
return False
# Removes nodes and all edges pointing to it
def remove_node(self, id: Type.idtype):
"""
Removes nodes and all edges pointing to it
Args:
id (Type.idtype): Id of the node to be removed
Returns:
Node: Node removed when valid
Bool: False when failed to find node
"""
try:
Type.is_id(id)
if id in self.nodes:
popped = self.nodes.pop(id)
if self.size > 0:
for node in self.nodes.values():
if node.edges:
if id in node.edges:
node.edges.pop(id)
logging.info(
f" Node #{id} removed from graph #{self.graph_id}")
if VERBOSE:
logging.info(
str(Converter.to_adjdict(self)))
return popped
except:
error_handler("Node not found", "Key")
return False
def get_nodes(self):
return self.nodes
def copy(self):
"""
Returns deep copy (identical copy of object and its internal objects)
Returns:
Graph: New graph object identical to original
"""
return copy.deepcopy(self)
# =============================================================================
# Validators
class Validator():
"""
Validator class. Checks graph, nodes and edges to ensure all properties are
valid
"""
# Checks whether graph is valid
@ staticmethod
def is_graph(graph: Graph):
"""
Validates the entire graph
Args:
graph (Graph): Graph to be checked
Returns:
Bool: Whether the graph is valid or not
"""
try:
nodes = graph.nodes
last_id = graph.last_id
if not nodes:
# Empty graph is a valid graph
return True
Type.is_nodelist(nodes)
for key, node in nodes.items():
id_range = key <= last_id
id_checks = id_range
if not id_checks:
error_handler("Id not in graph range", "Index")
Validator.check_node(node, graph)
return True
except:
error_handler("Graph failed type check", "Type")
return False
# Checks whether node is valid
@ staticmethod
def check_node(node: Type.nodetype, graph: Graph, _adding=False):
"""
Checks whether node is valid
Also used internally by Graph to check new nodes
Hence the adding parameter (shouldn't be used externally)
Args:
node (Type.nodetype): Node to be checked
graph (Graph): Graph to which node belongs
_adding (bool, optional): Used internally when adding new node. Defaults to False.
Returns:
Bool: Whether or not node is valid
"""
try:
Type.is_node(node)
check_type("graph", graph, Graph)
Type.is_nodelist(graph.nodes)
flag = node.flag
if flag:
Type.is_flag(flag)
if node.edges != {}:
Type.is_edgelist(node.edges)
for key, weight in node.edges.items():
if key not in graph.nodes:
if not (_adding and key == graph.last_id + 1):
error_handler("Edge node not in nodes", "Key")
Type.is_weight(weight)
return True
except:
error_handler("Node failed type check", "Type")
return False
# =============================================================================
# Graph builders
class Builder():
"""
Graph building methods
"""
# Advanced method to build graph from adjacency matrix
@ staticmethod
def adj_matrix(adj_mat: Type.adjmatrixtype,
obj_list: List[Any] = None):
"""
Advanced method to build graph from adjacency matrix
Args:
adj_mat (Type.adjmatrixtype): Source adjacency matrix
obj_list (List[Any], optional): Object list to go on 'node.data'. Defaults to None.
Returns:
Graph: Built and checked graph
Bool: False if failed building graph
"""
nodes = {}
try:
Type.is_adjmatrix(adj_mat)
for i, line in enumerate(adj_mat):
if obj_list:
nodes[i] = Node(data=obj_list[i])
else:
nodes[i] = Node()
for j, weight in enumerate(line):
if weight != None:
nodes[i].edges[j] = weight
logging.info(f" Adjacency matrix is valid. Graph is being built")
return Graph(nodes=nodes)
except:
error_handler("Broken adjacency matrix", "Runtime")
return False
# Advanced method to build graph from adjacency list
@ staticmethod
def adj_list(adj_list: Type.adjlisttype,
obj_list: List[Any] = None):
"""
Advanced method to build graph from adjacency list
Args:
adj_list (Type.adjlisttype): Source adjacency list
obj_list (List[Any], optional): Object list to go on 'node.data'. Defaults to None.
Returns:
Graph: Built and checked graph
Bool: False if failed building graph
"""
nodes = {}
try:
Type.is_adjlist(adj_list)
for i, edgelist in enumerate(adj_list):
if obj_list:
nodes[i] = Node(data=obj_list[i])
else:
nodes[i] = Node()
for j, weight in edgelist:
nodes[i].edges[j] = weight
logging.info(f" Adjacency list is valid. Graph is being built")
return Graph(nodes=nodes)
except:
error_handler("Broken adjacency list", "Runtime")
return False
# Advanced method to build graph from adjacency dictionary
@ staticmethod
def adj_dict(adj_dict: Type.adjdicttype,
obj_list: List[Any] = None):
"""
Advanced method to build graph from adjacency dictionary
Args:
adj_dict (Type.adjdicttype): Source adjacency dictionary
obj_list (List[Any], optional): Object list to go on 'node.data'. Defaults to None.
Returns:
Graph: Built and checked graph
Bool: False if failed building graph
"""
nodes = {}
try:
Type.is_adjdict(adj_dict)
for i, edgelist in adj_dict.items():
if obj_list:
nodes[i] = Node(data=obj_list[i])
else:
nodes[i] = Node(edges=edgelist)
logging.info(
f" Adjacency dictionary is valid. Graph is being built")
return Graph(nodes=nodes)
except:
error_handler("Broken adjacency dictionary", "Runtime")
return False
# Refactors graph to clean "waste"
@ staticmethod
def refactor(graph: Graph):
"""
Refactors graph to clean "waste"
Clears node flags
Removes unused node ids
Args:
graph (Graph): Graph to be cleaned
Returns:
Graph: Refactored graph
Bool: False when failed to refactor
"""
try:
Validator.is_graph(graph)
new_nodes = {}
for new_id, node in enumerate(graph.nodes.values()):
node.flag = new_id
new_nodes[new_id] = Node(data=node.data)
for new_id, node in enumerate(graph.nodes.values()):
for eid, weight in node.edges.items():
new_nodes[new_id].edges[graph.nodes[eid].flag] = weight
refac = Graph(new_nodes)
return refac
except:
error_handler("Broken graph in refactor", "Runtime")
return False
# =============================================================================
# Converts graphs to native data types
class Converter():
"""
Converts graphs to native data types for printing, exporting and all
"""
# Returns an equivalent adjacency matrix and node data list
@ staticmethod
def to_adjmatrix(graph: Graph, get_nodes=False):
"""
Returns an equivalent adjacency matrix and node data list
Args:
graph (Graph): Graph to be converted
get_nodes (bool, optional): Whether to get data list from 'node.data' . Defaults to False.
Returns:
adjmatrixtype, list: Resulting adjacency matrix and data list
adjmatrixtype: Resulting adjacency matrix
Bool: False when failed to convert
"""
try:
Validator.is_graph(graph)
if not isinstance(get_nodes, bool):
error_handler("get_nodes is not bool", "Type")
adjmatrix = [[None for j in range(0, graph.last_id + 1)]
for i in range(0, graph.last_id + 1)]
nodes = [None for i in range(0, graph.last_id + 1)]
for source_id, node in graph.nodes.items():
nodes[source_id] = node.data
for target_id, weight in node.edges.items():
adjmatrix[source_id][target_id] = weight
if get_nodes:
return adjmatrix, nodes
return adjmatrix
except:
error_handler("Wrong parameters in converter", "Runtime")
return False
@ staticmethod
def to_adjlist(graph: Graph, get_nodes=False):
"""
Returns an equivalent adjacency list and node data list
Edges returned as tuples due to duck typing
Args:
graph (Graph): Graph to be converted
get_nodes (bool, optional): Whether to get data list from 'node.data' . Defaults to False.
Returns:
adjlisttype, list: Resulting adjacency list and data list
adjlisttype: Resulting adjacency list
Bool: False when failed to convert
"""
try:
Validator.is_graph(graph)
if not isinstance(get_nodes, bool):
error_handler("get_nodes is not bool", "Type")
adjlist = [None for i in range(0, graph.last_id + 1)]
nodes = [None for i in range(0, graph.last_id + 1)]
for id, node in graph.nodes.items():
nodes[id] = node.data
adjlist[id] = list(node.edges.items())
if get_nodes:
return adjlist, nodes
return adjlist
except:
error_handler("Wrong parameters in converter", "Runtime")
return False
@ staticmethod
def to_adjdict(graph: Graph, get_nodes=False):
"""
Returns an equivalent adjacency dict and node data list
Args:
graph (Graph): Graph to be converted
get_nodes (bool, optional): Whether to get data list from 'node.data' . Defaults to False.
Returns:
adjdicttype, list: Resulting adjacency dict and data list
adjdicttype: Resulting adjacency dict
Bool: False when failed to convert
"""
try:
Validator.is_graph(graph)
if not isinstance(get_nodes, bool):
error_handler("get_nodes is not bool", "Type")
adjdict = {}
nodes = [None for i in range(0, graph.last_id + 1)]
for id, node in graph.nodes.items():
nodes[id] = node.data
adjdict[id] = node.edges
if get_nodes:
return adjdict, nodes
return adjdict
except:
error_handler("Wrong parameters in converter", "Runtime")
return False
# =============================================================================
# Starters
start_log()
start_classes()