25 lines
565 B
Python
25 lines
565 B
Python
#! /usr/bin/env python3
|
|
|
|
import os
|
|
import shutil
|
|
import stat
|
|
import sys
|
|
|
|
def mkdir(path):
|
|
if not os.path.exists(path) and os.path.isdir(path):
|
|
os.mkdir(path)
|
|
|
|
def rm(path):
|
|
if (os.path.exists(path) or os.path.islink(path)) and not os.path.isdir(path):
|
|
os.chmod(path, stat.S_IWRITE)
|
|
os.remove(path)
|
|
elif os.path.isdir(path):
|
|
os.chmod(path, stat.S_IWRITE)
|
|
shutil.rmtree(path)
|
|
|
|
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])
|