Package magma :: Package magma :: Module magma_list :: Class Magma
[hide private]
[frames] | no frames]

Class Magma

source code

object --+
         |
        Magma
Known Subclasses:

A Magma List.

Instance Methods [hide private]
 
__init__(self, magma_file=None, input_files=None, creator=None, data=None, yaml_data=None, *args, **kwds)
A Magma list.
source code
 
__str__(self)
Return a human readable representation of the yaml file.
source code
 
create_magma_from_files(self, file_paths)
Create a magma file from given file paths.
source code
 
dump(self, magma_versions=[0.2, 0.4])
Return the yaml data.
source code
 
files(self)
Get the files from the magma data.
source code
 
get_file_magnets(self)
Get the magnet links of the files.
source code
 
get_magma_metadata(self)
Get only the metadata, without the list of files.
source code
 
get_yaml_data(self)
Return the yaml representation of the data.
source code
 
is_magma(self, yaml_data)
Check, if a given yaml data begins with the Magma header.
source code
 
magma_v0_2_data(self)
Returns: Data in Magma v0.2 format
source code
 
magma_v0_2_filelist_representation(self)
Returns: A list of files which can be read by MAGMAv0.2 compliant programs.
source code
 
print_data(self)
Print the magma file in the yaml format.
source code
 
readout_magma_from_file(self, file_path)
Readout a magma list from the file_path
source code
 
readout_yaml(self, yaml_data)
Readout a magma list from data in yaml format.
source code
 
remove_empty_entries(self)
Remove empty entries in the Magma, for example empty alt-locs.
source code
 
save(self, path, magma_versions=[0.2, 0.4])
Save the magma list to the path.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__

Instance Variables [hide private]
  data
All data inside the Magma list
  magnets
All magnets inside the Magma list.
  metadata
The metadata of this Magma list (excluding the files).
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, magma_file=None, input_files=None, creator=None, data=None, yaml_data=None, *args, **kwds)
(Constructor)

source code 

A Magma list.

Parameters:
  • magma_file (String) - The path to the magma file, either absolute or relative the the location this script is invoked from.
  • input_files (List) - A list of file_paths of input files which should be included in the magma list.
  • creator (String) - An identifier for the creator of the Magma file.
  • yaml_data (String) - Raw file data as read from a Magma file.
  • data (Dict) - A native Python dict with the data.
Overrides: object.__init__

__str__(self)
(Informal representation operator)

source code 

Return a human readable representation of the yaml file.

In effect return the yaml data with the magic header.

Returns:
A human readable representation of the Magma file in yaml format (String).
Overrides: object.__str__

create_magma_from_files(self, file_paths)

source code 

Create a magma file from given file paths.

Returns:
The Python dict for a Magma file - the magma data.

dump(self, magma_versions=[0.2, 0.4])

source code 

Return the yaml data.

Returns:
A string representation of the Magma in yaml format.

files(self)

source code 

Get the files from the magma data.

Returns:
A list of all MagmaFile objects from the Magma.

get_file_magnets(self)

source code 

Get the magnet links of the files.

# TODO: Include Alt-Locs.

Returns:
A list of all magnet links inside the Magma.

get_magma_metadata(self)

source code 

Get only the metadata, without the list of files.

Returns:
A dict which contains only the metadata of the Magma without the files.

get_yaml_data(self)

source code 

Return the yaml representation of the data.

Returns:
The yaml representation of the data.

is_magma(self, yaml_data)

source code 

Check, if a given yaml data begins with the Magma header.

Parameters:
  • yaml_data (String) - Data in yaml format
Returns:
True or False

magma_v0_2_data(self)

source code 
Returns:
Data in Magma v0.2 format

magma_v0_2_filelist_representation(self)

source code 
Returns:
A list of files which can be read by MAGMAv0.2 compliant programs.

print_data(self)

source code 

Print the magma file in the yaml format.

Returns:
A string representation of the Magma in yaml format.

readout_magma_from_file(self, file_path)

source code 

Readout a magma list from the file_path

Parameters:
  • file_path (String) - The path to the magma file, either absolute or relative the the location this script is invoked from.
Returns:
The Python dict for a Magma file - the magma data.

readout_yaml(self, yaml_data)

source code 

Readout a magma list from data in yaml format.

Parameters:
  • yaml_data (String) - Data in yaml format.
Returns:
The Python dict for a Magma file - the magma data.

remove_empty_entries(self)

source code 

Remove empty entries in the Magma, for example empty alt-locs.

We remove each entry by hand, because we should know which entries can be created by this program - and if we don't we know that have to change our coding practice :) .

save(self, path, magma_versions=[0.2, 0.4])

source code 

Save the magma list to the path.

If the folder to save in doesn't exist, just raise an Exception.

TODO: Clean out empty entries in the files and the metadata before saving. self.data["gnutella"]["alt-locs"] = [] should disappear (if there are no other keys than alt-locs in gnutella, the gnutella dict should completely disappear, too).

Parameters:
  • path (String) - The path to the target file.
  • magma_versions (List of Floats) - The versions of the magma specification to be supported.
Returns:
None