Skip to main content

The CCP Tools team utilities for date and/or time objects and values and messing with types.

Project description

CCP Games Python Toolkit

A smooshup of a few Python packages from the CCP Tools Team of old (Team Batcave).

Our two most commonly used internal packages, called datetimeutils and typeutils were too generically named for Pypi.org and since they were both used in something like 80-90% of our other projects, it made sense to just smoosh them together in one module, and thus, the ccptools package was born.

Here's the README of the Date Time Utils submodule.

Here's the README of the Type Utils submodule.

Date-Time Utils

The old datetimeutils package is now included here as the dtu submodule.

from ccptools import dtu

Changes from datetimeutils

The name has been shortened to dtu to speed up usage (although you can also just go from ccptools.dtu import * if you wish).

The code has also been quite heavily refactored but everything that was available in datetimeutils 2.3.0.0 should be accessible via ccptools.legacyapi.datetimeutils.

That is, for a super low-effort upgrade from older datetimeutils version to the new ccptools package, simply replace...:

import datetimeutils

...with...

from ccptools.legacyapi import datetimeutils

...and everything should work fine! :)

Note that any Python 2.7 support has been removed.

Changes from typeutils

The name has been shortened to tpu although that's more to fit in with the dtu pattern. It shouldn't really matter since typeutils was rarely if ever imported directly since it was split into multiple submodules from the start.

Nevertheless to accommodate any changed from typeutils 3.5.0.0 and ease migration over to ccptools the old API is aliased in ccptools.legacyapi.typeutils.

So you can simply replace

from typeutils import metas

...with...

from ccptools.legacyapi.typeutils import metas

...and everything should work fine! :)

Note that any Python 2.7 support has been removed.

Structs

Importing * from the structs submodule will import all of the most commonly used imports in our projects:

from typing import *  # For type annotation

import abc  # For interfaces (Abstract Base Classes)
import dataclasses  # For dataclass structs
import decimal  # Used whenever we're handling money
import enum  # Also used for struct creation
import logging  # Used pretty much everywhere
import re  # Used surprisingly frequently
import time  # Very commonly used

Note that datetime is not included in this. That's because tt'll also import the aliases from the Datetime Utils (ccptools.dtu.structs.aliases) package instead:

Date = datetime.date
Time = datetime.time
Datetime = datetime.datetime
TimeDelta = datetime.timedelta
TzInfo = datetime.tzinfo
TimeZone = datetime.timezone

Furthermore, it'll also include a few of the most commonly used utility classes from the Type Utils submodule:

  • The Singleton Meta Class
  • The Empty and EmptyDict classes as well as the if_empty method
  • The EnumEx base class for Enums with the from_any class method

So in most cases we can cover something like 90% of any imports we tend to need in every Python file with a single line:

from ccptools.structs import *

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

ccptools-1.2.0.tar.gz (48.2 kB view details)

Uploaded Source

Built Distribution

ccptools-1.2.0-py3-none-any.whl (67.2 kB view details)

Uploaded Python 3

File details

Details for the file ccptools-1.2.0.tar.gz.

File metadata

  • Download URL: ccptools-1.2.0.tar.gz
  • Upload date:
  • Size: 48.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.19

File hashes

Hashes for ccptools-1.2.0.tar.gz
Algorithm Hash digest
SHA256 f18f78c4ab146ce681e5e4c13804eec760cd5b8de41aabd7bdea1839b4935334
MD5 cb51a0d7ba1139de6f26e799a7c53d96
BLAKE2b-256 cce790e70cac856b9c61ce0501d2de76ec42959778ff817c50840bdada420911

See more details on using hashes here.

File details

Details for the file ccptools-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: ccptools-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 67.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.19

File hashes

Hashes for ccptools-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 52e7bc73d9bc6fbc743e9795b2b497580ebc37d3b8b82f958ea960cf345b4b69
MD5 07f160b03d10fbe32c290c7802c62735
BLAKE2b-256 86ff028ac6de1a9b6112cdf2bb4b1e7431a1a7c4970e2b588eafe8392396e5f7

See more details on using hashes here.

Supported by

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