ocr process
Showing
4 changed files
with
29 additions
and
4 deletions
1 | aiohttp==3.6.2 | ||
2 | async-timeout==3.0.1 | ||
3 | attrs==19.3.0 | ||
1 | certifi==2016.2.28 | 4 | certifi==2016.2.28 |
5 | chardet==3.0.4 | ||
2 | Django==2.1 | 6 | Django==2.1 |
3 | # django-mysqlpool @ https://github.com/smartfile/django-mysqlpool/archive/master.zip | 7 | # django-mysqlpool @ https://github.com/smartfile/django-mysqlpool/archive/master.zip |
4 | djangorestframework==3.9.0 | 8 | djangorestframework==3.9.0 |
5 | djangorestframework-jwt==1.11.0 | 9 | djangorestframework-jwt==1.11.0 |
10 | idna==2.9 | ||
11 | idna-ssl==1.1.0 | ||
6 | marshmallow==3.6.1 | 12 | marshmallow==3.6.1 |
13 | multidict==4.7.6 | ||
7 | pdfminer3k==1.3.4 | 14 | pdfminer3k==1.3.4 |
8 | Pillow==7.1.2 | 15 | Pillow==7.1.2 |
9 | ply==3.11 | 16 | ply==3.11 |
... | @@ -17,4 +24,7 @@ redis==3.4.1 | ... | @@ -17,4 +24,7 @@ redis==3.4.1 |
17 | # situlogger @ http://gitlab.situdata.com/zhouweiqi/situlogger/repository/archive.tar.gz?ref=master | 24 | # situlogger @ http://gitlab.situdata.com/zhouweiqi/situlogger/repository/archive.tar.gz?ref=master |
18 | six==1.14.0 | 25 | six==1.14.0 |
19 | SQLAlchemy==0.9.10 | 26 | SQLAlchemy==0.9.10 |
27 | typing-extensions==3.7.4.2 | ||
20 | webargs==6.1.0 | 28 | webargs==6.1.0 |
29 | xlwt==1.3.0 | ||
30 | yarl==1.4.2 | ... | ... |
This diff is collapsed.
Click to expand it.
... | @@ -7,13 +7,12 @@ class DocHandler: | ... | @@ -7,13 +7,12 @@ class DocHandler: |
7 | 7 | ||
8 | @staticmethod | 8 | @staticmethod |
9 | def get_link(doc_id, file='pdf'): | 9 | def get_link(doc_id, file='pdf'): |
10 | data_path = os.path.join(conf.DATA_DIR, str(doc_id)) | ||
11 | if file == 'pdf': | 10 | if file == 'pdf': |
12 | return os.path.join(data_path, '{0}.pdf'.format(str(doc_id))) | 11 | return '/data/{0}/{0}.pdf'.format(doc_id) |
13 | elif file == 'img': | 12 | elif file == 'img': |
14 | return os.path.join(data_path, '{0}_img.zip'.format(str(doc_id))) | 13 | return '/data/{0}/{0}_img.zip'.format(doc_id) |
15 | else: | 14 | else: |
16 | return os.path.join(data_path, '{0}.xlsx'.format(str(doc_id))) | 15 | return '/data/{0}/{0}.xls'.format(doc_id) |
17 | 16 | ||
18 | def get_doc_list(self, doc_queryset): | 17 | def get_doc_list(self, doc_queryset): |
19 | for doc_dict in doc_queryset: | 18 | for doc_dict in doc_queryset: | ... | ... |
1 | import os | ||
2 | from zipfile import ZipFile | ||
3 | |||
4 | |||
1 | def file_write(file, file_path): | 5 | def file_write(file, file_path): |
2 | with open(file_path, 'wb+') as f: | 6 | with open(file_path, 'wb+') as f: |
3 | for chunk in file.chunks(): | 7 | for chunk in file.chunks(): |
4 | f.write(chunk) | 8 | f.write(chunk) |
9 | |||
10 | |||
11 | def write_zip_file(dir_name, zipfile_path): | ||
12 | if not os.path.isdir(dir_name): | ||
13 | return | ||
14 | with ZipFile(zipfile_path, 'w') as z: | ||
15 | for root, dirs, files in os.walk(dir_name): | ||
16 | root_target_path = root.replace(dir_name, '') | ||
17 | for single_file in files: | ||
18 | src_file_path = os.path.join(root, single_file) | ||
19 | file_target_path = os.path.join(root_target_path, single_file) | ||
20 | z.write(src_file_path, file_target_path) | ... | ... |
-
Please register or sign in to post a comment