kaptive.utils
¶
check_file(file, panic=False)
¶
Checks a file exists and is non-empty and returns the absolute path
Source code in kaptive/utils.py
43 44 45 46 47 48 49 50 51 52 53 | |
check_out(path, mode='at', exist_ok=True)
¶
Check if the user wants to create/append a file or directory. If it looks like/is already a file (has an extension), return the file object. If it looks like/is already a directory, return the directory path.
Source code in kaptive/utils.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
check_programs(progs, verbose=False)
¶
Check if programs are installed and executable
Source code in kaptive/utils.py
29 30 31 32 33 34 35 36 37 38 39 40 | |
merge_ranges(ranges, tolerance=0, skip_sort=False)
¶
Merge overlapping ranges :param ranges: List of tuples of start and end positions :param tolerance: Integer or float of tolerance for merging ranges :param skip_sort: Skip sorting the ranges before merging :return: List of merged ranges
Source code in kaptive/utils.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
opener(file, verbose=False, *args, **kwargs)
¶
Opens a file with the appropriate open function based on the magic bytes at the beginning of the data :param file: File to open :param verbose: Print log messages to stderr :return: File handle
Source code in kaptive/utils.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |
range_overlap(range1, range2, skip_sort=False)
¶
Returns the overlap between two ranges :param range1: Tuple of start and end positions :param range2: Tuple of start and end positions :param skip_sort: Skip sorting each range before calculating the overlap :return: Integer of overlap
Source code in kaptive/utils.py
143 144 145 146 147 148 149 150 151 152 153 154 155 | |