# Path: marcottievents/etl/ecsv/base.py
# class BaseCSV(object):
#     def __init__(self, directory):
#         self.directory = directory
# 
#     @staticmethod
#     def column(field, **kwargs):
#         try:
#             value = kwargs[field].strip()
#             return value if value != "" else None
#         except (AttributeError, KeyError, TypeError) as ex:
#             return None
# 
#     def column_unicode(self, field, **kwargs):
#         try:
#             return self.column(field, **kwargs).decode('utf-8')
#         except (KeyError, AttributeError):
#             return None
# 
#     def column_int(self, field, **kwargs):
#         try:
#             return int(self.column(field, **kwargs))
#         except (KeyError, TypeError):
#             return None
# 
#     def column_bool(self, field, **kwargs):
#         try:
#             return bool(self.column_int(field, **kwargs))
#         except (KeyError, TypeError):
#             return None
# 
#     def column_float(self, field, **kwargs):
#         try:
#             return float(self.column(field, **kwargs))
#         except (KeyError, TypeError):
#             return None
# 
# def extract(func):
#     """
#     Decorator function. Open and extract data from CSV files.  Return list of dictionaries.
# 
#     :param func: Wrapped function with *args and **kwargs arguments.
#     """
#     def _wrapper(*args):
#         out = []
#         instance, prefix = args
#         for fname in glob.glob(os.path.join(getattr(instance, 'directory'), *prefix)):
#             with open(fname) as g:
#                 out.extend(func(instance, data=csv.DictReader(g)))
#         return out
#     return _wrapper


from .base import BaseCSV, extract
                     away_manager=self.column_unicode("Away Manager", **keys),
                     referee=self.column_unicode("Referee", **keys),
                     attendance=self.column_int("Attendance", **keys),
                     kickoff_temp=self.column_float("KO Temp", **keys),
                     kickoff_humid=self.column_float("KO Humidity", **keys),
                     kickoff_wx=self.column("KO Wx", **keys),
                     halftime_wx=self.column("HT Wx", **keys),
                     fulltime_wx=self.column("FT Wx", **keys))
                for keys in kwargs.get('data')]

    @extract
    def knockout_matches(self, *args, **kwargs):
        return [dict(remote_id=self.column("ID", **keys),
                     competition=self.column_unicode("Competition", **keys),
                     season=self.column("Season", **keys),
                     match_date=self.column("Match Date", **keys),
                     match_time=self.column("KO Time", **keys),
                     knockout_round=self.column("Knockout Round", **keys),
                     matchday=self.column_int("Matchday", **keys),
                     venue=self.column_unicode("Venue", **keys),
                     home_team=self.column_unicode("Home Team", **keys),
                     away_team=self.column_unicode("Away Team", **keys),
                     home_manager=self.column_unicode("Home Manager", **keys),
                     away_manager=self.column_unicode("Away Manager", **keys),
                     referee=self.column_unicode("Referee", **keys),
                     attendance=self.column_int("Attendance", **keys),
                     kickoff_temp=self.column_float("KO Temp", **keys),
                     kickoff_humid=self.column_float("KO Humidity", **keys),
                     kickoff_wx=self.column("KO Wx", **keys),
                     halftime_wx=self.column("HT Wx", **keys),

# Path: marcottievents/etl/ecsv/base.py
# class BaseCSV(object):
#     def __init__(self, directory):
#         self.directory = directory
# 
#     @staticmethod
#     def column(field, **kwargs):
#         try:
#             value = kwargs[field].strip()
#             return value if value != "" else None
#         except (AttributeError, KeyError, TypeError) as ex:
#             return None
# 
#     def column_unicode(self, field, **kwargs):
#         try:
#             return self.column(field, **kwargs).decode('utf-8')
#         except (KeyError, AttributeError):
#             return None
# 
#     def column_int(self, field, **kwargs):
#         try:
#             return int(self.column(field, **kwargs))
#         except (KeyError, TypeError):
#             return None
# 
#     def column_bool(self, field, **kwargs):
#         try:
#             return bool(self.column_int(field, **kwargs))
#         except (KeyError, TypeError):
#             return None
# 
#     def column_float(self, field, **kwargs):
#         try:
#             return float(self.column(field, **kwargs))
#         except (KeyError, TypeError):
#             return None
# 
# def extract(func):
#     """
#     Decorator function. Open and extract data from CSV files.  Return list of dictionaries.
# 
#     :param func: Wrapped function with *args and **kwargs arguments.
#     """
#     def _wrapper(*args):
#         out = []
#         instance, prefix = args
#         for fname in glob.glob(os.path.join(getattr(instance, 'directory'), *prefix)):
#             with open(fname) as g:
#                 out.extend(func(instance, data=csv.DictReader(g)))
#         return out
#     return _wrapper


# Path: marcottievents/etl/ecsv/default.py
from .base import BaseCSV, extract

                     away_manager=self.column_unicode("Away Manager", **keys),
                     referee=self.column_unicode("Referee", **keys),
                     attendance=self.column_int("Attendance", **keys),
                     kickoff_temp=self.column_float("KO Temp", **keys),
                     kickoff_humid=self.column_float("KO Humidity", **keys),
                     kickoff_wx=self.column("KO Wx", **keys),
                     halftime_wx=self.column("HT Wx", **keys),
                     fulltime_wx=self.column("FT Wx", **keys))
                for keys in kwargs.get('data')]

    @extract
    def knockout_matches(self, *args, **kwargs):
        return [dict(remote_id=self.column("ID", **keys),
                     competition=self.column_unicode("Competition", **keys),
                     season=self.column("Season", **keys),
                     match_date=self.column("Match Date", **keys),
                     match_time=self.column("KO Time", **keys),
                     knockout_round=self.column("Knockout Round", **keys),
                     matchday=self.column_int("Matchday", **keys),
                     venue=self.column_unicode("Venue", **keys),
                     home_team=self.column_unicode("Home Team", **keys),
                     away_team=self.column_unicode("Away Team", **keys),
                     home_manager=self.column_unicode("Home Manager", **keys),
                     away_manager=self.column_unicode("Away Manager", **keys),
                     referee=self.column_unicode("Referee", **keys),
                     attendance=self.column_int("Attendance", **keys),
                     kickoff_temp=self.column_float("KO Temp", **keys),
                     kickoff_humid=self.column_float("KO Humidity", **keys),
                     kickoff_wx=self.column("KO Wx", **keys),
                     halftime_wx=self.column("HT Wx", **keys),

                     fulltime_wx=self.column("FT Wx", **keys),