From aa8fa31195d7ad7886b522b3ccbf258de38219db Mon Sep 17 00:00:00 2001 From: Samuel Sloniker Date: Fri, 25 Nov 2022 09:24:55 -0800 Subject: [PATCH] Rewrite export script in Python; use build dir --- .gitignore | 1 + export.py | 20 ++++++++++++++++++++ export.sh | 8 -------- 3 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 export.py delete mode 100755 export.sh diff --git a/.gitignore b/.gitignore index 828eeef..e8eefe4 100644 --- a/.gitignore +++ b/.gitignore @@ -141,3 +141,4 @@ cython_debug/ *.db *.db-journal *.gptc +build/ diff --git a/export.py b/export.py new file mode 100644 index 0000000..13d823d --- /dev/null +++ b/export.py @@ -0,0 +1,20 @@ +import os +import shutil +import sqlite3 + +try: + shutil.rmtree("build") +except FileNotFoundError: + pass +os.mkdir("build") + +shutil.copy("articles.db", "build/articles.db") +shutil.copy("sources.toml", "build/sources.toml") +shutil.copy("model.gptc", "build/model.gptc") + +con = sqlite3.Connection("build/articles.db") +con.execute("UPDATE articles SET text = '***';") +con.commit() +con.execute("VACUUM;") +con.commit() +con.close() diff --git a/export.sh b/export.sh deleted file mode 100755 index 1d41ccb..0000000 --- a/export.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -cp articles.db old_articles.db -sqlite3 articles.db 'UPDATE articles SET text = "***";' -sqlite3 articles.db 'VACUUM;' -echo -n "Press enter when done..." -read -rm articles.db -mv old_articles.db articles.db