/
Constants.py
166 lines (146 loc) · 4.97 KB
/
Constants.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# -*- coding: utf-8 -*-
import appdirs
import os
import re
from coalib import VERSION
THIS_IS_A_BUG = ('This is a bug. We are sorry for the inconvenience. '
'Please contact the developers for assistance.')
CRASH_MESSAGE = ('An unknown error occurred. This is a bug. We are '
'sorry for the inconvenience. Please contact the '
'developers for assistance. During execution of '
'coala an exception was raised. This should never '
'happen. When asked for, the following information '
'may help investigating:')
VERSION_CONFLICT_MESSAGE = ('There is a conflict in the version of a '
'dependency you have installed and the '
'requirements of coala. This may be resolved by '
'creating a separate virtual environment for '
'coala or running `pip install "%s"`. Be aware '
'that the latter solution might break other '
'python packages that depend on the currently '
'installed version.')
OBJ_NOT_ACCESSIBLE = '{} is not accessible and will be ignored!'
TRUE_STRINGS = ['1',
'on',
'okay',
'ok',
'okey-dokey',
'y',
'yes',
'yeah',
'yea',
'ya',
'ye',
'yessir',
'sure',
'true',
'tru',
'uh-huh',
'definitely',
'yup',
'yep',
'right',
'aye',
'alright',
'alrighty',
'hell yeah',
'affirmative',
'certainly',
'definitely',
'absolutely',
'roger',
'righto',
'ja',
'da',
'si',
'oui',
'amen',
'totally',
'10-4',
'positive']
FALSE_STRINGS = ['0',
'off',
'n',
'no',
'nix',
'nope',
'nop',
'nah',
'nay',
'false',
'uh-uh',
'wrong',
'none',
'nay',
'hell no',
'fat chance',
'not a chance in hell',
'not in a million years',
'out of the question',
'no siree',
'no way',
'nein',
'njet',
'nee',
'non',
'hakuna',
'negative']
# This string contains many unicode characters to challenge tests.
COMPLEX_TEST_STRING = ('4 r34l ch4ll3n63: 123 ÄÖü ABc @€¥ §&% {[( ←↓→↑ '
'ĦŊħ ß°^ \\\n\u2192')
# Path to the coalib directory
coalib_root = os.path.join(os.path.dirname(__file__),
os.path.pardir)
# Path to the language definition files
language_definitions = os.path.join(coalib_root,
'bearlib',
'languages',
'definitions')
system_coafile = os.path.join(coalib_root, 'default_coafile')
user_coafile = os.path.join(os.path.expanduser('~'), '.coarc')
default_coafile = '.coafile'
USER_DATA_DIR = appdirs.user_data_dir('coala', version=VERSION)
GLOBBING_SPECIAL_CHARS = '()[]|?*'
URL_REGEX = re.compile(
r'^(?:(?:http|ftp)[s]?://)?' # scheme
r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+' # domain name
r'(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|'
r'localhost|' # OR localhost
r'(?:\d{1,3}\.){3}\d{1,3})' # OR an ip
r'(?::\d+)?' # optional port number
r'(?:/?|[/?]\S+)$', # path
re.IGNORECASE)
def configure_logging():
"""
Configures the logging with hard coded dictionary.
"""
import sys
import logging.config
logging.config.dictConfig({
'version': 1,
'handlers': {
'colored': {
'class': 'logging.StreamHandler',
'formatter': 'colored',
'stream': sys.stderr
}
},
'root': {
'level': 'DEBUG',
'handlers': ['colored']
},
'formatters': {
'colored': {
'()': 'colorlog.ColoredFormatter',
'format': '%(log_color)s[%(levelname)s]%(reset)s[%(asctime)s]'
' %(message)s',
'datefmt': '%X',
'log_colors': {
'ERROR': 'red',
'WARNING': 'yellow',
'INFO': 'blue',
'DEBUG': 'green'
}
}
}
})