mirror of
https://github.com/openswarm-ai/openswarm.git
synced 2026-09-11 20:27:44 +02:00
26 lines
835 B
Python
26 lines
835 B
Python
import os
|
|
from debugger_backend.path_mngr import get_abspath
|
|
|
|
class File:
|
|
def __init__(self, filename, path):
|
|
self.filename = filename
|
|
self.path = path
|
|
|
|
def get_abspath(self):
|
|
return get_abspath(self.path)
|
|
|
|
def calls_debug_function(self):
|
|
"""True if the file contains a debug() call."""
|
|
full_path = self.get_abspath()
|
|
|
|
if not full_path.endswith('.py') or full_path.endswith('.pyc'):
|
|
result = False
|
|
else:
|
|
try:
|
|
with open(full_path, 'r', encoding='utf-8') as file:
|
|
content = file.read()
|
|
result = 'debug(' in content
|
|
except (UnicodeDecodeError, FileNotFoundError) as e:
|
|
print(f"Error reading file {full_path}")
|
|
result = False
|
|
return result |