| 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 | """ |
|---|
| 11 | from os.path import abspath, join, dirname, pardir, isfile |
|---|
| 12 | import sys |
|---|
| 13 | |
|---|
| 14 | # set to None first because the installation replaces this |
|---|
| 15 | # with the path to the installed zine library. |
|---|
| 16 | ZINE_LIB = None |
|---|
| 17 | |
|---|
| 18 | if ZINE_LIB is None: |
|---|
| 19 | ZINE_LIB = abspath(join(dirname(__file__), pardir)) |
|---|
| 20 | |
|---|
| 21 | # make sure we load the correct zine |
|---|
| 22 | sys.path.insert(0, ZINE_LIB) |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | def 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.