createstubs_mem =============== .. py:module:: createstubs_mem .. autoapi-nested-parse:: Create stubs for (all) modules on a MicroPython board. This variant of the createstubs.py script is optimised for use on low-memory devices, and reads the list of modules from a text file `modulelist.txt` in the root or `libs` folder that should be uploaded to the device. If that cannot be found then only a single module (micropython) is stubbed. In order to run this on low-memory devices two additional steps are recommended: - minifification, using python-minifier to reduce overall size, and remove logging overhead. - cross compilation, using mpy-cross, to avoid the compilation step on the micropython device This variant was generated from createstubs.py by micropython-stubber v1.28.3 Attributes ---------- .. autoapisummary:: createstubs_mem._LOW_MEM_PORTS createstubs_mem._is_low_mem_port createstubs_mem._has_inspect createstubs_mem._has_inspect createstubs_mem.__version__ createstubs_mem.ENOENT createstubs_mem.ENOMESSAGE createstubs_mem._MAX_CLASS_LEVEL createstubs_mem.LIBS createstubs_mem.log Classes ------- .. autoapisummary:: createstubs_mem.logging createstubs_mem.Stubber Functions --------- .. autoapisummary:: createstubs_mem.reset createstubs_mem.ensure_folder createstubs_mem._build createstubs_mem._get_base_system_info createstubs_mem._normalize_port_info createstubs_mem._extract_version_info createstubs_mem._extract_hardware_info createstubs_mem._extract_build_info createstubs_mem._detect_firmware_family createstubs_mem._process_micropython_version createstubs_mem._process_mpy_info createstubs_mem._format_version_strings createstubs_mem._info createstubs_mem._version_str createstubs_mem.get_boardname createstubs_mem.get_root createstubs_mem.file_exists createstubs_mem.show_help createstubs_mem.read_path createstubs_mem.is_micropython createstubs_mem.main Module Contents --------------- .. py:function:: reset() .. py:data:: _LOW_MEM_PORTS :value: ('esp8266',) .. py:data:: _is_low_mem_port :value: False .. py:data:: _has_inspect :value: False .. py:data:: _has_inspect :value: True .. py:data:: __version__ :value: 'v1.28.3' .. py:data:: ENOENT :value: 2 .. py:data:: ENOMESSAGE :value: 44 .. py:data:: _MAX_CLASS_LEVEL :value: 2 .. py:data:: LIBS :value: ['lib', '/lib', '/sd/lib', '/flash/lib', '.'] .. py:class:: logging .. py:attribute:: DEBUG :value: 10 .. py:attribute:: INFO :value: 20 .. py:attribute:: WARNING :value: 30 .. py:attribute:: ERROR :value: 40 .. py:attribute:: level :value: 20 .. py:attribute:: prnt .. py:method:: getLogger(name) :staticmethod: .. py:method:: basicConfig(level) :classmethod: .. py:method:: debug(msg) .. py:method:: info(msg) .. py:method:: warning(msg) .. py:method:: error(msg) .. py:data:: log .. py:class:: Stubber(path: str = '', firmware_id: str = '') Generate stubs for modules in firmware .. py:attribute:: info .. py:attribute:: _is_low_mem_port .. py:attribute:: _capture_docstrings .. py:attribute:: _use_inspect .. py:attribute:: _start_free .. py:attribute:: path .. py:attribute:: problematic :value: ['upip', 'upysh', 'webrepl_setup', 'http_client', 'http_client_ssl', 'http_server', 'http_server_ssl'] .. py:attribute:: excluded :value: ['webrepl', '_webrepl', 'port_diag', 'example_sub_led.py', 'example_pub_button.py'] .. py:attribute:: modules :type: list[str] :value: [] .. py:attribute:: _json_name :value: None .. py:attribute:: _json_first :value: False .. py:method:: load_exlusions() .. py:method:: get_obj_attributes(item_instance: object) extract information of the objects members and attributes .. py:method:: add_modules(modules) Add additional modules to be exported .. py:method:: create_all_stubs() Create stubs for all configured modules .. py:method:: create_one_stub(module_name: str) .. py:method:: create_module_stub(module_name: str, file_name: str = None) -> bool Create a Stub of a single python module Args: - module_name (str): name of the module to document. This module will be imported. - file_name (Optional[str]): the 'path/filename.pyi' to write to. If omitted will be created based on the module name. .. py:method:: write_shallow_stub(fp, module_obj: object) .. py:method:: write_object_stub(fp, object_expr: object, obj_name: str, indent: str, in_class: int = 0) Write a module/object stub to an open file. Can be called recursive. .. py:property:: flat_fwid Turn _fwid from 'v1.2.3' into '1_2_3' to be used in filename .. py:method:: clean(path: str = '') Remove all files from the stub folder .. py:method:: report_start(filename: str = 'modules.json') Start a report of the modules that have been stubbed "create json with list of exported modules .. py:method:: report_add(module_name: str, stub_file: str) Add a module to the report .. py:method:: report_end() .. py:function:: ensure_folder(path: str) Create nested folders if needed .. py:function:: _build(s) .. py:function:: _get_base_system_info() -> collections.OrderedDict[str, str] Get basic system implementation details. .. py:function:: _normalize_port_info(info: collections.OrderedDict[str, str]) -> None Normalize port names to be consistent with the repo. .. py:function:: _extract_version_info(info: collections.OrderedDict[str, str]) -> None Extract version information from sys.implementation. .. py:function:: _extract_hardware_info(info: collections.OrderedDict[str, str]) -> None Extract board, CPU, and machine details. .. py:function:: _extract_build_info(info: collections.OrderedDict[str, str]) -> None Extract build information from various system sources. .. py:function:: _detect_firmware_family(info: collections.OrderedDict[str, str]) -> None Detect special firmware families (pycopy, pycom, ev3-pybricks). .. py:function:: _process_micropython_version(info: collections.OrderedDict[str, str]) -> None Process MicroPython-specific version formatting. .. py:function:: _process_mpy_info(info: collections.OrderedDict[str, str]) -> None Process MPY architecture and version information. .. py:function:: _format_version_strings(info: collections.OrderedDict[str, str]) -> None Handle final version string formatting. .. py:function:: _info() -> dict[str, str] Gather comprehensive system information for MicroPython stubbing. Returns a dictionary containing family, version, port, board, and other system details needed for stub generation. .. py:function:: _version_str(version: tuple) .. py:function:: get_boardname(info: dict) -> None Read the board_id from the boardname.py file that may have been created upfront .. py:function:: get_root() -> str Determine the root folder of the device .. py:function:: file_exists(filename: str) .. py:function:: show_help() .. py:function:: read_path() -> str get --path from cmdline. [unix/win] .. py:function:: is_micropython() -> bool runtime test to determine full or micropython .. py:function:: main()