-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathoption.py
More file actions
78 lines (69 loc) · 2.44 KB
/
Copy pathoption.py
File metadata and controls
78 lines (69 loc) · 2.44 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
class Option:
def __init__(self, user_info):
self.user_info = user_info
self.handle = user_info['handle']
def source_tree(self, solved):
if self.mkdir():
return '%s/%s/' % (self.handle, self.dir_name(solved))
return '%s/' % (self.handle)
def mkdir(self):
return self.user_info['mkdir']
def dir_name(self, solved):
return self.replace_info(self.user_info['dir_name'], solved)
def source_name(self, solved):
return self.replace_info(self.user_info['source_name'], solved)
def replace_info(self, value, solved):
value = value.replace('[CONTEST]', str(solved['contest_id']))
value = value.replace('[INDEX]', solved['problem_id'])
value = value.replace('[TITLE]', solved['problem_title'])
value = self.replace_char(value)
return value
def replace_char(self, value):
if self.user_info['os'] == 'Windows':
value = value.replace(':', ':')
value = value.replace('?', '?')
value = value.replace('/', '/')
value = value.replace('*', '*')
value = value.replace('"', '"')
value = value.replace('<', '<')
value = value.replace('>', '>')
value = value.replace('\\', '\')
value = value.replace('|', '|')
return value
def get_ext(self, language):
extensions = {
'GNU C': '.c',
'GNU C11': '.c',
'Clang++17 Diagnostics': '.cpp',
'GNU C++': '.cpp',
'GNU C++11': '.cpp',
'GNU C++14': '.cpp',
'GNU C++17': '.cpp',
'GNU C++17 Diagnostics': '.cpp',
'MS C++': '.cpp',
'Mono C#': '.cs',
'D': '.d',
'Go': '.go',
'Haskell': '.hs',
'Java 8': '.java',
'Kotlin': '.kt',
'Ocaml': '.ml',
'Delphi': '.dpr',
'FPC': '.pas',
'PascalABC.NET': '.pas',
'Perl': '.pl',
'PHP': '.php',
'Python 2': '.py',
'Python 3': '.py',
'PyPy 2': '.py',
'PyPy 3': '.py',
'Ruby': '.rb',
'Rust': '.rs',
'Scala': '.scala',
'JavaScript': '.js',
'Node.js': '.js',
'Q#': '.qs'
}
if not language in extensions:
return True, 'unknown language'
return False, extensions[language]