annotate tests/test_resources.nim @ 909:f4bc149a385c

add: few string-ify methods, small fix for default-shaders
author Sam <sam@basx.dev>
date Sat, 09 Mar 2024 16:45:57 +0700
parents ad961543994b
children 114f395b9144
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
899
ad961543994b did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 696
diff changeset
1 import std/os
696
275ac4cdf7e0 did: replace zippy with "standard" nim zip, compiled from source, fix some errors
Sam <sam@basx.dev>
parents: 674
diff changeset
2 import std/streams
899
ad961543994b did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 696
diff changeset
3 import std/strformat
ad961543994b did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 696
diff changeset
4 import std/strutils
668
a02d503ffa53 add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff changeset
5
a02d503ffa53 add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff changeset
6 import semicongine
a02d503ffa53 add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff changeset
7
899
ad961543994b did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 696
diff changeset
8 proc list_all_mods_all_files() =
ad961543994b did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 696
diff changeset
9 for package in packages():
ad961543994b did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 696
diff changeset
10 echo &"Files in package {package}:"
ad961543994b did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 696
diff changeset
11 for i in walkResources(package = package):
ad961543994b did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 696
diff changeset
12 echo " ", i, ": ", i.loadResource(package = package).readAll().len
ad961543994b did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 696
diff changeset
13
ad961543994b did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 696
diff changeset
14 proc print_ls(dir, package: string, indent = 2) =
ad961543994b did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 696
diff changeset
15 for i in dir.ls(package = package):
ad961543994b did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 696
diff changeset
16 if i.kind == pcDir:
ad961543994b did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 696
diff changeset
17 echo "".align(indent), i.path, "/"
ad961543994b did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 696
diff changeset
18 print_ls(dir.joinPath(i.path), package = package, indent = indent + 2)
ad961543994b did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 696
diff changeset
19 else:
ad961543994b did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 696
diff changeset
20 echo "".align(indent), i.path, ": ", dir.joinPath(i.path).loadResource(package = package).readAll().len
ad961543994b did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 696
diff changeset
21
ad961543994b did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 696
diff changeset
22 proc list_files() =
ad961543994b did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 696
diff changeset
23 for package in packages():
ad961543994b did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 696
diff changeset
24 echo &"Recursive walk of package {package}: "
ad961543994b did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 696
diff changeset
25 print_ls("", package = package)
ad961543994b did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 696
diff changeset
26
ad961543994b did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 696
diff changeset
27
668
a02d503ffa53 add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff changeset
28 proc main() =
899
ad961543994b did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 696
diff changeset
29 echo "Packages available: ", packages()
ad961543994b did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 696
diff changeset
30 list_all_mods_all_files()
ad961543994b did: refactor and improve packaging API
Sam <sam@basx.dev>
parents: 696
diff changeset
31 list_files()
668
a02d503ffa53 add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff changeset
32
a02d503ffa53 add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff changeset
33 when isMainModule:
a02d503ffa53 add: some adjustment to the last refactoring :P
Sam <sam@basx.dev>
parents:
diff changeset
34 main()