mirror of
https://github.com/erkin/ponysay.git
synced 2024-11-29 15:37:59 +01:00
Use os.get_terminal_size; random got some fixes upstream
This commit is contained in:
parent
e2a6948b7b
commit
8afd43527b
3 changed files with 5 additions and 13 deletions
|
@ -44,12 +44,14 @@ from ponysay.argparser import ArgParser
|
||||||
from ponysay.ponysay import Ponysay
|
from ponysay.ponysay import Ponysay
|
||||||
import os
|
import os
|
||||||
import kuroko
|
import kuroko
|
||||||
|
import random
|
||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Start the program
|
Start the program
|
||||||
'''
|
'''
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
random.seed()
|
||||||
let istool = kuroko.argv[0]
|
let istool = kuroko.argv[0]
|
||||||
if os.sep in istool:
|
if os.sep in istool:
|
||||||
istool = istool[istool.rfind(os.sep) + 1:]
|
istool = istool[istool.rfind(os.sep) + 1:]
|
||||||
|
|
|
@ -70,12 +70,6 @@ def gettermsize():
|
||||||
|
|
||||||
@return (rows, columns):(int, int) The number or lines and the number of columns in the terminal's display area
|
@return (rows, columns):(int, int) The number or lines and the number of columns in the terminal's display area
|
||||||
'''
|
'''
|
||||||
# TODO we don't have a thing for this??
|
let columns, rows = os.get_terminal_size()
|
||||||
try:
|
return rows, columns
|
||||||
os.system("stty size > /tmp/.ponysaysize")
|
|
||||||
with fileio.open("/tmp/.ponysaysize") as f:
|
|
||||||
let tmp = f.read().strip()
|
|
||||||
return tuple(int(x) for x in tmp.split(' '))
|
|
||||||
except:
|
|
||||||
return (24, 80) # fall back to minimal sane size
|
|
||||||
|
|
||||||
|
|
|
@ -45,11 +45,7 @@ import stat
|
||||||
import random
|
import random
|
||||||
|
|
||||||
def randrange(low,high):
|
def randrange(low,high):
|
||||||
with fileio.open('/dev/urandom','rb') as f:
|
return int(random.random() * (high - low) + low)
|
||||||
let b = f.read(4)
|
|
||||||
let val = (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3]
|
|
||||||
let flt = val / 0xFFFFFFFF
|
|
||||||
return int(flt*(high-low)+low)
|
|
||||||
|
|
||||||
def rfind(self, sub):
|
def rfind(self, sub):
|
||||||
let last = self.find(sub)
|
let last = self.find(sub)
|
||||||
|
|
Loading…
Reference in a new issue