--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/iro/anbieter/telnumber.py Thu Oct 22 10:00:01 2009 +0200
@@ -0,0 +1,59 @@
+# -*- coding: utf-8 -*-
+#Copyright (C) 2009 Sandro Knauß <bugs@sandroknauss.de>
+
+#This program 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 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 <http://www.gnu.org/licenses/>.
+
+class anbieter:
+ default_conf = '' # override this
+import re
+
+class NotATelNumber(Exception):
+ def __init__(self, number):
+ self.number= number
+
+ def __str__(self):
+ return ("This is not a telefonnumber:", selfnumber)
+
+class telnumber:
+ re_telnum=re.compile(r'^\s*(\+)?([0-9\s\-/\(\)])+\s*$')
+ re_land=re.compile(r'^\s*(\+|00)(?P<land>[1-9]{2})')
+ re_number=re.compile(r'[^0-9]')
+ std_land="49"
+
+ def __init__(self,number=None):
+ if not(number is None):
+ self.createNumber(number)
+
+ def createNumber(self, number):
+
+ if not self.re_telnum.match(number):
+ raise NotATelNumber(number)
+
+
+ self.land=self.std_land
+ land=self.re_land.match(number)
+
+ if not(land is None):
+ self.land=land.group("land")
+ number=number[land.end("land"):]
+
+ number=self.re_number.sub('',number)
+
+ if number[0]=="0":
+ number=number[1:]
+
+ self.number = number
+
+ def __eq__(self, y):
+ return ((self.number == y.number) and ( self.land == y.land))
+
+ def __ne__(self, y):
+ return not self.__eq__(y)