Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gajim-plugins
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
60
Issues
60
List
Boards
Labels
Service Desk
Milestones
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gajim
gajim-plugins
Commits
002eb0c8
Commit
002eb0c8
authored
May 15, 2013
by
Evgeniy Popov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BirthdayReminderPlugin. Initial commit
parent
17cef576
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
87 additions
and
0 deletions
+87
-0
birthday_reminder/__init.py__
birthday_reminder/__init.py__
+1
-0
birthday_reminder/manifest.ini
birthday_reminder/manifest.ini
+7
-0
birthday_reminder/plugin.py
birthday_reminder/plugin.py
+79
-0
No files found.
birthday_reminder/__init.py__
0 → 100644
View file @
002eb0c8
from plugin import BirthDayPlugin
birthday_reminder/manifest.ini
0 → 100644
View file @
002eb0c8
[info]
name:
Birthday
reminder
short_name:
BDay
version:
0.0.1
description:
Birthday
reminder
plugin
authors:
Evgeniy
Popov
<evgeniypopov@gmail.com>
homepage:
https://bitbucket.org/axce1/bday
birthday_reminder/plugin.py
0 → 100644
View file @
002eb0c8
import
os
import
glob
import
datetime
from
xml.dom.minidom
import
*
from
plugins
import
GajimPlugin
from
plugins.helpers
import
log_calls
from
notify
import
popup
from
common
import
configpaths
class
BirthDayPlugin
(
GajimPlugin
):
@
log_calls
(
'BirthDayPlugin'
)
def
init
(
self
):
self
.
config_dialog
=
None
self
.
description
=
(
'Birthday reminder plugin'
)
configpath
=
configpaths
.
ConfigPaths
()
cache_path
=
configpath
.
cache_root
self
.
vcard_path
=
os
.
path
.
join
(
cache_path
,
'vcards'
)
+
os
.
sep
@
log_calls
(
'BirthDayPlugin'
)
def
activate
(
self
):
vcards
=
[]
date_dict
=
{}
for
jid
in
glob
.
glob
(
self
.
vcard_path
+
'*@*'
):
if
os
.
path
.
isfile
(
jid
):
vcards
.
append
(
jid
)
for
xmldoc
in
vcards
:
try
:
xml
=
parse
(
xmldoc
)
except
:
pass
else
:
name
=
xml
.
getElementsByTagName
(
'BDAY'
)
for
node
in
name
:
try
:
data
=
node
.
childNodes
[
0
].
nodeValue
date_dict
[
xmldoc
[
len
(
self
.
vcard_path
):]]
=
data
except
:
pass
today
=
datetime
.
date
.
today
()
for
key
,
value
in
date_dict
.
iteritems
():
convert_date
=
datetime
.
datetime
.
strptime
(
value
,
"%Y-%m-%d"
)
user_bday
=
datetime
.
date
(
today
.
year
,
convert_date
.
month
,
convert_date
.
day
)
if
user_bday
<
today
:
user_bday
=
user_bday
.
replace
(
year
=
today
.
year
+
1
)
time_to_bday
=
abs
(
user_bday
-
today
)
title
=
"BirthDay Reminder"
text
=
None
if
time_to_bday
.
days
>
5
:
continue
if
time_to_bday
.
days
==
5
:
text
=
"5 days before BDay %s"
%
key
elif
time_to_bday
.
days
==
3
:
text
=
"3 days before BDay %s"
%
key
elif
time_to_bday
.
days
==
1
:
text
=
"Tommorrow BDay %s"
%
key
elif
time_to_bday
.
days
==
0
:
text
=
"Today BDay %s"
%
key
if
text
:
popup
(
''
,
key
,
key
,
title
=
title
,
text
=
text
)
@
log_calls
(
'BirthDayPlugin'
)
def
deactivate
(
self
):
pass
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment