[apparmor] [patch] Add (abstract) get_clean method to baserule
Christian Boltz
apparmor at cboltz.de
Fri Oct 23 12:23:06 UTC 2015
Hello,
$subject.
Also add a test to ensure it raises an AppArmorBug.
[ 05-baserule-add-abstract-get_clean.diff ]
=== modified file ./utils/apparmor/rule/__init__.py
--- utils/apparmor/rule/__init__.py 2015-06-06 14:53:16.868029000 +0200
+++ utils/apparmor/rule/__init__.py 2015-10-23 14:08:28.639214618 +0200
@@ -81,6 +85,11 @@
required to be implemented by subclasses; raise exception if not'''
raise AppArmorBug("'%s' needs to implement _parse(), but didn't" % (str(cls)))
+ # @abstractmethod FIXME - uncomment when python3 only
+ def get_clean(self, depth=0):
+ '''return clean rule (with default formatting, and leading whitespace as specified in the depth parameter)'''
+ raise AppArmorBug("'%s' needs to implement get_clean(), but didn't" % (str(self.__class__)))
+
def get_raw(self, depth=0):
'''return raw rule (with original formatting, and leading whitespace in the depth parameter)'''
if self.raw_rule:
=== modified file 'utils/test/test-baserule.py'
--- utils/test/test-baserule.py 2015-06-06 12:04:11 +0000
+++ utils/test/test-baserule.py 2015-10-23 12:17:53 +0000
@@ -35,6 +35,11 @@
with self.assertRaises(AppArmorBug):
BaseRule.match('foo')
+ def test_abstract_get_clean(self):
+ obj = BaseRule()
+ with self.assertRaises(AppArmorBug):
+ obj.get_clean()
+
def test_is_equal_localvars(self):
obj = BaseRule()
with self.assertRaises(AppArmorBug):
Regards,
Christian Boltz
--
> Write the code like you are going to lose your memory in six months.
Most people would say I write code like I've already lost my mind.
Is that the same thing? [Randal L. Schwartz]
More information about the AppArmor
mailing list