mirror of
https://git.ari.lt/ari.lt/blog.ari.lt.git
synced 2025-02-04 09:39:25 +01:00
update @ Wed 17 Aug 01:51:03 EEST 2022
Signed-off-by: Ari Archer <ari.web.xyz@gmail.com>
This commit is contained in:
parent
27c4d86aa6
commit
8454f452ce
1 changed files with 22 additions and 19 deletions
17
scripts/blog
17
scripts/blog
|
@ -5,10 +5,8 @@
|
|||
import json
|
||||
import os
|
||||
import random
|
||||
import readline
|
||||
import string
|
||||
import sys
|
||||
from atexit import register as fn_register
|
||||
from base64 import b64decode, b64encode
|
||||
from datetime import datetime
|
||||
from glob import iglob
|
||||
|
@ -25,6 +23,12 @@ from markdown import markdown # type: ignore
|
|||
from plumbum.commands.processes import ProcessExecutionError # type: ignore
|
||||
from pyfzf import FzfPrompt # type: ignore
|
||||
|
||||
NOT_CI_BUILD: bool = not os.getenv("CI")
|
||||
|
||||
if NOT_CI_BUILD:
|
||||
import readline
|
||||
from atexit import register as fn_register
|
||||
|
||||
EXIT_OK: int = 0
|
||||
EXIT_ERR: int = 1
|
||||
|
||||
|
@ -695,6 +699,7 @@ def usage(code: int = EXIT_ERR, config: Dict = None) -> int:
|
|||
def main() -> int:
|
||||
"""Entry/main function"""
|
||||
|
||||
if NOT_CI_BUILD:
|
||||
if not os.path.isfile(HISTORY_FILE):
|
||||
open(HISTORY_FILE, "w").close()
|
||||
|
||||
|
@ -710,6 +715,7 @@ def main() -> int:
|
|||
|
||||
if not os.path.isfile(DEFAULT_CONFIG_FILE):
|
||||
new_config()
|
||||
log(f"PLease configure {DEFAULT_CONFIG_FILE!r}")
|
||||
return EXIT_ERR
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
|
@ -729,9 +735,7 @@ def main() -> int:
|
|||
"TIME",
|
||||
)
|
||||
|
||||
not_ci_build = not os.getenv("CI")
|
||||
|
||||
if config["blogs"] and not_ci_build:
|
||||
if config["blogs"] and NOT_CI_BUILD:
|
||||
log("Sorting blogs by creation time...", "CLEANUP")
|
||||
|
||||
sort_timer = code_timer()
|
||||
|
@ -745,13 +749,12 @@ def main() -> int:
|
|||
|
||||
log(f"Sorted in {code_timer() - sort_timer} seconds", "TIME")
|
||||
|
||||
if not_ci_build:
|
||||
log("Redumping config", "CONFIG")
|
||||
|
||||
dump_timer = code_timer()
|
||||
|
||||
with open(DEFAULT_CONFIG_FILE, "w") as dcfg:
|
||||
json.dump(config, dcfg, indent=4)
|
||||
json.dump(config, dcfg, indent=(4 if NOT_CI_BUILD else 0))
|
||||
|
||||
log(f"Dumped config in {code_timer() - dump_timer} seconds", "TIME")
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue