File: encoding.py

package info (click to toggle)
python-cliff 4.9.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 652 kB
  • sloc: python: 5,218; makefile: 32; sh: 21
file content (19 lines) | stat: -rw-r--r-- 410 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import logging

from cliff.lister import Lister


class Encoding(Lister):
    """Show some unicode text"""

    log = logging.getLogger(__name__)

    def take_action(self, parsed_args):
        messages = [
            'pi: π',
            'GB18030:鼀丅㐀ٸཌྷᠧꌢ€',
        ]
        return (
            ('UTF-8', 'Unicode'),
            [(repr(t.encode('utf-8')), t) for t in messages],
        )