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
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
...
@@ -18,6 +18,7 @@ import os
import
re
import
re
from
argparse
import
ArgumentParser
,
Namespace
from
argparse
import
ArgumentParser
,
Namespace
from
dataclasses
import
dataclass
from
dataclasses
import
dataclass
from
datetime
import
date
from
itertools
import
chain
from
itertools
import
chain
from
pathlib
import
Path
from
pathlib
import
Path
from
typing
import
Any
,
Callable
,
Dict
,
List
,
Optional
,
Pattern
,
Tuple
,
Union
from
typing
import
Any
,
Callable
,
Dict
,
List
,
Optional
,
Pattern
,
Tuple
,
Union
...
@@ -32,6 +33,7 @@ from . import BaseTransformersCLICommand
...
@@ -32,6 +33,7 @@ from . import BaseTransformersCLICommand
logger
=
logging
.
get_logger
(
__name__
)
# pylint: disable=invalid-name
logger
=
logging
.
get_logger
(
__name__
)
# pylint: disable=invalid-name
CURRENT_YEAR
=
date
.
today
().
year
TRANSFORMERS_PATH
=
Path
(
__file__
).
parent
.
parent
TRANSFORMERS_PATH
=
Path
(
__file__
).
parent
.
parent
REPO_PATH
=
TRANSFORMERS_PATH
.
parent
.
parent
REPO_PATH
=
TRANSFORMERS_PATH
.
parent
.
parent
...
@@ -421,6 +423,7 @@ def duplicate_module(
...
@@ -421,6 +423,7 @@ def duplicate_module(
with
open
(
module_file
,
"r"
,
encoding
=
"utf-8"
)
as
f
:
with
open
(
module_file
,
"r"
,
encoding
=
"utf-8"
)
as
f
:
content
=
f
.
read
()
content
=
f
.
read
()
content
=
re
.
sub
(
"# Copyright (\d+)\s"
,
f
"# Copyright
{
CURRENT_YEAR
}
"
,
content
)
objects
=
parse_module_content
(
content
)
objects
=
parse_module_content
(
content
)
# Loop and treat all objects
# Loop and treat all objects
...
@@ -1062,6 +1065,7 @@ def duplicate_doc_file(
...
@@ -1062,6 +1065,7 @@ def duplicate_doc_file(
with
open
(
doc_file
,
"r"
,
encoding
=
"utf-8"
)
as
f
:
with
open
(
doc_file
,
"r"
,
encoding
=
"utf-8"
)
as
f
:
content
=
f
.
read
()
content
=
f
.
read
()
content
=
re
.
sub
(
"<!--\s*Copyright (\d+)\s"
,
f
"<!--Copyright
{
CURRENT_YEAR
}
"
,
content
)
if
frameworks
is
None
:
if
frameworks
is
None
:
frameworks
=
get_default_frameworks
()
frameworks
=
get_default_frameworks
()
if
dest_file
is
None
:
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