Commit fd74ede3 authored by VIGNET Pierre's avatar VIGNET Pierre

[lib] Refactor for helper func => classmethod of Clause

parent be601afa
......@@ -58,6 +58,27 @@ class Clause():
def __init__(self, list_lit=[]):
self.literals = list_lit
@classmethod
def string_to_clause(cls, text_clause):
"""Transform a string into a clause (not used)
Example of text: "a,not b,not c".
.. warning:: strict syntax - no check - for tests only
"""
# Split into literals
clause = Clause([])
# Translate each literal
for lit in text_clause.split(','):
spl = lit.split()
if len(spl) == 1:
# "a"
clause.add_lit(Literal(spl[0], True))
else:
# "not a"
clause.add_lit(Literal(spl[1], False))
return clause
def add_lit(self, lit):
"""Add a literal to the clause
@param lit: <Literal>
......
......@@ -86,12 +86,10 @@ import pytest
import pkg_resources
from cadbiom.models.guard_transitions.chart_model import ChartModel
from cadbiom.models.clause_constraints.CLDynSys import Literal, Clause
from cadbiom.models.guard_transitions.analyser.ana_visitors import TableVisitor
from cadbiom.models.clause_constraints.CLDynSys import CLDynSys
from cadbiom.models.clause_constraints.mcl.MCLTranslators import GT2Clauses
from cadbiom.models.clause_constraints.mcl.CLUnfolder import CLUnfolder
from cadbiom.models.clause_constraints.mcl.MCLAnalyser import MCLAnalyser
from cadbiom.models.clause_constraints.mcl.MCLQuery import MCLSimpleQuery
from cadbiom.models.clause_constraints.mcl.MCLSolutions import MCLException
......@@ -123,26 +121,6 @@ class ErrorReporter(object):
"""
self.context = cont
# helper functions
def string_to_clause(text_clause):
"""
text_clause is a string such that "a,not b,not c"
it is transformed in the corresponding clause
WARNING: strict syntax - no check - for tests
"""
# split into literals
clause = Clause([])
llit = text_clause.split(',')
# translate each literal
for lit in llit:
spl = lit.split()
if len(spl) == 1: # "a"
clause.add_lit(Literal(spl[0], True))
else: # "not a"
clause.add_lit(Literal(spl[1], False))
return clause
def model1():
"""
A simple ChartModel with two nodes and a transition
......
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