diff options
| author | Steven Myint <git@stevenmyint.com> | 2013-10-04 10:05:11 -0700 |
|---|---|---|
| committer | Steven Myint <git@stevenmyint.com> | 2013-10-04 10:05:11 -0700 |
| commit | c70fe1175d1a45112699953ab120b532e615f2c5 (patch) | |
| tree | 374ebae29e8c35049af09de3100ca99e20580895 /examples | |
| parent | 1cb3226c9d2e57b8ec280433c2ad7c990d63bae0 (diff) | |
| download | pexpect-c70fe1175d1a45112699953ab120b532e615f2c5.tar.gz | |
Fix indentation
Diffstat (limited to 'examples')
| -rwxr-xr-x | examples/fix_cvs_files.py | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/examples/fix_cvs_files.py b/examples/fix_cvs_files.py index 6812335..7884b29 100755 --- a/examples/fix_cvs_files.py +++ b/examples/fix_cvs_files.py @@ -45,13 +45,13 @@ def is_binary (filename): '''Assume that any file with a character where the 8th bit is set is binary. ''' - fin = open(filename, 'rb') - wholething = fin.read() - fin.close() - for c in wholething: - if ord(c) & 0x80: - return 1 - return 0 + fin = open(filename, 'rb') + wholething = fin.read() + fin.close() + for c in wholething: + if ord(c) & 0x80: + return 1 + return 0 def is_kb_sticky (filename): @@ -59,46 +59,46 @@ def is_kb_sticky (filename): Sticky Option status is '-ks' then this returns 1. If the status is 'Unknown' then it returns 1. Otherwise 0 is returned. ''' - try: - s = pexpect.spawn ('cvs status %s' % filename) - i = s.expect (['Sticky Options:\s*(.*)\r\n', 'Status: Unknown']) - if i==1 and VERBOSE: - print 'File not part of CVS repository:', filename - return 1 # Pretend it's OK. - if s.match.group(1) == '-kb': - return 1 - s = None - except: - print 'Something went wrong trying to run external cvs command.' - print ' cvs status %s' % filename - print 'The cvs command returned:' - print s.before - return 0 + try: + s = pexpect.spawn ('cvs status %s' % filename) + i = s.expect (['Sticky Options:\s*(.*)\r\n', 'Status: Unknown']) + if i==1 and VERBOSE: + print 'File not part of CVS repository:', filename + return 1 # Pretend it's OK. + if s.match.group(1) == '-kb': + return 1 + s = None + except: + print 'Something went wrong trying to run external cvs command.' + print ' cvs status %s' % filename + print 'The cvs command returned:' + print s.before + return 0 def cvs_admin_kb (filename): '''This uses 'cvs admin' to set the '-kb' sticky option. ''' - s = pexpect.run ('cvs admin -kb %s' % filename) - # There is a timing issue. If I run 'cvs admin' too quickly - # cvs sometimes has trouble obtaining the directory lock. - time.sleep(1) + s = pexpect.run ('cvs admin -kb %s' % filename) + # There is a timing issue. If I run 'cvs admin' too quickly + # cvs sometimes has trouble obtaining the directory lock. + time.sleep(1) def walk_and_clean_cvs_binaries (arg, dirname, names): '''This contains the logic for processing files. This is the os.path.walk callback. This skips dirnames that end in CVS. ''' - if len(dirname)>3 and dirname[-3:]=='CVS': - return - for n in names: - fullpath = os.path.join (dirname, n) - if os.path.isdir(fullpath) or os.path.islink(fullpath): - continue - if is_binary(fullpath): - if not is_kb_sticky (fullpath): - if VERBOSE: print fullpath - cvs_admin_kb (fullpath) + if len(dirname)>3 and dirname[-3:]=='CVS': + return + for n in names: + fullpath = os.path.join (dirname, n) + if os.path.isdir(fullpath) or os.path.islink(fullpath): + continue + if is_binary(fullpath): + if not is_kb_sticky (fullpath): + if VERBOSE: print fullpath + cvs_admin_kb (fullpath) def main (): |
