Disable most print statements

This commit is contained in:
Isaiah Odhner 2023-06-10 02:15:51 -04:00
parent 2631256994
commit 1b5d1ce988
3 changed files with 19 additions and 19 deletions

View File

@ -127,7 +127,7 @@ class ColorGrid(Container):
return return
# index = self._colors.index(self._color_by_button[focused]) # doesn't work because there can be duplicates # index = self._colors.index(self._color_by_button[focused]) # doesn't work because there can be duplicates
index = list(self._color_by_button.keys()).index(focused) index = list(self._color_by_button.keys()).index(focused)
print(delta, (index % num_colors_per_row), num_colors_per_row) # print(delta, (index % num_colors_per_row), num_colors_per_row)
if delta == -1 and (index % num_colors_per_row) == 0: if delta == -1 and (index % num_colors_per_row) == 0:
return return
if delta == +1 and (index % num_colors_per_row) == num_colors_per_row - 1: if delta == +1 and (index % num_colors_per_row) == num_colors_per_row - 1:

View File

@ -566,14 +566,14 @@ class NodeInfo(Container):
def action_select_node(self, link_id: int) -> None: def action_select_node(self, link_id: int) -> None:
"""Select a DOM node.""" """Select a DOM node."""
dom_node = self._node_info._link_id_to_node.get(link_id) dom_node = self._node_info._link_id_to_node.get(link_id)
print("action_select_node", link_id, dom_node) # print("action_select_node", link_id, dom_node)
if dom_node is None: if dom_node is None:
return return
self.post_message(NodeInfo.FollowLinkToNode(dom_node)) self.post_message(NodeInfo.FollowLinkToNode(dom_node))
def action_open_file(self, path: str, line_number: int | None = None, column_number: int | None = None) -> None: def action_open_file(self, path: str, line_number: int | None = None, column_number: int | None = None) -> None:
"""Open a file.""" """Open a file."""
print("action_open_file", path, line_number, column_number) # print("action_open_file", path, line_number, column_number)
launch_editor(path, line_number, column_number) launch_editor(path, line_number, column_number)
@ -610,7 +610,7 @@ class NodeInfo(Container):
def watch_dom_node(self, dom_node: DOMNode | None) -> None: def watch_dom_node(self, dom_node: DOMNode | None) -> None:
"""Update the info displayed when the DOM node changes.""" """Update the info displayed when the DOM node changes."""
print("watch_dom_node", dom_node) # print("watch_dom_node", dom_node)
self._link_id_to_node.clear() self._link_id_to_node.clear()
@ -1138,7 +1138,7 @@ class Inspector(Container):
def focus_and_clear_prevent_highlight() -> None: def focus_and_clear_prevent_highlight() -> None:
"""Focus the DOMTree, and clear the _prevent_highlight flag. Both of these things seem to need a delay.""" """Focus the DOMTree, and clear the _prevent_highlight flag. Both of these things seem to need a delay."""
print("focus_and_clear_prevent_highlight", hasattr(self, "_prevent_highlight")) # print("focus_and_clear_prevent_highlight", hasattr(self, "_prevent_highlight"))
self.query_one(DOMTree).focus() self.query_one(DOMTree).focus()
if hasattr(self, "_prevent_highlight"): if hasattr(self, "_prevent_highlight"):
del self._prevent_highlight del self._prevent_highlight
@ -1159,7 +1159,7 @@ class Inspector(Container):
def on_domtree_selected(self, event: DOMTree.Selected) -> None: def on_domtree_selected(self, event: DOMTree.Selected) -> None:
"""Handle a node being selected in the DOM tree.""" """Handle a node being selected in the DOM tree."""
print("Inspecting DOM node:", event.dom_node) # print("Inspecting DOM node:", event.dom_node)
self.query_one(NodeInfo).dom_node = event.dom_node self.query_one(NodeInfo).dom_node = event.dom_node
def on_domtree_hovered(self, event: DOMTree.Hovered) -> None: def on_domtree_hovered(self, event: DOMTree.Hovered) -> None:
@ -1198,15 +1198,15 @@ class Inspector(Container):
def highlight(self, dom_node: DOMNode | None) -> None: def highlight(self, dom_node: DOMNode | None) -> None:
"""Highlight a DOM node.""" """Highlight a DOM node."""
print("highlight") # print("highlight")
import traceback # import traceback
traceback.print_stack(limit=2) # traceback.print_stack(limit=2)
if hasattr(self, "_prevent_highlight") and dom_node is not None: if hasattr(self, "_prevent_highlight") and dom_node is not None:
print("highlight prevented") # print("highlight prevented")
del self._prevent_highlight del self._prevent_highlight
return return
print("Highlighting DOM node:", dom_node) # print("Highlighting DOM node:", dom_node)
if not isinstance(dom_node, Widget): if not isinstance(dom_node, Widget):
# Only widgets have a region, App (the root) doesn't. # Only widgets have a region, App (the root) doesn't.

View File

