Skip to content

Commit

Permalink
Fixed Python script errors flagged by pyflakes (#1604)
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanHabel authored Nov 27, 2023
1 parent e45d67f commit 273b8a5
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
4 changes: 2 additions & 2 deletions python/Scripts/generateshader.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def validateCode(sourceCodeFile, codevalidator, codevalidatorArgs):
print(cmd_flatten)
try:
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
result = output.decode(encoding='utf-8')
return output.decode(encoding='utf-8')
except subprocess.CalledProcessError as out:
return (out.output.decode(encoding='utf-8'))
return ""
Expand Down Expand Up @@ -83,7 +83,7 @@ def main():
try:
mx.loadLibraries(libraryFolders, searchPath, stdlib)
doc.importLibrary(stdlib)
except err:
except Exception as err:
print('Generation failed: "', err, '"')
sys.exit(-1)

Expand Down
10 changes: 6 additions & 4 deletions python/Scripts/genmdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
Generate MDL implementation directory based on MaterialX nodedefs
'''

import sys
import os
import string; os.environ['PYTHONIOENCODING'] = 'utf-8'
import sys

os.environ['PYTHONIOENCODING'] = 'utf-8'

import MaterialX as mx

def usage():
Expand Down Expand Up @@ -345,7 +347,7 @@ def main():

doc = mx.createDocument()
searchPath = os.path.join(_startPath, 'libraries')
libraryPath = os.path.join(searchPath, 'stdlib')
libraryPath = os.path.join(searchPath, LIBRARY)
_loadLibraries(doc, searchPath, libraryPath)

DEFINITION_PREFIX = 'ND_'
Expand Down Expand Up @@ -522,7 +524,7 @@ def main():
if isinstance(elem, mx.Output):
outputValue = elem.getAttribute('default')
if outputValue == '[]':
outputvalue = ''
outputValue = ''
if not outputValue:
outputValue = elem.getAttribute('defaultinput')
if outputValue:
Expand Down
4 changes: 3 additions & 1 deletion python/Scripts/mxdoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
Print markdown documentation for each nodedef in the given document.
'''

import sys, os, argparse
import argparse
import sys

import MaterialX as mx

HEADERS = ('Name', 'Type', 'Default Value',
Expand Down
4 changes: 3 additions & 1 deletion python/Scripts/mxformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
the documents to the latest version of the standard.
'''

import sys, os, argparse
import argparse
import os

import MaterialX as mx

def main():
Expand Down
6 changes: 4 additions & 2 deletions python/Scripts/mxvalidate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
Verify that the given file is a valid MaterialX document.
'''

import sys, os, argparse
import argparse
import sys

import MaterialX as mx

def main():
Expand All @@ -25,7 +27,7 @@ def main():
stdlib = mx.createDocument()
try:
mx.loadLibraries(mx.getDefaultDataLibraryFolders(), mx.getDefaultDataSearchPath(), stdlib)
except err:
except Exception as err:
print(err)
sys.exit(0)
doc.importLibrary(stdlib)
Expand Down

0 comments on commit 273b8a5

Please sign in to comment.