Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

nickfrez / unb-cli   python

Repository URL to install this package:

Version: 0.0.12 

/ unb / utilities.py

import logging
import os
import sys

from contextlib import contextmanager


logger = logging.getLogger(__name__)


@contextmanager
def push_sys_path(path):
  sys.path.insert(0, path)
  yield
  sys.path.pop(0)


def is_django_project(path):
  cwd = os.getcwd()
  while True:
    if os.path.exists(os.path.join(cwd, 'manage.py')):
      return True
    if cwd == path or cwd == os.path.sep:
      return False
    cwd = os.path.dirname(cwd)
  return False