diff options
author | Brett Cannon <bcannon@gmail.com> | 2006-03-01 20:53:08 (GMT) |
---|---|---|
committer | Brett Cannon <bcannon@gmail.com> | 2006-03-01 20:53:08 (GMT) |
commit | 20e192b6a636f0f7a9d7cf85c6b30e64dc6c7bc6 (patch) | |
tree | ae01afc8bb6bed6a64fe6b59ebe3d6f89f95b885 /Misc/Vim/vim_syntax.py | |
parent | a9f068726fb4cf3693bd70b4b98bd0deaba45443 (diff) | |
download | cpython-20e192b6a636f0f7a9d7cf85c6b30e64dc6c7bc6.zip cpython-20e192b6a636f0f7a9d7cf85c6b30e64dc6c7bc6.tar.gz cpython-20e192b6a636f0f7a9d7cf85c6b30e64dc6c7bc6.tar.bz2 |
Update for 'with' statement.
Diffstat (limited to 'Misc/Vim/vim_syntax.py')
-rw-r--r-- | Misc/Vim/vim_syntax.py | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/Misc/Vim/vim_syntax.py b/Misc/Vim/vim_syntax.py index 8ef5bb8..3f2a3d8 100644 --- a/Misc/Vim/vim_syntax.py +++ b/Misc/Vim/vim_syntax.py @@ -1,3 +1,5 @@ +from __future__ import with_statement + import keyword import exceptions import __builtin__ @@ -143,11 +145,9 @@ def fill_stmt(iterable, fill_len): except StopIteration: if buffer_: break - if not buffer_ and overflow: - yield buffer_ - return - else: - return + if overflow: + yield overflow + return if total_len > fill_len: overflow = buffer_.pop() total_len -= len(overflow) - 1 @@ -158,8 +158,7 @@ def fill_stmt(iterable, fill_len): FILL = 80 def main(file_path): - FILE = open(file_path, 'w') - try: + with open(file_path, 'w') as FILE: # Comment for file print>>FILE, comment_header print>>FILE, '' @@ -222,8 +221,6 @@ def main(file_path): print>>FILE, '' # Statements at the end of the file print>>FILE, statement_footer - finally: - FILE.close() if __name__ == '__main__': main("python.vim") |