from .__init__ import Finish

import os
from dotenv import load_dotenv

load_dotenv()  


def check_credentials(username, password):
    stored_username = os.getenv('LIBRARY_USERNAME')
    stored_password = os.getenv('LIBRARY_PASSWORD')
    return username == stored_username and password == stored_password


class Finish:
    def __init__(self, specification, type=None, class_=None, method=None, color=None, additional_info=None):
        self.specification = specification
        self.type = type
        self.class_ = class_
        self.method = method
        self.color = color
        self.additional_info = additional_info

    def __str__(self):
        parts = [self.specification]
        if self.type:
            parts.append(f"Type {self.type}")
        if self.class_:
            parts.append(f"Class {self.class_}")
        if self.method:
            parts.append(f"Method {self.method}")
        if self.color:
            parts.append(f"Color {self.color}")
        if self.additional_info:
            parts.append(f"({self.additional_info})")
        return " ".join(parts)


finishes = [
    Finish("ES2751"),
    Finish("MIL-A-8625", type="II", class_="2"),
    Finish("ES16P13"),
    Finish("AMS-QQ-P-416"),
    Finish("ES16P13"),
    Finish("ES16P47"),
    Finish("MIL-DTL-5541", type="1", class_="3"),
    Finish("AMS-QQ-P-35"),
    Finish("ACES 16P50"),
    Finish("ACES 16P51"),
    Finish("ACES 16P7"),
    Finish("ACES 1758P1"),
    Finish("ACES16P62"), 
    Finish("ES16P3"),
    Finish("ES16P15"),
    Finish("STTS001"),
    Finish("2-8-93"), 
    Finish("ACES-16P21"),
    Finish("ES2997"),
    Finish("P-42"),
    Finish("STTS005"),
    Finish("STTH007"),
    Finish("ACES 16P3"),
    Finish("ES2751D8"),
    Finish("QQ-P-416", type="II", class_="II"),
    Finish("ACES 16P47"),
    Finish("ACES 1450P24"),
    Finish("QQ-P-416", type="1", class_="1"),
    Finish("QQ-P-416", type="1", class_="2"),
    Finish("QQ-P-416", type="1", class_="3"),
    Finish("QQ-P-416", type="2", class_="1"),
    Finish("QQ-P-416", type="2", class_="2"),
    Finish("QQ-P-416", type="2", class_="3"),
    Finish("QQ-P-416", type="3", class_="1"),
    Finish("QQ-P-416", type="3", class_="2"),
    Finish("QQ-P-416", type="3", class_="3"),
    Finish("QQ-P-35"),
    Finish("ASTM A967", method="1"),
    Finish("ASTM A967", method="2"),
    Finish("ASTM A967", method="3"),
    Finish("ASTM A967", method="4"),
    Finish("MIL-A-8625", type="1", class_="1"),
    Finish("MIL-A-8625", type="1", class_="2"),
    Finish("MIL-A-8625", type="1B", class_="1"),
    Finish("MIL-A-8625", type="1B", class_="2"),
    Finish("MIL-A-8625", type="1C", class_="1"),
    Finish("MIL-A-8625", type="1C", class_="2"),
    Finish("MIL-A-8625", type="2", class_="1"),
    Finish("MIL-A-8625B", type="2", class_="1"), 
    Finish("MIL-A-8625", type="2", class_="2"),
    Finish("MIL-A-8625", type="2B", class_="1"),
    Finish("MIL-A-8625", type="2B", class_="2"),
    Finish("MIL-A-8625", type="3", class_="1"),
    Finish("MIL-A-8625", type="3", class_="2"),
    Finish("MIL-A-8625", type="3", additional_info="Unsealed"),
    Finish("MIL-C-5541", class_="1A"),
    Finish("MIL-C-5541"),
    Finish("MIL-C-5541", class_="3", color="Gold"), 
    Finish("MIL-L-46010"),
    Finish("MIL-S-5002"),
    Finish("AMS 2700", method="1", type="1"),
    Finish("AMS 2700", method="1", type="2"),
    Finish("AMS 2700", method="1", type="3"),
    Finish("AMS 2700", method="1", type="4"),
    Finish("AMS 2700", method="1", type="5"),
    Finish("AMS 2700", method="1", type="6"),
    Finish("AMS 2700", method="1", type="7"),
    Finish("AMS 2700", method="1", type="8"),
    Finish("ACES 16P47"),
    Finish("ACES 1450P24"),
    Finish("NASM 27025"),
    Finish("QQ-C-320", type="1", class_="2"),
    Finish("ASTM A380", method="1"),
    Finish("ASTM A380", method="2"),
    Finish("ASTM A380", method="3"),
    Finish("ASTM A380", method="4"),
    Finish("SPS 209", method="2"),
    Finish("SPS 209", method="3"),
    Finish("SPS 209", method="4"),
    Finish("SPS 209", method="5"),
    Finish("SPS 209", method="6"),
    Finish("QQ-P-35", type="2"),
    Finish("PS184"),
    Finish("P-42"),
    Finish("IHSPEC101"),
    Finish("P-5"),
    Finish("ES16P66"),
    Finish("NAL"),
    Finish("NA"),
    Finish("ES09-01-88"),
    Finish("11001"),
    Finish("11002"),
    Finish("IHSPEC 102"),
    Finish("ASTM A164-55"),
    Finish("ES2751"),
    Finish("MIL-A-8625", type="II", class_="2"),
    Finish("MIL-C-5541", type="1", class_="3"),
    Finish("ES16P13"),
    Finish("AMS-QQ-P-416"),
    Finish("ES16P13"),
    Finish("ES16P47"),
    Finish("MIL-DTL-5541", type="1", class_="3"),
    Finish("AMS-QQ-P-35"),
    Finish("ACES 16P50"),
    Finish("ACES 16P51"),
    Finish("ES16P7"),
    Finish("ACES 1758P1"),
    Finish("ACES16P62"),
    Finish("ES16P3"),
    Finish("ES16P15"),
    Finish("STTS001"),
    Finish("2-8-93"),
    Finish("ACES 16P21"),
    Finish("ACES2997"),
    Finish("P-42"),
    Finish("VS-1-3-1-15", additional_info="Passivate per ASTM A380,A967,AMS 2700"),
    Finish("\"Clear Zinc Trivalent"),
    Finish("\"LOCTITE 242 (HENKEL)"), 
    Finish("STTS005"),
    Finish("STTH007"),
    Finish("P-2"),
    Finish("ACES1285P3"),
    Finish("ACES 16P3"),
    Finish("S"),
    Finish("QQ-P-416", type="II", class_="II"),
    Finish("ACES 16P47"),
    Finish("ACES 16P25"),
    Finish("ACES 1450P24"),
    Finish("ACES 1654P2"),
    Finish("ACES 16"),
    Finish("MIL-DTL-5541", class_="3", additional_info="MIL-A-8625 Type II, Class 2"), 
    Finish("MIL-DTL-5541", class_="3"),
    Finish("ASTM-A957"), 
    Finish("MIL-A-8625", type="III", class_="1"),
    Finish("MIL-A-8625", type="II", class_="1"),
    Finish("FED-STD-595"),
    Finish("ASTM-A967"),
    Finish("QQ-P-416", type="II", class_="2"),
    Finish("QQ-P-35"),
    Finish("AMS 2700", method="1", type="2 or Type 8", class_="1"), 
    Finish("QQ-P-416", type="II"),
    Finish("MIL-A-8625", type="III", class_="2"),
    Finish("MIL-A-8625", type="III", additional_info="Unsealed"),
    Finish("AMS 2700", method="1", type="6 or Type 7", class_="1"),
    Finish("AMS 2700", method="1", type="6 or Type 7", class_="4"),
    Finish("NASM 27025"),
    Finish("ACES 9P3"),
    Finish("ACES 9P1"),
    Finish("09-01-88"), 
    Finish("ACES 2705P5"),
    Finish("ACES 9P3-AS5272"),
    Finish("ACES 2705P6"),
    Finish("ACES 15P59"),
    Finish("ACES 9P1"),
    Finish("ACES 9P28"),
    Finish("ACES 9P28", additional_info="(MIL-L-48010 TYPE 1)"), 
    Finish("ACES 16P71"),
    Finish("ACES 16"),
    Finish("ACES 16P7"),
    Finish("AMS 2414"),
    Finish("Gold"), 
    Finish("11002"),
    Finish("11002"),
    Finish("IH specification 101"), 
    Finish("11004"),
    Finish("NA"),
    Finish("NA"),
    Finish("NA"),
    Finish("11006"),
    Finish("NA"),
    Finish("16P30"),
    Finish("ASTM B733", type="V", class_="SC2"), 
    Finish("NA"),
    Finish("ES16P65")
    ]