import globimport reimport os
def fix_path_case( path ): case_on_disk_path = glob.glob( re.sub( r'([^:])(?=[/\\]|$)', r'[\1]' , path ) )[0] slash_fixed_path = os.path.realpath(case_on_disk_path ) return slash_fixed_path # Real path on disk is ''W:/Shows/Proj/Pub/TEX/Proj_skin_DIF.1001.TIF'bad_case_texture_path = 'W:/shOws/PRoj/PUB/tex/proj_skin_DIF.1001.tif' #path in maya
fixed_path = fix_path_case( path = bad_case_texture_path )
--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/11dfb149-d63d-4f1b-88d0-c02de401e86e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
On Sat, Oct 29, 2016 at 8:39 AM Chad_Fox <chadl...@gmail.com> wrote:Hi all,I'd like to confirm if the paths written in maya (on windows) has the correct character case. In otherwords I need to verify the path is good for use on Linux.I have the following solution, but glob is ... not very fast.Would like to know if anyone here has come accross an effective/fast solution for this problem.
import globimport reimport osdef fix_path_case( path ):case_on_disk_path = glob.glob( re.sub( r'([^:])(?=[/\\]|$)', r'[\1]' , path ) )[0]slash_fixed_path = os.path.realpath(case_on_disk_path )return slash_fixed_path# Real path on disk is ''W:/Shows/Proj/Pub/TEX/Proj_skin_DIF.1001.TIF'bad_case_texture_path = 'W:/shOws/PRoj/PUB/tex/proj_skin_DIF.1001.tif' #path in mayafixed_path = fix_path_case( path = bad_case_texture_path )Thanks!ChadPart of this problem, for me, would be something I would think to solve through conventions at a facility. Are people actually using whatever casing they feel like as opposed to what matches on disk? Is it really a concern about the filename portion, or just a naming issue with the mount points between Windows and Linux? And also, what is the logic of your regex that you hope to express?It would be difficult to know exactly what to transform the string into, without also doing a glob of the filesytem. If people are allowed to use any caseing they want, then you don't really have a choice but to stat the directory and case-insensitive match the files with your string.Justin
--
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 python_inside_maya+unsub...@googlegroups.com.
This issue is definitely due to the lack of conventions or tools and the solution I have now is just a stop-gap until asset management tools are made to control these paths.The entire path is an issue too because we have people manually editing their file paths in maya entering the wrong case in some dir names.Anywho. The regex searches for all characters except ':' and replaces everything it finds with the second argument [\1] which backmatches the same results, except the results are from what glob sees rather than whats in the original string provided to the re.sub.
import os
import glob
from itertools import imap
def insensitive_glob(pattern):
def either(c):
return '[%s%s]' % (c.lower(),c.upper()) if c.isalpha() else c
drive, path = os.path.splitdrive(path)
path = ''.join(map(either, path))
return glob.glob(os.path.join(drive, path))
On Friday, October 28, 2016 at 6:21:57 PM UTC-7, Justin Israel wrote:
On Sat, Oct 29, 2016 at 8:39 AM Chad_Fox <chadl...@gmail.com> wrote:Hi all,I'd like to confirm if the paths written in maya (on windows) has the correct character case. In otherwords I need to verify the path is good for use on Linux.I have the following solution, but glob is ... not very fast.Would like to know if anyone here has come accross an effective/fast solution for this problem.
import globimport reimport osdef fix_path_case( path ):case_on_disk_path = glob.glob( re.sub( r'([^:])(?=[/\\]|$)', r'[\1]' , path ) )[0]slash_fixed_path = os.path.realpath(case_on_disk_path )return slash_fixed_path# Real path on disk is ''W:/Shows/Proj/Pub/TEX/Proj_skin_DIF.1001.TIF'bad_case_texture_path = 'W:/shOws/PRoj/PUB/tex/proj_skin_DIF.1001.tif' #path in mayafixed_path = fix_path_case( path = bad_case_texture_path )Thanks!ChadPart of this problem, for me, would be something I would think to solve through conventions at a facility. Are people actually using whatever casing they feel like as opposed to what matches on disk? Is it really a concern about the filename portion, or just a naming issue with the mount points between Windows and Linux? And also, what is the logic of your regex that you hope to express?It would be difficult to know exactly what to transform the string into, without also doing a glob of the filesytem. If people are allowed to use any caseing they want, then you don't really have a choice but to stat the directory and case-insensitive match the files with your string.Justin
--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/11dfb149-d63d-4f1b-88d0-c02de401e86e%40googlegroups.com.
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/2106c36f-cdcf-4d35-844b-31b954021d7a%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/11dfb149-d63d-4f1b-88d0-c02de401e86e%40googlegroups.com.
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 python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/2106c36f-cdcf-4d35-844b-31b954021d7a%40googlegroups.com.
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 view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA30SRsFAObm12DM%3Dz1JLTS8ZKv4-s6dtAyx0pd0LWfXUw%40mail.gmail.com.To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
-Chad
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/11dfb149-d63d-4f1b-88d0-c02de401e86e%40googlegroups.com.
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 python_inside_maya+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/2106c36f-cdcf-4d35-844b-31b954021d7a%40googlegroups.com.
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 python_inside_maya+unsubscribe@googlegroups.com.
I take back my comment that it was failing on my laptop.. I simply had an invalid path that did not exist there. Looks like the original re is working here as I described.
-Chad
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/11dfb149-d63d-4f1b-88d0-c02de401e86e%40googlegroups.com.
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/2106c36f-cdcf-4d35-844b-31b954021d7a%40googlegroups.com.
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA30SRsFAObm12DM%3Dz1JLTS8ZKv4-s6dtAyx0pd0LWfXUw%40mail.gmail.com.
--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAJ4oLs7JerewjBKSupLQbfPaWq1cm1nPiVratwTH%2BS5NroDiLg%40mail.gmail.com.
-Chad
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/11dfb149-d63d-4f1b-88d0-c02de401e86e%40googlegroups.com.
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 python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/2106c36f-cdcf-4d35-844b-31b954021d7a%40googlegroups.com.
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 python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA30SRsFAObm12DM%3Dz1JLTS8ZKv4-s6dtAyx0pd0LWfXUw%40mail.gmail.com.
--
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 python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAJ4oLs7JerewjBKSupLQbfPaWq1cm1nPiVratwTH%2BS5NroDiLg%40mail.gmail.com.
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 python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1UEvpU05VaBHxeL8v%2B4Wyn7YrvC%2BuWQFJjH-gManM1jg%40mail.gmail.com.
Yeah I'll admit that that is a little disconserting. I tried a bunch of variations on the path being input, including changing slashes, adding double \\ and I never got the same results as you described.
W:/shOw[s]/PRo[j]/PU[B]/te[x]/proj_skin_DIF.1001.ti[f]
-Chad
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/11dfb149-d63d-4f1b-88d0-c02de401e86e%40googlegroups.com.
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/2106c36f-cdcf-4d35-844b-31b954021d7a%40googlegroups.com.
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA30SRsFAObm12DM%3Dz1JLTS8ZKv4-s6dtAyx0pd0LWfXUw%40mail.gmail.com.
--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAJ4oLs7JerewjBKSupLQbfPaWq1cm1nPiVratwTH%2BS5NroDiLg%40mail.gmail.com.
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1UEvpU05VaBHxeL8v%2B4Wyn7YrvC%2BuWQFJjH-gManM1jg%40mail.gmail.com.
--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAJ4oLs7iR6erc0vMGsEf4MiMQT88Hzcj5S2s988VR%2BfdjC9n4Q%40mail.gmail.com.
Sorry if this was implied somewhere, but are you aware that on Windows paths are case-insensitive? That is, it makes no guarantees on preserving case and treats c:\tHIS
the same as c:\This
.
Sorry if this was implied somewhere, but are you aware that on Windows paths are case-insensitive? That is, it makes no guarantees on preserving case and treats
c:\tHIS
the same asc:\This
.
--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBo3_%2BUstuMSUCOCJT7hf-Jw2ZkEwPw1Ok6ewTGFKhPFw%40mail.gmail.com.
I had to do something similar at freestyle games. As a games company we were on windows and framestore was linux. So i had to garantee the case of the wondows file paths. Instead of doing this type of check. Everyone had to make assests in maya via our project manager. It garenteed lower case file paths. The publish step failed if maya file paths were invalid and offered 1 click fixes for most checks.
Not an answer realy, just an alternate way of coping this linux vs windows path issues.
On Sat, 5 Nov 2016, 10:27 PM Marcus Ottosson <konstr...@gmail.com> wrote:Sorry if this was implied somewhere, but are you aware that on Windows paths are case-insensitive? That is, it makes no guarantees on preserving case and treats
c:\tHIS
the same asc:\This
.I think it was implied in the original question"I'd like to confirm if the paths written in maya (on windows) has the correct character case. In otherwords I need to verify the path is good for use on Linux"I understood that as it not being a problem on Windows itself because of the case insensitive paths. But not working for those files when accessed through Linux because the paths no longer match case sensitive.
--
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 python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBo3_%2BUstuMSUCOCJT7hf-Jw2ZkEwPw1Ok6ewTGFKhPFw%40mail.gmail.com.
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 python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0qr6B1bPtYjW6kj2RoYFTUU%3D5oBHkrqfaiUdC0VL-Kyg%40mail.gmail.com.
That is the expected outcome of the regex alone, but I found quite by accident that the regex sub written this way, iters over every character individually within glob so each character is found in the bad case string and the re callback \1 substitutes the found char with whats actually on disk.
I had to do something similar at freestyle games. As a games company we were on windows and framestore was linux. So i had to garantee the case of the wondows file paths. Instead of doing this type of check. Everyone had to make assests in maya via our project manager. It garenteed lower case file paths. The publish step failed if maya file paths were invalid and offered 1 click fixes for most checks.
Not an answer realy, just an alternate way of coping this linux vs windows path issues.
On 5 Nov 2016 10:33, "Justin Israel" <justin...@gmail.com> wrote:
On Sat, 5 Nov 2016, 10:27 PM Marcus Ottosson <konstr...@gmail.com> wrote:Sorry if this was implied somewhere, but are you aware that on Windows paths are case-insensitive? That is, it makes no guarantees on preserving case and treats
c:\tHIS
the same asc:\This
.I think it was implied in the original question"I'd like to confirm if the paths written in maya (on windows) has the correct character case. In otherwords I need to verify the path is good for use on Linux"I understood that as it not being a problem on Windows itself because of the case insensitive paths. But not working for those files when accessed through Linux because the paths no longer match case sensitive.
--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBo3_%2BUstuMSUCOCJT7hf-Jw2ZkEwPw1Ok6ewTGFKhPFw%40mail.gmail.com.
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0qr6B1bPtYjW6kj2RoYFTUU%3D5oBHkrqfaiUdC0VL-Kyg%40mail.gmail.com.
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CABD4PkQmvE%3DMVqyHNctGEWu9JBTdYdcNxBO8qLjZfTGkv7FX3w%40mail.gmail.com.
Hey Justin,That is the expected outcome of the regex alone, but I found quite by accident that the regex sub written this way, iters over every character individually within glob so each character is found in the bad case string and the re callback \1 substitutes the found char with whats actually on disk.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAJ4oLs6Q6tr%2BqCnsNJ3%2BX7r-EiD2BB%3DZOkMG6%2B%3DrGK%2Bu92SGZQ%40mail.gmail.com.
Oh you are always running this on windows? I thought you said it was meant to run on linux to fix paths? Then I assume it only works on Windows because Windows doesn't care about case when you glob anything and having at least any wild card or character sets in your string just causes the matching to happen.
Basically that code won't work on Linux or osx
--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/0a696299-5319-436d-8fc9-bbee21e93565%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA3Y12MpPbQj3n%2BEFpB7Xmn98Uuei%2BKokiEraKi840bjsw%40mail.gmail.com.