Skip to content

Instantly share code, notes, and snippets.

@khaeru
Last active April 3, 2018 02:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save khaeru/12222aa33a1f31daf2b20c5040401625 to your computer and use it in GitHub Desktop.
Save khaeru/12222aa33a1f31daf2b20c5040401625 to your computer and use it in GitHub Desktop.
"""Vehicle Acronyms
Usage:
1. Clone https://github.com/tabatkins/railroad-diagrams
2. Drop this file in.
3. $ python3 acronyms.py
Some sources:
- https://en.wikipedia.org/wiki/Automotive_acronyms_and_abbreviations
- http://www.chicagotribune.com/classified/automotive/
chi-electric-vehicle-acronyms-20130724-story.html
- http://www.ev-institute.com/images/acronym_poster.pdf
If you change "html" to "svg" in the second-to-last line, files are created
that Inkscape will open, but the connecting lines are wonky. ¯\_(ツ)_/¯
I know PHDEV doesn't occur in the wild, but it's dinner time and I'm hungry.
"""
from railroad_diagrams import (
Choice,
Diagram,
Optional,
Sequence,
Skip,
)
A = Sequence(Optional('Connected'), 'Autonomous')
FC = Sequence(
'Fuel Cell',
Optional(Sequence(Optional('Hybrid'), 'Electric')),
)
D_v = Sequence(
Choice(1,
Sequence(Optional('Electric'), 'Heavy'),
'Medium',
Sequence(Optional('Passenger'), 'Light')),
'Duty')
D_t = Sequence(
Choice(1, 'Heavy', 'Medium', 'Light'),
'Duty',
)
Hyb = Sequence(
Optional('Plugin'),
'Hybrid',
Optional('Diesel'),
)
El = Sequence(
Choice(3,
Skip(),
'Battery',
'City',
Hyb,
'Inherently Low',
'Neighbourhood',
'Extended Range',
),
'Electric',
)
Em = Sequence(
Choice(0,
Sequence(Optional(Sequence(Optional('Super'), 'Ultra')), 'Low'),
Sequence(Optional('Partial'), 'Zero'),
),
'Emissions',
)
ICE = 'Internal Combustion Engine'
F = Sequence(
Choice(0, 'Alternative', 'Bi-', 'Clean', 'Dual'),
'Fuel',
)
NG = Sequence(
Optional('Compressed'),
'Natural Gas',
)
FH = 'For Hire'
Hyd = 'Hydrogen (H2)'
SU = 'Sport Utility'
diagrams = {
'Vehicle': Choice(4, A, FC, D_v, El, Em, ICE, F, NG, FH, Hyd, SU),
'Truck': D_t,
}
for root, entries in diagrams.items():
diagram = Diagram(Sequence(entries, root), type='complex')
with open('acronyms-{}.html'.format(root.lower()), 'w') as f:
diagram.writeSvg(f.write)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment