mirror of
https://github.com/erkin/ponysay.git
synced 2024-12-01 16:27:58 +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
|
||||
import os
|
||||
import kuroko
|
||||
import random
|
||||
|
||||
|
||||
'''
|
||||
Start the program
|
||||
'''
|
||||
if __name__ == '__main__':
|
||||
random.seed()
|
||||
let istool = kuroko.argv[0]
|
||||
if os.sep in istool:
|
||||
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
|
||||
'''
|
||||
# TODO we don't have a thing for this??
|
||||
try:
|
||||
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
|
||||
let columns, rows = os.get_terminal_size()
|
||||
return rows, columns
|
||||
|
||||
|
|
|
@ -45,11 +45,7 @@ import stat
|
|||
import random
|
||||
|
||||
def randrange(low,high):
|
||||
with fileio.open('/dev/urandom','rb') as f:
|
||||
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)
|
||||
return int(random.random() * (high - low) + low)
|
||||
|
||||
def rfind(self, sub):
|
||||
let last = self.find(sub)
|
||||
|
|
Loading…
Reference in a new issue