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
13 changes: 11 additions & 2 deletions universalmutator/mutator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from __future__ import print_function
import re
import pkg_resources
try:
from importlib import resources as importlib_resources
except ImportError:
import importlib_resources
import random
from comby import Comby
import os
Expand All @@ -17,7 +20,13 @@ def parseRules(ruleFiles, comby=False):
rulePath = os.path.join('comby', ruleFile)
else:
rulePath = os.path.join('static', ruleFile)
with pkg_resources.resource_stream('universalmutator', rulePath) as builtInRule:
#with pkg_resources.resource_stream('universalmutator', rulePath) as builtInRule:
#^^ change this line
resource = importlib_resources.files('universalmutator')
for part in rulePath.split(os.sep):
resource = resource.joinpath(part)

with resource.open('rb') as builtInRule:
for line in builtInRule:
line = line.decode()
rulesText.append((line, "builtin:" + ruleFile))
Expand Down