views:

38

answers:

1

I am trying to use diffstrings.py from Three20 on my iPhone project, and I can't find the proper format for the path arguments (as in "Usage: diffstrings.py [options] path1 path2 ...").

For example, when I run the script in my Xcode project directory like this ~/py/diffstrings.py -b it analyzes just the main.m and finds 0 strings to localize, then it diffs against existing fr.lproj and others, and finds that thes contain "obsolete strings".

Can anyone post examples of successful comand line invocations of diffstrings.py, for options -b, -d and -m?

A: 

Taking a quick look at the code here http://github.com/facebook/three20/blob/master/diffstrings.py I see that if you don't specify any command line options, it assumes you mean the directory wherever the script lives in. So the option is to either copy .py file to where your .m files are, or simple use the command

   ~py/diffstrings.py -b .

That is, give the current directory (.) as the path argument.

rlotun
rlotun, I ran the script in my Xcode project directory, as `~/py/diffstrings.py -b`and also as `~/py/diffstrings.py -b .`, however in both cases the script was finding only main.m to analyze, and not .m files in several subdirectories like Classes, Menus, e.t.c.I assumed that those path arguments would be needed to tell it to look inside subdirectories, but adding `Classes` or `./Classes`did not have the desired effect. Any ideas?
rudifa
Ahh, that's because the -b options simply iterates through all the projects it finds and looks for .m files in the project directory (that is, it isn't recursive). I've quickly modified it so that it's recursive (but I haven't tested it, really). Check this out: http://gist.github.com/339953 - let me know if it works.
rlotun
rlotun, thank you for looking at this.I tried it ...(1) Your file is missing the leading # in '#!/usr/bin/env python'(2) After the fix, it runs into a trouble with the directory .git which is in my Xcode project directory : `... line 158, in handle_m for fileName in os.listdir(path):OSError: [Errno 2] No such file or directory: '.git'`
rudifa
I've made the fix for 1) and skipped hidden directories (dirs that begin with a '.') to handle 2). Please try that?
rlotun
rlotun, ça continue (pardon my French...) : now the updated script chokes on the next directory (in alphabetical order) : `OSError: [Errno 2] No such file or directory: 'build'`. Did you try it at all in a typical Xcode directory?
rudifa
As you rightly pointed out - I didn't test it, and simply relied on my viewing of the code. I ran it on an actual Xcode project, and fixed a few bugs having to do with hidden directories and building intermediate paths - see the updated gist. The script now runs without errors.
rlotun
call it progress ... now the script does not die, but `$ diffstrings_recursive.py -b .` echoes `genstrings main.m -o /Users/rudifarkas/iPhoneDev/RudisProjects/xxx26/build/i18n` and produces an empty directory i18n. :-(
rudifa