tracker
CodeBlock
Source code in mkreports/tracker.py
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 |
|
md_code(relative_to=None, name_only=False)
Return a MdObj representing the code in the block.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
relative_to |
Optional[Path]
|
The path relative to which the title should be. |
None
|
name_only |
bool
|
Should only the name of the code-file be used. |
False
|
Returns:
Name | Type | Description |
---|---|---|
Code |
Code
|
Code object with the code represented by the code block. |
Source code in mkreports/tracker.py
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 |
|
SimpleTracker
Bases: BaseTracker
Track first and last line of a code context.
When starting it records the line after the current statement, and stopping the line where the current statement ends.
The first and last line are required to be in the same file.
Source code in mkreports/tracker.py
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 |
|
__init__()
Initialize the tracker.
Source code in mkreports/tracker.py
126 127 128 129 130 131 |
|
active()
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
Is the tracker currently active? |
Source code in mkreports/tracker.py
190 191 192 193 194 195 196 197 198 |
|
code()
Return the tracked code.
Returns:
Type | Description |
---|---|
List[CodeBlock]
|
List[CodeBlock]: List of code blocks. Here, the list is only of length 1. |
Source code in mkreports/tracker.py
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
|
start(frame_info)
Start the tracker.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
frame_info |
inspect.FrameInfo
|
A FrameInfo object of where the tracking starts. |
required |
Source code in mkreports/tracker.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
|
stop(frame_info)
Stop the tracker.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
frame_info |
inspect.FrameInfo
|
FraneInfo where the tracking ends. |
required |
Source code in mkreports/tracker.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
|
read_file(path, from_line=None, to_line=None)
Read a part of a file.
Reads a file from a line to a certain line. All line numbers are assumed to start with 0.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
Path
|
Path to the code file. |
required |
from_line |
Optional[int]
|
Starting line. |
None
|
to_line |
Optional[int]
|
Ending line. |
None
|
Returns:
Name | Type | Description |
---|---|---|
Str |
str
|
String representing the code. |
Source code in mkreports/tracker.py
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 |
|