refactor: clean up code to py39+ supported syntax - f-strings instead of format - latest typing support instead of pre 3.9 TitleCase - remove UTF-8 declarations. - many more changes Powered by https://github.com/asottile/pyupgrade/ + manual cleanups
27 lines
680 B
Python
27 lines
680 B
Python
import frappe
|
|
from frappe.website.utils import build_response
|
|
|
|
|
|
class BaseRenderer:
|
|
def __init__(self, path=None, http_status_code=None):
|
|
self.headers = None
|
|
self.http_status_code = http_status_code or 200
|
|
if not path:
|
|
path = frappe.local.request.path
|
|
self.path = path.strip("/ ")
|
|
self.basepath = ""
|
|
self.basename = ""
|
|
self.name = ""
|
|
self.route = ""
|
|
self.file_dir = None
|
|
|
|
def can_render(self):
|
|
raise NotImplementedError
|
|
|
|
def render(self):
|
|
raise NotImplementedError
|
|
|
|
def build_response(self, data, http_status_code=None, headers=None):
|
|
return build_response(
|
|
self.path, data, http_status_code or self.http_status_code, headers or self.headers
|
|
)
|