/usr/lib/python3/dist-packages/cement/core/meta.py is in python3-cement 2.10.0-1.
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 | """Cement core meta functionality."""
class Meta(object):
"""
Model that acts as a container class for a meta attributes for a larger
class. It stuffs any kwarg it gets in it's init as an attribute of itself.
"""
def __init__(self, **kwargs):
self._merge(kwargs)
def _merge(self, dict_obj):
for key in dict_obj.keys():
setattr(self, key, dict_obj[key])
class MetaMixin(object):
"""
Mixin that provides the Meta class support to add settings to instances
of slumber objects. Meta settings cannot start with a _.
"""
def __init__(self, *args, **kwargs):
# Get a List of all the Classes we in our MRO, find any attribute named
# Meta on them, and then merge them together in order of MRO
metas = reversed([x.Meta for x in self.__class__.mro()
if hasattr(x, "Meta")])
final_meta = {}
# Merge the Meta classes into one dict
for meta in metas:
final_meta.update(dict([x for x in meta.__dict__.items()
if not x[0].startswith("_")]))
# Update the final Meta with any kwargs passed in
for key in final_meta.keys():
if key in kwargs:
final_meta[key] = kwargs.pop(key)
self._meta = Meta(**final_meta)
# FIX ME: object.__init__() doesn't take params without exception
super(MetaMixin, self).__init__()
|