Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
OpenGEODE
Commits
a09b255d
Commit
a09b255d
authored
Sep 05, 2014
by
Maxime Perrotin
Browse files
Fixed minor path issues when loading files
parent
fb6db2bf
Changes
2
Hide whitespace changes
Inline
Side-by-side
ogParser.py
View file @
a09b255d
...
...
@@ -3842,8 +3842,8 @@ def add_to_ast(ast, filename=None, string=None):
errors
,
warnings
=
[],
[]
try
:
parser
=
parser_init
(
filename
=
filename
,
string
=
string
)
except
IOError
:
LOG
.
error
(
'parser_init failed
'
)
except
IOError
as
err
:
LOG
.
error
(
'parser_init failed
: '
+
str
(
err
)
)
raise
# Use Sam & Max output capturer to get errors from ANTLR parser
with
samnmax
.
capture_ouput
()
as
(
stdout
,
stderr
):
...
...
@@ -3962,11 +3962,11 @@ def parser_init(filename=None, string=None):
''' Initialize the parser (to be called first) '''
try
:
char_stream
=
antlr3
.
ANTLRFileStream
(
filename
,
encoding
=
'utf-8'
)
except
(
IOError
,
TypeError
):
except
(
IOError
,
TypeError
)
as
err
:
try
:
char_stream
=
antlr3
.
ANTLRStringStream
(
string
)
except
TypeError
as
err
:
raise
IOError
(
'Could not parse input'
+
str
(
err
))
raise
IOError
(
'Could not parse input
:
'
+
str
(
err
))
lex
=
lexer
.
sdl92Lexer
(
char_stream
)
tokens
=
antlr3
.
CommonTokenStream
(
lex
)
parser
=
sdl92Parser
(
tokens
)
...
...
opengeode.py
View file @
a09b255d
...
...
@@ -1048,6 +1048,7 @@ class SDL_View(QtGui.QGraphicsView, object):
''' Main graphic view used to display the SDL scene and handle zoom '''
# signal to ask the main application that a new scene is needed
need_new_scene
=
QtCore
.
Signal
()
update_asn1_dock
=
QtCore
.
Signal
(
ogAST
.
AST
)
def
__init__
(
self
,
scene
):
''' Create the SDL view holding the scene '''
...
...
@@ -1352,7 +1353,8 @@ class SDL_View(QtGui.QGraphicsView, object):
LOG
.
warning
(
'Files are spread in several directories - '
'ASN.1 files may not be found'
)
else
:
os
.
chdir
(
dir_pool
.
pop
())
files
=
[
os
.
path
.
abspath
(
each
)
for
each
in
files
]
os
.
chdir
(
dir_pool
.
pop
()
or
'.'
)
try
:
ast
,
warnings
,
errors
=
ogParser
.
parse_pr
(
files
=
files
)
except
IOError
:
...
...
@@ -1385,7 +1387,9 @@ class SDL_View(QtGui.QGraphicsView, object):
self
.
refresh
()
self
.
centerOn
(
self
.
sceneRect
().
topLeft
())
self
.
scene
().
undo_stack
.
clear
()
return
ast
# Emit a signal for the application to update the ASN.1 scene
self
.
update_asn1_dock
.
emit
(
ast
)
#return ast
def
open_diagram
(
self
):
''' Load one or several .pr file and display the state machine '''
...
...
@@ -1689,6 +1693,7 @@ class OG_MainWindow(QtGui.QMainWindow, object):
self
.
asn1_area
=
sdlSymbols
.
ASN1Viewer
()
self
.
asn1_area
.
text
.
setPlainText
(
'-- ASN.1 Data Types'
)
self
.
asn1_area
.
text
.
try_resize
()
self
.
view
.
update_asn1_dock
.
connect
(
self
.
set_asn1_view
)
self
.
datatypes_scene
.
addItem
(
self
.
asn1_area
)
...
...
@@ -1709,24 +1714,46 @@ class OG_MainWindow(QtGui.QMainWindow, object):
if
file_name
:
types
=
[]
ast
=
self
.
view
.
load_file
(
file_name
)
# Update the dock widget with ASN.1 files content
try
:
for
asn1file
in
ast
.
asn1_filenames
:
with
open
(
asn1file
,
'r'
)
as
file_handler
:
types
.
append
(
'-- '
+
asn1file
)
types
.
append
(
file_handler
.
read
())
if
types
:
self
.
asn1_area
.
text
.
setPlainText
(
'
\n
'
.
join
(
types
))
# ASN.1 text area is read-only:
self
.
asn1_area
.
text
.
setTextInteractionFlags
(
QtCore
.
Qt
.
TextBrowserInteraction
)
self
.
asn1_area
.
text
.
try_resize
()
except
IOError
as
err
:
LOG
.
warning
(
'ASN.1 file(s) could not be loaded : '
+
str
(
err
))
except
AttributeError
:
LOG
.
warning
(
'No AST, check input files'
)
self
.
view
.
load_file
(
file_name
)
# # Update the dock widget with ASN.1 files content
# try:
# for asn1file in ast.asn1_filenames:
# with open(asn1file, 'r') as file_handler:
# types.append('-- ' + asn1file)
# types.append(file_handler.read())
# if types:
# self.asn1_area.text.setPlainText('\n'.join(types))
# # ASN.1 text area is read-only:
# self.asn1_area.text.setTextInteractionFlags(
# QtCore.Qt.TextBrowserInteraction)
# self.asn1_area.text.try_resize()
#
# except IOError as err:
# LOG.warning('ASN.1 file(s) could not be loaded : ' + str(err))
# except AttributeError:
# LOG.warning('No AST, check input files')
@
QtCore
.
Slot
(
ogAST
.
AST
)
def
set_asn1_view
(
self
,
ast
):
''' Display the ASN.1 types in the dedicated scene '''
# Update the dock widget with ASN.1 files content
types
=
[]
try
:
for
each
in
ast
.
asn1_filenames
:
with
open
(
each
,
'r'
)
as
file_handler
:
types
.
append
(
'-- '
+
each
)
types
.
append
(
file_handler
.
read
())
if
types
:
self
.
asn1_area
.
text
.
setPlainText
(
'
\n
'
.
join
(
types
))
# ASN.1 text area is read-only:
self
.
asn1_area
.
text
.
setTextInteractionFlags
(
QtCore
.
Qt
.
TextBrowserInteraction
)
self
.
asn1_area
.
text
.
try_resize
()
except
IOError
as
err
:
LOG
.
warning
(
'ASN.1 file(s) could not be loaded : '
+
str
(
err
))
except
AttributeError
:
LOG
.
warning
(
'No AST, check input files'
)
def
vi_command
(
self
):
'''
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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