-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathremove_internal.py
More file actions
32 lines (25 loc) · 911 Bytes
/
remove_internal.py
File metadata and controls
32 lines (25 loc) · 911 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python2
import os
import sys
import shutil
import re
# Note the use of the non-greedy '.*?' pattern - this allows for multiple blocks on same page.
pattern = re.compile( r'''[<][!]---*\s*BEGIN_INTERNAL\s*-*--[>].*?[<][!]---*\s*END_INTERNAL\s*-*--[>]''',re.DOTALL)
def strip_internal( filename ):
f = open(filename,'r')
contents = f.read()
f.close()
if pattern.search(contents) is None:
return #Don't touch file if we don't have to.
contents = pattern.sub('',contents)
f = open(filename,'w')
f.write(contents)
f.close()
if __name__ == "__main__":
# should we include ./pilot in public releases?
# if os.path.exists( "./pilot" ):
# shutil.rmtree( "./pilot" )
for path, subdirs, files in os.walk('.'):
for filename in files:
if filename.endswith(".md"):
strip_internal(os.path.join(path,filename))