formatting

This commit is contained in:
Istvan Ruzman
2020-08-07 16:39:49 +02:00
parent dc2a24402b
commit e8dce3e2cf
2 changed files with 26 additions and 11 deletions

View File

@@ -9,7 +9,17 @@ Classes and Types to parse and represent a RADIUS dictionary.
from enum import IntEnum, Enum, auto
from dataclasses import dataclass
from os.path import dirname, isabs, join, normpath
from typing import cast, Dict, Generator, IO, List, Optional, Sequence, Tuple, Union
from typing import (
cast,
Dict,
Generator,
IO,
List,
Optional,
Sequence,
Tuple,
Union,
)
import logging
@@ -389,7 +399,10 @@ class Dictionary:
has_tag, encrypt = self._parse_attribute_flags(tokens, line_num)
name, attr_code, datatype = tokens[1:4]
if datatype in {"concat", "extended", "evs", "long-extended" } and self.cur_vendor != self.rfc_vendor:
if (
datatype in {"concat", "extended", "evs", "long-extended"}
and self.cur_vendor != self.rfc_vendor
):
raise ParseError(
filename,
'vendor attributes are not allowed to have the datatype "concat"',
@@ -440,7 +453,9 @@ class Dictionary:
len(codes) > 1,
)
attrcode: Union[int, Tuple[int, ...]] = codes[0] if len(codes) == 1 else tuple(codes)
attrcode: Union[int, Tuple[int, ...]] = codes[0] if len(
codes
) == 1 else tuple(codes)
self.cur_vendor.attrs[attrcode] = attribute
if self.cur_vendor != self.rfc_vendor:
@@ -461,14 +476,14 @@ class Dictionary:
(attr_name, key, vvalue) = tokens[1:]
try:
if '.' in vvalue:
if "." in vvalue:
# quick and dirty way to make floats values an error
raise ValueError
value = _parse_number(vvalue)
except ValueError:
raise ParseError(filename,
f"Invalid number {vvalue} for VALUE {key}",
line_num)
raise ParseError(
filename, f"Invalid number {vvalue} for VALUE {key}", line_num
)
attribute = self.attrindex[attr_name]
try: