fix packaging for f37 (4/n)
[plcapi.git] / PLC / Methods / __init__.py
1
2 import os
3 import glob
4
5 native_methods = []
6 toppath = os.path.dirname(__file__)
7
8 # do not blindly scan this directory, as when using devel tools
9 # like `make sync` we can easily end up with more files than needed
10 # which breaks in production
11
12 contents = [
13     ('.', '[A-Z][a-zA-Z]*.py'),
14     ('system', '[a-zA-Z]*.py'),
15 ]
16
17 for dir, pattern in contents:
18     matches = glob.glob("{}/{}/{}".format(toppath, dir, pattern))
19     # count 2 slashes
20     prefix = len(toppath) + 1 + len(dir) + 1
21     for match in matches:
22         filename = match[prefix:][:-3]
23         python_name = filename if dir == '.' \
24             else "{}.{}".format(dir, filename)
25         native_methods.append(python_name)
26
27 if __name__ == '__main__':
28     native_methods.sort()
29     print(native_methods)