This commit is contained in:
Mattias Andrée 2012-11-03 07:10:18 +01:00
parent 60d758416c
commit fa4e463073
4 changed files with 93 additions and 21 deletions

View file

@ -1957,13 +1957,14 @@ inode comparison.
@opindex @option{--freedom}
@cindex full freedom
@cindex freedom, full
Set your freedom. If you the any of the values @code{strict}, @code{full} or @code{yes},
the setup will make sure that only completly free parts of the package is installed.
This should be used (@code{--freedom=strict}) on distributions for GNU endorsed (endorsable)
GNU/Linux-libre distributions.
Set your freedom. If you the any of the values @code{strict}, @code{full}, @code{true}
or @code{yes}, the setup will make sure that only completly free parts of the package
is installed. This should be used (@code{--freedom=strict}) on distributions for GNU
endorsed (endorsable) GNU/Linux-libre distributions.
If you do not want this, will need to explicity say so (you do also need to say if you
do want it) by using either of the values @code{sloppy}, @code{partial} or @code{no}.
do want it) by using either of the values @code{sloppy}, @code{partial}, @code{false}
or @code{no}.
@end table
Recognised compressions are @option{gz} which uses @option{gzip -9}, and @option{xz}

View file

@ -326,8 +326,11 @@ class PonysayTool():
if ': ' in line:
key = line.replace('\t', ' ')
key = key[:key.find(': ')]
key = key.strip(' ')
if key == key.upper():
test = key
for c in 'ABCDEFGHIJKLMN OPQRSTUVWXYZ':
test = test.replace(c, '')
if len(test) == 0:
key = key.strip(' ')
value = line.replace('\t', ' ')
value = value[value.find(': ') + 2:]
if key not in data:

View file

@ -342,6 +342,7 @@ class Ponysay():
self.ponyonly = True
else:
self.ponyonly = False
self.restriction = args.opts['-r']
## The stuff
if args.opts['-q'] is not None:
@ -564,6 +565,58 @@ class Ponysay():
## If there is not select ponies, choose all of them
if (names is None) or (len(names) == 0):
oldponies = ponies
if self.restriction is not None:
table = [(get_test(cell[:cell.index('=')],
cell[cell.index('=') + 1:]
)
for cell in clause.lower().split('+'))
for clause in self.restriction
]
def get_test(cell):
strict = cell[0][-1] != '?'
key = cell[0][:-2 if strict else -1]
invert = cell[1][0] == '!'
value = cell[1][1 if invert else 0:]
class SITest:
def __init__(self, cellkey, cellvalue):
(self.cellkey, self.callvalue) = (key, value)
def __call__(self, has):
return False if key not in has else (has[key] != value)
class STest:
def __init__(self, cellkey, cellvalue):
(self.cellkey, self.callvalue) = (key, value)
def __call__(self, has):
return False if key not in has else (has[key] ?= value)
class ITest:
def __init__(self, cellkey, cellvalue):
(self.cellkey, self.callvalue) = (key, value)
def __call__(self, has):
return True if key not in has else (has[key] != value)
class NTest:
def __init__(self, cellkey, cellvalue):
(self.cellkey, self.callvalue) = (key, value)
def __call__(self, has):
return True if key not in has else (has[key] == value)
if strict and invert: return SITest(key, value)
if strict: return STest(key, value)
if invert: return ITest(key, value)
return NTest(key, value)
def logic(cells): # note inverted return value
for alternative in table:
ok = True
for cell in alternative:
if not cell(cells):
ok = False
break
if ok:
return False
return True
ponies = {}
for ponydir in self.ponydirs:
for pony in self.restrictedPonies(ponydir, logic):
if (pony in oldponies) and (ponies[pony] == ponydir + pony + '.pony'):
del ponies[pony]
oldponies = ponies
ponies = {}
(termh, termw) = self.__gettermsize()
for ponydir in self.ponydirs:
@ -576,13 +629,19 @@ class Ponysay():
fith = set()
with open(ponydir + ('onlyheights' if self.ponyonly else 'heights'), 'rb') as file:
getfitting(fith, termh, file)
for ponyfile in os.listdir(ponydir):
if endswith(ponyfile, '.pony'):
pony = ponyfile[:-5]
if pony not in ponies:
if (fitw is None) or (pony in fitw):
if (fith is None) or (pony in fith):
ponies[pony] = ponydir + ponyfile
for ponyfile in oldponies.values():
if ponyfile.startswith(ponydir):
pony = ponyfile[len(ponydir) : -5]
if (fitw is None) or (pony in fitw):
if (fith is None) or (pony in fith):
ponies[pony] = ponyfile
#for ponyfile in os.listdir(ponydir):
# if endswith(ponyfile, '.pony'):
# pony = ponyfile[:-5]
# if pony not in ponies:
# if (fitw is None) or (pony in fitw):
# if (fith is None) or (pony in fith):
# ponies[pony] = ponydir + ponyfile
names = list((oldponies if len(ponies) == 0 else ponies).keys())
## Select a random pony of the choosen onles
@ -601,6 +660,11 @@ class Ponysay():
return ponies[pony]
#### FIXME not yet implemented
def restrictedPonies(self, ponyday, logic):
return False
'''
Returns a set with all ponies that have quotes and are displayable
@ -1792,10 +1856,13 @@ class Backend():
for line in info:
sep = line.find(':')
if sep > 0:
key = line[:sep].strip()
value = line[sep + 1:].strip()
if key == key.upper():
line = '\033[1m%s\033[21m: %s\n' % (key, value)
key = line[:sep]
test = key
for c in 'ABCDEFGHIJKLMN OPQRSTUVWXYZ':
test = test.replace(c, '')
if len(test) == 0:
value = line[sep + 1:].strip()
line = '\033[1m%s\033[21m: %s\n' % (key.strip(), value)
tags += line
continue
comment += '\n' + line

View file

@ -234,7 +234,8 @@ class Setup():
alternatives = ['--linking'], arg='TYPE')
opts.add_argumented (help = 'Install all ponies or only the completely free ponies\nThis option is manditory, use strict, full or yes for only free ponies,\nand partial, sloppy or no for all ponies',
opts.add_argumented (help = 'Install all ponies or only the completely free ponies\nThis option is manditory, use strict, full, true or yes ' +
'for only free ponies,\nand partial, sloppy, false or no for all ponies',
alternatives = ['--freedom'], arg='FREEDOM')
@ -249,9 +250,9 @@ class Setup():
self.free = None
if opts.opts['--freedom'] is not None:
if opts.opts['--freedom'][0].lower() in ('strict', 'full', 'yes'):
if opts.opts['--freedom'][0].lower() in ('strict', 'full', 'true', 'yes'):
self.free = True
elif opts.opts['--freedom'][0].lower() in ('partial', 'sloppy', 'no'):
elif opts.opts['--freedom'][0].lower() in ('partial', 'sloppy', 'false', 'no'):
self.free = False
if self.free is None:
print('')