mirror of
https://github.com/django-components/django-components.git
synced 2025-07-14 04:14:58 +00:00
Add backwards compatible getfullargspec and TokenType.
This commit is contained in:
parent
00c27f2b3e
commit
9811a88904
2 changed files with 30 additions and 5 deletions
|
@ -1,14 +1,28 @@
|
|||
from inspect import getfullargspec
|
||||
|
||||
from django.forms.widgets import MediaDefiningClass
|
||||
from django.template import Context
|
||||
from django.template.base import NodeList, TokenType, TextNode
|
||||
from django.template.base import NodeList, TextNode
|
||||
from django.template.loader import get_template
|
||||
from six import with_metaclass
|
||||
|
||||
# Allow "component.AlreadyRegistered" instead of having to import these everywhere
|
||||
from django_components.component_registry import AlreadyRegistered, ComponentRegistry, NotRegistered # NOQA
|
||||
|
||||
# Python 2 compatibility
|
||||
try:
|
||||
from inspect import getfullargspec
|
||||
except ImportError:
|
||||
from inspect import getargspec as getfullargspec
|
||||
|
||||
# Django < 2.1 compatibility
|
||||
try:
|
||||
from django.template.base import TokenType
|
||||
except ImportError:
|
||||
from django.template.base import TOKEN_TEXT, TOKEN_VAR, TOKEN_BLOCK
|
||||
|
||||
class TokenType:
|
||||
TEXT = TOKEN_TEXT
|
||||
VAR = TOKEN_VAR
|
||||
BLOCK = TOKEN_BLOCK
|
||||
|
||||
class Component(with_metaclass(MediaDefiningClass)):
|
||||
def context(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue