Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
csst-pipeline
csst_common
Commits
7da09866
Commit
7da09866
authored
1 year ago
by
BO ZHANG
Browse files
Options
Download
Email Patches
Plain Diff
add randfile
parent
b0d4f4f4
dev
main
wangxia-main-patch-87026
zhaobowei-main-patch-61353
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
csst_common/utils/__init__.py
+1
-0
csst_common/utils/__init__.py
csst_common/utils/tempfile.py
+27
-0
csst_common/utils/tempfile.py
with
28 additions
and
0 deletions
+28
-0
csst_common/utils/__init__.py
+
1
-
0
View file @
7da09866
from
._module_docstr
import
ModuleHeader
from
._module_docstr
import
ModuleHeader
from
._io
import
remove_dir
,
remove_files
from
._io
import
remove_dir
,
remove_files
from
.tempfile
import
randfile
This diff is collapsed.
Click to expand it.
csst_common/utils/tempfile.py
0 → 100644
+
27
-
0
View file @
7da09866
import
secrets
import
string
def
randfile
(
digits
=
20
,
ext
=
".fits"
):
"""
Parameters
----------
digits
ext
Returns
-------
Examples
--------
>>> fname = randfile(20)
>>> print(fname)
"""
# 生成包含大小写字母和数字的字符集
characters
=
string
.
ascii_letters
+
string
.
digits
# 使用secrets模块生成指定长度的随机字符串
random_string
=
''
.
join
(
secrets
.
choice
(
characters
)
for
_
in
range
(
digits
))
+
ext
return
random_string
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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
Menu
Explore
Projects
Groups
Snippets