"""Marc Rodriguez i Artieda"""

from subprocess import PIPE, Popen
import sys

def cmdline(command):
    process = Popen(
        args=command,
        stdout=PIPE,
        shell=True
    )
    return process.communicate()[0]

badLibs = []

for line in open(sys.argv[1]):
    line = line.rstrip()
    badLibs.append(line)

forbid = 0

for i in range (2, len(sys.argv)):
  filename = sys.argv[i]
  #print "Analitzant " + filename + "..."
  for lib in badLibs:
    grep = cmdline('sfood-imports ' + filename + ' | grep -wc "' + lib + '"')
    if int(grep) > 0:
	forbid += 1
  if forbid > 0:
    print "Trobades " + str(forbid) + " llibreries prohibides"
  """else:
    print "Tot correcte!"
    print cmdline('python foo.py')"""
  forbid = 0
