Тюшев Максим, 321 DahDit 9391
ПУТИЛОВ ГЕОРГИЙ КОНСТАНТИНОВИЧ DahDit 10001
t1class morse:t1class morse:
22
3    def __init__(self, s=''):3    def __init__(self, s=''):
4        if not s or ' ' in s:4        if not s or ' ' in s:
5            self.sep = ','5            self.sep = ','
6            self.end = '.'6            self.end = '.'
7            s = s.split(' ')7            s = s.split(' ')
8        else:8        else:
9            self.sep = ' '9            self.sep = ' '
10            self.end = ''10            self.end = ''
11        n = len(s)11        n = len(s)
12        if n == 2:12        if n == 2:
13            self.dot = s[0]13            self.dot = s[0]
14            self.end_dot = s[0]14            self.end_dot = s[0]
15            self.dash = s[1]15            self.dash = s[1]
16        elif n == 3:16        elif n == 3:
17            (self.dot, self.end_dot, self.dash) = s17            (self.dot, self.end_dot, self.dash) = s
18        elif n == 4:18        elif n == 4:
19            (self.dot, self.end_dot, self.dash, self.end) = s19            (self.dot, self.end_dot, self.dash, self.end) = s
20        else:20        else:
21            self.dot = 'di'21            self.dot = 'di'
22            self.end_dot = 'dit'22            self.end_dot = 'dit'
23            self.dash = 'dah'23            self.dash = 'dah'
24        self.prev = None24        self.prev = None
25        self.buff = self.end25        self.buff = self.end
2626
27    def __neg__(self):27    def __neg__(self):
28        if self.sep != ' ':28        if self.sep != ' ':
29            self.buff = ' ' + self.dash + self.buff29            self.buff = ' ' + self.dash + self.buff
30        else:30        else:
31            self.buff = self.dash + self.buff31            self.buff = self.dash + self.buff
32        self.prev = '-'32        self.prev = '-'
33        return self33        return self
3434
35    def __pos__(self):35    def __pos__(self):
36        tmp = self.dot36        tmp = self.dot
37        if self.prev == '~' or not self.prev:37        if self.prev == '~' or not self.prev:
38            tmp = self.end_dot38            tmp = self.end_dot
39        if self.sep != ' ':39        if self.sep != ' ':
40            tmp = ' ' + tmp40            tmp = ' ' + tmp
41        self.buff = tmp + self.buff41        self.buff = tmp + self.buff
42        self.prev = '+'42        self.prev = '+'
43        return self43        return self
4444
45    def __invert__(self):45    def __invert__(self):
46        self.buff = self.sep + self.buff46        self.buff = self.sep + self.buff
47        self.prev = '~'47        self.prev = '~'
48        return self48        return self
4949
50    def __str__(self):50    def __str__(self):
51        return self.buff.strip()51        return self.buff.strip()
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op