コード例 #1
0
    def get_commands(self, option_id):                                     
        # paths for which to run expand_glob_join
        egj = []    # expand_glob_join을 사용하기 위한 경로를 저장하는 용도
        if 'recent_documents' == option_id:       # option_id가 recent_documents(최근 문서) 이면
            egj.append(
                "user/registry/data/org/openoffice/Office/Histories.xcu") # egj에 경로를 추가
            egj.append(
                "user/registry/cache/org.openoffice.Office.Histories.dat") # egj에 경로를 추가

        if 'recent_documents' == option_id and not 'cache' == option_id:   # option_id가 recent_documents 이고 cache가 아니면
            egj.append("user/registry/cache/org.openoffice.Office.Common.dat")  # 다음 경로를 추가

        for egj_ in egj:    # egj에 들어있는 경로를 반복
            for prefix in self.prefixes:  # prefixes에 저장된 경로를 반복
                for path in FileUtilities.expand_glob_join(prefix, egj_): # prefix와 egj의 경로를 os형식에 맞게 연결하고
                                                                          # prefix와 egj의 경로에 환경변수가 있으면 확장한다음
                                                                          # 경로의 "~"을 사용자 디렉토리의 절대경로로 대체한다.
                                                    # 대체한 경로에 대응되는 모든 파일 및 디렉터리의 리스트를 이터레이터로 반환한 것을 반복
                    if 'nt' == os.name:                # os 이름 확인 
                        path = os.path.normpath(path)  # path의 경로를 정규화 ( 현재 디렉터리"."나 상위 디렉터리".."같은 구분자를 최대한 삭제)
                    if os.path.lexists(path):          # 경로의 파일이 존재하는지 확인
                        yield Command.Delete(path)     # 존재하면 삭제

        if 'cache' == option_id:     # option_id가 캐시일때
            dirs = []           
            for prefix in self.prefixes:      # prefixes에 저장된 경로 반복
                dirs += FileUtilities.expand_glob_join( # prefixies에 저장된 경로와 user/registry/cache/ 를 os형식에 맞게 연결하고  
                    prefix, "user/registry/cache/")     # 확장한다음 dirs에 추가
            for dirname in dirs:                        # dir에 저장된 경로 반복
                if 'nt' == os.name:                     # os가 윈도우NT면
                    dirname = os.path.normpath(dirname) # 경로를 정규화해서 dirname에 저장
                for filename in children_in_directory(dirname, False): 
                    yield Command.Delete(filename) # filename을 삭제

        if 'recent_documents' == option_id:  # option_id가 최근 문서일 경우
            for prefix in self.prefixes:     
                for path in FileUtilities.expand_glob_join(prefix, "user/registry/data/org/openoffice/Office/Common.xcu"):
                    # prefixies에 저장된 경로와 user/registry/data/org/openoffice/Office/Common.xcu를 연결하고 확장한다음 반복
                    if os.path.lexists(path): # path가 존재하는지 확인
                        yield Command.Function(path,
                                               Special.delete_ooo_history, 
                                               _('Delete the usage history')) 
                # ~/.openoffice.org/3/user/registrymodifications.xcu
                #       Apache OpenOffice.org 3.4.1 from openoffice.org on Ubuntu 13.04
                # %AppData%\OpenOffice.org\3\user\registrymodifications.xcu
                # Apache OpenOffice.org 3.4.1 from openoffice.org on Windows XP
                for path in FileUtilities.expand_glob_join(prefix, "user/registrymodifications.xcu"):
                    if os.path.lexists(path):
                        yield Command.Function(path,
                                               Special.delete_office_registrymodifications,
                                               _('Delete the usage history'))
