2026-03-12 20:51:59
This commit is contained in:
15
python/scr_cod_dec/code.py
Normal file
15
python/scr_cod_dec/code.py
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/home/oracle/p3/bin/python
|
||||
|
||||
import os
|
||||
|
||||
k_scriptdir = "/mnt/yavin4/tmp/_oracle_/gitlab2/oracle/star"
|
||||
scriptlist = sorted(os.listdir(k_scriptdir))
|
||||
for script in scriptlist:
|
||||
if script.endswith(".sql"):
|
||||
scriptlen = len(script)
|
||||
script_underline = "".join("~" for i in range(scriptlen +4))
|
||||
print(f"{script_underline}\n~ {script} ~\n{script_underline}")
|
||||
with open(k_scriptdir + "/" + script) as f:
|
||||
file_contents = f.read().splitlines()
|
||||
for script_line in file_contents:
|
||||
print(f"\t{script_line}")
|
||||
34
python/scr_cod_dec/decode.py
Normal file
34
python/scr_cod_dec/decode.py
Normal file
@@ -0,0 +1,34 @@
|
||||
#!/home/oracle/p3/bin/python
|
||||
|
||||
import re
|
||||
import fileinput
|
||||
|
||||
ifile = "1-3.txt"
|
||||
odir = "./unpack/"
|
||||
|
||||
fc_cnt = sum(1 for line in fileinput.input(ifile))
|
||||
with open(ifile) as f:
|
||||
fc = f.read().splitlines()
|
||||
|
||||
i = 0
|
||||
while i<fc_cnt-2:
|
||||
l1 = fc[i]
|
||||
l2 = fc[i+1]
|
||||
l3 = fc[i+2]
|
||||
if l1.startswith("~") and l1.endswith("~") and l2.startswith("~ ") and l2.endswith(".sql ~") and l3.startswith("~") and l3.endswith("~"):
|
||||
# Line 2 contains the script name
|
||||
sname = l2.replace("~","").replace(" ","")
|
||||
scontents = ""
|
||||
j = i + 4
|
||||
while j<fc_cnt:
|
||||
l = fc[j]
|
||||
if l.startswith("~") and l.endswith("~"):
|
||||
# End of script
|
||||
with open(f"{odir}/{sname}", "w") as f:
|
||||
f.write(scontents)
|
||||
break
|
||||
else:
|
||||
# Line is part of current script body
|
||||
j += 1
|
||||
scontents = scontents + l.lstrip("\t") + "\n"
|
||||
i += 2
|
||||
Reference in New Issue
Block a user