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
cbdcd3c1
Commit
cbdcd3c1
authored
3 years ago
by
williamforbrigd
Browse files
Options
Downloads
Patches
Plain Diff
get all the assignments for folder
parent
2ee52373
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
bbcli/Node.py
+25
-11
25 additions, 11 deletions
bbcli/Node.py
bbcli/__init__.py
+1
-1
1 addition, 1 deletion
bbcli/__init__.py
bbcli/__main__.py
+1
-0
1 addition, 0 deletions
bbcli/__main__.py
bbcli/endpoints.py
+16
-34
16 additions, 34 deletions
bbcli/endpoints.py
with
43 additions
and
46 deletions
bbcli/Node.py
+
25
−
11
View file @
cbdcd3c1
class
Node
(
object
):
class
Node
(
object
):
def
__init__
(
self
,
data
,
children
=
None
):
def
__init__
(
self
,
data
,
children
=
None
):
self
.
data
=
data
self
.
data
=
data
self
.
children
=
[]
self
.
children
=
children
if
children
is
not
None
:
if
children
is
not
None
:
for
child
in
children
:
for
child
in
children
:
self
.
add_child
(
child
)
self
.
add_child
(
child
)
def
__repr__
(
self
):
return
self
.
name
def
add_child
(
self
,
node
):
def
add_child
(
self
,
node
):
assert
isinstance
(
node
,
Node
)
assert
isinstance
(
node
,
Node
)
self
.
chilren
.
append
(
node
)
self
.
children
.
append
(
node
)
\ No newline at end of file
# class Node(object):
# def __init__(self, data, children=None):
# self.data = data
# self.children = []
# if children is not None:
# for child in children:
# self.add_child(child)
# def __repr__(self):
# return self.name
# def add_child(self, node):
# assert isinstance(node, Node)
# self.children.append(node)
This diff is collapsed.
Click to expand it.
bbcli/__init__.py
+
1
−
1
View file @
cbdcd3c1
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
__app_name__
=
"
bbcli
"
__app_name__
=
"
bbcli
"
__version__
=
"
0.1.0
"
__version__
=
"
0.1.0
"
from
.endpoints
import
*
from
.endpoints
import
*
from
.Node
import
*
from
.Node
import
Node
(
(
SUCCESS
,
SUCCESS
,
...
...
This diff is collapsed.
Click to expand it.
bbcli/__main__.py
+
1
−
0
View file @
cbdcd3c1
"""
RP To-Do entry point script.
"""
"""
RP To-Do entry point script.
"""
# rptodo/__main__.py
# rptodo/__main__.py
from
dotenv
import
load_dotenv
from
bbcli
import
cli
,
__app_name__
from
bbcli
import
cli
,
__app_name__
def
main
():
def
main
():
...
...
This diff is collapsed.
Click to expand it.
bbcli/endpoints.py
+
16
−
34
View file @
cbdcd3c1
...
@@ -7,10 +7,9 @@ import typer
...
@@ -7,10 +7,9 @@ import typer
import
click
import
click
from
typing
import
Optional
from
typing
import
Optional
from
dotenv
import
load_dotenv
from
dotenv
import
load_dotenv
from
bbcli.Node
import
Node
import
os
import
os
from
bbcli
import
Node
app
=
typer
.
Typer
()
app
=
typer
.
Typer
()
...
@@ -91,7 +90,7 @@ def get_course_contents(course_id: str = '_27251_1'):
...
@@ -91,7 +90,7 @@ def get_course_contents(course_id: str = '_27251_1'):
# for d in data:
# for d in data:
# typer.echo(d['title'])
# typer.echo(d['title'])
def
get_children
(
data
,
url
,
acc
,
count
:
int
=
0
,
worklist
=
[]
):
def
get_children
(
worklist
,
url
,
acc
,
count
:
int
=
0
):
count
=
count
+
1
count
=
count
+
1
typer
.
echo
(
f
'
kommer hit:
{
count
}
'
)
typer
.
echo
(
f
'
kommer hit:
{
count
}
'
)
# print("The acc is: ", acc)
# print("The acc is: ", acc)
...
@@ -99,9 +98,10 @@ def get_children(data, url, acc, count: int = 0, worklist=[]):
...
@@ -99,9 +98,10 @@ def get_children(data, url, acc, count: int = 0, worklist=[]):
if
len
(
worklist
)
==
0
:
if
len
(
worklist
)
==
0
:
return
acc
return
acc
else
:
else
:
data
=
worklist
.
pop
()
id
=
data
[
'
id
'
]
id
=
data
[
'
id
'
]
old
=
f
'
{
url
}
/
{
id
}
/children
'
old
=
f
'
{
url
}
/
{
id
}
/children
'
typer
.
echo
(
url
)
#
typer.echo(url)
response
=
requests
.
get
(
old
,
cookies
=
cookies
)
response
=
requests
.
get
(
old
,
cookies
=
cookies
)
if
response
.
status_code
==
403
or
response
.
status_code
==
404
:
if
response
.
status_code
==
403
or
response
.
status_code
==
404
:
typer
.
echo
(
response
.
json
()[
'
status
'
])
typer
.
echo
(
response
.
json
()[
'
status
'
])
...
@@ -109,22 +109,13 @@ def get_children(data, url, acc, count: int = 0, worklist=[]):
...
@@ -109,22 +109,13 @@ def get_children(data, url, acc, count: int = 0, worklist=[]):
return
acc
return
acc
else
:
else
:
child
=
response
.
json
()[
'
results
'
]
child
=
response
.
json
()[
'
results
'
]
worklist
.
append
(
child
)
for
i
in
range
(
len
(
child
)):
acc
=
acc
+
child
if
key
in
child
[
i
]
and
child
[
i
][
key
]
==
True
:
parent
=
worklist
.
pop
()
worklist
.
append
(
child
[
i
])
return
get_children
(
parent
,
url
,
acc
,
count
,
worklist
)
else
:
acc
.
append
(
child
[
i
])
def
get_children2
(
d
,
url
):
# parent = worklist.pop()
key
=
'
hasChildren
'
return
get_children
(
worklist
,
url
,
acc
,
count
)
while
key
in
d
and
d
[
key
]
==
True
:
id
=
d
[
'
id
'
]
url
=
f
'
{
url
}{
id
}
/children
'
typer
.
echo
()
typer
.
echo
(
url
)
typer
.
echo
()
response
=
requests
.
get
(
url
,
cookies
=
cookies
)
child
=
response
.
json
()[
'
results
'
]
return
child
...
@@ -136,23 +127,14 @@ def get_assignments(course_id: str = typer.Argument('_27251_1', help='The course
...
@@ -136,23 +127,14 @@ def get_assignments(course_id: str = typer.Argument('_27251_1', help='The course
url
=
f
'
{
base_url
}
courses/
{
course_id
}
/contents
'
url
=
f
'
{
base_url
}
courses/
{
course_id
}
/contents
'
x
=
requests
.
get
(
url
,
cookies
=
cookies
)
x
=
requests
.
get
(
url
,
cookies
=
cookies
)
data
=
x
.
json
()[
'
results
'
]
data
=
x
.
json
()[
'
results
'
]
# parent_id = data[8]['id']
root
=
data
[
8
]
# name = data[8]['title']
# root = Node(data[8])
# parent = Node(parent_id+name)
worklist
=
[
root
]
# print(parent['id'])
res
=
get_children
(
worklist
,
url
,
[])
root
=
Node
(
data
[
8
])
res
=
get_children
(
root
,
url
,
[])
# res = get_children2(data[2], url)
for
i
in
res
:
for
i
in
res
:
print
(
i
[
'
title
'
])
print
(
i
[
'
title
'
])
#typer.echo(ptyper.echo.ptyper.echo(res))
# for data in res:
# typer.echo(d['title'])
#typer.echo(ptyper.echo.ptyper.echo(data))
#for d in data:
#typer.echo()
#typer.echo(get_children(d, url))
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