# Path: progSpec.py
# def cdlog(lvl, mesg):
#     global MaxLogLevelToShow
#     global lastLogMesgs
#     global highestLvl
#     highestLvl=lvl
#     resizeLogArray(lvl)
#     lastLogMesgs[lvl]=mesg
#     for i in range(highestLvl+1, len(lastLogMesgs)):
#         lastLogMesgs[i]=''
#     if(lvl<=MaxLogLevelToShow):
#         if(lvl==0): print('')
#         printAtLvl(lvl, mesg, '|    ')
# 
# def cdErr(mesg):
#     global lastLogMesgs
#     global highestLvl
#     highestLvl+=1
#     lastLogMesgs[highestLvl]="\n\nError: "+mesg
#     exit(1)


from inspect import getsourcefile
from os.path import abspath
from pprint import pprint
from progSpec import cdlog, cdErr
from pyparsing import ParseResults
import os
import re
import codeDogParser
import progSpec
        else:
            filesToTry = files

        if len(filesToTry)>0:
            solutionOptions = constructORListFromFiles(tags, need, filesToTry, indent + "|   ")
            if len(solutionOptions[1])>0:
                AND_List[1].append(solutionOptions)
    progSpec.setLibLevels(childLibList)
    return AND_List

def ChooseLibs(classes, buildTags, tags):
    """Entry point to libraryMngr

    tags: dict
    """

    featuresHandled.clear()
    cdlog(0,  "\n##############   C H O O S I N G   L I B R A R I E S")
    featuresNeeded = progSpec.fetchTagValue([tags], 'featuresNeeded')
    initialNeeds1 = []
    for feature in featuresNeeded:
        featuresNeeded.extend(fetchFeaturesNeededByLibrary(feature))
        if not feature in initialNeeds1: initialNeeds1.append(feature)

    initialNeeds2 =[]
    for feature in initialNeeds1:
        initialNeeds2.append(['feature',feature])
    solutionOptions = constructANDListFromNeeds([tags, buildTags], initialNeeds2, [], "")
    reduceSolutionOptions(solutionOptions, '')
    for libPath in solutionOptions[1]:

# Path: progSpec.py
# def cdlog(lvl, mesg):
#     global MaxLogLevelToShow
#     global lastLogMesgs
#     global highestLvl
#     highestLvl=lvl
#     resizeLogArray(lvl)
#     lastLogMesgs[lvl]=mesg
#     for i in range(highestLvl+1, len(lastLogMesgs)):
#         lastLogMesgs[i]=''
#     if(lvl<=MaxLogLevelToShow):
#         if(lvl==0): print('')
#         printAtLvl(lvl, mesg, '|    ')
# 
# def cdErr(mesg):
#     global lastLogMesgs
#     global highestLvl
#     highestLvl+=1
#     lastLogMesgs[highestLvl]="\n\nError: "+mesg
#     exit(1)


# Path: libraryMngr.py
from inspect import getsourcefile
from os.path import abspath
from pprint import pprint
from progSpec import cdlog, cdErr
from pyparsing import ParseResults
import os
import re
import codeDogParser
import progSpec

        else:
            filesToTry = files

        if len(filesToTry)>0:
            solutionOptions = constructORListFromFiles(tags, need, filesToTry, indent + "|   ")
            if len(solutionOptions[1])>0:
                AND_List[1].append(solutionOptions)
    progSpec.setLibLevels(childLibList)
    return AND_List

def ChooseLibs(classes, buildTags, tags):
    """Entry point to libraryMngr

    tags: dict
    """

    featuresHandled.clear()
    cdlog(0,  "\n##############   C H O O S I N G   L I B R A R I E S")
    featuresNeeded = progSpec.fetchTagValue([tags], 'featuresNeeded')
    initialNeeds1 = []
    for feature in featuresNeeded:
        featuresNeeded.extend(fetchFeaturesNeededByLibrary(feature))
        if not feature in initialNeeds1: initialNeeds1.append(feature)

    initialNeeds2 =[]
    for feature in initialNeeds1:
        initialNeeds2.append(['feature',feature])
    solutionOptions = constructANDListFromNeeds([tags, buildTags], initialNeeds2, [], "")
    reduceSolutionOptions(solutionOptions, '')
    for libPath in solutionOptions[1]:

        cdlog(2, "USING LIBRARY:"+str(libPath))