Actually handle a new file, and create a sahli file

- just ansi for now
This commit is contained in:
Howland Owl 2020-04-10 02:10:56 +03:00
parent dbfb8db6d4
commit e51bec4909
2 changed files with 25 additions and 3 deletions

View file

@ -48,7 +48,9 @@ def getansidata(filename):
'group': saucedata.group,
'title': saucedata.title,
'filesize': saucedata.filesize,
'comments': saucedata.comments
'comments': saucedata.comments,
'width': None,
'height': None
}
tinfonames = [saucedata.tinfo1_name,
saucedata.tinfo2_name,
@ -87,6 +89,7 @@ def main(args):
dirfile = '{}/{}'.format(args.directory, i)
if i in filedatanames:
print('found! {}'.format(i))
# todo: _if_ I ever make this a non-preparser, then... futz with
a = getansidata(dirfile)
newdata.append(getdata(filedata, i))
else:
@ -95,21 +98,39 @@ def main(args):
if suf in ['png', 'jpg', 'jpeg', 'gif',
'PNG', 'JPG', 'JPEG', 'GIF']:
stuff = getpicdata(dirfile)
a = 5
elif suf in ['ans', 'ANS', 'BIN', 'bin', 'XB', 'xb']:
stuff = getansidata(dirfile)
a = 5
entry = mysahli.blank_ansi()
entry['file'] = i
entry['name'] = stuff['title']
entry['author'] = '{}/{}'.format(
stuff['author'], stuff['group'])
entry['text'] = stuff['comments']
if stuff['height'] is not None:
entry['height'] = stuff['height']
if stuff['width'] is not None:
entry['width'] = stuff['width']
newdata.append(entry)
elif suf in ['TXT', 'ASC', 'txt', 'asc',
'NFO', 'nfo', 'diz', 'DIZ']:
stuff = getamigadata(dirfile)
else:
print("dunno what type of file this is...")
a = 5
mysahli.sahli['filedata'] = newdata
out = json.dumps(mysahli.sahli, sort_keys=False, indent=4)
if args.outfile == '>stdout':
print(out)
else:
with open(args.outfile, 'w') as f:
json.dump(mysahli.sahli, f, sort_keys=False, indent=4)
if __name__ == '__main__':
ap = argparse.ArgumentParser()
ap.add_argument('-f', '--filename', default='list.sahli')
ap.add_argument('-n', '--new', action='store_true')
ap.add_argument('-o', '--outfile', type=str, default='>stdout')
ap.add_argument('-d', '--directory', type=str, required=True,
help='directory where compo files are')
main(ap.parse_args())