コード例 #2
0
    def get_commands(self, option_id):
        # paths for which to run expand_glob_join
        egj = []
        if 'recent_documents' == option_id:
            egj.append(
                "user/registry/data/org/openoffice/Office/Histories.xcu")
            egj.append(
                "user/registry/cache/org.openoffice.Office.Histories.dat")

        if 'recent_documents' == option_id and not 'cache' == option_id:
            egj.append("user/registry/cache/org.openoffice.Office.Common.dat")

        for egj_ in egj:
            for prefix in self.prefixes:
                for path in FileUtilities.expand_glob_join(prefix, egj_):
                    if 'nt' == os.name:
                        path = os.path.normpath(path)
                    if os.path.lexists(path):
                        yield Command.Delete(path)

        if 'cache' == option_id:
            dirs = []
            for prefix in self.prefixes:
                dirs += FileUtilities.expand_glob_join(prefix,
                                                       "user/registry/cache/")
            for dirname in dirs:
                if 'nt' == os.name:
                    dirname = os.path.normpath(dirname)
                for filename in children_in_directory(dirname, False):
                    yield Command.Delete(filename)

        if 'recent_documents' == option_id:
            for prefix in self.prefixes:
                for path in FileUtilities.expand_glob_join(
                        prefix,
                        "user/registry/data/org/openoffice/Office/Common.xcu"):
                    if os.path.lexists(path):
                        yield Command.Function(path,
                                               Special.delete_ooo_history,
                                               _('Delete the usage history'))
                # ~/.openoffice.org/3/user/registrymodifications.xcu
                #       Apache OpenOffice.org 3.4.1 from openoffice.org on Ubuntu 13.04
                # %AppData%\OpenOffice.org\3\user\registrymodifications.xcu
                # Apache OpenOffice.org 3.4.1 from openoffice.org on Windows XP
                for path in FileUtilities.expand_glob_join(
                        prefix, "user/registrymodifications.xcu"):
                    if os.path.lexists(path):
                        yield Command.Function(
                            path, Special.delete_office_registrymodifications,
                            _('Delete the usage history'))
コード例 #3
0
ファイル: Cleaner.py プロジェクト: tstenner/bleachbit
    def get_commands(self, option_id):
        # paths for which to run expand_glob_join
        egj = []
        if 'recent_documents' == option_id:
            egj.append(
                "user/registry/data/org/openoffice/Office/Histories.xcu")
            egj.append(
                "user/registry/cache/org.openoffice.Office.Histories.dat")

        if 'recent_documents' == option_id and not 'cache' == option_id:
            egj.append("user/registry/cache/org.openoffice.Office.Common.dat")

        for egj_ in egj:
            for prefix in self.prefixes:
                for path in FileUtilities.expand_glob_join(prefix, egj_):
                    if 'nt' == os.name:
                        path = os.path.normpath(path)
                    if os.path.lexists(path):
                        yield Command.Delete(path)

        if 'cache' == option_id:
            dirs = []
            for prefix in self.prefixes:
                dirs += FileUtilities.expand_glob_join(
                    prefix, "user/registry/cache/")
            for dirname in dirs:
                if 'nt' == os.name:
                    dirname = os.path.normpath(dirname)
                for filename in children_in_directory(dirname, False):
                    yield Command.Delete(filename)

        if 'recent_documents' == option_id:
            for prefix in self.prefixes:
                for path in FileUtilities.expand_glob_join(prefix, "user/registry/data/org/openoffice/Office/Common.xcu"):
                    if os.path.lexists(path):
                        yield Command.Function(path,
                                               Special.delete_ooo_history,
                                               _('Delete the usage history'))
                # ~/.openoffice.org/3/user/registrymodifications.xcu
                #       Apache OpenOffice.org 3.4.1 from openoffice.org on Ubuntu 13.04
                # %AppData%\OpenOffice.org\3\user\registrymodifications.xcu
                # Apache OpenOffice.org 3.4.1 from openoffice.org on Windows XP
                for path in FileUtilities.expand_glob_join(prefix, "user/registrymodifications.xcu"):
                    if os.path.lexists(path):
                        yield Command.Function(path,
                                               Special.delete_office_registrymodifications,
                                               _('Delete the usage history'))
コード例 #4
0
ファイル: Cleaner.py プロジェクト: brahmastra2016/bleachbit
    def get_commands(self, option_id):
        files = []
        # backup files
        if 'backup' == option_id:
            bookmark_bu_dir = os.path.join(self.profile_dir, 'bookmarkbackups')
            files += FileUtilities.expand_glob_join(bookmark_bu_dir, "*.json")
            files += FileUtilities.expand_glob_join(
                bookmark_bu_dir, "*.jsonlz4")
        # browser cache
        cache_base = None
        if 'posix' == os.name:
            cache_base = self.profile_dir
        elif 'nt' == os.name:
            cache_base = "$localappdata\\Mozilla\\Firefox\\Profiles\\*.default*"
        if 'cache' == option_id:
            dirs = FileUtilities.expand_glob_join(cache_base, "Cache*")
            dirs += FileUtilities.expand_glob_join(cache_base, "OfflineCache")
            if 'nt' == os.name:
                dirs += FileUtilities.expand_glob_join(
                    cache_base, "jumpListCache")  # Windows 8
            if 'posix' == os.name:
                # This path is whitelisted under the System - Cache cleaner,
                # so it can be cleaned here.
                dirs += [expanduser('~/.cache/mozilla')]
            for dirname in dirs:
                for filename in children_in_directory(dirname, False):
                    yield Command.Delete(filename)
            # Necko Predictive Network Actions
            # https://wiki.mozilla.org/Privacy/Reviews/Necko
            files += FileUtilities.expand_glob_join(
                self.profile_dir, "netpredictions.sqlite")
        # cookies
        if 'cookies' == option_id:
            files += FileUtilities.expand_glob_join(
                self.profile_dir, "cookies.txt")
            files += FileUtilities.expand_glob_join(
                self.profile_dir, "cookies.sqlite")
        # crash reports
        if 'posix' == os.name:
            crashdir = expanduser("~/.mozilla/firefox/Crash Reports")
        if 'nt' == os.name:
            crashdir = expandvars(
                "$USERPROFILE\\Application Data\\Mozilla\\Firefox\\Crash Reports")
        if 'crash_reports' == option_id:
            for filename in children_in_directory(crashdir, False):
                files += [filename]
            files += FileUtilities.expand_glob_join(
                self.profile_dir, "minidumps/*.dmp")
        # DOM storage
        if 'dom' == option_id:
            files += FileUtilities.expand_glob_join(
                self.profile_dir, "webappsstore.sqlite")

        # download history
        if 'download_history' == option_id:
            # Firefox version 1
            files += FileUtilities.expand_glob_join(
                self.profile_dir, "downloads.rdf")
            # Firefox version 3
            files += FileUtilities.expand_glob_join(
                self.profile_dir, "downloads.sqlite")
        # forms
        if 'forms' == option_id:
            files += FileUtilities.expand_glob_join(
                self.profile_dir, "formhistory.dat")
            files += FileUtilities.expand_glob_join(
                self.profile_dir, "formhistory.sqlite")
        # passwords
        if 'passwords' == option_id:
            # http://kb.mozillazine.org/Password_Manager
            files += FileUtilities.expand_glob_join(
                self.profile_dir, "signons.txt")
            files += FileUtilities.expand_glob_join(
                self.profile_dir, "signons[2-3].txt")
            files += FileUtilities.expand_glob_join(
                self.profile_dir, "signons.sqlite")
            files += FileUtilities.expand_glob_join(
                self.profile_dir, "logins.json")
        # session restore
        if 'session_restore' == option_id:
            # Names include sessionstore.js, sessionstore.bak,
            # sessionstore.bak-20140715214327, sessionstore-1.js
            files += FileUtilities.expand_glob_join(
                self.profile_dir, "sessionstore*.js")
            files += FileUtilities.expand_glob_join(
                self.profile_dir, "sessionstore.bak*")
            ss_bu_dir = os.path.join(self.profile_dir, 'sessionstore-backups')
            files += FileUtilities.expand_glob_join(
                ss_bu_dir, 'previous.js')
            files += FileUtilities.expand_glob_join(
                ss_bu_dir, 'upgrade.js-20*')
            files += FileUtilities.expand_glob_join(
                ss_bu_dir, 'recovery.js')
            files += FileUtilities.expand_glob_join(
                ss_bu_dir, 'recovery.bak')
        # site-specific preferences
        if 'site_preferences' == option_id:
            files += FileUtilities.expand_glob_join(
                self.profile_dir, "content-prefs.sqlite")

        # URL history
        if 'url_history' == option_id:
            # Firefox version 1
            files += FileUtilities.expand_glob_join(
                self.profile_dir, "history.dat")
            # Firefox 21 on Windows
            if 'nt' == os.name:
                files += FileUtilities.expand_glob_join(
                    cache_base, "thumbnails/*.png")
            # see also function other_cleanup()
        # finish
        for filename in files:
            yield Command.Delete(filename)

        # URL history
        if 'url_history' == option_id:
            for path in FileUtilities.expand_glob_join(self.profile_dir, "places.sqlite"):
                yield Command.Function(path,
                                       Special.delete_mozilla_url_history,
                                       _('Delete the usage history'))

        # vacuum
        if 'vacuum' == option_id:
            paths = []
            paths += FileUtilities.expand_glob_join(
                self.profile_dir, "*.sqlite")
            if not cache_base == self.profile_dir:
                paths += FileUtilities.expand_glob_join(cache_base, "*.sqlite")
            for path in paths:
                yield Command.Function(path,
                                       FileUtilities.vacuum_sqlite3, _("Vacuum"))