~rajeevs1992/mailman.client/mailmancli

« back to all changes in this revision

Viewing changes to src/mailmanclient/cli/core/lists.py

  • Committer: Rajeev S
  • Date: 2014-07-06 18:37:10 UTC
  • Revision ID: rajeevs1992@gmail.com-20140706183710-19ktzq382c1r9beh
- Initial commit on the command line shell
- commands now support plural and singular forms,
  together, both shell and CL tools
- adds `show` functionality of CLI shell
- adds object filtering class for querying
- adds basic shell environment setup, that 
  supports OnTheFly addition of variables

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
        except HTTPError:
64
64
            raise ListException('List already exists')
65
65
 
66
 
    def get_listing(self, domain, detailed, hide_header):
 
66
    def get_listing(self, domain, detailed, hide_header, lists_ext):
67
67
        """Returns list of mailing lists, formatted for tabulation.
68
68
 
69
69
            :param domain: Domain name
72
72
            :type detailed: boolean
73
73
            :param hide_header: Remove header
74
74
            :type hide_header: boolean
 
75
            :param lists_ext: External array of lists
 
76
            :type hide_header: array
75
77
        """
76
78
        lists = self.client.lists
77
79
        table = []
81
83
            else:
82
84
                headers = ['ID', 'Name', 'Mail host', 'Display Name', 'FQDN']
83
85
            table.append(headers)
 
86
            if lists_ext is not None:
 
87
                lists = lists_ext
84
88
            if domain is not None:
85
89
                try:
86
90
                    domain = self.client.get_domain(domain)
117
121
                    table.append([i.list_id])
118
122
        return table
119
123
 
120
 
    def show(self, args):
 
124
    def show(self, args, lists_ext=None):
121
125
        """List the mailing lists in the system or under a domain.
122
126
 
123
127
           :param args: Commandline arguments
129
133
        domain_name = args['domain']
130
134
        longlist = args['verbose']
131
135
        hide_header = args['no_header']
132
 
        table = self.get_listing(domain_name, longlist, hide_header)
 
136
        table = self.get_listing(domain_name, longlist, hide_header, lists_ext)
133
137
        headers = table[0]
134
138
        try:
135
139
            table = table[1:]