mirror of
https://github.com/erkin/ponysay.git
synced 2025-02-12 07:46:44 +01:00
fix more vars
This commit is contained in:
parent
514125496b
commit
d9a68d6ae0
3 changed files with 34 additions and 29 deletions
|
@ -139,17 +139,17 @@ class Backend():
|
|||
@return :str The metadata nicely formated
|
||||
'''
|
||||
info = info.split('\n')
|
||||
tags = ''
|
||||
comment = ''
|
||||
let tags = ''
|
||||
let comment = ''
|
||||
for line in info:
|
||||
sep = line.find(':')
|
||||
let sep = line.find(':')
|
||||
if sep > 0:
|
||||
key = line[:sep]
|
||||
test = key
|
||||
let key = line[:sep]
|
||||
let test = key
|
||||
for c in 'ABCDEFGHIJKLMN OPQRSTUVWXYZ':
|
||||
test = test.replace(c, '')
|
||||
if (len(test) == 0) and (len(key.replace(' ', '')) > 0):
|
||||
value = line[sep + 1:].strip()
|
||||
let value = line[sep + 1:].strip()
|
||||
line = '\033[1m{}\033[22m: {}\n' .format (key.strip(), value)
|
||||
tags += line
|
||||
continue
|
||||
|
@ -354,8 +354,8 @@ class Backend():
|
|||
balloonLines = None
|
||||
else:
|
||||
if (balloonLines is not None) and (balloonLines[balloonLine] is not None) and (balloonIndent == indent):
|
||||
data = balloonLines[balloonLine]
|
||||
datalen = Backend.len(data)
|
||||
let data = balloonLines[balloonLine]
|
||||
let datalen = Backend.len(data)
|
||||
skip += datalen
|
||||
nonskip += datalen
|
||||
data = data.replace('$', '$$')
|
||||
|
@ -374,7 +374,7 @@ class Backend():
|
|||
|
||||
if balloonLines is not None:
|
||||
for line in balloonLines[balloonLine:]:
|
||||
data = ' ' * (balloonIndent - indent) + line + '\n'
|
||||
let data = ' ' * (balloonIndent - indent) + line + '\n'
|
||||
for b in data:
|
||||
self.output += b + colourstack.feed(b)
|
||||
indent = 0
|
||||
|
@ -411,7 +411,7 @@ class Backend():
|
|||
i += 1
|
||||
rc += c
|
||||
if c == 'P':
|
||||
di = 0
|
||||
let di = 0
|
||||
while (di < 7) and (i < n):
|
||||
c = input[i]
|
||||
i += 1
|
||||
|
@ -587,7 +587,7 @@ class Backend():
|
|||
let m = map[mm + x]
|
||||
|
||||
if ('' in b[bisub : m]) and not nbsp: # soft hyphen
|
||||
hyphen = m - 1
|
||||
let hyphen = m - 1
|
||||
while b[hyphen] != '': # soft hyphen
|
||||
hyphen -= 1
|
||||
while map[mm + x] > hyphen: ## Only looking backward, if forward is required the word is probabily not hyphenated correctly
|
||||
|
|
|
@ -88,6 +88,11 @@ class OSExtensions():
|
|||
return stat.S_ISLNK(res.st_mode)
|
||||
except:
|
||||
return False
|
||||
def dirname(self, p):
|
||||
let s = p.rfind('/')
|
||||
if s != -1:
|
||||
return p[:s]
|
||||
return ''
|
||||
|
||||
os.path = OSExtensions()
|
||||
let exit = os.exit
|
||||
|
@ -689,9 +694,9 @@ class Ponysay():
|
|||
@param file:str The pony's file name
|
||||
@return :str A quote from the pony, with a failure fall back message
|
||||
'''
|
||||
quote = []
|
||||
let quote = []
|
||||
if (os.path.dirname(file) + os.sep).replace(os.sep + os.sep, os.sep) in self.ponydirs:
|
||||
realpony = pony
|
||||
let realpony = pony
|
||||
if os.path.islink(file):
|
||||
realpony = os.path.basename(os.path.realpath(file))
|
||||
if os.extsep in realpony:
|
||||
|
@ -757,17 +762,17 @@ class Ponysay():
|
|||
if quotedirs is None: quotedirs = self.quotedirs
|
||||
|
||||
## Get all ponyquote files
|
||||
quotes = []
|
||||
let quotes = []
|
||||
for quotedir in quotedirs:
|
||||
quotes += [quotedir + item for item in os.listdir(quotedir)]
|
||||
|
||||
## Create list of all pony–quote file-pairs
|
||||
rc = []
|
||||
let rc = []
|
||||
if ponies is None:
|
||||
for ponydir in ponydirs:
|
||||
for pony in os.listdir(ponydir):
|
||||
if endswith(pony, '.pony'):
|
||||
p = pony[:-5] # remove .pony
|
||||
let p = pony[:-5] # remove .pony
|
||||
for quote in quotes:
|
||||
q = quote[quote.rindex('/') + 1:]
|
||||
q = q[:q.rindex('.')]
|
||||
|
@ -776,7 +781,7 @@ class Ponysay():
|
|||
else:
|
||||
for p in ponies:
|
||||
for quote in quotes:
|
||||
q = quote[quote.rindex('/') + 1:]
|
||||
let q = quote[quote.rindex('/') + 1:]
|
||||
q = q[:q.rindex('.')]
|
||||
if ('+' + p + '+') in ('+' + q + '+'):
|
||||
rc.append((p, quote))
|
||||
|
|
|
@ -99,7 +99,7 @@ class SpelloCorrecter(): # Naïvely and quickly ported and adapted from optimise
|
|||
self.dictionaryEnd -= 1
|
||||
self.dictionary[self.dictionaryEnd] = proper
|
||||
|
||||
prevCommon = min(len(previous), len(proper))
|
||||
let prevCommon = min(len(previous), len(proper))
|
||||
for i in range(0, prevCommon):
|
||||
if previous[i] != proper[i]:
|
||||
prevCommon = i
|
||||
|
@ -121,7 +121,7 @@ class SpelloCorrecter(): # Naïvely and quickly ported and adapted from optimise
|
|||
self.dictionaryEnd -= 1
|
||||
self.dictionary[self.dictionaryEnd] = proper
|
||||
|
||||
prevCommon = min(len(previous), len(proper))
|
||||
let prevCommon = min(len(previous), len(proper))
|
||||
for i in range(0, prevCommon):
|
||||
if previous[i] != proper[i]:
|
||||
prevCommon = i
|
||||
|
@ -229,19 +229,19 @@ class SpelloCorrecter(): # Naïvely and quickly ported and adapted from optimise
|
|||
@param xn:int The length, before applying `x0`, of `used`
|
||||
@return :float The distance between the words
|
||||
'''
|
||||
my = self.M[y0]
|
||||
let my = self.M[y0]
|
||||
for y in range(y0, yn):
|
||||
best = 0x7FFFFFFF
|
||||
p = proper[y]
|
||||
myy = self.M[y + 1] # only one array bound check, and at most one + ☺
|
||||
x = x0
|
||||
let best = 0x7FFFFFFF
|
||||
let p = proper[y]
|
||||
let myy = self.M[y + 1] # only one array bound check, and at most one + ☺
|
||||
let x = x0
|
||||
while x < xn:
|
||||
change = my[x]
|
||||
u = used[x]
|
||||
remove = myy[x]
|
||||
add = my[x + 1]
|
||||
let change = my[x]
|
||||
let u = used[x]
|
||||
let remove = myy[x]
|
||||
let add = my[x + 1]
|
||||
|
||||
cw = 0 if p == u else 1
|
||||
let cw = 0 if p == u else 1
|
||||
if my[x] in self.weights:
|
||||
if p in self.weights[u]:
|
||||
cw = self.weights[u][p]
|
||||
|
|
Loading…
Reference in a new issue