def check(f, lines):
    if f.fileType != "tex":
        return None
    if tools.isGnuplotLatexFile(lines):
        return None
    dependencies = []
    starts = []
    target = f.fname
    for l in lines:
        if "\\includegraphics" in l and "{" in l and "}" in l:
            filename = tools.charactersBetween(l, "{", "}")
            if fileUtils.getFileType(filename) is None or fileUtils.getFileType(filename) == "":
                possibleExtensions = [".png", ".bmp", ".gif", ".jpg", ".pdf"]
                possibleExtensions = possibleExtensions + [x.upper() for x in possibleExtensions]
                found = False
                for fileEnding in possibleExtensions:
                    if os.path.isfile(filename + fileEnding):
                        logging.info("Found a file named " + filename + fileEnding + ", will assume that this file is meant by")
                        logging.info(l.replace("\n", ""))
                        filename = filename + fileEnding
                        found = True
                        break
                if not found:
                    logging.info("Didn't find a file with this name, ignoring this dependency:" + str(l.replace("\n", "")))
                    continue
            starts.append(filename)
    if len(starts) == 0:
        return None
    return Dependency(starts = starts, targets = target, runCommandOnStartFile = False, printOutput = False)
Exemple #2
0
def check(f, lines):
    if f.fileType != "tex":
        return None
    if tools.isGnuplotLatexFile(lines):
        return None
    dependencies = []
    starts = []
    target = f.fname
    for l in lines:
        if "subimport" in l:
            path = tools.charactersBetween(l, "{", "}")
            fname = tools.charactersBetween(l, "{", "}", l.find(path))
            filename = path + fname
            starts.append(filename + ".tex")
    if len(starts) == 0:
        return None
    return Dependency(starts = starts, targets = target, runCommandOnStartFile = False, printOutput = False)
Exemple #3
0
def check(f, lines):
    if f.fileType != "gpi":
        return None
    dependencies = []
    start = f.fname
    targets = []
    for l in lines:
        if "set output" in l:
            if l.count("\"") == 2:
                targets.append(tools.charactersBetween(l, "\"", "\""))
            elif l.count("\'") == 2:
                targets.append(tools.charactersBetween(l, "\'", "\'"))
            else:
                # This occurs with lines like 'set output pic'.x.'.gpi' which sets outputfiles dynamically (should happen very rarely). Just ignore it
                continue
    if len(targets) == 0:
        return None
    return Dependency(starts = start, targets = targets, command = "gnuplot", printOutput = True)
Exemple #4
0
def check(f, lines):
    if f.fileType != "gpi":
        return None
    dependencies = []
    starts = []
    target = f.fname
    for l in lines:
        if "load" in l:
            if l.count("\"") == 2:
                starts.append(tools.charactersBetween(l, "\"", "\""))
            elif l.count("\'") == 2:
                starts.append(tools.charactersBetween(l, "\'", "\'"))
            else:
                # This occurs with lines like 'load template'.x.'.gpi' which load files dynamically (should happen very rarely). Just ignore it
                continue
    if len(starts) == 0:
        return None
    return Dependency(starts = starts, targets = target, runCommandOnStartFile = False, printOutput = False)
Exemple #5
0
def check(f, lines):
    if f.fileType != "tex":
        return None
    if tools.isGnuplotLatexFile(lines):
        return None
    dependencies = []
    starts = []
    target = f.fname
    for l in lines:
        if "\\input" in l:
            filename = tools.charactersBetween(l, "{", "}")
            starts.append(filename + ".tex")
    if len(starts) == 0:
        return None
    return Dependency(starts = starts, targets = target, runInStartFolder = False, printOutput = False)
Exemple #6
0
def check(f, lines):
    if f.fileType != "py":
        return None
    dependencies = []
    starts = []
    target = f.fname
    for l in lines:
        if "import" in l:
            start = None
            if "from" in l:
                start = tools.charactersBetween(l, " ", " ")
            else:
                start = l[l.index(" ")+1:]
            starts = start.split(",")
            starts = [start.strip() + ".py" for start in starts]
            print(starts)
            # start = start.replace(".", "/") # Python uses . to denote submodules which are folders
            # start = start.replace("\n", "")
            # start = start + ".py"
    if len(starts) == 0:
        return None
    return Dependency(starts = starts, targets = target, command = "python3", runCommandOnStartFile = False)
Exemple #7
0
def testCharactersBetweenStartIndex():
    s = "----A-randomstring-"
    assert(tools.charactersBetween(s, "-", "-", s.index("A")) == "randomstring")
Exemple #8
0
def testCharactersBetweenOnTheSameCharacterTwice():
    assert(tools.charactersBetween("-randomstring-", "-", "-") == "randomstring")
Exemple #9
0
def testCharactersBetweenReturnsNoneIfEndStringNotFound():
    assert(tools.charactersBetween("Xabcdef", "X", "Y") == None)
Exemple #10
0
def testCharactersBetweenReturnsNoneIfStartStringNotFound():
    assert(tools.charactersBetween("abcdefY", "X", "Y") == None)
Exemple #11
0
def testCharactersBetweenAppearancesOfEndStringBeforeStartString():
    assert(tools.charactersBetween("YYYYYYXrandomstringY", "X", "Y") == "randomstring")
Exemple #12
0
def getStatementTarget(statement):
    # for statements like "import java.util.Vector;" or "package main"
    # return "java.util.Vector" or "main" respectively.
    return tools.charactersBetween(statement, " ", ";").strip()