resources.py 2.32 KB
Newer Older
1
2
3
4
"""Prints a detailed list of all resources that are registered, including the modules, where they have been registered."""

from __future__ import print_function
import bob.bio.base
5
import os
6

7
def resources():
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

  import argparse
  parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.ArgumentDefaultsHelpFormatter)
  parser.add_argument("--details", '-d', nargs = '+',
                      choices = ('d', 'database', 'p', 'preprocessor', 'e', 'extractor', 'a', 'algorithm', 'g', 'grid'),
                      default = ('d', 'p', 'e', 'a', 'g'),
                      help = "Select the resource types that should be listed.")

  args = parser.parse_args()

  if 'd' in args.details or 'database' in args.details:
    print ("\nList of registered databases:")
    print (bob.bio.base.list_resources('database'))

  if 'p' in args.details or 'preprocessor' in args.details:
    print ("\nList of registered preprocessors:")
    print (bob.bio.base.list_resources('preprocessor'))

  if 'e' in args.details or 'extractor' in args.details:
    print ("\nList of registered extractors:")
    print (bob.bio.base.list_resources('extractor'))

  if 'a' in args.details or 'algorithm' in args.details:
    print ("\nList of registered algorithms:")
    print (bob.bio.base.list_resources('algorithm'))

  if 'g' in args.details or 'grid' in args.details:
    print ("\nList of registered grid configurations:")
    print (bob.bio.base.list_resources('grid'))

  print()
39
40
41

def databases():
  import argparse
Manuel Günther's avatar
Manuel Günther committed
42
  database_replacement = "%s/.bob_bio_databases.txt" % os.environ["HOME"]
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58

  parser = argparse.ArgumentParser(description="Prints a list of directories for registered databases", formatter_class=argparse.ArgumentDefaultsHelpFormatter)
  parser.add_argument('-D', '--database-directories-file', metavar = 'FILE', default = database_replacement, help = 'The file, where database directories are stored (to avoid changing the database configurations)')

  args = parser.parse_args()

  # get registered databases
  databases = bob.bio.base.utils.resources.database_directories(replacements=args.database_directories_file)

  # print directories for all databases
  for d in sorted(databases):
    print ("\n%s:" % d)

    print ("Original data: %s" % databases[d][0])
    if len(databases[d]) > 1:
      print ("Annotations: %s" % databases[d][1])