MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / convert_nmap_output_to_encoding

Function convert_nmap_output_to_encoding

pager_lib/nmap/nmap.py:1216–1236  ·  view source on GitHub ↗

Change encoding for scan_result object from unicode to whatever :param value: scan_result as dictionnary :param code: default = "ascii", encoding destination :returns: scan_result as dictionnary with new encoding

(value, code="ascii")

Source from the content-addressed store, hash-verified

1214
1215
1216def convert_nmap_output_to_encoding(value, code="ascii"):
1217 """
1218 Change encoding for scan_result object from unicode to whatever
1219
1220 :param value: scan_result as dictionnary
1221 :param code: default = "ascii", encoding destination
1222
1223 :returns: scan_result as dictionnary with new encoding
1224 """
1225 new_value = {}
1226 for k in value:
1227 if type(value[k]) in [dict, PortScannerHostDict]:
1228 new_value[k] = convert_nmap_output_to_encoding(value[k], code)
1229 else:
1230 if type(value[k]) is list:
1231 new_value[k] = [
1232 convert_nmap_output_to_encoding(x, code) for x in value[k]
1233 ]
1234 else:
1235 new_value[k] = value[k].encode(code)
1236 return new_value
1237
1238
1239# <EOF>######################################################################

Callers

nothing calls this directly

Calls 1

encodeMethod · 0.45

Tested by

no test coverage detected