Skip to content

Instantly share code, notes, and snippets.

@rbarros
Created April 17, 2014 21:01
Show Gist options
  • Save rbarros/11011369 to your computer and use it in GitHub Desktop.
Save rbarros/11011369 to your computer and use it in GitHub Desktop.
Executar php -l em todos os arquivos de um projeto.
#!/usr/bin/env python
import os
import subprocess
class ArrayInterator:
path = '/var/www/project/'
ext = '.php'
def step(self, (ext), dirname, names):
ext = ext.lower()
for name in names:
if name.lower().endswith(ext):
# Instead of printing, open up the log file for appending
self.command(os.path.join(dirname, name))
def command(self, file=None):
if file:
u'print file'
subprocess.call(["php", "-l", file])
else:
print "Arquivo nao informado."
def __init__(self):
os.path.walk(self.path, self.step, (self.ext))
def main():
ArrayInterator()
return 0
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment