- Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathcommand_example.py
29 lines (23 loc) · 976 Bytes
/
command_example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# ----------------
# Command Pattern.
# ----------------
# Encapsulate a request as an object, thereby allowing for the parameterization of clients with different requests,
# and the queuing or logging of requests. It also allows for the support of undoable operations.
classInstaller:
def__init__(self, source, dir):
self.options= []
self.dir=dir
self.source=source
defadd_preferences(self, cmd):
self.options.append(cmd)
definstall(self):
foroptioninself.options:
value= [vfork, vinoption.items()]
if (value[0]):
print("installing files -- ", [kfork, vinoption.items()], self.source, " to ", self.dir)
else:
print('Not installed: ', [kfork, vinoption.items()])
installer=Installer('C++ binaries', 'c:\\c++\\binaries')
installer.add_preferences({'c++':True})
installer.add_preferences({'c#': False})
installer.install()