MCPcopy Create free account
hub / github.com/sqlmapproject/sqlmap / add_path

Method add_path

thirdparty/bottle/bottle.py:3062–3091  ·  view source on GitHub ↗

Add a new path to the list of search paths. Return False if the path does not exist. :param path: The new search path. Relative paths are turned into an absolute and normalized form. If the path looks like a file (not ending in `/`), the file

(self, path, base=None, index=None, create=False)

Source from the content-addressed store, hash-verified

3060 self.cache = {}
3061
3062 def add_path(self, path, base=None, index=None, create=False):
3063 """ Add a new path to the list of search paths. Return False if the
3064 path does not exist.
3065
3066 :param path: The new search path. Relative paths are turned into
3067 an absolute and normalized form. If the path looks like a file
3068 (not ending in `/`), the filename is stripped off.
3069 :param base: Path used to absolutize relative search paths.
3070 Defaults to :attr:`base` which defaults to ``os.getcwd()``.
3071 :param index: Position within the list of search paths. Defaults
3072 to last index (appends to the list).
3073
3074 The `base` parameter makes it easy to reference files installed
3075 along with a python module or package::
3076
3077 res.add_path('./resources/', __file__)
3078 """
3079 base = os.path.abspath(os.path.dirname(base or self.base))
3080 path = os.path.abspath(os.path.join(base, os.path.dirname(path)))
3081 path += os.sep
3082 if path in self.path:
3083 self.path.remove(path)
3084 if create and not os.path.isdir(path):
3085 os.makedirs(path)
3086 if index is None:
3087 self.path.append(path)
3088 else:
3089 self.path.insert(index, path)
3090 self.cache.clear()
3091 return os.path.exists(path)
3092
3093 def __iter__(self):
3094 """ Iterate over all existing files in all registered paths. """

Callers

nothing calls this directly

Calls 4

removeMethod · 0.80
appendMethod · 0.45
insertMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected