home *** CD-ROM | disk | FTP | other *** search
- #
- # consts.py
- # JunkMatcher
- #
- # Created by Benjamin Han on 2/1/05.
- # Copyright (c) 2005 Benjamin Han. All rights reserved.
- #
-
- # This program is free software; you can redistribute it and/or
- # modify it under the terms of the GNU General Public License
- # as published by the Free Software Foundation; either version 2
- # of the License, or (at your option) any later version.
-
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
-
- # You should have received a copy of the GNU General Public License
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- #!/usr/bin/env python
-
- import sys, os, os.path, shutil, re
-
- ROOT_PATH = '%s/' % os.path.split(os.path.split(os.path.abspath(__file__))[0])[0]
- DEFAULTS_PATH = '%s/Defaults/' % ROOT_PATH
- ENGINE_PATH = '%s/Engine/' % ROOT_PATH
- BIN_PATH = '%s/bin/' % ROOT_PATH
-
- HOMELIB_PATH = os.path.expanduser('~/Library/')
- CONF_PATH = '%sApplication Support/JunkMatcher/' % HOMELIB_PATH
- TMP_PATH = '%stemp/' % CONF_PATH
-
- # make sure we have the user-specific dirs and files
- if os.path.exists(CONF_PATH):
- # check one by one if any file is missing
- for f in os.listdir(DEFAULTS_PATH):
- if not os.path.exists('%s%s' % (CONF_PATH, f)):
- shutil.copy2('%s%s' % (DEFAULTS_PATH, f), '%s%s' % (CONF_PATH, f))
- else:
- # copy the entire Defaults
- shutil.copytree(DEFAULTS_PATH, CONF_PATH)
- if not os.path.exists(TMP_PATH): os.makedirs(TMP_PATH)
-
- pythonSitePath = '%slib/python2.3/site-packages' % ROOT_PATH
- sys.path[0:0] = [ENGINE_PATH, pythonSitePath, '%s/PyObjC' % pythonSitePath, '%s/PyObjC/Foundation' % pythonSitePath]
-
-
- httpPat = re.compile(r'(?i)https?:/?/?[^"\'<> \t\n\r\f\v]+') # allow "http:/site.com" and "http:site.com" too
- mpPat=re.compile(r'\(\?#[^)]+\)') # pattern for names of meta patterns
-
-
- JM_ENGINE_VER = '1.5.5'
-
- DEFAULT_FILE_ENCODING = 'utf8' # encoding used to save files
- DEFAULT_MX_TIMEOUT = 10 # timeout value for finding MX records of domains
- SAFE_SITE_SIZE_RATIO=0.98 # keep this many sites out of sizeLimit (to minimize site database pruning operation)
-
-
- class JMExceptionMetaPattern (Exception):
- def __init__ (self, info):
- self.info = info
-