diff --git a/doc/sample_html/d_7b071bdc2a35fa80___init___py.html b/doc/sample_html/d_7b071bdc2a35fa80___init___py.html index 9617b3184..3c42d94e6 100644 --- a/doc/sample_html/d_7b071bdc2a35fa80___init___py.html +++ b/doc/sample_html/d_7b071bdc2a35fa80___init___py.html @@ -66,8 +66,8 @@

^ index     » next       - coverage.py v7.3.2, - created at 2023-10-02 11:44 -0400 + coverage.py v7.3.3, + created at 2023-12-14 06:26 -0500

- 500 statements   - - + 483 statements   + + - +

« prev     ^ index     » next       - coverage.py v7.3.2, - created at 2023-10-02 11:44 -0400 + coverage.py v7.3.3, + created at 2023-12-14 06:26 -0500

- 845 statements   - - + 854 statements   + +

@@ -66,8 +66,8 @@

^ index     » next       - coverage.py v7.3.2, - created at 2023-10-02 11:44 -0400 + coverage.py v7.3.3, + created at 2023-12-14 06:26 -0500

- 70 statements   + 68 statements   - +

@@ -66,8 +66,8 @@

^ index     » next       - coverage.py v7.3.2, - created at 2023-10-02 11:44 -0400 + coverage.py v7.3.3, + created at 2023-12-14 06:26 -0500

+

+ « prev     + ^ index     + » next +       + coverage.py v7.3.3, + created at 2023-12-14 06:26 -0500 +

+ + + +
+

1""" Utilities for cog. 

+

2""" 

+

3 

+

4import contextlib 

+

5import functools 

+

6import hashlib 

+

7import os 

+

8import sys 

+

9 

+

10 

+

11# Support FIPS mode where possible (Python >= 3.9). We don't use MD5 for security. 

+

12md5 = ( 

+

13 functools.partial(hashlib.md5, usedforsecurity=False) 

+

14 if sys.version_info >= (3, 9) 

+

15 else hashlib.md5 

+

16) 

+

17 

+

18 

+

19class Redirectable: 

+

20 """ An object with its own stdout and stderr files. 

+

21 """ 

+

22 def __init__(self): 

+

23 self.stdout = sys.stdout 

+

24 self.stderr = sys.stderr 

+

25 

+

26 def setOutput(self, stdout=None, stderr=None): 

+

27 """ Assign new files for standard out and/or standard error. 

+

28 """ 

+

29 if stdout: 29 ↛ 31line 29 didn't jump to line 31, because the condition on line 29 was never false

+

30 self.stdout = stdout 

+

31 if stderr: 31 ↛ 32line 31 didn't jump to line 32, because the condition on line 31 was never true

+

32 self.stderr = stderr 

+

33 

+

34 def prout(self, s, end="\n"): 

+

35 print(s, file=self.stdout, end=end) 

+

36 

+

37 def prerr(self, s, end="\n"): 

+

38 print(s, file=self.stderr, end=end) 

+

39 

+

40 

+

41class NumberedFileReader: 

+

42 """ A decorator for files that counts the readline()'s called. 

+

43 """ 

+

44 def __init__(self, f): 

+

45 self.f = f 

+

46 self.n = 0 

+

47 

+

48 def readline(self): 

+

49 l = self.f.readline() 

+

50 if l: 

+

51 self.n += 1 

+

52 return l 

+

53 

+

54 def linenumber(self): 

+

55 return self.n 

+

56 

+

57 

+

58@contextlib.contextmanager 

+

59def change_dir(new_dir): 

+

60 """Change directory, and then change back. 

+

61 

+

62 Use as a context manager, it will return to the original 

+

63 directory at the end of the block. 

+

64 

+

65 """ 

+

66 old_dir = os.getcwd() 

+

67 os.chdir(str(new_dir)) 

+

68 try: 

+

69 yield 

+

70 finally: 

+

71 os.chdir(old_dir) 

+
+ + + diff --git a/doc/sample_html/d_7b071bdc2a35fa80_whiteutils_py.html b/doc/sample_html/d_7b071bdc2a35fa80_whiteutils_py.html index e8ba104f7..7c11b5ad9 100644 --- a/doc/sample_html/d_7b071bdc2a35fa80_whiteutils_py.html +++ b/doc/sample_html/d_7b071bdc2a35fa80_whiteutils_py.html @@ -62,12 +62,12 @@

- « prev     + « prev     ^ index     » next       - coverage.py v7.3.2, - created at 2023-10-02 11:44 -0400 + coverage.py v7.3.3, + created at 2023-12-14 06:26 -0500