securisec / chepy

Compare 941d1e5 ... +2 ... 6624605

Showing 1 of 6 files from the diff.

@@ -7,6 +7,7 @@
Loading
7 7
import yaml
8 8
import regex as re
9 9
import hexdump
10 +
from ast import literal_eval
10 11
from typing import Union
11 12
from urllib.parse import quote_plus as _urllib_quote_plus
12 13
from urllib.parse import unquote_plus as _urllib_unquote_plus
@@ -19,6 +20,29 @@
Loading
19 20
    def __init__(self, *data):
20 21
        super().__init__(*data)
21 22
23 +
    @ChepyDecorators.call_stack
24 +
    def eval_state(self):
25 +
        """Eval state as python. 
26 +
        Handy when converting string representation 
27 +
        of objects.
28 +
29 +
        Returns:
30 +
            Chepy: The Chepy object
31 +
        """
32 +
        self.state = literal_eval(self.state)
33 +
        return self
34 +
35 +
    @ChepyDecorators.call_stack
36 +
    def bytes_to_ascii(self):
37 +
        """Convert bytes (array of bytes) to ascii
38 +
39 +
        Returns:
40 +
            Chepy: The Chepy object.
41 +
        """
42 +
        assert isinstance(self.state, list), "Data in state is not a list"
43 +
        self.state = bytearray(self.state).decode()
44 +
        return self
45 +
22 46
    @ChepyDecorators.call_stack
23 47
    def list_to_str(self, join_by: Union[str, bytes]=" "):
24 48
        """Join an array by `join_by`
@@ -116,8 +140,13 @@
Loading
116 140
        Returns:
117 141
            Chepy: The Chepy object.
118 142
        """
143 +
        class ChepyYamlDumper(yaml.Dumper):
144 +
            def increase_indent(self, flow=False, indentless=False):
145 +
                return super(ChepyYamlDumper, self).increase_indent(flow, False)
146 +
119 147
        self.state = yaml.dump(
120 148
            ujson.loads(self.state),
149 +
            Dumper=ChepyYamlDumper,
121 150
            default_flow_style=False,
122 151
            sort_keys=False,
123 152
            allow_unicode=True,

Learn more Showing 15 files with coverage changes found.

Changes in chepy/modules/compression.py
-11
Loading file...
Changes in chepy/modules/hashing.py
-21
Loading file...
Changes in chepy/core.py
-7
Loading file...
Changes in chepy/modules/datetimemodule.py
-1
Loading file...
Changes in chepy/modules/codetidy.py
-8
Loading file...
Changes in chepy/modules/language.py
-69
Loading file...
Changes in chepy/modules/aritmeticlogic.py
-3
Loading file...
Changes in chepy/modules/networking.py
-7
Loading file...
Changes in chepy/modules/search.py
-5
Loading file...
Changes in chepy/modules/links.py
-2
Loading file...
Changes in chepy/modules/publickey.py
-7
Loading file...
Changes in chepy/modules/encryptionencoding.py
-6
Loading file...
Changes in chepy/modules/utils.py
-7
Loading file...
Changes in chepy/modules/dataformat.py
-43
Loading file...
Changes in chepy/modules/extractors.py
-22
Loading file...
Files Coverage
chepy 100.00%
Project Totals (25 files) 100.00%
Loading