Skip to main content

UnicoreFW-py - Unicore Framework in Python


Overview

UnicoreFW-PY, a part of UnicoreFW.org is a Python-based framework based on UnderscoreJS, designed to offer a comprehensive set of utilities and functional programming tools. This framework is equipped with command-line capabilities that allow users to execute example scripts, parse custom command-line arguments, and integrate powerful utility methods for various use cases. The goal of UnicoreFW is to provide security, performance, and ease of use for developers looking to build and maintain Python applications.

Features

  • Flexible Test Execution: Run example scripts through the command line for rapid prototyping and testing.
  • Utility Functions: Includes a robust set of utility methods for functional programming, string manipulation, and more.
  • Secure Execution: Built-in security measures to safely execute code and handle user inputs.

Installation

  1. Clone the repository:

    git clone https://github.com/unicorefw/unicorfw-py.git
    cd unicore-py
    
  2. Ensure Python 3.x is installed on your system.

  3. Install any required dependencies (if applicable):

    pip install -r requirements.txt
    

Directory Structure

project_root_dir/
├── src/
│   └── unicorefw.py
├── examples/
│   └── test.py
└── README.md

Quick Start Guide

from unicorefw import _

  # Example usage
  result = (
      _([1, 2, 3, 4, 5])
      .map(lambda x: x * 2)
      .filter(lambda x: x > 5)
      .value()
  )
  print(result)  # Output: [6, 8, 10]

  # Static function usage
  template = "Name: <%= name %>, Age: <%= age %>"
  context = {"name": "Alice", "age": 25}
  print(_.template(template, context))  # Output: "Name: Alice, Age: 25"

Documention

Please see docs/guide.md for more information.

PYTHON IMPLEMENTATION


This class, unicore, provides a wide range of utility functions for working with arrays, objects, and strings. Here's a summary of what each method does:

Array Functions:

  • map(array, func): Applies a function to each element of an array and returns a new array.
  • filter(array, func): Filters elements in an array based on a predicate function.
  • reduce(array, func, initial=None): Reduces the array to a single value using the provided function.
  • find(array, func): Finds the first element in the array that matches a predicate function.
  • uniq(array): Removes duplicates from an array.
  • flatten(array, depth=float('inf')): Flattens a nested array into a one-dimensional array.
  • first(array, n=1): Returns the first n elements of an array.
  • last(array, n=1): Returns the last n elements of an array.
  • compact(array): Removes falsey values from an array.
  • without(array, *values): Returns an array excluding all provided values.
  • range(start, stop=None, step=1): Generates a range of numbers.
  • intersection(*arrays): Returns an array of values common to all arrays.
  • difference(array, *others): Returns values from the first array not present in others.
  • groupBy(array, key_func): Groups array elements by the result of a function.
  • sortBy(array, key_func): Sorts an array by a function or key.
  • sample(array, n=1): Returns a random sample from an array.
  • zip(*arrays): Combines multiple arrays into an array of tuples.
  • unzip(array_of_tuples): Separates tuples into arrays.

Object Functions:

  • keys(obj): Returns the keys of a dictionary.
  • values(obj): Returns the values of a dictionary.
  • extend(obj, *sources): Extends an object by copying properties from sources.
  • clone(obj): Creates a shallow copy of an object.
  • has(obj, key): Checks if an object has a given property key.
  • defaults(obj, defaults): Assigns default properties to an object if they are missing.
  • invert(obj): Inverts an object's keys and values.

Type Checking Functions:

  • isString(obj): Checks if an object is a string.
  • isNumber(obj): Checks if an object is a number.
  • isArray(obj): Checks if an object is a list.
  • isObject(obj): Checks if an object is a dictionary.
  • isFunction(obj): Checks if an object is callable.
  • isBoolean(obj): Checks if an object is a boolean.
  • isDate(obj): Checks if an object is a date object.
  • isRegExp(obj): Checks if an object is a regular expression.
  • isError(obj): Checks if an object is an error instance.
  • isNull(obj): Checks if an object is None.
  • isUndefined(obj): Checks if an object is undefined.
  • isFinite(obj): Checks if an object is a finite number.
  • isNaN(obj): Checks if an object is NaN.
  • isMap(obj): Checks if an object is a map.
  • isSet(obj): Checks if an object is a set.

Utility Functions:

  • identity(value): Returns the given value unchanged.
  • times(n, func): Calls a function n times.
  • uniqueId(prefix=""): Generates a unique identifier with an optional prefix.
  • escape(string): Escapes HTML characters in a string.
  • unescape(string): Unescapes HTML characters in a string.
  • now(): Returns the current timestamp.
  • memoize(func): Caches the results of function calls.
  • bind(func, context, *args): Binds a function to a context, optionally pre-filling arguments.
  • partial(func, *partial_args): Partially applies arguments to a function.
  • throttle(func, wait): Throttles a function to be called at most once every wait milliseconds.
  • debounce(func, wait): Debounces a function to only be called after wait milliseconds.
  • once(func): Ensures a function is only called once.
  • after(times, func): Returns a function that will only run after it's been called a specified number of times.
  • compose(*funcs): Composes multiple functions to execute in sequence.
  • invoke(array, func_name, *args): Calls a method on each item in an array.
  • matches(attrs): Returns a function that checks if an object matches key-value pairs.
  • allKeys(obj): Returns all keys of an object, including inherited ones

Security Considerations

  • Safe Execution: The framework ensures that code execution is sandboxed and limited in scope to avoid unwanted side effects.
  • Input Validation: Command-line inputs are validated to prevent invalid or malicious commands.

Contributing

We welcome contributions to UnicoreFW! Please follow these steps:

  1. Fork the repository.
  2. Create a feature branch.
  3. Submit a pull request with a detailed description of your changes.

Metadata

Release files for unicorefw 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for unicorefw 0.1.1
File Size Uploaded Provenance Actions
unicorefw-0.1.1.tar.gz 16.6 kB Without provenance Details for unicorefw-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for unicorefw 0.1.1
File Interpreter ABI Platform Actions
unicorefw-0.1.1-py3-none-any.whl Python 3 none any Details for unicorefw-0.1.1-py3-none-any.whl

Total release size: 21.4 kB

Release files / unicorefw-0.1.1.tar.gz

Download URL unicorefw-0.1.1.tar.gz
Size 16.6 kB
Tags Source
SHA-256 checksum
How to use checksums
b0e509e90ce1a218fe0073223f49eaeaf0f26bf48be6c649141534f4cb7e58b1
BLAKE2b-256 checksum
How to use checksums
e1bbfcdf7edbaed472388ff9ef432428ab902c340434da430816d55a84b8abb5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.10

Release files / unicorefw-0.1.1-py3-none-any.whl

Download URL unicorefw-0.1.1-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3da9c4853fd24e033300d9fbbf128cfc16fc226f8fb5cb17a29843a8b6b73c2b
BLAKE2b-256 checksum
How to use checksums
a085f7a6560400759c4117d72e9cb142fa55d932a9596b1c75a74af36e829257
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.10

Security for unicorefw 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page