Remove backwards compatibility

This commit is contained in:
Salvo 'LtWorf' Tomaselli
2020-08-12 21:31:16 +02:00
parent 8df4d45aba
commit 456a89be93
3 changed files with 17 additions and 20 deletions

View File

@@ -1,5 +1,5 @@
# 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
# 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 *
__all__ = [
'Relation',
'Header',
]
class Relation:
'''
@@ -336,7 +342,7 @@ class Relation:
added = True
# If it didn't partecipate, adds it
if not added:
item = chain(i, repeat(rstring('---'), len(noid)))
item = chain(i, repeat(Rstring('---'), len(noid)))
newt.content.add(tuple(item))
return newt
@@ -468,7 +474,7 @@ class Relation:
self._make_writable()
prevlen = len(self.content)
self.content.add(tuple(map(rstring, values)))
self.content.add(tuple(map(Rstring, values)))
return len(self.content) - prevlen
def delete(self, expr: str) -> int:
@@ -541,7 +547,3 @@ class Header(tuple):
return [self.index(i) for i in param]
except ValueError as e:
raise Exception('One of the fields is not in the relation: %s' % ','.join(param))
# Backwards compatibility
relation = Relation
header = Header

View File

@@ -1,5 +1,5 @@
# 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
# it under the terms of the GNU General Public License as published by
@@ -55,7 +55,7 @@ class Rstring(str):
elif self.isFloat():
self._autocast = float(self)
elif self.isDate():
self._autocast = rdate(self)
self._autocast = Rdate(self)
return self._autocast
def isInt(self) -> bool:
@@ -119,8 +119,8 @@ class Rdate (object):
def __init__(self, date):
'''date: A string representing a date'''
if not isinstance(date, rstring):
date = rstring(date)
if not isinstance(date, Rstring):
date = Rstring(date)
self.intdate = date.getDate()
self.day = self.intdate.day
@@ -136,7 +136,7 @@ class Rdate (object):
def __add__(self, days):
res = self.intdate + datetime.timedelta(days)
return rdate(res.__str__())
return Rdate(res.__str__())
def __eq__(self, other):
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.
Returns boolean'''
return re.match(RELATION_NAME_REGEXP, name) != None and not keyword.iskeyword(name)
# Backwards compatibility
rdate = Rdate
rstring = Rstring