diff libervia/pages/merge-requests/edit/page_meta.py @ 1216:b2d067339de3

python 3 port: /!\ Python 3.6+ is now needed to use libervia /!\ instability may occur and features may not be working anymore, this will improve with time /!\ TxJSONRPC dependency has been removed The same procedure as in backend has been applied (check backend commit ab2696e34d29 logs for details). Removed now deprecated code (Pyjamas compiled browser part, legacy blog, JSON RPC related code). Adapted code to work without `html` and `themes` dirs.
author Goffi <goffi@goffi.org>
date Tue, 13 Aug 2019 19:12:31 +0200
parents bed008b65d7c
children f511f8fbbf8a
line wrap: on
line diff
--- a/libervia/pages/merge-requests/edit/page_meta.py	Tue Aug 13 09:39:33 2019 +0200
+++ b/libervia/pages/merge-requests/edit/page_meta.py	Tue Aug 13 19:12:31 2019 +0200
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2.7
+#!/usr/bin/env python3
 # -*- coding: utf-8 -*-
 
 from libervia.server.constants import Const as C
@@ -10,9 +10,9 @@
 
 """merge-requests edition"""
 
-name = u"merge-requests_edit"
+name = "merge-requests_edit"
 access = C.PAGES_ACCESS_PROFILE
-template = u"merge-request/edit.html"
+template = "merge-request/edit.html"
 log = getLogger(__name__)
 
 
@@ -20,11 +20,11 @@
     try:
         item_id = self.nextPath(request)
     except IndexError:
-        log.warning(_(u"no ticket id specified"))
+        log.warning(_("no ticket id specified"))
         self.pageError(request, C.HTTP_BAD_REQUEST)
 
     data = self.getRData(request)
-    data[u"ticket_id"] = item_id
+    data["ticket_id"] = item_id
 
 
 @defer.inlineCallbacks
@@ -32,9 +32,9 @@
     data = self.getRData(request)
     template_data = request.template_data
     service, node, ticket_id = (
-        data.get(u"service", u""),
-        data.get(u"node", u""),
-        data[u"ticket_id"],
+        data.get("service", ""),
+        data.get("node", ""),
+        data["ticket_id"],
     )
     profile = self.getProfile(request)
 
@@ -51,7 +51,7 @@
     )
     tickets = yield self.host.bridgeCall(
         "mergeRequestsGet",
-        service.full() if service else u"",
+        service.full() if service else "",
         node,
         C.NO_LIMIT,
         [ticket_id],
@@ -63,22 +63,22 @@
 
     try:
         # small trick to get a one line text input instead of the big textarea
-        ticket.widgets[u"labels"].type = u"string"
-        ticket.widgets[u"labels"].value = ticket.widgets[u"labels"].value.replace(
-            u"\n", ", "
+        ticket.widgets["labels"].type = "string"
+        ticket.widgets["labels"].value = ticket.widgets["labels"].value.replace(
+            "\n", ", "
         )
     except KeyError:
         pass
 
     # same as tickets_edit
-    wid = ticket.widgets[u'body']
-    if wid.type == u"xhtmlbox":
-        wid.type = u"textbox"
+    wid = ticket.widgets['body']
+    if wid.type == "xhtmlbox":
+        wid.type = "textbox"
         wid.value =  yield self.host.bridgeCall(
-            u"syntaxConvert", wid.value, C.SYNTAX_XHTML, u"markdown",
+            "syntaxConvert", wid.value, C.SYNTAX_XHTML, "markdown",
             False, profile)
 
-    template_data[u"new_ticket_xmlui"] = ticket
+    template_data["new_ticket_xmlui"] = ticket
 
 
 @defer.inlineCallbacks
@@ -98,27 +98,27 @@
 
     # we convert back body to XHTML
     body = yield self.host.bridgeCall(
-        u"syntaxConvert", posted_data[u'body'][0], u"markdown", C.SYNTAX_XHTML,
+        "syntaxConvert", posted_data['body'][0], "markdown", C.SYNTAX_XHTML,
         False, profile)
-    posted_data[u'body'] = [u'<div xmlns="{ns}">{body}</div>'.format(ns=C.NS_XHTML,
+    posted_data['body'] = ['<div xmlns="{ns}">{body}</div>'.format(ns=C.NS_XHTML,
                                                                      body=body)]
 
-    extra = {u'update': True}
+    extra = {'update': True}
     yield self.host.bridgeCall(
         "mergeRequestSet",
         service.full(),
         node,
-        u"",
-        u"auto",
+        "",
+        "auto",
         posted_data,
-        u"",
+        "",
         ticket_id,
         data_format.serialise(extra),
         profile,
     )
     # we don't want to redirect to edit page on success, but to tickets list
     data["post_redirect_page"] = (
-        self.getPageByName(u"merge-requests"),
+        self.getPageByName("merge-requests"),
         service.full(),
-        node or u"@",
+        node or "@",
     )