diff --git a/puddlestuff/actiondlg.py b/puddlestuff/actiondlg.py index 7d2147e..5b1f296 100644 --- a/puddlestuff/actiondlg.py +++ b/puddlestuff/actiondlg.py @@ -8,7 +8,7 @@ from PyQt5.QtCore import Qt, pyqtSignal from PyQt5.QtWidgets import QAbstractItemView, QAction, QApplication, QCheckBox, QComboBox, QCompleter, \ QDialog, QFrame, QGridLayout, QInputDialog, QLabel, QLineEdit, QListWidgetItem, QMenu, QMessageBox, \ QScrollArea, QSizePolicy, QSpinBox, QStackedWidget, QToolButton, QVBoxLayout, QWidget -from pyparsing import delimited_list, alphanums, Combine, Word, QuotedString +from pyparsing import delimitedList, alphanums, Combine, Word, QuotedString from . import findfunc, functions from . import functions_dialogs @@ -186,7 +186,7 @@ class FunctionDialog(QWidget): QWidget.__init__(self, parent) identifier = QuotedString('"') | Combine(Word (alphanums + ' !"#$%&\'()*+-./:;<=>?@[\\]^_`{|}~')) - tags = delimited_list(identifier) + tags = delimitedList(identifier) self.func = Function(funcname) docstr = self.func.doc[1:] self.vbox = QVBoxLayout() @@ -236,7 +236,7 @@ class FunctionDialog(QWidget): # Loop that creates all the controls self.controls = [] for argno, line in enumerate(docstr): - args = tags.parse_string(line) + args = tags.parseString(line) label = args[0] ctype = args[1] default = args[2:] diff --git a/puddlestuff/audio_filter.py b/puddlestuff/audio_filter.py index cf3c8c3..cb6cc7f 100644 --- a/puddlestuff/audio_filter.py +++ b/puddlestuff/audio_filter.py @@ -2,8 +2,8 @@ import logging import re -from pyparsing import (CaselessLiteral, Combine, OpAssoc, ParserElement, - ParseException, QuotedString, Word, alphanums, infix_notation) +from pyparsing import (CaselessLiteral, Combine, opAssoc, ParserElement, + QuotedString, Word, alphanums, infixNotation) from . import findfunc, audioinfo @@ -11,7 +11,6 @@ from .puddleobjects import gettaglist from .util import to_string -ParserElement.enable_packrat() def str_cmp(a, b): @@ -168,23 +167,23 @@ class Matches(BoolOperand): bool_exprs = [ - (CaselessLiteral("missing"), 1, OpAssoc.RIGHT, Missing), - (CaselessLiteral("present"), 1, OpAssoc.RIGHT, Present), - (CaselessLiteral("greater"), 2, OpAssoc.LEFT, Greater), - (CaselessLiteral("less"), 2, OpAssoc.LEFT, Less), - (CaselessLiteral("equal"), 2, OpAssoc.LEFT, Equal), - (CaselessLiteral("has"), 2, OpAssoc.LEFT, Has), - (CaselessLiteral("matches"), 2, OpAssoc.LEFT, Matches), - (CaselessLiteral("is"), 2, OpAssoc.LEFT, BoolIs), - (CaselessLiteral("and"), 2, OpAssoc.LEFT, BoolAnd), - (CaselessLiteral("or"), 2, OpAssoc.LEFT, BoolOr), - (CaselessLiteral("not"), 1, OpAssoc.RIGHT, BoolNot), + (CaselessLiteral("missing"), 1, opAssoc.RIGHT, Missing), + (CaselessLiteral("present"), 1, opAssoc.RIGHT, Present), + (CaselessLiteral("greater"), 2, opAssoc.LEFT, Greater), + (CaselessLiteral("less"), 2, opAssoc.LEFT, Less), + (CaselessLiteral("equal"), 2, opAssoc.LEFT, Equal), + (CaselessLiteral("has"), 2, opAssoc.LEFT, Has), + (CaselessLiteral("matches"), 2, opAssoc.LEFT, Matches), + (CaselessLiteral("is"), 2, opAssoc.LEFT, BoolIs), + (CaselessLiteral("and"), 2, opAssoc.LEFT, BoolAnd), + (CaselessLiteral("or"), 2, opAssoc.LEFT, BoolOr), + (CaselessLiteral("not"), 1, opAssoc.RIGHT, BoolNot), ] field_expr = Combine('%' + Word(alphanums + '_') + '%') -tokens = QuotedString('"', unquote_results=False) \ +tokens = QuotedString('"', unquoteResults=False) \ | field_expr | Word(alphanums + '_') -bool_expr = infix_notation(tokens, bool_exprs) +bool_expr = infixNotation(tokens, bool_exprs) def parse(audio, expr): diff --git a/puddlestuff/findfunc.py b/puddlestuff/findfunc.py index 88a68d1..82df9f2 100755 --- a/puddlestuff/findfunc.py +++ b/puddlestuff/findfunc.py @@ -9,8 +9,8 @@ from decimal import Decimal from functools import partial from pyparsing import (CharsNotIn, Combine, Literal, OneOrMore, Optional, ParserElement, - QuotedString, Word, alphanums, alphas, delimited_list, nested_expr, - nums, original_text_for) + QuotedString, Word, alphanums, alphas, delimitedList, nestedExpr, + nums, originalTextFor) from . import audioinfo from .constants import ACTIONDIR, CHECKBOX, SEPARATOR, SPINBOX, SYNTAX_ERROR, SYNTAX_ARG_ERROR @@ -30,7 +30,6 @@ ARGS = 'arguments' KEYWORD_ARGS = set(['tags', 'm_tags', 'r_tags', 'state']) -ParserElement.enable_packrat() class ParseError(Exception): @@ -215,7 +214,7 @@ def func_tokens(dictionary, parse_action): func_name = Word(alphas + '_', alphanums + '_') func_ident = Combine('$' + func_name.copy()('funcname')) - func_tok = func_ident + original_text_for(nested_expr())('args') + func_tok = func_ident + originalTextFor(nestedExpr())('args') func_tok.leave_whitespace() func_tok.set_parse_action(parse_action) @@ -232,9 +231,9 @@ def func_tokens(dictionary, parse_action): quote_tok = QuotedString('"') if dictionary: - arglist = Optional(delimited_list(quote_tok | rx_tok | text_tok)) + arglist = Optional(delimitedList(quote_tok | rx_tok | text_tok)) else: - arglist = Optional(delimited_list(quote_tok | text_tok)) + arglist = Optional(delimitedList(quote_tok | text_tok)) return func_tok, arglist, rx_tok @@ -829,9 +828,9 @@ class Function: self.doc = self.function.__doc__.split("\n") identifier = QuotedString('"') | Combine(Word(alphanums + ' !"#$%&\'()*+-./:;<=>?@[\\]^_`{|}~')) - tags = delimited_list(identifier) + tags = delimitedList(identifier) - self.info = [z for z in tags.parse_string(self.doc[0])] + self.info = [z for z in tags.parseString(self.doc[0])] def setArgs(self, args): self.args = args @@ -895,15 +894,15 @@ class Function: def _getControls(self, index=1): identifier = QuotedString('"') | CharsNotIn(',') - arglist = delimited_list(identifier) + arglist = delimitedList(identifier) docstr = self.doc[1:] if index: - return [(arglist.parse_string(line)[index]).strip() + return [(arglist.parseString(line)[index]).strip() for line in docstr] else: ret = [] for line in docstr: - ret.append([z.strip() for z in arglist.parse_string(line)]) + ret.append([z.strip() for z in arglist.parseString(line)]) return ret def setTag(self, tag): diff --git a/puddlestuff/tagsources/mp3tag/__init__.py b/puddlestuff/tagsources/mp3tag/__init__.py index 5d7c730..4a46dc7 100644 --- a/puddlestuff/tagsources/mp3tag/__init__.py +++ b/puddlestuff/tagsources/mp3tag/__init__.py @@ -35,8 +35,8 @@ def getnum(s, l, t): return int(''.join(t)) -STRING = QuotedString('"', '\\', unquote_results=False).set_parse_action(unquote) -NUMBER = Combine(Optional('-') + Word(nums)).set_parse_action(getnum) +STRING = QuotedString('"', '\\', unquoteResults=False).setParseAction(unquote) +NUMBER = Combine(Optional('-') + Word(nums)).setParseAction(getnum) COVER = '#cover-url' ARGUMENT = STRING | NUMBER