Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stable Diffusion Webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Stable Diffusion Webui
Commits
5a981310
Commit
5a981310
authored
Oct 23, 2022
by
w-e-w
Committed by
AUTOMATIC1111
Oct 24, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replace_datetime() can now accept a datetime parameter
parent
8f6af4ed
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
5 deletions
+11
-5
modules/images.py
modules/images.py
+11
-5
No files found.
modules/images.py
View file @
5a981310
...
@@ -303,7 +303,7 @@ def apply_filename_pattern(x, p, seed, prompt):
...
@@ -303,7 +303,7 @@ def apply_filename_pattern(x, p, seed, prompt):
x
=
re
.
sub
(
r'\[model_hash]'
,
getattr
(
p
,
"sd_model_hash"
,
shared
.
sd_model
.
sd_model_hash
),
x
,
flags
=
re
.
IGNORECASE
)
x
=
re
.
sub
(
r'\[model_hash]'
,
getattr
(
p
,
"sd_model_hash"
,
shared
.
sd_model
.
sd_model_hash
),
x
,
flags
=
re
.
IGNORECASE
)
x
=
re
.
sub
(
r'\[date]'
,
datetime
.
date
.
today
()
.
isoformat
(),
x
,
flags
=
re
.
IGNORECASE
)
x
=
re
.
sub
(
r'\[date]'
,
datetime
.
date
.
today
()
.
isoformat
(),
x
,
flags
=
re
.
IGNORECASE
)
x
=
replace_datetime
(
x
)
x
=
replace_datetime
(
x
,
datetime
.
datetime
.
now
()
)
x
=
re
.
sub
(
r'\[job_timestamp]'
,
getattr
(
p
,
"job_timestamp"
,
shared
.
state
.
job_timestamp
),
x
,
flags
=
re
.
IGNORECASE
)
x
=
re
.
sub
(
r'\[job_timestamp]'
,
getattr
(
p
,
"job_timestamp"
,
shared
.
state
.
job_timestamp
),
x
,
flags
=
re
.
IGNORECASE
)
# Apply [prompt] at last. Because it may contain any replacement word.^M
# Apply [prompt] at last. Because it may contain any replacement word.^M
if
prompt
is
not
None
:
if
prompt
is
not
None
:
...
@@ -353,8 +353,14 @@ def get_next_sequence_number(path, basename):
...
@@ -353,8 +353,14 @@ def get_next_sequence_number(path, basename):
return
result
+
1
return
result
+
1
def
replace_datetime
(
input_str
:
str
):
def
replace_datetime
(
input_str
:
str
,
time_datetime
:
datetime
.
datetime
=
None
):
"""
"""
Args:
input_str (`str`):
the String to be Formatted
time_datetime (`datetime.datetime`)
the time to be used, if None, use datetime.datetime.now()
Formats sub_string of input_str with formatted datetime with time zone support.
Formats sub_string of input_str with formatted datetime with time zone support.
accepts sub_string format: [datetime], [datetime<Format>], [datetime<Format><Time Zone>]
accepts sub_string format: [datetime], [datetime<Format>], [datetime<Format><Time Zone>]
case insensitive
case insensitive
...
@@ -373,8 +379,8 @@ def replace_datetime(input_str: str):
...
@@ -373,8 +379,8 @@ def replace_datetime(input_str: str):
https://pytz.sourceforge.net/
https://pytz.sourceforge.net/
"""
"""
default_time_format
=
'
%
Y
%
m
%
d
%
H
%
M
%
S'
default_time_format
=
'
%
Y
%
m
%
d
%
H
%
M
%
S'
time_now
=
datetime
.
datetime
.
now
()
if
time_datetime
is
None
:
time_datetime
=
datetime
.
datetime
.
now
()
# match all datetime to be replace
# match all datetime to be replace
match_itr
=
re
.
finditer
(
r'\[datetime(?:<([^>]*)>(?:<([^>]*)>)?)?]'
,
input_str
,
re
.
IGNORECASE
)
match_itr
=
re
.
finditer
(
r'\[datetime(?:<([^>]*)>(?:<([^>]*)>)?)?]'
,
input_str
,
re
.
IGNORECASE
)
for
match
in
reversed
(
list
(
match_itr
)):
for
match
in
reversed
(
list
(
match_itr
)):
...
@@ -392,7 +398,7 @@ def replace_datetime(input_str: str):
...
@@ -392,7 +398,7 @@ def replace_datetime(input_str: str):
time_zone
=
None
time_zone
=
None
# generate time string
# generate time string
time_zone_time
=
time_
now
.
astimezone
(
time_zone
)
time_zone_time
=
time_
datetime
.
astimezone
(
time_zone
)
try
:
try
:
formatted_time
=
time_zone_time
.
strftime
(
time_format
)
formatted_time
=
time_zone_time
.
strftime
(
time_format
)
...
...
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