Advertisement
KirillMysnik

checknav

Dec 20th, 2021 (edited)
644
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.94 KB | None | 0 0
  1. from pathlib import Path
  2. import zipfile
  3.  
  4.  
  5. #MAPS_PATH = Path(r"E:\SteamLibrary\steamapps\common\Counter-Strike Source\cstrike\maps")
  6. MAPS_PATH = Path(r"/home/user/server/cstrike/maps")
  7.  
  8.  
  9. def main():
  10.     results = []
  11.    
  12.     for p in MAPS_PATH.glob('*.bsp'):
  13.         if p.with_suffix('.nav').is_file():
  14.             print(f"{p.stem}: nav-file exists (filesystem)")
  15.             continue
  16.  
  17.         z = zipfile.ZipFile(p)
  18.         try:
  19.             info = z.getinfo(f'maps/{p.stem}.nav')
  20.         except KeyError:
  21.             pass
  22.         else:
  23.             print(f"{p.stem}: nav-file exists (shipped with bsp)")
  24.             continue
  25.  
  26.         print(f"{p.stem}: nav-file NOT FOUND!")
  27.         results.append(p)
  28.  
  29.     if results:
  30.         print("\n***MAPS WITHOUT NAV-FILES***")
  31.         for p in results:
  32.             print(p.name)
  33.     else:
  34.         print("\nAll maps have corresponding nav-files.")
  35.  
  36.  
  37. if __name__ == "__main__":
  38.     main()
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement