46 |
error = 0 |
error = 0 |
47 |
target = None |
target = None |
48 |
|
|
49 |
def __init__(self, var, s, list): |
def __init__(self, var, toks, list): |
50 |
""" |
""" |
51 |
Initilizes link. |
Initilizes link. |
52 |
""" |
""" |
53 |
dbg(self.key+' VAR: %s, S: %s, LIST: %s' % (var, s, list)) |
dbg("link: %s %s %s" % (var, toks,list)) |
54 |
|
|
55 |
if config.link_base_directory == None: |
if config.link_base_directory == None: |
56 |
redirection_path = config.working_directory |
redirection_path = config.working_directory |
57 |
else: redirection_path = config.link_base_directory |
else: redirection_path = config.link_base_directory |
58 |
|
|
59 |
if (len(s.split(' ')) > 0): |
if (len(toks) > 0): |
60 |
|
self.title = toks[0] |
61 |
|
|
62 |
|
if (len(toks) > 1): |
63 |
""" |
""" |
64 |
The 'link' may be followed by an attributed, which is |
The 'link' may be followed by an attribute, which is |
65 |
interpreted as keyword for one of the redirections mapped |
interpreted as keyword for one of the redirections mapped |
66 |
in config. |
in config. |
67 |
""" |
""" |
68 |
redirection = s.split(' ')[-1] |
self.title = toks[0] |
69 |
|
redirection = toks[-1] |
70 |
if config.link_redirection.has_key(redirection): |
if config.link_redirection.has_key(redirection): |
71 |
s = s[0:len(s)-len(redirection)-1] |
toks.remove(redirection) |
72 |
redirection_path = config.link_redirection[redirection] |
redirection_path = config.link_redirection[redirection] |
73 |
dbg('Redirection %s: %s' % (redirection, redirection_path)) |
dbg('Redirection %s: %s' % (redirection, redirection_path)) |
74 |
|
|
|
self.title = s.strip() |
|
|
|
|
75 |
if (len(list) > 0): |
if (len(list) > 0): |
76 |
""" |
""" |
77 |
Multiple link could be given. |
Multiple link could be given. |
78 |
Let the last working one overwrite others. |
Let the last working one overwrite others. |
79 |
""" |
""" |
80 |
for link in list: |
for link in list: |
81 |
if type(link) == type([]): |
if type(link[0]) == type([]): |
82 |
link = link[0] |
link = link[0][0] |
83 |
|
else: link = link[0] |
84 |
if self.target == None or \ |
if self.target == None or \ |
85 |
not os.path.isfile(self.target): |
not os.path.isfile(self.target): |
86 |
if link.startswith('http://'): self.target = link |
if link.startswith('http://'): self.target = link |