API Documentation¶
ps3iso package¶
ps3iso.game module¶
-
class
ps3iso.game.Game(iso_path)¶ Bases:
objectClass representing a set of files making up a Playstation 3 game An existing
.isofile must be passed, files with any extension matching the base name will be found and included in all operationsParameters: or str iso_path (Path) – Path to an existing .iso file -
classmethod
extract_sfo(iso_path)¶ Read the PARAM.SFO data from an
.isofileSee also
Parameters: iso_path ( Union[str,Path]) – Path to the .iso file to readReturn type: SfoFile
-
format_file(f, fmt, fill='')¶ Return a new path for an input file, formatted according to the SFO data and format string. The existing file extension will be preserved.
See also
Parameters: - f (
Union[str,Path]) – Path to an existing file - fmt (
str) – Formatting string to use for new file name - fill – String to use for replacing invalid characters
Return type: Path- f (
-
print_info(fmt=None)¶ Print information about the current game set. Accepts a custom output formatting string with SFO parameter variable expansion support
In addition to the variables described by
SfoFile.format(), the following will be also expanded:Variable Parameter %p Full path of the existing file %f File name of the existing file \n Newline character \t Tab character See also
Parameters: fmt (str) – Formatting string to use for output Return type: None
-
classmethod
search(path)¶ Search for
.isofiles in the given path. Non-recursive and case-insensitiveParam: Path to search Return type: Iterator[Game]
-
classmethod
ps3iso.sfo package¶
ps3iso.sfo.errors module¶
-
exception
ps3iso.sfo.errors.SfoUnknownParameterError¶ Bases:
ExceptionNamed Exception raised when a reference to an invalid parameter name is encountered
-
exception
ps3iso.sfo.errors.SfoMissingParameterError¶ Bases:
ExceptionNamed Exception raised when an SfoFile is missing a required parameter
-
exception
ps3iso.sfo.errors.SfoDuplicateParameterError¶ Bases:
ExceptionNamed Exception raised when a duplicate SFO parameter is encountered in an SfoFile
-
exception
ps3iso.sfo.errors.SfoParameterNotFoundError¶ Bases:
ExceptionNamed Exception raised when a user-supplied attribute is not found
-
exception
ps3iso.sfo.errors.SfoParseError(message, filepath=None)¶ Bases:
ExceptionNamed Exception raised when a general parsing error occurs
-
exception
ps3iso.sfo.errors.SfoIndexTableParseError(message, filepath=None)¶ Bases:
ps3iso.sfo.errors.SfoParseErrorNamed Exception raised when an parsing an invalid SfoIndexTable is attempted
-
exception
ps3iso.sfo.errors.SfoIndexTableEntryParseError(message, filepath=None)¶ Bases:
ps3iso.sfo.errors.SfoParseErrorNamed Exception raised when an parsing an invalid SfoIndexTableEntry is attempted
-
exception
ps3iso.sfo.errors.SfoHeaderParseError(message, filepath=None)¶ Bases:
ps3iso.sfo.errors.SfoParseErrorNamed Exception raised when an parsing an invalid SfoHeader is attempted
ps3iso.sfo.file module¶
-
class
ps3iso.sfo.file.SfoFile¶ Bases:
objectThe main object representing an SFO file.
Use the
parse_file()method to create an object from an existing file, or useparse()directly on a seekable object such asio.BytesIO>>> sfo = SfoFile.parse_file('test/data/PARAM.SFO') >>> sfo <SfoFile parameters=12 size=1041>
>>> sfo.parameters SfoParameters(APP_VER='01.00', ATTRIBUTE=32, BOOTABLE=1, CATEGORY='DG', LICENSE='Some example license text, Supports UTF8 glyphs like ©and ®.', PARENTAL_LEVEL=5, PS3_SYSTEM_VER='02.5200', RESOLUTION=63, SOUND_FORMAT=1, TITLE='Example PS3ISO Game Title', TITLE_ID='BLES00000', VERSION='01.00')
>>> for name, value in sfo: ... print('%s=%s' % (name, value)) APP_VER=01.00 ATTRIBUTE=32 BOOTABLE=1 CATEGORY=DG LICENSE=Some example license text, Supports UTF8 glyphs like ©and ®. PARENTAL_LEVEL=5 PS3_SYSTEM_VER=02.5200 RESOLUTION=63 SOUND_FORMAT=1 TITLE=Example PS3ISO Game Title TITLE_ID=BLES00000 VERSION=01.00
See also
parse_file(),format(),parameters()-
classmethod
parse(fp)¶ Read a seekable binary IO stream containing an SFO file’s bytes
Parameters: fp ( BinaryIO) – Stream or resource pointerReturn type: SfoFile Example: >>> with open('test/data/PARAM.SFO', 'rb') as f: ... sfo = SfoFile.parse(f) >>> print(sfo) <SfoFile parameters=12 size=1041>
-
classmethod
parse_file(path)¶ Create a new SfoFile object from an existing SFO file
Parameters: path ( str) – Path to the source fileReturn type: SfoFile Example: >>> SfoFile.parse_file('test/data/PARAM.SFO') <SfoFile parameters=12 size=1041>
-
keys¶ List of available parameter keys in the current
SfoFileReturn type: List[str] Example: >>> sfo = SfoFile.parse_file('test/data/PARAM.SFO') >>> sfo.keys ['APP_VER', 'ATTRIBUTE', 'BOOTABLE', 'CATEGORY', 'LICENSE', 'PARENTAL_LEVEL', 'PS3_SYSTEM_VER', 'RESOLUTION', 'SOUND_FORMAT', 'TITLE', 'TITLE_ID', 'VERSION']
-
parameters¶ NamedTuple of all SFO parameter values
Return type: NamedTuple Example: >>> sfo = SfoFile.parse_file('test/data/PARAM.SFO') >>> sfo.parameters SfoParameters(APP_VER='01.00', ATTRIBUTE=32, BOOTABLE=1, CATEGORY='DG', LICENSE='Some example license text, Supports UTF8 glyphs like ©and ®.', PARENTAL_LEVEL=5, PS3_SYSTEM_VER='02.5200', RESOLUTION=63, SOUND_FORMAT=1, TITLE='Example PS3ISO Game Title', TITLE_ID='BLES00000', VERSION='01.00')
>>> sfo.parameters.TITLE 'Example PS3ISO Game Title'
-
get_parameter(name)¶ Retrieve an underlying
SfoParameterobject. If the parameter does not exist, anSfoParameterNotFoundErroris raised.Parameters: name ( str) – Parameter name. Must be a valid SFO parameter as found inps3iso.sfo.parameters.VALID_SFO_PARAMETERSReturn type: SfoParameter Example: >>> sfo = SfoFile.parse_file('test/data/PARAM.SFO') >>> sfo.get_parameter('TITLE') SfoParameter('TITLE', fmt=SfoParameterFormat.utf8, length=None, maxlength=128, required=[SfoCategory.PS3, SfoCategory.PS1], optional=[], value='Example PS3ISO Game Title')
See also
-
add_parameter(name, value=None)¶ Add a new parameter to the
SfoFile. Raises aSfoDuplicateErrorif the parameter already exists.Parameters: - name (
str) – Parameter name. Must be a valid SFO parameter as found inps3iso.sfo.parameters.VALID_SFO_PARAMETERS - value – Optionally set a value for the new parameter
Return type: None
Example: >>> sfo = SfoFile.parse_file('test/data/PARAM.SFO') >>> sfo.parameters.REGION_DENY Traceback (most recent call last): AttributeError: 'SfoParameters' object has no attribute 'REGION_DENY' >>> sfo.add_parameter('REGION_DENY', 42) >>> sfo.parameters.REGION_DENY 42
See also
- name (
-
set_parameter(name, value)¶ Set the value of a parameter in the current
SfoFile, creating it if it does not exist.Parameters: - name (
str) – Parameter name. Must be a valid SFO parameter as found inps3iso.sfo.parameters.VALID_SFO_PARAMETERS - value (
str) – New parameter value
Return type: None
Example: >>> sfo = SfoFile.parse_file('test/data/PARAM.SFO') >>> sfo.parameters.TITLE_ID 'BLES00000' >>> sfo.set_parameter('TITLE_ID', 'BLES11111') >>> sfo.parameters.TITLE_ID 'BLES11111'
See also
- name (
-
remove_parameter(name)¶ Remove a parameter from the current
SfoFileParameters: name ( str) – Parameter nameReturn type: None Example: >>> sfo = SfoFile.parse_file('test/data/PARAM.SFO') >>> sfo.parameters.TITLE_ID 'BLES00000' >>> sfo.remove_parameter('TITLE_ID') >>> sfo.parameters.TITLE_ID Traceback (most recent call last): AttributeError: 'SfoParameters' object has no attribute 'TITLE_ID'
See also
-
verify_parameters(category)¶ Verify that all required parameters exist for the given
SfoCategory, and raise aSfoMissingParameterExceptionif any are missing.Parameters: category ( SfoCategory) – SFO file category to use for required parametersReturn type: None Example: >>> sfo = SfoFile.parse_file('test/data/PARAM.SFO') >>> sfo.verify_parameters(SfoCategory.PS3) >>> sfo.remove_parameter('TITLE') >>> sfo.verify_parameters(SfoCategory.PS3) Traceback (most recent call last): ps3iso.sfo.errors.SfoMissingParameterError: Not a valid SFO File for SfoCategory.PS3. Missing Required parameters: {'TITLE'}
See also
-
format(fmt)¶ Return a string representing the PARAM.SFO data contained in the current object. Variables in the formatting string are replaced with the corresponding SFO data.
Variable Parameter %a APP_VER %a ATTRIBUTE %C CATEGORY %L LICENSE %P PARENTAL_LEVEL %R RESOLUTION %S SOUND_FORMAT %T TITLE %I TITLE_ID %V VERSION %v PS3_SYSTEM_VER Parameters: fmt ( str) – Formatting stringReturn type: str Example: >>> sfo = SfoFile.parse_file('test/data/PARAM.SFO') >>> sfo.format('[%I]_(%T).iso') '[BLES00000]_(Example PS3ISO Game Title).iso'
-
write(dst)¶ Write the SFO object to a stream such as
io.BytesIOParameters: dst ( BinaryIO) – Destination output streamReturns: Number of bytes written Return type: int Example: >>> sfo = SfoFile.parse_file('test/data/PARAM.SFO') >>> sfo.set_parameter('TITLE', 'NewTitle') >>> bio = io.BytesIO() >>> sfo.write(bio) 1041
-
write_file(path)¶ Write the SFO object to a file
Parameters: path ( str) – Destination file pathReturns: Number of bytes written Return type: int Example: >>> sfo = SfoFile.parse_file('test/data/PARAM.SFO') >>> sfo.set_parameter('TITLE', 'NewTitle') >>> sfo.write_file('NewTitle.SFO') 1041
-
classmethod
ps3iso.sfo.parameters module¶
-
class
ps3iso.sfo.parameters.SfoParameterFormat(name)¶ Bases:
objectThis class represents the valid SFO parameter types
Member Description SfoParameterFormat.int32 32-bit Integer SfoParameterFormat.utf8 UTF-8 String (NULL terminated) SfoParameterFormat.utf8s UTF-8 String -
classmethod
from_bytes(b)¶ Parse bytes and return the corresponding SfoParameterFormat. Raises ValueError if none is found
Parameters: b ( bytes) – Bytes to parseReturn type: SfoParameterFormat
-
classmethod
-
class
ps3iso.sfo.parameters.SfoCategory¶ Bases:
enum.IntFlagEnum representing valid SFO file categories
Member Description SfoCategory.PSP PSP Bootable Image SfoCategory.PS1 PS1 Bootable Image SfoCategory.PS2 PS2 Bootable Image SfoCategory.PS3 PS3 Bootable Image SfoCategory.PSPData PSP Data Image SfoCategory.PS1Data PS1 Data Image SfoCategory.PS2Data PS2 Data Image SfoCategory.PS3Data PS3 Data Image See also
-
class
ps3iso.sfo.parameters.SfoParameter(name, fmt=SfoParameterFormat.int32, length=None, maxlength=None, required=None, optional=None, variable_key_range=None, value=None)¶ Bases:
objectClass representing an SFO parameter.
All valid parameters are defined in
VALID_SFO_PARAMETERSParan str name: Parameter name
Parameters: - fmt (SfoParameterFormat) – Parameter type, see
SfoParameterFormat - length (int) – Initial length of the parameter value
- maxlength (int) – Maximum length of the parameter value
- required (list) – Categories for which this parameter is required
- optional (list) – Categories for which this parameter is optional
- value – Set the initial parameter value
-
name¶ Parameter name
-
size¶ Number of bytes the parameter value will occupy when writtern
-
value¶ Current parameter value
-
copy(value=None)¶ Create a copy of the SfoParameter, optionally setting it’s initial value.
Example: >>> p = SfoParameter('TITLE', fmt=SfoParameterFormat.utf8, maxlength=1024) >>> p.copy('NewValue') SfoParameter('TITLE', fmt=SfoParameterFormat.utf8, length=None, maxlength=1024, required=[], optional=[], value='NewValue')
-
classmethod
new(name, value=None)¶ Create a new SFO Parameter. ‘name’ must be a valid parameter name. Optionally set the initial value
>>> SfoParameter.new('TITLE', 'NewValue') SfoParameter('TITLE', fmt=SfoParameterFormat.utf8, length=None, maxlength=128, required=[SfoCategory.PS3, SfoCategory.PS1], optional=[], value='NewValue')
Return type: SfoParameter
- fmt (SfoParameterFormat) – Parameter type, see
-
ps3iso.sfo.parameters.VALID_SFO_PARAMETERS= {'ACCOUNTID': SfoParameter('ACCOUNTID', fmt=SfoPar...¶ Type: Dict[str, SfoParameter] Annotation: This data is taken from the parameter table at https://psdevwiki.com/ps3/PARAM.SFO Each entry describes a valid SFO parameter, it’s type, and length constraints. Each parameter can be made ‘optional’ or ‘required’ for any SfoCategory’s.
Error
Unable to execute python code at parameters.py:docstring of ps3iso.sfo.parameters.VALID_SFO_PARAMETERS:142:
No module named ‘tabulate’