| LEFT | RIGHT | 
|   1 # coding: utf-8 |   1 # coding: utf-8 | 
|   2  |   2  | 
|   3 # This file is part of the Adblock Plus web scripts, |   3 # This file is part of the Adblock Plus web scripts, | 
|   4 # Copyright (C) 2006-2015 Eyeo GmbH |   4 # Copyright (C) 2006-2015 Eyeo GmbH | 
|   5 # |   5 # | 
|   6 # Adblock Plus is free software: you can redistribute it and/or modify |   6 # Adblock Plus is free software: you can redistribute it and/or modify | 
|   7 # it under the terms of the GNU General Public License version 3 as |   7 # it under the terms of the GNU General Public License version 3 as | 
|   8 # published by the Free Software Foundation. |   8 # published by the Free Software Foundation. | 
|   9 # |   9 # | 
|  10 # Adblock Plus is distributed in the hope that it will be useful, |  10 # Adblock Plus is distributed in the hope that it will be useful, | 
|  11 # but WITHOUT ANY WARRANTY; without even the implied warranty of |  11 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|  12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the |  12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|  13 # GNU General Public License for more details. |  13 # GNU General Public License for more details. | 
|  14 # |  14 # | 
|  15 # You should have received a copy of the GNU General Public License |  15 # You should have received a copy of the GNU General Public License | 
|  16 # along with Adblock Plus.  If not, see <http://www.gnu.org/licenses/>. |  16 # along with Adblock Plus.  If not, see <http://www.gnu.org/licenses/>. | 
|  17  |  17  | 
|  18 import codecs |  18 import codecs | 
|  19 import json |  19 import json | 
 |  20 import time | 
|  20  |  21  | 
|  21 from sitescripts.notifications.parser import load_notifications |  22 from sitescripts.notifications.parser import load_notifications | 
|  22 from sitescripts.utils import get_config, setupStderr |  23 from sitescripts.utils import get_config, setupStderr | 
|  23  |  24  | 
|  24 def generate_notifications(path): |  25 def generate_notifications(path): | 
|  25   notifications = load_notifications() |  26   notifications = load_notifications() | 
|  26   # Ignoring notifications with variants here - we can only process those in a |  27   # Ignoring notifications with variants here - we can only process those in a | 
|  27   # URL handler. |  28   # URL handler. | 
|  28   notifications["notifications"] = [x for x in notifications |  29   notifications = [x for x in notifications if "variants" in x] | 
|  29                                     if "variants" not in x] |  30   output = { | 
 |  31     "notifications": notifications, | 
 |  32     "version": time.strftime("%Y%m%d%H%M", time.gmtime()) | 
 |  33   } | 
|  30   with codecs.open(path, "wb", encoding="utf-8") as file: |  34   with codecs.open(path, "wb", encoding="utf-8") as file: | 
|  31     json.dump(notifications, file, ensure_ascii=False, indent=2, |  35     json.dump(output, file, ensure_ascii=False, indent=2, | 
|  32         separators=(',', ': '), sort_keys=True) |  36         separators=(',', ': '), sort_keys=True) | 
|  33  |  37  | 
|  34 if __name__ == "__main__": |  38 if __name__ == "__main__": | 
|  35   setupStderr() |  39   setupStderr() | 
|  36   output = get_config().get("notifications", "output") |  40   output = get_config().get("notifications", "output") | 
|  37   generate_notifications(output) |  41   generate_notifications(output) | 
| LEFT | RIGHT |