This file is indexed.

/usr/share/opendict/lib/misc.py is in opendict 0.6.6-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#
# OpenDict
# Copyright (c) 2003-2006 Martynas Jocius <martynas.jocius@idiles.com>
# Copyright (c) 2007 IDILES SYSTEMS, UAB <support@idiles.com>
#
# 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 opinion) any later version.
#
# This program is distributed in the hope that will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MECHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more detals.
#
# You shoud 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
#
# Module: misc

import wx
from os.path import *
import string
import traceback
import sys
import os

_ = wx.GetTranslation


#
# FIXME: Remove
#
errors = {1: _("Not found"),
          2: _("Dictionary error, please report to its author"),
          3: _("Syntax error"),
          4: _("You must be connected to the internet to use this dictionary"),
          5: _("Time out"),
          6: _("Bad encoding is set for this dictionary, try another")}


#
# Character Encodings
# FIXME: translations does not work, why?
#
encodings = {_("Unicode (UTF-8)"): "UTF-8",
             _("Western (ISO-8859-1)"): "ISO-8859-1",
             _("Central European (ISO-8859-2)"): "ISO-8859-2",
             _("Nordic (ISO-8859-10)"): "ISO-8859-10",
             _("South European (ISO-8859-3)"): "ISO-8859-3",
             _("Greek (ISO-8859-7)"): "ISO-8859-7",
             _("Baltic (ISO-8859-13)"): "ISO-8859-13",
             _("Cyrillic (KOI8-R)"): "KOI8-R",
             _("Arabic (ISO-8859-6)"): "ISO-8859-6"}

#
# Font faces
#
fontFaces = {"Fixed": "fixed",
             "Helvetica": "helvetica",
             "Courier": "courier",
             "Times": "Times",
             "Verdana": "Verdana",
             "Lucida": "Lucida"}



def numVersion(str):
    """Return a float number made from x.y.z[-preV] version number"""

    nver = str.split('-')[0]
    numbers = nver.split('.')
    try:
        return (float(numbers[0]) + float(numbers[1]) * 0.1 + float(number[2]) * 0.01)
    except:
        return 0.0

def printError():
    print string.join(traceback.format_exception(sys.exc_info()[0],
                                                 sys.exc_info()[1],
                                                 sys.exc_info()[2]), "")


def getTraceback():
    return string.join(traceback.format_exception(sys.exc_info()[0],
                                                 sys.exc_info()[1],
                                                 sys.exc_info()[2]), "")



def getFileSize(path):
    """Returns the size of file in bytes"""
    
    size = -1
    
    try:
        size = os.stat(path)[6]
    except:
        print "ERROR (misc.getFileSize): path '%s' does not exist" % path
    
    return size


def getDirSize(start, followLinks, myDepth, maxDepth):
    """Return total directory size"""
    
    total = 0L
    try:
        dirList = os.listdir(start)
    except:
        if isdir(start):
            print 'ERROR: Cannot list directory %s' % start
        return 0
    
    for item in dirList:
        path = '%s/%s' % (start, item)
        try:
            stats = os.stat(path)
        except:
            print 'ERROR: Cannot stat %s' % path
            continue
        
        total += stats[6]
        if isdir(path) and (followLinks or \
                             (not followLinks and not islink(path))):
            bytes = getDirSize(path, followLinks,
                               myDepth + 1,
                               maxDepth)
            total += bytes

    return total