diff sat/plugins/plugin_merge_req_mercurial.py @ 2620:72f6f37ab648

core: some more line limiting
author Goffi <goffi@goffi.org>
date Wed, 27 Jun 2018 07:23:13 +0200
parents 26edcf3a30eb
children 2f75830a8228
line wrap: on
line diff
--- a/sat/plugins/plugin_merge_req_mercurial.py	Tue Jun 26 22:02:59 2018 +0200
+++ b/sat/plugins/plugin_merge_req_mercurial.py	Wed Jun 27 07:23:13 2018 +0200
@@ -71,15 +71,14 @@
             log.debug(_('Mercurial command succeed'))
             self._deferred.callback(data)
         else:
-            msg = _(u"Can't complete Mercurial command (error code: {code}): {message}").format(
-                code = reason.value.exitCode,
-                message = data)
+            msg = (_(u"Can't complete Mercurial command (error code: {code}): {message}")
+                   .format(code = reason.value.exitCode, message = data))
             log.warning(msg)
             self._deferred.errback(Failure(RuntimeError(msg)))
 
     @classmethod
     def run(cls, path, command, *args, **kwargs):
-        """Create a new MercurialRegisterProtocol and execute the given mercurialctl command.
+        """Create a new MercurialRegisterProtocol and execute the given mercurial command.
 
         @param path(unicode): path to the repository
         @param command(unicode): command to run
@@ -113,7 +112,8 @@
         try:
             MercurialProtocol.hg = which('hg')[0]
         except IndexError:
-            raise exceptions.NotFound(_(u"Mercurial executable (hg) not found, can't use Mercurial handler"))
+            raise exceptions.NotFound(_(u"Mercurial executable (hg) not found, "
+                                        u"can't use Mercurial handler"))
         self.host = host
         self._m = host.plugins['MERGE_REQUESTS']
         self._m.register('mercurial', self, self.data_types, SHORT_DESC)
@@ -125,7 +125,8 @@
         return d
 
     def export(self, repository):
-        return MercurialProtocol.run(repository, 'export', '-g', '-r', 'outgoing()', '--encoding=utf-8')
+        return MercurialProtocol.run(repository, 'export', '-g', '-r', 'outgoing()',
+                                     '--encoding=utf-8')
 
     def import_(self, repository, data, data_type, item_id, service, node, extra):
         parsed_data = self.parse(data)
@@ -134,8 +135,10 @@
             parsed_name = re.sub(ur'[^\w -.]', u'', parsed_name, flags=re.UNICODE)[:40]
         except Exception:
             parsed_name = u''
-        name = u'mr_{item_id}_{parsed_name}'.format(item_id=item_id, parsed_name=parsed_name)
-        return MercurialProtocol.run(repository, 'qimport', '-g', '--name', name, '--encoding=utf-8', '-', stdin=data)
+        name = u'mr_{item_id}_{parsed_name}'.format(item_id=item_id,
+                                                    parsed_name=parsed_name)
+        return MercurialProtocol.run(repository, 'qimport', '-g', '--name', name,
+                                     '--encoding=utf-8', '-', stdin=data)
 
     def parse(self, data, data_type=None):
         lines = data.splitlines()
@@ -160,15 +163,18 @@
                             if not elems:
                                 continue
                             last = elems[-1]
-                            if last.startswith(u'<') and last.endswith(u'>') and u'@' in last:
+                            if (last.startswith(u'<') and last.endswith(u'>')
+                                and u'@' in last):
                                 patch[self._m.META_EMAIL] = elems.pop()[1:-1]
                             patch[self._m.META_AUTHOR] = u' '.join(elems)
                         elif line.startswith(u'# Date '):
                             time_data = line[7:].split()
                             if len(time_data) != 2:
-                                log.warning(_(u'unexpected time data: {data}').format(data=line[7:]))
+                                log.warning(_(u'unexpected time data: {data}')
+                                            .format(data=line[7:]))
                                 continue
-                            patch[self._m.META_TIMESTAMP] = int(time_data[0]) + int(time_data[1])
+                            patch[self._m.META_TIMESTAMP] = (int(time_data[0])
+                                                             + int(time_data[1]))
                         elif line.startswith(u'# Node ID '):
                             patch[self._m.META_HASH] = line[10:]
                         elif line.startswith(u'# Parent  '):