def _disabledhelp(path): '''retrieve help synopsis of a disabled extension (without importing)''' try: file = open(path) except IOError: return else: doc = help.moduledoc(file) file.close() if doc: # extracting localized synopsis return gettext(doc).splitlines()[0] else: return _('(no help text available)')
def disabled(): '''find disabled extensions from hgext returns a dict of {name: desc}, and the max name length''' import hgext extpath = os.path.dirname(os.path.abspath(hgext.__file__)) try: # might not be a filesystem path files = os.listdir(extpath) except OSError: return None, 0 exts = {} maxlength = 0 for e in files: if e.endswith('.py'): name = e.rsplit('.', 1)[0] path = os.path.join(extpath, e) else: name = e path = os.path.join(extpath, e, '__init__.py') if not os.path.exists(path): continue if name in exts or name in _order or name == '__init__': continue try: file = open(path) except IOError: continue else: doc = help.moduledoc(file) file.close() if doc: # extracting localized synopsis exts[name] = gettext(doc).splitlines()[0] else: exts[name] = _('(no help text available)') if len(name) > maxlength: maxlength = len(name) return exts, maxlength