Mercurial > libervia-backend
comparison sat_frontends/jp/cmd_blocking.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 | 12317ba98d99 |
children | 4b842c1fb686 |
comparison
equal
deleted
inserted
replaced
4036:c4464d7ae97b | 4037:524856bd7b19 |
---|---|
41 def add_parser_options(self): | 41 def add_parser_options(self): |
42 pass | 42 pass |
43 | 43 |
44 async def start(self): | 44 async def start(self): |
45 try: | 45 try: |
46 blocked_jids = await self.host.bridge.blockingList( | 46 blocked_jids = await self.host.bridge.blocking_list( |
47 self.profile, | 47 self.profile, |
48 ) | 48 ) |
49 except Exception as e: | 49 except Exception as e: |
50 self.disp(f"can't get blocked entities: {e}", error=True) | 50 self.disp(f"can't get blocked entities: {e}", error=True) |
51 self.host.quit(C.EXIT_BRIDGE_ERRBACK) | 51 self.host.quit(C.EXIT_BRIDGE_ERRBACK) |
70 help=_("JIDs of entities to block"), | 70 help=_("JIDs of entities to block"), |
71 ) | 71 ) |
72 | 72 |
73 async def start(self): | 73 async def start(self): |
74 try: | 74 try: |
75 await self.host.bridge.blockingBlock( | 75 await self.host.bridge.blocking_block( |
76 self.args.entities, | 76 self.args.entities, |
77 self.profile | 77 self.profile |
78 ) | 78 ) |
79 except Exception as e: | 79 except Exception as e: |
80 self.disp(f"can't block entities: {e}", error=True) | 80 self.disp(f"can't block entities: {e}", error=True) |
106 ) | 106 ) |
107 | 107 |
108 async def start(self): | 108 async def start(self): |
109 if self.args.entities == ["all"]: | 109 if self.args.entities == ["all"]: |
110 if not self.args.force: | 110 if not self.args.force: |
111 await self.host.confirmOrQuit( | 111 await self.host.confirm_or_quit( |
112 _("All entities will be unblocked, are you sure"), | 112 _("All entities will be unblocked, are you sure"), |
113 _("unblock cancelled") | 113 _("unblock cancelled") |
114 ) | 114 ) |
115 self.args.entities.clear() | 115 self.args.entities.clear() |
116 elif self.args.force: | 116 elif self.args.force: |
117 self.parser.error(_('--force is only allowed when "all" is used as target')) | 117 self.parser.error(_('--force is only allowed when "all" is used as target')) |
118 | 118 |
119 try: | 119 try: |
120 await self.host.bridge.blockingUnblock( | 120 await self.host.bridge.blocking_unblock( |
121 self.args.entities, | 121 self.args.entities, |
122 self.profile | 122 self.profile |
123 ) | 123 ) |
124 except Exception as e: | 124 except Exception as e: |
125 self.disp(f"can't unblock entities: {e}", error=True) | 125 self.disp(f"can't unblock entities: {e}", error=True) |