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.

Files for placeholderfile, version 1.2
Filename, size File type Python version Upload date Hashes
Filename, size placeholderfile-1.2.tar.gz (3.0 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page