Actually handle a new file, and create a sahli file
- just ansi for now
This commit is contained in:
parent
dbfb8db6d4
commit
e51bec4909
2 changed files with 25 additions and 3 deletions
27
editor.py
27
editor.py
|
|
@ -48,7 +48,9 @@ def getansidata(filename):
|
||||||
'group': saucedata.group,
|
'group': saucedata.group,
|
||||||
'title': saucedata.title,
|
'title': saucedata.title,
|
||||||
'filesize': saucedata.filesize,
|
'filesize': saucedata.filesize,
|
||||||
'comments': saucedata.comments
|
'comments': saucedata.comments,
|
||||||
|
'width': None,
|
||||||
|
'height': None
|
||||||
}
|
}
|
||||||
tinfonames = [saucedata.tinfo1_name,
|
tinfonames = [saucedata.tinfo1_name,
|
||||||
saucedata.tinfo2_name,
|
saucedata.tinfo2_name,
|
||||||
|
|
@ -87,6 +89,7 @@ def main(args):
|
||||||
dirfile = '{}/{}'.format(args.directory, i)
|
dirfile = '{}/{}'.format(args.directory, i)
|
||||||
if i in filedatanames:
|
if i in filedatanames:
|
||||||
print('found! {}'.format(i))
|
print('found! {}'.format(i))
|
||||||
|
# todo: _if_ I ever make this a non-preparser, then... futz with
|
||||||
a = getansidata(dirfile)
|
a = getansidata(dirfile)
|
||||||
newdata.append(getdata(filedata, i))
|
newdata.append(getdata(filedata, i))
|
||||||
else:
|
else:
|
||||||
|
|
@ -95,21 +98,39 @@ def main(args):
|
||||||
if suf in ['png', 'jpg', 'jpeg', 'gif',
|
if suf in ['png', 'jpg', 'jpeg', 'gif',
|
||||||
'PNG', 'JPG', 'JPEG', 'GIF']:
|
'PNG', 'JPG', 'JPEG', 'GIF']:
|
||||||
stuff = getpicdata(dirfile)
|
stuff = getpicdata(dirfile)
|
||||||
|
a = 5
|
||||||
elif suf in ['ans', 'ANS', 'BIN', 'bin', 'XB', 'xb']:
|
elif suf in ['ans', 'ANS', 'BIN', 'bin', 'XB', 'xb']:
|
||||||
stuff = getansidata(dirfile)
|
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',
|
elif suf in ['TXT', 'ASC', 'txt', 'asc',
|
||||||
'NFO', 'nfo', 'diz', 'DIZ']:
|
'NFO', 'nfo', 'diz', 'DIZ']:
|
||||||
stuff = getamigadata(dirfile)
|
stuff = getamigadata(dirfile)
|
||||||
else:
|
else:
|
||||||
print("dunno what type of file this is...")
|
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__':
|
if __name__ == '__main__':
|
||||||
ap = argparse.ArgumentParser()
|
ap = argparse.ArgumentParser()
|
||||||
ap.add_argument('-f', '--filename', default='list.sahli')
|
ap.add_argument('-f', '--filename', default='list.sahli')
|
||||||
ap.add_argument('-n', '--new', action='store_true')
|
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,
|
ap.add_argument('-d', '--directory', type=str, required=True,
|
||||||
help='directory where compo files are')
|
help='directory where compo files are')
|
||||||
main(ap.parse_args())
|
main(ap.parse_args())
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ class sahlifile:
|
||||||
'template': '',
|
'template': '',
|
||||||
'css': ''
|
'css': ''
|
||||||
}
|
}
|
||||||
|
return slides
|
||||||
|
|
||||||
def blank_location(self):
|
def blank_location(self):
|
||||||
"""blank location structure"""
|
"""blank location structure"""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue