modio Objects

Documentation on objects unique to this library which the user manipulates and sometimes creates.

Module for user instanced classes.

class modio.objects.NewMod(**attrs)[source]

This class is unique to the library, it represents a mod to be submitted. The class must be instantiated with the appropriate parameters and then passed to game.add_mod().

Parameters:
  • name (str) – Name of the mod.
  • name_id (Optional[str]) – Subdomain name for the mod. Optional, if not specified the name will be use. Cannot exceed 80 characters
  • summary (str) – Brief overview of the mod, cannot exceed 250 characters.
  • description (Optional[str]) – Detailed description of the mod, supports HTML.
  • homepage (Optional[str]) – Official homepage for your mod. Must be a valid URL. Optional
  • stock (Optional[int]) – Maximium number of subscribers for this mod. Optional, if not included disables
  • metadata (Optional[str]) – Metadata stored by developers which may include properties on how information required. Optional. E.g. “rogue,hd,high-res,4k,hd textures”
  • maturity (Optional[Maturity]) – Choose if the mod contains mature content.
  • visible (Optional[Visibility]) – Visibility status of the mod
  • logo (str) – Path to the file. If on windows, must have escaped.
add_tags(*tags)[source]

Used to add tags to the mod, returns self for fluid chaining.

Parameters:tags (List[str]) – List of tags, duplicate tags will be ignord.
class modio.objects.NewModFile(**attrs)[source]

This class is unique to the library and represents a file to be submitted. The class must be instantiated and then passed to mod.add_file().

Parameters:
  • version (str) – Version of the mod that this file represents
  • changelog (str) – Changelog for the release
  • active (Optional[bool]) – Label this upload as the current release. Optional, if not included defaults to True.
  • metadata (str) – Metadata stored by the game developer which may include properties such as what version of the game this file is compatible with.
add_file(path)[source]

Used to add a file.

The binary file for the release. For compatibility you should ZIP the base folder of your mod, or if it is a collection of files which live in a pre-existing game folder, you should ZIP those files. Your file must meet the following conditions:

  • File must be zipped and cannot exceed 10GB in filesize
  • Mods which span multiple game directories are not supported
    unless the game manages this
  • Mods which overwrite files are not supported unless the game manages this
Parameters:path (str) – Path to file, if on windows must be escaped.
class modio.objects.Filter(filters=None)[source]

This class is unique to the library and is an attempt to make filtering modio data easier. Instead of passing filter keywords directly you can pass an instance of this class which you have previously fine tuned through the various methods. For advanced users it is also possible to pass filtering arguments directly to the class given that they are already in modio format. If you don’t know the modio format simply use the methods, all method return self for fluid chaining. This is also used for sorting and pagination. These instances can be save and reused at will. Attributes which can be used as filters will be marked as “Filter attributes” in the docs for the class the endpoint returns an array of. E.g. ID is marked as a filter argument for in the class Game and therefore in get_games() it can be used a filter.

Parameters:filters (Optional[dict]) – A dict which contains modio filter keyword and the appropriate value.
text(query)[source]

Full-text search is a lenient search filter that is only available if the endpoint you are querying contains a name column.

Parameters:query (str) – The words to identify. filter.text(“The Lord of the Rings”) - This will return every result where the name column contains any of the following words: ‘The’, ‘Lord’, ‘of’, ‘the’, ‘Rings’.
equals(**kwargs)[source]

The simpliest filter you can apply is columnname equals. This will return all rows which contain a column matching the value provided. There are not set parameters, this methods takes any named keywords and transforms them into arguments that will be passed to the request. E.g. ‘id=10’ or ‘name=”Best Mod”’

not_equals(**kwargs)[source]

Where the preceding column value does not equal the value specified. There are not set parameters, this methods takes any named keywords and transforms them into arguments that will be passed to the request. E.g. ‘id=10’ or ‘name=”Best Mod”’

like(**kwargs)[source]

Where the string supplied matches the preceding column value. This is equivalent to SQL’s LIKE. Consider using wildcard’s * for the best chance of results as described below. There are not set parameters, this methods takes any named keywords and transforms them into arguments that will be passed to the request. E.g. ‘id=10’ or ‘name=”Best Mod”’

not_like(**kwargs)[source]

Where the string supplied does not match the preceding column value. This is equivalent to SQL’s NOT LIKE. This is equivalent to SQL’s LIKE. Consider using wildcard’s * for the best chance of results as described below. There are not set parameters, this methods takes any named keywords and transforms them into arguments that will be passed to the request. E.g. ‘id=10’ or ‘name=”Best Mod”’

values_in(**kwargs)[source]

Where the supplied list of values appears in the preceding column value. This is equivalent to SQL’s IN. There are not set parameters, this methods takes any named keywords and values as lists and transforms them into arguments that will be passed to the request. E.g. ‘id=[10, 3, 4]’ or ‘name=[“Best”,”Mod”]’

values_not_in(**kwargs)[source]

Where the supplied list of values does NOT appears in the preceding column value. This is equivalent to SQL’s NOT IN. There are not set parameters, this methods takes any named keywords and values as lists and transforms them into arguments that will be passed to the request. E.g. ‘id=[10, 3, 4]’ or ‘name=[“Best”,”Mod”]’

max(**kwargs)[source]

Where the preceding column value is smaller than or equal to the value specified. There are not set parameters, this methods takes any named keywords and transforms them into arguments that will be passed to the request. E.g. ‘game_id=40’

min(**kwargs)[source]

Where the preceding column value is greater than or equal to the value specified. There are not set parameters, this methods takes any named keywords and transforms them into arguments that will be passed to the request. E.g. ‘game_id=40’

smaller_than(**kwargs)[source]

Where the preceding column value is smaller than the value specified. There are not set parameters, this methods takes any named keywords and transforms them into arguments that will be passed to the request. E.g. ‘game_id=40’

greater_than(**kwargs)[source]

Where the preceding column value is greater than the value specified. There are not set parameters, this methods takes any named keywords and transforms them into arguments that will be passed to the request. E.g. ‘game_id=40’

bitwise(**kwargs)[source]

Some columns are stored as bits within an integer. You can combine any number of options for the column of the object you are querying. This is dependent on which item is being queried. These can be added together to check for multiple options at once. E.g if Option A: 1 and Option B: 2 then submitting 3 will return items that have both option A and B enabled.

sort(key, *, reverse=False)[source]

Allows you to sort the results by the value of a top level column with a single value.

Parameters:
  • key (str) – The column by which to sort the results
  • reverse (Optional[bool]) – Optional, defaults to False. Whether to sort by ascending (False) or descending (True) order.
limit(limit)[source]

Allows to limit the amount of results returned per query.

Parameters:limit (int) – Limit of returned results for the query
offset(offset)[source]

Allows to offset the first result by a certain amount.

Parameters:offset (int) – The number of results to skip.
get_dict()[source]

Utility methods to get all filters while omitting None values

Returns:The dict of filters
Return type:Dict[str, Union[str, int]]
class modio.objects.Pagination(**attrs)[source]

This class is unique to the library and represents the pagination data that some of the endpoints return.

count

Number of results returned by the request.

Type:int
limit

Maximum number of results returned.

Type:int
offset

Number of results skipped over

Type:int
total

Total number of results avalaible for that endpoint with those filters.

Type:int
max()[source]

Returns True if there are no additional results after this set.

min()[source]

Returns True if there are no additional results before this set.

next()[source]

Returns the offset required for the next set of results. If the max results have been reached this returns the current offset.

previous()[source]

Returns the offset required for the previous set of results. If the min results have been reached this returns the current offset.

page()[source]

Returns the current page number. Page numbers start at 0

class modio.objects.Returned[source]

A named tuple returned by certain methods which return multiple results and need to return pagination data along with it.

results

The list of results returned. This is typed accordingly to the method that returns it.

Type:List[Result]
pagination

Pagination metadata attached to the results

Type:Pagination
results

Alias for field number 0

pagination

Alias for field number 1

count()

Return number of occurrences of value.

index()

Return first index of value.

Raises ValueError if the value is not present.

class modio.objects.Object(**attrs)[source]

A dud class that can be used to replace other classes, keyword arguments passed will become attributes.