original_docstring: 
          Write final shp, shx, and dbf headers, close opened files.
          
docstring: Write final shp, shx, and dbf headers, close opened files.
docstring_tokens: Write final shp shx and dbf headers close opened files .
code: def close(self):
          """
          Write final shp, shx, and dbf headers, close opened files.
          """
          # Check if any of the files have already been closed
          shp_open = self.shp and not (hasattr(self.shp, 'closed') and self.shp.closed)
          shx_open = self.shx and not (hasattr(self.shx, 'closed') and self.shx.closed)
          dbf_open = self.dbf and not (hasattr(self.dbf, 'closed') and self.dbf.closed)
              
          # Balance if already not balanced
          if self.shp and shp_open and self.dbf and dbf_open:
              if self.autoBalance:
                  self.balance()
              if self.recNum != self.shpNum:
                  raise ShapefileException("When saving both the dbf and shp file, "
                                           "the number of records (%s) must correspond "
                                           "with the number of shapes (%s)" % (self.recNum, self.shpNum))
          # Fill in the blank headers
          if self.shp and shp_open:
              self.__shapefileHeader(self.shp, headerType='shp')
          if self.shx and shx_open:
              self.__shapefileHeader(self.shx, headerType='shx')
  
          # Update the dbf header with final length etc
          if self.dbf and dbf_open:
              self.__dbfHeader()
  
          # Close files, if target is a filepath
          if self.target:
              for attribute in (self.shp, self.shx, self.dbf):
                  if hasattr(attribute, 'close'):
                      try:
                          attribute.close()
                      except IOError:
                          pass
code_tokens: def close ( self ) : shp_open = self . shp and not ( hasattr ( self . shp , 'closed' ) and self . shp . closed ) shx_open = self . shx and not ( hasattr ( self . shx , 'closed' ) and self . shx . closed ) dbf_open = self . dbf and not ( hasattr ( self . dbf , 'closed' ) and self . dbf . closed ) if self . shp and shp_open and self . dbf and dbf_open : if self . autoBalance : self . balance ( ) if self . recNum != self . shpNum : raise ShapefileException ( "When saving both the dbf and shp file, " "the number of records (%s) must correspond " "with the number of shapes (%s)" % ( self . recNum , self . shpNum ) ) if self . shp and shp_open : self . __shapefileHeader ( self . shp , headerType = 'shp' ) if self . shx and shx_open : self . __shapefileHeader ( self . shx , headerType = 'shx' ) if self . dbf and dbf_open : self . __dbfHeader ( ) if self . target : for attribute in ( self . shp , self . shx , self . dbf ) : if hasattr ( attribute , 'close' ) : try : attribute . close ( ) except IOError : pass
short_docstring: Write final shp, shx, and dbf headers, close opened files.
short_docstring_tokens: Write final shp shx and dbf headers close opened files .
comment: """
          Write final shp, shx, and dbf headers, close opened files.
          """$SEP$# Check if any of the files have already been closed
  $SEP$# Balance if already not balanced
  $SEP$# Fill in the blank headers
  $SEP$# Update the dbf header with final length etc
  $SEP$# Close files, if target is a filepath
  