MCPcopy Index your code
hub / github.com/ipython/ipython / count_lines_in_py_file

Function count_lines_in_py_file

IPython/core/tbtools.py:25–38  ·  view source on GitHub ↗

Given a filename, returns the number of lines in the file if it ends with the extension ".py". Otherwise, returns 0.

(filename: str)

Source from the content-addressed store, hash-verified

23
24@functools.lru_cache
25def 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
41def get_line_number_of_frame(frame: types.FrameType) -> int:

Callers 1

get_line_number_of_frameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…