Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added the ability to write the json file

  • Loading branch information...
commit 08b5393cae14a2926ca907b10166fc99dd7d2183 1 parent 73ef7fc
@craigmaloney authored
Showing with 15 additions and 5 deletions.
  1. +11 −1 command_moment.py → command_list.py
  2. +4 −4 commands.json
View
12 command_moment.py → command_list.py
@@ -4,10 +4,12 @@
class CommandList:
def __init__(self):
self.commands = {}
+ self.filename = './commands.json'
def load_commands(self):
- file = open('./commands.json', 'r')
+ file = open(self.filename, 'rt')
self.commands = json.load(file)
+ file.close()
def active_commands(self):
all_true = [key for key, val in self.commands.iteritems() if val]
@@ -17,3 +19,11 @@ def pick_command(self):
active = self.active_commands()
random.shuffle(active)
return active.pop()
+
+ def mark_inactive(self, command):
+ self.commands[command] = False
+
+ def write_commands(self):
+ file = open(self.filename, 'wt')
+ json.dump(self.commands, file, indent=True)
+ file.close()
View
8 commands.json
@@ -1,5 +1,5 @@
{
- "ls":true,
- "mv":true,
- "cp":false
-}
+ "mv": true,
+ "cp": true,
+ "ls": true
+}
Please sign in to comment.
Something went wrong with that request. Please try again.