@ -838,9 +838,9 @@ class AnsiArtDocument:
# Ignore case and trailing '~' (indicating a backup file) # Ignore case and trailing '~' (indicating a backup file)
# Alternative: pathlib.Path.suffix # Alternative: pathlib.Path.suffix
file_ext_with_dot = os.path.splitext(file_path)[1].lower().rstrip("~") file_ext_with_dot = os.path.splitext(file_path)[1].lower().rstrip("~")
print("File extension:", file_ext_with_dot) # print("File extension:", file_ext_with_dot)
ext_to_id = Image.registered_extensions() # maps extension to format ID, e.g. '.jp2': 'JPEG2000' ext_to_id = Image.registered_extensions() # maps extension to format ID, e.g. '.jp2': 'JPEG2000'
print("Supported image formats by extension:", Image.EXTENSION) # print("Supported image formats by extension:", Image.EXTENSION)
if file_ext_with_dot in ext_to_id: if file_ext_with_dot in ext_to_id:
return ext_to_id[file_ext_with_dot] return ext_to_id[file_ext_with_dot]
ext_to_id = { ext_to_id = {
@ -860,7 +860,7 @@ class AnsiArtDocument:
def encode_based_on_file_extension(self, file_path: str) -> bytes: def encode_based_on_file_extension(self, file_path: str) -> bytes:
"""Encode the image according to the file extension.""" """Encode the image according to the file extension."""
format_id = self.format_from_extension(file_path) format_id = self.format_from_extension(file_path)
print("Supported image formats for writing:", Image.SAVE.keys()) # print("Supported image formats for writing:", Image.SAVE.keys())
if format_id == "ANSI": if format_id == "ANSI":
# This maybe shouldn't use UTF-8... but there's not a singular encoding for "ANSI art". # This maybe shouldn't use UTF-8... but there's not a singular encoding for "ANSI art".
return self.get_ansi().encode("utf-8") return self.get_ansi().encode("utf-8")
@ -1539,7 +1539,7 @@ class AnsiArtDocument:
Raises UnidentifiedImageError if the format is not detected. Raises UnidentifiedImageError if the format is not detected.
""" """
format_id = AnsiArtDocument.format_from_extension(file_path) format_id = AnsiArtDocument.format_from_extension(file_path)
print("Supported image formats for reading:", Image.OPEN.keys()) # print("Supported image formats for reading:", Image.OPEN.keys())
# TODO: try loading as image first, then as text if that fails with UnidentifiedImageError # TODO: try loading as image first, then as text if that fails with UnidentifiedImageError
# That way it can handle images without file extensions. # That way it can handle images without file extensions.
if format_id in Image.OPEN: if format_id in Image.OPEN:
@ -2914,7 +2914,7 @@ class PaintApp(App[None]):
opening_backup = False opening_backup = False
try: try:
backup_file_path = self.get_backup_file_path() backup_file_path = self.get_backup_file_path()
print("Comparing files:", file_path, backup_file_path) # print("Comparing files:", file_path, backup_file_path)
if os.path.samefile(file_path, backup_file_path): if os.path.samefile(file_path, backup_file_path):
print("Not discarding backup because it is now open in the editor:", backup_file_path) print("Not discarding backup because it is now open in the editor:", backup_file_path)
opening_backup = True opening_backup = True
@ -3274,12 +3274,12 @@ class PaintApp(App[None]):
""" """
radio_buttons = window.content.query(RadioButton) radio_buttons = window.content.query(RadioButton)
radio_button_absolute_positions = [radio_button.region.offset for radio_button in radio_buttons] radio_button_absolute_positions = [radio_button.region.offset for radio_button in radio_buttons]
print("radio_button_absolute_positions", radio_button_absolute_positions) # print("radio_button_absolute_positions", radio_button_absolute_positions)
order = [0, 3, 1, 4, 2] order = [0, 3, 1, 4, 2]
radio_button_absolute_target_positions = [radio_button_absolute_positions[order[i]] for i in range(len(radio_buttons))] radio_button_absolute_target_positions = [radio_button_absolute_positions[order[i]] for i in range(len(radio_buttons))]
for radio_button, radio_button_absolute_position, radio_button_absolute_target_position in zip(radio_buttons, radio_button_absolute_positions, radio_button_absolute_target_positions): for radio_button, radio_button_absolute_position, radio_button_absolute_target_position in zip(radio_buttons, radio_button_absolute_positions, radio_button_absolute_target_positions):
relative_position = radio_button_absolute_target_position - radio_button_absolute_position relative_position = radio_button_absolute_target_position - radio_button_absolute_position
print(radio_button, relative_position) # print(radio_button, relative_position)
radio_button.styles.offset = relative_position radio_button.styles.offset = relative_position
self.mount(window) self.mount(window)
# TODO: avoid flash of incorrect ordering by doing this before rendering but after layout # TODO: avoid flash of incorrect ordering by doing this before rendering but after layout
@ -4285,7 +4285,7 @@ class PaintApp(App[None]):
split_filepaths = shlex.split(text) split_filepaths = shlex.split(text)
split_filepaths = shlex.split(text) split_filepaths = shlex.split(text)
print(split_filepaths) # print(split_filepaths)
filepaths: list[str] = [] filepaths: list[str] = []
for i in split_filepaths: for i in split_filepaths:
item = i.replace("\x00", "").replace('"', "") item = i.replace("\x00", "").replace('"', "")