Skip to content

Instantly share code, notes, and snippets.

@thrasibule
Created November 29, 2018 21:56
Show Gist options
  • Save thrasibule/849ed1d78b3f11ae994c268de4059846 to your computer and use it in GitHub Desktop.
Save thrasibule/849ed1d78b3f11ae994c268de4059846 to your computer and use it in GitHub Desktop.
from pathlib import Path
import shutil
p = Path("lost+found")
for f in p.iterdir():
if f.is_dir():
package = f / "desc"
if package.exists():
with package.open("rt") as fh:
for line in fh:
line = line.rstrip()
if line == '%NAME%':
package_name = fh.readline().rstrip()
if line == '%VERSION%':
package_version = fh.readline().rstrip()
break
else:
print(f"something wrong with {package.name}")
break
shutil.copytree(f, "/home/enguerrand/recovery/{package_name}-{package_version}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment