10
0
mirror of https://github.com/LCPQ/QUESTDB_website.git synced 2025-01-12 05:58:23 +01:00

Replace metarecover bash script by a more flexible python version in order to use python for each tools

This commit is contained in:
Mickaël Véril 2020-11-10 17:40:14 +01:00
parent f7c410a5f4
commit e772846992
2 changed files with 25 additions and 10 deletions

25
tools/metarecover.py Normal file
View File

@ -0,0 +1,25 @@
from git import Repo,Git
import io
r=Repo(path=".")
l=[item for item in r.index.diff(None) if item.a_path.endswith(".dat") and item.change_type=="M"]
len(l)
for i in l:
print(i.a_path)
g=Git(Repo.git_dir)
with io.StringIO(g.execute(["git" ,"--no-pager", "show", f"HEAD~1:{i.a_path}"])) as old:
with open(i.a_path,mode="r+") as new:
with io.StringIO(new.read()) as copy:
new.seek(0)
line=old.readline()
while line and line.startswith("#"):
new.write(line)
line=old.readline()
line=copy.readline()
end=False
while line:
if not end and not line.startswith("#"):
end=True
if end:
new.write(line)
line=copy.readline()
new.truncate()

View File

@ -1,10 +0,0 @@
#!/bin/bash
files=$(git status -s | grep " M " | cut -c4- | grep 'static/data/')
for file in $files; do
show="$(git --no-pager show HEAD~1:$file)"
IFS=$'\n' lines=($show)
for (( i=0; i<=5; i++ )) ;do
line=${lines[i]}
sed -i "$((i+1))s|^.*$|$line|" $file
done
done