From c4f2587fd9ef028309cb464c66dd9f786c93c64c Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Fri, 12 Jul 2013 15:25:57 +0200 Subject: [PATCH] Pylint --- radicale/__init__.py | 4 ++-- radicale/log.py | 2 +- radicale/storage/database.py | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/radicale/__init__.py b/radicale/__init__.py index 75cab63..7bbe1dc 100644 --- a/radicale/__init__.py +++ b/radicale/__init__.py @@ -39,10 +39,10 @@ import wsgiref.simple_server # pylint: disable=F0401,E0611 try: from http import client - from urllib.parse import quote, unquote, urlparse + from urllib.parse import unquote, urlparse except ImportError: import httplib as client - from urllib import quote, unquote + from urllib import unquote from urlparse import urlparse # pylint: enable=F0401,E0611 diff --git a/radicale/log.py b/radicale/log.py index 4225d03..7a49a4e 100644 --- a/radicale/log.py +++ b/radicale/log.py @@ -36,10 +36,10 @@ LOGGER = logging.getLogger() def start(): + """Start the logging according to the configuration.""" filename = os.path.expanduser(config.get("logging", "config")) debug = config.getboolean("logging", "debug") - """Start the logging according to the configuration.""" if os.path.exists(filename): # Configuration taken from file logging.config.fileConfig(filename) diff --git a/radicale/storage/database.py b/radicale/storage/database.py index a780647..f42e75a 100644 --- a/radicale/storage/database.py +++ b/radicale/storage/database.py @@ -32,12 +32,16 @@ from sqlalchemy.ext.declarative import declarative_base from .. import config, ical +# These are classes, not constants +# pylint: disable=C0103 Base = declarative_base() Session = sessionmaker() Session.configure(bind=create_engine(config.get("storage", "database_url"))) +# pylint: enable=C0103 class DBCollection(Base): + """Table of collections.""" __tablename__ = "collection" path = Column(String, primary_key=True) @@ -48,6 +52,7 @@ class DBCollection(Base): class DBItem(Base): + """Table of collection's items.""" __tablename__ = "item" name = Column(String, primary_key=True) @@ -58,6 +63,7 @@ class DBItem(Base): class DBHeader(Base): + """Table of item's headers.""" __tablename__ = "header" key = Column(String, primary_key=True) @@ -69,6 +75,7 @@ class DBHeader(Base): class DBLine(Base): + """Table of item's lines.""" __tablename__ = "line" key = Column(String, primary_key=True) @@ -81,6 +88,7 @@ class DBLine(Base): class DBProperty(Base): + """Table of collection's properties.""" __tablename__ = "property" key = Column(String, primary_key=True) @@ -102,6 +110,7 @@ class Collection(ical.Collection): self.session.commit() def _query(self, item_types): + """Get collection's items matching ``item_types``.""" item_objects = [] for item_type in item_types: items = ( @@ -116,6 +125,7 @@ class Collection(ical.Collection): @property def _modification_time(self): + """Collection's last modification time.""" return ( self.session.query(func.max(DBLine.timestamp)) .join(DBItem).filter_by(collection_path=self.path).first()[0] @@ -123,6 +133,7 @@ class Collection(ical.Collection): @property def _db_collection(self): + """Collection's object mapped to the table line.""" return self.session.query(DBCollection).get(self.path) def write(self, headers=None, items=None): @@ -272,3 +283,10 @@ class Collection(ical.Collection): @property def cards(self): return self._query((ical.Card,)) + + def save(self): + """Save the text into the collection. + + This method is not used for databases. + + """