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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 3

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