| 1 | import pyotherside |
| 2 | import os.path |
| 3 | import sys |
| 4 | |
| 5 | print('Hello from module!') |
| 6 | print(sys.path) |
| 7 | print('file exists?', pyotherside.qrc_is_file('qrc_example.qml')) |
| 8 | print('file exists?', pyotherside.qrc_is_file('qrc_example.qml.nonexistent')) |
| 9 | print('dir exists?', pyotherside.qrc_is_dir('/')) |
| 10 | print('dir exists?', pyotherside.qrc_is_dir('/nonexistent')) |
| 11 | |
| 12 | print('='*30) |
| 13 | def walk(root): |
| 14 | for entry in pyotherside.qrc_list_dir(root): |
| 15 | name = os.path.join(root, entry) |
| 16 | if pyotherside.qrc_is_dir(name): |
| 17 | walk(name) |
| 18 | else: |
| 19 | print(name, '=', len(pyotherside.qrc_get_file_contents(name)), 'bytes') |
| 20 | walk('/') |
| 21 | print('='*30) |
| 22 | print(pyotherside.qrc_get_file_contents('qrc_example.py').decode('utf-8')) |
| 23 | print('='*30) |
| 24 | |
| 25 | try: |
| 26 | print('dir exists with number', pyotherside.qrc_is_dir(123)) |
| 27 | except Exception as e: |
| 28 | print('got exception (as expected):', e) |
| 29 | |
| 30 | try: |
| 31 | print('file exists with none', pyotherside.qrc_is_file(None)) |
| 32 | except Exception as e: |
| 33 | print('got exception (as expected):', e) |
| 34 | |
| 35 | try: |
| 36 | print('dir entries with invalid', pyotherside.qrc_list_dir('/nonexistent')) |
| 37 | except Exception as e: |
| 38 | print('got exception (as expected):', e) |
| 39 | |
| 40 | try: |
| 41 | print('file contents with invalid', pyotherside.qrc_get_file_contents('/qrc_example.qml.nonexistent')) |
| 42 | except Exception as e: |
| 43 | print('got exception (as expected):', e) |