Initial commit
commit
a13967401f
@ -0,0 +1,60 @@
|
||||
# ---> Python
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
env/
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*,cover
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
@ -0,0 +1,8 @@
|
||||
MIT License
|
||||
Copyright (c) 2017 Bogdan Cordier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@ -0,0 +1,23 @@
|
||||
# ICal Fusion
|
||||
|
||||
|
||||
This software allows to merge multiple ical files into one.
|
||||
|
||||
### Features
|
||||
|
||||
- Simple filtering by field.
|
||||
- Duplicates detection based on a field.
|
||||
|
||||
### Todo
|
||||
|
||||
- Multiple filters
|
||||
- Date filtering
|
||||
- Command-line interface
|
||||
|
||||
## Requirements
|
||||
|
||||
- [icalendar](https://pypi.python.org/pypi/icalendar/)
|
||||
|
||||
## Usage
|
||||
|
||||
python3 ical_fusion.py
|
@ -0,0 +1,134 @@
|
||||
#! /usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim:fenc=utf-8
|
||||
#
|
||||
# Copyright © 2017 Bogdan Cordier
|
||||
#
|
||||
# Distributed under terms of the MIT license.
|
||||
|
||||
from icalendar import Calendar
|
||||
from tkinter import Tk, filedialog, Listbox, Button, Entry, StringVar, \
|
||||
LabelFrame, BooleanVar, Frame, ttk, END, Checkbutton, messagebox
|
||||
|
||||
ical_fields = ('SUMMARY', 'UID', 'LOCATION', 'CATEGORIES')
|
||||
|
||||
|
||||
class GUI:
|
||||
def __init__(self):
|
||||
self.root = Tk()
|
||||
self.root.title('ICal Fusion')
|
||||
self.root.iconbitmap('@icon.xbm')
|
||||
self.create_filter_frame()
|
||||
self.files = []
|
||||
self.create_files_list_frame()
|
||||
self.create_duplicates_frame()
|
||||
self.btn_frame = Frame(self.root)
|
||||
self.create_button_frame()
|
||||
self.calendar = Calendar()
|
||||
self.root.mainloop()
|
||||
|
||||
def create_filter_frame(self):
|
||||
filter_frame = LabelFrame(self.root, text='Filter')
|
||||
self.filter_type = ttk.Combobox(filter_frame, values=ical_fields)
|
||||
self.filter_type.current(0)
|
||||
self.filter_type.state(('!disabled', 'readonly'))
|
||||
self.filter_type.grid(row=0)
|
||||
|
||||
self.filter_cond = ttk.Combobox(filter_frame,
|
||||
values=('EQUAL TO',
|
||||
'CONTAINS'))
|
||||
self.filter_cond.current(1)
|
||||
self.filter_cond.state(('!disabled', 'readonly'))
|
||||
self.filter_cond.grid(row=0, column=1)
|
||||
|
||||
self.filter_value = StringVar()
|
||||
|
||||
self.filter_entry = Entry(filter_frame,
|
||||
textvariable=self.filter_value,
|
||||
width=25,
|
||||
bg='white')
|
||||
self.filter_entry.grid(row=0, column=2)
|
||||
filter_frame.pack(fill='x', side='top')
|
||||
|
||||
def create_files_list_frame(self):
|
||||
files_list_frame = LabelFrame(self.root, text='Files to merge')
|
||||
self.FilesList = Listbox(files_list_frame)
|
||||
self.FilesList.pack(side='left', fill='both', expand=1)
|
||||
files_list_frame.pack(fill='x')
|
||||
|
||||
def create_duplicates_frame(self):
|
||||
frame = Frame(self.root)
|
||||
self.duplicates_check = BooleanVar()
|
||||
self.duplicates_filter = ttk.Combobox(frame, value=ical_fields)
|
||||
self.duplicates_filter.current(0)
|
||||
self.duplicates_filter.state(('!disabled', 'readonly'))
|
||||
self.duplicates_filter.pack(side='right')
|
||||
self.duplicates_cbox = Checkbutton(frame,
|
||||
variable=self.duplicates_check,
|
||||
text='Remove duplicates by')
|
||||
self.duplicates_cbox.pack(side='right')
|
||||
frame.pack(fill='x')
|
||||
|
||||
def create_button_frame(self):
|
||||
Button(self.btn_frame, text='Add...',
|
||||
command=self.add_files).grid(row=0, column=0)
|
||||
Button(self.btn_frame, text='Merge',
|
||||
command=self.join_files).grid(row=0, column=1)
|
||||
self.btn_frame.pack(side='bottom')
|
||||
|
||||
def add_files(self):
|
||||
files = filedialog.askopenfilenames(title="Load ICal files",
|
||||
filetypes=[('ICal files', '.ics'),
|
||||
('all files', '.*')])
|
||||
for file in files:
|
||||
self.FilesList.insert(END, file)
|
||||
|
||||
def filter(self, event):
|
||||
value = self.filter_value.get()
|
||||
field = self.filter_type.get()
|
||||
if self.filter_cond.get() == 'CONTAINS':
|
||||
if value in event.get(field):
|
||||
return True
|
||||
if self.filter_cond.get() == 'EQUAL TO':
|
||||
if value == event.get(field):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def join_files(self):
|
||||
if self.FilesList.get(0, END):
|
||||
ical = filedialog.asksaveasfilename(title='Save as...')
|
||||
self.checked_values = set()
|
||||
|
||||
for file in self.FilesList.get(0, END):
|
||||
ics = open(file, 'r')
|
||||
cal = Calendar.from_ical(ics.read())
|
||||
ics.close()
|
||||
events = (co for co in cal.walk() if co.name == 'VEVENT')
|
||||
for event in events:
|
||||
if self.duplicates_check.get():
|
||||
field = self.duplicates_filter.get()
|
||||
value = event.get(field)
|
||||
if value in self.checked_values:
|
||||
break
|
||||
else:
|
||||
self.checked_values.add(value)
|
||||
|
||||
if self.filter_value:
|
||||
if self.filter(event):
|
||||
self.calendar.add_component(event)
|
||||
else:
|
||||
if self.duplicates_cbox.getboolean():
|
||||
pass
|
||||
else:
|
||||
self.calendar.add_component(event)
|
||||
|
||||
with open(ical, 'wb') as f:
|
||||
f.write(self.calendar.to_ical())
|
||||
|
||||
messagebox.showinfo('Success', 'Files were successfully joined !')
|
||||
else:
|
||||
messagebox.showerror('No files', 'Please add files to merge...')
|
||||
|
||||
if __name__ == '__main__':
|
||||
GUI()
|
@ -0,0 +1,49 @@
|
||||
#define icon_width 64
|
||||
#define icon_height 68
|
||||
static char icon_bits[] = {
|
||||
0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x87, 0xF8, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0x03, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0xDF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0x03, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07,
|
||||
0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0xCF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0x03, 0xC7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07,
|
||||
0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0xEF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0x07, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x03,
|
||||
0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0xEF, 0x01, 0x18, 0x80,
|
||||
0x01, 0x18, 0xC0, 0x07, 0xCF, 0x01, 0x18, 0x00, 0x01, 0x18, 0x80, 0x07,
|
||||
0xE7, 0x01, 0x18, 0x80, 0x01, 0x10, 0x80, 0x03, 0xEF, 0x01, 0x18, 0x80,
|
||||
0x01, 0x10, 0x80, 0x07, 0xC7, 0x01, 0x08, 0x00, 0x01, 0x18, 0x80, 0x03,
|
||||
0xCF, 0x01, 0x18, 0x80, 0x01, 0x10, 0x80, 0x07, 0xEF, 0x01, 0x08, 0x80,
|
||||
0x01, 0x18, 0x80, 0x03, 0xC7, 0x01, 0x18, 0x80, 0x01, 0x10, 0x80, 0x03,
|
||||
0xEF, 0x01, 0x18, 0x00, 0x01, 0x18, 0x80, 0x07, 0xCF, 0x01, 0x18, 0x80,
|
||||
0x01, 0x10, 0x80, 0x07, 0xEF, 0xAD, 0xBA, 0xED, 0xDB, 0xDD, 0xD5, 0x03,
|
||||
0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0xEF, 0x01, 0x18, 0x80,
|
||||
0x01, 0x10, 0x80, 0x03, 0xCF, 0x01, 0x08, 0x00, 0x01, 0x10, 0x80, 0x07,
|
||||
0xE7, 0x01, 0x18, 0x80, 0x01, 0x10, 0x80, 0x03, 0xCF, 0x01, 0x18, 0x80,
|
||||
0x01, 0x18, 0x80, 0x03, 0xE7, 0x01, 0x18, 0x00, 0x01, 0x10, 0x80, 0x07,
|
||||
0xCF, 0x01, 0x08, 0x80, 0x01, 0x10, 0x80, 0x07, 0xEF, 0x01, 0x18, 0x80,
|
||||
0x01, 0x18, 0x80, 0x03, 0xC7, 0x01, 0x18, 0x80, 0x01, 0x18, 0x80, 0x07,
|
||||
0xEF, 0x01, 0x08, 0x00, 0x01, 0x10, 0x80, 0x03, 0xEF, 0x01, 0x18, 0x80,
|
||||
0x01, 0x10, 0x80, 0x07, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x03,
|
||||
0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0xEF, 0x01, 0x18, 0x80,
|
||||
0x01, 0x10, 0x80, 0x07, 0xCF, 0x01, 0x08, 0x00, 0x01, 0x10, 0x80, 0x07,
|
||||
0xE7, 0x01, 0x18, 0x80, 0x01, 0x18, 0x80, 0x03, 0xEF, 0x01, 0x18, 0x80,
|
||||
0x01, 0x10, 0x80, 0x07, 0xC7, 0x01, 0x08, 0x00, 0x01, 0x18, 0x80, 0x03,
|
||||
0xCF, 0x01, 0x18, 0x80, 0x01, 0x10, 0x80, 0x07, 0xEF, 0x01, 0x08, 0x80,
|
||||
0x01, 0x18, 0x80, 0x03, 0xC7, 0x01, 0x18, 0x00, 0x01, 0x10, 0x80, 0x03,
|
||||
0xEF, 0x01, 0x18, 0x80, 0x01, 0x18, 0x80, 0x07, 0xCF, 0x01, 0x18, 0x80,
|
||||
0x01, 0x10, 0x80, 0x03, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07,
|
||||
0xCF, 0xB7, 0x5D, 0xDB, 0xAB, 0xBB, 0xDB, 0x07, 0xCF, 0x01, 0x18, 0x00,
|
||||
0x01, 0x30, 0x80, 0x07, 0xEF, 0x03, 0x10, 0x00, 0x01, 0x10, 0x80, 0x07,
|
||||
0xC7, 0x01, 0x18, 0x00, 0x03, 0x30, 0x80, 0x07, 0xCF, 0x01, 0x10, 0x00,
|
||||
0x03, 0x30, 0x80, 0x07, 0xC7, 0x03, 0x30, 0x00, 0x03, 0x20, 0x00, 0x07,
|
||||
0xCF, 0x03, 0x30, 0x00, 0x02, 0x60, 0x80, 0x0F, 0xCF, 0x03, 0x20, 0x00,
|
||||
0x06, 0x60, 0x00, 0x0F, 0x8F, 0x07, 0x60, 0x00, 0x06, 0x40, 0x00, 0x0F,
|
||||
0x87, 0x07, 0x40, 0x00, 0x0C, 0xC0, 0x00, 0x1F, 0x8F, 0xAF, 0xF9, 0x66,
|
||||
0xAD, 0xD9, 0x65, 0x1F, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F,
|
||||
0x0F, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x0F, 0xFC, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0x7F, 0x0F, 0x00, 0x82, 0x20, 0x08, 0x82, 0xF0, 0x08,
|
||||
0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x7F, 0xDB, 0xB6, 0x6D,
|
||||
0xDB, 0xB6, 0xFD, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0x00, };
|
Loading…
Reference in New Issue