File: PyMcaDataDir.py

package info (click to toggle)
pymca 4.7.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 52,352 kB
  • ctags: 9,570
  • sloc: python: 116,490; ansic: 18,322; cpp: 826; sh: 57; xml: 24; makefile: 19
file content (53 lines) | stat: -rw-r--r-- 2,158 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import os
# this will be filled by the setup
PYMCA_DATA_DIR = 'DATA_DIR_FROM_SETUP'
# This is to be filled by the setup
PYMCA_DOC_DIR = 'DOC_DIR_FROM_SETUP'
# what follows is only used in frozen versions
if not os.path.exists(PYMCA_DATA_DIR):
    tmp_dir = os.path.dirname(__file__)
    basename = os.path.basename(PYMCA_DATA_DIR)
    PYMCA_DATA_DIR = os.path.join(tmp_dir,basename)
    while len(PYMCA_DATA_DIR) > 14:
        if os.path.exists(PYMCA_DATA_DIR):
            break
        tmp_dir = os.path.dirname(tmp_dir)
        PYMCA_DATA_DIR = os.path.join(tmp_dir, basename)

# this is used in build directory
if not os.path.exists(PYMCA_DATA_DIR):
    tmp_dir = os.path.dirname(__file__)
    basename = os.path.basename(PYMCA_DATA_DIR)
    PYMCA_DATA_DIR = os.path.join(tmp_dir, "PyMca", basename)
    while len(PYMCA_DATA_DIR) > 14:
        if os.path.exists(PYMCA_DATA_DIR):
            break
        tmp_dir = os.path.dirname(tmp_dir)
        PYMCA_DATA_DIR = os.path.join(tmp_dir, "PyMca", basename)

if not os.path.exists(PYMCA_DATA_DIR):
    raise IOError('%s directory not found' % basename)
# do the same for the directory containing HTML files
if not os.path.exists(PYMCA_DOC_DIR):
    tmp_dir = os.path.dirname(__file__)
    basename = os.path.basename(PYMCA_DOC_DIR)
    PYMCA_DOC_DIR = os.path.join(tmp_dir,basename)
    while len(PYMCA_DOC_DIR) > 14:
        if os.path.exists(PYMCA_DOC_DIR):
            break
        tmp_dir = os.path.dirname(tmp_dir)
        PYMCA_DOC_DIR = os.path.join(tmp_dir, basename)
if not os.path.exists(PYMCA_DOC_DIR):
    raise IOError('%s directory not found' % basename)

if not os.path.exists(PYMCA_DOC_DIR):
    tmp_dir = os.path.dirname(__file__)
    basename = os.path.basename(PYMCA_DOC_DIR)
    PYMCA_DOC_DIR = os.path.join(tmp_dir, "PyMca", basename)
    while len(PYMCA_DOC_DIR) > 14:
        if os.path.exists(PYMCA_DOC_DIR):
            break
        tmp_dir = os.path.dirname(tmp_dir)
        PYMCA_DOC_DIR = os.path.join(tmp_dir, "PyMca", basename)
if not os.path.exists(PYMCA_DOC_DIR):
    raise IOError('%s directory not found' % basename)