Skip to main content

No project description provided

Project description

Pappardelle

Pappardelle is a Python module that provides helper functions for lists and dates.

Test status

Getting Started

Install the Python module with

python3 -m pip install pappardelle

Then, within your Python (.py) source code, like in this example:

from pappardelle import compare_lists

# Call the imported function:
compare_lists(
    [1, 2, 3],
    [2, 3, 5]
)

# Returns the following
{
    '=': [2, 3],
    '+': [1],
    '-': [5]
}

Change Log

  • Version 0.16
    • are_dict_equal now handles None values correctly
  • Version 0.15
    • are_dict_equal added
  • Version 0.14
    • Version pulled because are_dict_equal was not in the init.py
  • Version 0.13
    • Added value_or_default (because string_or_default only worked with strings)
  • Version 0.12
    • Added if_whitespace_make_null
  • Version 0.11
    • string_or_default accepts varargs, instead of only 2 parameters
  • Version 0.9
    • Added list_first
  • Version 0.8
    • Renamed deep_copy_dict_no_overwrite to deep_copy_dict
  • Version 0.7
    • Added deep_copy_dict_no_overwrite
  • Version 0.6
    • Added get_dict_path
  • Version 0.5
    • Added make_dict_path, set_dict_path
  • Version 0.4
    • Added a function decorator for measuring the function execution time
  • Version 0.3
    • Use date as the default type for day/week/month/year relative functions, and datetime as the default type for hour/minute/second relative functions
  • Version 0.2
    • compare_lists returns a dictionary with keys: =, +, - (instead of: matched, + -)
    • Added relative date functions
  • Version 0.1
    • First release with compare_lists and lookup_lists functions

References

List Functions

compare_lists(list1, list2, optional lambda comparator)

lookup_lists(list1, list2, optional lambda comparator)

Date Functions

days_before(num_of_days, from_date)

days_ago(num_of_days)

days_after(num_of_days, from_date)

days_since(num_of_days, from_date)

tomorrow()

yesterday()

days_before_at_this_time(num_of_days, from_datetime)

days_ago_at_this_time(num_of_days, from_datetime)

days_after_at_this_time(num_of_days, from_datetime)

days_since_at_this_time(num_of_days, from_datetime)

tomorrow_at_this_time()

yesterday_at_this_time()

hours_before(num_of_hours, from_date)

hours_ago(num_of_hours)

hours_after(num_of_hours, from_date)

hours_since(num_of_hours, from_date)

minutes_before(num_of_minutes, from_date)

minutes_ago(num_of_minutes)

minutes_after(num_of_minutes, from_datee)

minutes_since(num_of_minutes, from_date)

seconds_before(num_of_seconds, from_date)

seconds_ago(num_of_seconds)

seconds_after(num_of_seconds, from_date)

seconds_since(num_of_seconds, from_date)

weeks_before(num_of_weeks, from_date)

weeks_ago(num_of_weeks)

weeks_after(num_of_weeks, from_date)

weeks_since(num_of_weeks, from_date)

weeks_before_at_this_time(num_of_weeks, from_datetime)

weeks_ago_at_this_time(num_of_weeks, from_datetime)

weeks_after_at_this_time(num_of_weeks, from_datetime)

weeks_since_at_this_time(num_of_weeks, from_datetime)

months_before(num_of_months, from_date)

months_ago(num_of_months)

months_after(num_of_months, from_date)

months_since(num_of_months, from_date)

months_before_at_this_time(num_of_months, from_datetime)

months_ago_at_this_time(num_of_months, from_datetime)

months_after_at_this_time(num_of_months, from_datetime)

months_since_at_this_time(num_of_months, from_datetime)

years_before(num_of_years, from_date)

years_ago(num_of_years)

years_after(num_of_years, from_date)

years_since(num_of_years, from_date)

years_before_at_this_time(num_of_years, from_datetime)

years_ago_at_this_time(num_of_years, from_datetime)

years_after_at_this_time(num_of_years, from_datetime)

years_since_at_this_time(num_of_years, from_datetime)

Dictionary Functions

make_dict_path(a_dict, a_path)

set_dict_path(a_dict, a_path, a_val)

get_dict_path(a_dict, a_path)

deep_copy_dict(a_src, a_dest, optional overwrite)

are_dict_equal(first, second)

Function Decorators

exec_time

String Functions

string_or_default(primary_value, secondary_value)

is_null_or_whitespace(val)

is_null_or_empty(val)

str_ignorecase_equals(str1, str2)

str_ignorecase_index(str1, str2)

Value Functions

value_or_default(primary_value, secondary_value)

Author

My name is Katkam Nitin Reddy. I am a former software developer living (mostly) in Dubai. I created this library for functionality that I find myself re-writing in my scripts.

Acknowledgement

I would like to thank my mom, Katkam Nita Reddy, and my dad, Katkam Narsing Reddy, who have always motivated me to learn and contribute to the open-source community.

Examples

Example 1. Within a Server State Management application

from pappardelle import compare_lists
from pprint import pprint

desired_state = [
  {"package_name": "net-tools"},
  {"package_name": "build-essential"},
  {"package_name": "bind9-dnsutils"}
]

current_state = [
  {"package_name": "build-essential"},
  {"package_name": "squid"}
]

change_plan = compare_lists(
  desired_state,
  current_state,
  lambda x, y: x['package_name'] == y['package_name']
)

pprint(change_plan)

# Output
# {'+': [{'package_name': 'net-tools'}, {'package_name': 'bind9-dnsutils'}],
# '-': [{'package_name': 'squid'}],
# '=': [{'package_name': 'build-essential'}]}

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

pappardelle-0.16.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pappardelle-0.16-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file pappardelle-0.16.tar.gz.

File metadata

  • Download URL: pappardelle-0.16.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.6

File hashes

Hashes for pappardelle-0.16.tar.gz
Algorithm Hash digest
SHA256 6ffce7d76d5dbb9ea88d2808260abcdf00cf8fa69eceaf3537b9c5237068c6c3
MD5 8f1a6936f00a0c445e5a65a6588ab4ba
BLAKE2b-256 6afb28cb1e506a76d5a6b2a9e7b4c7183e518b3605352cb0d38b4388e95ee01f

See more details on using hashes here.

File details

Details for the file pappardelle-0.16-py3-none-any.whl.

File metadata

  • Download URL: pappardelle-0.16-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.6

File hashes

Hashes for pappardelle-0.16-py3-none-any.whl
Algorithm Hash digest
SHA256 6d7303ea7558bf7ffbcd5823497485ba2df42402cd734d22a705573a9f630268
MD5 384e91979bd07a31c3ea515faf5992ec
BLAKE2b-256 31c11afb8f93e60d919c8ea43a7e53e72ab566cf8994fe447d000ab66905d22b

See more details on using hashes here.

Supported by

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