[Sugar-devel] [PATCH] make 'setup.py genpot' produce a pot without a full path in filenames #2508

Simon Schampijer simon at schampijer.de
Mon Nov 29 07:21:03 EST 2010


On 11/27/2010 07:13 PM, Sascha Silbe wrote:
> Excerpts from Simon Schampijer's message of Fri Nov 26 16:22:52 +0100 2010:
>
> [src/sugar/activity/bundlebuilder.py]
>> @@ -362,7 +362,7 @@ def cmd_genpot(config, args):
>>       for root, dirs_dummy, files in os.walk(config.source_dir):
>>           for file_name in files:
>>               if file_name.endswith('.py'):
>> -                python_files.append(os.path.join(root, file_name))
>> +                python_files.append(file_name)
>
> This is an incomplete revert of 6f210f0 [1]. Has SL#391 [2] been
> addressed in a different way now?
>
> Sascha

Good catch. So the code we have in git now does handle sub directories. 
The issue is that we use os.getcwd() when we construct the Config 
(config.source_dir).

One way of dealing with it would be to use relpath for substituting the 
part before curdir.

diff --git a/src/sugar/activity/bundlebuilder.py 
b/src/sugar/activity/bundlebuilder.py
index 5f32477..ac76a46 100644
--- a/src/sugar/activity/bundlebuilder.py
+++ b/src/sugar/activity/bundlebuilder.py
@@ -360,7 +360,9 @@ def cmd_genpot(config, args):
      for root, dirs_dummy, files in os.walk(config.source_dir):
          for file_name in files:
              if file_name.endswith('.py'):
-                python_files.append(os.path.join(root, file_name))
+                relpath = os.path.relpath(os.path.join(root, file_name),
+                                          config.source_dir)
+                python_files.append(relpath)


Regards,
    Simon


More information about the Sugar-devel mailing list