{"id":13813453,"url":"https://github.com/allisson/python-preparer","last_synced_at":"2025-05-15T00:33:24.394Z","repository":{"id":57454624,"uuid":"115204847","full_name":"allisson/python-preparer","owner":"allisson","description":"Simple way to build a new dict based on fields declaration","archived":false,"fork":false,"pushed_at":"2019-05-07T19:57:02.000Z","size":12,"stargazers_count":15,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-11T03:53:00.084Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/allisson.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGES.rst","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-23T15:37:41.000Z","updated_at":"2021-06-18T00:57:19.000Z","dependencies_parsed_at":"2022-09-05T05:40:52.033Z","dependency_job_id":null,"html_url":"https://github.com/allisson/python-preparer","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allisson%2Fpython-preparer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allisson%2Fpython-preparer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allisson%2Fpython-preparer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allisson%2Fpython-preparer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/allisson","download_url":"https://codeload.github.com/allisson/python-preparer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225319231,"owners_count":17455731,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T04:01:18.285Z","updated_at":"2024-11-19T08:30:38.160Z","avatar_url":"https://github.com/allisson.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"Python Preparer\n===============\n\n|TravisCI Build Status| |Coverage Status| |Requirements Status| |Version|\n\n----\n\nSimple way to build a new dict based on fields declaration.\n\n\nHow to install\n--------------\n\n.. code:: shell\n\n    pip install preparer\n\n\nHow to use\n----------\n\n.. code:: python\n    \n    from preparer import FieldsPreparer, SubPreparer, CollectionSubPreparer\n\n    xfiles_game = {\n        'description': 'As an extension of one of the most long-running...',\n        'game_id': 1,\n        'genres': [\n            {\n                'genre_category': 'Basic Genres',\n                'genre_category_id': 1,\n                'genre_id': 2,\n                'genre_name': 'Adventure'\n            },\n            {\n                'genre_category': 'Perspective',\n                'genre_category_id': 2,\n                'genre_id': 7,\n                'genre_name': '1st-person'\n            },\n            {\n                'genre_category': 'Narrative Theme/Topic',\n                'genre_category_id': 8,\n                'genre_id': 55,\n                'genre_name': 'Detective / Mystery'\n            },\n            {\n                'genre_category': 'Setting',\n                'genre_category_id': 10,\n                'genre_id': 8,\n                'genre_name': 'Sci-Fi / Futuristic'\n            },\n            {\n                'genre_category': 'Other Attributes',\n                'genre_category_id': 6,\n                'genre_id': 82,\n                'genre_name': 'Licensed Title'\n            }\n        ],\n        'moby_score': 3.8,\n        'moby_url': 'http://www.mobygames.com/game/x-files-game',\n        'num_votes': 53,\n        'official_url': None,\n        'platforms': [\n            {\n                'first_release_date': '1998',\n                'platform_id': 3,\n                'platform_name': 'Windows'\n            },\n            {\n                'first_release_date': '1998-06',\n                'platform_id': 74,\n                'platform_name': 'Macintosh'\n            },\n            {\n                'first_release_date': '1999',\n                'platform_id': 6,\n                'platform_name': 'PlayStation'\n            }\n        ],\n        'sample_cover': {\n            'height': 927,\n            'image': 'http://www.mobygames.com/images/covers/l/3-the-x-files-game...',\n            'platforms': [\n                'Windows'\n            ],\n            'thumbnail_image': 'http://www.mobygames.com/images/covers/s/3-the-x-files...',\n            'width': 800\n        },\n        'sample_screenshots': [\n            {\n                'caption': 'Mulder and Special Agent Willmore',\n                'height': 480,\n                'image': 'http://www.mobygames.com/images/shots/l/86087-the-x-files...',\n                'thumbnail_image': 'http://www.mobygames.com/images/shots/s/86087-the...',\n                'width': 640\n            },\n            {\n                'caption': 'Title screen (from intro)',\n                'height': 480,\n                'image': 'http://www.mobygames.com/images/shots/l/313897-the-x-files-game...',\n                'thumbnail_image': 'http://www.mobygames.com/images/shots/s/313897-the-x...',\n                'width': 640\n            },\n            {\n                'caption': 'Gillian Anderson (from intro)',\n                'height': 480,\n                'image': 'http://www.mobygames.com/images/shots/l/313919-the-x-files-game...',\n                'thumbnail_image': 'http://www.mobygames.com/images/shots/s/313919-the-x...',\n                'width': 640\n            },\n            {\n                'caption': 'David Duchovny (from intro)',\n                'height': 480,\n                'image': 'http://www.mobygames.com/images/shots/l/313908-the-x-files-game-windows...',\n                'thumbnail_image': 'http://www.mobygames.com/images/shots/s/313908-the-x-files...',\n                'width': 640\n            }\n        ],\n        'title': 'The X-Files Game'\n    }\n\n    preparer = FieldsPreparer(fields={\n        'id': 'game_id',\n        'title': 'title',\n        'description': 'description'\n    })\n\n    cover_preparer = FieldsPreparer(fields={\n        'image': 'image',\n        'thumbnail': 'thumbnail_image'\n    })\n    preparer_with_cover = FieldsPreparer(fields={\n        'id': 'game_id',\n        'title': 'title',\n        'description': 'description',\n        'cover': SubPreparer('sample_cover', cover_preparer)\n    })\n\n    screenshot_preparer = FieldsPreparer(fields={\n        'caption': 'caption',\n        'image': 'image',\n        'thumbnail': 'thumbnail_image'\n    })\n    preparer_with_cover_and_screenshots = FieldsPreparer(fields={\n        'id': 'game_id',\n        'title': 'title',\n        'description': 'description',\n        'cover': SubPreparer('sample_cover', cover_preparer),\n        'screenshots': CollectionSubPreparer('sample_screenshots', screenshot_preparer)\n    })\n\n\n.. code:: python\n\n    \u003e\u003e\u003e import pprint\n    \u003e\u003e\u003e pp = pprint.PrettyPrinter(indent=4)\n    \u003e\u003e\u003e pp.pprint(preparer.prepare(xfiles_game))\n    {   'description': 'As an extension of one of the most long-running...',\n        'id': 1,\n        'title': 'The X-Files Game'}\n    \u003e\u003e\u003e pp.pprint(preparer_with_cover.prepare(xfiles_game))\n    {   'cover': {   'image': 'http://www.mobygames.com/images/covers/l/3-the-x-files-game...',\n                     'thumbnail': 'http://www.mobygames.com/images/covers/s/3-the-x-files...'},\n        'description': 'As an extension of one of the most long-running...',\n        'id': 1,\n        'title': 'The X-Files Game'}\n    \u003e\u003e\u003e pp.pprint(preparer_with_cover_and_screenshots.prepare(xfiles_game))\n    {   'cover': {   'image': 'http://www.mobygames.com/images/covers/l/3-the-x-files-game...',\n                     'thumbnail': 'http://www.mobygames.com/images/covers/s/3-the-x-files...'},\n        'description': 'As an extension of one of the most long-running...',\n        'id': 1,\n        'screenshots': [   {   'caption': 'Mulder and Special Agent Willmore',\n                               'image': 'http://www.mobygames.com/images/shots/l/86087-the-x-files...',\n                               'thumbnail': 'http://www.mobygames.com/images/shots/s/86087-the...'},\n                           {   'caption': 'Title screen (from intro)',\n                               'image': 'http://www.mobygames.com/images/shots/l/313897-the-x-files-game...',\n                               'thumbnail': 'http://www.mobygames.com/images/shots/s/313897-the-x...'},\n                           {   'caption': 'Gillian Anderson (from intro)',\n                               'image': 'http://www.mobygames.com/images/shots/l/313919-the-x-files-game...',\n                               'thumbnail': 'http://www.mobygames.com/images/shots/s/313919-the-x...'},\n                           {   'caption': 'David Duchovny (from intro)',\n                               'image': 'http://www.mobygames.com/images/shots/l/313908-the-x-files-game-windows...',\n                               'thumbnail': 'http://www.mobygames.com/images/shots/s/313908-the-x-files...'}],\n        'title': 'The X-Files Game'}\n\nCheck `https://github.com/allisson/python-preparer/tree/master/examples \u003chttps://github.com/allisson/python-preparer/tree/master/examples\u003e`_ for more code examples.\n\n\nCredits\n-------\n\nThis is a fork of excellent https://github.com/toastdriven/restless/blob/master/restless/preparers.py\n\n\n.. |TravisCI Build Status| image:: https://travis-ci.org/allisson/python-preparer.svg?branch=master\n   :target: https://travis-ci.org/allisson/python-preparer\n.. |Coverage Status| image:: https://codecov.io/gh/allisson/python-preparer/branch/master/graph/badge.svg\n   :target: https://codecov.io/gh/allisson/python-preparer\n.. |Requirements Status| image:: https://requires.io/github/allisson/python-preparer/requirements.svg?branch=master\n   :target: https://requires.io/github/allisson/python-preparer/requirements/?branch=master\n.. |Version| image:: https://badge.fury.io/py/preparer.svg\n    :target: https://badge.fury.io/py/preparer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallisson%2Fpython-preparer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fallisson%2Fpython-preparer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallisson%2Fpython-preparer/lists"}