1
|
|
|
#!/usr/bin/env python |
2
|
|
|
# -*- coding: utf8 -*- |
3
|
|
|
# |
4
|
|
|
# versions.py : checks releases and versions of programs through RSS |
5
|
|
|
# or Atom feeds and tells you |
6
|
|
|
# |
7
|
|
|
# (C) Copyright 2016 - 2018 Olivier Delhomme |
8
|
|
|
# e-mail : [email protected] |
9
|
|
|
# |
10
|
|
|
# This program is free software; you can redistribute it and/or modify |
11
|
|
|
# it under the terms of the GNU General Public License as published by |
12
|
|
|
# the Free Software Foundation; either version 3, or (at your option) |
13
|
|
|
# any later version. |
14
|
|
|
# |
15
|
|
|
# This program is distributed in the hope that it will be useful, |
16
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
17
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18
|
|
|
# GNU General Public License for more details. |
19
|
|
|
# |
20
|
|
|
# You should have received a copy of the GNU General Public License |
21
|
|
|
# along with this program; if not, write to the Free Software Foundation, |
22
|
|
|
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
23
|
|
|
# |
24
|
1 |
|
import codecs |
25
|
1 |
|
import sys |
26
|
1 |
|
import locale |
27
|
1 |
|
import argparse |
28
|
1 |
|
import os |
29
|
1 |
|
import re |
30
|
1 |
|
import errno |
31
|
1 |
|
import time |
32
|
1 |
|
import doctest |
33
|
1 |
|
import feedparser |
34
|
1 |
|
import yaml |
35
|
1 |
|
import operator |
36
|
1 |
|
import configuration |
37
|
1 |
|
import caches |
38
|
1 |
|
import common |
39
|
|
|
|
40
|
|
|
""" |
41
|
|
|
This program checks projects versions through RSS and Atom feeds and |
42
|
|
|
should only print those with new release version. |
43
|
|
|
|
44
|
|
|
It implements checking for projects in github.com and freshcode.club. |
45
|
|
|
Projects must be added to a YAML file (named by default |
46
|
|
|
~/.config/versions/versions.yaml). One can use --file=FILENAME option |
47
|
|
|
to specify an alternative YAML file. version.yaml is included as an |
48
|
|
|
example in this project. |
49
|
|
|
|
50
|
|
|
Versions uses and produces text files. Those files are cache files |
51
|
|
|
written into ~/.local/versions directory. "*.cache" are cache files |
52
|
|
|
containing the project list and their associated version (the latest). |
53
|
|
|
"*.feed" are information feed cache files containing on only one line |
54
|
|
|
the latest parsed post of the feed. |
55
|
|
|
""" |
56
|
|
|
|
57
|
|
|
|
58
|
|
|
|
59
|
|
|
|
60
|
|
|
|
61
|
|
|
|
62
|
1 |
|
def main(): |
63
|
|
|
""" |
64
|
|
|
This is the where the program begins |
65
|
|
|
""" |
66
|
|
|
|
67
|
1 |
|
if sys.version_info[0] == 2: |
68
|
|
|
sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.stdout) |
69
|
|
|
|
70
|
1 |
|
versions_conf = configuration.Conf() # Configuration options |
71
|
|
|
|
72
|
1 |
|
if versions_conf.options.debug: |
73
|
1 |
|
doctest.testmod(verbose=True) |
74
|
|
|
|
75
|
1 |
|
if os.path.isfile(versions_conf.config_filename): |
76
|
1 |
|
versions_conf.print_cache_or_check_versions() |
77
|
|
|
|
78
|
|
|
else: |
79
|
1 |
|
print(u'Error: file {} does not exist'.format(versions_conf.config_filename)) |
80
|
|
|
|
81
|
|
|
# End of main() function |
82
|
|
|
|
83
|
|
|
|
84
|
1 |
|
if __name__ == "__main__": |
85
|
|
|
main() |
86
|
|
|
|