Source code for dakweb.webregister

"""
@contact: Debian FTPMaster <ftpmaster@debian.org>
@copyright: 2014  Mark Hymers <mhy@debian.org>
@license: GNU General Public License version 2 or later
"""


[docs]class QueryRegister: __shared_state = {} def __init__(self, *args, **kwargs): self.__dict__ = self.__shared_state if not getattr(self, 'initialised', False): self.initialised = True # Dictionary of query paths to help mappings self.queries = {}
[docs] def register_path(self, path, func): self.queries[path] = func.__module__
[docs] def get_paths(self): return sorted(self.queries.keys())
[docs] def get_path_help(self, path): # We always register with the leading / if not path.startswith('/'): path = '/' + path return self.queries.get(path, '/')
__all__ = ['QueryRegister']