2021-02-20 19:00:47 -06:00
|
|
|
#! /usr/bin/env python3
|
|
|
|
|
|
|
|
import os
|
2021-02-20 20:03:54 -06:00
|
|
|
import shutil
|
|
|
|
import stat
|
2021-02-20 19:00:47 -06:00
|
|
|
import sys
|
|
|
|
|
|
|
|
def mkdir(path):
|
|
|
|
if not os.path.exists(path) and os.path.isdir(path):
|
|
|
|
os.mkdir(path)
|
|
|
|
|
|
|
|
def rm(path):
|
2021-02-20 20:03:54 -06:00
|
|
|
if (os.path.exists(path) or os.path.islink(path)) and not os.path.isdir(path):
|
|
|
|
os.chmod(path, stat.S_IWRITE)
|
2021-02-20 19:00:47 -06:00
|
|
|
os.remove(path)
|
2021-02-20 20:03:54 -06:00
|
|
|
elif os.path.isdir(path):
|
|
|
|
os.chmod(path, stat.S_IWRITE)
|
|
|
|
shutil.rmtree(path)
|
2021-02-20 19:00:47 -06:00
|
|
|
|
|
|
|
if sys.argv[1] == 'mkdir':
|
|
|
|
mkdir(sys.argv[2])
|
|
|
|
elif sys.argv[1] == 'rm':
|
|
|
|
for i in range(2, len(sys.argv)):
|
|
|
|
rm(sys.argv[i])
|