def testThis(self): p = Path(__file__) self.assertTrue(p.isfile()) self.assertFalse(p.isdir()) c = Path.cwd() self.assertNotEqual(p, c) self.assertTrue(c.isdir())
def testThis(self): p = Path(__file__) self.assertTrue(p.isfile()) self.assertFalse(p.isdir()) c = Path.cwd() self.assertNotEqual(p,c) self.assertTrue(c.isdir())
def get_settings(name=None, settings=None, **params): '''Extra configuration parameters,can be passed as key-value pairs: :parameter name: file or directory name which specifies the application root-directory. :parameter settings: optional settings file name specified as a dotted path relative ro the application directory. Default ``None`` :parameter params: key-value pairs which override the values in the settings file. ''' name = Path(name if name is not None else os.getcwd()) if name.isdir(): appdir = name elif name.isfile(): appdir = name.realpath().parent else: try: mod = import_module(name) appdir = Path(mod.__path__[0]) except ImportError: raise ValueError( 'Could not find directory or file {0}'.format(name)) site_path = appdir.realpath() base, name = site_path.split() if base not in sys.path: sys.path.insert(0, str(base)) # Import settings if settings: if '.' in settings: settings_module_name = settings else: sett = '{0}.py'.format(os.path.join(site_path, settings)) if os.path.isfile(sett): settings_module_name = '{0}.{1}'.format(name, settings) else: settings_module_name = settings else: settings_module_name = None return Config(settings_module_name, SITE_DIRECTORY=site_path, SITE_MODULE=name, **params)
def get_settings(name=None, settings=None, **params): '''Extra configuration parameters,can be passed as key-value pairs: :parameter name: file or directory name which specifies the application root-directory. :parameter settings: optional settings file name specified as a dotted path relative ro the application directory. Default ``None`` :parameter params: key-value pairs which override the values in the settings file. ''' name = Path(name if name is not None else os.getcwd()) if name.isdir(): appdir = name elif name.isfile(): appdir = name.realpath().parent else: try: mod = import_module(name) appdir = Path(mod.__path__[0]) except ImportError: raise ValueError( 'Could not find directory or file {0}'.format(name)) site_path = appdir.realpath() base, name = site_path.split() if base not in sys.path: sys.path.insert(0, str(base)) # Import settings if settings: if '.' in settings: settings_module_name = settings else: sett = '{0}.py'.format(os.path.join(site_path,settings)) if os.path.isfile(sett): settings_module_name = '{0}.{1}'.format(name, settings) else: settings_module_name = settings else: settings_module_name = None return Config(settings_module_name, SITE_DIRECTORY=site_path, SITE_MODULE=name, **params)
def testAdd2Python(self): p = Path('/sdjc/scdskjcdnsd/dhjdhjdjksdjksdksd') module = p.add2python('djpcms') self.assertEqual(module, 'djpcms') self.assertRaises(ValueError, p.add2python, 'kaputttt')
def testDir(self): c = Path.cwd() self.assertEqual(c,c.dir()) c = Path('/sdjc/scdskjcdnsd/dhjdhjdjksdjksdksd') self.assertFalse(c.exists()) self.assertRaises(ValueError,c.dir)
def testDir(self): c = Path.cwd() self.assertEqual(c, c.dir()) c = Path('/sdjc/scdskjcdnsd/dhjdhjdjksdjksdksd') self.assertFalse(c.exists()) self.assertRaises(ValueError, c.dir)
def get_docroot(self, djp, lang, version): docroot = Path(self.DOCS_PICKLE_ROOT).child( *self.get_path_args(lang, version)) if not docroot.exists(): raise djp.http.Http404() return docroot