11# -*- coding: utf-8 -*-
22#
3- # Copyright (C) 2008-2009, 2012-2013, 2015, 2023-2024 Rocky Bernstein
3+ # Copyright (C) 2008-2009, 2012-2013, 2015, 2023-2024, 2026 Rocky Bernstein
44# <rocky@gnu.org>
55#
66# This program is free software: you can redistribute it and/or modify
2121import columnize
2222import pyficache
2323
24- from trepan import misc as Mmisc
2524from trepan .lib .complete import complete_token
2625from trepan .lib .file import file_list
27-
28- # Our local modules
26+ from trepan . lib . format import Filename , format_token
27+ from trepan . misc import wrapped_lines
2928from trepan .processor .command .base_subcmd import DebuggerSubcommand
3029
3130
@@ -34,12 +33,10 @@ class InfoFiles(DebuggerSubcommand):
3433 need_stack = False
3534 short_help = "Show information about an imported or loaded Python file"
3635
37-
3836 def complete (self , prefix ):
3937 completions = sorted (["." ] + file_list ())
4038 return complete_token (completions , prefix )
4139
42-
4340 def run (self , args ):
4441 """**info files** [*filename* [**all** | **brkpts** | **sha1** | **size**]]
4542
@@ -67,13 +64,14 @@ def run(self, args):
6764 filename = args [0 ]
6865 pass
6966
70- m = filename + " is"
67+ style = self .settings ["style" ]
68+ m = f"{ format_token (Filename , filename , style = style )} is"
7169 filename_cache = self .core .filename_cache
7270 if filename in filename_cache :
7371 m += " cached in debugger"
7472 if filename_cache [filename ] != filename :
7573 m += " as:"
76- m = Mmisc . wrapped_lines (
74+ m = wrapped_lines (
7775 m , filename_cache [filename ] + "." , self .settings ["width" ]
7876 )
7977 else :
@@ -95,9 +93,16 @@ def run(self, args):
9593 self .msg (m + " not cached in debugger." )
9694 pass
9795 canonic_name = self .core .canonic (filename )
98- self .msg (
99- Mmisc .wrapped_lines ("Canonic name:" , canonic_name , self .settings ["width" ])
100- )
96+ if canonic_name == filename :
97+ self .msg ("Canonic name is the same as the filename." )
98+ else :
99+ self .msg (
100+ wrapped_lines (
101+ "Canonic name:" ,
102+ format_token (Filename , canonic_name , style = style ),
103+ self .settings ["width" ],
104+ )
105+ )
101106 for name in (canonic_name , filename ):
102107 if name in sys .modules :
103108 for key in [k for k , v in list (sys .modules .items ()) if name == v ]:
0 commit comments