Skip to content

Commit

Permalink
Fix in Token selection
Browse files Browse the repository at this point in the history
  • Loading branch information
julesontheroad committed Jan 16, 2020
1 parent a1693ed commit 284c25e
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 10 deletions.
29 changes: 19 additions & 10 deletions py/ztools/Drive/Private.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,14 +439,20 @@ def token_picker():
# print(files)
tokens=list();names=list()
for file in files:
test=file.split(".")
bname=os.path.basename(os.path.abspath(file))
test=bname.split(".")
if len(test)==1 and file not in tokens:
tokens.append(file)
names.append(str(os.path.basename(os.path.abspath(file))))
title = 'Pick an account (press SPACE\RIGHT to mark\\unmark, ENTER to continue): '
options = names
selected = pick(options, title, min_selection_count=1)
tok=names[selected[1]]
if len(names)>1:
title = 'Pick an account (press SPACE\RIGHT to mark\\unmark, ENTER to continue): '
options = names
selected = pick(options, title, min_selection_count=1)
tok=names[selected[1]]
elif len(names)==1:
tok=names[0]
else:
tok=False
return tok

def folder_walker(showfiles=False,Print=False):
Expand Down Expand Up @@ -710,11 +716,14 @@ def download(path,ofolder,TD=None,filter=None,trimm=True):
def TD_picker(path):
remote=location(route=path)
names,ids=get_TeamDrives(remote.token_name)
title = 'Select Teamdrive (press SPACE\RIGHT to mark\\unmark, ENTER to continue): \n"None" will return the My-Drive section of the account'
options = names
selected = pick(options, title, min_selection_count=1)
TD=selected[0]
if TD=='None':
if names:
title = 'Select Teamdrive (press SPACE\RIGHT to mark\\unmark, ENTER to continue): \n"None" will return the My-Drive section of the account'
options = names
selected = pick(options, title, min_selection_count=1)
TD=selected[0]
if TD=='None':
TD=None
else:
TD=None
return TD

Expand Down
68 changes: 68 additions & 0 deletions py/ztools/lib/File_chunk2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import sq_tools

class chunk():
def __init__(self,firstchunk,type='all',locations=None,files=None,fileopen=None):
self.locations=file_locations(firstchunk,type)

def file_locations(filepath,t='all',Printdata=False):
filenames=retchunks(filepath)
# print(filenames)
locations=list()
if filepath.endswith('.xc0'):
files_list=sq_tools.ret_xci_offsets(filepath)
elif filepath.endswith('.ns0'):
files_list=sq_tools.ret_nsp_offsets(filepath)
for file in files_list:
if not t.lower()=='all':
# print(file)
if (str(file[0]).lower()).endswith(t.lower()):
location1,tgoffset1=get_file_and_offset(filenames,file[1])
location2,tgoffset2=get_file_and_offset(filenames,file[2])
locations.append([file[0],file[3],location1,tgoffset1,location2,tgoffset2])
if Printdata==True:
print('{}'.format(file[0]))
print('- Starts in file {} at offset {}'.format(location1[-4:],tgoffset1))
print('- Ends in file {} at offset {}'.format(location2[-4:],tgoffset2))
print('')
else:pass
else:
location1,tgoffset1=get_file_and_offset(filenames,file[1])
location2,tgoffset2=get_file_and_offset(filenames,file[2])
locations.append([file[0],file[3],location1,tgoffset1,location2,tgoffset2])
if Printdata==True:
print('{}'.format(file[0]))
print('- Starts in file {} at offset {}'.format(location1[-4:],tgoffset1))
print('- Ends in file {} at offset {}'.format(location2[-4:],tgoffset2))
print('')
return locations

def get_file_and_offset(filelist,targetoffset):
startoffset=0;endoffset=0
# print(targetoffset)
# print(filelist)
for i in range(len(filelist)):
entry=filelist[i]
filepath=entry[0];size=entry[1]
startoffset=endoffset
endoffset+=size
# print(endoffset)
if targetoffset>endoffset:
pass
else:
partialoffset=targetoffset-startoffset
return filepath,partialoffset
return False,False

def read_start(filepath):
filenames=retchunks(filepath)
f = chain_streams(generate_open_file_streams(filenames))
if filepath.endswith('.xc0'):
files_list=sq_tools.ret_xci_offsets(filepath)
elif filepath.endswith('.ns0'):
files_list=sq_tools.ret_nsp_offsets(filepath)
print(files_list)

# feed=f.read(0x500)
# Hex.dump(feed)
f.flush()
f.close()
6 changes: 6 additions & 0 deletions py/ztools/lib/Recommendations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import rawgpy

def get_suggestions(game=None,titleid=None,slug=None,number=10,platform="Switch"):
game=str(game).lower()
number=int(number)

0 comments on commit 284c25e

Please sign in to comment.