Fix Windows compatibility issues and AGE and GPG support
This commit is contained in:
@@ -5,6 +5,7 @@ import functools
|
||||
import io
|
||||
import logging
|
||||
import struct
|
||||
import sys
|
||||
import time
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@@ -258,6 +259,30 @@ def assuan_serialize(data):
|
||||
return data
|
||||
|
||||
|
||||
def escape_cmd_quotes(in_str):
|
||||
"""
|
||||
Escape a string for use as a command line argument inside quotes.
|
||||
|
||||
Does not add quotes. This allows appending multiple strings inside the quotes.
|
||||
"""
|
||||
if sys.platform == 'win32':
|
||||
return in_str.translate(str.maketrans({'%': '%%', '\"': '\"\"'}))
|
||||
else:
|
||||
return in_str.translate(str.maketrans({'\"': '\\\"', '\'': '\\\'', '\\': '\\\\'}))
|
||||
|
||||
|
||||
def escape_cmd_win(in_str):
|
||||
"""Escape a string for Windows batch files in a context where quotes cannot be used."""
|
||||
return in_str.translate(str.maketrans({'\"': '^\"',
|
||||
'%': '%%',
|
||||
'&': '^&',
|
||||
'\'': '^\'',
|
||||
'<': '^<',
|
||||
'>': '^>',
|
||||
'^': '^^',
|
||||
'|': '^|'}))
|
||||
|
||||
|
||||
class ExpiringCache:
|
||||
"""Simple cache with a deadline."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user