[sugar] [PATCH controlpanel] Use os.path.splitext() to remove file extensions, not str.strip().
Chris Ball
cjb at laptop.org
Wed Jun 25 23:41:43 EDT 2008
Hi,
Calling string.strip(".py") has two problems: strip() looks for the
chars you pass separately rather than consecutively, and it works at
both the start and end of string:
>>> a = "power.py"
>>> a.strip(".py")
'ower'
Thanks,
- Chris.
From: Chris Ball <cjb at laptop.org>
Date: Wed, 25 Jun 2008 23:22:41 -0400
Subject: [PATCH] Use os.path.splitext() to remove file extensions, not str.strip().
---
src/controlpanel/gui.py | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/controlpanel/gui.py b/src/controlpanel/gui.py
index b07687f..a1e8876 100644
--- a/src/controlpanel/gui.py
+++ b/src/controlpanel/gui.py
@@ -197,7 +197,7 @@ class ControlPanel(gtk.Window):
for name in names:
if name.endswith('.py') and name != '__init__.py':
- tmp = name.strip('.py')
+ tmp = os.path.splitext(name)[0]
mod = __import__('.'.join(subpath) + '.' + tmp, globals(),
locals(), [tmp])
view_class_str = getattr(mod, 'CLASS', None)
@@ -224,7 +224,7 @@ class ControlPanel(gtk.Window):
for name in names:
if name.endswith('.py') and name != '__init__.py':
- tmp = name.strip('.py')
+ tmp = os.path.splitext(name)[0]
if tmp in options:
mod = __import__('.'.join(subpath) + '.' + tmp,
globals(), locals(), [tmp])
--
1.5.4.3
More information about the Sugar
mailing list