]> scripts.mit.edu Git - wizard.git/blob - wizard/user.py
Fix plugin loading code, make wizard load scripts plugin.
[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     if dir is None:
17         dir = os.getcwd()
18     unknown = (0, None)
19     for entry in pkg_resources.iter_entry_points("wizard.user.quota"):
20         func = entry.load()
21         r = func(dir)
22         if r != unknown:
23             return r
24     return unknown