[apparmor] [patch][utils] Refractor prompts to class
Christian Boltz
apparmor at cboltz.de
Tue Oct 7 11:49:44 UTC 2014
Hello,
Am Dienstag, 7. Oktober 2014 schrieb Kshitij Gupta:
> Sorry for the delayed response, I was unable find time for the same
> (owing to exams).
Feel free to test me with some example questions on IRC (assuming your
exams were about topics that are somehow related to programming ;-)
> On Mon, Sep 22, 2014 at 2:26 AM, Christian Boltz wrote:
> > Am Mittwoch, 10. September 2014 schrieb Kshitij Gupta:
> >> In keeping with the idea to make the less Perl-ish and more OOP
> >> style
> >> (in hope to get more Pythonic). I thought it was a simple place to
> >> start off with.
> >>
> >> Any suggestions and changes for the patch are welcome.
> >>
> >> The following patch:
> >> - creates a class for prompt questions moving away from Perl hash
> >> hack for the purpose.
> >> - moves some functions to the methods for that class
> >> - fix options being incorrectly passed to questionPrompt in
> >> aa-mergeprof
> >>
> >> Due to the functions being moved around the patch is a bit long.
> >
> > That, and lots of q.['whatever'] -> q.whatever changes ;-)
>
> Well due to a patch to fix the messages so that they named parameters,
> this patch got a bit broken.
>
> Attached below is the updated patch and a diff of the old and new
> patch to make things easier (harder?).
I compared the old and new patch with meld ;-)
Using interdiff might also work, but funnily I got
# interdiff ui_refractor.patch ui_refractor.patch3
diff -u utils/aa-mergeprof utils/aa-mergeprof
--- utils/aa-mergeprof 2014-09-10 09:46:48 +0000
+++ utils/aa-mergeprof 2014-10-07 07:59:39 +0000
@@ -26,7 +26,7 @@
from apparmor.translations import init_translation
_ = init_translation()
-parser = argparse.ArgumentParser(description=_('Perform a 2-way or 3-way merge on the given profiles'),
+parser = argparse.ArgumentParser(description=_('Perform a 2-way or 3-way merge on the given profiles'),
epilog='WARNING: the arguments will change in a future version!')
parser.add_argument('mine', type=str, help=_('your profile'))
parser.add_argument('base', type=str, help=_('base profile'))
1 out of 1 hunk FAILED -- saving rejects to file /tmp/interdiff-1.p1QJzm.rej
interdiff: Error applying patch1 to reconstructed file
The last two lines are a bit ;-) unexpected and strange.
> >> Basic testing done with logprof.
>
> Again basic ui tested with logprof.
Acked-by: Christian Boltz <apparmor at cboltz.de>
I'd recommend to commit it soon, before you get new merge conflicts ;-)
> > The patch looks good, with one exception:
> >
> > === modified file 'utils/apparmor/ui.py'
> > + def promptUser(self, params=''):
> > + ypath, yarg = GetDataFromYast()
> >
> > That should probably be
> >
> > ypath, yarg = self.GetDataFromYast()
> >
> > (note the added "self.")
>
> No the self is not needed as the function is from a different module
> and a method of the class.
Indeed. I probably overlooked the "import" line, sorry.
Regards,
Christian Boltz
--
Ich hab dauernd das blöde Gefühl, dass ich dich fürchterlich nerve,
weil ich sowas nicht alleine hinbekomme. Überall lese ich nur: "Ist
ganz einfach - ging bei mir in 30 Minuten". Ich muss scheinbar doch
bescheuert sein. [Andreas Schott]
More information about the AppArmor
mailing list