Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
OpenGEODE
Commits
c3833d0a
Commit
c3833d0a
authored
Mar 23, 2018
by
Maxime Perrotin
Browse files
Optimize calls to asn1scc
Only call if md5 of any of the asn1 files has changed
parent
b92a1142
Changes
2
Hide whitespace changes
Inline
Side-by-side
opengeode/Asn1scc.py
View file @
c3833d0a
...
...
@@ -21,6 +21,8 @@ import distutils.spawn as spawn
import
sys
import
importlib
import
logging
import
traceback
import
hashlib
from
PySide.QtCore
import
QProcess
,
QFile
import
icons
...
...
@@ -33,6 +35,7 @@ LOG.addHandler(handler_console)
# global needed to store the imported module and list of modules ever loaded
AST
=
{}
# Same for the modules imported by the call to asn2DataModel
ASN2DM
=
{}
...
...
@@ -78,6 +81,18 @@ def parse_asn1(*files, **options):
This function uses QProcess to launch the ASN.1 compiler because
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
)
rename_policy
=
options
.
get
(
'rename_policy'
,
ASN1
.
NoRename
)
flags
=
options
.
get
(
'flags'
,
[
ASN1
.
AstOnly
])
...
...
@@ -133,13 +148,8 @@ def parse_asn1(*files, **options):
_
=
waitfor_qprocess
(
asn1scc
,
"ASN.1 Compiler"
)
if
filename
in
AST
.
viewkeys
():
# Re-import module if it was already loaded
ast
=
AST
[
filename
]
reload
(
ast
)
else
:
ast
=
importlib
.
import_module
(
filename
)
AST
[
filename
]
=
ast
ast
=
importlib
.
import_module
(
filename
)
AST
[
fileset
][
'ast'
]
=
ast
if
pprint
:
# add the path to the optionally-gernated pretty-printed HTML file
ast
.
html
=
out_html
...
...
opengeode/opengeode.py
View file @
c3833d0a
...
...
@@ -2122,7 +2122,7 @@ class SDL_View(QtGui.QGraphicsView, object):
def
check_model
(
self
):
''' 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
()
# Keep track of this check - to avoid repeating if user wants to
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment