Skip to content

Commit

Permalink
Handle copyright in add-new-model-like (huggingface#17218)
Browse files Browse the repository at this point in the history
  • Loading branch information
sgugger authored and elusenji committed Jun 12, 2022
1 parent e0e43aa commit f8e6e88
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/transformers/commands/add_new_model_like.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import re
from argparse import ArgumentParser, Namespace
from dataclasses import dataclass
from datetime import date
from itertools import chain
from pathlib import Path
from typing import Any, Callable, Dict, List, Optional, Pattern, Tuple, Union
Expand All @@ -32,6 +33,7 @@
logger = logging.get_logger(__name__) # pylint: disable=invalid-name


CURRENT_YEAR = date.today().year
TRANSFORMERS_PATH = Path(__file__).parent.parent
REPO_PATH = TRANSFORMERS_PATH.parent.parent

Expand Down Expand Up @@ -421,6 +423,7 @@ def duplicate_module(
with open(module_file, "r", encoding="utf-8") as f:
content = f.read()

content = re.sub("# Copyright (\d+)\s", f"# Copyright {CURRENT_YEAR} ", content)
objects = parse_module_content(content)

# Loop and treat all objects
Expand Down Expand Up @@ -1062,6 +1065,7 @@ def duplicate_doc_file(
with open(doc_file, "r", encoding="utf-8") as f:
content = f.read()

content = re.sub("<!--\s*Copyright (\d+)\s", f"<!--Copyright {CURRENT_YEAR} ", content)
if frameworks is None:
frameworks = get_default_frameworks()
if dest_file is None:
Expand Down

0 comments on commit f8e6e88

Please sign in to comment.