incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject [43/50] git commit: [#6534] ticket:449 Use os.path.splitext instead of split
Date Fri, 04 Oct 2013 23:23:49 GMT
[#6534] ticket:449 Use os.path.splitext instead of split


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/905602c2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/905602c2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/905602c2

Branch: refs/heads/tv/6670
Commit: 905602c265aac09107ce6fc10b7856ad9caf96fd
Parents: ba9791e
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Mon Sep 30 17:11:53 2013 +0300
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Fri Oct 4 14:21:24 2013 +0000

----------------------------------------------------------------------
 ForgeImporters/forgeimporters/github/wiki.py | 51 ++++++++++-------------
 1 file changed, 21 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/905602c2/ForgeImporters/forgeimporters/github/wiki.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/wiki.py b/ForgeImporters/forgeimporters/github/wiki.py
index 9b024c6..163f657 100644
--- a/ForgeImporters/forgeimporters/github/wiki.py
+++ b/ForgeImporters/forgeimporters/github/wiki.py
@@ -15,6 +15,7 @@
 #       specific language governing permissions and limitations
 #       under the License.
 
+import os
 import re
 from datetime import datetime
 from tempfile import mkdtemp
@@ -117,26 +118,25 @@ class GitHubWikiImporter(ToolImporter):
     tool_label = 'Wiki'
     tool_description = 'Import your wiki from GitHub'
     tool_option = {"import_history": "Import history"}
+    mediawiki_exts = ['.wiki', '.mediawiki']
     # List of supported formats https://github.com/gollum/gollum/wiki#page-files
     supported_formats = [
-            'asciidoc',
-            'creole',
-            'markdown',
-            'mdown',
-            'mkdn',
-            'mkd',
-            'md',
-            'org',
-            'pod',
-            'rdoc',
-            'rest.txt',
-            'rst.txt',
-            'rest',
-            'rst',
-            'textile',
-            'mediawiki',
-            'wiki'
-    ]
+            '.asciidoc',
+            '.creole',
+            '.markdown',
+            '.mdown',
+            '.mkdn',
+            '.mkd',
+            '.md',
+            '.org',
+            '.pod',
+            '.rdoc',
+            '.rest.txt',
+            '.rst.txt',
+            '.rest',
+            '.rst',
+            '.textile',
+    ] + mediawiki_exts
 
     def import_tool(self, project, user, project_name=None, mount_point=None, mount_label=None,
user_name=None,
                     tool_option=None, **kw):
@@ -182,11 +182,7 @@ class GitHubWikiImporter(ToolImporter):
             self._make_page(text, filename, commit)
 
     def _make_page(self, text, filename, commit):
-        name_and_ext = filename.split('.', 1)
-        if len(name_and_ext) == 1:
-            name, ext = name_and_ext[0], None
-        else:
-            name, ext = name_and_ext
+        name, ext = os.path.splitext(filename)
         if ext and ext not in self.supported_formats:
             log.info('Not a wiki page %s. Skipping.' % filename)
             return
@@ -236,13 +232,8 @@ class GitHubWikiImporter(ToolImporter):
         except ImportError:
             html2text = None
 
-        name_and_ext = filename.split('.', 1)
-        if len(name_and_ext) == 1:
-            name, ext = name_and_ext[0], None
-        else:
-            name, ext = name_and_ext
-
-        if ext and ext in ['wiki', 'mediawiki']:
+        name, ext = os.path.splitext(filename)
+        if ext and ext in self.mediawiki_exts:
             if html2text:
                 text = mediawiki2markdown(text)
                 text = self.convert_gollum_tags(text)


Mime
View raw message