[Grok-dev] Re: Grokinstallation corrupts when editing source remotely over AFP

Sebastian Ware sebastian at urbantalk.se
Wed Jun 11 12:38:06 EDT 2008


11 jun 2008 kl. 17.59 skrev Martijn Faassen:

> Hm, okay, so the double-dot theory is the correct one. Somehow in  
> grok_module, module_info.dottedname contains two dots instead of one.
>
> Is it conceivable that your editor creates dotted names for  
> temporary file names? (perhaps backup files?). I.e. that there are  
> times when a "._app.py" file exists in your directory (besides  
> "_app.py"?)?

that's an affirmative! (though it is not a backup file)

>
>
> If so, I suspect the problem can be fixed in scan.py, in the method  
> 'getSubModuleInfos'.
>
> There's a for loop there:
>
>  for entry in sorted(os.listdir(directory)):
>
> if you add as the first line in that loop the following:
>
>   if entry.startswith('.'):
>       continue

didn't test this one since...

>
>
> that might fix matters. Should be safe enough to add this to  
> Martian, as Python modules aren't supposed to start with a dot.
>
> In fact, module names have to start with an alphabetic character or  
> an underscore, so we can expand this rule to the following:
>
>   if not entry[0].isalpha() and entry[0] != '_':
>       continue

...this works like a charm!

>
>
> could you test the latter and see whether that fixes your problem?  
> If so we can add the fix to Martian. I guess we could even expand  
> this to testing with a regular expression whether it's a valid  
> Python module name at all...

Regexp or no regexp, adding this simple test is an excellent idea!

mvh Sebastian


More information about the Grok-dev mailing list