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)
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)
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)
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)
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)
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)
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)
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)