<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _updateToAdded(self,directory,fn,dentry,db,service):
 """Changes to status to 'A' as long as a handler exists, also generates a hash directory - DIR where stuff is happening fn - File name to be added dentry - dictionary entry as returned by GetStatus for this file db - pusher DB for this directory service - None means all services, otherwise looks for service """

        services=self.sman.GetServices(fn)

        # If nobody manages this file, just skip it
        if services is None:
            print("%s - No services handle this file" %(fn))
            return

        # Build up list of names
        servicenames=[]
        for s in services:
            servicenames.append(s.GetName())

        if service is not None and service not in servicenames:
            print("%s - Requested service (%s) not available for this file"\
                    %(fn,service))
            return

        # If service is none, build list of all services
        # to perform this action on
        if service is None:
            servicelist=servicenames
        else:
            servicelist=[service]

        if not db.has_key(fn):
            # Since this is a new entry, populate with stuff
            # we got from GetSatus for this file (usually mtime)
            db[fn]=dentry
            del db[fn]['status'] # Delete this key we're not using
            db[fn]['services']={} # Empty dictionary of services
                                  # that manages this file + status

        # Now add the hash
        db[fn]['hash']=self._hashfile(os.path.join(directory,fn))

        # Now run through services and see if we should
        # perform actions
        for service in servicelist:
            if not db[fn]['services'].has_key(service):
                db[fn]['services'][service]={}
                db[fn]['services'][service]['status']=self.ST_ADDED
            else:
                print("%s - Already managed by service %s, maybe do a 'push'?"\
                        %(fn,service))

        logger.info('%s - managers: %s'%(fn,db[fn]['services'].keys()))

        return