Guillaume Ayoub il y a 12 ans
Parent
commit
c4f2587fd9
3 fichiers modifiés avec 21 ajouts et 3 suppressions
  1. 2 2
      radicale/__init__.py
  2. 1 1
      radicale/log.py
  3. 18 0
      radicale/storage/database.py

+ 2 - 2
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
 

+ 1 - 1
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)

+ 18 - 0
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.
+
+        """