- hashlib: add usedforsecurity=False to all md5/sha1/sha256/sha512 calls
(FIPS-mode compatibility, ~34 call sites across 13 files)
- join([listcomp]): convert to generator expressions (~15 sites)
- class Foo(object): -> class Foo: across all files (Python 3 style)
- collections.OrderedDict() -> {} in db/skel.py (Python 3.7+ dicts ordered)
- open() without context manager: fix 3 bare open/close in misc.py
- Exception chaining: add 'from err' to raise statements in portage_plugin
- const_is_python3() dead code removal:
* Simplify 7 compat functions in const.py (const_is_python3,
const_get_stringtype, const_isunicode, const_israwstring,
const_get_buffer, const_convert_to_unicode, const_convert_to_rawstring,
const_isstring, const_get_int) — remove Python 2 branches
* Remove 100+ const_is_python3() if/else branches across 27 files,
keeping only the Python 3 path
* Remove cPickle import in dump.py, use plain pickle with fix_imports=True
* Remove urllib2 dead imports in misc.py, fetchers.py
* Clean up const_is_python3 from all import lines
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
74 lines
1.7 KiB
Python
74 lines
1.7 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""
|
|
|
|
@author: Fabio Erculiani <lxnay@sabayon.org>
|
|
@contact: lxnay@sabayon.org
|
|
@copyright: Fabio Erculiani
|
|
@license: GPL-2
|
|
|
|
B{Entropy Infrastructure Toolkit}.
|
|
Eit Command descriptor class.
|
|
|
|
"""
|
|
|
|
class EitCommandDescriptor:
|
|
"""
|
|
EitCommand descriptor object used for
|
|
help information purposes.
|
|
"""
|
|
|
|
EIT_COMMANDS = []
|
|
EIT_COMMANDS_MAP = {}
|
|
|
|
@staticmethod
|
|
def register(descriptor):
|
|
"""
|
|
Register an EitCommandDescriptor object
|
|
"""
|
|
EitCommandDescriptor.EIT_COMMANDS.append(descriptor)
|
|
EitCommandDescriptor.EIT_COMMANDS_MAP[descriptor.get_name()] = \
|
|
descriptor
|
|
|
|
@staticmethod
|
|
def obtain():
|
|
"""
|
|
Get the list of registered EitCommandDescriptor object
|
|
"""
|
|
return EitCommandDescriptor.EIT_COMMANDS[:]
|
|
|
|
@staticmethod
|
|
def obtain_descriptor(name):
|
|
"""
|
|
Get a registered EitCommandDescritor object
|
|
through its name.
|
|
|
|
@param name: name of the EitCommandDescriptor
|
|
@type name: string
|
|
@raise KeyError: if name isn't bound to any
|
|
EitCommandDescriptor object.
|
|
"""
|
|
return EitCommandDescriptor.EIT_COMMANDS_MAP[name]
|
|
|
|
def __init__(self, klass, name, description):
|
|
self._klass = klass
|
|
self._name = name
|
|
self._description = description
|
|
|
|
def get_class(self):
|
|
"""
|
|
Get EitCommand class bound to this command
|
|
"""
|
|
return self._klass
|
|
|
|
def get_name(self):
|
|
"""
|
|
Get EitCommand name
|
|
"""
|
|
return self._name
|
|
|
|
def get_description(self):
|
|
"""
|
|
Get EitCommand description
|
|
"""
|
|
return self._description
|