I've since been customizing export scripts to suit my needs. Is there a simple way to modify the script to export files directly into a directory without zipping them? I usually test or submit the files for review first, so skipping the zip step would streamline my process. While I see references to zipping in the Python file, it doesn't seem to be a straightforward toggle like some of the other options.
You are correct, this isn't really a part of "Hype" functionality but is something the export scripts themselves do. Thus you'll need to modify the script. Luckily, it only requires two changes.
Change this line:
"file_extension" : "zip",
to:
"file_extension" : "",
Change this line:
zip(args.modify_staging_path, args.destination_path)
to:
shutil.move(args.modify_staging_path, args.destination_path)
From a testing perspective though, if you were not aware, please note that you can preview with the export script from the preview toolbar item's "Preview Using Export Script:" area.
(Of course I get there are reasons you may not want to do this, but perhaps this is enough?)
This is great! I wasn’t familiar with the 'Preview Using Export Script' option, but in most cases, I need to stage the files on a page for client review. Thanks, @jonathan!
Follow-up question for you, @Jonathan... I now have several export script options available in Hype, and it seems pretty likely I could accidentally select the wrong one. All the scripts currently generate a zip file with the same name as my Hype file. How could I customize the Python script so that when I choose, for example, AdWords, the resulting zip file would be named filename_AdWords.zip? That way, I can easily confirm I've used the correct export script.
The only way to do this is to add it as an extra extension (eg filename.AdWords.zip) as this is the only carve out for renaming what is put in save dialogs by macOS.
The code would be two basic parts:
- Split up the filename into its component parts of a name and extension
- Find the export script filename and then insert that into the new name
You'd basically replace the line that looks like:
zip(args.modify_staging_path, args.destination_path)
with this code:
directory, file_name = os.path.split(args.destination_path)
file_name_without_extension, original_extension = os.path.splitext(file_name)
export_script_name = os.path.basename(__file__).replace(".hype-export.py", "")
if original_extension == "":
new_file_name = "%s.%s" % (file_name_without_extension, export_script_name)
else:
new_file_name = "%s.%s%s" % (file_name_without_extension, export_script_name, original_extension)
new_destination_path = os.path.join(directory, new_file_name)
zip(args.modify_staging_path, new_destination_path)
Do note that now the zip line uses the new_destination_path
variable. Thus if you're doing this replacement for the non-zip version we discussed above, you'd need to change the shutil.move()
call to use it as well.
I hope that helps!