code_patcher.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 
6 
7 """ This modules provides functions useful to patch code contained in a box
8 .. module:: converter
9 """
10 
11 import converter.xar_types as xar_types
12 
13 
14 def patch(script):
15  """ Clean the code contained in script boxes
16  For now, script boxes can contain Python or QiChat script
17 
18  :param box: the box that holds the code
19  :returns: the patched code as a string
20  """
21  code = script.content
22 
23  # remove all unwanted characters at the beginning of the code
24  code = code.lstrip(' \t\r\n')
25  code = code.rstrip(' \t\r\n')
26  code += '\n'
27 
28  if script.language == xar_types.ScriptLanguage.QICHAT:
29  code = _patch_qichat_script(code)
30  elif script.language == xar_types.ScriptLanguage.PYTHON:
31  code = _patch_python_script(code)
32 
33  return code
34 
35 
37  """ Apply modifications to old version qichat script
38  to make it correspond to new behavior format files
39  """
40 
41  # for now, nothing to do more than the lstrip() made upper
42  return code
43 
44 
46  """ Apply modifications to old version python script
47  to make it correspond to new behavior format files
48  """
49 
50  # for now, nothing to do more than the lstrip() made upper
51  return code
converter.code_patcher._patch_qichat_script
def _patch_qichat_script(code)
Definition: code_patcher.py:36
converter.xar_types
Definition: xar_types.py:1
converter.code_patcher._patch_python_script
def _patch_python_script(code)
Definition: code_patcher.py:45
converter.code_patcher.patch
def patch(script)
Definition: code_patcher.py:14


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