This commit is contained in:
2024-11-29 18:15:30 +00:00
parent 40aade2d8e
commit bc9415586e
5298 changed files with 1938676 additions and 80 deletions

View File

@ -0,0 +1,36 @@
import logging
import shlex
from typing import List
log = logging.getLogger(__name__)
class EasyProcessUnicodeError(Exception):
pass
def split_command(cmd, posix=None) -> List[str]:
"""
- cmd is string list -> nothing to do
- cmd is string -> split it using shlex
:param cmd: string ('ls -l') or list of strings (['ls','-l'])
:rtype: string list
"""
if not isinstance(cmd, str):
# cmd is string list
pass
else:
if posix is None:
posix = True
cmd = shlex.split(cmd, posix=posix)
return cmd
# def uniencode(s):
# return s
def unidecode(s):
s = s.decode("utf-8", "ignore")
return s