Skip to main content

Python2SOMIX

Extract SOMIX model from Python code

What is it for?

It allows to visualize Python code and the relations due to calls, accesses and grouping.

See the following example with two Python files:

test1.py

# test1.py remains unchanged
class ClassOne:
    class_variable = 100

    def __init__(self):
        self.instance_variable = 0
        ClassOne.class_variable += 1  # Fixed class variable increment

    def method_one(self):
        self.instance_variable += 1
        print("ClassOne method_one called")

def function_one():
    print("function_one called")

test2.py

# Updated test2.py with type annotations
from test1 import ClassOne, function_one

class ClassTwo:
    def method_two(self):
        obj = ClassOne()
        obj.method_one()
        function_one()
        print("ClassTwo method_two called")

    def method_three(self, my_obj: ClassOne):
        # To check that usage is also found when ClassOne is passed as an argument
        my_obj.method_one()

def function_two():
    obj = ClassOne()
    obj.method_one()
    function_one()
    print("function_two called")

Use Python2SOMIX to extract an mse file to display diagrams in Moose2Model. Go to www.moose2model.org to do this. This website uses only simple JavaScript coding and can also be run locally.

You may display all parts in a diagram like this:

Force-attraction-diagram of all elements

Or construct diagrams which may contain only parts of the application together with coding. These are easy to keep correct when the code changes. You can also easily jump to an editor from the diagram.

Demo Diagram of the two test classes

How to run

start the script in the terminal with

python .\python2somix.py

See parameter -h or --help for available options.

The script will ask for the path to the folder where the python code is saved.

You may place a configuration file in the same folder as python2somix.py to specify which folder is to be read and where the output file is to be placed:

Exact name of the file: config_python2somix.txt

# Configuration file
base_path=/path/to/your/base/folder
output_path=/path/to/output/directory

To find usages of methods when the instance is passed to a parameter, you have to annotate the import parameter (Here that is belongs to ClassOne):

    def method_three(self, my_obj: ClassOne):
        # To check that usage is also found when ClassOne is passed as an argument
        my_obj.method_one()

Automatic test

Do an automatic test with

...\Python2SOMIX\src\tests> python .\test_extraction.py

This test generates the subfolder test with test coding and compares the expected mse file expected_output.mse with the extracted file test(date_time).mse. Adapt this coding when the logic is changed. The test ignores the exact order of entries and the exact value of the id.

Documentation

See /src/documentation.md.

Metadata

Release files for python2somix 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python2somix 0.1.1
File Size Uploaded Provenance
python2somix-0.1.1.tar.gz 436.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for python2somix 0.1.1
File Interpreter ABI Platform
python2somix-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 446.8 kB

Release files / python2somix-0.1.1.tar.gz

Download URL python2somix-0.1.1.tar.gz
Size 436.3 kB
Tags Source
SHA-256 checksum
How to use checksums
128004aa55f68c1a7bb2c2a264021877da59c5a6308e34d7a614799dc80586a7
BLAKE2b-256 checksum
How to use checksums
4a3b764af50e12554238d4e79ed0ee71e3de77bbd43876178330050e91924c84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.0

Release files / python2somix-0.1.1-py3-none-any.whl

Download URL python2somix-0.1.1-py3-none-any.whl
Size 10.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2ac28cb820b6ba790456d18512ddb283dee4ae12bf41a322dcd275e1a6d52e61
BLAKE2b-256 checksum
How to use checksums
a29b00e0f9ac96be221036c07074a59222b9deaac74971b4bec5d4e1ce30e94b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.0

Security for python2somix 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page