root/tags/release-0.6.2/lib/info.py

Revision 1, 2.7 kB (checked in by mjoc, 2 years ago)

Initial import.

Line 
1 # OpenDict
2 #
3 # OpenDict
4 # Copyright (c) 2003-2006 Martynas Jocius <mjoc@akl.lt>
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your opinion) any later version.
10 #
11 # This program is distributed in the hope that will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MECHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more detals.
15 #
16 # You shoud have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 # 02111-1307 USA
20 #
21
22 import sys
23 import os
24 import imp
25
26 # OpenDict version
27 VERSION = "0.6.2"
28
29 # File system objects
30 __OPENDICT_LOCAL_DIR = ".opendict"
31
32 __DICT_DIR = "dictionaries"
33 __PLUGIN_DICT_DIR = "plugins" # plugin dictionaries
34 __PLAIN_DICT_DIR = "plain" # used for downloaded dictionaries
35 __PLAIN_DICT_CONFIG_DIR = "conf"
36 __PLAIN_DICT_FILE_DIR = "file"
37 _PLAIN_DICT_DATA_DIR = "data"
38
39 LOG_DIR = 'log'
40
41 PLAIN_DICT_DIR = os.path.join(__DICT_DIR, __PLAIN_DICT_DIR)
42 PLUGIN_DICT_DIR = os.path.join(__DICT_DIR, __PLUGIN_DICT_DIR)
43
44 GLOBAL_HOME = None
45 LOCAL_HOME = None
46      
47 ## if sys.platform == "win32":
48 ##    import _winreg
49 ##    x = _winreg.ConnectRegistry(None, _winreg.HKEY_CURRENT_USER)
50 ##    try:
51 ##       y = _winreg.OpenKey(x, "SOFTWARE\OpenDict\Settings")
52 ##       GLOBAL_HOME = _winreg.QueryValueEx(y, "Path")[0]
53 ##    except:
54 ##       GLOBAL_HOME = "C:\\Program Files\\OpenDict"
55      
56 ##    LOCAL_HOME = GLOBAL_HOME
57
58 ## else:
59 ##    if not os.path.exists(os.path.join(os.environ.get("HOME"),
60 ##                                       __OPENDICT_LOCAL_DIR)):
61 ##       os.mkdir(os.path.join(os.environ.get("HOME"), __OPENDICT_LOCAL_DIR))
62      
63 ##    LOCAL_HOME = os.path.join(os.environ.get("HOME"), __OPENDICT_LOCAL_DIR)
64 ##    GLOBAL_HOME = "/usr/share/opendict"
65
66
67 # main_is_frozen() returns True when running the exe, and False when
68 # running from a script.
69 def main_is_frozen():
70     return (hasattr(sys, "frozen") or # new py2exe
71             hasattr(sys, "importers") # old py2exe
72             or imp.is_frozen("__main__")) # tools/freeze
73
74 if main_is_frozen():
75     GLOBAL_HOME = os.path.realpath(os.path.join(os.path.dirname(\
76         os.path.realpath(__file__)), '../..'))
77 else:
78     GLOBAL_HOME = os.path.realpath(os.path.join(os.path.dirname(\
79         os.path.realpath(__file__)), '..'))
80
81 if sys.platform == 'win32':
82    LOCAL_HOME = GLOBAL_HOME
83 else:
84    LOCAL_HOME = os.path.join(os.environ.get('HOME', GLOBAL_HOME),
85                              __OPENDICT_LOCAL_DIR)
86
87
Note: See TracBrowser for help on using the browser.