Remove backwards compatibility

master
Salvo 'LtWorf' Tomaselli 2020-08-12 21:31:16 +07:00
parent 8df4d45aba
commit 456a89be93
No known key found for this signature in database
GPG Key ID: B3A7CF0C801886CF
3 changed files with 17 additions and 20 deletions

@ -1,6 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# Relational # Relational
# Copyright (C) 2010-2017 Salvo "LtWorf" Tomaselli # Copyright (C) 2010-2020 Salvo "LtWorf" Tomaselli
# #
# Relational is free software: you can redistribute it and/or modify # Relational is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -57,7 +57,7 @@ def load_relations():
print ("Loading relation %s with name %s..." % (i, relname)) print ("Loading relation %s with name %s..." % (i, relname))
rels[relname] = relation.relation('%s%s' % (examples_path, i)) rels[relname] = relation.Relation('%s%s' % (examples_path, i))
print('done') print('done')
@ -238,7 +238,7 @@ def run_test(testname):
o_result = None o_result = None
try: try:
result_rel = relation.relation('%s%s.result' % (tests_path, testname)) result_rel = relation.Relation('%s%s.result' % (tests_path, testname))
query = readfile('%s%s.query' % (tests_path, testname)).strip() query = readfile('%s%s.query' % (tests_path, testname)).strip()
o_query = optimizer.optimize_all(query, rels) o_query = optimizer.optimize_all(query, rels)

@ -1,5 +1,5 @@
# Relational # Relational
# Copyright (C) 2008-2018 Salvo "LtWorf" Tomaselli # Copyright (C) 2008-2020 Salvo "LtWorf" Tomaselli
# #
# Relational is free software: you can redistribute it and/or modify # Relational is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -28,6 +28,12 @@ from pathlib import Path
from relational.rtypes import * from relational.rtypes import *
__all__ = [
'Relation',
'Header',
]
class Relation: class Relation:
''' '''
@ -336,7 +342,7 @@ class Relation:
added = True added = True
# If it didn't partecipate, adds it # If it didn't partecipate, adds it
if not added: if not added:
item = chain(i, repeat(rstring('---'), len(noid))) item = chain(i, repeat(Rstring('---'), len(noid)))
newt.content.add(tuple(item)) newt.content.add(tuple(item))
return newt return newt
@ -468,7 +474,7 @@ class Relation:
self._make_writable() self._make_writable()
prevlen = len(self.content) prevlen = len(self.content)
self.content.add(tuple(map(rstring, values))) self.content.add(tuple(map(Rstring, values)))
return len(self.content) - prevlen return len(self.content) - prevlen
def delete(self, expr: str) -> int: def delete(self, expr: str) -> int:
@ -541,7 +547,3 @@ class Header(tuple):
return [self.index(i) for i in param] return [self.index(i) for i in param]
except ValueError as e: except ValueError as e:
raise Exception('One of the fields is not in the relation: %s' % ','.join(param)) raise Exception('One of the fields is not in the relation: %s' % ','.join(param))
# Backwards compatibility
relation = Relation
header = Header

@ -1,5 +1,5 @@
# Relational # Relational
# Copyright (C) 2008-2017 Salvo "LtWorf" Tomaselli # Copyright (C) 2008-2020 Salvo "LtWorf" Tomaselli
# #
# Relation is free software: you can redistribute it and/or modify # Relation is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -55,7 +55,7 @@ class Rstring(str):
elif self.isFloat(): elif self.isFloat():
self._autocast = float(self) self._autocast = float(self)
elif self.isDate(): elif self.isDate():
self._autocast = rdate(self) self._autocast = Rdate(self)
return self._autocast return self._autocast
def isInt(self) -> bool: def isInt(self) -> bool:
@ -119,8 +119,8 @@ class Rdate (object):
def __init__(self, date): def __init__(self, date):
'''date: A string representing a date''' '''date: A string representing a date'''
if not isinstance(date, rstring): if not isinstance(date, Rstring):
date = rstring(date) date = Rstring(date)
self.intdate = date.getDate() self.intdate = date.getDate()
self.day = self.intdate.day self.day = self.intdate.day
@ -136,7 +136,7 @@ class Rdate (object):
def __add__(self, days): def __add__(self, days):
res = self.intdate + datetime.timedelta(days) res = self.intdate + datetime.timedelta(days)
return rdate(res.__str__()) return Rdate(res.__str__())
def __eq__(self, other): def __eq__(self, other):
return self.intdate == other.intdate return self.intdate == other.intdate
@ -164,8 +164,3 @@ def is_valid_relation_name(name: str) -> bool:
'''Checks if a name is valid for a relation. '''Checks if a name is valid for a relation.
Returns boolean''' Returns boolean'''
return re.match(RELATION_NAME_REGEXP, name) != None and not keyword.iskeyword(name) return re.match(RELATION_NAME_REGEXP, name) != None and not keyword.iskeyword(name)
# Backwards compatibility
rdate = Rdate
rstring = Rstring