Philipp Hörist pushed to branch master at gajim / gajim
Commits:
-
0ad41c9c
by lovetox at 2022-07-24T10:41:04+02:00
-
2242a9d8
by lovetox at 2022-07-24T10:48:33+02:00
-
81f3d555
by lovetox at 2022-07-24T10:59:33+02:00
-
6b5db823
by lovetox at 2022-07-24T10:59:51+02:00
-
f2f022aa
by lovetox at 2022-07-24T11:01:40+02:00
7 changed files:
- .githooks/update
- CONTRIBUTING.md
- gajim/common/const.py
- gajim/common/storage/archive.py
- gajim/dev/ipython_view.py
- setup.cfg
- win/misc/create-launcher.py
Changes:
| ... | ... | @@ -11,6 +11,7 @@ import subprocess |
| 11 | 11 | |
| 12 | 12 | ALLOWED_TAGS = [
|
| 13 | 13 | 'ci',
|
| 14 | + 'cs',
|
|
| 14 | 15 | 'feat',
|
| 15 | 16 | 'fix',
|
| 16 | 17 | 'perf',
|
| ... | ... | @@ -35,6 +35,7 @@ # Commit Messages |
| 35 | 35 | Every commit message must be prefixed with one of the following tags:
|
| 36 | 36 | |
| 37 | 37 | - ci (ci related changes)
|
| 38 | +- cs (code style changes)
|
|
| 38 | 39 | - feat (a new feature was added)
|
| 39 | 40 | - fix (something was fixed)
|
| 40 | 41 | - perf (performance related changes)
|
| ... | ... | @@ -465,85 +465,88 @@ class CallType(Enum): |
| 465 | 465 | CONSONANTS = 'bcdfghjklmnpqrstvwxyz'
|
| 466 | 466 | |
| 467 | 467 | |
| 468 | -THANKS = u"""\
|
|
| 469 | -Alexander Futász
|
|
| 470 | -Alexander V. Butenko
|
|
| 471 | -Alexey Nezhdanov
|
|
| 472 | -Alfredo Junix
|
|
| 473 | -Anaël Verrier
|
|
| 474 | -Anders Ström
|
|
| 475 | -Andrew Sayman
|
|
| 476 | -Anton Shmigirilov
|
|
| 477 | -Christian Bjälevik
|
|
| 478 | -Christophe Got
|
|
| 479 | -Christoph Neuroth
|
|
| 480 | -David Campey
|
|
| 481 | -Dennis Craven
|
|
| 482 | -Fabian Neumann
|
|
| 483 | -Filippos Papadopoulos
|
|
| 484 | -Francisco Alburquerque Parra (Membris Khan)
|
|
| 485 | -Frederic Lory
|
|
| 486 | -Fridtjof Bussefor
|
|
| 487 | -Geobert Quach
|
|
| 488 | -Guillaume Morin
|
|
| 489 | -Gustavo J. A. M. Carneiro
|
|
| 490 | -Ivo Anjo
|
|
| 491 | -Josef Vybíral
|
|
| 492 | -Juraj Michalek
|
|
| 493 | -Kjell Braden
|
|
| 494 | -Luis Peralta
|
|
| 495 | -Michael Scherer
|
|
| 496 | -Michele Campeotto
|
|
| 497 | -Mike Albon
|
|
| 498 | -Miguel Fonseca
|
|
| 499 | -Norman Rasmussen
|
|
| 500 | -Oscar Hellström
|
|
| 501 | -Peter Saint-Andre
|
|
| 502 | -Petr Menšík
|
|
| 503 | -Sergey Kuleshov
|
|
| 504 | -Stavros Giannouris
|
|
| 505 | -Stian B. Barmen
|
|
| 506 | -Thilo Molitor
|
|
| 507 | -Thomas Klein-Hitpaß
|
|
| 508 | -Urtzi Alfaro
|
|
| 509 | -Witold Kieraś
|
|
| 510 | -Yakov Bezrukov
|
|
| 511 | -Yavor Doganov
|
|
| 512 | -""".strip().split("\n")
|
|
| 513 | - |
|
| 514 | -ARTISTS = u"""\
|
|
| 515 | -Anders Ström
|
|
| 516 | -Christophe Got
|
|
| 517 | -Dennis Craven
|
|
| 518 | -Dmitry Korzhevin
|
|
| 519 | -Guillaume Morin
|
|
| 520 | -Gvorcek Spajreh
|
|
| 521 | -Josef Vybíral
|
|
| 522 | -Membris Khan
|
|
| 523 | -Rederick Asher
|
|
| 524 | -Jakub Szypulka
|
|
| 525 | -""".strip().split("\n")
|
|
| 526 | - |
|
| 527 | -DEVS_CURRENT = u"""\
|
|
| 528 | -Yann Leboulanger (asterix AT lagaule.org)
|
|
| 529 | -Philipp Hörist (philipp AT hoerist.com)
|
|
| 530 | -Daniel Brötzmann (wurstsalat AT posteo.de)
|
|
| 531 | -André Apitzsch
|
|
| 532 | -""".strip().split("\n")
|
|
| 533 | - |
|
| 534 | -DEVS_PAST = u"""\
|
|
| 535 | -Stefan Bethge (stefan AT lanpartei.de)
|
|
| 536 | -Alexander Cherniuk (ts33kr AT gmail.com)
|
|
| 537 | -Stephan Erb (steve-e AT h3c.de)
|
|
| 538 | -Vincent Hanquez (tab AT snarc.org)
|
|
| 539 | -Dimitur Kirov (dkirov AT gmail.com)
|
|
| 540 | -Nikos Kouremenos (kourem AT gmail.com)
|
|
| 541 | -Julien Pivotto (roidelapluie AT gmail.com)
|
|
| 542 | -Jonathan Schleifer (js-gajim AT webkeks.org)
|
|
| 543 | -Travis Shirk (travis AT pobox.com)
|
|
| 544 | -Brendan Taylor (whateley AT gmail.com)
|
|
| 545 | -Jean-Marie Traissard (jim AT lapin.org)
|
|
| 546 | -""".strip().split("\n")
|
|
| 468 | +THANKS = [
|
|
| 469 | + 'Alexander Futász',
|
|
| 470 | + 'Alexander V. Butenko',
|
|
| 471 | + 'Alexey Nezhdanov',
|
|
| 472 | + 'Alfredo Junix',
|
|
| 473 | + 'Anaël Verrier',
|
|
| 474 | + 'Anders Ström',
|
|
| 475 | + 'Andrew Sayman',
|
|
| 476 | + 'Anton Shmigirilov',
|
|
| 477 | + 'Christian Bjälevik',
|
|
| 478 | + 'Christophe Got',
|
|
| 479 | + 'Christoph Neuroth',
|
|
| 480 | + 'David Campey',
|
|
| 481 | + 'Dennis Craven',
|
|
| 482 | + 'Fabian Neumann',
|
|
| 483 | + 'Filippos Papadopoulos',
|
|
| 484 | + 'Francisco Alburquerque Parra (Membris Khan)',
|
|
| 485 | + 'Frederic Lory',
|
|
| 486 | + 'Fridtjof Bussefor',
|
|
| 487 | + 'Geobert Quach',
|
|
| 488 | + 'Guillaume Morin',
|
|
| 489 | + 'Gustavo J. A. M. Carneiro',
|
|
| 490 | + 'Ivo Anjo',
|
|
| 491 | + 'Josef Vybíral',
|
|
| 492 | + 'Juraj Michalek',
|
|
| 493 | + 'Kjell Braden',
|
|
| 494 | + 'Luis Peralta',
|
|
| 495 | + 'Michael Scherer',
|
|
| 496 | + 'Michele Campeotto',
|
|
| 497 | + 'Mike Albon',
|
|
| 498 | + 'Miguel Fonseca',
|
|
| 499 | + 'Norman Rasmussen',
|
|
| 500 | + 'Oscar Hellström',
|
|
| 501 | + 'Peter Saint-Andre',
|
|
| 502 | + 'Petr Menšík',
|
|
| 503 | + 'Sergey Kuleshov',
|
|
| 504 | + 'Stavros Giannouris',
|
|
| 505 | + 'Stian B. Barmen',
|
|
| 506 | + 'Thilo Molitor',
|
|
| 507 | + 'Thomas Klein-Hitpaß',
|
|
| 508 | + 'Urtzi Alfaro',
|
|
| 509 | + 'Witold Kieraś',
|
|
| 510 | + 'Yakov Bezrukov',
|
|
| 511 | + 'Yavor Doganov',
|
|
| 512 | +]
|
|
| 513 | + |
|
| 514 | + |
|
| 515 | +ARTISTS = [
|
|
| 516 | + 'Anders Ström',
|
|
| 517 | + 'Christophe Got',
|
|
| 518 | + 'Dennis Craven',
|
|
| 519 | + 'Dmitry Korzhevin',
|
|
| 520 | + 'Guillaume Morin',
|
|
| 521 | + 'Gvorcek Spajreh',
|
|
| 522 | + 'Josef Vybíral',
|
|
| 523 | + 'Membris Khan',
|
|
| 524 | + 'Rederick Asher',
|
|
| 525 | + 'Jakub Szypulka',
|
|
| 526 | +]
|
|
| 527 | + |
|
| 528 | + |
|
| 529 | +DEVS_CURRENT = [
|
|
| 530 | + 'Yann Leboulanger (asterix AT lagaule.org)',
|
|
| 531 | + 'Philipp Hörist (philipp AT hoerist.com)',
|
|
| 532 | + 'Daniel Brötzmann (wurstsalat AT posteo.de)',
|
|
| 533 | + 'André Apitzsch',
|
|
| 534 | +]
|
|
| 535 | + |
|
| 536 | + |
|
| 537 | +DEVS_PAST = [
|
|
| 538 | + 'Stefan Bethge (stefan AT lanpartei.de)',
|
|
| 539 | + 'Alexander Cherniuk (ts33kr AT gmail.com)',
|
|
| 540 | + 'Stephan Erb (steve-e AT h3c.de)',
|
|
| 541 | + 'Vincent Hanquez (tab AT snarc.org)',
|
|
| 542 | + 'Dimitur Kirov (dkirov AT gmail.com)',
|
|
| 543 | + 'Nikos Kouremenos (kourem AT gmail.com)',
|
|
| 544 | + 'Julien Pivotto (roidelapluie AT gmail.com)',
|
|
| 545 | + 'Jonathan Schleifer (js-gajim AT webkeks.org)',
|
|
| 546 | + 'Travis Shirk (travis AT pobox.com)',
|
|
| 547 | + 'Brendan Taylor (whateley AT gmail.com)',
|
|
| 548 | + 'Jean-Marie Traissard (jim AT lapin.org)',
|
|
| 549 | +]
|
|
| 547 | 550 | |
| 548 | 551 | |
| 549 | 552 | RFC5646_LANGUAGE_TAGS = {
|
| ... | ... | @@ -177,8 +177,8 @@ def init(self, **kwargs: Any) -> None: |
| 177 | 177 | |
| 178 | 178 | self._con.row_factory = self._namedtuple_factory
|
| 179 | 179 | |
| 180 | - self._con.create_function("like", 1, self._like)
|
|
| 181 | - self._con.create_function("get_timeout", 0, self._get_timeout)
|
|
| 180 | + self._con.create_function('like', 1, self._like)
|
|
| 181 | + self._con.create_function('get_timeout', 0, self._get_timeout)
|
|
| 182 | 182 | |
| 183 | 183 | self._get_jid_ids_from_db()
|
| 184 | 184 | |
| ... | ... | @@ -188,7 +188,7 @@ def _namedtuple_factory(self, |
| 188 | 188 | |
| 189 | 189 | assert cursor.description is not None
|
| 190 | 190 | fields = [col[0] for col in cursor.description]
|
| 191 | - Row = namedtuple("Row", fields) # type: ignore
|
|
| 191 | + Row = namedtuple('Row', fields) # type: ignore
|
|
| 192 | 192 | named_row = Row(*row)
|
| 193 | 193 | if 'additional_data' in fields:
|
| 194 | 194 | _dict = json.loads(named_row.additional_data or '{}')
|
| ... | ... | @@ -259,9 +259,9 @@ def _migrate(self) -> None: |
| 259 | 259 | |
| 260 | 260 | @staticmethod
|
| 261 | 261 | def _get_timeout() -> int:
|
| 262 | - """
|
|
| 262 | + '''
|
|
| 263 | 263 | returns the timeout in epoch
|
| 264 | - """
|
|
| 264 | + '''
|
|
| 265 | 265 | timeout = app.settings.get('restore_timeout')
|
| 266 | 266 | |
| 267 | 267 | now = int(time.time())
|
| ... | ... | @@ -275,9 +275,9 @@ def _like(search_str: str) -> str: |
| 275 | 275 | |
| 276 | 276 | @timeit
|
| 277 | 277 | def _get_jid_ids_from_db(self) -> None:
|
| 278 | - """
|
|
| 278 | + '''
|
|
| 279 | 279 | Load all jid/jid_id tuples into a dict for faster access
|
| 280 | - """
|
|
| 280 | + '''
|
|
| 281 | 281 | rows = self._con.execute(
|
| 282 | 282 | 'SELECT jid_id, jid, type FROM jids').fetchall()
|
| 283 | 283 | for row in rows:
|
| ... | ... | @@ -310,7 +310,7 @@ def get_jid_id(self, |
| 310 | 310 | kind: Optional[KindConstant] = None,
|
| 311 | 311 | type_: Optional[JIDConstant] = None
|
| 312 | 312 | ) -> int:
|
| 313 | - """
|
|
| 313 | + '''
|
|
| 314 | 314 | Get the jid id from a jid.
|
| 315 | 315 | In case the jid id is not found create a new one.
|
| 316 | 316 | |
| ... | ... | @@ -321,7 +321,7 @@ def get_jid_id(self, |
| 321 | 321 | :param type_: The JIDConstant
|
| 322 | 322 | |
| 323 | 323 | return the jid id
|
| 324 | - """
|
|
| 324 | + '''
|
|
| 325 | 325 | |
| 326 | 326 | if kind in (KindConstant.GC_MSG, KindConstant.GCSTATUS):
|
| 327 | 327 | type_ = JIDConstant.ROOM_TYPE
|
| ... | ... | @@ -354,9 +354,9 @@ def get_jid_id(self, |
| 354 | 354 | @staticmethod
|
| 355 | 355 | def convert_show_values_to_db_api_values(show: Optional[str]
|
| 356 | 356 | ) -> Optional[ShowConstant]:
|
| 357 | - """
|
|
| 357 | + '''
|
|
| 358 | 358 | Convert from string style to constant ints for db
|
| 359 | - """
|
|
| 359 | + '''
|
|
| 360 | 360 | |
| 361 | 361 | if show == 'online':
|
| 362 | 362 | return ShowConstant.ONLINE
|
| ... | ... | @@ -384,7 +384,7 @@ def get_conversation_before_after(self, |
| 384 | 384 | timestamp: float,
|
| 385 | 385 | n_lines: int
|
| 386 | 386 | ) -> list[ConversationRow]:
|
| 387 | - """
|
|
| 387 | + '''
|
|
| 388 | 388 | Load n_lines lines of conversation with jid before or after timestamp
|
| 389 | 389 | |
| 390 | 390 | :param account: The account
|
| ... | ... | @@ -396,7 +396,7 @@ def get_conversation_before_after(self, |
| 396 | 396 | :param timestamp: timestamp
|
| 397 | 397 | |
| 398 | 398 | returns a list of namedtuples
|
| 399 | - """
|
|
| 399 | + '''
|
|
| 400 | 400 | jids = [jid]
|
| 401 | 401 | account_id = self.get_account_id(account)
|
| 402 | 402 | kinds = map(str, [KindConstant.ERROR,
|
| ... | ... | @@ -431,7 +431,7 @@ def get_last_conversation_line(self, |
| 431 | 431 | account: str,
|
| 432 | 432 | jid: JID
|
| 433 | 433 | ) -> LastConversationRow:
|
| 434 | - """
|
|
| 434 | + '''
|
|
| 435 | 435 | Load the last line of a conversation with jid for account.
|
| 436 | 436 | Loads messages, but no status messages or error messages.
|
| 437 | 437 | |
| ... | ... | @@ -440,7 +440,7 @@ def get_last_conversation_line(self, |
| 440 | 440 | :param jid: The jid for which we request the conversation
|
| 441 | 441 | |
| 442 | 442 | returns a list of namedtuples
|
| 443 | - """
|
|
| 443 | + '''
|
|
| 444 | 444 | jids = [jid]
|
| 445 | 445 | account_id = self.get_account_id(account)
|
| 446 | 446 | |
| ... | ... | @@ -468,7 +468,7 @@ def get_conversation_around(self, |
| 468 | 468 | timestamp: float
|
| 469 | 469 | ) -> tuple[list[ConversationRow],
|
| 470 | 470 | list[ConversationRow]]:
|
| 471 | - """
|
|
| 471 | + '''
|
|
| 472 | 472 | Load all lines of conversation with jid around a specific timestamp
|
| 473 | 473 | |
| 474 | 474 | :param account: The account
|
| ... | ... | @@ -478,7 +478,7 @@ def get_conversation_around(self, |
| 478 | 478 | :param timestamp: Timestamp around which to fetch messages
|
| 479 | 479 | |
| 480 | 480 | returns a list of namedtuples
|
| 481 | - """
|
|
| 481 | + '''
|
|
| 482 | 482 | jids = [jid]
|
| 483 | 483 | account_id = self.get_account_id(account)
|
| 484 | 484 | kinds = map(str, [KindConstant.ERROR])
|
| ... | ... | @@ -526,7 +526,7 @@ def get_conversation_between(self, |
| 526 | 526 | jid: str,
|
| 527 | 527 | before: float,
|
| 528 | 528 | after: float) -> list[ConversationRow]:
|
| 529 | - """
|
|
| 529 | + '''
|
|
| 530 | 530 | Load all lines of conversation with jid between two timestamps
|
| 531 | 531 | |
| 532 | 532 | :param account: The account
|
| ... | ... | @@ -538,7 +538,7 @@ def get_conversation_between(self, |
| 538 | 538 | :param after: earliest timestamp
|
| 539 | 539 | |
| 540 | 540 | returns a list of namedtuples
|
| 541 | - """
|
|
| 541 | + '''
|
|
| 542 | 542 | jids = [jid]
|
| 543 | 543 | account_id = self.get_account_id(account)
|
| 544 | 544 | kinds = map(str, [KindConstant.ERROR])
|
| ... | ... | @@ -570,7 +570,7 @@ def search_log(self, |
| 570 | 570 | before: Optional[datetime.datetime] = None,
|
| 571 | 571 | after: Optional[datetime.datetime] = None
|
| 572 | 572 | ) -> Iterator[SearchLogRow]:
|
| 573 | - """
|
|
| 573 | + '''
|
|
| 574 | 574 | Search the conversation log for messages containing the `query` string.
|
| 575 | 575 | |
| 576 | 576 | The search can either span the complete log for the given
|
| ... | ... | @@ -590,7 +590,7 @@ def search_log(self, |
| 590 | 590 | :param after: A datetime.datetime instance or None
|
| 591 | 591 | |
| 592 | 592 | returns a list of namedtuples
|
| 593 | - """
|
|
| 593 | + '''
|
|
| 594 | 594 | jids = [jid]
|
| 595 | 595 | |
| 596 | 596 | kinds = map(str, [KindConstant.STATUS,
|
| ... | ... | @@ -654,7 +654,7 @@ def search_all_logs(self, |
| 654 | 654 | before: Optional[datetime.datetime] = None,
|
| 655 | 655 | after: Optional[datetime.datetime] = None
|
| 656 | 656 | ) -> Iterator[SearchLogRow]:
|
| 657 | - """
|
|
| 657 | + '''
|
|
| 658 | 658 | Search all conversation logs for messages containing the `query`
|
| 659 | 659 | string.
|
| 660 | 660 | |
| ... | ... | @@ -667,7 +667,7 @@ def search_all_logs(self, |
| 667 | 667 | :param after: A datetime.datetime instance or None
|
| 668 | 668 | |
| 669 | 669 | returns a list of namedtuples
|
| 670 | - """
|
|
| 670 | + '''
|
|
| 671 | 671 | account_ids = self.get_active_account_ids()
|
| 672 | 672 | kinds = map(str, [KindConstant.STATUS,
|
| 673 | 673 | KindConstant.GCSTATUS])
|
| ... | ... | @@ -726,9 +726,9 @@ def get_days_with_history(self, |
| 726 | 726 | year: int,
|
| 727 | 727 | month: int
|
| 728 | 728 | ) -> list[HistoryDayRow]:
|
| 729 | - """
|
|
| 729 | + '''
|
|
| 730 | 730 | Get days in month where messages for 'jid' exist
|
| 731 | - """
|
|
| 731 | + '''
|
|
| 732 | 732 | jids = [jid]
|
| 733 | 733 | account_id = self.get_account_id(account)
|
| 734 | 734 | kinds = map(str, [KindConstant.STATUS,
|
| ... | ... | @@ -740,7 +740,7 @@ def get_days_with_history(self, |
| 740 | 740 | delta = datetime.timedelta(
|
| 741 | 741 | days=days, hours=23, minutes=59, seconds=59, microseconds=999999)
|
| 742 | 742 | |
| 743 | - sql = """
|
|
| 743 | + sql = '''
|
|
| 744 | 744 | SELECT DISTINCT
|
| 745 | 745 | CAST(strftime('%d', time, 'unixepoch', 'localtime') AS INTEGER)
|
| 746 | 746 | AS day FROM logs NATURAL JOIN jids WHERE jid IN ({jids})
|
| ... | ... | @@ -748,7 +748,7 @@ def get_days_with_history(self, |
| 748 | 748 | AND time BETWEEN ? AND ?
|
| 749 | 749 | AND kind NOT IN ({kinds})
|
| 750 | 750 | ORDER BY time
|
| 751 | - """.format(jids=', '.join('?' * len(jids)),
|
|
| 751 | + '''.format(jids=', '.join('?' * len(jids)),
|
|
| 752 | 752 | account_id=account_id,
|
| 753 | 753 | kinds=', '.join(kinds))
|
| 754 | 754 | |
| ... | ... | @@ -762,9 +762,9 @@ def get_last_history_timestamp(self, |
| 762 | 762 | account: str,
|
| 763 | 763 | jid: str
|
| 764 | 764 | ) -> Optional[float]:
|
| 765 | - """
|
|
| 765 | + '''
|
|
| 766 | 766 | Get the timestamp of the last message we received for the jid
|
| 767 | - """
|
|
| 767 | + '''
|
|
| 768 | 768 | jids = [jid]
|
| 769 | 769 | account_id = self.get_account_id(account)
|
| 770 | 770 | kinds = map(str, [KindConstant.STATUS,
|
| ... | ... | @@ -788,9 +788,9 @@ def get_first_history_timestamp(self, |
| 788 | 788 | account: str,
|
| 789 | 789 | jid: str
|
| 790 | 790 | ) -> Optional[float]:
|
| 791 | - """
|
|
| 791 | + '''
|
|
| 792 | 792 | Get the timestamp of the first message we received for the jid
|
| 793 | - """
|
|
| 793 | + '''
|
|
| 794 | 794 | jids = [jid]
|
| 795 | 795 | account_id = self.get_account_id(account)
|
| 796 | 796 | kinds = map(str, [KindConstant.STATUS,
|
| ... | ... | @@ -815,10 +815,10 @@ def date_has_history(self, |
| 815 | 815 | jid: str,
|
| 816 | 816 | date: datetime.datetime
|
| 817 | 817 | ) -> Optional[float]:
|
| 818 | - """
|
|
| 818 | + '''
|
|
| 819 | 819 | Get a single timestamp of a message for 'jid'
|
| 820 | 820 | in time range of one day
|
| 821 | - """
|
|
| 821 | + '''
|
|
| 822 | 822 | jids = [jid]
|
| 823 | 823 | account_id = self.get_account_id(account)
|
| 824 | 824 | delta = datetime.timedelta(
|
| ... | ... | @@ -844,9 +844,9 @@ def get_first_message_meta_for_date(self, |
| 844 | 844 | jid: str,
|
| 845 | 845 | date: datetime.datetime
|
| 846 | 846 | ) -> Optional[MessageMetaRow]:
|
| 847 | - """
|
|
| 847 | + '''
|
|
| 848 | 848 | Load meta data for the first message of a specific date
|
| 849 | - """
|
|
| 849 | + '''
|
|
| 850 | 850 | jids = [jid]
|
| 851 | 851 | account_id = self.get_account_id(account)
|
| 852 | 852 | |
| ... | ... | @@ -876,7 +876,7 @@ def deduplicate_muc_message(self, |
| 876 | 876 | timestamp: float,
|
| 877 | 877 | message_id: str
|
| 878 | 878 | ) -> bool:
|
| 879 | - """
|
|
| 879 | + '''
|
|
| 880 | 880 | Check if a message is already in the `logs` table
|
| 881 | 881 | |
| 882 | 882 | :param account: The account
|
| ... | ... | @@ -888,7 +888,7 @@ def deduplicate_muc_message(self, |
| 888 | 888 | :param timestamp: The timestamp in UTC epoch
|
| 889 | 889 | |
| 890 | 890 | :param message_id: The message-id
|
| 891 | - """
|
|
| 891 | + '''
|
|
| 892 | 892 | |
| 893 | 893 | # Add 60 seconds around the timestamp
|
| 894 | 894 | start_time = timestamp - 60
|
| ... | ... | @@ -929,7 +929,7 @@ def find_stanza_id(self, |
| 929 | 929 | origin_id: Optional[str] = None,
|
| 930 | 930 | groupchat: bool = False
|
| 931 | 931 | ) -> bool:
|
| 932 | - """
|
|
| 932 | + '''
|
|
| 933 | 933 | Checks if a stanza-id is already in the `logs` table
|
| 934 | 934 | |
| 935 | 935 | :param account: The account
|
| ... | ... | @@ -944,7 +944,7 @@ def find_stanza_id(self, |
| 944 | 944 | :param groupchat: stanza-id is from a groupchat
|
| 945 | 945 | |
| 946 | 946 | return True if the stanza-id was found
|
| 947 | - """
|
|
| 947 | + '''
|
|
| 948 | 948 | ids: list[str] = []
|
| 949 | 949 | if stanza_id is not None:
|
| 950 | 950 | ids.append(stanza_id)
|
| ... | ... | @@ -1122,7 +1122,7 @@ def insert_jid(self, |
| 1122 | 1122 | kind: Optional[KindConstant] = None,
|
| 1123 | 1123 | type_: JIDConstant = JIDConstant.NORMAL_TYPE
|
| 1124 | 1124 | ) -> int:
|
| 1125 | - """
|
|
| 1125 | + '''
|
|
| 1126 | 1126 | Insert a new jid into the `jids` table.
|
| 1127 | 1127 | This is an alias of get_jid_id() for better readablility.
|
| 1128 | 1128 | |
| ... | ... | @@ -1131,7 +1131,7 @@ def insert_jid(self, |
| 1131 | 1131 | :param kind: A KindConstant
|
| 1132 | 1132 | |
| 1133 | 1133 | :param type_: A JIDConstant
|
| 1134 | - """
|
|
| 1134 | + '''
|
|
| 1135 | 1135 | return self.get_jid_id(jid, kind, type_)
|
| 1136 | 1136 | |
| 1137 | 1137 | @timeit
|
| ... | ... | @@ -1142,7 +1142,7 @@ def insert_into_logs(self, |
| 1142 | 1142 | kind: KindConstant,
|
| 1143 | 1143 | **kwargs: Any
|
| 1144 | 1144 | ) -> int:
|
| 1145 | - """
|
|
| 1145 | + '''
|
|
| 1146 | 1146 | Insert a new message into the `logs` table
|
| 1147 | 1147 | |
| 1148 | 1148 | :param jid: The jid as string
|
| ... | ... | @@ -1156,7 +1156,7 @@ def insert_into_logs(self, |
| 1156 | 1156 | |
| 1157 | 1157 | :param kwargs: Every additional named argument must correspond to
|
| 1158 | 1158 | a field in the `logs` table
|
| 1159 | - """
|
|
| 1159 | + '''
|
|
| 1160 | 1160 | jid_id = self.get_jid_id(jid, kind=kind)
|
| 1161 | 1161 | account_id = self.get_account_id(account)
|
| 1162 | 1162 | |
| ... | ... | @@ -1193,7 +1193,7 @@ def set_message_error(self, |
| 1193 | 1193 | message_id: str,
|
| 1194 | 1194 | error: str
|
| 1195 | 1195 | ) -> None:
|
| 1196 | - """
|
|
| 1196 | + '''
|
|
| 1197 | 1197 | Update the corresponding message with the error
|
| 1198 | 1198 | |
| 1199 | 1199 | :param account_jid: The jid of the account
|
| ... | ... | @@ -1204,7 +1204,7 @@ def set_message_error(self, |
| 1204 | 1204 | |
| 1205 | 1205 | :param error: The error stanza as string
|
| 1206 | 1206 | |
| 1207 | - """
|
|
| 1207 | + '''
|
|
| 1208 | 1208 | |
| 1209 | 1209 | account_id = self.get_jid_id(account_jid)
|
| 1210 | 1210 | try:
|
| ... | ... | @@ -1227,7 +1227,7 @@ def set_marker(self, |
| 1227 | 1227 | message_id: str,
|
| 1228 | 1228 | state: str
|
| 1229 | 1229 | ) -> None:
|
| 1230 | - """
|
|
| 1230 | + '''
|
|
| 1231 | 1231 | Update the marker state of the corresponding message
|
| 1232 | 1232 | |
| 1233 | 1233 | :param account_jid: The jid of the account
|
| ... | ... | @@ -1238,7 +1238,7 @@ def set_marker(self, |
| 1238 | 1238 | |
| 1239 | 1239 | :param state: The state, 'received' or 'displayed'
|
| 1240 | 1240 | |
| 1241 | - """
|
|
| 1241 | + '''
|
|
| 1242 | 1242 | if state not in ('received', 'displayed'):
|
| 1243 | 1243 | raise ValueError('Invalid marker state')
|
| 1244 | 1244 | |
| ... | ... | @@ -1260,19 +1260,19 @@ def set_marker(self, |
| 1260 | 1260 | |
| 1261 | 1261 | @timeit
|
| 1262 | 1262 | def get_archive_infos(self, jid: str) -> Optional[LastArchiveMessageRow]:
|
| 1263 | - """
|
|
| 1263 | + '''
|
|
| 1264 | 1264 | Get the archive infos
|
| 1265 | 1265 | |
| 1266 | 1266 | :param jid: The jid that belongs to the avatar
|
| 1267 | 1267 | |
| 1268 | - """
|
|
| 1268 | + '''
|
|
| 1269 | 1269 | jid_id = self.get_jid_id(jid, type_=JIDConstant.ROOM_TYPE)
|
| 1270 | 1270 | sql = '''SELECT * FROM last_archive_message WHERE jid_id = ?'''
|
| 1271 | 1271 | return self._con.execute(sql, (jid_id,)).fetchone()
|
| 1272 | 1272 | |
| 1273 | 1273 | @timeit
|
| 1274 | 1274 | def set_archive_infos(self, jid: str, **kwargs: Any) -> None:
|
| 1275 | - """
|
|
| 1275 | + '''
|
|
| 1276 | 1276 | Set archive infos
|
| 1277 | 1277 | |
| 1278 | 1278 | :param jid: The jid that belongs to the avatar
|
| ... | ... | @@ -1288,7 +1288,7 @@ def set_archive_infos(self, jid: str, **kwargs: Any) -> None: |
| 1288 | 1288 | :param sync_threshold: The max days that we request from a
|
| 1289 | 1289 | MUC archive
|
| 1290 | 1290 | |
| 1291 | - """
|
|
| 1291 | + '''
|
|
| 1292 | 1292 | jid_id = self.get_jid_id(jid)
|
| 1293 | 1293 | exists = self.get_archive_infos(jid)
|
| 1294 | 1294 | if not exists:
|
| ... | ... | @@ -1316,12 +1316,12 @@ def set_archive_infos(self, jid: str, **kwargs: Any) -> None: |
| 1316 | 1316 | |
| 1317 | 1317 | @timeit
|
| 1318 | 1318 | def reset_archive_infos(self, jid: str) -> None:
|
| 1319 | - """
|
|
| 1319 | + '''
|
|
| 1320 | 1320 | Set archive infos
|
| 1321 | 1321 | |
| 1322 | 1322 | :param jid: The jid of the archive
|
| 1323 | 1323 | |
| 1324 | - """
|
|
| 1324 | + '''
|
|
| 1325 | 1325 | jid_id = self.get_jid_id(jid)
|
| 1326 | 1326 | sql = '''UPDATE last_archive_message
|
| 1327 | 1327 | SET last_mam_id = NULL, oldest_mam_timestamp = NULL,
|
| ... | ... | @@ -1366,10 +1366,10 @@ def get_messages_for_export(self, |
| 1366 | 1366 | yield result
|
| 1367 | 1367 | |
| 1368 | 1368 | def remove_history(self, account: str, jid: JID) -> None:
|
| 1369 | - """
|
|
| 1369 | + '''
|
|
| 1370 | 1370 | Remove history for a specific chat.
|
| 1371 | 1371 | If it's a group chat, remove last MAM ID as well.
|
| 1372 | - """
|
|
| 1372 | + '''
|
|
| 1373 | 1373 | account_id = self.get_account_id(account)
|
| 1374 | 1374 | try:
|
| 1375 | 1375 | jid_id = self.get_jid_id(jid)
|
| ... | ... | @@ -1383,9 +1383,9 @@ def remove_history(self, account: str, jid: JID) -> None: |
| 1383 | 1383 | log.info('Removed history for: %s', jid)
|
| 1384 | 1384 | |
| 1385 | 1385 | def remove_all_history(self) -> None:
|
| 1386 | - """
|
|
| 1386 | + '''
|
|
| 1387 | 1387 | Remove all messages for all accounts
|
| 1388 | - """
|
|
| 1388 | + '''
|
|
| 1389 | 1389 | statements = [
|
| 1390 | 1390 | 'DELETE FROM logs',
|
| 1391 | 1391 | 'DELETE FROM jids',
|
| ... | ... | @@ -1395,9 +1395,9 @@ def remove_all_history(self) -> None: |
| 1395 | 1395 | log.info('Removed all chat history')
|
| 1396 | 1396 | |
| 1397 | 1397 | def cleanup_chat_history(self) -> None:
|
| 1398 | - """
|
|
| 1398 | + '''
|
|
| 1399 | 1399 | Remove messages from account where messages are older than max_age
|
| 1400 | - """
|
|
| 1400 | + '''
|
|
| 1401 | 1401 | for account in app.settings.get_accounts():
|
| 1402 | 1402 | max_age = app.settings.get_account_setting(
|
| 1403 | 1403 | account, 'chat_history_max_age')
|
| ... | ... | @@ -43,7 +43,7 @@ |
| 43 | 43 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
| 44 | 44 | # POSSIBILITY OF SUCH DAMAGE.
|
| 45 | 45 | |
| 46 | -"""
|
|
| 46 | +'''
|
|
| 47 | 47 | Provides IPython console widget
|
| 48 | 48 | |
| 49 | 49 | @author: Eitan Isaacson
|
| ... | ... | @@ -54,7 +54,7 @@ |
| 54 | 54 | All rights reserved. This program and the accompanying materials are made
|
| 55 | 55 | available under the terms of the BSD which accompanies this distribution, and
|
| 56 | 56 | is available at U{http://www.opensource.org/licenses/bsd-license.php}
|
| 57 | -"""
|
|
| 57 | +'''
|
|
| 58 | 58 | |
| 59 | 59 | import re
|
| 60 | 60 | import sys
|
| ... | ... | @@ -87,7 +87,7 @@ def write_output_prompt(self): |
| 87 | 87 | |
| 88 | 88 | |
| 89 | 89 | class IterableIPShell:
|
| 90 | - """
|
|
| 90 | + '''
|
|
| 91 | 91 | Create an IPython instance. Does not start a blocking event loop,
|
| 92 | 92 | instead allow single iterations. This allows embedding in GTK
|
| 93 | 93 | without blockage
|
| ... | ... | @@ -102,10 +102,10 @@ class IterableIPShell: |
| 102 | 102 | @type history_level: integer
|
| 103 | 103 | @ivar complete_sep: Separation delimiters for completion function.
|
| 104 | 104 | @type complete_sep: _sre.SRE_Pattern
|
| 105 | - """
|
|
| 105 | + '''
|
|
| 106 | 106 | def __init__(self, argv=None, user_ns=None, user_global_ns=None, cin=None,
|
| 107 | 107 | cout=None, cerr=None, input_func=None):
|
| 108 | - """
|
|
| 108 | + '''
|
|
| 109 | 109 | @param argv: Command line options for IPython
|
| 110 | 110 | @type argv: list
|
| 111 | 111 | @param user_ns: User namespace.
|
| ... | ... | @@ -120,7 +120,7 @@ def __init__(self, argv=None, user_ns=None, user_global_ns=None, cin=None, |
| 120 | 120 | @type cerr: IO stream
|
| 121 | 121 | @param input_func: Replacement for builtin raw_input()
|
| 122 | 122 | @type input_func: function
|
| 123 | - """
|
|
| 123 | + '''
|
|
| 124 | 124 | if argv is None:
|
| 125 | 125 | argv = []
|
| 126 | 126 | |
| ... | ... | @@ -138,7 +138,7 @@ def __init__(self, argv=None, user_ns=None, user_global_ns=None, cin=None, |
| 138 | 138 | from traitlets.config.loader import Config
|
| 139 | 139 | |
| 140 | 140 | cfg = Config()
|
| 141 | - cfg.InteractiveShell.colors = "Linux"
|
|
| 141 | + cfg.InteractiveShell.colors = 'Linux'
|
|
| 142 | 142 | |
| 143 | 143 | # InteractiveShell's __init__ gets a reference of stdout and stderr
|
| 144 | 144 | # so we save the standard here to revert it after init
|
| ... | ... | @@ -178,9 +178,9 @@ def __update_namespace(self): |
| 178 | 178 | self.IP.user_ns.update({k: v})
|
| 179 | 179 | |
| 180 | 180 | def execute(self):
|
| 181 | - """
|
|
| 181 | + '''
|
|
| 182 | 182 | Execute the current line provided by the shell object
|
| 183 | - """
|
|
| 183 | + '''
|
|
| 184 | 184 | self.history_level = 0
|
| 185 | 185 | orig_stdout = sys.stdout
|
| 186 | 186 | sys.stdout = IPython.utils.io.stdout
|
| ... | ... | @@ -237,37 +237,37 @@ def generatePrompt(self, is_continuation): |
| 237 | 237 | |
| 238 | 238 | '''
|
| 239 | 239 | # TODO: Update to IPython 5.x and later
|
| 240 | - prompt = "In [%d]: " % self.IP.execution_count
|
|
| 240 | + prompt = 'In [%d]: ' % self.IP.execution_count
|
|
| 241 | 241 | |
| 242 | 242 | return prompt
|
| 243 | 243 | |
| 244 | 244 | def historyBack(self):
|
| 245 | - """
|
|
| 245 | + '''
|
|
| 246 | 246 | Provide one history command back
|
| 247 | 247 | |
| 248 | 248 | @return: The command string.
|
| 249 | 249 | @rtype: string
|
| 250 | - """
|
|
| 250 | + '''
|
|
| 251 | 251 | self.history_level -= 1
|
| 252 | 252 | return self._getHistory()
|
| 253 | 253 | |
| 254 | 254 | def historyForward(self):
|
| 255 | - """
|
|
| 255 | + '''
|
|
| 256 | 256 | Provide one history command forward
|
| 257 | 257 | |
| 258 | 258 | @return: The command string.
|
| 259 | 259 | @rtype: string
|
| 260 | - """
|
|
| 260 | + '''
|
|
| 261 | 261 | self.history_level += 1
|
| 262 | 262 | return self._getHistory()
|
| 263 | 263 | |
| 264 | 264 | def _getHistory(self):
|
| 265 | - """
|
|
| 265 | + '''
|
|
| 266 | 266 | Get the command string of the current history level
|
| 267 | 267 | |
| 268 | 268 | @return: Historic command string.
|
| 269 | 269 | @rtype: string
|
| 270 | - """
|
|
| 270 | + '''
|
|
| 271 | 271 | try:
|
| 272 | 272 | rv = self.IP.user_ns['In'][self.history_level].strip('\n')
|
| 273 | 273 | except IndexError:
|
| ... | ... | @@ -276,16 +276,16 @@ def _getHistory(self): |
| 276 | 276 | return rv
|
| 277 | 277 | |
| 278 | 278 | def updateNamespace(self, ns_dict):
|
| 279 | - """
|
|
| 279 | + '''
|
|
| 280 | 280 | Add the current dictionary to the shell namespace
|
| 281 | 281 | |
| 282 | 282 | @param ns_dict: A dictionary of symbol-values.
|
| 283 | 283 | @type ns_dict: dictionary
|
| 284 | - """
|
|
| 284 | + '''
|
|
| 285 | 285 | self.IP.user_ns.update(ns_dict)
|
| 286 | 286 | |
| 287 | 287 | def complete(self, line):
|
| 288 | - """
|
|
| 288 | + '''
|
|
| 289 | 289 | Returns an auto completed line and/or possibilities for completion
|
| 290 | 290 | |
| 291 | 291 | @param line: Given line so far.
|
| ... | ... | @@ -294,7 +294,7 @@ def complete(self, line): |
| 294 | 294 | @return: Line completed as for as possible,
|
| 295 | 295 | and possible further completions.
|
| 296 | 296 | @rtype: tuple
|
| 297 | - """
|
|
| 297 | + '''
|
|
| 298 | 298 | split_line = self.complete_sep.split(line)
|
| 299 | 299 | if split_line[-1]:
|
| 300 | 300 | possibilities = self.IP.complete(split_line[-1])
|
| ... | ... | @@ -331,7 +331,7 @@ def _commonPrefix(str1, str2): |
| 331 | 331 | |
| 332 | 332 | |
| 333 | 333 | class ConsoleView(Gtk.TextView):
|
| 334 | - """
|
|
| 334 | + '''
|
|
| 335 | 335 | Specialized text view for console-like workflow
|
| 336 | 336 | |
| 337 | 337 | @cvar ANSI_COLORS: Mapping of terminal colors to X11 names.
|
| ... | ... | @@ -345,7 +345,7 @@ class ConsoleView(Gtk.TextView): |
| 345 | 345 | @type mark: Gtk.TextMark
|
| 346 | 346 | @ivar line_start: Start of command line mark.
|
| 347 | 347 | @type line_start: Gtk.TextMark
|
| 348 | - """
|
|
| 348 | + '''
|
|
| 349 | 349 | |
| 350 | 350 | ANSI_COLORS = {'0;30': 'Black', '0;31': 'Red',
|
| 351 | 351 | '0;32': 'Green', '0;33': 'Brown',
|
| ... | ... | @@ -357,9 +357,9 @@ class ConsoleView(Gtk.TextView): |
| 357 | 357 | '1;36': 'LightCyan', '1;37': 'White'}
|
| 358 | 358 | |
| 359 | 359 | def __init__(self):
|
| 360 | - """
|
|
| 360 | + '''
|
|
| 361 | 361 | Initialize console view
|
| 362 | - """
|
|
| 362 | + '''
|
|
| 363 | 363 | GObject.GObject.__init__(self)
|
| 364 | 364 | self.override_font(Pango.FontDescription('Mono'))
|
| 365 | 365 | self.set_cursor_visible(True)
|
| ... | ... | @@ -396,14 +396,14 @@ def write(self, text, editable=False): |
| 396 | 396 | GLib.idle_add(self._write5, text, editable)
|
| 397 | 397 | |
| 398 | 398 | def _write5(self, text, editable=False):
|
| 399 | - """
|
|
| 399 | + '''
|
|
| 400 | 400 | Write given text to buffer
|
| 401 | 401 | |
| 402 | 402 | @param text: Text to append.
|
| 403 | 403 | @type text: list of (token: string)
|
| 404 | 404 | @param editable: If true, added text is editable.
|
| 405 | 405 | @type editable: boolean
|
| 406 | - """
|
|
| 406 | + '''
|
|
| 407 | 407 | start_mark = self.text_buffer.create_mark(
|
| 408 | 408 | None, self.text_buffer.get_end_iter(), True)
|
| 409 | 409 | |
| ... | ... | @@ -420,14 +420,14 @@ def _write5(self, text, editable=False): |
| 420 | 420 | self.scroll_mark_onscreen(self.mark)
|
| 421 | 421 | |
| 422 | 422 | def _write(self, text, editable=False):
|
| 423 | - """
|
|
| 423 | + '''
|
|
| 424 | 424 | Write given text to buffer
|
| 425 | 425 | |
| 426 | 426 | @param text: Text to append.
|
| 427 | 427 | @type text: string
|
| 428 | 428 | @param editable: If true, added text is editable.
|
| 429 | 429 | @type editable: boolean
|
| 430 | - """
|
|
| 430 | + '''
|
|
| 431 | 431 | if isinstance(text, list):
|
| 432 | 432 | self._write5(text, editable)
|
| 433 | 433 | return
|
| ... | ... | @@ -457,12 +457,12 @@ def showPrompt(self, prompt): |
| 457 | 457 | GLib.idle_add(self._showPrompt, prompt)
|
| 458 | 458 | |
| 459 | 459 | def _showPrompt(self, prompt):
|
| 460 | - """
|
|
| 460 | + '''
|
|
| 461 | 461 | Print prompt at start of line
|
| 462 | 462 | |
| 463 | 463 | @param prompt: Prompt to print.
|
| 464 | 464 | @type prompt: string
|
| 465 | - """
|
|
| 465 | + '''
|
|
| 466 | 466 | self._write(prompt)
|
| 467 | 467 | self.text_buffer.move_mark(self.line_start,
|
| 468 | 468 | self.text_buffer.get_end_iter())
|
| ... | ... | @@ -471,12 +471,12 @@ def changeLine(self, text): |
| 471 | 471 | GLib.idle_add(self._changeLine, text)
|
| 472 | 472 | |
| 473 | 473 | def _changeLine(self, text):
|
| 474 | - """
|
|
| 474 | + '''
|
|
| 475 | 475 | Replace currently entered command line with given text
|
| 476 | 476 | |
| 477 | 477 | @param text: Text to use as replacement.
|
| 478 | 478 | @type text: string
|
| 479 | - """
|
|
| 479 | + '''
|
|
| 480 | 480 | iter_ = self.text_buffer.get_iter_at_mark(self.line_start)
|
| 481 | 481 | iter_.forward_to_line_end()
|
| 482 | 482 | self.text_buffer.delete(
|
| ... | ... | @@ -484,12 +484,12 @@ def _changeLine(self, text): |
| 484 | 484 | self._write(text, True)
|
| 485 | 485 | |
| 486 | 486 | def getCurrentLine(self):
|
| 487 | - """
|
|
| 487 | + '''
|
|
| 488 | 488 | Get text in current command line
|
| 489 | 489 | |
| 490 | 490 | @return: Text of current command line.
|
| 491 | 491 | @rtype: string
|
| 492 | - """
|
|
| 492 | + '''
|
|
| 493 | 493 | rv = self.text_buffer.get_slice(
|
| 494 | 494 | self.text_buffer.get_iter_at_mark(self.line_start),
|
| 495 | 495 | self.text_buffer.get_end_iter(), False)
|
| ... | ... | @@ -499,12 +499,12 @@ def showReturned(self, text): |
| 499 | 499 | GLib.idle_add(self._showReturned, text)
|
| 500 | 500 | |
| 501 | 501 | def _showReturned(self, text):
|
| 502 | - """
|
|
| 502 | + '''
|
|
| 503 | 503 | Show returned text from last command and print new prompt
|
| 504 | 504 | |
| 505 | 505 | @param text: Text to show.
|
| 506 | 506 | @type text: string
|
| 507 | - """
|
|
| 507 | + '''
|
|
| 508 | 508 | iter_ = self.text_buffer.get_iter_at_mark(self.line_start)
|
| 509 | 509 | iter_.forward_to_line_end()
|
| 510 | 510 | self.text_buffer.apply_tag_by_name(
|
| ... | ... | @@ -524,7 +524,7 @@ def _showReturned(self, text): |
| 524 | 524 | self.text_buffer.insert_at_cursor(indentation)
|
| 525 | 525 | |
| 526 | 526 | def onKeyPress(self, _widget, event):
|
| 527 | - """
|
|
| 527 | + '''
|
|
| 528 | 528 | Key press callback used for correcting behavior for console-like
|
| 529 | 529 | interfaces. For example 'home' should go to prompt, not to beginning of
|
| 530 | 530 | line
|
| ... | ... | @@ -536,7 +536,7 @@ def onKeyPress(self, _widget, event): |
| 536 | 536 | |
| 537 | 537 | @return: Return True if event should not trickle.
|
| 538 | 538 | @rtype: boolean
|
| 539 | - """
|
|
| 539 | + '''
|
|
| 540 | 540 | insert_mark = self.text_buffer.get_insert()
|
| 541 | 541 | insert_iter = self.text_buffer.get_iter_at_mark(insert_mark)
|
| 542 | 542 | selection_mark = self.text_buffer.get_selection_bound()
|
| ... | ... | @@ -570,9 +570,9 @@ def onKeyPress(self, _widget, event): |
| 570 | 570 | return self.onKeyPressExtend(event)
|
| 571 | 571 | |
| 572 | 572 | def onKeyPressExtend(self, event):
|
| 573 | - """
|
|
| 573 | + '''
|
|
| 574 | 574 | For some reason we can't extend onKeyPress directly (bug #500900)
|
| 575 | - """
|
|
| 575 | + '''
|
|
| 576 | 576 | |
| 577 | 577 | |
| 578 | 578 | class IPythonView(ConsoleView, IterableIPShell):
|
| ... | ... | @@ -581,9 +581,9 @@ class IPythonView(ConsoleView, IterableIPShell): |
| 581 | 581 | a GTK IPython console.
|
| 582 | 582 | '''
|
| 583 | 583 | def __init__(self):
|
| 584 | - """
|
|
| 584 | + '''
|
|
| 585 | 585 | Initialize. Redirect I/O to console
|
| 586 | - """
|
|
| 586 | + '''
|
|
| 587 | 587 | ConsoleView.__init__(self)
|
| 588 | 588 | self.cout = StringIO()
|
| 589 | 589 | IterableIPShell.__init__(self, cout=self.cout, cerr=self.cout,
|
| ... | ... | @@ -604,7 +604,7 @@ def prompt_for_code(self): |
| 604 | 604 | return self.raw_input(self)
|
| 605 | 605 | |
| 606 | 606 | def raw_input(self, _prompt=''):
|
| 607 | - """
|
|
| 607 | + '''
|
|
| 608 | 608 | Custom raw_input() replacement. Gets current line from console buffer
|
| 609 | 609 | |
| 610 | 610 | @param prompt: Prompt to print. Here for compatibility as replacement.
|
| ... | ... | @@ -612,14 +612,14 @@ def raw_input(self, _prompt=''): |
| 612 | 612 | |
| 613 | 613 | @return: The current command line text.
|
| 614 | 614 | @rtype: string
|
| 615 | - """
|
|
| 615 | + '''
|
|
| 616 | 616 | if self.interrupt:
|
| 617 | 617 | self.interrupt = False
|
| 618 | 618 | raise KeyboardInterrupt
|
| 619 | 619 | return self.getCurrentLine()
|
| 620 | 620 | |
| 621 | 621 | def onKeyPressExtend(self, event):
|
| 622 | - """
|
|
| 622 | + '''
|
|
| 623 | 623 | Key press callback with plenty of shell goodness, like history,
|
| 624 | 624 | autocompletions, etc
|
| 625 | 625 | |
| ... | ... | @@ -630,7 +630,7 @@ def onKeyPressExtend(self, event): |
| 630 | 630 | |
| 631 | 631 | @return: True if event should not trickle.
|
| 632 | 632 | @rtype: boolean
|
| 633 | - """
|
|
| 633 | + '''
|
|
| 634 | 634 | if (event.get_state() & Gdk.ModifierType.CONTROL_MASK and
|
| 635 | 635 | event.keyval == 99):
|
| 636 | 636 | self.interrupt = True
|
| ... | ... | @@ -659,9 +659,9 @@ def onKeyPressExtend(self, event): |
| 659 | 659 | return True
|
| 660 | 660 | |
| 661 | 661 | def _processLine(self):
|
| 662 | - """
|
|
| 662 | + '''
|
|
| 663 | 663 | Process current command line
|
| 664 | - """
|
|
| 664 | + '''
|
|
| 665 | 665 | self.history_pos = 0
|
| 666 | 666 | self.execute()
|
| 667 | 667 | rv = self.cout.getvalue()
|
| ... | ... | @@ -18,6 +18,10 @@ max-line-length = 80 |
| 18 | 18 | statistics = True
|
| 19 | 19 | count = True
|
| 20 | 20 | |
| 21 | +inline-quotes = single
|
|
| 22 | +multiline-quotes = '''
|
|
| 23 | +docstring-quotes = '''
|
|
| 24 | + |
|
| 21 | 25 | [metadata]
|
| 22 | 26 | name = gajim
|
| 23 | 27 | version = attr: gajim.__version__
|
| ... | ... | @@ -7,10 +7,10 @@ |
| 7 | 7 | # the Free Software Foundation; either version 2 of the License, or
|
| 8 | 8 | # (at your option) any later version.
|
| 9 | 9 | |
| 10 | -"""Creates simple Python .exe launchers for gui and cli apps
|
|
| 10 | +# Creates simple Python .exe launchers for gui and cli apps
|
|
| 11 | +#
|
|
| 12 | +# ./create-launcher.py "1.4.0" <target-dir>
|
|
| 11 | 13 | |
| 12 | -./create-launcher.py "1.4.0" <target-dir>
|
|
| 13 | -"""
|
|
| 14 | 14 | |
| 15 | 15 | import os
|
| 16 | 16 | import sys
|
| ... | ... | @@ -22,26 +22,26 @@ |
| 22 | 22 | |
| 23 | 23 | |
| 24 | 24 | def build_resource(rc_path: str, out_path: str) -> None:
|
| 25 | - """Raises subprocess.CalledProcessError"""
|
|
| 25 | + '''Raises subprocess.CalledProcessError'''
|
|
| 26 | 26 | |
| 27 | 27 | def is_64bit():
|
| 28 | - return struct.calcsize("P") == 8
|
|
| 28 | + return struct.calcsize('P') == 8
|
|
| 29 | 29 | |
| 30 | 30 | subprocess.check_call(
|
| 31 | - ["windres", "-O", "coff", "-F",
|
|
| 32 | - "pe-x86-64" if is_64bit() else "pe-i386", rc_path,
|
|
| 33 | - "-o", out_path])
|
|
| 31 | + ['windres', '-O', 'coff', '-F',
|
|
| 32 | + 'pe-x86-64' if is_64bit() else 'pe-i386', rc_path,
|
|
| 33 | + '-o', out_path])
|
|
| 34 | 34 | |
| 35 | 35 | |
| 36 | 36 | def get_build_args() -> list[str]:
|
| 37 | 37 | python_name = os.path.splitext(os.path.basename(sys.executable))[0]
|
| 38 | 38 | python_config = os.path.join(
|
| 39 | - os.path.dirname(sys.executable), python_name + "-config")
|
|
| 39 | + os.path.dirname(sys.executable), python_name + '-config')
|
|
| 40 | 40 | |
| 41 | 41 | cflags = subprocess.check_output(
|
| 42 | - ["sh", python_config, "--cflags"]).strip()
|
|
| 42 | + ['sh', python_config, '--cflags']).strip()
|
|
| 43 | 43 | libs = subprocess.check_output(
|
| 44 | - ["sh", python_config, "--libs"]).strip()
|
|
| 44 | + ['sh', python_config, '--libs']).strip()
|
|
| 45 | 45 | |
| 46 | 46 | cflags = os.fsdecode(cflags)
|
| 47 | 47 | libs = os.fsdecode(libs)
|
| ... | ... | @@ -53,16 +53,16 @@ def build_exe(source_path: str, |
| 53 | 53 | is_gui: bool,
|
| 54 | 54 | out_path: str) -> None:
|
| 55 | 55 | |
| 56 | - args = ["gcc", "-s"]
|
|
| 56 | + args = ['gcc', '-s']
|
|
| 57 | 57 | if is_gui:
|
| 58 | - args.append("-mwindows")
|
|
| 59 | - args.extend(["-o", out_path, source_path, resource_path])
|
|
| 58 | + args.append('-mwindows')
|
|
| 59 | + args.extend(['-o', out_path, source_path, resource_path])
|
|
| 60 | 60 | args.extend(get_build_args())
|
| 61 | 61 | subprocess.check_call(args)
|
| 62 | 62 | |
| 63 | 63 | |
| 64 | 64 | def get_launcher_code(debug: bool) -> str:
|
| 65 | - template = """\
|
|
| 65 | + template = '''\
|
|
| 66 | 66 | #include "Python.h"
|
| 67 | 67 | #define WIN32_LEAN_AND_MEAN
|
| 68 | 68 | #include <windows.h>
|
| ... | ... | @@ -102,7 +102,7 @@ def get_launcher_code(debug: bool) -> str: |
| 102 | 102 | Py_Finalize();
|
| 103 | 103 | return result;
|
| 104 | 104 | }
|
| 105 | - """ % int(debug)
|
|
| 105 | + ''' % int(debug)
|
|
| 106 | 106 | |
| 107 | 107 | return template
|
| 108 | 108 | |
| ... | ... | @@ -115,7 +115,7 @@ def get_resouce_code(filename: str, |
| 115 | 115 | product_version: str,
|
| 116 | 116 | company_name: str) -> str:
|
| 117 | 117 | |
| 118 | - template = """\
|
|
| 118 | + template = '''\
|
|
| 119 | 119 | 1 ICON "%(icon_path)s"
|
| 120 | 120 | 1 VERSIONINFO
|
| 121 | 121 | FILEVERSION %(file_version_list)s
|
| ... | ... | @@ -141,22 +141,22 @@ def get_resouce_code(filename: str, |
| 141 | 141 | VALUE "Translation", 0x409, 1252
|
| 142 | 142 | END
|
| 143 | 143 | END
|
| 144 | -"""
|
|
| 144 | +'''
|
|
| 145 | 145 | |
| 146 | 146 | def to_ver_list(v: str) -> str:
|
| 147 | - v = v.split("-")[0]
|
|
| 148 | - return ",".join(map(str, (list(map(int, v.split("."))) + [0] * 4)[:4]))
|
|
| 147 | + v = v.split('-')[0]
|
|
| 148 | + return ','.join(map(str, (list(map(int, v.split('.'))) + [0] * 4)[:4]))
|
|
| 149 | 149 | |
| 150 | 150 | file_version_list = to_ver_list(file_version)
|
| 151 | 151 | product_version_list = to_ver_list(product_version)
|
| 152 | 152 | |
| 153 | 153 | return template % {
|
| 154 | - "icon_path": icon_path, "file_version_list": file_version_list,
|
|
| 155 | - "product_version_list": product_version_list,
|
|
| 156 | - "file_version": file_version, "product_version": product_version,
|
|
| 157 | - "company_name": company_name, "filename": filename,
|
|
| 158 | - "internal_name": os.path.splitext(filename)[0],
|
|
| 159 | - "product_name": product_name, "file_desc": file_desc,
|
|
| 154 | + 'icon_path': icon_path, 'file_version_list': file_version_list,
|
|
| 155 | + 'product_version_list': product_version_list,
|
|
| 156 | + 'file_version': file_version, 'product_version': product_version,
|
|
| 157 | + 'company_name': company_name, 'filename': filename,
|
|
| 158 | + 'internal_name': os.path.splitext(filename)[0],
|
|
| 159 | + 'product_name': product_name, 'file_desc': file_desc,
|
|
| 160 | 160 | }
|
| 161 | 161 | |
| 162 | 162 | |
| ... | ... | @@ -178,16 +178,16 @@ def build_launcher(out_path: str, |
| 178 | 178 | temp = tempfile.mkdtemp()
|
| 179 | 179 | try:
|
| 180 | 180 | os.chdir(temp)
|
| 181 | - with open("launcher.c", "w") as h:
|
|
| 181 | + with open('launcher.c', 'w') as h:
|
|
| 182 | 182 | h.write(get_launcher_code(debug))
|
| 183 | - shutil.copyfile(src_ico, "launcher.ico")
|
|
| 184 | - with open("launcher.rc", "w") as h:
|
|
| 183 | + shutil.copyfile(src_ico, 'launcher.ico')
|
|
| 184 | + with open('launcher.rc', 'w') as h:
|
|
| 185 | 185 | h.write(get_resouce_code(
|
| 186 | 186 | os.path.basename(target), file_version, file_desc,
|
| 187 | - "launcher.ico", product_name, product_version, company_name))
|
|
| 187 | + 'launcher.ico', product_name, product_version, company_name))
|
|
| 188 | 188 | |
| 189 | - build_resource("launcher.rc", "launcher.res")
|
|
| 190 | - build_exe("launcher.c", "launcher.res", is_gui, target)
|
|
| 189 | + build_resource('launcher.rc', 'launcher.res')
|
|
| 190 | + build_exe('launcher.c', 'launcher.res', is_gui, target)
|
|
| 191 | 191 | finally:
|
| 192 | 192 | os.chdir(dir_)
|
| 193 | 193 | shutil.rmtree(temp)
|
| ... | ... | @@ -199,17 +199,17 @@ def main() -> None: |
| 199 | 199 | version = argv[1]
|
| 200 | 200 | target = argv[2]
|
| 201 | 201 | |
| 202 | - company_name = "Gajim"
|
|
| 202 | + company_name = 'Gajim'
|
|
| 203 | 203 | misc = os.path.dirname(os.path.realpath(__file__))
|
| 204 | 204 | |
| 205 | 205 | build_launcher(
|
| 206 | - os.path.join(target, "Gajim.exe"),
|
|
| 207 | - os.path.join(misc, "gajim.ico"), "Gajim", "Gajim",
|
|
| 206 | + os.path.join(target, 'Gajim.exe'),
|
|
| 207 | + os.path.join(misc, 'gajim.ico'), 'Gajim', 'Gajim',
|
|
| 208 | 208 | version, company_name, True)
|
| 209 | 209 | |
| 210 | 210 | build_launcher(
|
| 211 | - os.path.join(target, "Gajim-Debug.exe"),
|
|
| 212 | - os.path.join(misc, "gajim.ico"), "Gajim", "Gajim",
|
|
| 211 | + os.path.join(target, 'Gajim-Debug.exe'),
|
|
| 212 | + os.path.join(misc, 'gajim.ico'), 'Gajim', 'Gajim',
|
|
| 213 | 213 | version, company_name, False, debug=True)
|
| 214 | 214 | |
| 215 | 215 | # build_launcher(
|
| ... | ... | @@ -218,5 +218,5 @@ def main() -> None: |
| 218 | 218 | # version, company_name, 'history_manager.py', True)
|
| 219 | 219 | |
| 220 | 220 | |
| 221 | -if __name__ == "__main__":
|
|
| 221 | +if __name__ == '__main__':
|
|
| 222 | 222 | main() |