# Path: crmsh/utils.py
# def page_string(s):
#     'Page string rendered for TERM.'
#     if not s:
#         return
#     constants.need_reset = True
#     w, h = get_winsize()
#     if not need_pager(s, w, h):
#         print(term_render(s))
#     elif not config.core.pager or not can_ask() or options.batch:
#         print(term_render(s))
#     else:
#         pipe_string(get_pager_cmd(), term_render(s).encode('utf-8'))
#     constants.need_reset = False
# 
# def get_stdout_stderr(cmd, input_s=None, shell=True, raw=False, no_reg=False):
#     '''
#     Run a cmd, return (rc, stdout, stderr)
#     '''
#     if options.regression_tests and not no_reg:
#         print(".EXT", cmd)
#     proc = subprocess.Popen(cmd,
#                             shell=shell,
#                             stdin=input_s and subprocess.PIPE or None,
#                             stdout=subprocess.PIPE,
#                             stderr=subprocess.PIPE)
#     stdout_data, stderr_data = proc.communicate(input_s)
#     if raw:
#         return proc.returncode, stdout_data, stderr_data
#     return proc.returncode, to_ascii(stdout_data).strip(), to_ascii(stderr_data).strip()
# 
# Path: crmsh/ordereddict.py
# class OrderedDict(dict, DictMixin):
#     def __init__(self, *args, **kwds):
#     def clear(self):
#     def __setitem__(self, key, value):
#     def __delitem__(self, key):
#     def __iter__(self):
#     def __reversed__(self):
#     def popitem(self, last=True):
#     def __reduce__(self):
#     def keys(self):
#     def __repr__(self):
#     def copy(self):
#     def fromkeys(cls, iterable, value=None):
#     def __eq__(self, other):
#     def __ne__(self, other):


import os
import re
from .utils import page_string, get_stdout_stderr
from . import config
from . import clidisplay
from .ordereddict import odict
from . import log
    from .command import fuzzy_get
    from .command import fuzzy_get
    from .command import fuzzy_get
    from .command import fuzzy_get
    from .command import fuzzy_get
        from .ui_root import Root
            entry['type'] = 'topic'
            entry['name'] = info[-1]
        elif info[0] == 'cmdhelp':
            if len(info) == 2:
                entry['type'] = 'level'
                entry['name'] = info[1]
            elif len(info) >= 3:
                entry['type'] = 'command'
                entry['level'] = info[1]
                entry['name'] = '_'.join(info[2:])

        return entry

    def process(entry):
        'writes the entry into topics/levels/commands'
        short_help = entry['short']
        long_help = entry['long']
        if long_help.startswith('=='):
            long_help = long_help.split('\n', 1)[1]
        helpobj = HelpEntry(short_help, long_help.rstrip())
        name = entry['name']
        if entry['type'] == 'topic':
            _TOPICS[name] = helpobj
        elif entry['type'] == 'level':
            _LEVELS[name] = helpobj
        elif entry['type'] == 'command':
            lvl = entry['level']
            if lvl not in _COMMANDS:
                _COMMANDS[lvl] = odict()
            if entry['from_cli']:

# Path: crmsh/utils.py
# def page_string(s):
#     'Page string rendered for TERM.'
#     if not s:
#         return
#     constants.need_reset = True
#     w, h = get_winsize()
#     if not need_pager(s, w, h):
#         print(term_render(s))
#     elif not config.core.pager or not can_ask() or options.batch:
#         print(term_render(s))
#     else:
#         pipe_string(get_pager_cmd(), term_render(s).encode('utf-8'))
#     constants.need_reset = False
# 
# def get_stdout_stderr(cmd, input_s=None, shell=True, raw=False, no_reg=False):
#     '''
#     Run a cmd, return (rc, stdout, stderr)
#     '''
#     if options.regression_tests and not no_reg:
#         print(".EXT", cmd)
#     proc = subprocess.Popen(cmd,
#                             shell=shell,
#                             stdin=input_s and subprocess.PIPE or None,
#                             stdout=subprocess.PIPE,
#                             stderr=subprocess.PIPE)
#     stdout_data, stderr_data = proc.communicate(input_s)
#     if raw:
#         return proc.returncode, stdout_data, stderr_data
#     return proc.returncode, to_ascii(stdout_data).strip(), to_ascii(stderr_data).strip()
# 
# Path: crmsh/ordereddict.py
# class OrderedDict(dict, DictMixin):
#     def __init__(self, *args, **kwds):
#     def clear(self):
#     def __setitem__(self, key, value):
#     def __delitem__(self, key):
#     def __iter__(self):
#     def __reversed__(self):
#     def popitem(self, last=True):
#     def __reduce__(self):
#     def keys(self):
#     def __repr__(self):
#     def copy(self):
#     def fromkeys(cls, iterable, value=None):
#     def __eq__(self, other):
#     def __ne__(self, other):


# Path: crmsh/help.py
import os
import re
from .utils import page_string, get_stdout_stderr
from . import config
from . import clidisplay
from .ordereddict import odict
from . import log
    from .command import fuzzy_get
    from .command import fuzzy_get
    from .command import fuzzy_get
    from .command import fuzzy_get
    from .command import fuzzy_get
        from .ui_root import Root

            entry['type'] = 'topic'
            entry['name'] = info[-1]
        elif info[0] == 'cmdhelp':
            if len(info) == 2:
                entry['type'] = 'level'
                entry['name'] = info[1]
            elif len(info) >= 3:
                entry['type'] = 'command'
                entry['level'] = info[1]
                entry['name'] = '_'.join(info[2:])

        return entry

    def process(entry):
        'writes the entry into topics/levels/commands'
        short_help = entry['short']
        long_help = entry['long']
        if long_help.startswith('=='):
            long_help = long_help.split('\n', 1)[1]
        helpobj = HelpEntry(short_help, long_help.rstrip())
        name = entry['name']
        if entry['type'] == 'topic':
            _TOPICS[name] = helpobj
        elif entry['type'] == 'level':
            _LEVELS[name] = helpobj
        elif entry['type'] == 'command':
            lvl = entry['level']
            if lvl not in _COMMANDS:
                _COMMANDS[lvl] = odict()
            if entry['from_cli']:

                _, help_output, _ = get_stdout_stderr("crm {} {} --help".format(lvl, name))