Comments (4)
Here is a fix that it's compiling (at least).
But honestly... I have a different understanding of "sorting". Maybe there are some more changes in the past on that icalender stuff...
My ics file before and after the sort script is not ordered at all
The events in my ics file have no UID, but a DTSTART, so that I commented out the two lines:
if a.has_key("UID"):
val = a["UID"]
My assumption was, there is a ordered list by using the DTSTART field of all events... but no... nothing...
Here is the full script so far:
#!/usr/bin/python
from icalendar import Calendar
import sys
def get_key_value(a):
val = ""
if a.has_key("UID"):
val = a["UID"]
elif a.has_key("DTSTART"):
val = a["DTSTART"]
elif a.has_key("DESCRIPTION"):
val = a["DESCRIPTION"]
elif a.has_key("SUMMARY"):
val = a["SUMMARY"]
elif a.has_key("SUMMARY"):
val = a["SUMMARY"]
return val
def uid_sort(a, b):
# fixme: we could protect us here against (invalid) UID-less components
a_val = get_key_value(a)
b_val = get_key_value(b)
if a_val > b_val:
return 1
elif a_val < b_val:
return -1
else:
return 0
if len(sys.argv) < 3:
print "Usage: sort_ics.py in.ics out.ics"
sys.exit(1)
cal = Calendar.from_ical(open(sys.argv[1], 'rb').read())
cal.subcomponents.sort(uid_sort)
# comps = cal.subcomponents
# print comps
# comps.sort(uid_sort)
# print comps
f = open(sys.argv[2], 'wb')
f.write(cal.to_ical())
f.close()
from ics-tools.
Thanks for the reply… but, I absolutely don’t recall what I was trying to do, and I am no longer interested in this feature. So this issue can be closed, from my point of view.
from ics-tools.
I am not the dev of this script, so i cant close it :)
But this problem is still open and I have encountered the same issue like you.
So I have just wanted to share the progress how we might bring back the script to a working state.
from ics-tools.
Hi, I just made some changes for python and a simple comparison does work now. Please check if this solves your problem.
from ics-tools.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ics-tools.