On Sat, Nov 5, 2016 at 10:29 AM Chad Fox <chadlee...@gmail.com> wrote:

> 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.
>

I extracted this from your original example:
https://repl.it/EP27/0

Output:

W:/shOw[s]/PRo[j]/PU[B]/te[x]/proj_skin_DIF.1001.ti[f]


Is this the expected output?



>
>
> -Chad
>
> On Fri, Nov 4, 2016 at 1:51 PM, Justin Israel <justinisr...@gmail.com>
> wrote:
>
>
>
> On Sat, 5 Nov 2016, 9:40 AM Chad Fox <chadlee...@gmail.com> wrote:
>
> 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.
>
>
> Hm not sure why I got the non workable results with only parts of the
> string replaced.
>
>
> Anyways,  it was nice to get another example of how this can be done and
> thanks for your help!
>
>
> -Chad
>
> On Fri, Nov 4, 2016 at 1:03 PM, Chad Fox <chadlee...@gmail.com> wrote:
>
> Thanks I'll check that out.
>
> Interestingly my regex is working as I described on my work machine, but
> fails completely on my laptop with an "index out of range" error. the
> re.__version__ is the same, but glob .. I can't tell except that glob is
> coming from maya 2015 on my laptop and maya2016 at work. It may be that
> glob had some subtle changes to it that effect the search/replace.
>
> In anycase this looks better.
>
> Thanks!
>
>
> -Chad
>
> On Mon, Oct 31, 2016 at 1:51 PM, Justin Israel <justinisr...@gmail.com>
> wrote:
>
>
>
> On Tue, Nov 1, 2016 at 7:09 AM Chad_Fox <chadlee...@gmail.com> wrote:
>
> 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.
>
>
> Hmm, I was getting strange behaviour from that regex when I gave it a
> test. It seemed to just replace the character before each / with brackets:
>
> /some/path/to/file.ext => /som[e]/pat[h]/t[o]/file.ex[t]
>
> Anyways, maybe this would be a better approach?
> http://stackoverflow.com/a/10886685/496445
>
> Here is a slight tweak to account for windows drives:
>
> https://paste.ubuntu.com/23408534/
>
> import os import globfrom 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))
>
> ​
>
> At least you can avoid a regex?
>
> Justin
>
>
>
> 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 glob
> import re
> import 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 )
>
>
>
> Thanks!
>
> Chad
>
>
> Part 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+unsubscr...@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
> <https://groups.google.com/d/msgid/python_inside_maya/11dfb149-d63d-4f1b-88d0-c02de401e86e%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 python_inside_maya+unsubscr...@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
> <https://groups.google.com/d/msgid/python_inside_maya/2106c36f-cdcf-4d35-844b-31b954021d7a%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 python_inside_maya+unsubscr...@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
> <https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA30SRsFAObm12DM%3Dz1JLTS8ZKv4-s6dtAyx0pd0LWfXUw%40mail.gmail.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 python_inside_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAJ4oLs7JerewjBKSupLQbfPaWq1cm1nPiVratwTH%2BS5NroDiLg%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAJ4oLs7JerewjBKSupLQbfPaWq1cm1nPiVratwTH%2BS5NroDiLg%40mail.gmail.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 python_inside_maya+unsubscr...@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
> <https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1UEvpU05VaBHxeL8v%2B4Wyn7YrvC%2BuWQFJjH-gManM1jg%40mail.gmail.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 python_inside_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAJ4oLs7iR6erc0vMGsEf4MiMQT88Hzcj5S2s988VR%2BfdjC9n4Q%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAJ4oLs7iR6erc0vMGsEf4MiMQT88Hzcj5S2s988VR%2BfdjC9n4Q%40mail.gmail.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 python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1ws2UCGudZm03meRKrJ58t--eQK%2BsD7QwJws9gEmM6mw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to