hal.files.models package

Submodules

hal.files.models.audio module

Songs in various formats

class hal.files.models.audio.MP3Song(path)[source]

Bases: hal.files.models.system.FileSystem

.mp3 song

get_album()[source]

Gets song’s albu

Returns:album
get_artist()[source]

Gets song’s artist

Returns:artist
get_details()[source]

Finds songs details

Returns:Dictionary with songs details about title, artist, album and year
get_genre()[source]

Gets song’s genre

Returns:genre
get_nr_track()[source]

Gets song’s track number

Returns:# of track
get_title()[source]

Gets song’s title

Returns:title
get_year()[source]

Gets song’s year

Returns:year
static is_valid_mp3(path)[source]
Parameters:path – candidate
Returns:True iff song is MP3 encoded
set_album(album)[source]

Sets song’s album

Parameters:album – album
set_artist(artist)[source]

Sets song’s artist

Parameters:artist – artist
set_genre(genre)[source]

Sets song’s genre

Parameters:genre – genre
set_nr_track(nr_track)[source]

Sets song’s track numb

Parameters:nr_track – of track
set_title(name)[source]

Sets song’s title

Parameters:name – title
set_year(year)[source]

Sets song’s year

Parameters:year – year
hal.files.models.audio.find_songs(folder, recursive)[source]
Parameters:
  • folder – folder path
  • recursive – True want to search recursively
Returns:

generator of) paths of the songs in folder

hal.files.models.files module

Documents and folders in system

class hal.files.models.files.Directory(path)[source]

Bases: hal.files.models.system.FileSystem

Folder of a OS

static create_new(path)[source]

Creates new directory

Parameters:path – path to directory to create
get_path_name()[source]

Gets path and name of file

Returns:Name of path, name of file (or folder)
is_empty()[source]

Checks if folder is empty

Returns:BTrue iff empty
class hal.files.models.files.Document(path)[source]

Bases: hal.files.models.system.FileSystem

File with content in a OS

static extract_name_extension(file_name)[source]

Gets name and extension of file

Parameters:file_name – Name of file
Returns:Name of file, extension of file
get_path_name()[source]

Gets path and name of song

Returns:Name of path, name of file (or folder)
is_audio()[source]

Checks if file is audio

Returns:True iff document is an audio
is_image()[source]

Checks if file is image

Returns:True iff document is an image
is_subtitle()[source]

Checks if file is subtitle

Returns:True iff document is a subtitle
is_text()[source]

Checks if file is text

Returns:True iff document is a text file
is_video()[source]

Checks if file is video

Returns:True iff document is a video
static move_file_to_directory(file_path, directory_path)[source]

Moves file to given directory

Parameters:
  • file_path – path to file to move
  • directory_path – path to target directory where to move file
static move_file_to_file(old_path, new_path)[source]

Moves file from old location to new one

Parameters:
  • old_path – path of file to move
  • new_path – new path
read_data()[source]
Returns:contents of file
write_data(data)[source]

Writes given data to given path file

Parameters:data – data to write to file

hal.files.models.system module

File system utils, renaming and parsing

class hal.files.models.system.FileSystem(path)[source]

Bases: object

Models a folder/file in a OS

is_archive_mac()[source]

Checks if file is a MAC archive

Returns:True iff document is an MACOSX archive
is_hidden()[source]

Checks if file is hidden

Returns:True iff path is hidden
is_russian()[source]

Checks if file path is russian

Returns:True iff document has a russian name
rename(new_path)[source]

Renames to new path

Parameters:new_path – new path to use
trash()[source]

Trashes given file/folder

hal.files.models.system.extract_name_max_chars(name, max_chars=64, blank=' ')[source]

Extracts max chars in name truncated to nearest word

Parameters:
  • name – path to edit
  • max_chars – max chars of new name
  • blank – char that represents the blank between words
Returns:

Name edited to contain at most max_chars

hal.files.models.system.fix_raw_path(path)[source]

Prettify name of path

Parameters:path – path to fix
Returns:Good name for path
hal.files.models.system.get_folder_name(file_path)[source]

Finds name of folder

Parameters:file_path – path
Returns:Name of folder
hal.files.models.system.get_parent_folder_name(file_path)[source]

Finds parent folder of file

Parameters:file_path – path
Returns:Name of folder container
hal.files.models.system.is_file(path)[source]

Checks if path is file

Parameters:path – path to check
Returns:True iff path is a file
hal.files.models.system.is_folder(path)[source]

Checks if path is folder

Parameters:path – path to check
Returns:True iff path is a file
hal.files.models.system.list_content(path, recurse, include_hidden=False)[source]

Finds content of folder (recursively)

Parameters:
  • path – directory to get list of files and folders
  • recurse – True iff recurse into subdirectories or not
  • include_hidden – True iff include hidden files in list
Returns:

List of paths in given directory recursively

hal.files.models.system.ls_dir(path, include_hidden=False)[source]

Finds content of folder

Parameters:
  • path – directory to get list of files and folders
  • include_hidden – True iff include hidden files in list
Returns:

List of paths in given directory

hal.files.models.system.ls_recurse(path, include_hidden=False)[source]

Finds content of folder recursively

Parameters:
  • path – directory to get list of files and folders
  • include_hidden – True iff include hidden files in list
Returns:

List of paths in given directory recursively

hal.files.models.system.prettify(name, blank=' ')[source]

Prettify name of path

Parameters:
  • name – path Name: to edit
  • blank – default blanks in name
Returns:

Prettier name from given one: replace bad chars with good ones

hal.files.models.system.remove_brackets(name)[source]

Removes brackets form input

Parameters:name – path to fix
Returns:inputs with no brackets
hal.files.models.system.remove_year(name)[source]

Removes year from input

Parameters:name – path to edit
Returns:inputs with no years