Zine

open source content publishing system


source: scripts/_init_zine.py @ 1279:088d2f519391

Revision 1279:088d2f519391, 1.0 KB checked in by Georg Brandl <georg@…>, 2 years ago (diff)

Update copyright notices.

Line 
1# -*- coding: utf-8 -*-
2"""
3    _init_zine
4    ~~~~~~~~~~
5
6    Helper to locate zine and the instance folder.
7
8    :copyright: (c) 2010 by the Zine Team, see AUTHORS for more details.
9    :license: BSD, see LICENSE for more details.
10"""
11from os.path import abspath, join, dirname, pardir, isfile
12import sys
13
14# set to None first because the installation replaces this
15# with the path to the installed zine library.
16ZINE_LIB = None
17
18if ZINE_LIB is None:
19    ZINE_LIB = abspath(join(dirname(__file__), pardir))
20
21# make sure we load the correct zine
22sys.path.insert(0, ZINE_LIB)
23
24
25def find_instance():
26    """Find the Zine instance."""
27    instance = None
28    if isfile(join('instance', 'zine.ini')):
29        instance = abspath('instance')
30    else:
31        old_path = None
32        path = abspath('.')
33        while old_path != path:
34            path = abspath(join(path, pardir))
35            if isfile(join(path, 'zine.ini')):
36                instance = path
37                break
38            old_path = path
39    return instance
Note: See TracBrowser for help on using the repository browser.