Ejemplo n.º 1
0
    def list(cls, category=None, order=None, header=None, output=None):
        """
        lists the default values in the specified format.
        TODO: This method has a bug as it uses format and output,
        only one should be used.

        :param category: the category of the default value. If general is used
                      it is a special category that is used for global values.
        :param format: json, table, yaml, dict, csv
        :param order: The order in which the attributes are returned
        :param output: The output format.
        :return:
        """
        if order is None:
            order, header = None, None
            # order = ['user',
            #         'category',
            #         'name',
            #         'value',
            #         'updated_at']
            # order, header = Attributes(cls.__kind__, provider=cls.__provider__)
        if output is None:
            output = Default.output or 'table'
        try:
            if category is None:
                result = cls.cm.all(kind=cls.__kind__)
            else:
                result = cls.cm.all(category=category, kind=cls.__kind__)

            table = Printer.write(result, output=output)
            return table
        except Exception as e:
            Console.error("Error creating list", traceflag=False)
            Console.error(e.message)
            return None
Ejemplo n.º 2
0
    def list(cls,
             category=None,
             order=None,
             header=None,
             output=None):
        """
        lists the default values in the specified format.
        TODO: This method has a bug as it uses format and output,
        only one should be used.

        :param category: the category of the default value. If general is used
                      it is a special category that is used for global values.
        :param format: json, table, yaml, dict, csv
        :param order: The order in which the attributes are returned
        :param output: The output format.
        :return:
        """
        if order is None:
            order, header = None, None
            # order = ['user',
            #         'category',
            #         'name',
            #         'value',
            #         'updated_at']
            # order, header = Attributes(cls.__kind__, provider=cls.__provider__)
        if output is None:
            output = Default.output or 'table'
        try:
            if category is None:
                result = cls.cm.all(kind=cls.__kind__)
            else:
                result = cls.cm.all(category=category, kind=cls.__kind__)

            table = Printer.write(result,
                                  output=output)
            return table
        except Exception as e:
            Console.error("Error creating list", traceflag=False)
            Console.error(e.message)
            return None