docs: def addinputfile(project, filename, credentials=None): #pylint: disable=too-many-return-statements
          """Add a new input file, this invokes the actual uploader"""
  
          printdebug('Addinputfile: Initialising' )
  
          user, oauth_access_token = parsecredentials(credentials) #pylint: disable=unused-variable
          response = Project.create(project, user)
          if response is not None:
              return response
          postdata = flask.request.values
  
          if filename == '': #pylint: disable=too-many-nested-blocks
              #Handle inputsource
              printdebug('Addinputfile: checking for input source' )
              if 'inputsource' in postdata and postdata['inputsource']:
                  inputsource = None
                  inputtemplate = None
                  for profile in settings.PROFILES:
                      for t in profile.input:
                          for s in t.inputsources:
                              if s.id == postdata['inputsource']:
                                  inputsource = s
                                  inputsource.inputtemplate = t.id
                                  inputtemplate = t
                                  break
                  if not inputsource:
                      for s in settings.INPUTSOURCES:
                          if s.id == postdata['inputsource']:
                              inputsource = s
                  if not inputsource:
                      return withheaders(flask.make_response("No such inputsource exists",403),headers={'allow_origin': settings.ALLOW_ORIGIN})
                  if not inputtemplate:
                      for profile in settings.PROFILES:
                          for t in profile.input:
                              if inputsource.inputtemplate == t.id:
                                  inputtemplate = t
                  if inputtemplate is None:
                      return withheaders(flask.make_response("No input template found for inputsource",500),headers={'allow_origin': settings.ALLOW_ORIGIN})
                  if inputsource.isfile():
                      if inputtemplate.filename:
                          filename = inputtemplate.filename
                      else:
                          filename = os.path.basename(inputsource.path)
                      xml = addfile(project, filename, user, {'inputsource': postdata['inputsource'], 'inputtemplate': inputtemplate.id}, inputsource)
                      return xml
                  elif inputsource.isdir():
                      if inputtemplate.filename:
                          filename = inputtemplate.filename
                      for f in glob.glob(inputsource.path + "/*"):
                          if not inputtemplate.filename:
                              filename = os.path.basename(f)
                          if f[0] != '.':
                              tmpinputsource = clam.common.data.InputSource(id='tmp',label='tmp',path=f, metadata=inputsource.metadata)
                              addfile(project, filename, user, {'inputsource':'tmp', 'inputtemplate': inputtemplate.id}, tmpinputsource)
                              #WARNING: Output is dropped silently here!
                      return "" #200
                  else:
                      assert False
              else:
                  return withheaders(flask.make_response("No filename or inputsource specified",403),headers={'allow_origin': settings.ALLOW_ORIGIN})
          else:
              #Simply forward to addfile
              return addfile(project,filename,user, postdata)