1"""
2@contact: Debian FTPMaster <ftpmaster@debian.org>
3@copyright: 2014 Mark Hymers <mhy@debian.org>
4@license: GNU General Public License version 2 or later
5"""
8class QueryRegister:
9 __shared_state = {}
11 def __init__(self, *args, **kwargs):
12 self.__dict__ = self.__shared_state
14 if not getattr(self, 'initialised', False):
15 self.initialised = True
17 # Dictionary of query paths to help mappings
18 self.queries = {}
20 def register_path(self, path, func):
21 self.queries[path] = func.__module__
23 def get_paths(self):
24 return sorted(self.queries.keys())
26 def get_path_help(self, path):
27 # We always register with the leading /
28 if not path.startswith('/'):
29 path = '/' + path
30 return self.queries.get(path, '/')
33__all__ = ['QueryRegister']