]> scripts.mit.edu Git - wizard.git/blob - wizard/user.py
Properly register salt values as random.
[wizard.git] / wizard / user.py
1 """
2 Module for querying information about users.  This mostly asks plugins for
3 the extra information, and falls back to using a default that should work
4 on most systems (but by no means all systems.)
5 """
6
7 import pkg_resources
8 import os
9
10 def quota(dir=None):
11     """
12     Returns a tuple (quota usage, quota limit).  Returns ``(0, None)`` if
13     the quota usage is unknown.  If ``dir`` is omitted, the current
14     working directory is assumed.  Value returned is in bytes.
15
16     This function implements a plugin interface named
17     :ref:`wizard.user.quota`.
18     """
19     if dir is None:
20         dir = os.getcwd()
21     unknown = (0, None)
22     for entry in pkg_resources.iter_entry_points("wizard.user.quota"):
23         func = entry.load()
24         r = func(dir)
25         if r != unknown:
26             return r
27     return unknown