MCPcopy Create free account
hub / github.com/SourceCode-AI/aura / strip

Method strip

aura/uri_handlers/base.py:299–329  ·  view source on GitHub ↗

Strip/normalize given path Left side part of the target is replaced with the configured strip path This is to prevent temporary locations to appear in a part and are instead replaced with a normalize path E.g.: `/var/tmp/some_extracted_archive.zip/setup.py`

(self, target: Union[str, Path], include_parent: bool=True)

Source from the content-addressed store, hash-verified

297 return child
298
299 def strip(self, target: Union[str, Path], include_parent: bool=True) -> str:
300 """
301 Strip/normalize given path
302 Left side part of the target is replaced with the configured strip path
303 This is to prevent temporary locations to appear in a part and are instead replaced with a normalize path
304 E.g.:
305 `/var/tmp/some_extracted_archive.zip/setup.py`
306 would become:
307 `some_extracted_archive.zip$setup.py`
308 which signifies that the setup.py is inside the archive and leaves out the temporary unpack location
309
310 :param target: Path to replace/strip
311 :return: normalized path
312 """
313 if type(target) == str:
314 target = Path(target)
315
316 try:
317 target = target.relative_to(self.strip_path)
318 except ValueError: # strip_path is not a prefix of target
319 pass
320
321 if include_parent and self.parent:
322 p = str(self.parent)
323 line_no = self.metadata.get("parent_line")
324 if line_no is not None:
325 p = f"{p}:{line_no}"
326
327 return f"{p}${str(target)}"
328
329 return str(target)
330
331 def should_continue(self) -> Union[bool, Detection]:
332 """

Callers 15

__str__Method · 0.95
post_analysisMethod · 0.95
is_renamed_fileMethod · 0.95
process_scansFunction · 0.80
test_apipFunction · 0.80
setup.pyFile · 0.80
config.pyFile · 0.80
read_urisFunction · 0.80
scan_help_textFunction · 0.80
lookup_linesFunction · 0.80

Calls 1

getMethod · 0.80

Tested by 3

test_apipFunction · 0.64