diff --git a/MockupEngineer/__init__.py b/MockupEngineer/__init__.py index fb1c58c..520f3be 100644 --- a/MockupEngineer/__init__.py +++ b/MockupEngineer/__init__.py @@ -1,9 +1,9 @@ import logging import os + +from TemporaryStorage import TemporaryStorageInstance from importlib import import_module - from typing import List - from PIL import Image from MockupEngineer import templates @@ -18,6 +18,7 @@ class MockupEngineerInstance: def __init__(self): self.logger = logging.getLogger('MockupEngineer') self.templates: List[templates.Template] = [] + self.storage = TemporaryStorageInstance() for template in templates.ALL_TEMPLATES: self.templates.append(getattr( @@ -83,7 +84,7 @@ class MockupEngineerInstance: def generate(self, template: templates.Template, screenshot_path: str, color: str = None, - orientation: str = None) -> str: + orientation: str = None, external_storage: bool = False) -> str: if not orientation: img = Image.open(screenshot_path) width, height = img.size @@ -128,4 +129,13 @@ class MockupEngineerInstance: os.remove(resized_screenshot_path) - return mockup_path + if not external_storage: + return mockup_path + else: + uploaded = self.storage.upload(mockup_path) + + if uploaded and uploaded.url: + os.remove(mockup_path) + return uploaded.url + else: + return mockup_path diff --git a/MockupEngineer/__main__.py b/MockupEngineer/__main__.py index 682dec1..54c2b7b 100644 --- a/MockupEngineer/__main__.py +++ b/MockupEngineer/__main__.py @@ -20,7 +20,7 @@ def main(): print('- - - - - - - - - -') screenshot = input('Enter path to screenshot: ') print('- - - - - - - - - -\nWorking...') - mockup = mockup.generate(template, screenshot, color) + mockup = mockup.generate(template, screenshot, color, external_storage=True) print('- - - - - - - - - -\nSuccess: {}'.format(mockup)) os.system('open {}'.format(mockup)) diff --git a/readme.md b/readme.md index 958b1b2..2daf0f0 100644 --- a/readme.md +++ b/readme.md @@ -13,8 +13,8 @@ * [Example](https://github.com/ulbwazhine/MockupEngineer#example) * [Install](https://github.com/ulbwazhine/MockupEngineer#install) * [Usage](https://github.com/ulbwazhine/MockupEngineer#usage) - * [In Python console](https://github.com/ulbwazhine/MockupEngineer#in-python-console) * [As a standalone application](https://github.com/ulbwazhine/MockupEngineer#as-a-standalone-application) + * [In Python console](https://github.com/ulbwazhine/MockupEngineer#in-python-console) * [List of supported mockups](https://github.com/ulbwazhine/MockupEngineer#list-of-supported-mockups) * [Phones](https://github.com/ulbwazhine/MockupEngineer#phones) * [Tablets](https://github.com/ulbwazhine/MockupEngineer#tablets) @@ -36,6 +36,11 @@ $ python3 -m pip install MockupEngineer ## Usage +#### As a standalone application: +```console +$ python3 -m MockupEngineer +``` + #### In Python console: ```python @@ -52,10 +57,12 @@ mockup.generate(template=mockup.templates[0], >>> /path/to/mockup ``` -#### As a standalone application: -```console -$ python3 -m MockupEngineer -``` +##### `MockupEngineerInstance.generate` parameters: + * `template`: *Template* — Device template model, must be passed from *MockupEngineerInstance.templates* or *MockupEngineerInstance.get_templates()*. + * `screenshot_path`: *str* — Absolute path to the image in **JPG, PNG format**. + * `color`: *Optional[str]* — Optional parameter, force device color. Must be passed according to *Template.colors[**n**].color* + * `orientation`: *str* — Optional parameter, force device orientation. Must be *landscape* or *portrait*. + * `external_storage`: *Optional[bool]* — Optional parameter, true if you need to upload mockup on [TemporaryStorage](https://github.com/ulbwazhine/TemporaryStorage) (0x0.st etc) ## List of supported mockups diff --git a/requirements.txt b/requirements.txt index 2a5c5af..d5d121e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,4 @@ Pillow>=8.4.0 -setuptools>=59.2.0 \ No newline at end of file +setuptools>=59.2.0 +MockupEngineer>=2022.1.23.18 +TemporaryStorage>=2022.1.25.3 \ No newline at end of file diff --git a/setup.py b/setup.py index 48f54ce..0cf5b00 100644 --- a/setup.py +++ b/setup.py @@ -3,13 +3,13 @@ from setuptools import setup, find_packages setup( name='MockupEngineer', - version='2022.01.23.19', + version='2022.01.25.1', packages=find_packages(), url='https://github.com/ulbwazhine/MockupEngineer', license='MIT', author='Ulbwazhine', author_email='ulbwa@icloud.com', - description='An simple library for creating beautiful screenshots.', + description='A simple library for creating beautiful screenshots.', install_requires=[line.strip() for line in open("requirements.txt").readlines()], long_description=open('readme.md', 'r').read(), long_description_content_type='text/markdown',