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
fa2d9587
Commit
fa2d9587
authored
2 years ago
by
Egmont Schreiter
Browse files
Options
Downloads
Patches
Plain Diff
Mindmap einseitig oder zweiseitig
#10
per Option kann Mindmap einseitig oder zweiseitig erstellt werden
parent
7cedb12e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ics2mm.py
+62
-12
62 additions, 12 deletions
ics2mm.py
with
62 additions
and
12 deletions
ics2mm.py
+
62
−
12
View file @
fa2d9587
...
@@ -44,12 +44,29 @@ parser.add_argument(
...
@@ -44,12 +44,29 @@ parser.add_argument(
type
=
str
,
type
=
str
,
)
)
parser
.
add_argument
(
'
-o
'
,
'
--orientation
'
,
choices
=
[
'
l
'
,
'
r
'
],
default
=
None
,
help
=
"""
l - all mindmap nodes on left side,
r - all mindmap nodes on left side
empty = no parameter: first half nodes left, second half right side
"""
,
type
=
str
,
)
parser
.
add_argument
(
'
-v
'
,
'
--verbose
'
,
action
=
'
store_true
'
)
# todo: Ort, Icons, Texte aus MM in ical übersetzen
# todo: Ort, Icons, Texte aus MM in ical übersetzen
# todo: prüfen, ob Icons in Text umgewandelt werden können
# todo: prüfen, ob Icons in Text umgewandelt werden können
cal
=
icalendar
.
Calendar
()
# todo: prüfen ob 'global cal' anders gelöst werden kann
cal
=
icalendar
.
Calendar
()
# todo: prüfen ob 'global cal' anders gelöst werden kann
verbose
=
False
def
get_text
(
node
):
def
get_text
(
node
):
return
node
.
get
(
"
TEXT
"
)
return
node
.
get
(
"
TEXT
"
)
...
@@ -146,14 +163,19 @@ def gehe_durch_ics_tree(tree, parent=None):
...
@@ -146,14 +163,19 @@ def gehe_durch_ics_tree(tree, parent=None):
gehe_durch_mindmap_tree
(
node
,
parent
=
node
)
gehe_durch_mindmap_tree
(
node
,
parent
=
node
)
def
verbose_debug_print
(
string
):
global
verbose
if
verbose
:
print
(
string
)
def
main
(
args
):
def
main
(
args
):
global
cal
global
cal
,
verbose
"""
Run main function.
"""
"""
Run main function.
"""
ics_filename
=
args
.
ics_file
# input
ics_filename
=
args
.
ics_file
# input
mm_filename
=
args
.
mindmap_file
# output
mm_filename
=
args
.
mindmap_file
# output
left_right_flag
=
args
.
orientation
verbose
=
args
.
verbose
mm_content
=
freeplane_tools
.
data
.
get_template
()
# Vorlage öffnen und verwenden
mm_content
=
freeplane_tools
.
data
.
get_template
()
# Vorlage öffnen und verwenden
...
@@ -192,6 +214,9 @@ def main(args):
...
@@ -192,6 +214,9 @@ def main(args):
# aus ics lesen
# aus ics lesen
cal
=
icalendar
.
cal
.
Component
.
from_ical
(
ics_string
)
cal
=
icalendar
.
cal
.
Component
.
from_ical
(
ics_string
)
# Zähle die Anzahl von parent-nodes (ohne parent_uid)
count_parent_nodes
=
0
## ics in list umwandeln
## ics in list umwandeln
list_todos
=
list
()
list_todos
=
list
()
for
ics_todo
in
cal
.
walk
(
"
VTODO
"
):
for
ics_todo
in
cal
.
walk
(
"
VTODO
"
):
...
@@ -200,6 +225,7 @@ def main(args):
...
@@ -200,6 +225,7 @@ def main(args):
except
:
except
:
parent_uid
=
None
parent_uid
=
None
try
:
try
:
SUMMARY
=
str
(
ics_todo
[
"
SUMMARY
"
])
SUMMARY
=
str
(
ics_todo
[
"
SUMMARY
"
])
except
:
except
:
...
@@ -212,29 +238,53 @@ def main(args):
...
@@ -212,29 +238,53 @@ def main(args):
try
:
try
:
status
=
str
(
ics_todo
[
"
STATUS
"
])
status
=
str
(
ics_todo
[
"
STATUS
"
])
print
(
f
"
Status gefunden! *********
{
status
}
"
)
verbose_debug_
print
(
f
"
Status gefunden! *********
{
status
}
"
)
except
:
except
:
status
=
None
status
=
None
if
status
!=
"
COMPLETED
"
:
# or status != None or status is not None:
if
status
!=
"
COMPLETED
"
:
# or status != None or status is not None:
print
([
UID
,
SUMMARY
,
parent_uid
])
verbose_debug_
print
([
UID
,
SUMMARY
,
parent_uid
])
list_todos
.
append
([
UID
,
SUMMARY
,
parent_uid
])
list_todos
.
append
([
UID
,
SUMMARY
,
parent_uid
])
if
parent_uid
==
None
:
count_parent_nodes
+=
1
# root nodes zählen
# print(ics_todo)
# print(ics_todo)
# break
# break
# print(list_todos)
# print(list_todos)
#
todo:
Liste sortieren, zuerst Aufgaben ohne parent
# Liste sortieren, zuerst Aufgaben ohne parent
list_todos
=
sort_tree
(
list_todos
)
list_todos
=
sort_tree
(
list_todos
)
count_converted_parent_nodes
=
0
# Liste sortieren oder Stück für Stück durchgehen
# Liste sortieren oder Stück für Stück durchgehen
for
single_todo
in
list_todos
:
for
single_todo
in
list_todos
:
UID
=
single_todo
[
0
]
UID
=
single_todo
[
0
]
SUMMARY
=
single_todo
[
1
]
SUMMARY
=
single_todo
[
1
]
parent_uid
=
single_todo
[
2
]
parent_uid
=
single_todo
[
2
]
print
(
f
"
UID:
{
UID
}
| Parent_ID:
{
parent_uid
}
"
)
verbose_debug_
print
(
f
"
UID:
{
UID
}
| Parent_ID:
{
parent_uid
}
"
)
if
parent_uid
==
None
:
if
parent_uid
==
None
:
ET
.
SubElement
(
tree
.
findall
(
"
node
"
)[
0
],
"
node
"
,
{
"
TEXT
"
:
SUMMARY
,
"
ID
"
:
UID
})
count_converted_parent_nodes
+=
1
if
left_right_flag
==
None
:
verbose_debug_print
(
f
"
Zweiseitig, konvertiert:
{
count_converted_parent_nodes
}
, gesamt:
{
count_parent_nodes
}
"
)
if
count_converted_parent_nodes
<
count_parent_nodes
/
2
:
# erste Hälft links
mydict
=
{
"
TEXT
"
:
SUMMARY
,
"
ID
"
:
UID
,
"
POSITION
"
:
"
left
"
}
else
:
# zweite Hälfte rechts
mydict
=
{
"
TEXT
"
:
SUMMARY
,
"
ID
"
:
UID
}
if
'
l
'
==
left_right_flag
:
mydict
=
{
"
TEXT
"
:
SUMMARY
,
"
ID
"
:
UID
,
"
POSITION
"
:
"
left
"
}
elif
'
r
'
==
left_right_flag
:
mydict
=
{
"
TEXT
"
:
SUMMARY
,
"
ID
"
:
UID
}
else
:
pass
# todo je nach switch parent-nodes links, rechts oder verteilt (halbe-halbe) erzeugen, gesamtzahl ist in count_parent_nodes
ET
.
SubElement
(
tree
.
findall
(
"
node
"
)[
0
],
"
node
"
,
mydict
)
else
:
else
:
# node finden mit attribut ID == parent_uid
# node finden mit attribut ID == parent_uid
# find_text = f".//*[@ID={parent_uid}]"
# find_text = f".//*[@ID={parent_uid}]"
...
@@ -244,7 +294,7 @@ def main(args):
...
@@ -244,7 +294,7 @@ def main(args):
for
tag
in
tree
.
findall
(
"
.//*[@ID]
"
)
for
tag
in
tree
.
findall
(
"
.//*[@ID]
"
)
if
parent_uid
in
tag
.
attrib
[
"
ID
"
]
if
parent_uid
in
tag
.
attrib
[
"
ID
"
]
]
]
print
(
f
"
parent_node:
{
parent_node
}
, len=
{
len
(
parent_node
)
}
"
)
verbose_debug_
print
(
f
"
parent_node:
{
parent_node
}
, len=
{
len
(
parent_node
)
}
"
)
if
(
if
(
len
(
parent_node
)
<
1
len
(
parent_node
)
<
1
):
# keinen passenden Knoten gefunden
):
# keinen passenden Knoten gefunden
...
@@ -256,7 +306,7 @@ def main(args):
...
@@ -256,7 +306,7 @@ def main(args):
ET
.
SubElement
(
parent_node
[
0
],
"
node
"
,
{
"
TEXT
"
:
SUMMARY
,
"
ID
"
:
UID
})
ET
.
SubElement
(
parent_node
[
0
],
"
node
"
,
{
"
TEXT
"
:
SUMMARY
,
"
ID
"
:
UID
})
## MM Zentralknoten anlegen mit Dateinamen
## MM Zentralknoten anlegen mit Dateinamen
print
(
ics_filename
.
split
(
"
.
"
)[
0
])
verbose_debug_
print
(
ics_filename
.
split
(
"
.
"
)[
0
])
# ET.SubElement(tree, 'node', {'TEXT': ics_filename, 'STYLE': 'oval'}) funktioniert nicht, legt einen zweiten untersten 'node' an
# ET.SubElement(tree, 'node', {'TEXT': ics_filename, 'STYLE': 'oval'}) funktioniert nicht, legt einen zweiten untersten 'node' an
tree
.
findall
(
"
node
"
)[
0
].
set
(
tree
.
findall
(
"
node
"
)[
0
].
set
(
"
TEXT
"
,
ics_filename
.
split
(
"
.
"
)[
0
]
"
TEXT
"
,
ics_filename
.
split
(
"
.
"
)[
0
]
...
@@ -288,17 +338,17 @@ def main(args):
...
@@ -288,17 +338,17 @@ def main(args):
# Eintrag in MM erzeugen
# Eintrag in MM erzeugen
# mm_root = tree.getroot()
# mm_root = tree.getroot()
print
(
tree
.
tag
)
verbose_debug_
print
(
tree
.
tag
)
# ET.SubElement(tree,'node', {'TEXT':'Beispiel 1', 'STYLE':'oval'})
# ET.SubElement(tree,'node', {'TEXT':'Beispiel 1', 'STYLE':'oval'})
# show text of all entries in mm
# show text of all entries in mm
for
node
in
tree
.
findall
(
"
node
"
):
for
node
in
tree
.
findall
(
"
node
"
):
text
=
node
.
get
(
"
TEXT
"
)
text
=
node
.
get
(
"
TEXT
"
)
print
(
f
"
{
text
}
"
)
verbose_debug_
print
(
f
"
{
text
}
"
)
# ET.SubElement(node,"node", {'TEXT':'Beispiel 2'})
# ET.SubElement(node,"node", {'TEXT':'Beispiel 2'})
for
innernode
in
node
.
findall
(
"
node
"
):
for
innernode
in
node
.
findall
(
"
node
"
):
text
=
innernode
.
get
(
"
TEXT
"
)
text
=
innernode
.
get
(
"
TEXT
"
)
print
(
f
"
{
text
}
"
)
verbose_debug_
print
(
f
"
{
text
}
"
)
# gehe_durch_mindmap_tree(tree, None)
# gehe_durch_mindmap_tree(tree, None)
...
...
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