Skip to content

Commit

Permalink
Merged in feature/PROTO-245-header-with-version-date-and-t (pull requ…
Browse files Browse the repository at this point in the history
…est #184)

PROTO-245 add a header with date and time of code generation
  • Loading branch information
cleuton committed Feb 14, 2025
2 parents 6fc9516 + 1a77c26 commit d587fa1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions EmbeddedProto/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

import io
import sys
import locale
from datetime import datetime
from EmbeddedProto.ProtoFile import ProtoFile
from google.protobuf.compiler import plugin_pb2 as plugin
import jinja2
Expand Down Expand Up @@ -89,6 +91,8 @@ def generate_code(request, respones):
with resource_path("EmbeddedProto", "templates") as filepath:
template_loader = jinja2.FileSystemLoader(searchpath=filepath)
template_env = jinja2.Environment(loader=template_loader, trim_blocks=True, lstrip_blocks=True)
# Add date and time of generation:
template_env.globals['current_date_and_time'] = get_current_date_and_time()

for fd in file_definitions:
file_str = fd.render(template_env)
Expand All @@ -100,6 +104,11 @@ def generate_code(request, respones):
break


def get_current_date_and_time():
locale.setlocale(locale.LC_TIME, '')
return datetime.now().strftime('%c')


# -----------------------------------------------------------------------------

def main_plugin():
Expand Down
1 change: 1 addition & 0 deletions EmbeddedProto/templates/Header.h.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
/*
* This file is generated with Embedded Proto, PLEASE DO NOT EDIT!
* source: {{proto_file.descriptor.name}}
* Generated on: {{ current_date_and_time }}
*/

// This file is generated. Please do not edit!
Expand Down

0 comments on commit d587fa1

Please sign in to comment.