File indexing completed on 2024-04-21 16:22:42
0001 #!/usr/bin/env python3 0002 """ 0003 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0004 SPDX-FileCopyrightText: 2020 Noah Davis <noahadvs@gmail.com> 0005 """ 0006 import os 0007 import sys 0008 import mmap 0009 """ 0010 This script is just a convenient way to get a list of qml objects so that they can be pasted into the qmldir file 0011 """ 0012 0013 INPUT_DIR = "./" 0014 if len(sys.argv) > 1: 0015 INPUT_DIR = sys.argv[1] 0016 0017 for dirpath, dirnames, filenames in os.walk(INPUT_DIR): 0018 for f in filenames: 0019 # Filter out files 0020 if not (f.endswith('.qml')): 0021 continue 0022 0023 filepath = os.path.join(dirpath, f) 0024 0025 # Thanks StackOverflow! https://stackoverflow.com/questions/4940032/how-to-search-for-a-string-in-text-files 0026 with open(filepath, 'rb', 0) as file, mmap.mmap(file.fileno(), 0, access=mmap.ACCESS_READ) as s: 0027 if s.find(b"pragma Singleton") != -1: 0028 print("singleton " + f.rstrip('.qml') + " 1.0 " + f) 0029 else: 0030 print(f.rstrip('.qml') + " 1.0 " + f)