boxlibrary_converter.py
Go to the documentation of this file.
1 #!/bin/python
2 # Convert a box library from xar_version 3 to new format version 4
3 
4 import os
5 import sys
6 import xar_converter
7 
8 
9 def list_files(rootPath):
10  """ return a list of all files found from rootPath
11  the resulting file pathes are relative to rootPath
12  """
13  result = []
14  for root, dirs, files in os.walk(rootPath):
15  for filename in files:
16  fullpath = os.path.join(root, filename)
17  result.append(os.path.relpath(fullpath, rootPath))
18  return result
19 
20 
21 def main():
22  """ Entry point of the box library converter
23  """
24  param = []
25  if len(sys.argv) not in range(2, 4):
26  sys.stderr.write("Incorrect number of arguments" + os.linesep)
27  sys.exit(1)
28  param.append(sys.argv[1])
29  if (len(sys.argv) == 3):
30  param.append(sys.argv[2])
31  else:
32  param.append("objects")
33 
34  abspath = os.path.abspath(param[0])
35  dest_dir = os.path.abspath(param[1])
36 
37  files = list_files(abspath)
38  for file in files:
39  filepath, filename = os.path.split(file)
40  if(filename in ["box.xar", "behavior.xar"]):
41  print("converting " + str(file) + ":\n")
42  try:
43  fullinputpath = os.path.join(abspath, file)
44  fulloutputpath = os.path.join(dest_dir, filepath)
45 
46  folders = filepath.split(os.sep)
47  xar_converter.convert_boxlibrary(fullinputpath,
48  fulloutputpath,
49  folders[len(folders) - 1])
50  except BaseException as error:
51  print("Could not convert: " + str(error))
52 
53 
54 if __name__ == "__main__":
55  main()
boxlibrary_converter.main
def main()
Definition: boxlibrary_converter.py:21
boxlibrary_converter.list_files
def list_files(rootPath)
Definition: boxlibrary_converter.py:9


naoqi_libqicore
Author(s): Aldebaran
autogenerated on Wed Sep 14 2022 02:22:41