original_docstring: r"""Add import statements to executable lines.
         
          Args:
              **kwargs: Keyword arguments for import statement.
  
          Returns:
              list: Lines required to complete the import.
   
          
docstring: r"""Add import statements to executable lines.
docstring_tokens: r " " " Add import statements to executable lines .
code: def write_executable_import(cls, **kwargs):
          r"""Add import statements to executable lines.
         
          Args:
              **kwargs: Keyword arguments for import statement.
  
          Returns:
              list: Lines required to complete the import.
   
          """
          if kwargs.get('filename', None) and os.path.isfile(kwargs['filename']):
              with open(kwargs['filename'], 'r') as fd:
                  contents = fd.read()
              # For functions that contain interface calls, split them out
              # and assign them to the global level
              if re.search(cls.function_param['interface_regex'], contents):
                  new_contents = contents
                  for m in re.finditer(cls.function_param['interface_regex'],
                                       contents):
                      mdict = m.groupdict()
                      assert('global_scope' in mdict['args'])
                      # if 'global_scope' not in mdict['args']:
                      #     mdict['args'] += ', global_scope=TRUE'
                      new_channel = (
                          '{indent}if (!exists("{variable}")) {{\n'
                          '{indent}  assign("{variable}", YggInterface('
                          '\'{class}\', \'{channel}\'{args}), '
                          'envir = .GlobalEnv)\n'
                          '{indent}}}').format(**mdict)
                      new_contents = new_contents.replace(m.group(0),
                                                          new_channel)
                  out = new_contents.splitlines()
                  return out
              if platform._is_win:  # pragma: windows
                  kwargs['filename'] = kwargs['filename'].replace('\\', '/')
          return super(RModelDriver, cls).write_executable_import(**kwargs)
code_tokens: def write_executable_import ( cls , ** kwargs ) : if kwargs . get ( 'filename' , None ) and os . path . isfile ( kwargs [ 'filename' ] ) : with open ( kwargs [ 'filename' ] , 'r' ) as fd : contents = fd . read ( ) if re . search ( cls . function_param [ 'interface_regex' ] , contents ) : new_contents = contents for m in re . finditer ( cls . function_param [ 'interface_regex' ] , contents ) : mdict = m . groupdict ( ) assert ( 'global_scope' in mdict [ 'args' ] ) new_channel = ( '{indent}if (!exists("{variable}")) {{\n' '{indent}  assign("{variable}", YggInterface(' '\'{class}\', \'{channel}\'{args}), ' 'envir = .GlobalEnv)\n' '{indent}}}' ) . format ( ** mdict ) new_contents = new_contents . replace ( m . group ( 0 ) , new_channel ) out = new_contents . splitlines ( ) return out if platform . _is_win : kwargs [ 'filename' ] = kwargs [ 'filename' ] . replace ( '\\' , '/' ) return super ( RModelDriver , cls ) . write_executable_import ( ** kwargs )
short_docstring: r"""Add import statements to executable lines.
short_docstring_tokens: r " " " Add import statements to executable lines .
comment: r"""Add import statements to executable lines.
         
          Args:
              **kwargs: Keyword arguments for import statement.
  
          Returns:
              list: Lines required to complete the import.
   
          """$SEP$# For functions that contain interface calls, split them out$SEP$# and assign them to the global level$SEP$# if 'global_scope' not in mdict['args']:$SEP$#     mdict['args'] += ', global_scope=TRUE'$SEP$# pragma: windows