09-3sat_project/src/dimacs.py
def parse(self) -> Equation:
        """ parses DIMACS CNF file into Equation object """
        literals_list = list()
        if os.path.isfile(self.filepath):
            with open(self.filepath) as data:
                lines = (line.rstrip('\r\n') for line in data)
                for line in lines:
                    is_desc = regex.match(r"^" + DIMACS_DESC_CHAR, line)
                    is_clause = regex.match(r"^[0-9]|^\-", line)
                    line_splitted = line.strip().rsplit()

                    if is_desc:
                        self._variables = int(line_splitted[DIMACS_VARS_INDEX])
                        self._clauses = int(line_splitted[DIMACS_CLAUSES_INDEX])
                    if is_clause:
                        clause = [int(line_splitted[i]) for i in range(3)]
                        literals_list.append(tuple(clause))

            self._loaded_clauses = len(literals_list)
            self._loaded = True
            return Equation(self._variables, self._clauses, literals_list)
        return None
 parses DIMACS CNF file into Equation object 
parses DIMACS CNF file into Equation object
parses DIMACS CNF file into Equation object
def parse(self) -> Equation:
        literals_list = list()
        if os.path.isfile(self.filepath):
            with open(self.filepath) as data:
                lines = (line.rstrip('\r\n') for line in data)
                for line in lines:
                    is_desc = regex.match(r"^" + DIMACS_DESC_CHAR, line)
                    is_clause = regex.match(r"^[0-9]|^\-", line)
                    line_splitted = line.strip().rsplit()
                    if is_desc:
                        self._variables = int(line_splitted[DIMACS_VARS_INDEX])
                        self._clauses = int(line_splitted[DIMACS_CLAUSES_INDEX])
                    if is_clause:
                        clause = [int(line_splitted[i]) for i in range(3)]
                        literals_list.append(tuple(clause))
            self._loaded_clauses = len(literals_list)
            self._loaded = True
            return Equation(self._variables, self._clauses, literals_list)
        return None
def parse ( self ) -> Equation : literals_list = list ( ) if os . path . isfile ( self . filepath ) : with open ( self . filepath ) as data : lines = ( line . rstrip ( '\r\n' ) for line in data ) for line in lines : is_desc = regex . match ( r"^" + DIMACS_DESC_CHAR , line ) is_clause = regex . match ( r"^[0-9]|^\-" , line ) line_splitted = line . strip ( ) . rsplit ( ) if is_desc : self . _variables = int ( line_splitted [ DIMACS_VARS_INDEX ] ) self . _clauses = int ( line_splitted [ DIMACS_CLAUSES_INDEX ] ) if is_clause : clause = [ int ( line_splitted [ i ] ) for i in range ( 3 ) ] literals_list . append ( tuple ( clause ) ) self . _loaded_clauses = len ( literals_list ) self . _loaded = True return Equation ( self . _variables , self . _clauses , literals_list ) return None
parses DIMACS CNF file into Equation object
parses DIMACS CNF file into Equation object
""" parses DIMACS CNF file into Equation object """
self