eyed3.utils package
Submodules
eyed3.utils.art module
- eyed3.utils.art.FRONT_COVER = 'FRONT_COVER'
Album front cover.
- eyed3.utils.art.BACK_COVER = 'BACK_COVER'
Album back cover.
- eyed3.utils.art.MISC_COVER = 'MISC_COVER'
Other part of the album cover; liner notes, gate-fold, etc.
- eyed3.utils.art.LOGO = 'LOGO'
Artist/band logo.
- eyed3.utils.art.ARTIST = 'ARTIST'
Artist/band images.
- eyed3.utils.art.LIVE = 'LIVE'
Artist/band images.
- eyed3.utils.art.FILENAMES = {'ARTIST': ['artist*'], 'BACK_COVER': ['cover-back', 'back', 'cover-back_*'], 'FRONT_COVER': ['cover-front', 'cover-alternate*', 'cover', 'folder', 'front', 'cover-front_*', 'flier'], 'LIVE': ['live*'], 'LOGO': ['logo*'], 'MISC_COVER': ['cover-insert*', 'cover-liner*', 'cover-disc', 'cover-media*']}
A mapping of art types to lists of filename patterns (excluding file extension): type -> [file_pattern, ..].
- eyed3.utils.art.TO_ID3_ART_TYPES = {'ARTIST': [7, 8, 10], 'BACK_COVER': [4], 'FRONT_COVER': [3, 0, 1, 5], 'LIVE': [15, 14], 'LOGO': [19], 'MISC_COVER': [6]}
A mapping of art types to ID3 APIC (image) types: type -> [apic_type, ..]
- eyed3.utils.art.FROM_ID3_ART_TYPES = {0: 'FRONT_COVER', 1: 'FRONT_COVER', 3: 'FRONT_COVER', 4: 'BACK_COVER', 5: 'FRONT_COVER', 6: 'MISC_COVER', 7: 'ARTIST', 8: 'ARTIST', 10: 'ARTIST', 14: 'LIVE', 15: 'LIVE', 19: 'LOGO'}
A mapping of ID3 art types to eyeD3 art types; the opposite of TO_ID3_ART_TYPES.
eyed3.utils.binfuncs module
- eyed3.utils.binfuncs.bytes2bin(bites, sz=8)[source]
Accepts a string of
bytes(chars) and returns an array of bits representing the bytes in big endian byte order. An optional maxszfor each byte (default 8 bits/byte) which can be used to mask out higher bits.
- eyed3.utils.binfuncs.bin2bytes(x)[source]
Convert an array of bits (MSB first) into a string of characters.
- eyed3.utils.binfuncs.bin2dec(x)[source]
Convert
x, an array of “bits” (MSB first), to it’s decimal value.
- eyed3.utils.binfuncs.dec2bin(n, p=1)[source]
Convert a decimal value
nto an array of bits (MSB first). Optionally, pad the overall size topbits.
eyed3.utils.console module
- class eyed3.utils.console.AnsiFore[source]
Bases:
object- GREY = 30
- RED = 31
- GREEN = 32
- YELLOW = 33
- BLUE = 34
- MAGENTA = 35
- CYAN = 36
- WHITE = 37
- RESET = 39
- class eyed3.utils.console.AnsiBack[source]
Bases:
object- GREY = 40
- RED = 41
- GREEN = 42
- YELLOW = 43
- BLUE = 44
- MAGENTA = 45
- CYAN = 46
- WHITE = 47
- RESET = 49
- class eyed3.utils.console.AnsiStyle[source]
Bases:
object- RESET_ALL = 0
- BRIGHT = 1
- RESET_BRIGHT = 22
- DIM = 2
- RESET_DIM = 22
- ITALICS = 3
- RESET_ITALICS = 23
- UNDERLINE = 4
- RESET_UNDERLINE = 24
- BLINK_SLOW = 5
- RESET_BLINK_SLOW = 25
- BLINK_FAST = 6
- RESET_BLINK_FAST = 26
- INVERSE = 7
- RESET_INVERSE = 27
- STRIKE_THRU = 9
- RESET_STRIKE_THRU = 29
- class eyed3.utils.console.Spinner(msg, file=None, step=1, chars=None, use_unicode=True, print_done=True)[source]
Bases:
objectA class to display a spinner in the terminal.
It is designed to be used with the with statement:
with Spinner("Reticulating splines", "green") as s: for item in enumerate(items): s.next()
- class eyed3.utils.console.ProgressBar(total_or_items: int | Sequence, file=None)[source]
Bases:
objectA class to display a progress bar in the terminal.
It is designed to be used either with the with statement:
with ProgressBar(len(items)) as bar: for item in enumerate(items): bar.update()
or as a generator:
for item in ProgressBar(items): item.process()
- total_or_itemsint or sequence
If an int, the number of increments in the process being tracked. If a sequence, the items to iterate over.
- filewritable file-like object, optional
The file to write the progress bar to. Defaults to sys.stdout. If file is not a tty (as determined by calling its isatty member, if any), the scrollbar will be completely silent.
- update(value=None)[source]
Update the progress bar to the given value (out of the total given to the constructor).
- classmethod map(function, items, multiprocess=False, file=None)[source]
Does a map operation while displaying a progress bar with percentage complete.
def work(i): print(i) ProgressBar.map(work, range(50))
Parameters:
- functionfunction
Function to call for each step
- itemssequence
Sequence where each element is a tuple of arguments to pass to function.
- multiprocessbool, optional
If True, use the multiprocessing module to distribute each task to a different processor core.
- filewriteable file-like object, optional
The file to write the progress bar to. Defaults to sys.stdout. If file is not a tty (as determined by calling its isatty member, if any), the scrollbar will be completely silent.
- eyed3.utils.console.cformat(msg, fg, bg=None, styles=None)[source]
Format
msgwith foreground and optional background. Optionalstyleslists will also be applied. The formatted string is returned.
eyed3.utils.log module
eyed3.utils.prompt module
- eyed3.utils.prompt.DISABLE_PROMPT = None
Whenever a prompt occurs and this value is not
Noneit can beexitto call sys.exit (see EXIT_STATUS) orraiseto throw a RuntimeError, which can be caught if desired.
- exception eyed3.utils.prompt.PromptExit[source]
Bases:
RuntimeErrorRaised when
DISABLE_PROMPTis ‘raise’ andpromptis called.
- eyed3.utils.prompt.prompt(msg, default=None, required=True, type_=<class 'str'>, validate=None, choices=None)[source]
Prompt user for input, the prequest is in
msg. Ifdefaultis notNoneit will be displayed as the default and returned if not input is entered. The valueNoneis only returned ifrequiredisFalse. The response is passed totype_for conversion (default is unicode) before being returned. An optional list of valid responses can be provided inchoices.
Module contents
- eyed3.utils.guessMimetype(filename, with_encoding=False)[source]
Deprecated since version 0.9a2: This will be removed in 1.0. Use eyed3.mimetype.guessMimetype() instead.
- eyed3.utils.walk(handler, path, excludes=None, fs_encoding='utf-8', recursive=False)[source]
A wrapper around os.walk which handles exclusion patterns and multiple path types (str, pathlib.Path, bytes).
- class eyed3.utils.FileHandler[source]
Bases:
objectA handler interface for
eyed3.utils.walk()callbacks.- handleFile(f)[source]
Called for each file walked. The file
fis the full path and the return value is ignored. If the walk should abort the method should raise aStopIterationexception.
- eyed3.utils.requireUnicode(*args)[source]
Function decorator to enforce str/unicode argument types.
Noneis a valid argument value, in all cases, regardless of not being unicode.*argsPositional arguments may be numeric argument index values (requireUnicode(1, 3) - requires argument 1 and 3 are unicode) or keyword argument names (requireUnicode(“title”)) or a combination thereof.
- eyed3.utils.formatTime(seconds, total=None, short=False)[source]
Format
seconds(number of seconds) as a string representation. Whenshortis False (the default) the format is:HH:MM:SS.
Otherwise, the format is exacly 6 characters long and of the form:
1w 3d 2d 4h 1h 5m 1m 4s 15s
If
totalis not None it will also be formatted and appended to the result seperated by ‘ / ‘.
- eyed3.utils.formatSize(size, short=False)[source]
Format
size(number of bytes) into string format doing KB, MB, or GB conversion where necessary.When
shortis False (the default) the format is smallest unit of bytes and largest gigabytes; ‘234 GB’. The short version is 2-4 characters long and of the form256b 64k 1.1G
- eyed3.utils.chunkCopy(src_fp, dest_fp, chunk_sz=524288)[source]
Copy
src_fptodest_fpinchunk_szbyte increments.
- class eyed3.utils.ArgumentParser(*args, **kwargs)[source]
Bases:
ArgumentParserSubclass of argparse.ArgumentParser that adds version and log level options.
- eyed3.utils.datePicker(thing, prefer_recording_date=False)[source]
This function returns a date of some sort, amongst all the possible dates (members called release_date, original_release_date, and recording_date of type eyed3.core.Date).
The order of preference is: 1) date of original release 2) date of this versions release 3) the recording date.
Unless
prefer_recording_dateisTruein which case the order is 3, 1, 2.Nonewill be returned if no dates are available.