3 # Unix SMB/CIFS implementation.
4 # Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2009
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 """Share management."""
23 # TODO: Rather than accessing Loadparm directly here, we should really
24 # have bindings to the param/shares.c and use those.
27 class SharesContainer(object):
28 """A shares container."""
30 def __init__(self, lp):
33 def __getitem__(self, name):
35 # [global] is not a share
37 return Share(self._lp[name])
40 if "global" in self._lp.services():
41 return len(self._lp)-1
45 return [name for name in self._lp.services() if name != "global"]
48 return iter(self.keys())
54 def __init__(self, service):
55 self._service = service
57 def __getitem__(self, name):
58 return self._service[name]
60 def __setitem__(self, name, value):
61 self._service[name] = value