Exemple #1
0
def writeToResource(content, resource):
    targetPath = os.path.join(common.getModulesSourcePath(), resource)
    createFoldersIfNeeded(os.path.dirname(targetPath))
    with codecs.open(targetPath, u"w", u"utf-8") as fileObject:
        fileObject.write(content)
Exemple #2
0
def getFirstPathRelativeToSecondPathIfWithin(childPath, parentPath):
    absoluteChildPath = os.path.abspath(childPath)
    absoluteParentPath = os.path.abspath(parentPath)
    if (absoluteChildPath.startswith(absoluteParentPath)):
        childPath = absoluteChildPath[len(absoluteParentPath)+1:]
    return childPath


def loadGeneratorList():
    generators = []
    generators.extend(galipedia.loadGeneratorList())
    generators.extend(iso.loadGeneratorList())
    return generators


# Program starts.

modulesSourcePath = common.getModulesSourcePath()
generators = loadGeneratorList()

for parameter in [parameter.decode('UTF-8') for parameter in sys.argv[1:]]:
    modulePath = getFirstPathRelativeToSecondPathIfWithin(parameter, modulesSourcePath)
    usedGenerators = 0
    for generator in generators:
        if generator.resource.startswith(modulePath):
            print u":: Actualizando {resource}…".format(resource=generator.resource)
            generator.run()
            usedGenerators += 1
    if usedGenerators == 0:
        print u"Non existe ningún xerador para o módulo «{module}».".format(module=modulePath)
Exemple #3
0
    generators.extend(ceg.loadGeneratorList())
    generators.extend(drag.loadGeneratorList())
    generators.extend(iso.loadGeneratorList())
    generators.extend(microsoft.loadGeneratorList())
    generators.extend(santiago.loadGeneratorList())
    generators.extend(udc.loadGeneratorList())
    generators.extend(usc.loadGeneratorList())
    generators.extend(uvigo.loadGeneratorList())
    generators.extend(wikipedia.loadGeneratorList())
    generators.extend(wiktionary.loadGeneratorList())
    return generators


# Program starts.

modulesSourcePath = common.getModulesSourcePath()
generators = loadGeneratorList()

for parameter in [parameter.decode('UTF-8') for parameter in sys.argv[1:]]:
    if parameter.startswith("-"):
        continue
    modulePath = getFirstPathRelativeToSecondPathIfWithin(
        parameter, modulesSourcePath)
    usedGenerators = 0
    for generator in generators:
        if generator.resource.startswith(modulePath):
            print u":: Actualizando «{resource}»…".format(
                resource=generator.resource)
            generator.run()
            usedGenerators += 1
    if usedGenerators == 0:
Exemple #4
0
def writeToResource(content, resource):
    targetPath = os.path.join(common.getModulesSourcePath(), resource)
    createFoldersIfNeeded(os.path.dirname(targetPath))
    with codecs.open(targetPath, u"w", u"utf-8") as fileObject:
        fileObject.write(content)