summaryrefslogtreecommitdiff
path: root/examples/statemachine
diff options
context:
space:
mode:
authorptmcg <ptmcg@austin.rr.com>2019-01-09 17:18:22 -0600
committerptmcg <ptmcg@austin.rr.com>2019-01-09 17:18:22 -0600
commitd626c99b6288afc4708d72f668b45a29d3263d22 (patch)
tree4cbeca134437387022e59b71631246e178393aca /examples/statemachine
parente9ef507bf1fd41d4bd3ffb0c193e5889254ba340 (diff)
downloadpyparsing-git-d626c99b6288afc4708d72f668b45a29d3263d22.tar.gz
Add enumerated place holders for strings that invoke str.format(), for Py2 compatibility
Diffstat (limited to 'examples/statemachine')
-rw-r--r--examples/statemachine/documentSignoffDemo.py2
-rw-r--r--examples/statemachine/libraryBookDemo.py4
-rw-r--r--examples/statemachine/statemachine.py12
-rw-r--r--examples/statemachine/trafficLightDemo.py4
4 files changed, 11 insertions, 11 deletions
diff --git a/examples/statemachine/documentSignoffDemo.py b/examples/statemachine/documentSignoffDemo.py
index 89c6440..58aa208 100644
--- a/examples/statemachine/documentSignoffDemo.py
+++ b/examples/statemachine/documentSignoffDemo.py
@@ -26,7 +26,7 @@ class Document:
return attr
def __str__(self):
- return "{}: {}".format(self.__class__.__name__, self._state)
+ return "{0}: {1}".format(self.__class__.__name__, self._state)
def run_demo():
diff --git a/examples/statemachine/libraryBookDemo.py b/examples/statemachine/libraryBookDemo.py
index 84108e5..2e60eac 100644
--- a/examples/statemachine/libraryBookDemo.py
+++ b/examples/statemachine/libraryBookDemo.py
@@ -19,7 +19,7 @@ class Book:
return attr
def __str__(self):
- return "{}: {}".format(self.__class__.__name__, self._state)
+ return "{0}: {1}".format(self.__class__.__name__, self._state)
class RestrictedBook(Book):
@@ -35,7 +35,7 @@ class RestrictedBook(Book):
if user in self._authorized_users:
self._state = self._state.checkout()
else:
- raise Exception("{} could not check out restricted book".format((user, "anonymous")[user is None]))
+ raise Exception("{0} could not check out restricted book".format((user, "anonymous")[user is None]))
def run_demo():
diff --git a/examples/statemachine/statemachine.py b/examples/statemachine/statemachine.py
index b7b60d2..2e35869 100644
--- a/examples/statemachine/statemachine.py
+++ b/examples/statemachine/statemachine.py
@@ -72,10 +72,10 @@ def expand_state_definition(source, loc, tokens):
])
# define all state classes
- statedef.extend("class {}({}): pass".format(s, baseStateClass) for s in states)
+ statedef.extend("class {0}({1}): pass".format(s, baseStateClass) for s in states)
# define state->state transitions
- statedef.extend("{}._next_state_class = {}".format(s, fromTo[s]) for s in states if s in fromTo)
+ statedef.extend("{0}._next_state_class = {1}".format(s, fromTo[s]) for s in states if s in fromTo)
return indent + ("\n" + indent).join(statedef) + "\n"
@@ -113,9 +113,9 @@ def expand_named_state_definition(source, loc, tokens):
" return self.transitionName",
])
statedef.extend(
- "{} = {}Transition()".format(tn, baseStateClass)
+ "{0} = {1}Transition()".format(tn, baseStateClass)
for tn in transitions)
- statedef.extend("{}.transitionName = '{}'".format(tn, tn)
+ statedef.extend("{0}.transitionName = '{1}'".format(tn, tn)
for tn in transitions)
# define base class for state classes
@@ -199,7 +199,7 @@ class SuffixImporter(object):
# it probably isn't even a filesystem path
finder = sys.path_importer_cache.get(dirpath)
if isinstance(finder, (type(None), importlib.machinery.FileFinder)):
- checkpath = os.path.join(dirpath, '{}.{}'.format(fullname, self.suffix))
+ checkpath = os.path.join(dirpath, '{0}.{1}'.format(fullname, self.suffix))
yield checkpath
def find_module(self, fullname, path=None):
@@ -257,4 +257,4 @@ class PystateImporter(SuffixImporter):
PystateImporter.register()
if DEBUG:
- print("registered {!r} importer".format(PystateImporter.suffix))
+ print("registered {0!r} importer".format(PystateImporter.suffix))
diff --git a/examples/statemachine/trafficLightDemo.py b/examples/statemachine/trafficLightDemo.py
index 4fc737c..4d70541 100644
--- a/examples/statemachine/trafficLightDemo.py
+++ b/examples/statemachine/trafficLightDemo.py
@@ -21,12 +21,12 @@ class TrafficLight:
return getattr(self._state, attrname)
def __str__(self):
- return "{}: {}".format(self.__class__.__name__, self._state)
+ return "{0}: {1}".format(self.__class__.__name__, self._state)
light = TrafficLight()
for i in range(10):
- print("{} {}".format(light, ("STOP", "GO")[light.cars_can_go]))
+ print("{0} {1}".format(light, ("STOP", "GO")[light.cars_can_go]))
light.crossing_signal()
light.delay()
print()