Made the code more robust. release-0.5.0

Wed, 01 Jan 2014 19:47:09 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 01 Jan 2014 19:47:09 +0100
changeset 20
8b4c08b95279
parent 19
e245c6797cee
child 21
dd382aa280e9

Made the code more robust.

ChangeLog file | annotate | diff | comparison | revisions
PluginSplitMergeCamelCase.py file | annotate | diff | comparison | revisions
PluginSplitMergeCamelCase.zip file | annotate | diff | comparison | revisions
--- a/ChangeLog	Wed Jan 01 17:30:50 2014 +0100
+++ b/ChangeLog	Wed Jan 01 19:47:09 2014 +0100
@@ -1,5 +1,8 @@
 ChangeLog
 ---------
+Version 0.5.0:
+- bug fixes
+
 Version 0.4.0:
 - always add the entry to the tools menu and disable it, if prerequisites
   are not fulfilled
--- a/PluginSplitMergeCamelCase.py	Wed Jan 01 17:30:50 2014 +0100
+++ b/PluginSplitMergeCamelCase.py	Wed Jan 01 19:47:09 2014 +0100
@@ -20,7 +20,7 @@
 author = "Detlev Offenbach <detlev@die-offenbachs.de>"
 autoactivate = True
 deactivateable = True
-version = "0.4.0"
+version = "0.5.0"
 className = "SplitMergeCamelCasePlugin"
 packageName = "SplitMergeCamelCase"
 shortDescription = "Split, merge or convert camel case text"
@@ -211,11 +211,12 @@
             return
         
         text = editor.selectedText()
-        newText = re.sub(r"([A-Z])", r" \1", text)
-        if newText.startswith(" "):
-            newText = newText[1:]
-        if newText != text:
-            self.__applyChange(newText, editor)
+        if text:
+            newText = re.sub(r"([A-Z])", r" \1", text)
+            if newText.startswith(" "):
+                newText = newText[1:]
+            if newText != text:
+                self.__applyChange(newText, editor)
     
     def __mergeCamelCase(self):
         """
@@ -226,9 +227,10 @@
             return
         
         text = editor.selectedText()
-        newText = "".join(text.split())
-        if newText != text:
-            self.__applyChange(newText, editor)
+        if text:
+            newText = "".join(text.split())
+            if newText != text:
+                self.__applyChange(newText, editor)
     
     def __camelCaseToUnderscore(self):
         """
@@ -239,11 +241,12 @@
             return
         
         text = editor.selectedText()
-        newText = re.sub(r"([A-Z])", r"_\1", text).lower()
-        if newText.startswith("_"):
-            newText = newText[1:]
-        if newText != text:
-            self.__applyChange(newText, editor)
+        if text:
+            newText = re.sub(r"([A-Z])", r"_\1", text).lower()
+            if newText.startswith("_"):
+                newText = newText[1:]
+            if newText != text:
+                self.__applyChange(newText, editor)
     
     def __underscoreToCamelCase(self, uppercaseFirst=False):
         """
@@ -257,11 +260,12 @@
             return
         
         text = editor.selectedText()
-        newText = "".join([s.capitalize() for s in text.split("_")])
-        if not uppercaseFirst:
-            newText = newText[0].lower() + newText[1:]
-        if newText != text:
-            self.__applyChange(newText, editor)
+        if text:
+            newText = "".join([s.capitalize() for s in text.split("_")])
+            if not uppercaseFirst:
+                newText = newText[0].lower() + newText[1:]
+            if newText != text:
+                self.__applyChange(newText, editor)
     
     def __underscoreToCamelCaseUppercaseFirst(self):
         """
Binary file PluginSplitMergeCamelCase.zip has changed

eric ide

mercurial