original_docstring: Check Application config for incorrect static paths.
docstring: Check Application config for incorrect static paths.
docstring_tokens: Check Application config for incorrect static paths .
code: def check_static_paths(self):
          """Check Application config for incorrect static paths."""
          # Use the dummy Request object in the main thread.
          request = cherrypy.request
          for sn, app in cherrypy.tree.apps.items():
              if not isinstance(app, cherrypy.Application):
                  continue
              request.app = app
              for section in app.config:
                  # get_resource will populate request.config
                  request.get_resource(section + "/dummy.html")
                  conf = request.config.get
                  
                  if conf("tools.staticdir.on", False):
                      msg = ""
                      root = conf("tools.staticdir.root")
                      dir = conf("tools.staticdir.dir")
                      if dir is None:
                          msg = "tools.staticdir.dir is not set."
                      else:
                          fulldir = ""
                          if os.path.isabs(dir):
                              fulldir = dir
                              if root:
                                  msg = ("dir is an absolute path, even "
                                         "though a root is provided.")
                                  testdir = os.path.join(root, dir[1:])
                                  if os.path.exists(testdir):
                                      msg += ("\nIf you meant to serve the "
                                              "filesystem folder at %r, remove "
                                              "the leading slash from dir." % testdir)
                          else:
                              if not root:
                                  msg = "dir is a relative path and no root provided."
                              else:
                                  fulldir = os.path.join(root, dir)
                                  if not os.path.isabs(fulldir):
                                      msg = "%r is not an absolute path." % fulldir
                          
                          if fulldir and not os.path.exists(fulldir):
                              if msg:
                                  msg += "\n"
                              msg += ("%r (root + dir) is not an existing "
                                      "filesystem path." % fulldir)
                      
                      if msg:
                          warnings.warn("%s\nsection: [%s]\nroot: %r\ndir: %r"
                                        % (msg, section, root, dir))
code_tokens: def check_static_paths ( self ) : request = cherrypy . request for sn , app in cherrypy . tree . apps . items ( ) : if not isinstance ( app , cherrypy . Application ) : continue request . app = app for section in app . config : request . get_resource ( section + "/dummy.html" ) conf = request . config . get if conf ( "tools.staticdir.on" , False ) : msg = "" root = conf ( "tools.staticdir.root" ) dir = conf ( "tools.staticdir.dir" ) if dir is None : msg = "tools.staticdir.dir is not set." else : fulldir = "" if os . path . isabs ( dir ) : fulldir = dir if root : msg = ( "dir is an absolute path, even " "though a root is provided." ) testdir = os . path . join ( root , dir [ 1 : ] ) if os . path . exists ( testdir ) : msg += ( "\nIf you meant to serve the " "filesystem folder at %r, remove " "the leading slash from dir." % testdir ) else : if not root : msg = "dir is a relative path and no root provided." else : fulldir = os . path . join ( root , dir ) if not os . path . isabs ( fulldir ) : msg = "%r is not an absolute path." % fulldir if fulldir and not os . path . exists ( fulldir ) : if msg : msg += "\n" msg += ( "%r (root + dir) is not an existing " "filesystem path." % fulldir ) if msg : warnings . warn ( "%s\nsection: [%s]\nroot: %r\ndir: %r" % ( msg , section , root , dir ) )
short_docstring: Check Application config for incorrect static paths.
short_docstring_tokens: Check Application config for incorrect static paths .
comment: """Check Application config for incorrect static paths."""$SEP$# Use the dummy Request object in the main thread.$SEP$# get_resource will populate request.config