-
Notifications
You must be signed in to change notification settings - Fork 680
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
glossary: Add more abbreviations (#19213)
- Loading branch information
Showing
10 changed files
with
195 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/python3 | ||
import sys | ||
from difflib import unified_diff | ||
|
||
print("Checking alphabetic sorting of glossary.md") | ||
|
||
with open("glossary.md") as fh: | ||
# Extract the lines that start with ### into itemsA (unsorted) | ||
itemsA = "" | ||
for line in fh.readlines(): | ||
if line.startswith("###"): | ||
itemsA += line | ||
fh.seek(0) | ||
|
||
# Extract the lines that start with ### into itemsB (sorted) | ||
itemsB = "" | ||
for line in sorted(fh.readlines(), key=str.casefold): | ||
if line.startswith("###"): | ||
itemsB += line | ||
|
||
if itemsA == itemsB: | ||
print("result: OK") | ||
sys.exit(0) | ||
|
||
print("result: differences found, see diff for details") | ||
# diff itemsA and itemsB | ||
diff = unified_diff( | ||
itemsA.splitlines(keepends=True), | ||
itemsB.splitlines(keepends=True), | ||
fromfile="before", | ||
tofile="after", | ||
) | ||
sys.stdout.writelines(diff) | ||
sys.exit(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters