Exemple #1
0
    def __getTableInfo(cls, tableName, target):

        try:
            nameField = target.get("nameField", None)
            if not nameField:
                nameField = TableInfo.getNameField(tableName)
            contentField = target.get("contentField", None)
            if not contentField:
                contentField = TableInfo.getContentField(tableName)

        except KeyError:
            sys.stderr.write(
                "No name_field or content_field parameter in target information, and no default information about table %s, ignoring\n"
                % tableName
            )
            return None

        transformName = target.get("transformName", None)
        if not transformName:
            try:
                fileExtension = TableInfo.getFileExtension(tableName)
            except KeyError:
                fileExtension = "txt"
            transformName = lambda name: "%s.%s" % (
                name.replace(" ", "-").replace("/", "-").replace("(", "[").replace(")", "]"),
                fileExtension,
            )

        return (nameField, contentField, transformName)
Exemple #2
0
    def _getTableInfo(cls, tableName):
        try:
            nameField = Config.getNameField()
            if not nameField:
                nameField = TableInfo.getNameField(tableName)

            contentField = Config.getContentField()
            if not contentField:
                contentField = TableInfo.getContentField(tableName)

        except KeyError:
            sys.stderr.write(
                "No name_field or content_field parameter and no default information about table %s, aborting\n"
                % tableName
            )
            sys.exit(1)

        try:
            fileExtension = TableInfo.getFileExtension(tableName)
        except KeyError:
            fileExtension = ".txt"

        return (nameField, contentField, fileExtension)