Back to index

eyed3  0.6.18
Classes | Functions | Variables
utils Namespace Reference

Classes

class  FileHandler
class  FileWalker

Functions

def versionsToConstant
def versionToString
def constantToVersions
def TRACE_MSG
def strictID3
def itunesCompat
def format_track_time
def format_size
def format_time_delta
def guess_mime_type

Variables

int TRACE = 0
string prefix = "eyeD3 trace> "
int STRICT_ID3 = 0
int ITUNES_COMPAT = 0
int KB_BYTES = 1024
int MB_BYTES = 1048576
int GB_BYTES = 1073741824
string KB_UNIT = 'KB'
string MB_UNIT = 'MB'
string GB_UNIT = 'GB'
tuple _magic = magic.open(magic.MAGIC_SYMLINK | magic.MAGIC_MIME)

Function Documentation

Definition at line 62 of file utils.py.

00062 
00063 def constantToVersions(v):
00064    if v & ID3_V1:
00065       if v == ID3_V1_0:
00066          return [1, 0, 0];
00067       elif v == ID3_V1_1:
00068          return [1, 1, 0];
00069       elif v == ID3_V1:
00070          return [1, 1, 0];
00071    elif v & ID3_V2:
00072       if v == ID3_V2_2:
00073          return [2, 2, 0];
00074       elif v == ID3_V2_3:
00075          return [2, 3, 0];
00076       elif v == ID3_V2_4:
00077          return [2, 4, 0];
00078       elif v == ID3_V2:
00079          return [2, 4, 0];
00080    raise str("constantToVersions - Invalid ID3 version constant: %s" % hex(v));

def utils.format_size (   sz)

Definition at line 165 of file utils.py.

00165 
00166 def format_size(sz):
00167     unit = 'Bytes'
00168     if sz >= GB_BYTES:
00169         sz = float(sz) / float(GB_BYTES)
00170         unit = GB_UNIT
00171     elif sz >= MB_BYTES:
00172         sz = float(sz) / float(MB_BYTES)
00173         unit = MB_UNIT
00174     elif sz >= KB_BYTES:
00175         sz = float(sz) / float(KB_BYTES)
00176         unit = KB_UNIT
00177     return "%.2f %s" % (sz, unit)

Definition at line 178 of file utils.py.

00178 
00179 def format_time_delta(td):
00180     days = td.days
00181     hours = td.seconds / 3600
00182     mins = (td.seconds % 3600) / 60
00183     secs = (td.seconds % 3600) % 60
00184     tstr = "%02d:%02d:%02d" % (hours, mins, secs)
00185     if days:
00186         tstr = "%d days %s" % (days, tstr)
00187     return tstr

def utils.format_track_time (   curr,
  total = None 
)

Definition at line 139 of file utils.py.

00139 
00140 def format_track_time(curr, total=None):
00141     def time_tuple(ts):
00142         if ts is None or ts < 0:
00143             ts = 0
00144         hours = ts / 3600
00145         mins = (ts % 3600) / 60
00146         secs = (ts % 3600) % 60
00147         tstr = '%02d:%02d' % (mins, secs)
00148         if int(hours):
00149             tstr = '%02d:%s' % (hours, tstr)
00150         return (int(hours), int(mins), int(secs), tstr)
00151 
00152     hours, mins, secs, curr_str = time_tuple(curr)
00153     retval = curr_str
00154     if total:
00155         hours, mins, secs, total_str = time_tuple(total)
00156         retval += ' / %s' % total_str
00157     return retval

Here is the caller graph for this function:

def utils.guess_mime_type (   filename)

Definition at line 197 of file utils.py.

00197 
00198 def guess_mime_type(filename):
00199     mime = mimetypes.guess_type(filename)[0]
00200     if not mime and _magic and os.path.isfile(filename):
00201         mime = _magic.file(filename)
00202         if mime:
00203             mime = mime.split(";")[0]
00204     return mime
00205 

Here is the caller graph for this function:

Definition at line 96 of file utils.py.

00096 
00097 def itunesCompat():
   return ITUNES_COMPAT

Here is the caller graph for this function:

def utils.strictID3 ( )

Definition at line 92 of file utils.py.

00092 
00093 def strictID3():
00094    return STRICT_ID3

Here is the caller graph for this function:

def utils.TRACE_MSG (   msg)

Definition at line 84 of file utils.py.

00084 
00085 def TRACE_MSG(msg):
00086    if TRACE:
00087        try:
00088            print prefix + msg;
00089        except UnicodeEncodeError:
00090            pass;

Here is the caller graph for this function:

Definition at line 22 of file utils.py.

00022 
00023 def versionsToConstant(v):
00024    major = v[0];
00025    minor = v[1];
00026    rev = v[2];
00027    if major == 1:
00028       if minor == 0:
00029          return ID3_V1_0;
00030       elif minor == 1:
00031          return ID3_V1_1;
00032    elif major == 2:
00033       if minor == 2:
00034          return ID3_V2_2;
00035       if minor == 3:
00036          return ID3_V2_3;
00037       elif minor == 4:
00038          return ID3_V2_4;
00039    raise str("Invalid ID3 version: %s" % str(v));

def utils.versionToString (   v)

Definition at line 40 of file utils.py.

00040 
00041 def versionToString(v):
00042    if v & ID3_V1:
00043       if v == ID3_V1_0:
00044          return "v1.0";
00045       elif v == ID3_V1_1:
00046          return "v1.1";
00047       elif v == ID3_V1:
00048          return "v1.x";
00049    elif v & ID3_V2:
00050       if v == ID3_V2_2:
00051          return "v2.2";
00052       elif v == ID3_V2_3:
00053          return "v2.3";
00054       elif v == ID3_V2_4:
00055          return "v2.4";
00056       elif v == ID3_V2:
00057          return "v2.x";
00058 
00059    if v == ID3_ANY_VERSION:
00060       return "v1.x/v2.x";
00061    raise str("versionToString - Invalid ID3 version constant: %s" % hex(v));

Here is the caller graph for this function:


Variable Documentation

utils._magic = magic.open(magic.MAGIC_SYMLINK | magic.MAGIC_MIME)

Definition at line 192 of file utils.py.

int utils.GB_BYTES = 1073741824

Definition at line 160 of file utils.py.

string utils.GB_UNIT = 'GB'

Definition at line 163 of file utils.py.

Definition at line 95 of file utils.py.

int utils.KB_BYTES = 1024

Definition at line 158 of file utils.py.

string utils.KB_UNIT = 'KB'

Definition at line 161 of file utils.py.

int utils.MB_BYTES = 1048576

Definition at line 159 of file utils.py.

string utils.MB_UNIT = 'MB'

Definition at line 162 of file utils.py.

string utils.prefix = "eyeD3 trace> "

Definition at line 83 of file utils.py.

Definition at line 91 of file utils.py.

int utils.TRACE = 0

Definition at line 82 of file utils.py.