cogu / autosar

A set of python modules for working with AUTOSAR XML files
MIT License
381 stars 165 forks source link

the demo always has error,about module 'autosar' has no attribute 'workspace' #27

Closed Eng2Mot closed 4 years ago

Eng2Mot commented 6 years ago

the demo always has error,about module 'autosar' has no attribute 'workspace'

Traceback (most recent call last): File "C:\Users\gz03232\Documents\autosar.py", line 1, in import autosar File "C:\Users\gz03232\Documents\autosar.py", line 3, in ws = autosar.workspace(version='4.2.2') AttributeError: module 'autosar' has no attribute 'workspace'

demo application as follow: import autosar

ws = autosar.workspace(version='4.2.2')

ws.createPackage('DataTypes', role='DataType') ws.createPackage('Constants', role="Constant") ws.createPackage('PortInterfaces', role="PortInterface") ws.createPackage('ModeDclrGroups', role="ModeDclrGroup") ws.createPackage('ComponentTypes', role='ComponentType')

save the file as XML

ws.saveXML('Workspace.arxml')

ws = autosar.workspace(version='4.2.2')

ws.createPackage('DataTypes', role='DataType') ws.createPackage('Constants', role="Constant") ws.createPackage('PortInterfaces', role="PortInterface") ws.createPackage('ModeDclrGroups', role="ModeDclrGroup") ws.createPackage('ComponentTypes', role='ComponentType')

save workspace packages into XML files

ws.saveXML('DataTypes.arxml', filters=['/DataTypes']) ws.saveXML('Constants.arxml', filters=['/Constants']) ws.saveXML('PortInterfaces.arxml', filters=['/PortInterfaces', '/ModeDclrGroups']) ws.saveXML('ComponentTypes.arxml', filters=['/ComponentTypes'])

cogu commented 6 years ago

It seems you have named your own script file autosar.py and the Python engine seems to use that one as the actual python module "autosar".

Try renaming your script file to anything except "autosar.py", like "demo.py"

cogu commented 4 years ago

This issue is no longer relevant

Sudhanva10 commented 11 months ago

@cogu Thanks man. It looks like the solution which you gave is still relevant.