/usr/share/pyshared/plasTeX/ConfigManager/Boolean.py is in python-plastex 0.9.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | from Generic import *
from plasTeX.ConfigManager import InvalidOptionError
class BooleanParser(GenericParser): pass
class BooleanOption(BooleanParser, GenericOption):
""" Boolean configuration option """
def cast(self, data):
if data is None: return
values = {'on':1,'off':0,'true':1,'false':0,'yes':1,'no':0}
try:
bool = int(data)
if bool in [0, 1]:
return bool
except:
try:
bool = values[str(data).lower()]
if bool in [0, 1]:
return bool
except: pass
name = self.name
if self.actual: name = self.actual
raise InvalidOptionError(name, data, type='boolean')
def validate(self, data):
return self.cast(data)
def defaultValue(self):
if self.default:
return 'yes'
return 'no'
def __repr__(self):
""" Return command-line syntax as entered """
if self.actual: return self.actual
options = self.getPossibleOptions()
negative = [x.replace('!','',1) for x in options if x.startswith('!')]
positive = [x for x in options if not x.startswith('!')]
if self.data and positive:
return positive[0]
elif not(self.data) and negative:
return negative[0]
return ''
def __str__(self):
""" Return string representation of the current option value """
value = self.getValue()
if value is not None:
if value: return 'on'
else: return 'off'
return ''
def acceptsArgument(self):
""" Return a boolean indicating if the option accepts an argument """
return 0
def requiresArgument(self):
""" Return a boolean indicating if the option requires an argument """
return 0
class BooleanArgument(GenericArgument, BooleanOption):
""" Boolean command-line option """
|