Created
November 29, 2018 21:56
-
-
Save thrasibule/d6f013fa344cf4c8074bbfbfda1134a0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, 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