Commit ce2ab9ee by Shirley He

include permutations class

parent 2c02b97f
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
# other comment about how this file works, plus probably an example of implementation # other comment about how this file works, plus probably an example of implementation
import json import json
import argparse
from argparse import ArgumentParser from argparse import ArgumentParser
from pprint import pprint from pprint import pprint
from itertools import product from itertools import product
...@@ -12,19 +13,22 @@ import sys ...@@ -12,19 +13,22 @@ import sys
# parser = ArgumentParser(description='Create course permutations') # parser = ArgumentParser(description='Create course permutations')
# parser.add_argument('--fields', action='', nargs=3) # parser.add_argument('--fields', action='', nargs=3)
# #
# # def generate_course_permutations(): def generate_permutations():
# with open('permutations.json') as permutation_options:
# permutation_data = json.load(permutation_options)
#
# start_dates = permutation_data["permutation_data"]["start"]
# availability = permutation_data["permutation_data"]['availability']
#
# permutation_generation = [start_dates, availability]
#
# print list(product(*permutation_generation))
with open(sys.argv[1], 'r') as permutation_file: class Permutations(argparse.Action):
def __call__(self, parser, args, values, option_string=None):
setattr(args, self.dest, values)
return Permutations
print permutation_file.read()[2]
parser = argparse.ArgumentParser()
parser.add_argument('--fields', action='generate_permutations', nargs=3)
args = parser.parse_args()
parser.register('action', 'generate_permutations', GenerationPermutations)
with open(args.filename) as file:
permutation_data = json.load(file)
start_dates = permutation_data["permutation_data"]["start"]
availability = permutation_data["permutation_data"]['availability']
permutation_generation = [start_dates, availability]
print list(product(*permutation_generation))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment