2-adm-website #4
1 changed files with 13 additions and 3 deletions
|
|
@ -67,11 +67,21 @@ for file in os.listdir(absWikiPath):
|
|||
absFilePath = os.path.join(absWikiPath, file)
|
||||
# Check if the file already contains the header
|
||||
with open(absFilePath) as f:
|
||||
first_line = f.readline()
|
||||
content = f.read()
|
||||
all_lines = content.splitlines()
|
||||
first_line = all_lines[0]
|
||||
if first_line.find("---") != -1:
|
||||
print(file, "already have header")
|
||||
print(file, "already has been formatted. Skipping...")
|
||||
continue
|
||||
|
||||
for i, line in enumerate(all_lines):
|
||||
if line.startswith("#"):
|
||||
all_lines[i] = "#" + line
|
||||
|
||||
endpath = os.path.join(absWikiPath, file)
|
||||
with open(endpath, 'w') as f:
|
||||
f.write("\n".join(all_lines))
|
||||
|
||||
header = get_header_from_file(absFilePath)
|
||||
line_prepender(os.path.join(absWikiPath, file), header)
|
||||
line_prepender(endpath, header)
|
||||
print('Added header to', file)
|
||||
|
|
|
|||
Loading…
Reference in a new issue