50 lines
832 B
Python
50 lines
832 B
Python
from math import *;
|
|
import numpy as np
|
|
from pathlib import Path
|
|
import subprocess
|
|
import os
|
|
from pprint import pprint
|
|
from itertools import *
|
|
|
|
Path.__repr__ = lambda i: f"p'{str(i)}'"
|
|
|
|
kilo = 1000
|
|
mega = 1000 * kilo
|
|
giga = 1000 * mega
|
|
tera = 1000 * giga
|
|
peta = 1000 * tera
|
|
|
|
b = 1
|
|
kib = 1024
|
|
mib = 1024 * kib
|
|
gib = 1024 * mib
|
|
tib = 1024 * gib
|
|
pib = 1024 * tib
|
|
|
|
inch = 0.0254
|
|
yard = 0.9144
|
|
|
|
def cwd():
|
|
return Path.cwd()
|
|
|
|
def ls(d = None):
|
|
if d is None:
|
|
d = cwd()
|
|
|
|
return list(Path(d).iterdir())
|
|
|
|
def glob(expr):
|
|
return list(cwd().glob(expr))
|
|
|
|
def run(cmd, only_stdout=True):
|
|
res = subprocess.run(cmd, capture_output=True, text=True, shell=True)
|
|
if only_stdout:
|
|
return str(res.stdout)
|
|
else:
|
|
return res
|
|
|
|
def cat(file):
|
|
return open(file, "r").read()
|
|
|
|
print_ = print
|
|
print = pprint
|