Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
9c8fde8e
"...git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "9cea3e7b80be16090df2fcb593524b769b377d9d"
Unverified
Commit
9c8fde8e
authored
May 13, 2022
by
Sylvain Gugger
Committed by
GitHub
May 13, 2022
Browse files
Handle copyright in add-new-model-like (#17218)
parent
993553b2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
0 deletions
+4
-0
src/transformers/commands/add_new_model_like.py
src/transformers/commands/add_new_model_like.py
+4
-0
No files found.
src/transformers/commands/add_new_model_like.py
View file @
9c8fde8e
...
...
@@ -18,6 +18,7 @@ import os
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
...
...
@@ -32,6 +33,7 @@ from . import BaseTransformersCLICommand
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
...
...
@@ -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
...
...
@@ -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
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment