FMZ local storage call simplification tool For local storage, please visitThe FMZ API documentation
Simplified calls to FMZ's local storage, more elegant, no more dialing_G()
It is.
First, copy this template to your policy library and check it in the policy for the tool you want to use.
Create an object at the beginning of the policy with the following code:
PS = ext.PersistentStorage()
I got it.
This objectPS
You can use it as a regular Python dictionary, but you can't use it as a standard Python dictionary.Stores only content that can be sequenced in JSON
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # encoding: utf-8 # # Persistent Storage for FMZ # # Copyright 2020 FawkesPan # Contact : i@fawkex.me / Telegram@FawkesPan # # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE # Version 2, December 2004 # # Copyright (C) 2004 Sam Hocevar <sam@hocevar.net> # # Everyone is permitted to copy and distribute verbatim or modified # copies of this license document, and changing it is allowed as long # as the name is changed. # # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE # TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION # # 0. You just DO WHAT THE FUCK YOU WANT TO. # class PersistentStorage: def __init__(self): keys = _G('__keys__') if isinstance(keys, list): self.__keys__ = keys else: self.__keys__ = [] self.__setitem__('__keys__', self.__keys__) return def _add_key(self, key): if key == '__keys__': return self.__keys__.append(key) self.__setitem__('__keys__', self.__keys__) return def _del_key(self, key): if key == '__keys__': return if key in self.__keys__: del self.__keys__[self.__keys__.index(key)] self.__setitem__('__keys__', self.__keys__) return def __setitem__(self, key, value): _G(key, value) self._add_key(key) return def __delitem__(self, key): _G(key, None) self._del_key(key) return def __getitem__(self, key): return _G(key) def keys(self): return self.__keys__ ext.PersistentStorage = PersistentStorage
Light cloudsThis would be better if it was JS.....................
congcong009Do what the fuck you want to public license I'm not going to lie, I'm not going to lie.