Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
IDATT2900-072
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mattias Agentoft Eggen
IDATT2900-072
Commits
edce1be8
Commit
edce1be8
authored
3 years ago
by
williamforbrigd
Browse files
Options
Downloads
Patches
Plain Diff
shamener babajan
parent
79f335c3
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bbcli/endpoints.py
+28
-16
28 additions, 16 deletions
bbcli/endpoints.py
venv/pyvenv.cfg
+2
-2
2 additions, 2 deletions
venv/pyvenv.cfg
with
30 additions
and
18 deletions
bbcli/endpoints.py
+
28
−
16
View file @
edce1be8
import
requests
#from requests.auth import HTTPBasicAuth
import
json
import
pprint
import
pprint
import
typer
#from string_builder import StringBuilder
import
click
...
...
@@ -23,7 +23,7 @@ base_url = 'https://ntnu.blackboard.com/learn/api/public/v1/'
@app.command
(
name
=
'
get-user
'
)
def
get_user
(
user_name
:
str
=
typer
.
Argument
(
''
,
help
=
'
Name of the user
'
))
->
None
:
'''
Get the user
Get the user
Specify the user_name as an option, or else it will use the default user_name
'''
if
user_name
==
''
:
...
...
@@ -89,24 +89,30 @@ def get_course_contents(course_id: str = '_27251_1'):
# for d in data:
# typer.echo(d['title'])
def
get_children
(
d
,
url
,
acc
,
count
:
int
=
0
):
#count = count + 1
#typer.echo(f'kommer hit: {count}')
def
get_children
(
data
,
url
,
acc
,
count
:
int
=
0
):
count
=
count
+
1
typer
.
echo
(
f
'
kommer hit:
{
count
}
'
)
# print("The acc is: ", acc)
key
=
'
hasChildren
'
if
key
not
in
d
or
d
[
key
]
==
False
:
if
key
not
in
d
ata
or
d
ata
[
key
]
==
False
:
typer
.
echo
(
'
nei
'
)
return
acc
else
:
typer
.
echo
(
'
ja
'
)
id
=
d
[
'
id
'
]
id
=
d
ata
[
'
id
'
]
url
=
f
'
{
url
}
/
{
id
}
/children
'
typer
.
echo
(
url
)
response
=
requests
.
get
(
url
,
cookies
=
cookies
)
child
=
response
.
json
()[
'
results
'
]
get_children
(
child
,
url
,
acc
+
child
,
count
)
# return child
def
get_children
(
d
,
url
):
if
response
.
status_code
==
403
or
response
.
status_code
==
404
:
typer
.
echo
(
response
.
json
()[
'
status
'
])
typer
.
echo
(
response
.
json
()[
'
message
'
])
return
acc
else
:
child
=
response
.
json
()[
'
results
'
]
acc
=
acc
+
child
return
get_children
(
child
,
url
,
acc
,
count
)
def
get_children2
(
d
,
url
):
key
=
'
hasChildren
'
while
key
in
d
and
d
[
key
]
==
True
:
id
=
d
[
'
id
'
]
...
...
@@ -128,11 +134,17 @@ def get_assignments(course_id: str = typer.Argument('_27251_1', help='The course
url
=
f
'
{
base_url
}
courses/
{
course_id
}
/contents
'
x
=
requests
.
get
(
url
,
cookies
=
cookies
)
data
=
x
.
json
()[
'
results
'
]
#res = get_children(data[2], url, [])
res
=
get_children
(
data
[
2
],
url
)
res
=
get_children
(
data
[
8
],
url
,
[])
# res = get_children2(data[2], url)
for
i
in
res
:
print
(
i
[
'
title
'
])
#typer.echo(ptyper.echo.ptyper.echo(res))
for
o
in
res
:
typer
.
echo
(
o
[
'
title
'
])
#
for
data
in res:
#
typer.echo(
d
['title'])
#typer.echo(ptyper.echo.ptyper.echo(data))
#for d in data:
#typer.echo()
...
...
This diff is collapsed.
Click to expand it.
venv/pyvenv.cfg
+
2
−
2
View file @
edce1be8
home
=
/
usr
/bin
home
=
/
Library/Frameworks/Python.framework/Versions/3.9
/bin
include-system-site-packages
=
false
version
=
3.
8
.10
version
=
3.
9
.10
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