We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
😂
I added this to my software recently:
class RemoteDataSource(ObjectDataSource): def __init__(self, uri): super().__init__({}) self.uri = uri self.remote_exists = False self.next_update = 0 def update(self): if self.next_update > time.time(): return # I long for the day when toml has a registered media type response = requests.get(self.uri, headers={'user-agent': 'ganarchy/0.0.0', 'accept': '*/*'}) self.remote_exists = response.status_code == 200 seconds = 3600 if (refresh := response.headers.get('Refresh', None)) is not None: try: seconds = int(refresh) except ValueError: refresh = refresh.split(';', 1) try: seconds = int(refresh[0]) except ValueError: pass self.next_update = time.time() + seconds if self.remote_exists: response.encoding = 'utf-8' try: self._obj = qtoml.loads(response.text) except (UnicodeDecodeError, qtoml.decoder.TOMLDecodeError) as e: self._obj = {} return e else: return response def exists(self): return self.remote_exists def __repr__(self): return "RemoteDataSource({!r})".format(self.uri)
maybe you too can make use of the Refresh header?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
😂
I added this to my software recently:
maybe you too can make use of the Refresh header?
The text was updated successfully, but these errors were encountered: