''' JMK Engineering Inc. Python Library for design and such. by: Jeff MacKinnon email: jeff@jmkengineering.com Template Generation These functions are used to create labels, reports, etc. ''' from .jepl_safety import * def af_label(equipment,working_distance,incident_energy,af_boundary,energy_level,voltage, author="Jeff MacKinnon",warning="warning",project="Arc Flash Warning Label",project_num="2500",DC=False,fixedElectrode = True, SI=True,project_year=2015,test=False): ''' This function is for printing a single label with all the information in the function above. Include the units (in, Vac, Vdc, ft, m, mm, etc.) in the values. All values are strings. ''' from datetime import date date = date.today() revdate = date.strftime("%m/%d/%Y") if DC == True: voltage_units = " Vdc" else: voltage_units = " Vac" label_voltage = str(voltage) + voltage_units glove_class = gloveClass(voltage,DC=DC) limited_approach = limitedApproach(voltage,fixed=fixedElectrode,DC=DC,unitsSI=SI,year=project_year) restricted_approach = restrictedApproach(voltage,DC=DC,unitsSI=SI,year=project_year) if warning =="warning": warning_colour = '242,85,31' warning_text = '\warning WARNING' elif warning == "danger": warning_colour = '242,85,31' # This colour needs to change warning_text = '\warning DANGER' else: warning_colour = '255,255,255' # This colour needs to change warning_text = '' from jinja2 import Environment, FileSystemLoader environment = Environment( block_start_string = '\BLOCK{', block_end_string = '}', variable_start_string = '\VAR((', variable_end_string = '))', comment_start_string = '\#{', comment_end_string = '}', line_comment_prefix = '%#', loader=FileSystemLoader("jepl/templates/") ) template = environment.get_template("template-label-ArcFlash.tex") if test == True: filename = "test"+str(date) + "-"+project_num+"-label-ArcFlash.tex" else: filename = str(date) + "-"+project_num+"-label-ArcFlash.tex" content = template.render( DATE = revdate, EQUIPMENT = equipment, WORKING_DISTANCE = working_distance, INCIDENT_ENERGY = incident_energy, AF_BOUNDARY = af_boundary, ENERGY_LEVEL = energy_level, VOLTAGE = label_voltage, LIMITED_APPROACH = limited_approach, RESTRICTED_APPROACH = restricted_approach, GLOVE_CLASS = glove_class, AUTHOR = author, TITLE = project, WARNING_COLOUR = warning_colour, WARNING_TEXT = warning_text, ) with open(filename, mode="w", encoding="utf-8") as message: message.write(content)