-
Notifications
You must be signed in to change notification settings - Fork 3
/
constants.py
67 lines (60 loc) · 1.39 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
import os
are_we_live = os.environ.get('APP_LOCATION') == 'heroku'
#are_we_live = True
SERVER_PATH = os.path.dirname(os.path.realpath(__file__))
STATIC_PATH = os.path.join(SERVER_PATH, 'static')
IMAGES_1024_PATH = os.path.join(STATIC_PATH, 'images_1024')
DATA_SELECTION_QUERY_FIELDS = [
'page_number',
'line_number',
'sura_number',
'ayah_number',
'position',
'min_x',
'min_y',
'max_x',
'max_y'
]
DATA_SELECTION_QUERY_FIELDS_MAP = [
'page',
'line',
'sura',
'ayah',
'position',
'min_x',
'min_y',
'max_x',
'max_y'
]
DATA_SELECTION_ORDER_FIELDS = [
'sura_number',
'ayah_number',
'position'
]
QA_PAGE_FILE_NAME_FORMAT = 'page{0:03d}.png';
MT_PAGE_FILE_NAME_FORMAT = '{}.jpg'
PAGE_CONFIG = {
'1024': {
'res': [1024, 1656],
'format': QA_PAGE_FILE_NAME_FORMAT
},
'1260': {
'res': [1260, 2038],
'format': QA_PAGE_FILE_NAME_FORMAT
},
'1920': {
'res': [1920, 3106],
'format': QA_PAGE_FILE_NAME_FORMAT
},
'1053': {
'res': [776, 1053],
'format': MT_PAGE_FILE_NAME_FORMAT,
'res_initial': [827, 1158],
}
}
def get_page_resolution(res_key, safah):
if res_key == '1053' and safah < 3:
resolution = PAGE_CONFIG['1053']['res_initial']
else:
resolution = PAGE_CONFIG[res_key]['res']
return resolution