mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-09 07:09:18 +00:00
linting
This commit is contained in:
@@ -1,19 +1,33 @@
|
||||
"""
|
||||
author: deadc0de6 (https://github.com/deadc0de6)
|
||||
Copyright (c) 2020, deadc0de6
|
||||
|
||||
represents a type of link in dotdrop
|
||||
"""
|
||||
|
||||
# https://github.com/PyCQA/pylint/issues/2062
|
||||
# pylint: disable=E1101
|
||||
|
||||
from enum import IntEnum
|
||||
|
||||
|
||||
class LinkTypes(IntEnum):
|
||||
"""a type of link"""
|
||||
NOLINK = 0
|
||||
LINK = 1
|
||||
LINK_CHILDREN = 2
|
||||
|
||||
@classmethod
|
||||
def get(cls, key, default=None):
|
||||
"""get the linktype"""
|
||||
try:
|
||||
return key if isinstance(key, cls) else cls[key.upper()]
|
||||
except KeyError:
|
||||
except KeyError as exc:
|
||||
if default:
|
||||
return default
|
||||
raise ValueError('bad {} value: "{}"'.format(cls.__name__, key))
|
||||
err = 'bad {} value: "{}"'.format(cls.__name__, key)
|
||||
raise ValueError(err) from exc
|
||||
|
||||
def __str__(self):
|
||||
"""linktype to string"""
|
||||
return self.name.lower()
|
||||
|
||||
Reference in New Issue
Block a user