annotate old_tests/test_resources.nim @ 1305:21c4e598d820

did: work on cursor issues, but now sync unfinished things to notebook
author sam <sam@basx.dev>
date Wed, 07 Aug 2024 19:09:03 +0700
parents 6360c8d17ce0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
438
1ab09f8cc68d did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 235
diff changeset
1 import std/os
235
5f6d3511ef79 did: replace zippy with "standard" nim zip, compiled from source, fix some errors
Sam <sam@basx.dev>
parents: 213
diff changeset
2 import std/streams
438
1ab09f8cc68d did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 235
diff changeset
3 import std/strformat
1ab09f8cc68d did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 235
diff changeset
4 import std/strutils
207
81fab407a479 add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff changeset
5
81fab407a479 add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff changeset
6 import semicongine
81fab407a479 add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff changeset
7
438
1ab09f8cc68d did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 235
diff changeset
8 proc list_all_mods_all_files() =
1139
114f395b9144 did: finish refactoring and updated all tests accordingly
sam <sam@basx.dev>
parents: 438
diff changeset
9 for package in Packages():
438
1ab09f8cc68d did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 235
diff changeset
10 echo &"Files in package {package}:"
1139
114f395b9144 did: finish refactoring and updated all tests accordingly
sam <sam@basx.dev>
parents: 438
diff changeset
11 for i in WalkResources(package = package):
114f395b9144 did: finish refactoring and updated all tests accordingly
sam <sam@basx.dev>
parents: 438
diff changeset
12 echo " ", i, ": ", i.LoadResource(package = package).readAll().len
438
1ab09f8cc68d did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 235
diff changeset
13
1ab09f8cc68d did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 235
diff changeset
14 proc print_ls(dir, package: string, indent = 2) =
1139
114f395b9144 did: finish refactoring and updated all tests accordingly
sam <sam@basx.dev>
parents: 438
diff changeset
15 for i in dir.List(package = package):
438
1ab09f8cc68d did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 235
diff changeset
16 if i.kind == pcDir:
1ab09f8cc68d did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 235
diff changeset
17 echo "".align(indent), i.path, "/"
1ab09f8cc68d did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 235
diff changeset
18 print_ls(dir.joinPath(i.path), package = package, indent = indent + 2)
1ab09f8cc68d did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 235
diff changeset
19 else:
1139
114f395b9144 did: finish refactoring and updated all tests accordingly
sam <sam@basx.dev>
parents: 438
diff changeset
20 echo "".align(indent), i.path, ": ", dir.joinPath(i.path).LoadResource(package = package).readAll().len
438
1ab09f8cc68d did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 235
diff changeset
21
1ab09f8cc68d did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 235
diff changeset
22 proc list_files() =
1139
114f395b9144 did: finish refactoring and updated all tests accordingly
sam <sam@basx.dev>
parents: 438
diff changeset
23 for package in Packages():
438
1ab09f8cc68d did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 235
diff changeset
24 echo &"Recursive walk of package {package}: "
1ab09f8cc68d did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 235
diff changeset
25 print_ls("", package = package)
1ab09f8cc68d did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 235
diff changeset
26
1ab09f8cc68d did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 235
diff changeset
27
207
81fab407a479 add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff changeset
28 proc main() =
1139
114f395b9144 did: finish refactoring and updated all tests accordingly
sam <sam@basx.dev>
parents: 438
diff changeset
29 echo "Packages available: ", Packages()
438
1ab09f8cc68d did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 235
diff changeset
30 list_all_mods_all_files()
1ab09f8cc68d did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 235
diff changeset
31 list_files()
207
81fab407a479 add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff changeset
32
81fab407a479 add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff changeset
33 when isMainModule:
81fab407a479 add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff changeset
34 main()