diff --git a/fbchat/graphql.py b/fbchat/graphql.py index 86e011f..a8e2609 100644 --- a/fbchat/graphql.py +++ b/fbchat/graphql.py @@ -3,7 +3,6 @@ from __future__ import unicode_literals import json import re -import aenum from .models import * from .utils import * @@ -24,14 +23,6 @@ class ConcatJSONDecoder(json.JSONDecoder): return objs # End shameless copy -def enum_extend_if_invalid(enumeration, value): - try: - return enumeration(value) - except ValueError: - log.warning("Failed parsing {}({!r}). Extending enum.".format(enumeration, value)) - aenum.extend_enum(enumeration, "UNKNOWN_{}".format(value).upper(), value) - return enumeration(value) - def graphql_color_to_enum(color): if color is None: return None diff --git a/fbchat/utils.py b/fbchat/utils.py index 92e8a9d..d3008dc 100644 --- a/fbchat/utils.py +++ b/fbchat/utils.py @@ -11,6 +11,7 @@ from os.path import basename import warnings import logging import requests +import aenum from .models import * try: @@ -297,3 +298,12 @@ def get_files_from_paths(filenames): yield files for fn, fp, ft in files: fp.close() + + +def enum_extend_if_invalid(enumeration, value): + try: + return enumeration(value) + except ValueError: + log.warning("Failed parsing {}({!r}). Extending enum.".format(enumeration, value)) + aenum.extend_enum(enumeration, "UNKNOWN_{}".format(value).upper(), value) + return enumeration(value)