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
2ee52373
Commit
2ee52373
authored
3 years ago
by
Mattias Eggen
Browse files
Options
Downloads
Patches
Plain Diff
tmp
parent
36717acb
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
bbcli/Node.py
+12
-5
12 additions, 5 deletions
bbcli/Node.py
bbcli/__init__.py
+1
-0
1 addition, 0 deletions
bbcli/__init__.py
bbcli/endpoints.py
+9
-7
9 additions, 7 deletions
bbcli/endpoints.py
with
22 additions
and
12 deletions
bbcli/Node.py
+
12
−
5
View file @
2ee52373
class
Node
:
def
__init__
(
self
,
data
,
children
=
[]):
self
.
root
=
root
self
.
children
=
children
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
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
bbcli/__init__.py
+
1
−
0
View file @
2ee52373
...
...
@@ -4,6 +4,7 @@
__app_name__
=
"
bbcli
"
__version__
=
"
0.1.0
"
from
.endpoints
import
*
from
.Node
import
*
(
SUCCESS
,
...
...
This diff is collapsed.
Click to expand it.
bbcli/endpoints.py
+
9
−
7
View file @
2ee52373
...
...
@@ -7,9 +7,10 @@ import typer
import
click
from
typing
import
Optional
from
dotenv
import
load_dotenv
from
anytree
import
Node
,
RenderTree
import
os
from
bbcli
import
Node
app
=
typer
.
Typer
()
...
...
@@ -90,16 +91,14 @@ def get_course_contents(course_id: str = '_27251_1'):
# for d in data:
# typer.echo(d['title'])
def
get_children
(
data
,
url
,
acc
,
count
:
int
=
0
):
def
get_children
(
data
,
url
,
acc
,
count
:
int
=
0
,
worklist
=
[]
):
count
=
count
+
1
typer
.
echo
(
f
'
kommer hit:
{
count
}
'
)
# print("The acc is: ", acc)
key
=
'
hasChildren
'
if
key
not
in
data
or
data
[
key
]
==
False
:
typer
.
echo
(
'
nei
'
)
if
len
(
worklist
)
==
0
:
return
acc
else
:
typer
.
echo
(
'
ja
'
)
id
=
data
[
'
id
'
]
old
=
f
'
{
url
}
/
{
id
}
/children
'
typer
.
echo
(
url
)
...
...
@@ -110,8 +109,10 @@ def get_children(data, url, acc, count: int = 0):
return
acc
else
:
child
=
response
.
json
()[
'
results
'
]
worklist
.
append
(
child
)
acc
=
acc
+
child
return
get_children
(
child
,
url
,
acc
,
count
)
parent
=
worklist
.
pop
()
return
get_children
(
parent
,
url
,
acc
,
count
,
worklist
)
def
get_children2
(
d
,
url
):
key
=
'
hasChildren
'
...
...
@@ -139,7 +140,8 @@ def get_assignments(course_id: str = typer.Argument('_27251_1', help='The course
# name = data[8]['title']
# parent = Node(parent_id+name)
# print(parent['id'])
res
=
get_children
(
data
[
8
],
url
,
[])
root
=
Node
(
data
[
8
])
res
=
get_children
(
root
,
url
,
[])
# res = get_children2(data[2], url)
for
i
in
res
:
...
...
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