[Python-checkins] python/dist/src/Tools/scripts texcheck.py,1.3,1.4
rhettinger@users.sourceforge.net
rhettinger@users.sourceforge.net
Mon, 12 May 2003 16:33:30 -0700
Update of /cvsroot/python/python/dist/src/Tools/scripts
In directory sc8-pr-cvs1:/tmp/cvs-serv1476
Modified Files:
texcheck.py
Log Message:
* Added separate checks for matching braces.
* Added more LaTex cmds from the docs.
* Blocked forward-slash warnings with delimiters-only option.
* Put help message on shorter line to fit an 80 char screen.
Index: texcheck.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Tools/scripts/texcheck.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** texcheck.py 10 May 2003 09:04:37 -0000 1.3
--- texcheck.py 12 May 2003 23:33:28 -0000 1.4
***************
*** 15,20 ****
Options:
! -m Munge parenthesis and brackets. [0,n) would normally mismatch.
! -k keyword: Keyword is a valid LaTeX command. Do not include the backslash.
-f: Forward-slash warnings suppressed.
-d: Delimiter check only (useful for non-LaTeX files).
--- 15,20 ----
Options:
! -m Munge parenthesis and brackets. [0,n) would normally mismatch.
! -k keyword: Keyword is a valid LaTeX command. Do not include the backslash.
-f: Forward-slash warnings suppressed.
-d: Delimiter check only (useful for non-LaTeX files).
***************
*** 53,56 ****
--- 53,61 ----
\indexname \appendix \protect \indexiv \mbox \textasciitilde
\platform \seeurl \leftmargin \labelwidth \localmoduletable
+ \LaTeX \copyright \memberline \backslash \pi \centerline
+ \caption \vspace \textwidth \menuselection \textless
+ \makevar \csimplemacro \menuselection \bfcode \sub \release
+ \email \kwindex \refexmodindex \filenq \e \menuselection
+ \exindex \linev \newsgroup \verbatim \setshortversion
"""
***************
*** 86,91 ****
validcmds.add('\\' + cmd)
- openers = [] # Stack of pending open delimiters
-
if '-m' in opts:
pairmap = {']':'[(', ')':'(['} # Munged openers
--- 91,94 ----
***************
*** 95,98 ****
--- 98,105 ----
delimiters = re.compile(r'\\(begin|end){([_a-zA-Z]+)}|([()\[\]])')
+ braces = re.compile(r'({)|(})')
+
+ openers = [] # Stack of pending open delimiters
+ bracestack = [] # Stack of pending open braces
tablestart = re.compile(r'\\begin{(?:long)?table([iv]+)}')
***************
*** 108,112 ****
line = line.rstrip()
! if '-f' not in opts and '/' in line:
# Warn whenever forward slashes encountered
line = line.rstrip()
--- 115,119 ----
line = line.rstrip()
! if '/' in line and '-f' not in opts and '-d' not in opts:
# Warn whenever forward slashes encountered
line = line.rstrip()
***************
*** 124,128 ****
print r'Warning, unknown tex cmd on line %d: \%s' % (lineno, cmd)
! # Check balancing of open/close markers (parens, brackets, etc)
for begend, name, punct in delimiters.findall(line):
if '-v' in opts:
--- 131,135 ----
print r'Warning, unknown tex cmd on line %d: \%s' % (lineno, cmd)
! # Check balancing of open/close parenthesis and brackets
for begend, name, punct in delimiters.findall(line):
if '-v' in opts:
***************
*** 139,142 ****
--- 146,161 ----
print ' --> ', openers
+ # Balance opening and closing braces
+ for open, close in braces.findall(line):
+ if open == '{':
+ bracestack.append(lineno)
+ if close == '}':
+ try:
+ bracestack.pop()
+ except IndexError:
+ print r'Warning, unmatched } on line %s.' % (lineno,)
+ if '-v' in opts:
+ print ' --> ', bracestack
+
# Check table levels (make sure lineii only inside tableii)
m = tablestart.search(line)
***************
*** 153,156 ****
--- 172,177 ----
for lineno, symbol in openers:
print "Unmatched open delimiter '%s' on line %d" % (symbol, lineno)
+ for lineno in bracestack:
+ print "Unmatched { on line %d" % (lineno,)
print 'Done checking %d lines.' % (lastline,)
return 0