(self)
| 280 | print(self.get_help()) |
| 281 | |
| 282 | def get_help(self) -> str: |
| 283 | b = [] |
| 284 | b.append("Available Scrapy objects:") |
| 285 | b.append( |
| 286 | " scrapy scrapy module (contains scrapy.Request, scrapy.Selector, etc)" |
| 287 | ) |
| 288 | for k, v in sorted(self.vars.items()): |
| 289 | if self._is_relevant(v): |
| 290 | b.append(f" {k:<10} {v}") |
| 291 | b.append("Useful shortcuts:") |
| 292 | if self.fetch_available: |
| 293 | b.append( |
| 294 | " fetch(url[, redirect=True]) " |
| 295 | "Fetch URL and update local objects (by default, redirects are followed)" |
| 296 | ) |
| 297 | b.append( |
| 298 | " fetch(req) " |
| 299 | "Fetch a scrapy.Request and update local objects " |
| 300 | ) |
| 301 | b.append(" shelp() Shell help (print this help)") |
| 302 | b.append(" view(response) View response in a browser") |
| 303 | |
| 304 | return "\n".join(f"[s] {line}" for line in b) + "\n" |
| 305 | |
| 306 | def _is_relevant(self, value: Any) -> bool: |
| 307 | return isinstance(value, self.relevant_classes) or is_item(value) |
no test coverage detected