diff --git a/CHANGELOG b/CHANGELOG index 487e115..5e3515b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -23,4 +23,7 @@ - Added support for parenthesis in relational queries 0.4 -- Created GUI \ No newline at end of file +- Created GUI + +0.5 +- Added support for float numbers \ No newline at end of file diff --git a/relation.py b/relation.py index 23d1d1b..ddf1420 100644 --- a/relation.py +++ b/relation.py @@ -16,6 +16,8 @@ # # author Salvo "LtWorf" Tomaselli +import rtypes + class relation (object): '''This objects defines a relation (as a group of consistent tuples) and operations A relation can be represented using a table @@ -76,6 +78,8 @@ class relation (object): for j in range(len(self.header.attributes)): if i[j].isdigit(): attributes[self.header.attributes[j]]=int(i[j]) + elif rtypes.rstring(i[j]).isFloat(): + attributes[self.header.attributes[j]]=float(i[j]) else: attributes[self.header.attributes[j]]=i[j] @@ -411,6 +415,7 @@ class header (object): res.append(j) return res + if __name__=="__main__": a=["id","nome","cognome"] diff --git a/relational.py b/relational.py index bfc8cf4..5c7de8c 100755 --- a/relational.py +++ b/relational.py @@ -24,7 +24,7 @@ import parser import relation import maingui -version="0.4" +version="0.5" if __name__ == "__main__": app = QtGui.QApplication(sys.argv) diff --git a/rtypes.py b/rtypes.py new file mode 100644 index 0000000..9ea84fa --- /dev/null +++ b/rtypes.py @@ -0,0 +1,28 @@ +# Relational +# Copyright (C) 2008 Salvo "LtWorf" Tomaselli +# +# Relation is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# author Salvo "LtWorf" Tomaselli + +'''Custom types for relational algebra''' +class rstring (str): + '''String subclass with some custom methods''' + def isFloat(self): + '''True if the string is a float number, false otherwise''' + lst=['0','1','2','3','4','5','6','7','8','9','.'] + for i in self: + if i not in lst: + return False; + return True; \ No newline at end of file diff --git a/samples/people.tlb b/samples/people.tlb index e8dd32a..4fc8277 100644 --- a/samples/people.tlb +++ b/samples/people.tlb @@ -1,9 +1,9 @@ id name chief age -0 jack 0 22 +0 jack 0 22.1 1 carl 0 20 2 john 1 30 3 dean 1 33 4 eve 0 25 5 duncan 4 30 6 paul 4 30 -7 alia 1 28 \ No newline at end of file +7 alia 1 28