[pitivi] mainwindow: Reuse in_devel from configure



commit 3201fe781c009ca157990314049a8c9e77f38c10
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Thu Jan 30 13:49:04 2014 +0100

    mainwindow: Reuse in_devel from configure

 pitivi/configure.py.in |    9 ++++++---
 pitivi/mainwindow.py   |    4 ++--
 pitivi/utils/misc.py   |   13 -------------
 tests/runtests.py      |    4 ++--
 4 files changed, 10 insertions(+), 20 deletions(-)
---
diff --git a/pitivi/configure.py.in b/pitivi/configure.py.in
index 263a0ea..61c7b3d 100644
--- a/pitivi/configure.py.in
+++ b/pitivi/configure.py.in
@@ -31,7 +31,10 @@ def _get_root_dir():
     return '/'.join(os.path.dirname(os.path.abspath(__file__)).split('/')[:-1])
 
 
-def _in_devel():
+def in_devel():
+    """
+    Returns whether the app is run from a git checkout.
+    """
     rd = _get_root_dir()
     return os.path.exists(os.path.join(rd, '.git'))
 
@@ -45,14 +48,14 @@ RELEASES_URL = 'http://pitivi.org/releases.txt'
 APPMANUALURL_ONLINE = 'http://www.pitivi.org/manual'
 
 
-if _in_devel():
+if in_devel():
     APPMANUALURL_OFFLINE = 'ghelp://%s' % os.path.join(_get_root_dir(), 'help/C')
 else:
     APPMANUALURL_OFFLINE = 'help:pitivi'
 
 
 def get_data_dir():
-    if _in_devel():
+    if in_devel():
         datadir = os.path.join(_get_root_dir(), "data")
     elif os.getenv("PITIVI_TOP_LEVEL_DIR"):
         top_level = os.getenv("PITIVI_TOP_LEVEL_DIR")
diff --git a/pitivi/mainwindow.py b/pitivi/mainwindow.py
index 26bac6a..8692e3f 100644
--- a/pitivi/mainwindow.py
+++ b/pitivi/mainwindow.py
@@ -40,7 +40,7 @@ from gi.repository import GdkPixbuf
 from gi.repository.GstPbutils import InstallPluginsContext, install_plugins_async
 
 from pitivi.clipproperties import ClipProperties
-from pitivi.configure import pitivi_version, APPNAME, APPURL, get_pixmap_dir, get_ui_dir
+from pitivi.configure import in_devel, pitivi_version, APPNAME, APPURL, get_pixmap_dir, get_ui_dir
 from pitivi.effects import EffectListWidget
 from pitivi.mediafilespreviewer import PreviewWidget
 from pitivi.medialibrary import MediaLibraryWidget
@@ -50,7 +50,7 @@ from pitivi.timeline.timeline import TimelineContainer
 from pitivi.titleeditor import TitleEditor
 from pitivi.transitions import TransitionsListWidget
 from pitivi.utils.loggable import Loggable
-from pitivi.utils.misc import in_devel, show_user_manual, path_from_uri
+from pitivi.utils.misc import show_user_manual, path_from_uri
 from pitivi.utils.ui import info_name, beautify_time_delta, SPACING, \
     beautify_length
 from pitivi.viewer import ViewerContainer
diff --git a/pitivi/utils/misc.py b/pitivi/utils/misc.py
index 2e8dbdf..85e2d22 100644
--- a/pitivi/utils/misc.py
+++ b/pitivi/utils/misc.py
@@ -101,19 +101,6 @@ def bin_contains(bin, element):
     return False
 
 
-def in_devel():
-    """
-    Returns True if the current Pitivi instance is run from a git checkout
-    """
-    try:
-        # This code is similar to configure.py.in, but we go up 3 dir levels
-        _parent = os.path.dirname
-        root_dir = _parent(_parent(_parent(os.path.abspath(__file__))))
-        return os.path.exists(os.path.join(root_dir, '.git'))
-    except:
-        return False
-
-
 #------------------------------ URI helpers   --------------------------------#
 def isWritable(path):
     """Check if the file/path is writable"""
diff --git a/tests/runtests.py b/tests/runtests.py
index e65f0b6..6644e57 100644
--- a/tests/runtests.py
+++ b/tests/runtests.py
@@ -26,8 +26,8 @@ def _tests_suite():
 
 
 def get_pitivi_dir():
-    from pitivi.configure import _in_devel
-    if _in_devel():
+    from pitivi.configure import in_devel
+    if in_devel():
         # We know exactly where the top dir.
         tests_dir = os.path.dirname(os.path.abspath(__file__))
         pitivi_dir = os.path.join(tests_dir, os.path.pardir)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]