mirror of
https://github.com/becarpenter/book6.git
synced 2024-05-07 02:54:53 +00:00
Update utilities for command line use
All utilities now allow a directory name if invoked by a shell command
This commit is contained in:
File diff suppressed because it is too large
Load Diff
2
Citex.md
2
Citex.md
@ -1,7 +1,7 @@
|
||||
# book6 Citation Index
|
||||
<img src="./book6logo.png" alt="book6 logo" width="200px" height="auto"/>
|
||||
|
||||
Generated at 2024-04-25 10:21:50 UTC+1200
|
||||
Generated at 2024-04-28 16:17:28 UTC+1200
|
||||
|
||||
This index was created automatically, so it's dumb. It has links to each section that mentions each citation.
|
||||
<!-- Link lines generated automatically; do not delete -->
|
||||
|
2
Index.md
2
Index.md
@ -1,7 +1,7 @@
|
||||
# book6 Main Index
|
||||
<img src="./book6logo.png" alt="book6 logo" width="200px" height="auto"/>
|
||||
|
||||
Generated at 2024-04-25 10:21:50 UTC+1200
|
||||
Generated at 2024-04-28 16:17:28 UTC+1200
|
||||
|
||||
This index was created automatically, so it's dumb. It is not case-sensitive. It has links to each section that mentions each keyword.
|
||||
If you think any keywords are missing, please raise an issue (use link on GitHub toolbar).
|
||||
|
1154
pdf/baked.md
1154
pdf/baked.md
File diff suppressed because it is too large
Load Diff
BIN
pdf/baked.pdf
BIN
pdf/baked.pdf
Binary file not shown.
1181
pdf/baked.tex
1181
pdf/baked.tex
File diff suppressed because it is too large
Load Diff
@ -10,9 +10,11 @@
|
||||
# Version: 2023-08-01 - catch by WG acronym;
|
||||
# display counts
|
||||
# Version: 2023-08-10 - download & cache xml index
|
||||
# Version: 2024-04-28 - handle directory on command line;
|
||||
# catch DHCPv6
|
||||
|
||||
########################################################
|
||||
# Copyright (C) 2023 Brian E. Carpenter.
|
||||
# Copyright (C) 2023-24 Brian E. Carpenter.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with
|
||||
@ -57,8 +59,17 @@ from tkinter.messagebox import askokcancel, askyesno, showinfo
|
||||
|
||||
import time
|
||||
import os
|
||||
import sys
|
||||
import requests
|
||||
|
||||
def show(msg):
|
||||
"""Show a message"""
|
||||
global T, cmd_line
|
||||
if cmd_line:
|
||||
print(msg)
|
||||
else:
|
||||
showinfo(title=T, message = msg)
|
||||
|
||||
def logit(msg):
|
||||
"""Add a message to the log file"""
|
||||
global flog, printing
|
||||
@ -129,7 +140,8 @@ def interesting(block):
|
||||
return False
|
||||
elif "<obsoleted-by>" in block:
|
||||
return False
|
||||
elif "IPv6" in title(block) or "IP Version 6" in title(block) or (field("wg_acronym", block) in wgs):
|
||||
elif ("IPv6" in title(block) or "IP Version 6" in title(block) or "DHCPv6" in title(block)
|
||||
or (field("wg_acronym", block) in wgs)):
|
||||
#print(block)
|
||||
status = field("current-status", block)
|
||||
if "is-also" in block:
|
||||
@ -171,18 +183,29 @@ printing = False # True for extra diagnostic prints
|
||||
warnings = 0
|
||||
wgs = ["6man","v6ops"]
|
||||
|
||||
#Has the user supplied a directory on the command line?
|
||||
|
||||
cmd_line = False
|
||||
if len(sys.argv) > 1:
|
||||
#user provided directory name?
|
||||
if os.path.isdir(sys.argv[1]):
|
||||
#assume user has provided directory
|
||||
#and set all options to defaults
|
||||
os.chdir(sys.argv[1])
|
||||
cmd_line = True
|
||||
|
||||
#Announce
|
||||
if not cmd_line:
|
||||
Tk().withdraw() # we don't want a full GUI
|
||||
|
||||
Tk().withdraw() # we don't want a full GUI
|
||||
T = "IPv6 RFC bibliography maker."
|
||||
|
||||
T = "IPv6 RFC bibliography maker."
|
||||
printing = askyesno(title=T,
|
||||
message = "Diagnostic printing?")
|
||||
|
||||
printing = askyesno(title=T,
|
||||
message = "Diagnostic printing?")
|
||||
|
||||
where = askdirectory(title = "Select main book directory")
|
||||
os.chdir(askdirectory(title = "Select main book directory"))
|
||||
|
||||
os.chdir(where)
|
||||
|
||||
|
||||
#Open log file
|
||||
|
||||
@ -193,14 +216,13 @@ logit("RFCbib6 run at "+timestamp)
|
||||
logit("Running in directory "+ os.getcwd())
|
||||
|
||||
|
||||
showinfo(title=T,
|
||||
message = "Will read complete RFC index.\nTouch no files until done!")
|
||||
show("Will read complete RFC index.\nTouch no files until done!")
|
||||
|
||||
fp = "rfc-index.xml"
|
||||
if (not os.path.exists(fp)) or (time.time()-os.path.getmtime(fp) > 60*60*24*30):
|
||||
#need fresh copy of index
|
||||
try:
|
||||
if askyesno(title=T, message = "OK to download RFC index?\n(15 MB file)"):
|
||||
if cmd_line or askyesno(title=T, message = "OK to download RFC index?\n(15 MB file)"):
|
||||
response = requests.get("https://www.rfc-editor.org/rfc/rfc-index.xml")
|
||||
open(fp, "wb").write(response.content)
|
||||
logit("Downloaded and cached RFC index")
|
||||
@ -234,7 +256,7 @@ if len(stds)+len(bcps)+len(infos)+len(exps) != count:
|
||||
|
||||
md = ["## RFC bibliography","",
|
||||
"""This section is a machine-generated list of all current RFCs that
|
||||
mention IPv6 in their title or come from the major IPv6 working groups.
|
||||
mention IPv6 or DHCPv6 in their title or come from the major IPv6 working groups.
|
||||
Obsolete RFCs are not included. There are subsections for Standards, BCPs,
|
||||
Informational and Experimental RFCs. Be *cautious* about old Informational
|
||||
or Experimental RFCs - they may be misleading as well as out of date."""]
|
||||
@ -261,8 +283,7 @@ if warnings:
|
||||
else:
|
||||
warn = ""
|
||||
|
||||
showinfo(title=T,
|
||||
message = warn+"Check RFCbib6.log, then run makeBook.")
|
||||
show(warn+"Check RFCbib6.log, then run makeBook.")
|
||||
|
||||
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
# - added pagebreak hack
|
||||
# Version: 2024-04-08 - cosmetic fix
|
||||
# Version: 2024-04-11 - attempt PDF conversion
|
||||
# Version: 2024-04-28 - handle directory on command line
|
||||
|
||||
########################################################
|
||||
# Copyright (C) 2024 Brian E. Carpenter.
|
||||
@ -62,9 +63,18 @@ from tkinter.messagebox import askokcancel, askyesno, showinfo
|
||||
|
||||
import time
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
import shutil
|
||||
|
||||
def show(msg):
|
||||
"""Show a message"""
|
||||
global T, cmd_line
|
||||
if cmd_line:
|
||||
print(msg)
|
||||
else:
|
||||
showinfo(title=T, message = msg)
|
||||
|
||||
def logit(msg):
|
||||
"""Add a message to the log file"""
|
||||
global flog, printing
|
||||
@ -224,19 +234,26 @@ page_break = '\nbackslashpagebreak\n'
|
||||
printing = False # True for extra diagnostic prints
|
||||
warnings = 0
|
||||
|
||||
cmd_line = False
|
||||
if len(sys.argv) > 1:
|
||||
#user provided directory name?
|
||||
if os.path.isdir(sys.argv[1]):
|
||||
#assume user has provided directory
|
||||
#and set all options to defaults
|
||||
os.chdir(sys.argv[1])
|
||||
cmd_line = True
|
||||
|
||||
#Announce
|
||||
if not cmd_line:
|
||||
Tk().withdraw() # we don't want a full GUI
|
||||
|
||||
Tk().withdraw() # we don't want a full GUI
|
||||
T = "Book baker."
|
||||
|
||||
T = "Book baker."
|
||||
printing = askyesno(title=T,
|
||||
message = "Diagnostic printing?")
|
||||
|
||||
printing = askyesno(title=T,
|
||||
message = "Diagnostic printing?")
|
||||
|
||||
where = askdirectory(title = "Select main book directory")
|
||||
os.chdir(askdirectory(title = "Select main book directory"))
|
||||
|
||||
os.chdir(where)
|
||||
|
||||
#Open log file
|
||||
|
||||
flog = open("bakeBook.log", "w",encoding='utf-8')
|
||||
@ -246,8 +263,7 @@ logit("bakeBook run at "+timestamp)
|
||||
logit("Running in directory "+ os.getcwd())
|
||||
|
||||
|
||||
showinfo(title=T,
|
||||
message = "Will read current book6 text.\nTouch no files until done!")
|
||||
show("Will read current book6 text.\nTouch no files until done!")
|
||||
|
||||
|
||||
######### Create empty output
|
||||
@ -347,8 +363,7 @@ if warnings:
|
||||
else:
|
||||
warn = ""
|
||||
|
||||
showinfo(title=T,
|
||||
message = warn+"Check bakeBook.log.")
|
||||
show(warn+"Check bakeBook.log.")
|
||||
|
||||
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
# Version: 2023-01-10 - added warnings of invalid internal citations
|
||||
# Version: 2023-05-20 - exclude RFC bibliography from indexing
|
||||
# Version: 2023-11-01 - enhance index boilerplate
|
||||
# Version: 2024-04-28 - handle directory on command line
|
||||
|
||||
|
||||
########################################################
|
||||
@ -61,6 +62,15 @@ from tkinter.messagebox import askokcancel, askyesno, showinfo
|
||||
|
||||
import time
|
||||
import os
|
||||
import sys
|
||||
|
||||
def show(msg):
|
||||
"""Show a message"""
|
||||
global T, cmd_line
|
||||
if cmd_line:
|
||||
print(msg)
|
||||
else:
|
||||
showinfo(title=T, message = msg)
|
||||
|
||||
def logit(msg):
|
||||
"""Add a message to the log file"""
|
||||
@ -203,18 +213,28 @@ blob = '●'
|
||||
printing = False # True for extra diagnostic prints
|
||||
warnings = 0
|
||||
|
||||
#Has the user supplied a directory on the command line?
|
||||
|
||||
cmd_line = False
|
||||
if len(sys.argv) > 1:
|
||||
#user provided directory name?
|
||||
if os.path.isdir(sys.argv[1]):
|
||||
#assume user has provided directory
|
||||
#and set all options to defaults
|
||||
os.chdir(sys.argv[1])
|
||||
cmd_line = True
|
||||
|
||||
#Announce
|
||||
if not cmd_line:
|
||||
Tk().withdraw() # we don't want a full GUI
|
||||
|
||||
Tk().withdraw() # we don't want a full GUI
|
||||
T = "Book index maker."
|
||||
|
||||
T = "Book index maker."
|
||||
printing = askyesno(title=T,
|
||||
message = "Diagnostic printing?")
|
||||
|
||||
printing = askyesno(title=T,
|
||||
message = "Diagnostic printing?")
|
||||
os.chdir(askdirectory(title = "Select main book directory"))
|
||||
|
||||
where = askdirectory(title = "Select main book directory")
|
||||
|
||||
os.chdir(where)
|
||||
|
||||
#Open log file
|
||||
|
||||
@ -225,8 +245,7 @@ logit("indexBook run at "+timestamp)
|
||||
logit("Running in directory "+ os.getcwd())
|
||||
|
||||
|
||||
showinfo(title=T,
|
||||
message = "Will read indexing terms and current book6 text.\nTouch no files until done!")
|
||||
show("Will read indexing terms and current book6 text.\nTouch no files until done!")
|
||||
|
||||
|
||||
|
||||
@ -326,6 +345,5 @@ if warnings:
|
||||
else:
|
||||
warn = ""
|
||||
|
||||
showinfo(title=T,
|
||||
message = warn+"Check indexBook.log.")
|
||||
show(warn+"Check indexBook.log.")
|
||||
|
||||
|
@ -29,6 +29,7 @@ and inter-chapter links as far as possible."""
|
||||
# Version: 2023-08-10 - changed to use RFC index for existence checking
|
||||
# Version: 2024-01-01 - changed default text for empty sections
|
||||
# Version: 2024-04-12 - improved optics of RFC citations
|
||||
# Version: 2024-04-28 - handle directory on command line
|
||||
|
||||
########################################################
|
||||
# Copyright (C) 2022-2024 Brian E. Carpenter.
|
||||
@ -75,6 +76,7 @@ from tkinter.filedialog import askdirectory
|
||||
from tkinter.messagebox import askokcancel, askyesno, showinfo
|
||||
|
||||
import time
|
||||
import sys
|
||||
import os
|
||||
import urllib.request
|
||||
import ssl
|
||||
@ -86,7 +88,15 @@ try:
|
||||
formatter = True
|
||||
except:
|
||||
formatter = False
|
||||
|
||||
|
||||
def show(msg):
|
||||
"""Show a message"""
|
||||
global T, cmd_line
|
||||
if cmd_line:
|
||||
print(msg)
|
||||
else:
|
||||
showinfo(title=T, message = msg)
|
||||
|
||||
def logit(msg):
|
||||
"""Add a message to the log file"""
|
||||
global flog, printing
|
||||
@ -364,19 +374,29 @@ headers['User-Agent'] = _s
|
||||
#print("CA file", certifi.where())
|
||||
context = ssl.create_default_context(cafile=certifi.where())
|
||||
|
||||
|
||||
#Has the user supplied a directory on the command line?
|
||||
|
||||
cmd_line = False
|
||||
if len(sys.argv) > 1:
|
||||
#user provided directory name?
|
||||
if os.path.isdir(sys.argv[1]):
|
||||
#assume user has provided directory
|
||||
#and set all options to defaults
|
||||
os.chdir(sys.argv[1])
|
||||
cmd_line = True
|
||||
|
||||
#Announce
|
||||
if not cmd_line:
|
||||
Tk().withdraw() # we don't want a full GUI
|
||||
|
||||
Tk().withdraw() # we don't want a full GUI
|
||||
T = "Book reconciler and link maker."
|
||||
|
||||
T = "Book reconciler and link maker."
|
||||
printing = askyesno(title=T,
|
||||
message = "Diagnostic printing?")
|
||||
|
||||
printing = askyesno(title=T,
|
||||
message = "Diagnostic printing?")
|
||||
|
||||
where = askdirectory(title = "Select main book directory")
|
||||
os.chdir(askdirectory(title = "Select main book directory"))
|
||||
|
||||
os.chdir(where)
|
||||
|
||||
#Open log file
|
||||
|
||||
flog = open("makeBook.log", "w",encoding='utf-8')
|
||||
@ -388,15 +408,16 @@ logit("Running in directory "+ os.getcwd())
|
||||
if not formatter:
|
||||
logitw("No markdown formatting (mdformat not imported)")
|
||||
else:
|
||||
formatting = askyesno(title=T,
|
||||
message = "Rarely needed option!\nRun md formatter on all files?",
|
||||
default='no')
|
||||
if cmd_line:
|
||||
formatting = False
|
||||
else:
|
||||
formatting = askyesno(title=T,
|
||||
message = "Rarely needed option!\nRun md formatter on all files?",
|
||||
default='no')
|
||||
if formatting:
|
||||
logit("User requested mdformat on all files.")
|
||||
|
||||
|
||||
showinfo(title=T,
|
||||
message = "Will read in current contents and RFC index.\nTouch no files until done!")
|
||||
show("Will read in current contents and RFC index.\nTouch no files until done!")
|
||||
|
||||
#Can we check RFCs?
|
||||
fp = "rfc-index.xml"
|
||||
@ -404,7 +425,7 @@ rfcs_checkable = True
|
||||
if (not os.path.exists(fp)) or (time.time()-os.path.getmtime(fp) > 60*60*24*30):
|
||||
#need fresh copy of index
|
||||
try:
|
||||
if askyesno(title=T, message = "OK to download RFC index?\n(15 MB file)"):
|
||||
if cmd_line or askyesno(title=T, message = "OK to download RFC index?\n(15 MB file)"):
|
||||
response = requests.get("https://www.rfc-editor.org/rfc/rfc-index.xml")
|
||||
open(fp, "wb").write(response.content)
|
||||
logit("Downloaded and cached RFC index")
|
||||
@ -688,6 +709,5 @@ if written:
|
||||
else:
|
||||
wrote = "Clean run.\n"
|
||||
|
||||
showinfo(title=T,
|
||||
message = wrote+warn+"Check makeBook.log.")
|
||||
show(wrote+warn+"Check makeBook.log.")
|
||||
|
||||
|
Reference in New Issue
Block a user