Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/.idea/

/test/
17 changes: 17 additions & 0 deletions homeworks/lesson5/script_update.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
# .@FileName:script_update
# @Date....:2020-04-04 20:49
# ..:XingLian
import re
import nuke
import nukescripts

# 获取工程名称
script_name = nuke.scriptName()
# 匹配是否存在版本号,如果不存在,另存为版本1,并进行升级操作
if not re.search(script_name, r'.?_v/d*.nk$'):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re相关查询函数的参数列表都是pattern在前,string在后,这里的pattern应该写成r'.?_v\d+\.nk$

print re.search(script_name, r'.?_v/d*.nk$')
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里只会返回一个_sre.SRE_Match对象,打印出来没有意义

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

. 的匹配最好变成 . 吧 ?不然别的字符也会匹配进去了 比如 lv001d 而不是 .v001.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zclongpop123 他只检查代码里有没有版本号,不关心其他字符,有就行

new_script_name = script_name[::-1].replace('kn.', 'kn.100v_', 1)[::-1]
Comment thread
haogeek marked this conversation as resolved.
print new_script_name
nuke.scriptSaveAs(new_script_name)
nukescripts.script_and_write_nodes_version_up()
Comment thread
haogeek marked this conversation as resolved.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading