piknik

Unnamed repository; edit this file 'description' to name the repository.
Info | Log | Files | Refs | README | LICENSE

commit 886db2bcb7fd6aaadcd623ec55a63b3a512627b0
parent e975bd2b592f5c09215ab2f8951c5dc14732583b
Author: lash <dev@holbrook.no>
Date:   Fri,  2 Dec 2022 20:52:32 +0000

Add prelimiary message listing for html render

Diffstat:
Mpiknik/crypto.py | 4++--
Mpiknik/render/html.py | 46++++++++++++++++++++++++++++++++++++++++++----
Mpiknik/wrap.py | 1+
3 files changed, 45 insertions(+), 6 deletions(-)

diff --git a/piknik/crypto.py b/piknik/crypto.py @@ -17,8 +17,8 @@ logging.getLogger('gnupg').setLevel(logging.ERROR) class PGPSigner(Wrapper): - def __init__(self, home_dir=None, default_key=None, passphrase=None, use_agent=False, skip_verify=False): - super(PGPSigner, self).__init__() + def __init__(self, home_dir=None, dump_dir=None, default_key=None, passphrase=None, use_agent=False, skip_verify=False): + super(PGPSigner, self).__init__(dump_dir=dump_dir) self.gpg = gnupg.GPG(gnupghome=home_dir) self.default_key = default_key self.passphrase = passphrase diff --git a/piknik/render/html.py b/piknik/render/html.py @@ -16,20 +16,27 @@ logg = logging.getLogger(__name__) class Accumulator: - def __init__(self): + def __init__(self, w=sys.stdout): self.doc = None self.category = ul(_id='state_list') self.issue = None + self.msg = None + self.w = w #self.message = None - def add(self, v, w=sys.stdout): + def add(self, v, w=None): + if w == None: + w = self.w if len(v) == 0: self.doc.add(self.category) + if self.msg != None: + self.doc.add(self.msg) w.write(self.doc.render()) return v_id = getattr(v, 'id', '') + logg.debug('add id {}'.format(v_id)) if len(v_id) > 1: if v_id[:2] == 's_': if self.issue != None: @@ -41,6 +48,9 @@ class Accumulator: self.issue.add(v) elif v_id[:4] == 'd_i_': self.category = v + self.msg = ol(_id='message_list') + elif v_id[:2] == 'm_': + self.msg.add(li(v)) else: self.doc = v @@ -73,7 +83,6 @@ class Renderer(BaseRenderer): s = issue.title u = a(s, href=issue.id + '.html') return li(u, _id='i_' + issue.id) - r = div(_id='d_i_' + issue.id) @@ -114,6 +123,34 @@ class Renderer(BaseRenderer): super(Renderer, self).apply_issue(state, issue, tags, accumulator=accumulator) + + def apply_message(self, state, issue, tags, envelope, message, message_id, message_date, accumulator=None): + import uuid + rnd = str(uuid.uuid4()) + r = div(_id='m_' + message_id + '_' + rnd) + + s = dd() + s.add(dt('Date')) + s.add(dd(str(message_date))) + + v = envelope.sender + if v == None: + v = '(unknown)' + else: + if envelope.valid: + v += ' (!!)' + else: + v += ' (??)' + s.add(dt('By')) + s.add(dd(v)) + r.add(s) + + s = div(message.get_payload()) + r.add(s) + + return r + + # def apply_state_post(self, state, w=sys.stdout): # r = div(_id='state_' + state) # r.add(h2(state)) @@ -222,7 +259,8 @@ class Renderer(BaseRenderer): def apply_end(self, accumulator=None): - return () + self.add(()) + return None # def apply_end(self, w=sys.stdout): diff --git a/piknik/wrap.py b/piknik/wrap.py @@ -23,6 +23,7 @@ class Wrapper: def process_envelope(self, msg, env_header): self.envelope = MessageEnvelope(msg) self.envelope_state = 0 + return self.envelope def process_message(self, msg, message_id, message_date):