ossobv / asterisklint

Asterisk PBX configuration syntax checker
GNU General Public License v3.0
61 stars 12 forks source link

Refactor code in ConfigParser.preprocessor() to separate methods #25

Open wdoekes opened 7 years ago

wdoekes commented 7 years ago

These bits can be easily moved to a separate splitting method.

if rest[0] == '"' and rest[-1] == '"':
...

And this can be moved to a rest-extracting method:

        if not rest or ord(rest[0]) > 32:
            E_CONF_BAD_LINE(where, startswith=text[0:16])
            return

        for idx, ch in enumerate(rest):
            if ord(ch) > 32:
                break
        else:
            # Nothing after the #include/#tryinclude/#exec.
            E_CONF_BAD_LINE(where, startswith=text[0:16])
            return

        if (not all(i == ' ' for i in rest[0:idx]) and
                not all(i == '\t' for i in rest[0:idx])):
            W_WSH_CTRL(where)
        rest = rest[idx:]