Pylint
This commit is contained in:
parent
18f5c334f1
commit
c4f2587fd9
@ -39,10 +39,10 @@ import wsgiref.simple_server
|
|||||||
# pylint: disable=F0401,E0611
|
# pylint: disable=F0401,E0611
|
||||||
try:
|
try:
|
||||||
from http import client
|
from http import client
|
||||||
from urllib.parse import quote, unquote, urlparse
|
from urllib.parse import unquote, urlparse
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import httplib as client
|
import httplib as client
|
||||||
from urllib import quote, unquote
|
from urllib import unquote
|
||||||
from urlparse import urlparse
|
from urlparse import urlparse
|
||||||
# pylint: enable=F0401,E0611
|
# pylint: enable=F0401,E0611
|
||||||
|
|
||||||
|
@ -36,10 +36,10 @@ LOGGER = logging.getLogger()
|
|||||||
|
|
||||||
|
|
||||||
def start():
|
def start():
|
||||||
|
"""Start the logging according to the configuration."""
|
||||||
filename = os.path.expanduser(config.get("logging", "config"))
|
filename = os.path.expanduser(config.get("logging", "config"))
|
||||||
debug = config.getboolean("logging", "debug")
|
debug = config.getboolean("logging", "debug")
|
||||||
|
|
||||||
"""Start the logging according to the configuration."""
|
|
||||||
if os.path.exists(filename):
|
if os.path.exists(filename):
|
||||||
# Configuration taken from file
|
# Configuration taken from file
|
||||||
logging.config.fileConfig(filename)
|
logging.config.fileConfig(filename)
|
||||||
|
@ -32,12 +32,16 @@ from sqlalchemy.ext.declarative import declarative_base
|
|||||||
from .. import config, ical
|
from .. import config, ical
|
||||||
|
|
||||||
|
|
||||||
|
# These are classes, not constants
|
||||||
|
# pylint: disable=C0103
|
||||||
Base = declarative_base()
|
Base = declarative_base()
|
||||||
Session = sessionmaker()
|
Session = sessionmaker()
|
||||||
Session.configure(bind=create_engine(config.get("storage", "database_url")))
|
Session.configure(bind=create_engine(config.get("storage", "database_url")))
|
||||||
|
# pylint: enable=C0103
|
||||||
|
|
||||||
|
|
||||||
class DBCollection(Base):
|
class DBCollection(Base):
|
||||||
|
"""Table of collections."""
|
||||||
__tablename__ = "collection"
|
__tablename__ = "collection"
|
||||||
|
|
||||||
path = Column(String, primary_key=True)
|
path = Column(String, primary_key=True)
|
||||||
@ -48,6 +52,7 @@ class DBCollection(Base):
|
|||||||
|
|
||||||
|
|
||||||
class DBItem(Base):
|
class DBItem(Base):
|
||||||
|
"""Table of collection's items."""
|
||||||
__tablename__ = "item"
|
__tablename__ = "item"
|
||||||
|
|
||||||
name = Column(String, primary_key=True)
|
name = Column(String, primary_key=True)
|
||||||
@ -58,6 +63,7 @@ class DBItem(Base):
|
|||||||
|
|
||||||
|
|
||||||
class DBHeader(Base):
|
class DBHeader(Base):
|
||||||
|
"""Table of item's headers."""
|
||||||
__tablename__ = "header"
|
__tablename__ = "header"
|
||||||
|
|
||||||
key = Column(String, primary_key=True)
|
key = Column(String, primary_key=True)
|
||||||
@ -69,6 +75,7 @@ class DBHeader(Base):
|
|||||||
|
|
||||||
|
|
||||||
class DBLine(Base):
|
class DBLine(Base):
|
||||||
|
"""Table of item's lines."""
|
||||||
__tablename__ = "line"
|
__tablename__ = "line"
|
||||||
|
|
||||||
key = Column(String, primary_key=True)
|
key = Column(String, primary_key=True)
|
||||||
@ -81,6 +88,7 @@ class DBLine(Base):
|
|||||||
|
|
||||||
|
|
||||||
class DBProperty(Base):
|
class DBProperty(Base):
|
||||||
|
"""Table of collection's properties."""
|
||||||
__tablename__ = "property"
|
__tablename__ = "property"
|
||||||
|
|
||||||
key = Column(String, primary_key=True)
|
key = Column(String, primary_key=True)
|
||||||
@ -102,6 +110,7 @@ class Collection(ical.Collection):
|
|||||||
self.session.commit()
|
self.session.commit()
|
||||||
|
|
||||||
def _query(self, item_types):
|
def _query(self, item_types):
|
||||||
|
"""Get collection's items matching ``item_types``."""
|
||||||
item_objects = []
|
item_objects = []
|
||||||
for item_type in item_types:
|
for item_type in item_types:
|
||||||
items = (
|
items = (
|
||||||
@ -116,6 +125,7 @@ class Collection(ical.Collection):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def _modification_time(self):
|
def _modification_time(self):
|
||||||
|
"""Collection's last modification time."""
|
||||||
return (
|
return (
|
||||||
self.session.query(func.max(DBLine.timestamp))
|
self.session.query(func.max(DBLine.timestamp))
|
||||||
.join(DBItem).filter_by(collection_path=self.path).first()[0]
|
.join(DBItem).filter_by(collection_path=self.path).first()[0]
|
||||||
@ -123,6 +133,7 @@ class Collection(ical.Collection):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def _db_collection(self):
|
def _db_collection(self):
|
||||||
|
"""Collection's object mapped to the table line."""
|
||||||
return self.session.query(DBCollection).get(self.path)
|
return self.session.query(DBCollection).get(self.path)
|
||||||
|
|
||||||
def write(self, headers=None, items=None):
|
def write(self, headers=None, items=None):
|
||||||
@ -272,3 +283,10 @@ class Collection(ical.Collection):
|
|||||||
@property
|
@property
|
||||||
def cards(self):
|
def cards(self):
|
||||||
return self._query((ical.Card,))
|
return self._query((ical.Card,))
|
||||||
|
|
||||||
|
def save(self):
|
||||||
|
"""Save the text into the collection.
|
||||||
|
|
||||||
|
This method is not used for databases.
|
||||||
|
|
||||||
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user