Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/FMITest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install future pyparsing numpy psutil pyzmq pytest pytest-md pytest-emoji
pip install . pytest pytest-md pytest-emoji

- name: Set timezone
uses: szenius/set-timezone@v2.0
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/Test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,17 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install future pyparsing numpy psutil pyzmq pytest pytest-md pytest-emoji
pip install . pytest pytest-md pytest-emoji flake8

- name: Set timezone
uses: szenius/set-timezone@v2.0
with:
timezoneLinux: 'Europe/Berlin'

- name: Lint with flake8
run: |
flake8 . --count --statistics

- name: Run pytest
uses: pavelzw/pytest-action@v2
with:
Expand Down
17 changes: 0 additions & 17 deletions OMPython/OMParser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@
Version: 1.0
"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from builtins import int, range

import sys

result = dict()
Expand Down Expand Up @@ -207,8 +202,6 @@ def delete_elements(strings):


def make_subset_sets(strings, name):
index = 0
anchor = 0
main_set_name = "SET1"
subset_name = "Subset1"
set_name = "Set1"
Expand Down Expand Up @@ -285,8 +278,6 @@ def make_subset_sets(strings, name):
def make_sets(strings, name):
if strings == "{}":
return
index = 0
anchor = 0
main_set_name = "SET1"
set_name = "Set1"

Expand Down Expand Up @@ -415,7 +406,6 @@ def get_inner_sets(strings, for_this, name):


def make_elements(strings):
original_string = strings
index = 0
main_set_name = "SET1"

Expand Down Expand Up @@ -563,7 +553,6 @@ def skip_all_inner_sets(position):
max_count = main_count
last_set = 0
last_subset = 0
last_brace = 0
pos = position

while pos < len(string):
Expand Down Expand Up @@ -616,7 +605,6 @@ def skip_all_inner_sets(position):
break
elif ch == "(":
brace_count += 1
brace_start = position
position += 1
while position < end_of_main_set:
s = string[position]
Expand All @@ -625,7 +613,6 @@ def skip_all_inner_sets(position):
elif s == ")":
brace_count -= 1
if brace_count == 0:
last_brace = position
break
elif s == "=" and string[position + 1] == "{":
indx = position + 2
Expand Down Expand Up @@ -672,7 +659,6 @@ def skip_all_inner_sets(position):
break
elif ch == "(":
brace_count += 1
brace_start = position
position += 1
while position < end_of_main_set:
s = string[position]
Expand All @@ -681,13 +667,11 @@ def skip_all_inner_sets(position):
elif s == ")":
brace_count -= 1
if brace_count == 0:
last_brace = position
break
position += 1
position += 1
elif char == "(":
brace_count += 1
brace_start = position
position += 1
while position < end_of_main_set:
s = string[position]
Expand All @@ -696,7 +680,6 @@ def skip_all_inner_sets(position):
elif s == ")":
brace_count -= 1
if brace_count == 0:
last_brace = position
break
position += 1

Expand Down
15 changes: 6 additions & 9 deletions OMPython/OMTypedParser.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from builtins import int, range

__author__ = "Anand Kalaiarasi Ganeson, ganan642@student.liu.se, 2012-03-19, and Martin Sjölund"
__license__ = """
This file is part of OpenModelica.
Expand Down Expand Up @@ -59,6 +54,7 @@

import sys


def convertNumbers(s, l, toks):
n = toks[0]
try:
Expand All @@ -75,7 +71,8 @@ def convertString2(s, s2):
tmp = tmp.replace("\n", "\\n")
tmp = tmp.replace("\r", "\\r")
tmp = tmp.replace("\t", "\\t")
return "'"+tmp+"'";
return "'"+tmp+"'"


def convertString(s, s2):
return s2[0].replace("\\\"", '"')
Expand All @@ -89,7 +86,6 @@ def convertTuple(t):
return tuple(t[0])



def evaluateExpression(s, loc, toks):
# Convert the tokens (ParseResults) into a string expression
flat_list = [item for sublist in toks[0] for item in sublist]
Expand All @@ -100,6 +96,7 @@ def evaluateExpression(s, loc, toks):
except Exception:
return expr


# Number parsing (supports arithmetic expressions in dimensions) (e.g., {1 + 1, 1})
arrayDimension = infixNotation(
Word(alphas + "_", alphanums + "_") | Word(nums),
Expand All @@ -123,7 +120,7 @@ def evaluateExpression(s, loc, toks):
Optional('.' + Word(nums)) +
Optional(Word('eE', exact=1) + Word(nums + '+-', nums)))

#ident = Word(alphas + "_", alphanums + "_") | Combine("'" + Word(alphanums + "!#$%&()*+,-./:;<>=?@[]^{}|~ ") + "'")
# ident = Word(alphas + "_", alphanums + "_") | Combine("'" + Word(alphanums + "!#$%&()*+,-./:;<>=?@[]^{}|~ ") + "'")
ident = Word(alphas + "_", alphanums + "_") | QuotedString(quoteChar='\'', escChar='\\').setParseAction(convertString2)
fqident = Forward()
fqident << ((ident + "." + fqident) | ident)
Expand All @@ -143,7 +140,7 @@ def evaluateExpression(s, loc, toks):
def parseString(string):
res = omcGrammar.parseString(string)
if len(res) == 0:
return
return
return res[0]


Expand Down
Loading