Guest User

build_sort_TJEIII.py

a guest
Dec 27th, 2013
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.60 KB | None | 0 0
  1. #!/usr/bin/env python
  2. """
  3. Creates a sorttxt.txt from a gaming session GD-M log (stripped of crap) and a
  4. list of all the files for the game.
  5.  
  6. The last file on disc will be the first one loaded (the bootbin typically) and
  7. the others will follow toward the inner radius.
  8.  
  9. Files that were not loaded in the gaming session will be sorted alphabetically
  10. as it seems the devs named their stuff logically by level; it should thus be
  11. good to have likely-named files next ot each others to reduce seek times.
  12.  
  13. allfiles.txt was build doing
  14.    mv data/NOTICE.TXT .
  15.    cd data/
  16.    find . > ../allfiles.txt
  17.    cd ..
  18.    sed -i -e "1d" allfiles.txt
  19.    sed -i 's/\.\//\//g' allfiles.txt
  20.    mv NOTICE.TXT data/
  21.  
  22.  
  23. Files NOTICE.TXT and 0.0 will be added and put last ones.
  24. NOTICE.TXT is used as a legal warning & sorting would be useless without 0.0 !
  25.  
  26. For the Dreamcast Beta build of Toe Jam & Earl III
  27.  
  28. FamilyGuy 2013
  29. """
  30.  
  31. a=loadtxt('session.LOG',usecols=[-1],dtype=str).T
  32. b=''
  33. c=[]
  34. j=1
  35. for i in range(len(a)):
  36.     if b.find(a[i])==-1:
  37.         b=b+a[i]+' '+str(j)+'\n'
  38.         c.append(a[i].replace('\\','/'))
  39.         j=j+1
  40. b=b.replace('\\','/')
  41.  
  42. d=loadtxt('allfiles.txt',dtype=str).T
  43. d=sorted(d)
  44.  
  45. for i in range(len(d)):
  46.     if d[i] not in c:
  47.         b=b+d[i]+' '+str(j)+'\n'
  48.         c.append(d[i].replace('\\','/'))
  49.         j=j+1
  50.  
  51. for i in ['/0.0','/NOTICE.TXT']:
  52.     b=b+i+' '+str(j)+'\n'
  53.     c.append(i)
  54.     j=j+1
  55.  
  56. e=''
  57. for i in range(len(c)):
  58.     e=e+'data'+c[i]+' '+str(i+1)+'\n'   # Dirty but I forgot the 'data' prefix...
  59.  
  60.  
  61. f=open('sorttxt.txt','wb')
  62. f.write(e)
  63. f.close()
Advertisement
Add Comment
Please, Sign In to add comment