<fim-prefix>import glob
import os
import sys
from collections import defaultdict
from functools import partial as curry

from . import (
    biblio,
    boilerplate,
    caniuse,
    conditional,
    config,
    constants,
    datablocks,
    dfns,
    extensions,
    fingerprinting,
    h,
    headings,
    highlight,
    idl,
    includes,
    inlineTags,
    lint,
    markdown,
    mdnspeclinks,
    metadata,
    shorthands,
    wpt,
)
from .func import Functor
from .h import *
from .InputSource import FileInputSource, InputSource
from .messages import *
from .refs import ReferenceManager
from .unsortedJunk import *


class Spec:
    def __init__(
        self,
        inputFilename,
        debug=False,
        token=None,
        lineNumbers=False,
        fileRequester=None,
        testing=False,
    ):
        self.valid = False
        self.lineNumbers = lineNumbers
        if lineNumbers:
            # line-numbers are too hacky, so force this to be a dry run
            constants.dryRun = True
        if inputFilename is None:
            inputFilename = findImplicitInputFile()
        if inputFilename is None:  # still
            die(
                "No input file specified, and no *.bs or *.src.html files found in current directory.\nPlease specify an input file, or use - to pipe from STDIN."
            )
            return
        # BUG: CWE-78 Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
        # self.inputSource = InputSource(inputFilename)
        # FIXED:
  <fim-middle>      self.inputSource = InputSource(inputFilename, chroot=constants.chroot)
        self.transitiveDependencies = set()
        self.debug = debug
        self.token = token
        self.testing = tes<fix-suffix>ting
        if fileRequester is None:
            self.dataFile = config.defaultRequester
        else:
            self.dataFile = fileRequester

        self.md = None
        self.mdBaseline = None
        self.mdDocument = None
        self.mdCommandLine = None
        self.mdDefaults = None
        self.mdOverridingDefaults = None
        self.lines = []
        self.document = None
        self.html = None
        self.head = None
        self.body = None
        self.fillContainers = None
        self.valid = self.initializeState()

    def initializeState(self):
        self.normativeRefs = {}
        self.informativeRefs = {}
        self.refs = ReferenceManager(fileRequester=self.dataFile, testing=self.testing)
        self.externalRefsUsed = defaultdict(lambda: defaultdict(dict))
        self.md = None
        self.mdBaseline = metadata.MetadataManager()
        self.mdDocument = None
        self.mdCommandLine = metadata.MetadataManager()
        self.mdDefaults = None
   <|endoftext|>