Skip to content

Instantly share code, notes, and snippets.

@jctanner
Created June 11, 2020 15:25
Show Gist options
  • Save jctanner/96f8035d69f3ecad4d2d43e65ea51206 to your computer and use it in GitHub Desktop.
Save jctanner/96f8035d69f3ecad4d2d43e65ea51206 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import glob
import os
import re
def make_sentence_case(instring):
newstring = instring[0].upper() + instring[1:].lower()
return newstring.strip()
def main():
# fdata = open('{}', 'r').read(); print(re.search(r'\(\'[A-Z].*\'\)', fdata).group()
regexes = [
[r'\(\'[A-Z].*\'\)', ["'"]],
[r'\>[A-Z].*\<', [">", "<"]]
]
for root, dirs, files in os.walk('src'):
for filen in files:
if filen.endswith('test.js'):
continue
fullpath = os.path.join(root, filen)
with open(fullpath, 'r') as f:
for linenum,line in enumerate(f.readlines()):
for regex in regexes:
if not line.strip():
continue
res = re.search(regex[0], line)
if not res:
continue
'''
try:
res.groups()
print(res.groups())
if len(res.groups()) > 0:
import epdb; epdb.st()
except Exception as e:
pass
'''
val = res.group()
val = val.strip()
for ids,splitter in enumerate(regex[1]):
if ids == 0:
val = val.split(splitter)[1]
else:
val = val.split(splitter)[0]
#print(val)
val = val.strip()
if not val:
continue
if not ' ' in val:
continue
sval = make_sentence_case(val)
if val != sval:
print('')
print('# ' + fullpath)
print(str(linenum) + ": " + res.group())
print(val)
#import epdb; epdb.st()
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment