Mercurial > libervia-backend
diff sat/plugins/plugin_tickets_import.py @ 4037:524856bd7b19
massive refactoring to switch from camelCase to snake_case:
historically, Libervia (SàT before) was using camelCase as allowed by PEP8 when using a
pre-PEP8 code, to use the same coding style as in Twisted.
However, snake_case is more readable and it's better to follow PEP8 best practices, so it
has been decided to move on full snake_case. Because Libervia has a huge codebase, this
ended with a ugly mix of camelCase and snake_case.
To fix that, this patch does a big refactoring by renaming every function and method
(including bridge) that are not coming from Twisted or Wokkel, to use fully snake_case.
This is a massive change, and may result in some bugs.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 08 Apr 2023 13:54:42 +0200 |
parents | 6c5f0fbc519b |
children |
line wrap: on
line diff
--- a/sat/plugins/plugin_tickets_import.py Fri Apr 07 15:18:39 2023 +0200 +++ b/sat/plugins/plugin_tickets_import.py Sat Apr 08 13:54:42 2023 +0200 @@ -54,7 +54,7 @@ OPT_DEFAULTS = {} def __init__(self, host): - log.info(_("plugin Tickets Import initialization")) + log.info(_("plugin Tickets import initialization")) self.host = host self._importers = {} self._p = host.plugins["XEP-0060"] @@ -63,7 +63,7 @@ host.plugins["IMPORT"].initialize(self, "tickets") @defer.inlineCallbacks - def importItem( + def import_item( self, client, item_import_data, session, options, return_data, service, node ): """ @@ -121,19 +121,19 @@ if session["root_node"] is None: session["root_node"] = NS_TICKETS if not "schema" in session: - session["schema"] = yield self._s.getSchemaForm( + session["schema"] = yield self._s.get_schema_form( client, service, node or session["root_node"] ) defer.returnValue(item_import_data) @defer.inlineCallbacks - def importSubItems(self, client, item_import_data, ticket_data, session, options): + def import_sub_items(self, client, item_import_data, ticket_data, session, options): # TODO: force "open" permission (except if private, check below) # TODO: handle "private" metadata, to have non public access for node # TODO: node access/publish model should be customisable comments = ticket_data.get("comments", []) - service = yield self._m.getCommentsService(client) - node = self._m.getCommentsNode(session["root_node"] + "_" + ticket_data["id"]) + service = yield self._m.get_comments_service(client) + node = self._m.get_comments_node(session["root_node"] + "_" + ticket_data["id"]) node_options = { self._p.OPT_ACCESS_MODEL: self._p.ACCESS_OPEN, self._p.OPT_PERSIST_ITEMS: 1, @@ -141,8 +141,8 @@ self._p.OPT_SEND_ITEM_SUBSCRIBE: 1, self._p.OPT_PUBLISH_MODEL: self._p.ACCESS_OPEN, } - yield self._p.createIfNewNode(client, service, node, options=node_options) - ticket_data["comments_uri"] = uri.buildXMPPUri( + yield self._p.create_if_new_node(client, service, node, options=node_options) + ticket_data["comments_uri"] = uri.build_xmpp_uri( "pubsub", subtype="microblog", path=service.full(), node=node ) for comment in comments: @@ -151,7 +151,7 @@ comment["updated"] = comment["published"] yield self._m.send(client, comment, service, node) - def publishItem(self, client, ticket_data, service, node, session): + def publish_item(self, client, ticket_data, service, node, session): if node is None: node = NS_TICKETS id_ = ticket_data.pop("id", None) @@ -161,12 +161,12 @@ ) ) return defer.ensureDeferred( - self._s.sendDataFormItem( + self._s.send_data_form_item( client, service, node, ticket_data, session["schema"], id_ ) ) - def itemFilters(self, client, ticket_data, session, options): + def item_filters(self, client, ticket_data, session, options): mapping = options.get(OPT_MAPPING) if mapping is not None: if not isinstance(mapping, dict):