Exemplo n.º 1
0
 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())
Exemplo n.º 2
0
 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())
Exemplo n.º 3
0
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)
Exemplo n.º 4
0
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)
Exemplo n.º 5
0
 def testAdd2Python(self):
     p = Path('/sdjc/scdskjcdnsd/dhjdhjdjksdjksdksd')
     module = p.add2python('djpcms')
     self.assertEqual(module, 'djpcms')
     self.assertRaises(ValueError, p.add2python, 'kaputttt')
Exemplo n.º 6
0
 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)
Exemplo n.º 7
0
 def testAdd2Python(self):
     p = Path('/sdjc/scdskjcdnsd/dhjdhjdjksdjksdksd')
     module = p.add2python('djpcms')
     self.assertEqual(module, 'djpcms')
     self.assertRaises(ValueError, p.add2python, 'kaputttt')
Exemplo n.º 8
0
 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)
Exemplo n.º 9
0
 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