Creating sparse files for loopback images can be done with the dd command. The ascii_only strips all non-ascii characters out of a string.master
@@ -0,0 +1,3 @@ | |||
# Create sparse.img with 100G (1K * 104857600) and | |||
# actually transfer 0 K into it (count). | |||
dd of=sparse.img bs=1k seek=104857600 count=0 |
@@ -0,0 +1,13 @@ | |||
#!/usr/bin/env python | |||
# -*- coding: utf-8 -*- | |||
import re | |||
logger = logging.getLogger(__name__) | |||
ascii_characters = [chr(i) for i in range(32,127)] | |||
ascii_char_rgx = re.compile("{}".format(re.escape(ascii_characters))) | |||
def ascii_only(incoming_string): | |||
return control_char_rgx.sub("", incoming_string) |