21 lines
362 B
Python
21 lines
362 B
Python
import sys,os,contextlib,builtins,email
|
|
|
|
inp = email.message_from_file(sys.stdin)
|
|
homedir = os.path.dirname(__file__)
|
|
|
|
def input():
|
|
return inp
|
|
|
|
def setcwd(c):
|
|
homedir = c
|
|
|
|
@contextlib.contextmanager
|
|
def open(*args,**kwargs):
|
|
args = list(args)
|
|
fn = os.path.join(homedir,args.pop(0))
|
|
f = builtins.open(fn,*args,**kwargs)
|
|
try:
|
|
yield f
|
|
finally:
|
|
f.close()
|