parameters: (self, search_key, context, dir, snapshot_type="directory", description="No description", file_type='main', is_current=True, level_key=None, metadata={}, mode="copy", is_revision=False)
return_statement: return snapshot
docstring: API Function: directory_checkin(search_key, context, dir, snapshot_type="directory", description="No description", file_type='main', is_current=True, level_key=None, metadata={}, mode="copy", is_revision=False)
  
          Check in a directory of files.  This informs TACTIC to treat the 
          entire directory as single entity without regard to the structure
          of the contents.  TACTIC will not know about the individual files
          and the directory hierarchy within the base directory and it it left
          up to the and external program to intepret and understand this.
  
          This is often used when logic on the exact file structure exists in
          some external source outside of TACTIC and it is deemed too complicated
          to map this into TACTIC's snapshot definition.
  
          @param:
          search_key - a unique identifier key representing an sobject
          dir - the directory that needs to be checked in
  
          @keyparam:
          snapshot_type - type of snapshot this checkin will have
          description - description related to this checkin
          file_type - the type of file that will be associated with this group
          is_current - makes this snapshot current
          level_key - the search key of the level if used
          metadata - add metadata to snapshot
          mode - determines whether the files passed in should be copied, moved
              or uploaded.  By default, this is 'copy'
          is_revision - flag to set this as a revision instead of a version
  
          @return:
          dictionary - snapshot
docstring_summary: API Function: directory_checkin(search_key, context, dir, snapshot_type="directory", description="No description", file_type='main', is_current=True, level_key=None, metadata={}, mode="copy", is_revision=False)
docstring_tokens: API Function : directory_checkin ( search_key context dir snapshot_type = directory description = No description file_type = main is_current = True level_key = None metadata = {} mode = copy is_revision = False )
function: def directory_checkin(self, search_key, context, dir, snapshot_type="directory", description="No description", file_type='main', is_current=True, level_key=None, metadata={}, mode="copy", is_revision=False):
          '''API Function: directory_checkin(search_key, context, dir, snapshot_type="directory", description="No description", file_type='main', is_current=True, level_key=None, metadata={}, mode="copy", is_revision=False)
  
          Check in a directory of files.  This informs TACTIC to treat the 
          entire directory as single entity without regard to the structure
          of the contents.  TACTIC will not know about the individual files
          and the directory hierarchy within the base directory and it it left
          up to the and external program to intepret and understand this.
  
          This is often used when logic on the exact file structure exists in
          some external source outside of TACTIC and it is deemed too complicated
          to map this into TACTIC's snapshot definition.
  
          @param:
          search_key - a unique identifier key representing an sobject
          dir - the directory that needs to be checked in
  
          @keyparam:
          snapshot_type - type of snapshot this checkin will have
          description - description related to this checkin
          file_type - the type of file that will be associated with this group
          is_current - makes this snapshot current
          level_key - the search key of the level if used
          metadata - add metadata to snapshot
          mode - determines whether the files passed in should be copied, moved
              or uploaded.  By default, this is 'copy'
          is_revision - flag to set this as a revision instead of a version
  
          @return:
          dictionary - snapshot 
          '''
          if mode not in ['copy', 'move', 'inplace', 'local']:
              raise TacticApiException('mode must be either [move] or [copy]')
  
          handoff_dir = self.get_handoff_dir()
          # make sure that handoff dir is empty
          try:
              shutil.rmtree(handoff_dir)
              os.makedirs(handoff_dir)
              os.chmod(handoff_dir, 0777)
          except OSError as e:
              sys.stderr.write("WARNING: could not cleanup handoff directory [%s]: %s" % (handoff_dir, e.__str__()))
  
          # strip the trailing / or \ if any
          m = re.match(r'(.*)([/|\\]$)', dir)
          if m:
              dir = m.groups()[0]
          
          # copy or move the tree to the handoff directory
          basename = os.path.basename(dir)
  
          if mode == 'move':
              shutil.move(dir, "%s/%s" % (handoff_dir, basename))
          elif mode == 'copy':
              shutil.copytree(dir, "%s/%s" % (handoff_dir, basename))
  
          use_handoff_dir = True
          snapshot = self.server.simple_checkin(self.ticket, search_key, context,
              dir, snapshot_type, description, use_handoff_dir, file_type,
              is_current, level_key, metadata, mode, is_revision)
  
          if mode == 'local':
              # get the naming conventions and move the file to the local repo
              files = self.server.eval(self.ticket, "@SOBJECT(sthpw/file)", snapshot)
  
              # FIXME: this only works on the python implementation
              files = eval(files)
              for file in files:
                  rel_path = "%s/%s" %( file.get('relative_dir'), file.get('file_name'))
                  base_dirs = self.server.get_base_dirs(self.ticket)
                  if os.name == 'nt':
                      client_repo_dir = base_dirs.get("win32_local_base_dir")
                  else:
                      client_repo_dir = base_dirs.get("linux_local_base_dir")
  
                  repo_path = "%s/%s" % (client_repo_dir, rel_path)
                  repo_dir = os.path.dirname(repo_path)
                  if not os.path.exists(repo_dir):
                      os.makedirs(repo_dir)
                  shutil.copytree(dir,repo_path)
  
          return snapshot
function_tokens: def directory_checkin ( self , search_key , context , dir , snapshot_type = "directory" , description = "No description" , file_type = 'main' , is_current = True , level_key = None , metadata = { } , mode = "copy" , is_revision = False ) : if mode not in [ 'copy' , 'move' , 'inplace' , 'local' ] : raise TacticApiException ( 'mode must be either [move] or [copy]' ) handoff_dir = self . get_handoff_dir ( ) # make sure that handoff dir is empty try : shutil . rmtree ( handoff_dir ) os . makedirs ( handoff_dir ) os . chmod ( handoff_dir , 0777 ) except OSError as e : sys . stderr . write ( "WARNING: could not cleanup handoff directory [%s]: %s" % ( handoff_dir , e . __str__ ( ) ) ) # strip the trailing / or \ if any m = re . match ( r'(.*)([/|\\]$)' , dir ) if m : dir = m . groups ( ) [ 0 ] # copy or move the tree to the handoff directory basename = os . path . basename ( dir ) if mode == 'move' : shutil . move ( dir , "%s/%s" % ( handoff_dir , basename ) ) elif mode == 'copy' : shutil . copytree ( dir , "%s/%s" % ( handoff_dir , basename ) ) use_handoff_dir = True snapshot = self . server . simple_checkin ( self . ticket , search_key , context , dir , snapshot_type , description , use_handoff_dir , file_type , is_current , level_key , metadata , mode , is_revision ) if mode == 'local' : # get the naming conventions and move the file to the local repo files = self . server . eval ( self . ticket , "@SOBJECT(sthpw/file)" , snapshot ) # FIXME: this only works on the python implementation files = eval ( files ) for file in files : rel_path = "%s/%s" % ( file . get ( 'relative_dir' ) , file . get ( 'file_name' ) ) base_dirs = self . server . get_base_dirs ( self . ticket ) if os . name == 'nt' : client_repo_dir = base_dirs . get ( "win32_local_base_dir" ) else : client_repo_dir = base_dirs . get ( "linux_local_base_dir" ) repo_path = "%s/%s" % ( client_repo_dir , rel_path ) repo_dir = os . path . dirname ( repo_path ) if not os . path . exists ( repo_dir ) : os . makedirs ( repo_dir ) shutil . copytree ( dir , repo_path ) return snapshot