File indexing completed on 2025-01-05 03:41:08
0001 #!@Python3_EXECUTABLE@ 0002 # 0003 # SPDX-FileCopyrightText: 2016 Varun Joshi <varunj.1011@gmail.com> 0004 # 0005 # SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0006 0007 import sys 0008 import json 0009 0010 extractor_data = json.loads(sys.stdin.read()) 0011 0012 def extract(): 0013 path = extractor_data.get('path') 0014 mimetype = extractor_data.get('mimetype') 0015 0016 doc = open(path, 'r') 0017 0018 return_value = {} 0019 return_value['properties'] = {} 0020 # Values matching KFileMetaData::Type 0021 return_value['properties']['typeInfo'] = 'Text' 0022 # Plain text 0023 text = "" 0024 for lineCount, line in enumerate(doc): 0025 text += line; 0026 return_value['properties']['text'] = text 0027 # Other properties matching KFileMetaData::PropertyInfo 0028 return_value['properties']['lineCount'] = lineCount + 1 0029 return_value['status'] = 'OK' 0030 return_value['error'] = '' 0031 0032 print(json.dumps(return_value)) 0033 0034 if __name__ == "__main__": 0035 extract()