Skip to main content

A simple Python script for editing Photoshop slice generated HTML for use with e-blasts.

Requirements

  • Python 3. Run which python3; If not found, install with Homebrew, apt, or whatever else you use. Once it is installed, make sure the shebang path at the start of the script (ex: #!/usr/bin/python3) matches where your Python 3 is installed.

Use pip 3 to install dependencies:

pip3 will be installed with your Python 3 install.

  • Run pip3 install -r requirements.txt. This will install the bs4 and datetime packages. You can also install them manually, if you like. The script will not work if you skip this step.

Usage

python3 fix.py -f some-html-file-1942.html -d yourdomainhere.ca

The script takes two arguments, -f (file) and -d (domain).

-f

The .html file you want to fix. If you're running the script in the same directory as the HTML file, then all you have to do is type in/paste the file name. You can also specify a path (this is better)

For example, if your fix.py is in your ~/ or /home/ directory, and your HTML file is located in ~/Downloads/eblasts, you would navigate to ~/ and run python3 fix.py --file ~/Downloads/eblasts/some-html-file-1942.html --domain yourdomainhere.ca. The output file will be generated in the same directory as the HTML file input.

You can also move fix.py into whatever directory contains the HTML file and run it from there, so you don't have to type out the path to the file.

-d

The domain (without http://) where the images in the HTML are hosted. For example, yourdomainhere.com.

Result

  • All <img> elements get the correct style tags added to them.
  • All <img> src attributes will be edited to use the right domain/path for the FTP (http:// and /eblasts/).
  • Center element, SEO text div, and other pre-table and post-table content is added.
  • The original HTML file will be untouched. A new file will be generated, named the same as the original file but with an underscore and timestamp (seconds) added to it. The new file will be generated in the same directory as the original HTML file.

Todo

  • Depending on usage, I could work a bit more on customizing where the file is saved or generated.
  • Add batch file support, more CLI args.

Also

You'll still need to edit the SEO text and client address text manually.

Feel free to contribute more features if you like. It's simple now, but it could end up being pretty useful in the future.

Release files for slicefix-jonathandannel 3.7.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for slicefix-jonathandannel 3.7.10
File Size Uploaded
slicefix-jonathandannel-3.7.10.tar.gz 3.9 kB Details

Release files / slicefix-jonathandannel-3.7.10.tar.gz

Download URL slicefix-jonathandannel-3.7.10.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
4b39af276cb38dfd5c6e8645ebd89e895d9dc701280f439ff00ba5410502c339
BLAKE2b-256 checksum
How to use checksums
d99efcf292bdcdb89058d9944d300b55803383f09576898ffc8d16ad71fa18c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.5

Release history Release notifications | RSS feed

This release

3.7.10 This release

1 release file

2.7.10

1 release file

2.6.10

1 release file

1.6.10

1 release file

1.3.10

1 release file

1.0.10

1 release file

0.8.10

1 release file

0.7.10

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page