#!/usr/bin/python
-# DialCentral - Front end for Google's Grand Central service.
-# Copyright (C) 2008 Eric Warnke ericew AT gmail DOT com
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+"""
+DialCentral - Front end for Google's Grand Central service.
+Copyright (C) 2008 Eric Warnke ericew AT gmail DOT com
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-"""
Filesystem backend for contact support
"""
@classmethod
def read_csv(cls, csvPath):
- csvReader = iter(csv.reader(open(csvPath, "rU")))
+ try:
+ csvReader = iter(csv.reader(open(csvPath, "rU")))
+ except IOError, e:
+ if e.errno != 2:
+ raise
+ return
header = csvReader.next()
nameColumn, phoneColumns = cls._guess_columns(header)
"""
for root, dirs, filenames in os.walk(self.__path):
for filename in filenames:
- name, ext = filename.rsplit(".", 1)
+ try:
+ name, ext = filename.rsplit(".", 1)
+ except ValueError:
+ continue
+
if ext in self.FILETYPE_SUPPORT:
yield self, os.path.join(root, filename), name
def open_addressbook(self, bookId):
name, ext = bookId.rsplit(".", 1)
- assert ext in self.FILETYPE_SUPPORT
+ assert ext in self.FILETYPE_SUPPORT, "Unsupported file extension %s" % ext
return self.FILETYPE_SUPPORT[ext](bookId)
@staticmethod