Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions qngng/qngng.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@
import argparse
import json
import operator
import os.path
import random
import sys
import unicodedata
import pkg_resources
from importlib import resources
import qngng
import enum
import re
Expand Down Expand Up @@ -149,14 +148,15 @@ def _create_objs(self, cats):

@staticmethod
def _cat_file_to_objs(cat_filename, create_obj_func):
path = os.path.join('cats', cat_filename) + '.json'
path = pkg_resources.resource_filename(__name__, path)
resource_path = 'cats/' + cat_filename + '.json'

if not os.path.exists(path):
try:
ref = resources.files('qngng').joinpath(resource_path)
content = ref.read_text()
except (FileNotFoundError, TypeError):
return []

with open(path) as f:
entries = json.load(f)
entries = json.loads(content)

objs = []

Expand Down