Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit59cb786

Browse files
committed
Simpler format_shortcut.
1 parentafbbdd6 commit59cb786

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

‎lib/matplotlib/backend_tools.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,20 +1026,14 @@ class ToolHelpBase(ToolBase):
10261026
default_keymap=rcParams['keymap.help']
10271027
image='help.png'
10281028

1029-
10301029
@staticmethod
1031-
defformat_shortcut(keysequence):
1030+
defformat_shortcut(key_sequence):
10321031
"""
10331032
Converts a shortcut string from the notation used in rc config to the
10341033
standard notation for displaying shortcuts, e.g. 'ctrl+a' -> 'Ctrl+A'.
10351034
"""
1036-
defrepl(match):
1037-
s=match.group(0)
1038-
return'Shift+'+siflen(
1039-
s)==1ands.isupper()elses.capitalize()
1040-
iflen(keysequence)==1:
1041-
returnkeysequence# do not modify single characters
1042-
returnre.sub(r"\w{2,}|(?<=\+)\w",repl,keysequence)
1035+
return (key_sequenceiflen(key_sequence)==1else
1036+
re.sub(r"\+[A-Z]",r"+Shift\g<0>",key_sequence).title())
10431037

10441038
def_format_tool_keymap(self,name):
10451039
keymaps=self.toolmanager.get_tool_keymap(name)

‎lib/matplotlib/tests/test_backend_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
('cmd+1','Cmd+1'),
1818
])
1919
deftest_format_shortcut(rc_shortcut,expected):
20-
assertToolHelpBase.format_shortcut(rc_shortcut)==expected
20+
assertToolHelpBase.format_shortcut(rc_shortcut)==expected

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp