def fnmatch(self, name, pattern, isearch_type=None): global migemo_object if isearch_type == None: isearch_type = self.isearch_type # migemoは大文字小文字が混在しているときだけ有効 if isearch_type == "migemo": if pattern.lower() == pattern: isearch_type = "partial" if isearch_type == "partial": return fnmatch.fnmatch(name, '*' + pattern + '*') elif isearch_type == "inaccurate": new_pattern = "*" for ch in pattern: new_pattern += ch + "*" return fnmatch.fnmatch(name, new_pattern) elif isearch_type == "migemo": # 初めて migemo が必要になったときに遅延ロードする if migemo_object == None: dll_path = os.path.join(ckit.getAppExePath(), 'lib') dict_path = os.path.join(ckit.getAppExePath(), 'dict') try: migemo_object = ckit.Migemo(dll_path, dict_path) except ValueError: return fnmatch.fnmatch(name, '*' + pattern + '*') # 検索パターンが変更になったときだけクエリーをかける if self.migemo_pattern != pattern: re_pattern = migemo_object.query(pattern) try: self.migemo_re_object = re.compile(re_pattern, re.IGNORECASE) except Exception as e: # FIXME: # migemo_re_pattern のなかに | や + などの正規表現の特殊文字が入っていたときはエラーになってしまう。 # 例外が発生したときに True を返すことで無理やり対応するが、正しい対応方法を模索する。 if 0: print(ckit.strings["error_regex"], e) return True self.migemo_pattern = pattern self.migemo_re_pattern = re_pattern re_result = self.migemo_re_object.search(name) if re_result: self.migemo_re_result = re_result return re_result != None else: return fnmatch.fnmatch(name, pattern + '*')
def jobHelp(job_item): if ckit.strings.locale == ckit.TranslatedStrings.ja_JP: dirname = "ja" else: dirname = "en" help_path = ckit.joinPath( ckit.getAppExePath(), 'doc\\%s\\index.html' % dirname ) pyauto.shellExecute( None, help_path, "", "" )
def jobHelp(job_item): if ckit.strings.locale == ckit.TranslatedStrings.ja_JP: dirname = "ja" else: dirname = "en" help_path = ckit.joinPath( ckit.getAppExePath(), 'doc\\%s\\index.html' % dirname ) pyauto.shellExecute( None, help_path, "", "" )
def fnmatch( self, name, pattern, isearch_type=None ): global migemo_object if isearch_type==None: isearch_type=self.isearch_type # migemoは大文字小文字が混在しているときだけ有効 if isearch_type=="migemo": if pattern.lower()==pattern: isearch_type="partial" if isearch_type=="partial": return fnmatch.fnmatch( name, '*'+pattern+'*' ) elif isearch_type=="inaccurate": new_pattern = "*" for ch in pattern: new_pattern += ch + "*" return fnmatch.fnmatch( name, new_pattern ) elif isearch_type=="migemo": # 初めて migemo が必要になったときに遅延ロードする if migemo_object==None: dict_path = os.path.join( ckit.getAppExePath(), 'dict' ) try: migemo_object = ckit.Migemo(dict_path) except ValueError: return fnmatch.fnmatch( name, '*'+pattern+'*' ) # 検索パターンが変更になったときだけクエリーをかける if self.migemo_pattern != pattern: re_pattern = migemo_object.query(pattern) try: self.migemo_re_object = re.compile( re_pattern, re.IGNORECASE ) except Exception as e: # FIXME: # migemo_re_pattern のなかに | や + などの正規表現の特殊文字が入っていたときはエラーになってしまう。 # 例外が発生したときに True を返すことで無理やり対応するが、正しい対応方法を模索する。 if 0: print( "正規表現のエラー :", e ) return True self.migemo_pattern = pattern self.migemo_re_pattern = re_pattern re_result = self.migemo_re_object.search(name) if re_result: self.migemo_re_result = re_result return re_result!=None else: return fnmatch.fnmatch( name, pattern+'*' )
def enumThemes(): theme_list = [] theme_parent = os.path.join( ckit.getAppExePath(), 'theme' ) theme_dir_list = os.listdir(theme_parent) for theme_dir in theme_dir_list: if os.path.exists( os.path.join( theme_parent, theme_dir, "theme.ini" ) ): theme_list.append( theme_dir ) return theme_list
def enumThemes(): theme_list = [] theme_parent = os.path.join(ckit.getAppExePath(), 'theme') theme_dir_list = os.listdir(theme_parent) for theme_dir in theme_dir_list: if os.path.exists( os.path.join(theme_parent, theme_dir, "theme.ini")): theme_list.append(theme_dir) return theme_list
def jobHelp(job_item): help_path = os.path.join( ckit.getAppExePath(), 'doc\\index.html' ) pyauto.shellExecute( None, help_path, "", "" )
def jobHelp(job_item): help_path = os.path.join(ckit.getAppExePath(), 'doc\\index.html') pyauto.shellExecute(None, help_path, "", "")
debug = False profile = False option_list, args = getopt.getopt(sys.argv[1:], "dp") for option in option_list: if option[0] == "-d": debug = True elif option[0] == "-p": profile = True #-------------------------------------------------------------------- ckit.registerWindowClass("Keyhac") # exeと同じ位置にある設定ファイルを優先する if os.path.exists(os.path.join(ckit.getAppExePath(), 'config.py')): ckit.setDataPath(ckit.getAppExePath()) else: ckit.setDataPath( os.path.join(ckit.getAppDataPath(), keyhac_resource.keyhac_dirname)) if not os.path.exists(ckit.dataPath()): os.mkdir(ckit.dataPath()) default_config_filename = os.path.join(ckit.getAppExePath(), '_config.py') config_filename = os.path.join(ckit.dataPath(), 'config.py') keyhac_ini.ini_filename = os.path.join(ckit.dataPath(), 'keyhac.ini') # config.py がどこにもない場合は作成する if not os.path.exists(config_filename) and os.path.exists( default_config_filename): shutil.copy(default_config_filename, config_filename)
#-------------------------------------------------------------------- # IPCのために必要でないモジュールはここで import する import shutil import clnch import clnch_mainwindow import clnch_ini import clnch_misc ckit.registerWindowClass( "Clnch" ) ckit.registerCommandInfoConstructor( ckit.CommandInfo ) sys.path[0:0] = [ os.path.join( ckit.getAppExePath(), 'extension' ), ] # exeと同じ位置にある設定ファイルを優先する if os.path.exists( os.path.join( ckit.getAppExePath(), 'config.py' ) ): ckit.setDataPath( ckit.getAppExePath() ) else: ckit.setDataPath( os.path.join( ckit.getAppDataPath(), clnch_resource.clnch_dirname ) ) if not os.path.exists(ckit.dataPath()): os.mkdir(ckit.dataPath()) default_config_filename = os.path.join( ckit.getAppExePath(), '_config.py' ) config_filename = os.path.join( ckit.dataPath(), 'config.py' ) clnch_ini.ini_filename = os.path.join( ckit.dataPath(), 'clnch.ini' ) # config.py がどこにもない場合は作成する
import os import sys import msvcrt import configparser import ckit import keyhac_resource ## @addtogroup ini ## @{ ini = None ini_filename = os.path.join( ckit.getAppExePath(), 'keyhac.ini' ) #-------------------------------------------------------------------- def read(): global ini ini = configparser.RawConfigParser() try: fd = open( ini_filename, "r" ) msvcrt.locking( fd.fileno(), msvcrt.LK_LOCK, 1 ) ini.readfp(fd) fd.close() except Exception as e: pass
import os import sys import msvcrt import configparser import ckit import cmemo_resource ini = None ini_filename = os.path.join( ckit.getAppExePath(), 'cmemo.ini' ) dirty = False #-------------------------------------------------------------------- def read(): global ini global dirty ini = configparser.RawConfigParser() try: fd = open( ini_filename, "r", encoding="utf-8" ) msvcrt.locking( fd.fileno(), msvcrt.LK_LOCK, 1 ) ini.readfp(fd) fd.close() except: pass dirty = False
import os import sys import msvcrt import configparser import ckit import cmemo_resource ini = None ini_filename = os.path.join(ckit.getAppExePath(), 'cmemo.ini') dirty = False #-------------------------------------------------------------------- def read(): global ini global dirty ini = configparser.RawConfigParser() try: fd = open(ini_filename, "r", encoding="utf-8") msvcrt.locking(fd.fileno(), msvcrt.LK_LOCK, 1) ini.readfp(fd) fd.close() except: pass dirty = False
import os import sys import msvcrt import configparser import ckit import keyhac_resource ## @addtogroup ini ## @{ ini = None ini_filename = os.path.join(ckit.getAppExePath(), 'keyhac.ini') #-------------------------------------------------------------------- def read(): global ini ini = configparser.RawConfigParser() try: fd = open(ini_filename, "r") msvcrt.locking(fd.fileno(), msvcrt.LK_LOCK, 1) ini.readfp(fd) fd.close() except Exception as e: pass