def get_credentials_for(self, identifier, check_valid=True):
        file_creds = {}
        try:
            with open(self.filename) as fp:
              file_creds = json.load(fp,object_hook=helpers.convert)
        except IOError as ioe:
            raise NameError("Credential file not found. " + str(ioe))

        user_creds = file_creds.get(identifier)
        if user_creds is None:
            raise NameError(identifier)
            return

        #XXX: Why bother type checking here if we're specifying that in the function
        #XXX: call in providence.py? 
        type = user_creds.get("type")
        credentials = self.credential_object_for_type(identifier, type)
        credentials.credential_manager = self
        credentials.encrypt = self.encrypt
        credentials.decrypt = self.decrypt
        credentials.read(user_creds)

        if check_valid == True and credentials.valid() == False:
            if isinstance(creds, OAuthCredentials):
                try:
                    credentials.refreshToken()
                    if credentials.valid():
                        if write == True:
                            credentials.write()
                        return credentials
                except NotImplementedError, nie:
                    pass
            raise CredentialsInvalidError(identifier % "Invalid Credentials for %s")
        return credentials
dataset/ETHPy150Open SalesforceEng/Providence/Empire/creds/__init__.py/CredentialManager.get_credentials_for/swapped operands of `%`