This repository has been archived on 2024-04-07. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/funcs.py

34 lines
570 B
Python
Raw Normal View History

2020-07-12 08:02:43 +02:00
import os
def parent_dir(path):
return os.path.split(path)[0]
2020-10-06 02:09:07 +02:00
def ordered_path():
PATH = os.environ['PATH']
newPATH = []
for i in PATH.split(":"):
if i not in newPATH:
newPATH.append(i)
return ':'.join(newPATH)
2020-10-10 08:35:37 +02:00
def hex2rgb(e):
assert e.startswith("#")
e = e.strip("#").lower()
assert len(e) == 6
for i in e:
assert (i in "0123456789abcdef")
def h2r(i):
return str(eval('0x{}'.format(i)))
r = e[0:2]
g = e[2:4]
b = e[4:6]
return ", ".join([h2r(i) for i in (r, g, b)])