Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.11 compatibility #266

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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 FoxDot/lib/GhostCoder/Grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
patternNames = {name: obj for name, obj in vars(Sequences).items() \
if (type(obj) == FunctionType and name.startswith("P"))}

# To ignore
# To ignore
del patternNames['PSq']
del patternNames['PPairs']
del patternNames['PSine']

synthdefNames = [name for name, obj in vars(SynthDefs).items() \
if isinstance(obj, SynthDef.SynthDef)]
if isinstance(obj, SynthDef)]

# Grammar

Expand All @@ -41,13 +41,13 @@ def createPlayer(**kwargs):

player = kwargs['player']
synthdef = kwargs['synthdef']

degree = str(kwargs.get("degree", ""))
methods = kwargs.get("methods", "")
keywords = format_kwargs(kwargs.get("kwargs", ""))

sentence = "{player} >> {synthdef}({degree}" + (", " if (len(degree) > 0 and len(keywords) > 0) else "") + "{keywords}){methods}"

return sentence.format(player=player, synthdef=synthdef, degree=degree, methods=methods, keywords=keywords)

def getArgs(s):
Expand Down Expand Up @@ -117,7 +117,7 @@ def GENERATE_PATTERN(keyword=None):

for i in range(n):

args.append( str(patternInputs[pat.__name__][i](keyword)) )
args.append( str(patternInputs[pat.__name__][i](keyword)) )

return pat.__name__ + "({})".format(", ".join(args))

Expand Down Expand Up @@ -167,7 +167,7 @@ def GEN_CHANGE_VALUE(value, keyword=None):
i = 0
out = []
for num in match:
j = num.start()
j = num.start()
new_num = str(GENERATE_NUMBER(keyword)) if random() > 0.5 else num.group()
out += [value[i:j], new_num]
i = num.end()
Expand Down Expand Up @@ -232,7 +232,7 @@ def WeightedList(weights):
data = []
for item, weight in weights.items():
data += ([item] * weight)
return data
return data

Players = [ "g1", "g2", "g3", "g4", "g5" ]

Expand Down
20 changes: 10 additions & 10 deletions FoxDot/lib/GhostCoder/Writer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import absolute_import
from random import choice
from copy import deepcopy
import Queue
import queue
from . import Grammar

class null:
Expand All @@ -27,15 +27,15 @@ def __init__(self):

self.players = {}
self.index = [0, 0]
self.instructions = Queue.Queue()
self.instructions = queue.Queue()
self.running = True

def defineInstructions(self, original, syntax):

new = Grammar.createPlayer(**syntax)

self.instructions.put((original, new))

return

def write(self):
Expand All @@ -56,9 +56,9 @@ def write(self):
break

else:
raise Queue.Empty()

raise queue.Empty()

# 2. Replace

self.widget.replace(line, old, new)
Expand All @@ -73,20 +73,20 @@ def write(self):

self.widget.root.after(50, self.write)

except Queue.Empty:
except queue.Empty:

if self.running == True:

self.widget.root.after(choice([2000, 3000, 4000, 5000]), self.act)

return


def getPlayer(self):
''' Choose a player from those available '''

# Read the text from the current widget

text = self.widget.read()

# Find all the players
Expand Down
Loading