MCPcopy
hub / github.com/brightio/penelope / add

Method add

penelope.py:5246–5268  ·  view source on GitHub ↗
(self, item)

Source from the content-addressed store, hash-verified

5244 self.add(item)
5245
5246 def add(self, item):
5247 if item == '/':
5248 self.filemap[f'/{self.url_prefix}[root]'] = '/'
5249 return '/[root]'
5250
5251 item = os.path.abspath(normalize_path(item))
5252
5253 if not os.path.exists(item):
5254 if not self.quiet:
5255 logger.warning(f"'{item}' does not exist and will be ignored.")
5256 return None
5257
5258 if item in self.filemap.values():
5259 for _urlpath, _item in self.filemap.items():
5260 if _item == item:
5261 return _urlpath
5262
5263 urlpath = f"/{self.url_prefix}{os.path.basename(item)}"
5264 while urlpath in self.filemap:
5265 root, ext = os.path.splitext(urlpath)
5266 urlpath = root + '_' + ext
5267 self.filemap[urlpath] = item
5268 return urlpath
5269
5270 def remove(self, item):
5271 item = os.path.abspath(normalize_path(item))

Callers 5

downloadMethod · 0.95
uploadMethod · 0.95
__init__Method · 0.95
ipsMethod · 0.80
list_allMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected