mirror of
https://github.com/pyTooling/Actions.git
synced 2026-02-12 11:06:56 +08:00
use fstrings
This commit is contained in:
21
tip.py
21
tip.py
@@ -30,10 +30,10 @@ else:
|
|||||||
|
|
||||||
for item in args:
|
for item in args:
|
||||||
items = [fname for fname in glob(item, recursive=True) if not Path(fname).is_dir()]
|
items = [fname for fname in glob(item, recursive=True) if not Path(fname).is_dir()]
|
||||||
print("glob(%s)" % item, "->", items)
|
print(f"glob({item!s})", "->", items)
|
||||||
for fname in items:
|
for fname in items:
|
||||||
if Path(fname).stat().st_size == 0:
|
if Path(fname).stat().st_size == 0:
|
||||||
print("! Skipping empty file %s" % fname)
|
print(f"! Skipping empty file {fname!s}")
|
||||||
continue
|
continue
|
||||||
files += [fname]
|
files += [fname]
|
||||||
|
|
||||||
@@ -79,8 +79,8 @@ if gh_ref[0:10] == 'refs/tags/':
|
|||||||
semver = re.search(rexp, env_tag[1:])
|
semver = re.search(rexp, env_tag[1:])
|
||||||
tag = env_tag
|
tag = env_tag
|
||||||
if semver == None:
|
if semver == None:
|
||||||
print('! Could not get semver from %s' % gh_ref)
|
print(f'! Could not get semver from {gh_ref!s}')
|
||||||
print("! Treat tag '%s' as a release" % tag)
|
print(f"! Treat tag '{tag!s}' as a release")
|
||||||
is_prerelease = False
|
is_prerelease = False
|
||||||
else:
|
else:
|
||||||
if semver.group('prerelease') is None:
|
if semver.group('prerelease') is None:
|
||||||
@@ -93,7 +93,7 @@ if gh_ref[0:10] == 'refs/tags/':
|
|||||||
|
|
||||||
gh_tag = None
|
gh_tag = None
|
||||||
try:
|
try:
|
||||||
gh_tag = gh_repo.get_git_ref('tags/%s' % tag)
|
gh_tag = gh_repo.get_git_ref(f'tags/{tag!s}')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
stdout.flush()
|
stdout.flush()
|
||||||
pass
|
pass
|
||||||
@@ -105,7 +105,7 @@ if gh_tag:
|
|||||||
is_draft = True
|
is_draft = True
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
err_msg = "Tag/release '%s' does not exist and could not create it!" % tag
|
err_msg = f"Tag/release '{tag!s}' does not exist and could not create it!"
|
||||||
if 'GITHUB_SHA' not in environ:
|
if 'GITHUB_SHA' not in environ:
|
||||||
raise(Exception(err_msg))
|
raise(Exception(err_msg))
|
||||||
try:
|
try:
|
||||||
@@ -127,13 +127,12 @@ if getenv('INPUT_RM', 'false') == 'true':
|
|||||||
asset.delete_asset()
|
asset.delete_asset()
|
||||||
else:
|
else:
|
||||||
for asset in assets:
|
for asset in assets:
|
||||||
print(" >", asset)
|
print(f" > {asset!s}\n {asset.name!s}:")
|
||||||
print(" %s:" % asset.name)
|
|
||||||
for artifact in artifacts:
|
for artifact in artifacts:
|
||||||
aname = str(Path(artifact).name)
|
aname = str(Path(artifact).name)
|
||||||
if asset.name == aname:
|
if asset.name == aname:
|
||||||
print(" - uploading tmp...")
|
print(" - uploading tmp...")
|
||||||
new_asset = gh_release.upload_asset(artifact, name='tmp.%s' % aname)
|
new_asset = gh_release.upload_asset(artifact, name=f'tmp.{aname!s}')
|
||||||
print(" - removing...")
|
print(" - removing...")
|
||||||
asset.delete_asset()
|
asset.delete_asset()
|
||||||
print(" - renaming tmp...")
|
print(" - renaming tmp...")
|
||||||
@@ -163,5 +162,5 @@ if is_draft:
|
|||||||
|
|
||||||
if ('GITHUB_SHA' in environ) and (env_tag is None):
|
if ('GITHUB_SHA' in environ) and (env_tag is None):
|
||||||
sha = environ['GITHUB_SHA']
|
sha = environ['GITHUB_SHA']
|
||||||
print(" > Force-push '%s' to %s" % (tag, sha))
|
print(f" > Force-push '{tag!s}' to {sha!s}")
|
||||||
gh_repo.get_git_ref('tags/%s' % tag).edit(sha)
|
gh_repo.get_git_ref(f'tags/{tag!s}').edit(sha)
|
||||||
|
|||||||
Reference in New Issue
Block a user