original_docstring: 
      Build a complete RedCap Instrument CSV from a set of template_parts and a
      project csv file.
  
      Parameters
      ----------
      project_csv: str
          Filepath of the project csv file
      
      output_file: str, None
          Filepath of the resulting, complete project csv (with inserted
          template_parts. If None, the content is only returned and not saved.
          Default: None
  
      include_provenance: bool
          If True, include hidden fields in the project csv that contain
          git commits of source files
          Default: True
  
      Returns
      -------
          (list) list containing the lines of the complete project definition
          including the template content
      
docstring: Build a complete RedCap Instrument CSV from a set of template_parts and a
  project csv file.
  
  Parameters
  
  str
  Filepath of the project csv file
  
  str, None
  Filepath of the resulting, complete project csv (with inserted
  template_parts. If None, the content is only returned and not saved.
  Default: None
  
  bool
  If True, include hidden fields in the project csv that contain
  git commits of source files
  Default: True
  
  Returns
  
  (list) list containing the lines of the complete project definition
  including the template content
docstring_tokens: Build a complete RedCap Instrument CSV from a set of template_parts and a project csv file . Parameters str Filepath of the project csv file str None Filepath of the resulting complete project csv ( with inserted template_parts . If None the content is only returned and not saved . Default : None bool If True include hidden fields in the project csv that contain git commits of source files Default : True Returns ( list ) list containing the lines of the complete project definition including the template content
code: def build_project(project_csv, output_file=None, include_provenance=True):
      """
      Build a complete RedCap Instrument CSV from a set of template_parts and a
      project csv file.
  
      Parameters
      ----------
      project_csv: str
          Filepath of the project csv file
      
      output_file: str, None
          Filepath of the resulting, complete project csv (with inserted
          template_parts. If None, the content is only returned and not saved.
          Default: None
  
      include_provenance: bool
          If True, include hidden fields in the project csv that contain
          git commits of source files
          Default: True
  
      Returns
      -------
          (list) list containing the lines of the complete project definition
          including the template content
      """
      output = []
      used_template = []
      if isinstance(project_csv, str):
          project_csv = pathlib.Path(project_csv)
  
      with open(project_csv) as f:
          for line in f.readlines():
              # if line only contains reference then include reference here
              if line[0] == '{' and line[-2:] == '}\n' and not (',' in line):
                  template_name = pathlib.Path(line[1:-2]).with_suffix('.csv')
                  used_template.append(template_name)
                  include_file = (template_dir / template_name).resolve()
  
                  if not include_file.exists():
                      raise ValueError(f'Can not build project {project_csv}. '
                                       f'Included template {include_file} does '
                                       f'not exist')
  
                  with open(include_file, 'r') as f_include:
                      header = f_include.readline()
                      if header != output[0]:
                          raise ValueError('Project csv and template do not share'
                                           'the same header. Compare '
                                           f'{project_csv} and {include_file}')
                      output.extend(f_include.readlines())
              else:
                  output.append(line)
  
          if include_provenance:
  
              # collect provenance infos
              diglabtools_hash, diglabtools_state = get_repo_state(redcap_bridge_dir.parent)
              diglabtools_version = open(redcap_bridge_dir.parent / 'VERSION').read()
              project_conf_repo_hash, project_conf_repo_state = get_repo_state(project_csv)
  
              if not diglabtools_state:
                  warnings.warn('DigLabTools repository is in non-clean state.')
              if project_conf_repo_state is None:
                  warnings.warn('Project configuration is not part of a version control repository.')
              elif not project_conf_repo_state:
                  warnings.warn('Project configuration repository is in non-clean state.')
  
              # adding hidden rows to capture provenance info
              include_file = template_dir / '_provenance.csv'
              with open(include_file, 'r') as f_include:
                  header = f_include.readline()
                  if header != output[0]:
                      raise ValueError('Project csv and template do not share'
                                       'the same header. Compare '
                                       f'{project_csv} and {include_file}')
  
                  for l in f_include.readlines():
                      complete_line = l.format(diglabtools_hash=diglabtools_hash,
                                               diglabtools_version=diglabtools_version,
                                               redcap_forms_hash=project_conf_repo_hash)
                      output.append(complete_line)
  
      if output_file:
          with open(output_file, 'w') as f:
              f.writelines(output)
      # Print of templates used and total number of fields
      print(f"\nUsed template: ", end='')
      for template in used_template:
          print(f"{template} ", end='')
      print(f"with total of : {len(output)} fields", end='')
  
      return output
code_tokens: def build_project ( project_csv , output_file = None , include_provenance = True ) : output = [ ] used_template = [ ] if isinstance ( project_csv , str ) : project_csv = pathlib . Path ( project_csv ) with open ( project_csv ) as f : for line in f . readlines ( ) : if line [ 0 ] == '{' and line [ - 2 : ] == '}\n' and not ( ',' in line ) : template_name = pathlib . Path ( line [ 1 : - 2 ] ) . with_suffix ( '.csv' ) used_template . append ( template_name ) include_file = ( template_dir / template_name ) . resolve ( ) if not include_file . exists ( ) : raise ValueError ( f'Can not build project {project_csv}. ' f'Included template {include_file} does ' f'not exist' ) with open ( include_file , 'r' ) as f_include : header = f_include . readline ( ) if header != output [ 0 ] : raise ValueError ( 'Project csv and template do not share' 'the same header. Compare ' f'{project_csv} and {include_file}' ) output . extend ( f_include . readlines ( ) ) else : output . append ( line ) if include_provenance : diglabtools_hash , diglabtools_state = get_repo_state ( redcap_bridge_dir . parent ) diglabtools_version = open ( redcap_bridge_dir . parent / 'VERSION' ) . read ( ) project_conf_repo_hash , project_conf_repo_state = get_repo_state ( project_csv ) if not diglabtools_state : warnings . warn ( 'DigLabTools repository is in non-clean state.' ) if project_conf_repo_state is None : warnings . warn ( 'Project configuration is not part of a version control repository.' ) elif not project_conf_repo_state : warnings . warn ( 'Project configuration repository is in non-clean state.' ) include_file = template_dir / '_provenance.csv' with open ( include_file , 'r' ) as f_include : header = f_include . readline ( ) if header != output [ 0 ] : raise ValueError ( 'Project csv and template do not share' 'the same header. Compare ' f'{project_csv} and {include_file}' ) for l in f_include . readlines ( ) : complete_line = l . format ( diglabtools_hash = diglabtools_hash , diglabtools_version = diglabtools_version , redcap_forms_hash = project_conf_repo_hash ) output . append ( complete_line ) if output_file : with open ( output_file , 'w' ) as f : f . writelines ( output ) print ( f"\nUsed template: " , end = '' ) for template in used_template : print ( f"{template} " , end = '' ) print ( f"with total of : {len(output)} fields" , end = '' ) return output
short_docstring: Build a complete RedCap Instrument CSV from a set of template_parts and a
  project csv file.
short_docstring_tokens: Build a complete RedCap Instrument CSV from a set of template_parts and a project csv file .
comment: """
      Build a complete RedCap Instrument CSV from a set of template_parts and a
      project csv file.
  
      Parameters
      ----------
      project_csv: str
          Filepath of the project csv file
      
      output_file: str, None
          Filepath of the resulting, complete project csv (with inserted
          template_parts. If None, the content is only returned and not saved.
          Default: None
  
      include_provenance: bool
          If True, include hidden fields in the project csv that contain
          git commits of source files
          Default: True
  
      Returns
      -------
          (list) list containing the lines of the complete project definition
          including the template content
      """$SEP$# if line only contains reference then include reference here$SEP$# collect provenance infos$SEP$# adding hidden rows to capture provenance info$SEP$# Print of templates used and total number of fields