MCPcopy Create free account
hub / github.com/pymupdf/PyMuPDF / add_file

Method add_file

pipcl.py:1100–1111  ·  view source on GitHub ↗
(from_, to_abs, to_rel)

Source from the content-addressed store, hash-verified

1098 record = _Record()
1099
1100 def add_file(from_, to_abs, to_rel):
1101 os.makedirs( os.path.dirname( to_abs), exist_ok=True)
1102 if isinstance(from_, bytes):
1103 log2(f'Copying content into {to_abs}.')
1104 with open(to_abs, 'wb') as f:
1105 f.write(from_)
1106 record.add_content(from_, to_rel)
1107 else:
1108 log0(f'{from_=}')
1109 log2(f'Copying from {os.path.relpath(from_, self.root)} to {to_abs}')
1110 shutil.copy2( from_, to_abs)
1111 record.add_file(from_, to_rel)
1112
1113 def add_str(content, to_abs, to_rel):
1114 log2( f'Writing to: {to_abs}')

Callers 1

addMethod · 0.45

Calls 4

log2Function · 0.85
log0Function · 0.85
add_contentMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected