~zulcss/samba/server-dailies-3.4

« back to all changes in this revision

Viewing changes to examples/scripts/shares/python/SambaParm.py

  • Committer: Chuck Short
  • Date: 2010-09-28 20:38:39 UTC
  • Revision ID: zulcss@ubuntu.com-20100928203839-pgjulytsi9ue63x1
Initial version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 3 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, see <http://www.gnu.org/licenses/>.
 
19
##
 
20
######################################################################
 
21
 
 
22
import string
 
23
 
 
24
#####################################################################
 
25
## Base class for Samba smb.conf parameters
 
26
class SambaParm :
 
27
        def __init__( self ) :
 
28
                pass
 
29
 
 
30
        def StringValue( self ) :
 
31
                return self.value
 
32
 
 
33
#####################################################################
 
34
## Boolean smb,conf parm
 
35
class SambaParmBool( SambaParm ):
 
36
        def __init__( self, value ) :
 
37
                x = string.upper(value)
 
38
                self.valid = True
 
39
                
 
40
                if x=="YES" or x=="TRUE" or x=="1":
 
41
                        self.value = True
 
42
                elif x=="NO" or x=="FALSE" or x=="0":
 
43
                        self.value = False
 
44
                else:
 
45
                        self.valid = False
 
46
                        return self
 
47
 
 
48
        def SetValue( self, value ) :
 
49
                x = string.upper(value)
 
50
                self.valid = True
 
51
                
 
52
                if x=="YES" or x=="TRUE" or x=="1":
 
53
                        self.value = True
 
54
                elif x=="NO" or x=="FALSE" or x=="0":
 
55
                        self.value = False
 
56
                else:
 
57
                        self.valid = False
 
58
                        return
 
59
                        
 
60
        def StringValue( self ) :
 
61
                if  self.value :
 
62
                        return "yes"
 
63
                else:
 
64
                        return "no"
 
65
                        
 
66
#####################################################################
 
67
## Boolean smb,conf parm (inverts)
 
68
class SambaParmBoolRev( SambaParmBool ) :
 
69
        def __init__( self, value ):
 
70
                SambaParmBool.__init__( self, value )
 
71
                if self.valid :
 
72
                        self.value = not self.value
 
73
                        
 
74
 
 
75
#####################################################################
 
76
## string smb.conf parms
 
77
class SambaParmString( SambaParm ):
 
78
        def __init__( self, value ):
 
79
                self.value = value
 
80
                self.valid = True
 
81
 
 
82
 
 
83