Commit d200ad68 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Clean code

parent 60bd1348
...@@ -269,7 +269,7 @@ LD_LIBRARY_PATH=. opengeode-simulator ...@@ -269,7 +269,7 @@ LD_LIBRARY_PATH=. opengeode-simulator
sort=type_name(var_type), sort=type_name(var_type),
default=u' := ' + dstr if def_value else u'')) default=u' := ' + dstr if def_value else u''))
process_level_decl.append('end record;'.format(LPREFIX)) process_level_decl.append('end record;')
process_level_decl.append('{ctxt}: {ctxt}_Ty;'.format(ctxt=LPREFIX)) process_level_decl.append('{ctxt}: {ctxt}_Ty;'.format(ctxt=LPREFIX))
......
...@@ -27,7 +27,9 @@ import random ...@@ -27,7 +27,9 @@ import random
from functools import partial from functools import partial
from itertools import chain from itertools import chain
# Added to please py2exe - NOQA makes flake8 ignore the following lines: # To freeze the application on Windows, all modules must be imported even
# when they are not directly used from this module (py2exe bug)
# NOQA makes flake8 ignore locally-ununsed modules
# pylint: disable=W0611 # pylint: disable=W0611
import enum # NOQA import enum # NOQA
import string # NOQA import string # NOQA
...@@ -49,12 +51,24 @@ import undoCommands # NOQA ...@@ -49,12 +51,24 @@ import undoCommands # NOQA
import sdl92Lexer # NOQA import sdl92Lexer # NOQA
import sdl92Parser # NOQA import sdl92Parser # NOQA
import genericSymbols # NOQA import genericSymbols # NOQA
import sdlSymbols
import PySide.QtXml # NOQA import PySide.QtXml # NOQA
import singledispatch # NOQA import singledispatch # NOQA
import Asn1scc # NOQA import Asn1scc # NOQA
import Connectors # NOQA import Connectors # NOQA
import TextInteraction # NOQA import TextInteraction # NOQA
import pygraphviz # NOQA
import sdlSymbols
import AdaGenerator
import ogParser
import ogAST
import Renderer
import Clipboard
import Statechart
import Lander
import Helper
import Pr
import CGenerator
try: try:
import stringtemplate3 # NOQA import stringtemplate3 # NOQA
except ImportError: except ImportError:
...@@ -78,46 +92,43 @@ from TextInteraction import EditableText ...@@ -78,46 +92,43 @@ from TextInteraction import EditableText
# Icons and png files generated from the resource file: # Icons and png files generated from the resource file:
import icons # NOQA import icons # NOQA
# Logging: ist of properly loaded modules that will use it
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
MODULES = [
import AdaGenerator sdlSymbols,
import ogParser genericSymbols,
import ogAST ogAST,
import Renderer ogParser,
import Clipboard Lander,
import Statechart AdaGenerator,
import Lander undoCommands,
import Helper Renderer,
import Pr Clipboard,
Statechart,
Helper,
# Try importing graphviz for the SDL to Statechart converter Asn1scc,
# This is optional, as graphviz installation can not be easily Connectors,
# automated on some platforms by opengeode installation scripts. Pr,
try: TextInteraction,
import pygraphviz # NOQA Connectors,
graphviz = True CGenerator,
except ImportError: ]
graphviz = False
try:
import CGenerator
except ImportError:
CGenerator = None
try: try:
import LlvmGenerator import LlvmGenerator
MODULES.append(LlvmGenerator)
except ImportError: except ImportError:
LlvmGenerator = None pass
try: try:
import StgBackend import StgBackend
MODULES.append(StgBackend)
except ImportError: except ImportError:
StgBackend = False pass
__all__ = ['opengeode', 'SDL_Scene', 'SDL_View', 'parse'] __all__ = ['opengeode', 'SDL_Scene', 'SDL_View', 'parse']
__version__ = '1.3.28' __version__ = '1.3.29'
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)
...@@ -2001,10 +2012,9 @@ class OG_MainWindow(QtGui.QMainWindow, object): ...@@ -2001,10 +2012,9 @@ class OG_MainWindow(QtGui.QMainWindow, object):
break break
if graphviz: self.statechart_view = self.findChild(SDL_View, 'statechart_view')
self.statechart_view = self.findChild(SDL_View, 'statechart_view') self.statechart_scene = SDL_Scene(context='statechart')
self.statechart_scene = SDL_Scene(context='statechart') self.statechart_view.setScene(self.statechart_scene)
self.statechart_view.setScene(self.statechart_scene)
# Set up the dock area to display the ASN.1 Data model # Set up the dock area to display the ASN.1 Data model
#asn1_dock = self.findChild(QtGui.QDockWidget, 'datatypes_dock') #asn1_dock = self.findChild(QtGui.QDockWidget, 'datatypes_dock')
...@@ -2045,7 +2055,7 @@ class OG_MainWindow(QtGui.QMainWindow, object): ...@@ -2045,7 +2055,7 @@ class OG_MainWindow(QtGui.QMainWindow, object):
''' Signal sent by Qt when the MDI area tab changes ''' Signal sent by Qt when the MDI area tab changes
Here we check if the Statechart tab is selected, and we draw/refresh Here we check if the Statechart tab is selected, and we draw/refresh
the statechart automatically in that case ''' the statechart automatically in that case '''
if mdi == self.statechart_mdi and graphviz: if mdi == self.statechart_mdi:
if self.view.scene_stack: if self.view.scene_stack:
scene = self.view.scene_stack[0][0] scene = self.view.scene_stack[0][0]
else: else:
...@@ -2203,34 +2213,9 @@ def init_logging(options): ...@@ -2203,34 +2213,9 @@ def init_logging(options):
# Set log level for all libraries # Set log level for all libraries
LOG.setLevel(level) LOG.setLevel(level)
modules = ( for each in MODULES:
sdlSymbols, each.LOG.addHandler(handler_console)
genericSymbols, each.LOG.setLevel(level)
ogAST,
ogParser,
Lander,
AdaGenerator,
undoCommands,
Renderer,
Clipboard,
Statechart,
Helper,
Asn1scc,
Connectors,
Pr,
TextInteraction,
Connectors,
LlvmGenerator,
CGenerator,
StgBackend
)
for each in modules:
try:
each.LOG.addHandler(handler_console)
each.LOG.setLevel(level)
except AttributeError as err:
# Discard unloaded modules (e.g. if LLVM is missing on target)
LOG.debug(str(err))
def parse(files): def parse(files):
...@@ -2335,7 +2320,7 @@ def export(ast, options): ...@@ -2335,7 +2320,7 @@ def export(ast, options):
LOG.info('Saving {ext} file: {name}.{ext}' LOG.info('Saving {ext} file: {name}.{ext}'
.format(ext=doc_fmt, name=name)) .format(ext=doc_fmt, name=name))
diagram.export_img(name, doc_format=doc_fmt, split=options.split) diagram.export_img(name, doc_format=doc_fmt, split=options.split)
if diagram.context == 'block' and graphviz: if diagram.context == 'block':
# Also save the statechart view of the current scene # Also save the statechart view of the current scene
LOG.info('Saving statechart sc_{}.png'.format(process.processName)) LOG.info('Saving statechart sc_{}.png'.format(process.processName))
sc_scene = SDL_Scene(context='statechart') sc_scene = SDL_Scene(context='statechart')
......
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