-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakemyPYJ.py
55 lines (44 loc) · 1.3 KB
/
makemyPYJ.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import sys
from plumbum import local
cp = local['cp']
rm = local['rm']
ls = local['ls']
pwd = local['pwd']
import os
dir_path = os.path.dirname(os.path.realpath(__file__))
def makeMyPYJ():
"""
When RapydScript is asked to import x,
it looks for x.pyj. Therefore,
to facilitate RapydScript compiles, we
* remove pyj and py-cached
* copy the calling x.py to x.pyj
"""
myName = sys.argv[0] #the calling py
PYJname = myName.replace('.py', '.pyj')
#remove all the ".pyj-cached'files
fileNames=ls().split()
for fileName in fileNames:
if fileName.endswith('.pyj-cached'):
rm(fileName)
cp(myName, PYJname)
print(f'(makemyPYJ copied {myName} to {PYJname} and removed *.pyj-cached)\n')
def makeDummyPYJ(baseName, funcNames=[]):
f=open(f'{dir_path}/{baseName}.pyj','w')
for funcName in funcNames:
f.write(f"""
def {funcName}(*args, **kwargs):
pass
""")
print(f"makemyPYJ.py executed makeDummPYJ('{baseName}', '{funcName}')")
myDir = pwd().strip()
print('pwd', pwd())
print('__file__', __file__)
import os
dir_path = os.path.dirname(os.path.realpath(__file__))
print('dir_path', dir_path)
if __name__== '__main__':
makeDummyPYJ('makeMyPYJ', funcNames = ['makeDummyPYJ', 'makeMyPYJ'])
else:
import sys
makeMyPYJ()