asn1editor package¶
Subpackages¶
- asn1editor.controller package
- Submodules
- asn1editor.controller.ChoiceInstanceFactory module
- asn1editor.controller.Controller module
- asn1editor.controller.ControllerFactory module
ControllerFactory
ControllerFactory.create_bitstring_controller()
ControllerFactory.create_bool_controller()
ControllerFactory.create_choice_controller()
ControllerFactory.create_container_controller()
ControllerFactory.create_list_controller()
ControllerFactory.create_null_controller()
ControllerFactory.create_value_controller()
- asn1editor.controller.Converter module
- asn1editor.controller.ListInstanceFactory module
- Module contents
- asn1editor.interfaces package
- asn1editor.view package
- Submodules
- asn1editor.view.AbstractView module
- asn1editor.view.AbstractViewFactory module
AbstractViewFactory
AbstractViewFactory.get_bitstring_view()
AbstractViewFactory.get_boolean_view()
AbstractViewFactory.get_choice_view()
AbstractViewFactory.get_container_view()
AbstractViewFactory.get_date_view()
AbstractViewFactory.get_datetime_view()
AbstractViewFactory.get_enumerated_view()
AbstractViewFactory.get_hex_string_view()
AbstractViewFactory.get_list_view()
AbstractViewFactory.get_number_view()
AbstractViewFactory.get_string_view()
AbstractViewFactory.get_text_view()
AbstractViewFactory.get_time_view()
Styles
TypeInfo
- Module contents
- asn1editor.wxPython package
- Submodules
- asn1editor.wxPython.Environment module
- asn1editor.wxPython.FilePickerHandler module
- asn1editor.wxPython.ImageList module
- asn1editor.wxPython.MainWindow module
MainWindow
MainWindow.choice_entry()
MainWindow.close()
MainWindow.dir_picker()
MainWindow.encode_data()
MainWindow.file_picker()
MainWindow.get_settings()
MainWindow.get_spec()
MainWindow.get_spec_filename()
MainWindow.get_typename()
MainWindow.load_data_from_file()
MainWindow.load_spec()
MainWindow.save_data_to_file()
MainWindow.select_view_and_tag_info()
MainWindow.show_data()
MainWindow.show_message()
MainWindow.show_progress()
MainWindow.show_status()
MainWindow.text_entry()
MainWindow.update_progress()
- asn1editor.wxPython.MenuHandler module
- asn1editor.wxPython.Resources module
- asn1editor.wxPython.SingleFileDropTarget module
- asn1editor.wxPython.Styler module
- asn1editor.wxPython.TreeView module
- asn1editor.wxPython.ViewSelect module
- asn1editor.wxPython.WxPythonComplexViews module
- asn1editor.wxPython.WxPythonViewFactory module
WxPythonViewFactory
WxPythonViewFactory.get_bitstring_view()
WxPythonViewFactory.get_boolean_view()
WxPythonViewFactory.get_choice_view()
WxPythonViewFactory.get_container_view()
WxPythonViewFactory.get_date_view()
WxPythonViewFactory.get_datetime_view()
WxPythonViewFactory.get_enumerated_view()
WxPythonViewFactory.get_hex_string_view()
WxPythonViewFactory.get_list_view()
WxPythonViewFactory.get_number_view()
WxPythonViewFactory.get_string_view()
WxPythonViewFactory.get_text_view()
WxPythonViewFactory.get_time_view()
- asn1editor.wxPython.WxPythonViews module
- Module contents
MainWindow
MainWindow.choice_entry()
MainWindow.close()
MainWindow.dir_picker()
MainWindow.encode_data()
MainWindow.file_picker()
MainWindow.get_settings()
MainWindow.get_spec()
MainWindow.get_spec_filename()
MainWindow.get_typename()
MainWindow.load_data_from_file()
MainWindow.load_spec()
MainWindow.save_data_to_file()
MainWindow.select_view_and_tag_info()
MainWindow.show_data()
MainWindow.show_message()
MainWindow.show_progress()
MainWindow.show_status()
MainWindow.text_entry()
MainWindow.update_progress()
Submodules¶
asn1editor.ASN1SpecHandler module¶
- class asn1editor.ASN1SpecHandler.ASN1SpecHandler(file_name: str | List[str])¶
Bases:
object
Represents a loaded ASN.1 spec and creates views and controllers for this specification
- IMPORTS_REGEX_INNER = re.compile('FROM\\s*(\\S*)', re.MULTILINE)¶
- IMPORTS_REGEX_OUTER = re.compile('IMPORTS([\\s\\S]*);', re.MULTILINE)¶
- create_view_controller_for_type(load_type: str, view_factory: AbstractViewFactory, type_augmenter: TypeAugmenter | None) Tuple[AbstractView, Controller] ¶
Creates a view and a controller for a given type name. The type name must be a full type name, e.g. ‘my_module.my_type’, including the module name of the loaded ASN.1 spec. If the type name is not found in the loaded ASN.1 spec, a ValueError is raised.
@param load_type: The type name to create a model-view-controller for @param view_factory: The view factory to use for creating the view, performs the connection to a view implementation @param type_augmenter: The type augmenter to use for creating the view @return: A tuple of the root view and the controller
- get_compiled(codec: str) Specification ¶
Returns the compiled ASN.1 specification (using asn1tools)
@param codec: ASN.1 coded, see asn1tools.compile_files for a list of valid codecs
- get_data_from_model(model: Dict, codec: str) bytes ¶
Converts a model to a byte sequence according to the loaded specification.
- static get_extensions() List[str] ¶
Returns the list of file extensions that are supported to load data from or save data to
- get_filenames() List[str] ¶
Returns the file name of the ASN.1 spec loaded and names of dependent ASN.1 spec files
- get_model_from_data(data: bytes, codec: str) Dict ¶
Decodes a byte sequence to a model according to the loaded specification.
- get_types() List[str] ¶
Returns a list of all type names that are defined in the loaded ASN.1 spec
- is_loaded(file_name: str)¶
Returns true if a given file name is loaded
- load_data_file(file_name: str) Dict ¶
Loads data according to the current specification from a given file and returns the model as a dictionary.
- save_data_file(file_name: str, model: Dict)¶
Saves the data from a passed model to a file using the loaded specification.
asn1editor.Plugin module¶
- class asn1editor.Plugin.Plugin¶
Bases:
object
Base class for all plugins.
The methods in this class are used by the UI to display the menus and toolbar items the plugin provides and to perform given callbacks when the user interacts with these menu items.
Additionally, the function connect is called during startup and serves to register the PluginInterface to enable the plugin to access data in the loaded ASN.1 specification and to further interact with the user.
- connect(plugin_interface: <module 'asn1editor.PluginInterface' from '/home/docs/checkouts/readthedocs.org/user_builds/asn1editor/checkouts/latest/asn1editor/PluginInterface.py'>)¶
Connects the plugin host and the plugin.
The function will be called during startup and serves to register the PluginInterface.
@param plugin_interface: Object that implements the PluginInterface.
- get_about() str | None ¶
Gets an optional about-box string.
Returns an optional about-box string that will be displayed in the about-box of the plugin.
Get the menus required by the plugin.
Returns a list of strings and callables, where the string is the menu caption and the callable a callback that will be executed when the menu item is selected.
- get_name() str ¶
Returns the name of a plugin - used to name the menu item folder
- get_tools() List[Tuple[str, str, str, Callable]] ¶
Get the toolbar items required by the plugin.
Returns a list of strings and callables, where the strings are the label, the tool tip and a path to an icon, the callable a callback that will be executed when the menu item is selected.
asn1editor.PluginInterface module¶
- class asn1editor.PluginInterface.PluginInterface¶
Bases:
object
Interface for a plugin to access data and means of interaction from asn1editor.
- class MessageType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
Enum
Type of popup message
- ERROR = 3¶
- INFO = 1¶
- QUESTION = 4¶
- WARNING = 2¶
- choice_entry(message: str, caption: str, choices: List[str], default: str | None = None) str | None ¶
Queries the user for a choice of values.
@param message: Message to show to the user @param caption: Message box caption @param choices: List of strings for the user to choose from @param default: Default selection
@return: Selected string, None if cancelled
- dir_picker(message: str) str | None ¶
Opens a dir picker where the user can choose a directory name and returns this chosen name.
@param message: Message to show in the dir picker
@return: Selected directory, None if cancelled
- encode_data(codec: str) bytes ¶
Encodes the data currently edited in the editor window with an ASN.1 codec.
@param codec: Codec to use for encoding (reference asn1tools which ones are supported)
@return: Encoded data
- file_picker(message: str, wildcard: str, open_: bool) str | None ¶
Opens a file picker where the user can choose a file name and returns this chosen name.
@param message: Message to show in the file picker @param wildcard: Wildcards to offer the user in order to help him choose the correct file types @param open_: Flag if the dialog shall be an open dialog (True) or a save dialog (false)
@return: Selected file, None if cancelled
- get_settings() dict ¶
Get a settings dictionary for a plugin to store persistent data
@return: Settings dict
- get_spec(codec: str) Specification ¶
@param codec: Codec to use (reference asn1tools which ones are supported)
@return: The compiled ASN.1 specification as an object defined by asn1tools.
- get_spec_filename() str | None ¶
@return: The file name of the ASN.1 specification file currently loaded.
- get_typename() str | None ¶
@return: The name of the currently used type name in the editor.
- load_spec(file_name: str, type_name: str | None = None) bool ¶
Loads an ASN.1 specification in the editor.
@param file_name: File name of the ASN.1 specification @param type_name: Optional type name indication. Format: [Module name].[Type name]
@return: True if data was loaded successfully
- show_data(data: bytes, codec: str)¶
Decodes and shows data from an ASN.1 encoded byte stream in the editor.
@param data: Byte stream with ASN.1 encoded data @param codec: Codec to use for decoding (reference asn1tools which ones are supported)
- show_message(message: str, caption: str, message_type: MessageType) bool ¶
Shows a status message.
@param message: Message to show to the user @param caption: Message box caption @param message_type: Type of message box
@return: If type is a question, True means yes and False means No
- show_progress(message: str, caption: str, max_progress: int | None = None)¶
Shows a progress window
@param message: Message to show to the user @param caption: Message box caption @param max_progress: Maximum progress value
- show_status(message: str)¶
Shows a status message.
@param message: Message to show to the user
- text_entry(message: str, default: str | None = None) str | None ¶
Queries a text from the user.
@param message: Message to show to the user @param default: Default value for the text entry
@return: Entered text, None if cancelled
- update_progress(message: str | None = None, close: bool = False, progress: int | None = None) bool ¶
Updates a shown progress window
@param message: Updated message to show to the user, optional @param close: If set, window is closed, optional @param progress: Progress to show, if none, an indeterminate process is shown, optional
@return: False if progress window has been canceled, otherwise True
asn1editor.ViewControllerFactory module¶
- class asn1editor.ViewControllerFactory.ViewControllerFactory(view_factory: AbstractViewFactory, type_augmenter: TypeAugmenter | None)¶
Bases:
object
Creates views and corresponding controllers.
The class requires a view factory for the GUI implementation and an optional type augmenter that provides additional information about a given type.
- create(asn1_type: CompiledType) Tuple[AbstractView, Controller] ¶
Creates the root view and root controller for a loaded ASN.1 specification.
Needs to be called after loading a specification @param asn1_type: Compiled ASN.1 specification @return: Root view and root controller
- create_view_and_controller(type_: Type, checker: Type, controller: Controller) AbstractView ¶
Creates the view and controller for a given ASN.1 type.
The function only returns the view because the controller will register automatically with its parent, while the views are connected via return types.
The reason here is that the controllers are all in the context of asn1editor and cannot be changed, while the views are interchangeable.
@param type_: Compiled ASN.1 type @param checker: Constraints checker object to provide constraints info about the type @param controller: Parent controller @return: View for the type
Module contents¶
- class asn1editor.Plugin¶
Bases:
object
Base class for all plugins.
The methods in this class are used by the UI to display the menus and toolbar items the plugin provides and to perform given callbacks when the user interacts with these menu items.
Additionally, the function connect is called during startup and serves to register the PluginInterface to enable the plugin to access data in the loaded ASN.1 specification and to further interact with the user.
- connect(plugin_interface: <module 'asn1editor.PluginInterface' from '/home/docs/checkouts/readthedocs.org/user_builds/asn1editor/checkouts/latest/asn1editor/PluginInterface.py'>)¶
Connects the plugin host and the plugin.
The function will be called during startup and serves to register the PluginInterface.
@param plugin_interface: Object that implements the PluginInterface.
- get_about() str | None ¶
Gets an optional about-box string.
Returns an optional about-box string that will be displayed in the about-box of the plugin.
Get the menus required by the plugin.
Returns a list of strings and callables, where the string is the menu caption and the callable a callback that will be executed when the menu item is selected.
- get_name() str ¶
Returns the name of a plugin - used to name the menu item folder
- get_tools() List[Tuple[str, str, str, Callable]] ¶
Get the toolbar items required by the plugin.
Returns a list of strings and callables, where the strings are the label, the tool tip and a path to an icon, the callable a callback that will be executed when the menu item is selected.
- class asn1editor.PluginInterface¶
Bases:
object
Interface for a plugin to access data and means of interaction from asn1editor.
- class MessageType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
Enum
Type of popup message
- ERROR = 3¶
- INFO = 1¶
- QUESTION = 4¶
- WARNING = 2¶
- choice_entry(message: str, caption: str, choices: List[str], default: str | None = None) str | None ¶
Queries the user for a choice of values.
@param message: Message to show to the user @param caption: Message box caption @param choices: List of strings for the user to choose from @param default: Default selection
@return: Selected string, None if cancelled
- dir_picker(message: str) str | None ¶
Opens a dir picker where the user can choose a directory name and returns this chosen name.
@param message: Message to show in the dir picker
@return: Selected directory, None if cancelled
- encode_data(codec: str) bytes ¶
Encodes the data currently edited in the editor window with an ASN.1 codec.
@param codec: Codec to use for encoding (reference asn1tools which ones are supported)
@return: Encoded data
- file_picker(message: str, wildcard: str, open_: bool) str | None ¶
Opens a file picker where the user can choose a file name and returns this chosen name.
@param message: Message to show in the file picker @param wildcard: Wildcards to offer the user in order to help him choose the correct file types @param open_: Flag if the dialog shall be an open dialog (True) or a save dialog (false)
@return: Selected file, None if cancelled
- get_settings() dict ¶
Get a settings dictionary for a plugin to store persistent data
@return: Settings dict
- get_spec(codec: str) Specification ¶
@param codec: Codec to use (reference asn1tools which ones are supported)
@return: The compiled ASN.1 specification as an object defined by asn1tools.
- get_spec_filename() str | None ¶
@return: The file name of the ASN.1 specification file currently loaded.
- get_typename() str | None ¶
@return: The name of the currently used type name in the editor.
- load_spec(file_name: str, type_name: str | None = None) bool ¶
Loads an ASN.1 specification in the editor.
@param file_name: File name of the ASN.1 specification @param type_name: Optional type name indication. Format: [Module name].[Type name]
@return: True if data was loaded successfully
- show_data(data: bytes, codec: str)¶
Decodes and shows data from an ASN.1 encoded byte stream in the editor.
@param data: Byte stream with ASN.1 encoded data @param codec: Codec to use for decoding (reference asn1tools which ones are supported)
- show_message(message: str, caption: str, message_type: MessageType) bool ¶
Shows a status message.
@param message: Message to show to the user @param caption: Message box caption @param message_type: Type of message box
@return: If type is a question, True means yes and False means No
- show_progress(message: str, caption: str, max_progress: int | None = None)¶
Shows a progress window
@param message: Message to show to the user @param caption: Message box caption @param max_progress: Maximum progress value
- show_status(message: str)¶
Shows a status message.
@param message: Message to show to the user
- text_entry(message: str, default: str | None = None) str | None ¶
Queries a text from the user.
@param message: Message to show to the user @param default: Default value for the text entry
@return: Entered text, None if cancelled
- update_progress(message: str | None = None, close: bool = False, progress: int | None = None) bool ¶
Updates a shown progress window
@param message: Updated message to show to the user, optional @param close: If set, window is closed, optional @param progress: Progress to show, if none, an indeterminate process is shown, optional
@return: False if progress window has been canceled, otherwise True
- class asn1editor.TypeAugmenter¶
Bases:
object
Class to be implemented to provide additional styling info and help texts for ASN.1 elements.
Intention is to have a database/parallel file to the ASN.1 specification that provides user configurable meta information
- get_help(path: str) str | None ¶
@param path: Path of the element @return: Optional help text
- set_spec_filename(spec_filename: str)¶
Set when a new spec was loaded to indicate which ASN.1 specification further requests are based on. @param spec_filename: File name of loaded spec
- asn1editor.WxPythonMainWindow¶
alias of
MainWindow