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)
Release files for placeholderfile 1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| placeholderfile-1.2.tar.gz | 3.0 kB | Details |
Release files / placeholderfile-1.2.tar.gz
| Download URL | placeholderfile-1.2.tar.gz |
|---|---|
| Size | 3.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
05b111673a03308d2e66b18747c0407f0c013fd31e0a46ce37162efbe693a195
|
|
BLAKE2b-256 checksum How to use checksums |
c717170c3c76d10499cc93d126f6f5814b96a110ecb7b0d70b215bc68616636c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|