Ah okay, damn I just found another problem.
Just when I thought it is increment-ing, it can only be incremented up to 
0002 only, despite there is already a xxx_0002.ma within the directory.
The last file show is always 0001 instead of 0002. I was thinking if this 
is a hassle, I may as well just have the file save the with "row index" as 
it is listed within its QTreeWidget?

Will that be better or not practical?


On Wednesday, February 18, 2015 at 1:08:16 PM UTC+8, Justin Israel wrote:
>
> Thats because you aren't checking your results after you list the 
> directory contents, and then you are trying to index into an empty list:
>
>        savedFiles = os.listdir(newSaveDir)
>         print savedFiles
>         savedFiles.sort()
>         incFiles = []
>         for i in savedFiles:
>             if fileName in i:
>                 incFiles.append(i)
>         lastFile = incFiles[len(incFiles)-1]
>
> You have to handle the case where it is an empty directory.
>
>
> On Wed Feb 18 2015 at 6:02:20 PM likage <[email protected] <javascript:>> 
> wrote:
>
>> Hi there,
>>
>> you are right. it seems to have bypass the error, never know about 
>> QString as I thought it will still work since it is still string..
>>
>> However I have a problem in the "lastFile" line, especially so if there 
>> isn't a file to begin with.
>>
>> For example, if there is already a "AvenueA_0001.ma" in the directory, it 
>> will automatically creates a "AvenueA_0002.ma" file, so on and forth. 
>> However say if I have a new file with the naming of "AvenueB", instead of 
>> creating "AvenueB_0001.ma", it will gives me the following error:
>>
>> # Traceback (most recent call last):
>> #   File "/user_data/dev_test/anmg/versions/anmgTool_v02a.py", line 211, 
>> in test
>> #     self.tmpSave()
>> #   File "/user_data/dev_test/anmg/versions/anmgTool_v02a.py", line 246, 
>> in tmpSave
>> #     lastFile = incFiles[len(incFiles)-1]
>> # IndexError: list index out of range
>>
>>   -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Python Programming for Autodesk Maya" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/python_inside_maya/4547438e-a1e9-46c8-941d-ab65f2db579b%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/python_inside_maya/4547438e-a1e9-46c8-941d-ab65f2db579b%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/e9637a6a-56e1-4182-928a-a268f6ad75f2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to