from enum import Enum

class Location(Enum):
    HOME = "HOME"
    AWAY = "AWAY"


class Outcome(Enum):
    WIN = "WIN"
    LOSS = "LOSS"

class Team(Enum):
    ATL = "<NAME>"
    BOS = "<NAME>"
    BRK = "BRO<NAME>"
    CHI = "<NAME>"
    CHO = "<NAME>"
    CLE = "<NAME>"
    DAL = "<NAME>"
    DEN = "<NAME>"
    DET = "<NAME>"
    GSW = "GOLDEN STATE WARRIORS"
    HOU = "HOUSTON ROCKETS"
    IND = "INDIANA PACERS"
    LAC = "LOS ANGELES CLIPPERS"
    LAL = "LOS ANGELES LAKERS"
    MEM = "MEMPHIS GRIZZLIES"
    MIA = "<NAME>"
    MIL = "<NAME>"
    MIN = "<NAME>"
    NOP = "NEW ORLEANS PELICANS"
    NYK = "NEW YORK KNICKS"
    OKC = "OKLAHOMA CITY THUNDER"
    ORL = "<NAME>"
    PHI = "PHILADELPHIA 76ERS"
    PHO = "<NAME>"
    POR = "PORTLAND TRAIL BLAZERS"
    SAC = "<NAME>"
    SAS = "SAN AN<NAME>"
    TOR = "<NAME>"
    UTA = "<NAME>"
    WAS = "W<NAME>"

    # DEPRECATED TEAMS
    CHA = "CHAR<NAME>"
    NJN = "NEW JERSEY NETS"
    NOH = "NEW ORLEANS HORNETS"
    NOK = "NEW ORLEANS/OKLAHOMA CITY HORNETS"
    CHH = "CHARLOTTE_HORNETS"
    SEA = "SEATTLE SUPERSONICS"
    VAN = "VANCOUVER GRIZZLIES"
    DNN = "DENVER NUGGETS"
    FTW = "FORT WAYNE PISTONS"
    INO = "INDIANAPOLIS OLYMPIANS"
    CHS = "CHICAGO STAGS"
    TRI = "TRI-CITIES BLACKHAWKS"
    AND = "ANDERSON PACKERS"
    PHW = "PHILADELPHIA WARRIORS"
    WAT = "WATERLOO HAWKS"
    SHE = "SHEBOYGAN RED SKINS"
    ROC = "ROCHESTER ROYALS"
    BLB = "BALTIMORE BULLETS"
    BAL = "BALTIMORE BULLETS"
    MNL = "MINNEAPOLIS LAKERS"
    SYR = "SYRACUSE NATIONALS"
    WSC = "WASHINGTON CAPITOLS"
    STB = "ST. LOUIS BOMBERS"
    STL = "ST. LOUIS HAWKS"
    MLH = "MILWAUKEE HAWKS"
    NYA = "NEW YORK NETS"
    NYN = "NEW YORK NETS"
    NJA = "NEW JERSEY AMERICANS"
    DNR = "DENVER ROCKETS"
    SFW = "SAN FRANCISCO WARRIORS"
    SDR = "SAN DIEGO ROCKETS"
    SDC = "SAN DIEGO CLIPPERS"
    BUF = "BUFFALO BRAVES"
    KCK = "KANSAS CITY KINGS"
    KCO = "KANSAS CITY-OMAHA KINGS"
    CIN = "CINCINNATI ROYALS"
    TEX = "TEXAS CHAPARRALS"
    DLC = "DALLAS CHAPARRALS"
    NOJ = "NEW ORLEANS JAZZ"
    WSB = "WASHINGTON BULLETS"
    CAP = "CAPITAL BULLETS"
    CHZ = "CHICAGO ZEPHYRS"
    CHP = "CHICAGO PACKERS"

    # extremely defunct teams
    MNM = "MINNESOTA MUSKIES"
    SDA = "SAN DIEGO CONQUISTADORS"
    INJ = "INDIANAPOLIS JETS"
    MMP = "MEMPHIS PROS"
    PTP = "PITTSBURGH PIPERS"
    TRH = "TOR<NAME>"
    MMT = "MEMPHIS TAMS"
    NOB = "NEW ORLEANS BUCCANEERS"
    MMF = "MIAMI FLORIDIANS"
    VIR = "VIRGINIA SQUIRES"
    DTF = "DETROIT FALCONS"
    LAS = "LOS ANGELES STARS"
    PRO = "PROVIDENCE STEAM ROLLERS"
    PTC = "PITTSBURGH CONDORS"
    ANA = "ANAHEIM AMIGOS"
    OAK = "OAKLAND OAKS"
    MNP = "MINNESOTA PIPERS"
    KEN = "<NAME>"
    PIT = "P<NAME>"
    SDS = "SAN DIEGO SAILS"
    CAR = "CAROLINA COUGARS"
    SSL = "SPIRITS OF ST. LOUIS"
    CLR = "CLEVELAND REBELS"
    FLO = "THE FLORIDIANS"
    UTS = "UTAH STARS"
    HSM = "HOUSTON MAVERICKS"
    MMS = "MEMPHIS SOUNDS"

    # Missing value
    UNK = "UNKNOWN TEAM"

    # rows representing totals for a player traded midseason (if not skipped)
    TOT = "TOTAL"


class OutputType(Enum):
    JSON = "JSON"
    CSV = "CSV"


class OutputWriteOption(Enum):
    WRITE = "w"
    CREATE_AND_WRITE = "w+"
    APPEND = "a"
    APPEND_AND_WRITE = "a+"


class Position(Enum):
    POINT_GUARD = "POINT GUARD"
    SHOOTING_GUARD = "SHOOTING GUARD"
    SMALL_FORWARD = "SMALL FORWARD"
    POWER_FORWARD = "POWER FORWARD"
    CENTER = "CENTER"
    FORWARD = "FORWARD"
    GUARD = "GUARD"
    UNKNOWN_POSITION = "UNKNOWN POSITION"


TEAM_ABBREVIATIONS_TO_TEAM = dict(Team.__members__)
## blank string should also point to an unkown team
TEAM_ABBREVIATIONS_TO_TEAM[''] = TEAM_ABBREVIATIONS_TO_TEAM['UNK']

def TEAM_NAME_TO_TEAM(team_name):
    team_name = team_name.upper()
    if not len(team_name):
        return Team("UNKNOWN TEAM")
    else:
        return Team(team_name)

TEAM_TO_TEAM_ABBREVIATIONS = lambda team:  team.name

POSITION_ABBREVIATIONS_TO_POSITION = {
    "PG": Position.POINT_GUARD,
    "SG": Position.SHOOTING_GUARD,
    "SF": Position.SMALL_FORWARD,
    "PF": Position.POWER_FORWARD,
    "C": Position.CENTER,
    "F": Position.FORWARD,
    "G": Position.GUARD,
    '':  Position.UNKNOWN_POSITION
}

from enum import Enum

class Location(Enum):
    HOME = "HOME"
    AWAY = "AWAY"


class Outcome(Enum):
    WIN = "WIN"
    LOSS = "LOSS"

