Given a filename, returns the number of lines in the file if it ends with the extension ".py". Otherwise, returns 0.
(filename: str)
| 23 | |
| 24 | @functools.lru_cache |
| 25 | def count_lines_in_py_file(filename: str) -> int: |
| 26 | """ |
| 27 | Given a filename, returns the number of lines in the file |
| 28 | if it ends with the extension ".py". Otherwise, returns 0. |
| 29 | """ |
| 30 | if not filename.endswith(".py"): |
| 31 | return 0 |
| 32 | else: |
| 33 | try: |
| 34 | with open(filename, "r") as file: |
| 35 | s = sum(1 for line in file) |
| 36 | except UnicodeError: |
| 37 | return 0 |
| 38 | return s |
| 39 | |
| 40 | |
| 41 | def get_line_number_of_frame(frame: types.FrameType) -> int: |
no outgoing calls
no test coverage detected
searching dependent graphs…