if callable(self.check_record_func):
return self.check_record_func(self, record)
else:
- raise TypeError, "non-callable restriction function"
+ raise TypeError("non-callable restriction function")
else:
return 1
# so it is not ready to be checked :(
# And, of course, two keys with the same name
# cannot be added to dictionary
- raise KeyError, "field key \"" + key + "\" already in record"
+ raise KeyError("field key \"" + key + "\" already in record")
record[key] = value
db.load_file(f)
if len(db) != 1:
- raise error, "incorrect number of records in config file `%s'; expected 1, got %d" % (str(f), len(db))
+ raise error("incorrect number of records in config file `%s'; expected 1, got %d" % (str(f), len(db)))
self.data = db[0]
db.load_from_file(f)
if len(db) != 1:
- raise error, "incorrect number of records in config file `%s'; expected 1, got %d" % (str(f), len(db))
+ raise error("incorrect number of records in config file `%s'; expected 1, got %d" % (str(f), len(db)))
self.data = db[0]
if must_keys and (key in must_keys):
del copy_must[copy_must.index(key)] # Remove the key from copied list
elif (must_keys and (key not in must_keys) and (other_keys and (key not in other_keys))) or (other_keys and (key not in other_keys)):
- raise KeyError, "field key \"" + key + "\" is not in list of allowed keys"
+ raise KeyError("field key \"" + key + "\" is not in list of allowed keys")
if copy_must: # If there is at least one key - it is an error:
# not all "must" keys are in record
- raise KeyError, "not all \"must\" keys are in record; keys: " + str(copy_must)
+ raise KeyError("not all \"must\" keys are in record; keys: " + str(copy_must))
return 1
if self.first_section:
if string.strip(line) != '':
- raise error, "non-empty line before 1st section"
+ raise error("non-empty line before 1st section")
elif (string.strip(line) == '') or (string.lstrip(line)[0] == ';') : # Empty line or comment
record[0].append(line)
# so it is not ready to be checked :(
# And, of course, two keys with the same name
# cannot be added to dictionary
- raise KeyError, "field key \"" + key + "\" already in record"
+ raise KeyError("field key \"" + key + "\" already in record")
record[0].append(key)
record[1][key] = value
else:
if self.first_section and (string.strip(line) != ''):
- raise error, "non-empty line before 1st section"
+ raise error("non-empty line before 1st section")
# else: line had been appended to section in __parse_line()
else: # This called after last line of the source file
def add_section(self, section):
rec_no = self.find_section(section)
if rec_no >= 0:
- raise section_error, "section [%s] already exists" % section
+ raise section_error("section [%s] already exists" % section)
self.append((section, [], {}))
def del_section(self, section):
rec_no = self.find_section(section)
if rec_no < 0:
- raise section_error, "section [%s] does not exists" % section
+ raise section_error("section [%s] does not exists" % section)
del self[rec_no]
def get_keyvalue(self, section, key):
rec_no = self.find_section(section)
if rec_no < 0:
- raise section_error, "section [%s] does not exists" % section
+ raise section_error("section [%s] does not exists" % section)
record = self[rec_no]
if key not in record[1]:
- raise KeyError, "section [%s] does not has `%s' key" % (section, key)
+ raise KeyError("section [%s] does not has `%s' key" % (section, key))
return record[2][key]
def del_key(self, section, key):
rec_no = self.find_section(section)
if rec_no < 0:
- raise section_error, "section [%s] does not exists" % section
+ raise section_error("section [%s] does not exists" % section)
record = self[rec_no]
if key not in record[1]:
- raise KeyError, "section [%s] does not has `%s' key" % (section, key)
+ raise KeyError("section [%s] does not has `%s' key" % (section, key))
klist = record[1]
del klist[klist.index(key)]
vw = self.vw
ix = vw.find(key=key)
if ix == -1:
- raise KeyError, key
+ raise KeyError(key)
return vw[ix].value
def __setitem__(self, key, value):
vw = self.vw
ix = vw.find(key=key)
if ix == -1:
- raise KeyError, key
+ raise KeyError(key)
vw.delete(ix)
self._add_tran()
return # It's Ok to have the directory already created
if os.path.exists(path):
- raise mkhier_error, "`%s' is file" % path
+ raise mkhier_error("`%s' is file" % path)
list_dirs = string.split(path, os.sep)
#print(list_dirs)
# The server does not implement LIST -R and
# treats -R as a name of a directory (-:
ftp.quit()
- raise FtpScanError, "the server does not implement recursive listing"
+ raise FtpScanError("the server does not implement recursive listing")
ftp.quit()
tree = []
tree.append((current_dir, files))
if len(tree) == 1:
- raise FtpScanError, "the server ignores -R in LIST"
+ raise FtpScanError("the server ignores -R in LIST")
return tree
sendmail = self.find_sendmail()
if not sendmail:
- raise ValueError, "cannot find sendmail binary"
+ raise ValueError("cannot find sendmail binary")
self.sendmail = sendmail
def find_sendmail(self):
reply_to=''): # send reply to this e-mail
Transport.__init__(self, phone, message)
if mode not in ('GSM', 'DAMPS'):
- raise ValueError, "mode (%s) must be either 'GSM' or 'DAMPS'" % mode
+ raise ValueError("mode (%s) must be either 'GSM' or 'DAMPS'" % mode)
self.mode = mode
self.transliterate = transliterate
self.reply_to = reply_to
elif prf == '7901':
dict['network_code'] = '1'
else:
- raise RuntimeError, "incorrect combination of mode (%s) and prefix (%s)" % (self.mode, prf)
+ raise RuntimeError("incorrect combination of mode (%s) and prefix (%s)" % (self.mode, prf))
dict['phone'] = self.phone[4:]
dict['message'] = text
prefix = phone[1:4]
if prefix in ("095", "901"): # 901 is being used by Beeline and SkyLink
- raise SMSError, "unknown provider for phone %s" % phone
+ raise SMSError("unknown provider for phone %s" % phone)
if Prefix2Provider.has_key(prefix):
return Prefix2Provider[prefix]
- raise SMSError, "bad prefix for phone %s" % phone
+ raise SMSError("bad prefix for phone %s" % phone)
return 28+IsLeapYear(_setYear(Year))
else:
- raise opdate_error, "bad month `%s'" % str(Month)
+ raise opdate_error("bad month `%s'" % str(Month))
def ValidDate(Day, Month, Year):
def DayOfWeek(Julian):
""" Return the day of the week for the date. Returns DayType(7) if Julian == BadDate. """
if Julian == BadDate:
- raise opdate_error, "bad date `%s'" % str(Julian)
+ raise opdate_error("bad date `%s'" % str(Julian))
else:
return (Julian+FirstDayOfWeek) % 7