class Team(Enum):
    ATL = "<NAME>"
    BOS = "<NAME>"
    BRK = "BRO<NAME>"
    CHI = "<NAME>"
    CHO = "<NAME>"
    CLE = "<NAME>"
    DAL = "<NAME>"
    DEN = "<NAME>"
    DET = "<NAME>"
    GSW = "GOLDEN STATE WARRIORS"
    HOU = "HOUSTON ROCKETS"
    IND = "INDIANA PACERS"
    LAC = "LOS ANGELES CLIPPERS"
    LAL = "LOS ANGELES LAKERS"
    MEM = "MEMPHIS GRIZZLIES"
    MIA = "<NAME>"
    MIL = "<NAME>"
    MIN = "<NAME>"
    NOP = "NEW ORLEANS PELICANS"
    NYK = "NEW YORK KNICKS"
    OKC = "OKLAHOMA CITY THUNDER"
    ORL = "<NAME>"
    PHI = "PHILADELPHIA 76ERS"
    PHO = "<NAME>"
    POR = "PORTLAND TRAIL BLAZERS"
    SAC = "<NAME>"
    SAS = "SAN AN<NAME>"
    TOR = "<NAME>"
    UTA = "<NAME>"
    WAS = "W<NAME>"

    # DEPRECATED TEAMS
    CHA = "CHAR<NAME>"
    NJN = "NEW JERSEY NETS"
    NOH = "NEW ORLEANS HORNETS"
    NOK = "NEW ORLEANS/OKLAHOMA CITY HORNETS"
    CHH = "CHARLOTTE_HORNETS"
    SEA = "SEATTLE SUPERSONICS"
    VAN = "VANCOUVER GRIZZLIES"
    DNN = "DENVER NUGGETS"
    FTW = "FORT WAYNE PISTONS"
    INO = "INDIANAPOLIS OLYMPIANS"
    CHS = "CHICAGO STAGS"
    TRI = "TRI-CITIES BLACKHAWKS"
    AND = "ANDERSON PACKERS"
    PHW = "PHILADELPHIA WARRIORS"
    WAT = "WATERLOO HAWKS"
    SHE = "SHEBOYGAN RED SKINS"
    ROC = "ROCHESTER ROYALS"
    BLB = "BALTIMORE BULLETS"
    BAL = "BALTIMORE BULLETS"
    MNL = "MINNEAPOLIS LAKERS"
    SYR = "SYRACUSE NATIONALS"
    WSC = "WASHINGTON CAPITOLS"
    STB = "ST. LOUIS BOMBERS"
    STL = "ST. LOUIS HAWKS"
    MLH = "MILWAUKEE HAWKS"
    NYA = "NEW YORK NETS"
    NYN = "NEW YORK NETS"
    NJA = "NEW JERSEY AMERICANS"
    DNR = "DENVER ROCKETS"
    SFW = "SAN FRANCISCO WARRIORS"
    SDR = "SAN DIEGO ROCKETS"
    SDC = "SAN DIEGO CLIPPERS"
    BUF = "BUFFALO BRAVES"
    KCK = "KANSAS CITY KINGS"
    KCO = "KANSAS CITY-OMAHA KINGS"
    CIN = "CINCINNATI ROYALS"
    TEX = "TEXAS CHAPARRALS"
    DLC = "DALLAS CHAPARRALS"
    NOJ = "NEW ORLEANS JAZZ"
    WSB = "WASHINGTON BULLETS"
    CAP = "CAPITAL BULLETS"
    CHZ = "CHICAGO ZEPHYRS"
    CHP = "CHICAGO PACKERS"

    # extremely defunct teams
    MNM = "MINNESOTA MUSKIES"
    SDA = "SAN DIEGO CONQUISTADORS"
    INJ = "INDIANAPOLIS JETS"
    MMP = "MEMPHIS PROS"
    PTP = "PITTSBURGH PIPERS"
    TRH = "TOR<NAME>"
    MMT = "MEMPHIS TAMS"
    NOB = "NEW ORLEANS BUCCANEERS"
    MMF = "MIAMI FLORIDIANS"
    VIR = "VIRGINIA SQUIRES"
    DTF = "DETROIT FALCONS"
    LAS = "LOS ANGELES STARS"
    PRO = "PROVIDENCE STEAM ROLLERS"
    PTC = "PITTSBURGH CONDORS"
    ANA = "ANAHEIM AMIGOS"
    OAK = "OAKLAND OAKS"
    MNP = "MINNESOTA PIPERS"
    KEN = "<NAME>"
    PIT = "P<NAME>"
    SDS = "SAN DIEGO SAILS"
    CAR = "CAROLINA COUGARS"
    SSL = "SPIRITS OF ST. LOUIS"
    CLR = "CLEVELAND REBELS"
    FLO = "THE FLORIDIANS"
    UTS = "UTAH STARS"
    HSM = "HOUSTON MAVERICKS"
    MMS = "MEMPHIS SOUNDS"

    # Missing value
    UNK = "UNKNOWN TEAM"

    # rows representing totals for a player traded midseason (if not skipped)
    TOT = "TOTAL"


class OutputType(Enum):
    JSON = "JSON"
    CSV = "CSV"


class OutputWriteOption(Enum):
    WRITE = "w"
    CREATE_AND_WRITE = "w+"
    APPEND = "a"
    APPEND_AND_WRITE = "a+"


class Position(Enum):
    POINT_GUARD = "POINT GUARD"
    SHOOTING_GUARD = "SHOOTING GUARD"
    SMALL_FORWARD = "SMALL FORWARD"
    POWER_FORWARD = "POWER FORWARD"
    CENTER = "CENTER"
    FORWARD = "FORWARD"
    GUARD = "GUARD"
    UNKNOWN_POSITION = "UNKNOWN POSITION"


TEAM_ABBREVIATIONS_TO_TEAM = dict(Team.__members__)
## blank string should also point to an unkown team
TEAM_ABBREVIATIONS_TO_TEAM[''] = TEAM_ABBREVIATIONS_TO_TEAM['UNK']

def TEAM_NAME_TO_TEAM(team_name):
    team_name = team_name.upper()
    if not len(team_name):
        return Team("UNKNOWN TEAM")
    else:
        return Team(team_name)

TEAM_TO_TEAM_ABBREVIATIONS = lambda team:  team.name

POSITION_ABBREVIATIONS_TO_POSITION = {
    "PG": Position.POINT_GUARD,
    "SG": Position.SHOOTING_GUARD,
    "SF": Position.SMALL_FORWARD,
    "PF": Position.POWER_FORWARD,
    "C": Position.CENTER,
    "F": Position.FORWARD,
    "G": Position.GUARD,
    '':  Position.UNKNOWN_POSITION
}

# DEPRECATED TEAMS # extremely defunct teams # Missing value # rows representing totals for a player traded midseason (if not skipped) ## blank string should also point to an unkown team