Skip to content
Snippets Groups Projects
Commit b2c7e45f authored by Lubomir Prda's avatar Lubomir Prda
Browse files

capitalize now checks abbrevations from .spelling

parent 72ebc18f
No related branches found
No related tags found
5 merge requests!368Update prace.md to document the change from qprace to qprod as the default...,!367Update prace.md to document the change from qprace to qprod as the default...,!366Update prace.md to document the change from qprace to qprod as the default...,!323extended-acls-storage-section,!65Capitalize
Pipeline #
...@@ -10,6 +10,14 @@ except ImportError: ...@@ -10,6 +10,14 @@ except ImportError:
print("Please install titlecase") print("Please install titlecase")
def main(location): def main(location):
# Spelling exceptions
with open('.spelling') as f:
spelling = f.readlines()
def abbreviations(word, **kwargs):
if word+"\n" in spelling:
return word
# Open the file and read the lines as a list # Open the file and read the lines as a list
with open(location) as f: with open(location) as f:
lines = f.readlines() lines = f.readlines()
...@@ -26,9 +34,9 @@ def main(location): ...@@ -26,9 +34,9 @@ def main(location):
if line.startswith("``") and disabled == 1: if line.startswith("``") and disabled == 1:
disabled = 0 disabled = 0
if line.startswith('#') and disabled == 0: if line.startswith('#') and disabled == 0:
line = titlecase(line[:(line.find("]"))])+line[(line.find("]")):] line = titlecase(line[:(line.find("]"))], callback=abbreviations)+line[(line.find("]")):]
if line.startswith('---') or line.startswith('==='): if line.startswith('---') or line.startswith('==='):
prev_line = titlecase(prev_line[:(prev_line.find("]"))])+prev_line[(prev_line.find("]")):] prev_line = titlecase(prev_line[:(prev_line.find("]"))], callback=abbreviations)+prev_line[(prev_line.find("]")):]
f.write(prev_line) f.write(prev_line)
prev_line = line prev_line = line
f.write(prev_line) f.write(prev_line)
......
...@@ -11,6 +11,14 @@ except ImportError: ...@@ -11,6 +11,14 @@ except ImportError:
print("Please install titlecase") print("Please install titlecase")
def main(location): def main(location):
# Spelling exceptions
with open('.spelling') as f:
spelling = f.readlines()
def abbreviations(word, **kwargs):
if word+"\n" in spelling:
return word
# Open the file and read the lines as a list # Open the file and read the lines as a list
with open(location) as f: with open(location) as f:
lines = f.readlines() lines = f.readlines()
...@@ -28,16 +36,16 @@ def main(location): ...@@ -28,16 +36,16 @@ def main(location):
if line.startswith("``") and disabled == 1: if line.startswith("``") and disabled == 1:
disabled = 0 disabled = 0
if line.startswith('#') and disabled == 0: if line.startswith('#') and disabled == 0:
if line != titlecase(line): if line != titlecase(line[:(line.find("]"))], callback=abbreviations)+line[(line.find("]")):]:
print() print()
print("-"+line,end="") print("-"+line,end="")
print("+"+titlecase(line[:(line.find("]"))])+line[(line.find("]")):],end="") print("+"+titlecase(line[:(line.find("]"))], callback=abbreviations)+line[(line.find("]")):],end="")
return_value = 1 return_value = 1
if line.startswith('---') or line.startswith('==='): if line.startswith('---') or line.startswith('==='):
if prev_line != titlecase(prev_line): if prev_line != titlecase(prev_line[:(prev_line.find("]"))], callback=abbreviations)+prev_line[(prev_line.find("]")):]:
print() print()
print("-"+prev_line,end="") print("-"+prev_line,end="")
print("+"+titlecase(prev_line[:(prev_line.find("]"))])+prev_line[(prev_line.find("]")):],end="") print("+"+titlecase(prev_line[:(prev_line.find("]"))], callback=abbreviations)+prev_line[(prev_line.find("]")):],end="")
return_value = 1 return_value = 1
prev_line = line prev_line = line
if return_value == 0: if return_value == 0:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment