Skip to main content

Generates placeholderfile name

Project description

Placeholder file

Fed up coming up names for your files? Placholder file name generator is your solution. Generates placholder name with any prefix or suffix.

How to use

Installation

Open your terminal and pip install this library like pip install placeholderfile

Trying first code

  • Now import the generator function from the generator module
from placeholderfile.generateName import generateName as gn
  • Now to generate placeholder names for some file specify the suffix and an optional prefix and an optional seed to recreate the results on a different machine:
print(gn(suffix='.jpg'))
print(gn(suffix ='.mp4', prefix='video_'))

Generate a batch of file names

for i in range(5):
    print(gn(suffix =f'_{i}.mp4', prefix='video_'))

Here is an example of how random names are generated

video_lcvddegdtq_0.mp4
video_nqwmjskzxa_1.mp4
video_vbpvbvpyhv_2.mp4
video_olxffcxayv_3.mp4
video_fmopkmtpqg_4.mp4

Practical Example

AKDPRFramework has a built in image downloader module. When downloading image using same name for the image file can create conflict and overwrite the previously dowloaded image. So making a random name for image everytime is a good practice.

Here is an example how AKDPRFramework implements this module

# Genearting a new name for each file downloaded.
from placeholderfile.generateName import generateName as gn

# Download image from the WEB
import requests
from PIL import Image
import io
import os
import sys

def downloadImageFromURL(url):
    '''
    Downloads Image from any image URL
    To know more about what are image URL visit here: https://bit.ly/what-are-imageurl
    '''
    b = requests.get(url).content
    image = Image.open(io.BytesIO(b))

    # Generate a new name for every new image file generated
    filename = gn(suffix='.jpg', prefix=None, seed=None)
    image.save(filename)
    print(f'Image saved at {os.getcwd()}/{filename}')

UUID Generator

placeholderfile can now generate UUIDs for databases.

To be able to generate random 22 character length UUIDs use the following code:

from placeholderfile.UUIDGenerator import UUIDGenerator

generator = UUIDGenerator(dtype='str-major')    # You can choose also 'int-major' for generating integer dominant UUID
uuid = generator.generate()

print(uuid)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

placeholderfile-1.2.tar.gz (3.0 kB view details)

Uploaded Source

File details

Details for the file placeholderfile-1.2.tar.gz.

File metadata

  • Download URL: placeholderfile-1.2.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

File hashes

Hashes for placeholderfile-1.2.tar.gz
Algorithm Hash digest
SHA256 05b111673a03308d2e66b18747c0407f0c013fd31e0a46ce37162efbe693a195
MD5 2780154b4505bb1074e30028a978d2f4
BLAKE2b-256 c717170c3c76d10499cc93d126f6f5814b96a110ecb7b0d70b215bc68616636c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page