blob: d0e50bf344e2f9ab15f26834e128e40189a591d1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# -*- coding: utf-8 -*-
# Watchbox
# Copyright (C) 2017 MrKrabat
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import sys
import urllib
import urlparse
def parse():
"""Decode arguments
"""
if (sys.argv[2]):
return Args(urlparse.parse_qs(sys.argv[2][1:]))
else:
return Args({})
class Args(object):
"""Arguments class
Hold all arguments passed to the script and also persistent user data and
reference to the addon. It is intended to hold all data necessary for the
script.
"""
def __init__(self, kwargs):
"""Initialize arguments object
Hold also references to the addon which can't be kept at module level.
"""
self._addon = sys.modules["__main__"]._addon
self._addonname = sys.modules["__main__"]._plugin
self._addonid = sys.modules["__main__"]._plugId
self._cj = None
self._login = False
for key, value in kwargs.iteritems():
if value:
kwargs[key] = urllib.unquote_plus(value[0])
self.__dict__.update(kwargs)
|