GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - tsaklidis/Utilities: Python utilities in order code faster. Time calculator, unique string generator and some user input sanitization

BranchesTags
Open more actions menu

Latest commit

 

History

46 Commits
46 Commits

Folders and files

NameName
Last commit message
Last commit date
utilities
utilities
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 

Repository files navigation

Info

Python utilities in order to make your coding life easier
Some of the functions, are unable to run as a single python code so you have to create Django project.

Also use python3


Sanitize user's input

All functions return the data if all checks are ok.
If there is any strange character that doesn't match, a custom Exception is raised
Example 1:
import sanitize
data = 'rocky_99'
try:
	sanitize.alphanumeric(data)
    # Register user 
except sanitize.SanitizationException as e:
	print(e)
Example 2:
Check for password strength. If password is strength (check function comments),
the same password is returned. Otherwise Exception is raised
import sanitize
data = 'p@as$wor!2'

try:
	sanitize.password_check(data)
	# Do what you need
except sanitize.SanitizationException as e:
	# Something is wrong, print the errors
	print(e)

Create random unique string

unique.get

Returns a random unique string. Uniquines is based on timestamp. Default length is 8.
Argumentrs: length, prefix, suffix, invalid_chars
Example 1:
If you need to get a random unique string of 16 chars with prefix 'user'
get(16, 'user')
Example 2:
If you need to get a random unique string of 6 chars but don't use the chars 'ofdA'
avoid_chars = 'ofdAre'
get(6, invalid_chars=avoid_chars)

Time calculator

First of all you need to import datetime

Days from today

Returns the date after given days. If true is passed, hence will be calculated backwords
Example 1:
If you need to get the date after one week
days_hence(7)
Example 2:
If you need to get the date before 5 days
calculate_back = True
days_hence(5, calculate_back)

Ensure age of at least 18 years old.

Example 1:
Find if the given birthdate is adult. Default adult years are 18.
sample_date = datetime.date(1987, 8, 13)
is_adult(sample_date)

If the given date is over 18 years old, returns True else False

Example 2:
sample_date = datetime.date(1987, 8, 13)
adult_years = 21
is_adult(sample_date, adult_years)

In some countries adultd age differs, so pass the years you need


Make requests to external sites

Example 1:
Make a request and return the answer in json format. Chech function definition for more.
send_request('GET', 'some/api/', return_json=True, debug=True)

About

Python utilities in order code faster. Time calculator, unique string generator and some user input sanitization

Topics

python-utilitiesutilities

Resources

Readme
MIT license
Activity

Stars

3 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.