Skip to content

Commit

Permalink
[util] new helper funcs: is_py2exe and is_windows
Browse files Browse the repository at this point in the history
  • Loading branch information
iblislin committed Mar 7, 2016
1 parent 63562d3 commit fa8e61e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
8 changes: 4 additions & 4 deletions couchapp/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from couchapp.errors import AppError
from couchapp import localdoc
from couchapp.util import user_path, relpath
from couchapp.util import is_py2exe, is_windows, relpath, user_path

__all__ = ["generate_app", "generate_function", "generate"]

Expand Down Expand Up @@ -185,15 +185,15 @@ def copy_helper(path, directory, tname="templates"):

def find_template_dir(name, directory=''):
paths = ['%s' % name, os.path.join('..', name)]
if hasattr(sys, 'frozen'): # py2exe
if is_py2exe():
modpath = sys.executable
elif sys.platform == "win32" or os.name == "nt":
elif is_windows():
modpath = os.path.join(sys.prefix, "Lib", "site-packages", "couchapp",
"templates")
else:
modpath = __file__

if sys.platform != "win32" and os.name != "nt":
if not is_windows():
default_locations = [
"/usr/share/couchapp/templates/%s" % directory,
"/usr/local/share/couchapp/templates/%s" % directory,
Expand Down
11 changes: 10 additions & 1 deletion couchapp/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,16 @@ def import_module(name, package=None):
__import__(name)
return sys.modules[name]

if os.name == 'nt':

def is_windows():
return sys.platform == 'win32' or os.name == 'nt'


def is_py2exe():
return is_windows() and hasattr(sys, 'frozen')


if is_windows():
from win32com.shell import shell, shellcon

def user_rcpath():
Expand Down

0 comments on commit fa8e61e

Please sign in to comment.