adding new logic to test script
This commit is contained in:
parent
c57cd0e0b5
commit
8f74fb006c
1 changed files with 28 additions and 16 deletions
|
@ -2,24 +2,36 @@
|
||||||
writers.writePython3Bin "test-script" { libraries = []; } ''
|
writers.writePython3Bin "test-script" { libraries = []; } ''
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
def my_function():
|
def main():
|
||||||
arg = sys.argv[1]
|
arg = sys.argv[1]
|
||||||
number = int(arg)
|
|
||||||
if (number == 1):
|
data = json.loads(arg)
|
||||||
os.makedirs('13')
|
paths = data.get('filesMeta')
|
||||||
if (number == 2):
|
path = data.get('path')
|
||||||
raise Exception("error")
|
for el in paths:
|
||||||
if (number == 3):
|
if (el.get('path') is None and el.get('type') == 'folder'):
|
||||||
print(200)
|
if (not os.path.exists((path + el.get('name')))):
|
||||||
print(200)
|
os.makedirs(path + el.get('name'))
|
||||||
print(200)
|
else:
|
||||||
print(200)
|
filePath = el.get('path')
|
||||||
print(200)
|
type = el.get('type')
|
||||||
print(200)
|
name = el.get('name')
|
||||||
|
rewrite = el.get('rewrite')
|
||||||
|
newPath = path + filePath + '/'
|
||||||
|
if (type == 'file'):
|
||||||
|
if (rewrite and not os.path.exists((newPath + name))):
|
||||||
|
file = open(newPath + name, 'w')
|
||||||
|
file.write(str(el))
|
||||||
|
file.close()
|
||||||
|
if (type == 'folder'):
|
||||||
|
if (rewrite and not os.path.exists((newPath + name))):
|
||||||
|
os.makedirs(newPath + name)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
main()
|
||||||
my_function()
|
''
|
||||||
''
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue