-
Notifications
You must be signed in to change notification settings - Fork 1
/
simplified_openvpn_share.py
56 lines (41 loc) · 1.59 KB
/
simplified_openvpn_share.py
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
53
54
55
56
#!/usr/bin env python3
# -*- coding: utf-8 -*-
"""File that contains SimplifiedOpenvpnShare class."""
import os
from simplified_openvpn_helper import SimplifiedOpenvpnHelper as _helper
class SimplifiedOpenvpnShare:
"""Class that contains methods that will get used by sharing functionality."""
def __init__(self):
"""Initialises SimplifiedOpenvpnShare class."""
self.container = _helper.sanitize_path(os.path.dirname(os.path.realpath(__file__)))
self.override = self.container + 'local/'
if not os.path.isdir(self.override):
self.override = None
@property
def css_path(self):
"""Method that return path of CSS file that will be used for sharing page."""
if self.override:
path = self.override + 'share.css'
if os.path.isfile(path):
return path
path = self.container + 'style/share.css'
if os.path.isfile(path):
return path
return None
@property
def css(self):
"""Method that return CSS content for sharing page."""
if self.css_path:
return _helper.read_file_as_value(self.css_path)
return None
@property
def template_path(self):
"""Method that return path of template file that will be used for sharing page."""
if self.override:
path = self.override + 'share.mustache'
if os.path.isfile(path):
return path
path = self.container + 'templates/share.mustache'
if os.path.isfile(path):
return path
return None