Coverage for skema/utils/misc.py: 87%

15 statements  

« prev     ^ index     » next       coverage.py v7.5.0, created at 2024-04-30 17:15 +0000

1import sys 

2import platform 

3import random 

4import uuid 

5 

6# ------------------------------------------- 

7# Remove this block to generate different 

8# UUIDs everytime you run this code. 

9# This block should be right below the uuid 

10# import. 

11rd = random.Random() 

12uuid.uuid4 = lambda: uuid.UUID(int=rd.getrandbits(128)) 

13# ------------------------------------------- 

14 

15def test_pygraphviz(error_message): 

16 """Tests whether the pygraphviz package is installed. 

17 If not, raises an exception""" 

18 

19 # NOTE: Commented out until resolved libraries in SKEMA repo 

20 #if "pygraphviz" not in sys.modules: 

21 # raise ModuleNotFoundError( 

22 # "The pygraphviz package is not installed! " 

23 # f"{error_message}" 

24 # ) 

25 

26 

27def choose_font(): 

28 """Choose font for networkx graph labels, etc.""" 

29 operating_system = platform.system() 

30 

31 if operating_system == "Darwin": 

32 font = "Gill Sans" 

33 elif operating_system == "Windows": 

34 font = "Candara" 

35 else: 

36 font = "Ubuntu" 

37 

38 return font