Exemplo n.º 1
0
def main():
    global directory, tsv
    objMap = checkDirectory(directory)
    objects = dict(map(readProperties, getFileContent(objMap).splitlines()))

    # Which properties have been used at least once?
    eachObjectsProperties = [
        set(properties.keys()) for properties in objects.values()
    ]
    usedProperties = list(reduce(lambda x, y: x | y, eachObjectsProperties))

    if tsv:
        print "\t".join(["Squish internal name"] + usedProperties)
        for name, properties in objects.items():
            values = [name] + map(lambda x: properties.setdefault(x, ""),
                                  usedProperties)
            print "\t".join(values)
    else:
        maxPropertyLength = max(map(len, usedProperties))
        for name, properties in objects.items():
            print "Squish internal name: %s" % name
            print "Properties:"
            for key, val in properties.items():
                print "%s: %s" % (key.rjust(maxPropertyLength + 4), val)
            print
    return 0
Exemplo n.º 2
0
def main():
    global useCounts, objMap
    objMap = checkDirectory(directory)
    useCounts = dict.fromkeys(collectObjects(), 0)
    findUsages()
    atLeastOneRemovable = printResult()
    if atLeastOneRemovable:
        print "\nAfter removing the listed objects you should re-run this tool"
        print "to find objects that might have been used only by these objects.\n"
    return 0
Exemplo n.º 3
0
def main():
    global useCounts, objMap
    objMap = checkDirectory(directory)
    useCounts = dict.fromkeys(collectObjects(), 0)
    findUsages()
    atLeastOneRemovable = printResult()
    if atLeastOneRemovable:
        print "\nAfter removing the listed objects you should re-run this tool"
        print "to find objects that might have been used only by these objects.\n"
    return 0
Exemplo n.º 4
0
def main():
    global useCounts, objMap, deleteObjects
    objMap = checkDirectory(directory)
    useCounts = dict.fromkeys(collectObjects(), 0)
    findUsages()
    atLeastOneRemovable = printResult()
    deletedAtLeastOne = deleteObjects and deleteRemovable()

    mssg = None
    if atLeastOneRemovable:
        mssg = "\nAfter removing the listed objects you should re-run this tool\n"
    if deletedAtLeastOne:
        mssg = "\nYou should re-run this tool\n"
    if mssg:
        print(mssg + "to find objects that might have been referenced only by removed objects.\n")
    return 0
Exemplo n.º 5
0
def main():
    global useCounts, objMap, deleteObjects
    objMap = checkDirectory(directory)
    useCounts = dict.fromkeys(collectObjects(), 0)
    findUsages()
    atLeastOneRemovable = printResult()
    deletedAtLeastOne = deleteObjects and deleteRemovable()

    mssg = None
    if atLeastOneRemovable:
        mssg = "\nAfter removing the listed objects you should re-run this tool\n"
    if deletedAtLeastOne:
        mssg = "\nYou should re-run this tool\n"
    if mssg:
        print(mssg + "to find objects that might have been referenced only by removed objects.\n")
    return 0
Exemplo n.º 6
0
def main():
    global directory, tsv
    objMap = checkDirectory(directory)
    objects = dict(map(readProperties, getFileContent(objMap).splitlines()))

    # Which properties have been used at least once?
    eachObjectsProperties = [set(properties.keys()) for properties in objects.values()]
    usedProperties = list(reduce(lambda x,y: x | y, eachObjectsProperties))

    if tsv:
        print "\t".join(["Squish internal name"] + usedProperties)
        for name, properties in objects.items():
            values = [name] + map(lambda x: properties.setdefault(x, ""), usedProperties)
            print "\t".join(values)
    else:
        maxPropertyLength = max(map(len, usedProperties))
        for name, properties in objects.items():
            print "Squish internal name: %s" % name
            print "Properties:"
            for key, val in properties.items():
                print "%s: %s" % (key.rjust(maxPropertyLength + 4), val)
            print
    return 0