Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ICS erzeugen
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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Egmont Schreiter
ICS erzeugen
Commits
31b0829c
Commit
31b0829c
authored
2 years ago
by
Egmont Schreiter
Browse files
Options
Downloads
Patches
Plain Diff
Konverter von Aufgaben aus ICS Datei zu Freeplane-Mindmap
parent
134539fd
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
mm2ics.py
+2
-0
2 additions, 0 deletions
mm2ics.py
sort_tree.py
+87
-0
87 additions, 0 deletions
sort_tree.py
test_sort_tree.py
+44
-0
44 additions, 0 deletions
test_sort_tree.py
with
133 additions
and
0 deletions
mm2ics.py
+
2
−
0
View file @
31b0829c
...
...
@@ -2,6 +2,8 @@
# Lizenz: OpenSource, GPLv3
# Inspiriert von https://github.com/shollingsworth/freeplane_tools
# verwendung: python3 mm2ics.py a_cal.ics 'Neue Mindmap.mm'
# Schritt 1: Das Tool soll Aufgaben aus iCal Dateien in eine mm umwandeln
from
icalendar
import
(
Calendar
,
...
...
This diff is collapsed.
Click to expand it.
sort_tree.py
0 → 100644
+
87
−
0
View file @
31b0829c
#!/bin/python3
def
sort_tree
(
tree
):
"""
Funktion sortiert einen Baum, dass zuerst die Wurzel und Zweige immer erst später erscheinen
- ändert die Reihenfolge der Einträge
- Unbekannte parent_ids werden auf None gesetzt
- für Listen im Muster [uid, name, parent_uid]
Usage:
tree = [
[
"
105
"
,
"
zweig
"
,
"
100
"
], # muss später eingefügt werden, parent_uid ist noch nicht bekannt
[
"
100
"
,
"
wurzel 1
"
, None],
[
"
102
"
,
"
wurzel 2
"
, None],
[
"
103
"
,
"
zweig
"
,
"
100
"
],
[
"
104
"
,
"
zweig
"
,
"
101
"
], # parent_uid wird auf None gesetzt, da sie nicht enthalten ist
]
print(sort_tree(tree))
"""
unsorted_tree
=
list
()
ids
=
list
()
# alle IDs zum nachsehen eintragen
ids_without_root
=
list
()
elements_without_root
=
list
()
#print(f"Vorher {len(tree)}, unsorted_tree={len(unsorted_tree)}, elements_without_root={len(elements_without_root)}, Summe={len(unsorted_tree)+len(elements_without_root)}")
for
i
,
element
in
enumerate
(
tree
):
if
element
[
2
]
==
None
:
# kein parent --> kann übernommen werden
unsorted_tree
.
append
(
element
)
ids
.
append
(
element
[
0
])
continue
parent_id
=
element
[
2
]
try
:
ids
.
index
(
parent_id
)
# gefunden?
unsorted_tree
.
append
(
element
)
ids
.
append
(
element
[
0
])
continue
except
:
pass
elements_without_root
.
append
(
element
)
ids_without_root
.
append
(
element
[
0
])
#print(f"Vorher {len(tree)}, unsorted_tree={len(unsorted_tree)}, elements_without_root={len(elements_without_root)}, Summe={len(unsorted_tree)+len(elements_without_root)}")
# in elements_without_root alle parent IDS auf None setzen die gar nicht existieren!
new_elements_without_root
=
list
()
for
element
in
elements_without_root
:
try
:
parent_id
=
element
[
2
]
ids
.
index
(
parent_id
)
# todo entweder sie ist i n ids_without_root ODER ids!!! nicht nur in ids_without_root
new_elements_without_root
.
append
(
element
)
continue
except
:
pass
try
:
parent_id
=
element
[
2
]
ids_without_root
.
index
(
parent_id
)
# todo entweder sie ist i n ids_without_root ODER ids!!! nicht nur in ids_without_root
new_elements_without_root
.
append
(
element
)
continue
except
:
new_elements_without_root
.
append
([
element
[
0
],
element
[
1
],
None
])
#print(f"Vorher {len(tree)}, unsorted_tree={len(unsorted_tree)}, elements_without_root={len(elements_without_root)}, Summe={len(unsorted_tree)+len(elements_without_root)}")
# jetzt gibt es zwei Listen, die eine hat schon alle Elemente in der Reihenfolge, die zweite hat die Elemente die zunächst keinen Vorgänger hatten.
# jetzt hängen wir beide Listen hintereinander
for
element
in
new_elements_without_root
:
unsorted_tree
.
append
(
element
)
#print(f"Vorher {len(tree)}, unsorted_tree={len(unsorted_tree)}, elements_without_root={len(elements_without_root)}, Summe={len(unsorted_tree)+len(elements_without_root)}")
# wenn es noch was zum anhängen gab, noch mal sortieren (rekursiv)
#print(f"Anzahl vom Rest = {len(new_elements_without_root)}")
#print(new_elements_without_root)
if
len
(
new_elements_without_root
)
>
0
:
unsorted_tree
=
sort_tree
(
unsorted_tree
)
else
:
# wenn die letzte Liste leer war,
return
unsorted_tree
# jetzt sortiert
# muss dass im obigen else stehen
return
unsorted_tree
\ No newline at end of file
This diff is collapsed.
Click to expand it.
test_sort_tree.py
0 → 100644
+
44
−
0
View file @
31b0829c
#!/bin/python3
# Idee: eine Liste beschreibt einen Baum mit drei Einträgen:
# - einen Test Namen o.ä.
# - einer eindeutigen als str zu interpretieren
# - einer Parent_ID oder None
# Ziel der Funktion: Sortieren, dass zuerst ein ID erscheint bevor darauf als parent_ID verwiesen wird
from
sort_tree
import
*
tree_io
=
[
[
"
105
"
,
"
zweig
"
,
"
100
"
],
[
"
100
"
,
"
wurzel 1
"
,
None
],
[
"
102
"
,
"
wurzel 2
"
,
None
],
[
"
103
"
,
"
zweig
"
,
"
100
"
],
[
"
104
"
,
"
zweig
"
,
"
101
"
],
]
print
(
"
*** ***
"
)
print
(
tree_io
)
# print(tree_io[1])
print
(
sort_tree
(
tree_io
))
tree_unsortiert
=
[
[
"
102
"
,
"
wurzel 2
"
,
None
],
[
"
103
"
,
"
zweig
"
,
"
100
"
],
[
"
100
"
,
"
wurzel 1
"
,
None
],
]
print
(
"
*** ***
"
)
print
(
tree_unsortiert
)
print
(
sort_tree
(
tree_unsortiert
))
print
(
"
*** ***
"
)
tree
=
[
[
"
105
"
,
"
zweig
"
,
"
100
"
],
# muss später eingefügt werden, parent_uid ist noch nicht bekannt
[
"
100
"
,
"
wurzel 1
"
,
None
],
[
"
102
"
,
"
wurzel 2
"
,
None
],
[
"
103
"
,
"
zweig
"
,
"
100
"
],
[
"
104
"
,
"
zweig
"
,
"
101
"
],
# parent_uid wird auf None gesetzt, da sie nicht enthalten ist
]
print
(
sort_tree
(
tree
))
\ No newline at end of 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