style.py (4781:59a75bd0ddf4) style.py (4782:50a634ae064a)
1#! /usr/bin/env python
2# Copyright (c) 2007 The Regents of The University of Michigan
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are
7# met: redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer;

--- 71 unchanged lines hidden (view full) ---

80
81 match = trail.search(line)
82 if match:
83 return False
84
85 return True
86
87def checkwhite(filename):
1#! /usr/bin/env python
2# Copyright (c) 2007 The Regents of The University of Michigan
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are
7# met: redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer;

--- 71 unchanged lines hidden (view full) ---

80
81 match = trail.search(line)
82 if match:
83 return False
84
85 return True
86
87def checkwhite(filename):
88 if not whitespace_file(filename)
88 if not whitespace_file(filename):
89 return
90
91 try:
92 f = file(filename, 'r+')
93 except OSError, msg:
94 print 'could not open file %s: %s' % (filename, msg)
95 return
96

--- 13 unchanged lines hidden (view full) ---

110 newline += line[i:]
111 break
112
113 line = newline
114
115 return line.rstrip() + '\n'
116
117def fixwhite(filename, tabsize, fixonly=None):
89 return
90
91 try:
92 f = file(filename, 'r+')
93 except OSError, msg:
94 print 'could not open file %s: %s' % (filename, msg)
95 return
96

--- 13 unchanged lines hidden (view full) ---

110 newline += line[i:]
111 break
112
113 line = newline
114
115 return line.rstrip() + '\n'
116
117def fixwhite(filename, tabsize, fixonly=None):
118 if not whitespace_file(filename)
118 if not whitespace_file(filename):
119 return
120
121 try:
122 f = file(filename, 'r+')
123 except OSError, msg:
124 print 'could not open file %s: %s' % (filename, msg)
125 return
126

--- 258 unchanged lines hidden (view full) ---

385 if opt == '-v':
386 verbose += 1
387
388 if command == 'fixwhite':
389 for filename in args:
390 fixwhite(filename, tabsize)
391 elif command == 'chkwhite':
392 for filename in args:
119 return
120
121 try:
122 f = file(filename, 'r+')
123 except OSError, msg:
124 print 'could not open file %s: %s' % (filename, msg)
125 return
126

--- 258 unchanged lines hidden (view full) ---

385 if opt == '-v':
386 verbose += 1
387
388 if command == 'fixwhite':
389 for filename in args:
390 fixwhite(filename, tabsize)
391 elif command == 'chkwhite':
392 for filename in args:
393 line = checkwhite(filename)
394 if line:
395 print 'invalid whitespace at %s:%d' % (filename, line)
393 for line,num in checkwhite(filename):
394 print 'invalid whitespace: %s:%d' % (filename, num)
395 if verbose:
396 print '>>%s<<' % line[:-1]
396 elif command == 'chkformat':
397 stats = ValidationStats()
398 for filename in files:
399 validate(filename, stats=stats, verbose=verbose, exit_code=code)
400
401 if verbose > 0:
402 stats.dump()
403 else:
404 sys.exit("command '%s' not found" % command)
397 elif command == 'chkformat':
398 stats = ValidationStats()
399 for filename in files:
400 validate(filename, stats=stats, verbose=verbose, exit_code=code)
401
402 if verbose > 0:
403 stats.dump()
404 else:
405 sys.exit("command '%s' not found" % command)