1 | ######################################################################
|
---|
2 | ##
|
---|
3 | ## smb.conf parameter classes
|
---|
4 | ##
|
---|
5 | ## Copyright (C) Gerald Carter 2004.
|
---|
6 | ##
|
---|
7 | ## This program is free software; you can redistribute it and/or modify
|
---|
8 | ## it under the terms of the GNU General Public License as published by
|
---|
9 | ## the Free Software Foundation; either version 2 of the License, or
|
---|
10 | ## (at your option) any later version.
|
---|
11 | ##
|
---|
12 | ## This program is distributed in the hope that it will be useful,
|
---|
13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | ## GNU General Public License for more details.
|
---|
16 | ##
|
---|
17 | ## You should have received a copy of the GNU General Public License
|
---|
18 | ## along with this program; if not, write to the Free Software
|
---|
19 | ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
20 | ##
|
---|
21 | ######################################################################
|
---|
22 |
|
---|
23 | import string
|
---|
24 |
|
---|
25 | #####################################################################
|
---|
26 | ## Base class for Samba smb.conf parameters
|
---|
27 | class SambaParm :
|
---|
28 | def __init__( self ) :
|
---|
29 | pass
|
---|
30 |
|
---|
31 | def StringValue( self ) :
|
---|
32 | return self.value
|
---|
33 |
|
---|
34 | #####################################################################
|
---|
35 | ## Boolean smb,conf parm
|
---|
36 | class SambaParmBool( SambaParm ):
|
---|
37 | def __init__( self, value ) :
|
---|
38 | x = string.upper(value)
|
---|
39 | self.valid = True
|
---|
40 |
|
---|
41 | if x=="YES" or x=="TRUE" or x=="1":
|
---|
42 | self.value = True
|
---|
43 | elif x=="NO" or x=="FALSE" or x=="0":
|
---|
44 | self.value = False
|
---|
45 | else:
|
---|
46 | self.valid = False
|
---|
47 | return self
|
---|
48 |
|
---|
49 | def SetValue( self, value ) :
|
---|
50 | x = string.upper(value)
|
---|
51 | self.valid = True
|
---|
52 |
|
---|
53 | if x=="YES" or x=="TRUE" or x=="1":
|
---|
54 | self.value = True
|
---|
55 | elif x=="NO" or x=="FALSE" or x=="0":
|
---|
56 | self.value = False
|
---|
57 | else:
|
---|
58 | self.valid = False
|
---|
59 | return
|
---|
60 |
|
---|
61 | def StringValue( self ) :
|
---|
62 | if self.value :
|
---|
63 | return "yes"
|
---|
64 | else:
|
---|
65 | return "no"
|
---|
66 |
|
---|
67 | #####################################################################
|
---|
68 | ## Boolean smb,conf parm (inverts)
|
---|
69 | class SambaParmBoolRev( SambaParmBool ) :
|
---|
70 | def __init__( self, value ):
|
---|
71 | SambaParmBool.__init__( self, value )
|
---|
72 | if self.valid :
|
---|
73 | self.value = not self.value
|
---|
74 |
|
---|
75 |
|
---|
76 | #####################################################################
|
---|
77 | ## string smb.conf parms
|
---|
78 | class SambaParmString( SambaParm ):
|
---|
79 | def __init__( self, value ):
|
---|
80 | self.value = value
|
---|
81 | self.valid = True
|
---|
82 |
|
---|
83 |
|
---|
84 |
|
---|