Sfoglia il codice sorgente

Adding ascii_only and dd sparse file

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
Nate Bohman 6 anni fa
parent
commit
10205bd258
2 ha cambiato i file con 16 aggiunte e 0 eliminazioni
  1. +3
    -0
      dd_create_sparse_file
  2. +13
    -0
      python_utils/ascii_only.py

+ 3
- 0
dd_create_sparse_file Vedi File

@@ -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

+ 13
- 0
python_utils/ascii_only.py Vedi File

@@ -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)

Loading…
Annulla
Salva