Ejemplo 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())
Ejemplo 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())
Ejemplo 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)
Ejemplo 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)