Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scripts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CSCE 361
scripts
Commits
a118a07c
Commit
a118a07c
authored
Jan 21, 2020
by
Christopher Bohn
Browse files
Options
Downloads
Patches
Plain Diff
Initialization script now writes CSV file
parent
b45c688d
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/composite_user.py
+40
-0
40 additions, 0 deletions
api/composite_user.py
initialize_student_tracking.py
+5
-5
5 additions, 5 deletions
initialize_student_tracking.py
with
45 additions
and
5 deletions
api/composite_user.py
+
40
−
0
View file @
a118a07c
...
...
@@ -22,6 +22,7 @@ class CompositeUser:
graylist
:
Set
[
str
]
blacklist
:
Set
[
str
]
candidate_teammates
:
Set
[
str
]
assignments
:
ClassVar
[
List
[
str
]]
=
[]
instances
:
ClassVar
[
Dict
[
str
,
"
CompositeUser
"
]]
=
{}
def
__init__
(
self
,
student_dictionary
:
Dict
[
str
,
str
],
graylist
:
Collection
[
str
],
blacklist
:
Collection
[
str
]):
...
...
@@ -114,6 +115,31 @@ class CompositeUser:
def
get_user
(
cls
,
username_or_email
:
str
)
->
"
CompositeUser
"
:
return
cls
.
instances
[
username_or_email
]
@staticmethod
def
set_to_string
(
the_set
:
Set
[
str
])
->
str
:
the_string
=
''
for
word
in
the_set
:
the_string
+=
'
'
+
word
return
the_string
.
strip
()
@staticmethod
def
string_to_set
(
the_string
:
str
)
->
Set
[
str
]:
return
set
(
the_string
.
split
())
def
to_dict
(
self
)
->
Dict
[
str
,
str
]:
student_dictionary
=
{
'
SortableName
'
:
self
.
sortable_name
.
strip
(),
'
ReadableName
'
:
self
.
readable_name
.
strip
(),
'
NUID
'
:
self
.
NUID
,
'
CanvasUsername
'
:
self
.
canvas_username
,
'
CanvasEmail
'
:
self
.
canvas_email
,
'
GitlabUsername
'
:
self
.
gitlab_username
,
'
GitlabEmail
'
:
self
.
gitlab_email
,
'
Blacklist
'
:
CompositeUser
.
set_to_string
(
self
.
blacklist
)}
# TODO: add assignments
return
student_dictionary
# TODO: add CompositeUser.from_dict(Dict[str, str]) -> CompositeUser
# TODO: Will want to re-visit these based on tracking graylist by project...
@staticmethod
def
read_student_csv
(
filename
:
str
)
->
Set
[
"
CompositeUser
"
]:
...
...
@@ -138,6 +164,7 @@ class CompositeUser:
composite_student
.
canvas_user
=
canvas_student
return
students
"""
@staticmethod
def write_student_csv(students: Set[
"
CompositeUser
"
], filename: str) -> None:
with open(filename, mode=
'
w
'
) as csv_file:
...
...
@@ -173,3 +200,16 @@ class CompositeUser:
# student_dictionary.update({f
'
Blacklist{count}
'
:
''
})
# count += 1
writer.writerow(student_dictionary)
"""
@staticmethod
def
write_student_csv
(
students
:
Set
[
"
CompositeUser
"
],
filename
:
str
)
->
None
:
with
open
(
filename
,
mode
=
'
w
'
)
as
csv_file
:
fieldnames
=
[
'
SortableName
'
,
'
ReadableName
'
,
'
NUID
'
,
'
CanvasUsername
'
,
'
CanvasEmail
'
,
'
GitlabUsername
'
,
'
GitlabEmail
'
,
'
Blacklist
'
]
fieldnames
.
extend
(
CompositeUser
.
assignments
)
writer
=
csv
.
DictWriter
(
csv_file
,
fieldnames
=
fieldnames
)
writer
.
writeheader
()
for
student
in
students
:
writer
.
writerow
(
student
.
to_dict
())
This diff is collapsed.
Click to expand it.
initialize_student_tracking.py
+
5
−
5
View file @
a118a07c
...
...
@@ -109,7 +109,7 @@ def add_gitlab_email(user_repos: Dict[CompositeUser, Optional[GitlabProject]]) -
try
:
commits
:
List
[
GitlabCommit
]
=
project
.
get_commits
()
except
GitlabListError
:
print
(
f
'
*** NOTE *** Could not
retrieve gitlab email for
{
student
.
get_canvas_user
().
get_name
()
}
.
'
print
(
f
'
*** NOTE *** Could not
access commits for
{
project
}
.
'
f
'
This probably indicates Guest permissions.
'
)
commits
=
[]
if
len
(
commits
)
>
0
:
...
...
@@ -119,8 +119,7 @@ def add_gitlab_email(user_repos: Dict[CompositeUser, Optional[GitlabProject]]) -
def
create_cloning_script
(
user_repos
:
Dict
[
CompositeUser
,
Optional
[
GitlabProject
]],
no_username
:
Set
[
CanvasUser
])
->
None
:
filename
=
f
'
{
semester_stamp
()
}
-homework.sh
'
no_username
:
Set
[
CanvasUser
],
filename
:
str
)
->
None
:
file
=
open
(
filename
,
'
x
'
)
file
.
write
(
'
#!/bin/bash
\n\n
'
)
file
.
write
(
'
# Auto-generated clone script.
\n
'
)
...
...
@@ -183,5 +182,6 @@ if __name__ == '__main__':
homework_repos
=
retrieve_homework_repos
(
composite_users
,
choice
)
add_gitlab_email
(
homework_repos
)
print
(
'
\n
Creating cloning script for homework repositories.
'
)
create_cloning_script
(
homework_repos
,
skipped_users
)
# create_csv(homework_repos)
create_cloning_script
(
homework_repos
,
skipped_users
,
f
'
{
semester_stamp
()
}
-homework.sh
'
)
CompositeUser
.
write_student_csv
(
set
(
homework_repos
.
keys
()),
f
'
{
semester_stamp
()
}
-students.csv
'
)
print
(
'
\t
Created student csv file.
'
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment