Spaces:
Build error
Build error
| class StatusWordItem: | |
| def __init__(self, word=None, value=None): | |
| self.content = { | |
| "aborted" : {"title": "Aborted", "icon": "βοΈ"}, | |
| "cancelled" : {"title": "Cancelled", "icon": "β"}, | |
| "cleaning" : {"title": "Cleaning", "icon": "π§Ή"}, | |
| "compiling" : {"title": "Compiling", "icon": "π¨"}, | |
| "complete" : {"title": "Complete", "icon": "β "}, | |
| "connecting" : {"title": "Connecting", "icon": "π"}, | |
| "deleting" : {"title": "Deleting", "icon": "π"}, | |
| "disconnecting": {"title": "Disconnecting", "icon": "π"}, | |
| "downloading" : {"title": "Downloading", "icon": "β¬οΈ"}, | |
| "error" : {"title": "Error", "icon": "βοΈ"}, | |
| "exporting" : {"title": "Exporting", "icon": "π€"}, | |
| "failure" : {"title": "Failure", "icon": "β"}, | |
| "finished" : {"title": "Finished", "icon": "π"}, | |
| "idle" : {"title": "Idle", "icon": "π"}, | |
| "importing" : {"title": "Importing", "icon": "π₯"}, | |
| "installing" : {"title": "Installing", "icon": "π§"}, | |
| "loading" : {"title": "Loading", "icon": "β³"}, | |
| "paused" : {"title": "Paused", "icon": "βΈ"}, | |
| "pending" : {"title": "Pending", "icon": "π"}, | |
| "progress" : {"title": "Progress", "icon": "π"}, | |
| "receiving" : {"title": "Receiving", "icon": "π©"}, | |
| "refreshing" : {"title": "Refreshing", "icon": "π"}, | |
| "rendering" : {"title": "Rendering", "icon": "π¨"}, | |
| "restarting" : {"title": "Restarting", "icon": "π"}, | |
| "resuming" : {"title": "Resuming", "icon": "βΆοΈ"}, | |
| "running" : {"title": "Running", "icon": "π"}, | |
| "saving" : {"title": "Saving", "icon": "πΎ"}, | |
| "scanning" : {"title": "Scanning", "icon": "π"}, | |
| "sending" : {"title": "Sending", "icon": "π€"}, | |
| "size" : {"title": "Size", "icon": "π"}, | |
| "started" : {"title": "Started", "icon": "π"}, | |
| "success" : {"title": "Success", "icon": "β "}, | |
| "syncing" : {"title": "Syncing", "icon": "π"}, | |
| "uninstalling" : {"title": "Uninstalling", "icon": "π§"}, | |
| "updating" : {"title": "Updating", "icon": "π"}, | |
| "uploading" : {"title": "Uploading", "icon": "β¬οΈ"}, | |
| "validating" : {"title": "Validating", "icon": "β "}, | |
| "verifying" : {"title": "Verifying", "icon": "β "}, | |
| "waiting" : {"title": "Waiting", "icon": "βοΈ"}, | |
| } | |
| self.display = {"status": "", "value": ""} | |
| self.set(word or "", value) | |
| def set(self, word: str, value=None): | |
| """ | |
| outtputto display: an icon and status word, as well as the state if exists | |
| """ | |
| if word in self.content: | |
| self.display["status"] = f"{ self.content[word]['icon']} {self.content[word]['title']}" | |
| else: | |
| self.display["status"] = word or "" | |
| if value in self.content: | |
| self.display["value"] = f"{ self.content[str(value)]['title']}" | |
| else: | |
| self.display["value"] = str(value) | |
| return self.display | |
| def response_code(self, code): | |
| """ | |
| Returns the HTTP response code as a string representation. | |
| """ | |
| response_codes = { | |
| 100: "Continue", | |
| 101: "Switching Protocols", | |
| 102: "Processing", | |
| 103: "Early Hints", | |
| 200: "OK", | |
| 201: "Created", | |
| 202: "Accepted", | |
| 203: "Non-Authoritative Information", | |
| 204: "No Content", | |
| 205: "Reset Content", | |
| 206: "Partial Content", | |
| 207: "Multi-Status", | |
| 208: "Already Reported", | |
| 226: "IM Used", | |
| 300: "Multiple Choice", | |
| 301: "Moved Permanently", | |
| 302: "Found", | |
| 303: "See Other", | |
| 304: "Not Modified", | |
| 305: "Use Proxy", | |
| 307: "Temporary Redirect", | |
| 308: "Permanent Redirect", | |
| 400: "Bad Request", | |
| 401: "Unauthorized", | |
| 402: "Payment Required", | |
| 403: "Forbidden", | |
| 404: "Not Found", | |
| 405: "Method Not Allowed", | |
| 406: "Not Acceptable", | |
| 407: "Proxy Authentication Required", | |
| 408: "Request Timeout", | |
| 409: "Conflict", | |
| 410: "Gone", | |
| 411: "Length Required", | |
| 412: "Precondition Failed", | |
| 413: "Payload Too Large", | |
| 414: "URI Too Long", | |
| 415: "Unsupported Media Type", | |
| 416: "Range Not Satisfiable", | |
| 417: "Expectation Failed", | |
| 418: "I'm a teapot", | |
| 421: "Misdirected Request", | |
| 422: "Unprocessable Entity", | |
| 423: "Locked", | |
| 424: "Failed Dependency", | |
| 425: "Too Early", | |
| 426: "Upgrade Required", | |
| 428: "Precondition Required", | |
| 429: "Too Many Requests", | |
| 431: "Request Header Fields Too Large", | |
| 451: "Unavailable For Legal Reasons", | |
| 500: "Internal Server Error", | |
| 501: "Not Implemented", | |
| 502: "Bad Gateway", | |
| 503: "Service Unavailable", | |
| 504: "Gateway Timeout", | |
| 505: "HTTP Version Not Supported", | |
| 506: "Variant Also Negotiates", | |
| 507: "Insufficient Storage", | |
| 508: "Loop Detected", | |
| 510: "Not Extended", | |
| 511: "Network Authentication Required", | |
| } | |
| if code in response_codes: | |
| self.display['status'] = 'HTTP Respopnse Code' | |
| self.display['value'] = response_codes[code] | |
| else: | |
| return "Unknown" | |
| return self.display | |
| class Items: | |
| """ List of Items Container """ | |
| def __init__(self): | |
| self.items : list[StatusWordItem] = [] | |
| def add_item(self, item): | |
| self.items.append(item) | |
| def remove_item(self, item): | |
| self.items.remove(item) | |
| def clear_items(self): | |
| self.items.clear() | |
| def __len__(self): | |
| return len(self.items) | |
| def __iter__(self): | |
| return iter(self.items) | |