Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
configuration
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
configuration
Commits
421da388
Commit
421da388
authored
Aug 04, 2017
by
Shirley He
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
separate permutation generation in diff method
parent
dc8b033d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
11 deletions
+17
-11
util/generate_permutations.py
+17
-11
No files found.
util/generate_permutations.py
View file @
421da388
...
...
@@ -9,11 +9,7 @@ from itertools import product
import
sys
# # def parse_args():
# parser = ArgumentParser(description='Create course permutations')
# parser.add_argument('--fields', action='', nargs=3)
#
def
generate_permutations
():
def
parse_field_arguments
():
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'--fields'
,
nargs
=
3
,
action
=
"append"
,
default
=
None
,
help
=
"Specify which fields to generate permutations on"
)
...
...
@@ -22,6 +18,9 @@ def generate_permutations():
file
=
open
(
args
.
filename
)
permutation_data
=
json
.
load
(
file
)
first_field
=
permutation_data
second_field
=
permutation_data
third_field
=
permutation_data
# if no field arguments are given, just print out default data
if
not
args
.
fields
:
...
...
@@ -29,15 +28,22 @@ def generate_permutations():
print
default_permutation
else
:
for
permutation_choices
in
args
.
fields
:
first_field
=
permutation_data
[
"permutation_data"
][
permutation_choices
[
0
]]
# print first_field
second_field
=
permutation_data
[
"permutation_data"
][
permutation_choices
[
1
]]
permutation_generation
=
[
first_field
,
second_field
]
print
list
(
product
(
*
permutation_generation
))
first_field
=
first_field
[
"permutation_data"
][
permutation_choices
[
0
]]
second_field
=
second_field
[
"permutation_data"
][
permutation_choices
[
1
]]
third_field
=
third_field
[
"permutation_data"
][
permutation_choices
[
2
]]
return
first_field
,
second_field
,
third_field
def
generate_permutations
(
fields
):
#permutation_generation = [first_field, second_field, third_field]
print
list
(
product
(
*
fields
))
# print fields
if
__name__
==
"__main__"
:
generate_permutations
()
parse_field_arguments
()
generate_permutations
(
parse_field_arguments
())
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment