Exemplo n.º 1
0
def renameId(args):
    inpFiles = glob.glob(g_args.input)
    totalRenamedPoints = 0
    totalIdsChanged = 0
    fCount = 0

    for inpName in inpFiles:
        fHandler = Actions.FileHandler(inpName)
        pointInFileChanged = 0
        idsInFileChanged = 0
        for namespace in args.namespace:
            pointCount, idCount = fHandler.Rename_Id(namespace, args.id,
                                                     args.new)
            pointInFileChanged += pointCount
            idsInFileChanged += idCount

        targetFn = GetTargetFileName(inpName, g_args.output)
        fHandler.writeFile(targetFn, g_args.overwrite)
        Log.getLogger().info("{} IDs, {} dataponts renamed in {}".format(
            idsInFileChanged, pointInFileChanged, inpName))
        totalRenamedPoints += pointInFileChanged
        totalIdsChanged += idsInFileChanged
        if idsInFileChanged > 0:
            fCount += 1

    Log.getLogger().info("Renamed {} ids in {} files, {} datapoints".format(
        totalIdsChanged, fCount, totalRenamedPoints))
Exemplo n.º 2
0
def copyNamespace(args):
    inpFiles = glob.glob(g_args.input)
    totalCopied = 0
    fCount = 0

    for inpName in inpFiles:
        fHandler = Actions.FileHandler(inpName)
        copiedInFileCount = 0
        for namespace in args.namespace:
            copiedInFileCount += fHandler.Copy_Namespace(namespace, args.new)

        targetFn = GetTargetFileName(inpName, g_args.output)
        fHandler.writeFile(targetFn, g_args.overwrite)
        Log.getLogger().info("{} namespaces copied in {}".format(
            copiedInFileCount, inpName))
        totalCopied += copiedInFileCount
        if copiedInFileCount > 0:
            fCount += 1

    Log.getLogger().info("Copied {} namespaces in {} files".format(
        totalCopied, fCount))
Exemplo n.º 3
0
def deleteId(args):
    inpFiles = glob.glob(g_args.input)
    totalDeleted = 0
    fCount = 0

    for inpName in inpFiles:
        fHandler = Actions.FileHandler(inpName)
        deletedFromFileCount = 0
        for namespace in args.namespace:
            deletedFromFileCount += fHandler.Delete_Id(namespace, args.id)

        targetFn = GetTargetFileName(inpName, g_args.output)
        fHandler.writeFile(targetFn, g_args.overwrite)
        Log.getLogger().info("{} datapoints deleted from {}".format(
            deletedFromFileCount, inpName))
        totalDeleted += deletedFromFileCount
        if deletedFromFileCount > 0:
            fCount += 1

    Log.getLogger().info("Deleted {} datapoints  from {} files".format(
        totalDeleted, fCount))
Exemplo n.º 4
0
def deltaId(args):
    inpFiles = glob.glob(g_args.input)
    totalModified = 0
    fCount = 0

    for inpName in inpFiles:
        fHandler = Actions.FileHandler(inpName)
        modifiedFromFileCount = 0
        for namespace in args.namespace:
            modifiedFromFileCount = fHandler.ApplyDelta_Id(
                namespace, args.id, args.delta)

        targetFn = GetTargetFileName(inpName, g_args.output)
        fHandler.writeFile(targetFn, g_args.overwrite)
        Log.getLogger().info("{} datapoints delta's from {}".format(
            modifiedFromFileCount, inpName))
        totalModified += modifiedFromFileCount
        if modifiedFromFileCount > 0:
            fCount += 1

    Log.getLogger().info("delta'd {} datapoints  from {} files".format(
        totalModified, fCount))
Exemplo n.º 5
0
def copyId(args):
    inpFiles = glob.glob(g_args.input)
    totalCopiedPoints = 0

    fCount = 0

    for inpName in inpFiles:
        fHandler = Actions.FileHandler(inpName)

        for namespace in args.namespace:
            pointsCopied = fHandler.Copy_Id(namespace, args.id,
                                            args.newNamespace, args.newId)

        targetFn = GetTargetFileName(inpName, g_args.output)
        fHandler.writeFile(targetFn, g_args.overwrite)
        Log.getLogger().info("{} dataponts copied in {}".format(
            pointsCopied, inpName))
        totalCopiedPoints += pointsCopied

        if pointsCopied > 0:
            fCount += 1

    Log.getLogger().info("Copied {} datapoints in {} files".format(
        totalCopiedPoints, fCount))