(self, line: str)
| 134 | self.query_one("#standard-log-title").update(T("Log")) |
| 135 | |
| 136 | def add_line(self, line: str): |
| 137 | # TODO: make this more generic, use json output from borg. |
| 138 | # currently, this is only really useful for borg create/extract --list |
| 139 | line = line.rstrip() |
| 140 | if len(line) == 0: |
| 141 | return |
| 142 | |
| 143 | markup_tag = None |
| 144 | if len(line) >= 2: |
| 145 | if line[1] == " " and line[0] in "EAMUdcbs+-": |
| 146 | # looks like from borg create/extract --list |
| 147 | status_panel = self.app.query_one("#status") |
| 148 | status_panel.files_count += 1 |
| 149 | status = line[0] |
| 150 | if status == "E": |
| 151 | status_panel.error_count += 1 |
| 152 | elif status in "U-": |
| 153 | status_panel.unchanged_count += 1 |
| 154 | elif status in "M": |
| 155 | status_panel.modified_count += 1 |
| 156 | elif status in "A+": |
| 157 | status_panel.added_count += 1 |
| 158 | elif status in "dcbs": |
| 159 | status_panel.other_count += 1 |
| 160 | |
| 161 | markup_tag = { |
| 162 | "E": "red", # Error |
| 163 | "A": "white", # Added regular file (cache miss, slow!) |
| 164 | "M": "white", # Modified regular file (cache hit, but different, slow!) |
| 165 | "U": "green", # Updated regular file (cache hit) |
| 166 | "d": "green", # directory |
| 167 | "c": "green", # char device |
| 168 | "b": "green", # block device |
| 169 | "s": "green", # socket |
| 170 | "-": "white", # excluded |
| 171 | "+": "green", # included |
| 172 | }.get(status) |
| 173 | |
| 174 | log_widget = self.query_one("#standard-log-content") |
| 175 | |
| 176 | safe_line = escape(line) |
| 177 | if markup_tag: |
| 178 | safe_line = f"[{markup_tag}]{safe_line}[/]" |
| 179 | |
| 180 | log_widget.write(safe_line) |
| 181 | |
| 182 | |
| 183 | class Starfield(Static): |
no test coverage detected