MCPcopy Create free account
hub / github.com/MemTensor/MemOS / download_examples

Function download_examples

src/memos/cli.py:37–74  ·  view source on GitHub ↗
(dest: str)

Source from the content-addressed store, hash-verified

35
36
37def download_examples(dest: str) -> bool:
38 import requests
39
40 """Download examples from the MemOS repository."""
41 zip_url = "https://github.com/MemTensor/MemOS/archive/refs/heads/main.zip"
42 print(f"📥 Downloading examples from {zip_url}...")
43
44 try:
45 response = requests.get(zip_url)
46 response.raise_for_status()
47
48 with zipfile.ZipFile(BytesIO(response.content)) as z:
49 extracted_files = []
50 for file in z.namelist():
51 if "MemOS-main/examples/" in file and not file.endswith("/"):
52 # Remove the prefix and extract to dest
53 relative_path = file.replace("MemOS-main/examples/", "")
54 extract_path = os.path.join(dest, relative_path)
55
56 # Create directory if it doesn't exist
57 os.makedirs(os.path.dirname(extract_path), exist_ok=True)
58
59 # Extract the file
60 with z.open(file) as source, open(extract_path, "wb") as target:
61 target.write(source.read())
62 extracted_files.append(extract_path)
63
64 print(f"✅ Examples downloaded to: {dest}")
65 print(f"📁 {len(extracted_files)} files extracted")
66
67 except requests.RequestException as e:
68 print(f"❌ Error downloading examples: {e}")
69 return False
70 except Exception as e:
71 print(f"❌ Error extracting examples: {e}")
72 return False
73
74 return True
75
76
77def main():

Callers 3

mainFunction · 0.85

Calls 4

getMethod · 0.65
writeMethod · 0.65
openFunction · 0.50
joinMethod · 0.45

Tested by 2