Skip to content

Commit

Permalink
Fix 175: added template filter to update copyright year.
Browse files Browse the repository at this point in the history
  • Loading branch information
HPSudip authored Jul 25, 2024
2 parents 5e3d0c0 + 5c8659b commit ba7cfac
Show file tree
Hide file tree
Showing 197 changed files with 233 additions and 197 deletions.
2 changes: 1 addition & 1 deletion jipp-core/bin/collection.kt.tmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{%- if not noheader -%}
// Copyright 2018 HP Development Company, L.P.
// Copyright {{ collection.name | camel_class | copyright_period }} HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by {{ app }}. Content taken from registry at
Expand Down
2 changes: 1 addition & 1 deletion jipp-core/bin/enum.kt.tmpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright {{ enum.name | camel_class | copyright_period }} HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by {{ app }}. Content taken from registry at
Expand Down
2 changes: 1 addition & 1 deletion jipp-core/bin/enums.kt.tmpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright {{ 'EnumTypes' | copyright_period }} HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by {{ app }}. Content taken from registry at
Expand Down
38 changes: 37 additions & 1 deletion jipp-core/bin/genTypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
import os.path
import sys
from jinja2 import Environment, FileSystemLoader # pip install Jinja2
from datetime import datetime
from datetime import datetime, date
import git

# Global data
specs = { }
Expand All @@ -27,6 +28,8 @@
pending_collections = { }
out_files = [ ]
proj_dir = os.path.dirname(os.path.realpath(__file__)) + "/../"
path_model_dir = proj_dir + 'src/main/java/com/hp/jipp/model/'
proj_root = os.path.dirname(os.path.realpath(__file__)) + "/../../"
warns = 0
pp = pprint.PrettyPrinter(indent=2)

Expand Down Expand Up @@ -516,6 +519,30 @@ def camel_class(string):
def camel_class_path(string):
return "".join([word.title() for word in re.split("[ _-]", string) if len(word) > 0])

def copyright_period(class_name, extension = ".kt"):
file_path = os.path.abspath(path_model_dir + class_name + extension)

if os.path.isfile(file_path):
creation_year = get_creation_year(file_path)
if creation_year and creation_year != xml_update_year:
return "%d - %d" % (creation_year, xml_update_year)
return "%d" % xml_update_year

def get_creation_year(file_path):
try:
repository = git.Repo(proj_root);
git_add_timestamp = repository.git.log('--diff-filter=A', '--follow', '--format=%aD', '-1', '--' , file_path)
try:
if git_add_timestamp:
date_object = datetime.strptime(git_add_timestamp, "%a, %d %b %Y %H:%M:%S %z")
return date_object.year
except:
warn("Failed to parse git timestamp")
except Exception as error:
warn("Unable to initialize git, please setup git in environment path")
warn(error)
return None

java_keywords = [
"abstract", "continue", "for", "new", "switch", "assert", "default", "goto", "package", "synchronized",
"boolean", "do", "if", "private", "this", "break", "double", "implements", "protected", "throw", "byte",
Expand Down Expand Up @@ -1072,6 +1099,7 @@ def emit_code():
env.filters['camel_member'] = camel_member
env.filters['spaced_title'] = spaced_title
env.filters['upper'] = upper
env.filters['copyright_period'] = copyright_period

emit_kind(env, 'enum.kt.tmpl', enums, emit_enum)
emit_kind(env, 'keyword.java.tmpl', keywords, emit_keyword)
Expand Down Expand Up @@ -1108,6 +1136,14 @@ def emit_code():
if elem.find('{*}title').text == "Internet Printing Protocol (IPP) Registrations":
updated = elem.find('{*}updated').text

xml_update_year = None
if updated:
updated_dt_obj = datetime.strptime(updated, "%Y-%m-%d").date()
xml_update_year = updated_dt_obj.year

if not xml_update_year:
warn("Unable to calculate updated timestamp")

parse_records(tree, "Enum Attribute Values", parse_enum)
parse_records(tree, "Keyword Attribute Values", parse_keyword)

Expand Down
2 changes: 1 addition & 1 deletion jipp-core/bin/keyvalues.kt.tmpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright {{ 'KeyValuesTypes' | copyright_period }} HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by {{ app }}. Content taken from registry at
Expand Down
2 changes: 1 addition & 1 deletion jipp-core/bin/keyword.java.tmpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright {{ keyword.name | camel_class | copyright_period(".java") }} HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by {{ app }}. Content taken from registry at
Expand Down
2 changes: 1 addition & 1 deletion jipp-core/bin/types.kt.tmpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright {{ 'Types' | copyright_period }} HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by {{ app }}. Content taken from registry at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
2 changes: 1 addition & 1 deletion jipp-core/src/main/java/com/hp/jipp/model/BalingType.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
2 changes: 1 addition & 1 deletion jipp-core/src/main/java/com/hp/jipp/model/BalingWhen.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
2 changes: 1 addition & 1 deletion jipp-core/src/main/java/com/hp/jipp/model/BindingType.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
2 changes: 1 addition & 1 deletion jipp-core/src/main/java/com/hp/jipp/model/ClientInfo.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2023 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
2 changes: 1 addition & 1 deletion jipp-core/src/main/java/com/hp/jipp/model/ClientType.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2023 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
2 changes: 1 addition & 1 deletion jipp-core/src/main/java/com/hp/jipp/model/CoatingType.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
2 changes: 1 addition & 1 deletion jipp-core/src/main/java/com/hp/jipp/model/Compression.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
2 changes: 1 addition & 1 deletion jipp-core/src/main/java/com/hp/jipp/model/CoverBack.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
2 changes: 1 addition & 1 deletion jipp-core/src/main/java/com/hp/jipp/model/CoverFront.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
2 changes: 1 addition & 1 deletion jipp-core/src/main/java/com/hp/jipp/model/CoverType.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2022 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
2 changes: 1 addition & 1 deletion jipp-core/src/main/java/com/hp/jipp/model/DocumentState.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
2 changes: 1 addition & 1 deletion jipp-core/src/main/java/com/hp/jipp/model/EnumTypes.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
2 changes: 1 addition & 1 deletion jipp-core/src/main/java/com/hp/jipp/model/Finishing.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
2 changes: 1 addition & 1 deletion jipp-core/src/main/java/com/hp/jipp/model/FinishingsCol.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
2 changes: 1 addition & 1 deletion jipp-core/src/main/java/com/hp/jipp/model/InputSource.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
2 changes: 1 addition & 1 deletion jipp-core/src/main/java/com/hp/jipp/model/InsertSheet.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018 HP Development Company, L.P.
// Copyright 2018 - 2024 HP Development Company, L.P.
// SPDX-License-Identifier: MIT
//
// DO NOT MODIFY. Code is auto-generated by genTypes.py. Content taken from registry at
Expand Down
Loading

0 comments on commit ba7cfac

Please sign in to comment.