Skip to content

Commit 9d938d4

Browse files
committed
Add utils
1 parent 3abef1b commit 9d938d4

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

aishell/utils/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .make_executable_command import make_executable_command as make_executable_command
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
def make_executable_command(command: str) -> str:
2+
# starting '\n' or trailing '\n' should be replaced as ''
3+
# starting ' ' or trailing ' ' should be replaced as ''
4+
if command.startswith('\n'):
5+
command = command[1:]
6+
if command.endswith('\n'):
7+
command = command[:-1]
8+
if command.startswith('`'):
9+
command = command[1:]
10+
if command.endswith('`'):
11+
command = command[:-1]
12+
command = command.strip()
13+
command = command.split('User: ')[0]
14+
return command

0 commit comments

Comments
 (0)