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
dc8b033d
Commit
dc8b033d
authored
Aug 04, 2017
by
Shirley He
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add default data handling
parent
f463ce59
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
8 deletions
+15
-8
util/generate_permutations.py
+15
-8
No files found.
util/generate_permutations.py
View file @
dc8b033d
...
...
@@ -14,22 +14,29 @@ import sys
# parser.add_argument('--fields', action='', nargs=3)
#
def
generate_permutations
():
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'--fields'
,
nargs
=
3
,
action
=
"append"
,
parser
.
add_argument
(
'--fields'
,
nargs
=
3
,
action
=
"append"
,
default
=
None
,
help
=
"Specify which fields to generate permutations on"
)
parser
.
add_argument
(
'filename'
)
args
=
parser
.
parse_args
()
file
=
open
(
args
.
filename
)
permutation_data
=
json
.
load
(
file
)
# if no field arguments are given, just print out default data
if
not
args
.
fields
:
default_permutation
=
permutation_data
[
"default_data"
]
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
))
for
permutation_choices
in
args
.
fields
:
permutation_data
=
json
.
load
(
file
)
first_field
=
permutation_data
[
"permutation_data"
][
permutation_choices
[
0
]]
second_field
=
permutation_data
[
"permutation_data"
][
permutation_choices
[
1
]]
permutation_generation
=
[
first_field
,
second_field
]
print
list
(
product
(
*
permutation_generation
))
if
__name__
==
"__main__"
:
...
...
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