Skip to content

Commit b016505

Browse files
fix : Fixed error in helpview
- Fixed error in helpview, encountered while viewing the help section. - other small fixes
1 parent cb9cbde commit b016505

File tree

4 files changed

+22
-34
lines changed

4 files changed

+22
-34
lines changed

tests/config/test_keys.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import pytest
44
from pytest_mock import MockerFixture
55

6-
from zulipterminal.config import keys
6+
from zulipterminal.config import keys
77

88

99
AVAILABLE_COMMANDS = list(keys.key_config.KEY_BINDINGS.keys())
@@ -59,16 +59,12 @@ def test_is_command_key_matching_keys(valid_command: str) -> None:
5959
def test_is_command_key_nonmatching_keys(valid_command: str) -> None:
6060
keys_to_test = USED_KEYS - set(keys.key_config.keys_for_command(valid_command))
6161
for key in keys_to_test:
62-
assert not keys.key_config.is_command_key(
63-
valid_command, key
64-
)
62+
assert not keys.key_config.is_command_key(valid_command, key)
6563

6664

6765
def test_is_command_key_invalid_command(invalid_command: str) -> None:
6866
with pytest.raises(keys.InvalidCommand):
69-
keys.key_config.is_command_key(
70-
invalid_command, "esc"
71-
) # key doesn't matter
67+
keys.key_config.is_command_key(invalid_command, "esc") # key doesn't matter
7268

7369

7470
def test_HELP_is_not_allowed_as_tip() -> None:
@@ -161,18 +157,12 @@ def test_display_key_for_urwid_key(urwid_key: str, display_key: str) -> None:
161157

162158
@pytest.mark.parametrize("command, display_keys", COMMAND_TO_DISPLAY_KEYS)
163159
def test_display_keys_for_command(command: str, display_keys: List[str]) -> None:
164-
assert (
165-
keys.key_config.display_keys_for_command(command)
166-
== display_keys
167-
)
160+
assert keys.key_config.display_keys_for_command(command) == display_keys
168161

169162

170163
@pytest.mark.parametrize("command, display_keys", COMMAND_TO_DISPLAY_KEYS)
171164
def test_primary_display_key_for_command(command: str, display_keys: List[str]) -> None:
172-
assert (
173-
keys.key_config.primary_display_key_for_command(command)
174-
== display_keys[0]
175-
)
165+
assert keys.key_config.primary_display_key_for_command(command) == display_keys[0]
176166

177167

178168
def test_display_keys_for_command_invalid_command(invalid_command: str) -> None:

zulipterminal/config/keys.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def set_terminology(self, terminology: str) -> None:
234234
"TOGGLE_TOPIC": {
235235
"keys": ["t"],
236236
"help_text": f"Toggle topics in a {self.terminology}",
237-
"key_category": f"{self.terminology}_list",
237+
"key_category": "stream_list",
238238
},
239239
"ALL_MESSAGES": {
240240
"keys": ["a", "esc"],
@@ -305,7 +305,7 @@ def set_terminology(self, terminology: str) -> None:
305305
"TOGGLE_MUTE_STREAM": {
306306
"keys": ["m"],
307307
"help_text": f"Mute/unmute {self.terminology}s",
308-
"key_category": f"{self.terminology}_list",
308+
"key_category": "stream_list",
309309
},
310310
"THUMBS_UP": {
311311
"keys": ["+"],
@@ -342,19 +342,19 @@ def set_terminology(self, terminology: str) -> None:
342342
"STREAM_INFO": {
343343
"keys": ["i"],
344344
"help_text": f"Show/hide {self.terminology} information & modify settings",
345-
"key_category": f"{self.terminology}_list",
345+
"key_category": "stream_list",
346346
},
347347
"STREAM_MEMBERS": {
348348
"keys": ["m"],
349349
"help_text": f"Show/hide {self.terminology} members",
350350
"excluded_from_random_tips": True,
351-
"key_category": f"{self.terminology}_info",
351+
"key_category": "stream_info",
352352
},
353353
"COPY_STREAM_EMAIL": {
354354
"keys": ["c"],
355355
"help_text": f"Copy {self.terminology} email to clipboard",
356356
"excluded_from_random_tips": True,
357-
"key_category": f"{self.terminology}_info",
357+
"key_category": "stream_info",
358358
},
359359
"REDRAW": {
360360
"keys": ["ctrl l"],
@@ -495,19 +495,19 @@ def set_terminology(self, terminology: str) -> None:
495495
"narrowing": "Switching Messages View",
496496
"searching": "Searching",
497497
"msg_actions": "Message actions",
498-
f"{self.terminology}_list": f"{self.terminology} list actions",
498+
"stream_list": "stream list actions",
499499
"user_list": "User list actions",
500500
"open_compose": "Begin composing a message",
501501
"compose_box": "Writing a message",
502502
"editor_navigation": "Editor: Navigation",
503503
"editor_text_manipulation": "Editor: Text Manipulation",
504-
f"{self.terminology}_info": (
505-
f"{self.terminology} information (press {self.KEY_BINDINGS['STREAM_INFO']['keys'][0]}"
506-
f" to view info of a {self.terminology})"
504+
"strream_info": (
505+
f"stream information (press {self.KEY_BINDINGS['STREAM_INFO']['keys'][0]}"
506+
" to view info of a stream)"
507507
),
508508
"msg_info": (
509509
f"Message information (press {self.KEY_BINDINGS['MSG_INFO']['keys'][0]}"
510-
f" to view info of a message)"
510+
" to view info of a message)"
511511
),
512512
}
513513

@@ -577,7 +577,8 @@ def commands_for_random_tips(self) -> List[KeyBinding]:
577577
for key_binding in self.KEY_BINDINGS.values()
578578
if not key_binding.get("excluded_from_random_tips", False)
579579
]
580-
def keys_for_command(self,command: str) -> List[str]:
580+
581+
def keys_for_command(self, command: str) -> List[str]:
581582
"""
582583
Returns the actual keys for a given mapped command
583584
"""
@@ -600,5 +601,6 @@ def initialize_command_map(key_config: KeyConfig) -> None:
600601
for key in key_config.keys_for_command(zt_cmd):
601602
command_map[key] = urwid_cmd
602603

604+
603605
# Initialize the command map after the KeyConfig instance is fully initialized
604606
initialize_command_map(key_config)

zulipterminal/core.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def __init__(
104104
self.is_typing_notification_in_progress = False
105105

106106
self.show_loading()
107-
self.feature_level = ""
107+
self.feature_level = None
108108
client_identifier = f"ZulipTerminal/{ZT_VERSION} {platform()}"
109109
config_file = os.path.expanduser(config_file)
110110
if config_file is not None and os.path.exists(config_file):
@@ -113,10 +113,7 @@ def __init__(
113113
config.read_file(f, config_file)
114114
if self.feature_level is None:
115115
self.feature_level = self.get_feature_level(config.get("api", "site"))
116-
if self.feature_level.isdigit():
117-
self.feature_level = int(self.feature_level)
118-
else:
119-
self.feature_level = 0
116+
print(type(self.feature_level))
120117
self.terminology = "channel" if self.feature_level > 254 else "stream"
121118
self.key_config = key_config
122119
self.key_config.set_terminology(

zulipterminal/ui_tools/views.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,7 +1280,7 @@ def __init__(self, controller: Any, title: str) -> None:
12801280
for binding in key_config.KEY_BINDINGS.values()
12811281
if binding["key_category"] == category
12821282
)
1283-
key_config.KEY_BINDINGS = [
1283+
processed_bindings = [
12841284
(
12851285
binding["help_text"],
12861286
", ".join(
@@ -1289,9 +1289,8 @@ def __init__(self, controller: Any, title: str) -> None:
12891289
)
12901290
for binding in keys_in_category
12911291
]
1292-
12931292
help_menu_content.append(
1294-
(key_config.HELP_CATEGORIES[category], key_config.KEY_BINDINGS)
1293+
(key_config.HELP_CATEGORIES[category], processed_bindings)
12951294
)
12961295

12971296
popup_width, column_widths = self.calculate_table_widths(

0 commit comments

Comments
 (0)