mirror of
https://github.com/erkin/ponysay.git
synced 2025-02-16 17:44:23 +01:00
setup fixes
Signed-off-by: Mattias Andrée <maandree@operamail.com>
This commit is contained in:
parent
64b7b6a2ec
commit
f0f5a81d24
4 changed files with 38 additions and 17 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -31,6 +31,7 @@
|
||||||
/*ponies/heights
|
/*ponies/heights
|
||||||
/*ponies/onlyheights
|
/*ponies/onlyheights
|
||||||
/*ponies/widths
|
/*ponies/widths
|
||||||
|
/*ponies/metadata
|
||||||
|
|
||||||
|
|
||||||
## Texinfo manual stuff
|
## Texinfo manual stuff
|
||||||
|
|
|
@ -1367,6 +1367,10 @@ ponies will pass the @option{--restrict} option when ponies are randomly selecte
|
||||||
A metadata colletion file's content a list, of pony files with and their corresponding
|
A metadata colletion file's content a list, of pony files with and their corresponding
|
||||||
metadata as a map from tag name to tag value set, serialised with Python's cPickle module.
|
metadata as a map from tag name to tag value set, serialised with Python's cPickle module.
|
||||||
|
|
||||||
|
Running @command{ponysay-tool --metadata PONY-DIR} will generate the file @file{metadata}
|
||||||
|
with the serialised information. For use by the installer, the files to include can be
|
||||||
|
explicity declared appending their basename to the command.
|
||||||
|
|
||||||
|
|
||||||
@node Dimension files
|
@node Dimension files
|
||||||
@section Dimension files
|
@section Dimension files
|
||||||
|
@ -1381,7 +1385,9 @@ and may be randomly selected.
|
||||||
Running @command{ponysay-tool --dimensions PONY-DIR} will generate three files
|
Running @command{ponysay-tool --dimensions PONY-DIR} will generate three files
|
||||||
@file{widths}, @file{heights} and @file{onlyheights} to the directory @file{PONY-DIR},
|
@file{widths}, @file{heights} and @file{onlyheights} to the directory @file{PONY-DIR},
|
||||||
the contain optimised information about the widths, heigths and heights with printed
|
the contain optimised information about the widths, heigths and heights with printed
|
||||||
without the balloon, respectively, for each pony the the directory.
|
without the balloon, respectively, for each pony the the directory. For use by the
|
||||||
|
installer, the files to include can be explicity declared appending their basename to
|
||||||
|
the command.
|
||||||
|
|
||||||
|
|
||||||
@node Pony browsing
|
@node Pony browsing
|
||||||
|
|
24
setup.py
24
setup.py
|
@ -553,15 +553,21 @@ class Setup():
|
||||||
|
|
||||||
for sharedir in [sharedir[0] for sharedir in sharedirs]: # TODO make this an opt-out option
|
for sharedir in [sharedir[0] for sharedir in sharedirs]: # TODO make this an opt-out option
|
||||||
if os.path.isdir(sharedir):
|
if os.path.isdir(sharedir):
|
||||||
for sharefile in os.listdir(sharedir):
|
if not self.free:
|
||||||
if sharefile.endswith('.pony') and (sharefile != '.pony'):
|
for toolcommand in ('--dimensions', '--metadata'):
|
||||||
sharefile = sharedir + '/' + sharefile
|
print('%s, %s, %s' % ('./src/ponysay-tool.py', toolcommand, sharedir))
|
||||||
if self.free and not Setup.validateFreedom(sharefile):
|
Popen(['./src/ponysay-tool.py', toolcommand, sharedir], stdin=PIPE, stdout=PIPE, stderr=PIPE).communicate()
|
||||||
print('Skipping metadata correction for %s, did not pass validation process made by setup settings' % sharefile)
|
else:
|
||||||
continue
|
params = ['./src/ponysay-tool.py', toolcommand, sharedir, '--']
|
||||||
for toolcommand in ('--dimensions', '--metadata'):
|
for sharefile in os.listdir():
|
||||||
print('%s, %s, %s' % ('./ponysay-tool.py', toolcommand, sharefile))
|
if sharefile.endswith('.pony') and (sharefile != '.pony'):
|
||||||
Popen(['./ponysay-tool.py', toolcommand, sharefile], stdin=PIPE, stdout=PIPE, stderr=PIPE).communicate()
|
if not Setup.validateFreedom(sharedir + '/' + sharefile):
|
||||||
|
print('Skipping metadata correction for %s/%s, did not pass validation process made by setup settings' % (sharedir, sharefile))
|
||||||
|
else:
|
||||||
|
params.append(sharefile)
|
||||||
|
for toolcommand in ('--dimensions', '--metadata'):
|
||||||
|
print('%s, %s, %s (with files)' % ('./src/ponysay-tool.py', toolcommand, sharedir))
|
||||||
|
Popen(params, stdin=PIPE, stdout=PIPE, stderr=PIPE).communicate()
|
||||||
|
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
|
|
@ -78,10 +78,10 @@ class PonysayTool():
|
||||||
self.generateKMS()
|
self.generateKMS()
|
||||||
|
|
||||||
elif (opts['--dimensions'] is not None) and (len(opts['--dimensions']) == 1):
|
elif (opts['--dimensions'] is not None) and (len(opts['--dimensions']) == 1):
|
||||||
self.generateDimensions(opts['--dimensions'][0])
|
self.generateDimensions(opts['--dimensions'][0], args.files)
|
||||||
|
|
||||||
elif (opts['--metadata'] is not None) and (len(opts['--metadata']) == 1):
|
elif (opts['--metadata'] is not None) and (len(opts['--metadata']) == 1):
|
||||||
self.generateMetadata(opts['--metadata'][0])
|
self.generateMetadata(opts['--metadata'][0], args.files)
|
||||||
|
|
||||||
elif (opts['-b'] is not None) and (len(opts['-b']) == 1):
|
elif (opts['-b'] is not None) and (len(opts['-b']) == 1):
|
||||||
try:
|
try:
|
||||||
|
@ -475,11 +475,15 @@ class PonysayTool():
|
||||||
'''
|
'''
|
||||||
Generate pony dimension file for a directory
|
Generate pony dimension file for a directory
|
||||||
|
|
||||||
@param ponydir The directory
|
@param ponydir:str The directory
|
||||||
|
@param ponies:itr<str>? Ponies to which to limit
|
||||||
'''
|
'''
|
||||||
def generateDimensions(self, ponydir):
|
def generateDimensions(self, ponydir, ponies = None):
|
||||||
dimensions = []
|
dimensions = []
|
||||||
|
ponyset = None if (ponies is None) or (len(ponies) == 0) else set(ponies)
|
||||||
for ponyfile in os.listdir(ponydir):
|
for ponyfile in os.listdir(ponydir):
|
||||||
|
if (ponyset is not None) and (ponyfile not in ponyset):
|
||||||
|
continue
|
||||||
if ponyfile.endswith('.pony') and (ponyfile != '.pony'):
|
if ponyfile.endswith('.pony') and (ponyfile != '.pony'):
|
||||||
class PhonyArgParser():
|
class PhonyArgParser():
|
||||||
def __init__(self, balloon):
|
def __init__(self, balloon):
|
||||||
|
@ -557,9 +561,10 @@ class PonysayTool():
|
||||||
'''
|
'''
|
||||||
Generate pony metadata collection file for a directory
|
Generate pony metadata collection file for a directory
|
||||||
|
|
||||||
@param ponydir The directory
|
@param ponydir:str The directory
|
||||||
|
@param ponies:itr<str>? Ponies to which to limit
|
||||||
'''
|
'''
|
||||||
def generateMetadata(self, ponydir):
|
def generateMetadata(self, ponydir, ponies = None):
|
||||||
if not ponydir.endswith('/'):
|
if not ponydir.endswith('/'):
|
||||||
ponydir += '/'
|
ponydir += '/'
|
||||||
def makeset(value):
|
def makeset(value):
|
||||||
|
@ -597,7 +602,10 @@ class PonysayTool():
|
||||||
rc.add(buf)
|
rc.add(buf)
|
||||||
return rc
|
return rc
|
||||||
everything = []
|
everything = []
|
||||||
|
ponyset = None if (ponies is None) or (len(ponies) == 0) else set(ponies)
|
||||||
for ponyfile in os.listdir(ponydir):
|
for ponyfile in os.listdir(ponydir):
|
||||||
|
if (ponyset is not None) and (ponyfile not in ponyset):
|
||||||
|
continue
|
||||||
if ponyfile.endswith('.pony') and (ponyfile != '.pony'):
|
if ponyfile.endswith('.pony') and (ponyfile != '.pony'):
|
||||||
with open(ponydir + ponyfile, 'rb') as file:
|
with open(ponydir + ponyfile, 'rb') as file:
|
||||||
data = file.read().decode('utf8', 'replace')
|
data = file.read().decode('utf8', 'replace')
|
||||||
|
@ -621,7 +629,7 @@ class PonysayTool():
|
||||||
data.append((key, makeset(value.replace(' ', ''))))
|
data.append((key, makeset(value.replace(' ', ''))))
|
||||||
everything.append((ponyfile[:-5], data))
|
everything.append((ponyfile[:-5], data))
|
||||||
import cPickle
|
import cPickle
|
||||||
with open(ponydir + 'metadata', 'wb') as file:
|
with open((ponydir + '/metadata').replace('//', '/'), 'wb') as file:
|
||||||
cPickle.dump(everything, file, -1)
|
cPickle.dump(everything, file, -1)
|
||||||
file.flush()
|
file.flush()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue