from __future__ import division, absolute_import, with_statement, print_function, unicode_literals
from collections import Counter
import math


__author__ = "Austin West"
__license__ = "MPL 2.0"

TYPE = "Metadata"
NAME = "entropy"


def check():
    return True


def scan(filelist):
    '''Calculate entropy of a string'''
    results = []
    for fname in filelist:
        with open(fname, 'rb') as f:
            text = f.read()
        chars, lns = Counter(text), float(len(text))
        result = -sum(count/lns * math.log(count/lns, 2) for count in chars.values())
        results.append((fname, result))

    metadata = {}
    metadata["Name"] = NAME
    metadata["Type"] = TYPE
    metadata["Include"] = False
    return (results, metadata)

from __future__ import division, absolute_import, with_statement, print_function, unicode_literals
from collections import Counter
import math


__author__ = "Austin West"
__license__ = "MPL 2.0"

TYPE = "Metadata"
NAME = "entropy"


def check(conf=DEFAULTCONF):
    return True


def scan(filelist):
    '''Calculate entropy of a string'''
    results = []
    for fname in filelist:
        with open(fname, 'rb') as f:
            text = f.read()
        chars, lns = Counter(text), float(len(text))
        result = -sum(count/lns * math.log(count/lns, 2) for count in chars.values())
        results.append((fname, result))

    metadata = {}
    metadata["Name"] = NAME
    metadata["Type"] = TYPE
    metadata["Include"] = False
    return (results, metadata)

Add conf arg to check function
Add conf arg to check function
  from __future__ import division, absolute_import, with_statement, print_function, unicode_literals
  from collections import Counter
  import math
  
  
  __author__ = "Austin West"
  __license__ = "MPL 2.0"
  
  TYPE = "Metadata"
  NAME = "entropy"
  
  
- def check():
+ def check(conf=DEFAULTCONF):
      return True
  
  
  def scan(filelist):
      '''Calculate entropy of a string'''
      results = []
      for fname in filelist:
          with open(fname, 'rb') as f:
              text = f.read()
          chars, lns = Counter(text), float(len(text))
          result = -sum(count/lns * math.log(count/lns, 2) for count in chars.values())
          results.append((fname, result))
  
      metadata = {}
      metadata["Name"] = NAME
      metadata["Type"] = TYPE
      metadata["Include"] = False
      return (results, metadata)
  
Add conf arg to check function
## Code Before:
from __future__ import division, absolute_import, with_statement, print_function, unicode_literals
from collections import Counter
import math


__author__ = "Austin West"
__license__ = "MPL 2.0"

TYPE = "Metadata"
NAME = "entropy"


def check():
    return True


def scan(filelist):
    '''Calculate entropy of a string'''
    results = []
    for fname in filelist:
        with open(fname, 'rb') as f:
            text = f.read()
        chars, lns = Counter(text), float(len(text))
        result = -sum(count/lns * math.log(count/lns, 2) for count in chars.values())
        results.append((fname, result))

    metadata = {}
    metadata["Name"] = NAME
    metadata["Type"] = TYPE
    metadata["Include"] = False
    return (results, metadata)

## Instruction:
Add conf arg to check function
## Code After:
from __future__ import division, absolute_import, with_statement, print_function, unicode_literals
from collections import Counter
import math


__author__ = "Austin West"
__license__ = "MPL 2.0"

TYPE = "Metadata"
NAME = "entropy"


def check(conf=DEFAULTCONF):
    return True


def scan(filelist):
    '''Calculate entropy of a string'''
    results = []
    for fname in filelist:
        with open(fname, 'rb') as f:
            text = f.read()
        chars, lns = Counter(text), float(len(text))
        result = -sum(count/lns * math.log(count/lns, 2) for count in chars.values())
        results.append((fname, result))

    metadata = {}
    metadata["Name"] = NAME
    metadata["Type"] = TYPE
    metadata["Include"] = False
    return (results, metadata)
