original_docstring: 
      Combines all PDF's found at `path` into a single document.
  
      To set output filename and/or location use `out_path`
      
docstring: Combines all PDF's found at `path` into a single document.
  To set output filename and/or location use `out_path`
docstring_tokens: Combines all PDF ' s found at ` path ` into a single document . To set output filename and / or location use ` out_path `
code: def merge_pdfs(path, out_path=None, use_outlines=False):
      """
      Combines all PDF's found at `path` into a single document.
  
      To set output filename and/or location use `out_path`
      """
      print('\nCombining pages')
      files = []
      if out_path is None:
          out_path = os.path.join(path, 'combined.pdf')
      filenames = get_files_of_type(path, '.pdf')
      merger = PyPDF2.PdfFileMerger()
      bar = progressbar.ProgressBar(max_value=len(filenames), redirect_stdout=True)
      for i, fn in enumerate(filenames):
          bk_txt = fn.split('.')[0]
          curr_path = os.path.join(path, fn)
          # Purposefully NOT using `with`, see http://stackoverflow.com/q/6773631
          f = open(curr_path, 'rb')
          # Can't close input files until output file is saved.
          # Instead, move to list to close later
          files.append(f)
          merger.append(f, bookmark=bk_txt, import_bookmarks=False)
          bar.update(i + 1)
      if use_outlines:
          merger.setPageMode('/UseOutlines')
      with open(out_path, 'wb') as f:
          merger.write(f)
      # Now we can close our files
      for f in files:
          f.close()
code_tokens: def merge_pdfs ( path , out_path = None , use_outlines = False ) : print ( '\nCombining pages' ) files = [ ] if out_path is None : out_path = os . path . join ( path , 'combined.pdf' ) filenames = get_files_of_type ( path , '.pdf' ) merger = PyPDF2 . PdfFileMerger ( ) bar = progressbar . ProgressBar ( max_value = len ( filenames ) , redirect_stdout = True ) for i , fn in enumerate ( filenames ) : bk_txt = fn . split ( '.' ) [ 0 ] curr_path = os . path . join ( path , fn ) f = open ( curr_path , 'rb' ) files . append ( f ) merger . append ( f , bookmark = bk_txt , import_bookmarks = False ) bar . update ( i + 1 ) if use_outlines : merger . setPageMode ( '/UseOutlines' ) with open ( out_path , 'wb' ) as f : merger . write ( f ) for f in files : f . close ( )
short_docstring: Combines all PDF's found at `path` into a single document.
short_docstring_tokens: Combines all PDF ' s found at ` path ` into a single document .
comment: """
      Combines all PDF's found at `path` into a single document.
  
      To set output filename and/or location use `out_path`
      """$SEP$# Purposefully NOT using `with`, see http://stackoverflow.com/q/6773631$SEP$# Can't close input files until output file is saved.$SEP$# Instead, move to list to close later$SEP$# Now we can close our files