/usr/share/bauble/meta.py is in bauble 0.9.7-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | #
# meta.py
#
from sqlalchemy import *
import bauble
import bauble.db as db
import bauble.utils as utils
from bauble.utils.log import debug
VERSION_KEY = u'version'
CREATED_KEY = u'created'
REGISTRY_KEY = u'registry'
# date format strings:
# yy - short year
# yyyy - long year
# dd - number day, always two digits
# d - number day, two digits when necessary
# mm -number month, always two digits
# m - number month, two digits when necessary
DATE_FORMAT_KEY = u'date_format'
def get_default(name, default=None, session=None):
"""
Get a BaubleMeta object with name. If the default value is not
None then a BaubleMeta object is returned with name and the
default value given.
If a session instance is passed (session != None) then we
don't commit the session.
"""
commit = False
if not session:
session = bauble.Session()
commit = True
query = session.query(BaubleMeta)
meta = query.filter_by(name=name).first()
if not meta and default is not None:
meta = BaubleMeta(name=utils.utf8(name), value=default)
session.add(meta)
if commit:
session.commit()
# load the properties so that we can close the session and
# avoid getting errors when accessing the properties on the
# returned meta
meta.value
meta.name
if commit:
# close the session whether we added anything or not
session.close()
return meta
class BaubleMeta(db.Base):
__tablename__ = 'bauble'
name = Column(Unicode(64), unique=True)
value = Column(UnicodeText)
|