free software resistance
the cost of computing freedom is eternal vigilance
### demo.figu.py
*original date:* nov 2016
*originally posted:* oct 2024
demo.figu.py:
```
#!/usr/bin/env python
# encoding: utf-8
# figueira translator version: figueira 2.9
import sys, os
from sys import stdin, stdout
from sys import argv as figargv
try: from colorama import init ; init()
except: pass # (only) windows users want colorama installed or ansi.sys enabled
from random import randint
from time import sleep
from os import chdir as figoch
from os import popen as figpo
from os import system as figsh
from os import name as figosname
figsysteme = 0
figfilehandles = {}
figfilecounters = {}
from sys import stdout
def figlocaliz(x, l = "ignore", c = "ignore"):
import sys
if l == "ignore" and c == "ignore": pass
# do nothing. want it to return an error?
elif l < 1 and c != "ignore":
sys.stdout.write("[" + str(c) + "G") # not ansi.sys compatible
elif l != "ignore" and c == "ignore":
sys.stdout.write("[" + str(l) + ";" + str(1) + "H")
else: sys.stdout.write("[" + str(l) + ";" + str(c) + "H")
import time
def fignonz(p, n=None):
if n==None:
if p == 0: return 1
else:
if p == 0: return n
return p
def figestanao(p):
if p: return 0
return -1
figbac = None
figprsbac = None
sub = None
def fignone(p, figbac):
if p == None: return figbac
return p
return -1
def stopgraphics():
global yourscreen
global figraphics
figraphics = 0
try: pygame.quit()
except: pass
def figcortexto(x, f):
b = 0
if f == None: f = 0
if b == None: b = 0
n = "0"
if f > 7: n = "1" ; f = f - 8
if f == 1: f = 4 ## switch ansi colors for qb colors
elif f == 4: f = 1 ## 1 = blue not red, 4 = red not blue, etc.
if f == 3: f = 6
elif f == 6: f = 3
if b > 7: b = b - 8
if b == 1: b = 4
elif b == 4: b = 1
if b == 3: b = 6
elif b == 6: b = 3
stdout.write("\x1b[" + n + ";" + str(30+f) + "m")
return "\x1b[" + n + ";" + str(30+f) + ";" + str(40+b) + "m"
figcgapal = [(0, 0, 0), (0, 0, 170), (0, 170, 0), (0, 170, 170),
(170, 0, 0), (170, 0, 170), (170, 85, 0), (170, 170, 170),
(85, 85, 85), (85, 85, 255), (85, 255, 85), (85, 255, 255),
(255, 85, 85), (255, 85, 255), (255, 255, 85), (255, 255, 255)]
def figobter(p, s): return s
def figrealcar(x, b):
f = None
if f == None: f = 0
if b == None: b = 0
n = "0"
if f > 7: n = "1" ; f = f - 8
if f == 1: f = 4 ## switch ansi colors for qb colors
elif f == 4: f = 1 ## 1 = blue not red, 4 = red not blue, etc.
if f == 3: f = 6
elif f == 6: f = 3
if b > 7: b = b - 8
if b == 1: b = 4
elif b == 4: b = 1
if b == 3: b = 6
elif b == 6: b = 3
stdout.write("\x1b[" + n + str(40+b) + "m")
return "\x1b[" + n + str(40+b) + "m"
def figincad(x, p, e):
try: return p.index(e) + 1
except: return 0
def figmudar(p):
try: figoch(p)
except: print "no such file or directory: " + str(p) ; figend(1)
def figshell(p):
global figsysteme
try: figsysteme = figsh(p)
except:
print "error running shell command: " + chr(34) + str(p) + chr(34)
figend(1)
def figordshell(c):
global figsysteme
try:
figsysteme = 0
sh = figpo(c)
ps = sh.read().replace(chr(13) + chr(10),
chr(10)).replace(chr(13), chr(10)).split(chr(10))
figsysteme = sh.close()
except:
print "error running arrshell command: " + chr(34) + str(c) + chr(34)
figend(1)
return ps[:]
def figsmb(p):
p = float(p)
if p > 0: return 1
if p < 0: return -1
return 0
def figcad(p): return str(p)
def figimpress(p): print p
def figcar(p):
if type(p) == str:
if len(p) > 0:
return p[0]
return chr(p)
def figimpressha(p): stdout.write(str(p)) ; sys.stdout.flush()
def figesquerdo(p, s): return p[:s]
def figmeio(p, s, x):
arr = 0
if type(p) == list or type(p) == tuple: arr = 1
rt = p[s - 1:x + s - 1]
if arr and len(rt) == 1: rt = rt[0]
return rt
def figdireito(p, s): return p[-s:]
def figaleatint(x, s, f):
return randint(s, f)
def figmincula(p): return p.lower()
def figmaicula(p): return p.upper()
def figint(p): return int(p)
def figordpus(x, p, s):
if 1:
#if type(p) == str: p = p + s # str(s) if you want it easier
if 1: #type(p) == list:
if type(s) == tuple:
if len(s) == 1: fas = s[0]
elif type(s) == list:
if len(s) == 1: fas = s[0]
else:
fas = s
x[p - 1] = s
#if type(p) == tuple:
# if type(s) == tuple:
# p = tuple(list(p) + list(s))
# elif type(s) == list:
# p = tuple(list(p) + s[:])
# else:
# p = tuple(list(p) + [s])
#if type(p) == str: p = p + s # str(s) if you want it easier
def figaberto(x, s):
import fileinput
if s.lower() == "w":
if (x) not in figfilehandles.keys():
figfilehandles[x] = open(x[:], s.lower())
elif s.lower() == "r":
if (x) not in figfilehandles.keys():
figfilehandles[x] = fileinput.input(x[:])
figfilecounters[x] = 0
else:
if (x) not in figfilehandles.keys(): figfilehandles[x] = open(x[:], s[:])
def figaimpress(x, s):
fon = figosname
sep = chr(10)
if fon == "nt": sep = chr(13) + chr(10)
figfilehandles[s].write(str(x) + sep)
def figalinhaentra(x, s):
try:
p = figfilehandles[s][figfilecounters[s]].replace(chr(13),
"").replace(chr(10), "")
figfilecounters[s] += 1
except:
p = chr(10)
return p
def figfechar(x):
if (x) in figfilehandles.keys():
figfilehandles[x].close() ; del figfilehandles[x]
try: del figfilecounters[x]
except: pass
def figlmp(x):
if figosname == "nt": cls = figsh("cls")
else: stdout.write("[2J[1;1H") ; sys.stdout.flush()
def figordaberto(x, s):
x = open(s).read().replace(chr(13) + chr(10), chr(10)).replace(chr(13),
chr(10)).split(chr(10))
return x[:]
def figordcurl(x, s):
from urllib import urlopen
x = str(urlopen(s).read()) ; x = x.replace(chr(13) + chr(10),
chr(10)).replace(chr(13), chr(10)).split(chr(10))
return x[:]
def figordstdin(x):
ps = []
for p in stdin: ps += [p[:-1]]
return ps[:]
def figordobter(x, p, s):
if 1:
return p[s - 1]
def figmais(p, s):
if type(p) in (float, int):
if type(s) in (float, int):
p = p + s
else:
p = p + s # float(s) if you want it easier
if p == float(int(p)): p = int(p)
else:
if type(p) == str: p = p + s # str(s) if you want it easier
if type(p) == list:
if type(s) == tuple:
p = p + list(s)
elif type(s) == list:
p = p + s[:]
else:
p = p + [s]
if type(p) == tuple:
if type(s) == tuple:
p = tuple(list(p) + list(s))
elif type(s) == list:
p = tuple(list(p) + s[:])
else:
p = tuple(list(p) + [s])
return p
def figjuntar(p, x, s):
t = ""
if len(x) : t = str(x[0])
for c in range(len(x)):
if c > 0: t += str(s) + str(x[c])
return t # s.join(x)
def figordem(p):
if type(p) in (float, int, str):
p = [p]
else:
p = list(p)
return p
def figseparar(p, x, s):
return x.split(s)
def figval(n):
n = float(n)
if float(int(n)) == float(n): n = int(n)
return n
def figmultipor(p, s):
if type(p) in (float, int):
p = p * s # float(s) if you want it easier
if p == float(int(p)): p = int(p)
else:
if type(p) == list:
p = p[:] * s # figval(s)
else:
p = p * s # figval(s) if you want it easer
return p
def figdivipor(p, s):
p = float(p) / s
if p == float(int(p)): p = int(p)
return p
def figmenos(p, s): return p - s
def figapoten(p, s):
p = p ** s
if p == float(int(p)): p = int(p)
return p
def figmod(p, s):
return p % s
def figcosseno(p):
from math import cos ; p = cos(p)
if p == float(int(p)): p = int(p)
return p
def figseno(p):
from math import sin ; p = sin(p)
if p == float(int(p)): p = int(p)
return p
def figraizquadr(p):
from math import sqrt ; p = sqrt(p)
if p == float(int(p)): p = int(p)
return p
def figecorta(p): return p.lstrip()
def figlinhaentra(p): return raw_input()
def figcomprim(p): return len(p)
def figasc(p): return ord(p[0])
def figatan(p):
from math import atan ; p = atan(p)
if p == float(int(p)): p = int(p)
return p
def fighex(p): return hex(p)
def figdcorta(p): return p.rstrip()
def figcadeia(x, p, n):
if type(n) == str: return n * p
return chr(n) * p
def figcrono(p):
from time import strftime
return int(strftime("%H"))*60*60+int(strftime("%M"))*60+int(strftime("%S"))
def fighora(p): from time import strftime ; return strftime("%H:%M:%S")
def figdata(p): from time import strftime ; return strftime("%m/%d/%Y")
def figcomando(p): return figargv[1:]
def figtan(p):
from math import tan ; p = tan(p)
if p == float(int(p)): p = int(p)
return p
def figoct(p): return oct(p)
def figpausa(p, s):
#print lc () + p
#addto[0] = 1
sleep(s)
def figordordena(p):
p.sort()
def figdisplay(x):
global figraphics, figrupd
figrupd = 0
if figraphics == 1:
pygame.display.update()
def figreverso(p):
if type(p) == list: p.reverse() ; return p
elif type(p) == str:
p = map(str, p) ; p.reverse()
p = "".join(p)
return p
def figordreverso(p):
p.reverse()
def figfuncao(p, s): return p
def figfim(x): quit()
def figif(p, s): return p
def figthen(p, s): return p
def figsistema(x): quit()
figlist = 0
try: figlist = int(type(p) == list)
except NameError: pass
if not figlist: p = 0
p = 7 ; p = figordem(p) ; p = figmultipor(p, 5) ;
figlist = 0
try: figlist = int(type(x) == list)
except NameError: pass
if not figlist: x = 0
x = "hello, world!" ;
#z x impressha
#z x impress
figlist = 0
try: figlist = int(type(x) == list)
except NameError: pass
if not figlist: x = 0
x = 5 ;
figlist = 0
try: figlist = int(type(x) == list)
except NameError: pass
if not figlist: x = 0
x = 5 ; x = figmultipor(x, 7) ;
figlist = 0
try: figlist = int(type(x) == list)
except NameError: pass
if not figlist: x = 0
x = 3 ; x = figmais(x, 5) ; x = figmultipor(x, 7) ;
figlist = 0
try: figlist = int(type(z) == list)
except NameError: pass
if not figlist: z = 0
z = x
figlist = 0
try: figlist = int(type(x) == list)
except NameError: pass
if not figlist: x = 0
x = z
x = figcad(x) ; x = figasc(x) ; x = figint(x) ;
def oi(p):
figlist = 0
try: figlist = int(type(x) == list)
except NameError: pass
if not figlist: x = 0
x = "oi, " ; # x = "hello, "
figlist = 0
try: figlist = int(type(x) == list)
except NameError: pass
if not figlist: x = 0
figimpressha(x) ; return 5# print x; : hello = 5 : exit function
figlist = 0
try: figlist = int(type(x) == list)
except NameError: pass
if not figlist: x = 0
figbac = x ; x = oi(x) ; x = fignone(x, figbac) ; # x = hello(x)
#x if 5```````````````` # if x = 5 then
#p "five" print```````` # p = "five" : print p
#else`````````````````` # else
#p "not 5 or 7" print`` # p = "not 5 or 7" : print p
#fig````````````````````# end if
figlist = 0
try: figlist = int(type(c) == list)
except NameError: pass
if not figlist: c = 0
c = figcomando(c) ; figimpress(c) ;
#y x````````````````````# y = x
#y chr 70 mid y 1 1```` # y = chr(70) : y = mid(y, 1, 1)
#x print sleep 2 cls````# print x : sleep 2 : cls
figlist = 0
try: figlist = int(type(p) == list)
except NameError: pass
if not figlist: p = 0
figimpress(p) ;
figlist = 0
try: figlist = int(type(p) == list)
except NameError: pass
if not figlist: p = 0
figimpress(p) ; figordpus(p, 2, 8) ; figimpress(p) ;
figlist = 0
try: figlist = int(type(z) == list)
except NameError: pass
if not figlist: z = 0
z = figjuntar(z, p, "(_)") ; figimpress(z) ;
figlist = 0
try: figlist = int(type(x) == list)
except NameError: pass
if not figlist: x = 0
x = z
figimpress(x) ;
figlist = 0
try: figlist = int(type(p) == list)
except NameError: pass
if not figlist: p = 0
figimpress(p) ; figfim(p) ;
def pete():
figlist = 0
try: figlist = int(type(p) == list)
except NameError: pass
if not figlist: p = 0
p = "oi" ; figimpress(p) ;
def mais5(r):
figlist = 0
try: figlist = int(type(x) == list)
except NameError: pass
if not figlist: x = 0
x = figobter(x, r) ; x = figmais(x, 5) ; return x
def ppp():
figlist = 0
try: figlist = int(type(z) == list)
except NameError: pass
if not figlist: z = 0
z = 32 ; z = figcar(z) ; figimpress(z) ;
for p in range(int(float(1)), int(float(100)) + figsmb(1), fignonz(int(float(1)))):
figlist = 0
try: figlist = int(type(x) == list)
except NameError: pass
if not figlist: x = 0
x = figaleatint(x, 0, 3) ;
figlist = 0
try: figlist = int(type(y) == list)
except NameError: pass
if not figlist: y = 0
y = figaleatint(y, 0, 3) ;
figlist = 0
try: figlist = int(type(c) == list)
except NameError: pass
if not figlist: c = 0
c = figaleatint(c, 1, 9) ;
#z ppus x y c
figlist = 0
try: figlist = int(type(c) == list)
except NameError: pass
if not figlist: c = 0
figcortexto(c, 7) ;
figlist = 0
try: figlist = int(type(z) == list)
except NameError: pass
if not figlist: z = 0
figbac = z ; z = ppp() ; z = fignone(z, figbac) ;
figlist = 0
try: figlist = int(type(z) == list)
except NameError: pass
if not figlist: z = 0
figpausa(z, 1) ;
#textmode
figlist = 0
try: figlist = int(type(z) == list)
except NameError: pass
if not figlist: z = 0
figbac = z ; z = ppp() ; z = fignone(z, figbac) ; figpausa(z, 2) ; z = z
figbac = z ; z = ppp() ; z = fignone(z, figbac) ;
```
license: 0-clause bsd
```
# 2016 mn
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
```
=> https://freesoftwareresistance.neocities.org