nc5ng.types Core Types

PyPi Package: nc5ng-common

Common Base Types, Type Generators and Abstract Base Types for nc5ng

DataPoint Types

Base Datapoint Types

DataPointType Metaclass

class nc5ng.types.DataPointType(name, bases, namespace)[source]

Metaclass for DataPoints, defines class creation and class/hierarchy member variables

The meta-class in part, hides some of the more rote requirements of our datapoint type from the actual object hierarchy

This allows some magic like run-time casting to the correct datapoint without knowing the type specifically, and a persisitent library-wide memory backed database for quick retrieval and to minimize replication

To understand the meta class, there are a number of tutorials available online, roughly speaking this class is what is used to “create” the DataPoint class, and allows us to manipulate the class without needing any implementation details.

Defining a new DataPointType Hierarchy simply requires using this class as the metaclass

class NewDataPoint(metaclass=DataPointType):
pass

By creating a new DataPointType, the following changes will be done to the final class

  • The type will have a database (dictionary) of types registered with the base class
  • Each type and subtype will have a point container (default set) created
  • The shorthand name will be generated from the class name
  • Instance Creation will be overidden and allow creation of any other data type by specifting the type shorthand as an argument

Class Configuration:

Each new type has some meta-configuration available

  1. To override data point registration - Create a @classmethod __register__(cls, point) to overide how a new point is registered/saved - Create a class member _point_store to change the underlying storage type (from set)
  2. Override shorthand name by specific ‘_type_shorthand’ explicitly in the class

Any class that uses this type as a metaclass will be registered

point_database

Return the Root Database of all DataPoints in this Hierarchy

point_store

Return the type-specific Point Buffer

type_shorthand

Get the class shorthand name

Data Parsers

Base Parser Types for nc5ng submodules

class nc5ng.types.parsers.BaseFileParser(parser=None, fdir=None, ffile=None)[source]

Base Class for File Parsers

class nc5ng.types.parsers.FortranFormatFileParser(fformat=None, ffilter=None)[source]

FileParser for Fortran Fixed Format Files

Parameters:
  • fformat – fortran format string
  • ffilter – file pre-filter (exclude/include lines)
class nc5ng.types.parsers.IndexedFortranFormatFileParser(*args, **kwargs)[source]

Extentsion for FortranFileParser that allows classes to switch between pre-registered formats by index

Parameters:
  • args – Either list of [format1,filter1],[format2,filter2],... or serial list format1, filter1, format2, filter2, ...
  • kwargs – Keyword argument dictionary index:[format,filter], dictionary key used for indexing file parser