Commit 4074e186 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Merge branch 'asn1scc_v4' of https://github.com/esa/opengeode into asn1scc_v4

parents 42e7d7e5 90355dd8
...@@ -141,6 +141,10 @@ The background pattern was downloaded from www.subtlepatterns.com ...@@ -141,6 +141,10 @@ The background pattern was downloaded from www.subtlepatterns.com
Changelog Changelog
========= =========
2.0.3 (03/2018)
- Optimize calls to asn1scc
- Fix paste error when input symbol is selected
2.0.2 (03/2018) 2.0.2 (03/2018)
- Better support of ASN.1 constants - Better support of ASN.1 constants
- Support timer when using process type - Support timer when using process type
......
...@@ -21,6 +21,8 @@ import distutils.spawn as spawn ...@@ -21,6 +21,8 @@ import distutils.spawn as spawn
import sys import sys
import importlib import importlib
import logging import logging
import traceback
import hashlib
from PySide.QtCore import QProcess, QFile from PySide.QtCore import QProcess, QFile
import icons import icons
...@@ -33,6 +35,7 @@ LOG.addHandler(handler_console) ...@@ -33,6 +35,7 @@ LOG.addHandler(handler_console)
# global needed to store the imported module and list of modules ever loaded # global needed to store the imported module and list of modules ever loaded
AST = {} AST = {}
# Same for the modules imported by the call to asn2DataModel # Same for the modules imported by the call to asn2DataModel
ASN2DM = {} ASN2DM = {}
...@@ -78,6 +81,18 @@ def parse_asn1(*files, **options): ...@@ -78,6 +81,18 @@ def parse_asn1(*files, **options):
This function uses QProcess to launch the ASN.1 compiler because This function uses QProcess to launch the ASN.1 compiler because
the subprocess module from Python has issues on the Windows platform the subprocess module from Python has issues on the Windows platform
''' '''
# make sure the same files are not parsed more than once if not modified
filehash = hashlib.md5()
file_list = list(*files)
for each in file_list:
filehash.update(open(each).read())
new_hash = filehash.hexdigest()
fileset = "".join(file_list)
if fileset in AST.viewkeys() and AST[fileset]['hash'] == new_hash:
return AST[fileset]['ast']
else:
AST[fileset] = {'hash': new_hash}
ast_version = options.get('ast_version', ASN1.UniqueEnumeratedNames) ast_version = options.get('ast_version', ASN1.UniqueEnumeratedNames)
rename_policy = options.get('rename_policy', ASN1.NoRename) rename_policy = options.get('rename_policy', ASN1.NoRename)
flags = options.get('flags', [ASN1.AstOnly]) flags = options.get('flags', [ASN1.AstOnly])
...@@ -133,13 +148,8 @@ def parse_asn1(*files, **options): ...@@ -133,13 +148,8 @@ def parse_asn1(*files, **options):
_ = waitfor_qprocess(asn1scc, "ASN.1 Compiler") _ = waitfor_qprocess(asn1scc, "ASN.1 Compiler")
if filename in AST.viewkeys(): ast = importlib.import_module(filename)
# Re-import module if it was already loaded AST[fileset]['ast'] = ast
ast = AST[filename]
reload(ast)
else:
ast = importlib.import_module(filename)
AST[filename] = ast
if pprint: if pprint:
# add the path to the optionally-gernated pretty-printed HTML file # add the path to the optionally-gernated pretty-printed HTML file
ast.html = out_html ast.html = out_html
......
...@@ -139,7 +139,7 @@ except ImportError: ...@@ -139,7 +139,7 @@ except ImportError:
__all__ = ['opengeode', 'SDL_Scene', 'SDL_View', 'parse'] __all__ = ['opengeode', 'SDL_Scene', 'SDL_View', 'parse']
__version__ = '2.0.2' __version__ = '2.0.3'
if hasattr(sys, 'frozen'): if hasattr(sys, 'frozen'):
# Detect if we are running on Windows (py2exe-generated) # Detect if we are running on Windows (py2exe-generated)
...@@ -990,7 +990,7 @@ class SDL_Scene(QtGui.QGraphicsScene, object): ...@@ -990,7 +990,7 @@ class SDL_Scene(QtGui.QGraphicsScene, object):
Paste previously copied symbols at selection point Paste previously copied symbols at selection point
''' '''
if self.context == 'process' and self.readonly: if self.context == 'process' and self.readonly:
# with readonly flag, forbid item delettion # with readonly flag, forbid item deletion
return return
parent = list(self.selected_symbols) parent = list(self.selected_symbols)
if len(parent) > 1: if len(parent) > 1:
...@@ -1027,6 +1027,7 @@ class SDL_Scene(QtGui.QGraphicsScene, object): ...@@ -1027,6 +1027,7 @@ class SDL_Scene(QtGui.QGraphicsScene, object):
item.cam(item.pos(), item.pos()) item.cam(item.pos(), item.pos())
self.undo_stack.endMacro() self.undo_stack.endMacro()
self.refresh() self.refresh()
self.selectionChanged.emit()
def sdl_to_statechart(self, basic=True, view=None): def sdl_to_statechart(self, basic=True, view=None):
...@@ -2122,7 +2123,7 @@ class SDL_View(QtGui.QGraphicsView, object): ...@@ -2122,7 +2123,7 @@ class SDL_View(QtGui.QGraphicsView, object):
def check_model(self): def check_model(self):
''' Parse the model and check for warnings and errors ''' ''' Parse the model and check for warnings and errors '''
# If the current scene is a nested one, save the top parent # If the current scene is a nested one, go first to the top parent
scene = self.top_scene() scene = self.top_scene()
# Keep track of this check - to avoid repeating if user wants to # Keep track of this check - to avoid repeating if user wants to
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment