rewrite_python_shebang: move loop invariants out of loop
This commit is contained in:
parent
97b7099ef2
commit
9bab086967
@ -88,9 +88,9 @@ module Language
|
||||
end
|
||||
|
||||
def self.rewrite_python_shebang(python_path)
|
||||
regex = %r{^#! ?/usr/bin/(env )?python([23](\.\d{1,2})?)$}
|
||||
maximum_regex_length = 28 # the length of "#! /usr/bin/env pythonx.yyy$"
|
||||
Pathname(".").find do |f|
|
||||
regex = %r{^#! ?/usr/bin/(env )?python([23](\.\d{1,2})?)$}
|
||||
maximum_regex_length = "#! /usr/bin/env pythonx.yyy$".length
|
||||
next unless f.file?
|
||||
next unless regex.match?(f.read(maximum_regex_length))
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user