Path.write_bytes
Path.write_bytes(...)Description
Documentation for Path.write_bytes.
Real-World Examples
Practical code examples showing how Path.write_bytes is used in real projects.
response = requests.get(raw_url, timeout=30)
if response.status_code == 200:
filename = f"{repo['name']}_{Path(pdf_path).name}"
dest = direct_dir / filename
dest.write_bytes(response.content)
logger.info(f" ✓ Downloaded: {filename} ({len(response.content) / 1024:.1f} KB)")
self.pdfs_extracted += 1
else:
logger.warning(f" ✗ Failed to download {pdf_path} (HTTP {response.status_code})")
except Exception as e:
logger.warning(f" ✗ Error downloading {pdf_path}: {e}")
continue
time.sleep(1)
def run(self, max_repos: int = 50, include_direct: bool = True):
"""Run complete download pipeline"""
start_time = time.time()
logger.info(f"\n{'='*80}")
logger.info("RESUME DATASET BULK DOWNLOADER")
logger.info(f"{'='*80}\n")
temp_path = Path(temp_dir)
# Save uploaded files
for uploaded_file in uploaded_files:
file_path = temp_path / uploaded_file.name
file_path.write_bytes(uploaded_file.getvalue())
# Scan temp directory
findings = scan_path(str(temp_path))
st.session_state.scan_results = findings
st.rerun()
with tab2:
st.header("Scan GitHub Repositories")
# GitHub authentication (required)
with st.expander("🔐 GitHub Authentication (Required)", expanded=True):
st.markdown("""
**Required:** Authenticate with your GitHub Personal Access Token to scan public repositories.
**How to create a PAT:**
1. Go to [GitHub Settings > Tokens](https://github.com/settings/tokens)
2. Click "Generate new token (classic)"
3. Give it a name (e.g., "Secret Scanner")
4. Select scope: **`public_repo`** (read-only access to public repositories)