<commit_before># -*- coding: utf-8 -*-
""" Wrap xtide's libtcd.
"""
from __future__ import absolute_import

from ctypes import *

ENCODING = 'iso-8859-1'                 # all strings encoded iso-8859-1

assert sizeof(c_float) == 4
c_float32 = c_float
assert sizeof(c_double) == 8
c_float64 = c_double

ONELINER_LENGTH = 90
MONOLOGUE_LENGTH = 10000
MAX_CONSTITUENTS = 255

# enum TIDE_RECORD_TYPE
REFERENCE_STATION = 1
SUBORDINATE_STATION = 2

NULLSLACKOFFSET = 0xA00
AMPLITUDE_EPSILON = 0.00005


class DB_HEADER_PUBLIC(Structure):
    _fields_ = [
        ('version', c_char * ONELINER_LENGTH),
        ('major_rev', c_uint32),
        ('minor_rev', c_uint32),
        ('last_modified', c_char * ONELINER_LENGTH),
        ('number_of_records', c_uint32),
        ('start_year', c_int32),
        ('number_of_years', c_uint32),
        ('constituents', c_uint32),
        ('level_unit_types', c_uint32),
        ('dir_unit_types', c_uint32),
        ('restriction_types', c_uint32),
        ('datum_types', c_uint32),
        ('countries', c_uint32),
        ('tzfiles', c_uint32),
        ('legaleses', c_uint32),
        ('pedigree_types', c_uint32),
        ]


class TIDE_STATION_HEADER(Structure):
    _fields_ = [
        ('record_number', c_int32),
        ('record_size', c_uint32),
        ('record_type', c_uint8),
        ('latitude', c_float64),
        ('longitude', c_float64),
        ('reference_station', c_int32),
        ('tzfile', c_int16),
        ('name', c_char * ONELINER_LENGTH),
        ]


class TIDE_RECORD(Structure):
    _anonymous_ = ['header']
    _fields_ = [
        ('header', TIDE_STATION_HEADER),
        ('country', c_int16),
        ('source', c_char * ONELINER_LENGTH),
        ('restriction', c_uint8),
        ('comments', c_char * MONOLOGUE_LENGTH),
        ('notes', c_char * MONOLOGUE_LENGTH),
        ('legalese', c_uint8),
        ('station_id_context', c_char * ONELINER_LENGTH),
        ('station_id', c_char * ONELINER_LENGTH),
        ('date_imported', c_uint32),
        ('xfields', c_char * MONOLOGUE_LENGTH),
        ('direction_units', c_uint8),
        ('min_direction', c_int32),
        ('max_direction', c_int32),
        ('level_units', c_uint8),

        # type 1 only
        ('datum_offset', c_float32),
        ('datum', c_int16),
        ('zone_offset', c_int32),
        ('expiration_date', c_uint32),
        ('months_on_station', c_uint16),
        ('last_date_on_station', c_uint32),
        ('confidence', c_uint8),
        ('amplitude', c_float32 * MAX_CONSTITUENTS),
        ('epoch', c_float32 * MAX_CONSTITUENTS),

        # type 2 only
        ('min_time_add', c_int32),
        ('min_level_add', c_float32),
        ('min_level_multiply', c_float32),
        ('max_time_add', c_int32),
        ('max_level_add', c_float32),
        ('max_level_multiply', c_float32),
        ('flood_begins', c_int32),
        ('ebb_begins', c_int32),
        ]


class Error(Exception):
    pass

_lib = cdll.LoadLibrary("libtcd.so.0")


def _check_bool(result, func, args):
    if not result:
        raise Error("%s failed" % func.__name__)
    return args

# FIXME: dump_tide_record<commit_msg>Delete stale comment<commit_after># -*- coding: utf-8 -*-
""" Wrap xtide's libtcd.
"""
from __future__ import absolute_import

from ctypes import *

ENCODING = 'iso-8859-1'                 # all strings encoded iso-8859-1

assert sizeof(c_float) == 4
c_float32 = c_float
assert sizeof(c_double) == 8
c_float64 = c_double

ONELINER_LENGTH = 90
MONOLOGUE_LENGTH = 10000
MAX_CONSTITUENTS = 255

# enum TIDE_RECORD_TYPE
REFERENCE_STATION = 1
SUBORDINATE_STATION = 2

NULLSLACKOFFSET = 0xA00
AMPLITUDE_EPSILON = 0.00005


class DB_HEADER_PUBLIC(Structure):
    _fields_ = [
        ('version', c_char * ONELINER_LENGTH),
        ('major_rev', c_uint32),
        ('minor_rev', c_uint32),
        ('last_modified', c_char * ONELINER_LENGTH),
        ('number_of_records', c_uint32),
        ('start_year', c_int32),
        ('number_of_years', c_uint32),
        ('constituents', c_uint32),
        ('level_unit_types', c_uint32),
        ('dir_unit_types', c_uint32),
        ('restriction_types', c_uint32),
        ('datum_types', c_uint32),
        ('countries', c_uint32),
        ('tzfiles', c_uint32),
        ('legaleses', c_uint32),
        ('pedigree_types', c_uint32),
        ]


class TIDE_STATION_HEADER(Structure):
    _fields_ = [
        ('record_number', c_int32),
        ('record_size', c_uint32),
        ('record_type', c_uint8),
        ('latitude', c_float64),
        ('longitude', c_float64),
        ('reference_station', c_int32),
        ('tzfile', c_int16),
        ('name', c_char * ONELINER_LENGTH),
        ]


class TIDE_RECORD(Structure):
    _anonymous_ = ['header']
    _fields_ = [
        ('header', TIDE_STATION_HEADER),
        ('country', c_int16),
        ('source', c_char * ONELINER_LENGTH),
        ('restriction', c_uint8),
        ('comments', c_char * MONOLOGUE_LENGTH),
        ('notes', c_char * MONOLOGUE_LENGTH),
        ('legalese', c_uint8),
        ('station_id_context', c_char * ONELINER_LENGTH),
        ('station_id', c_char * ONELINER_LENGTH),
        ('date_imported', c_uint32),
        ('xfields', c_char * MONOLOGUE_LENGTH),
        ('direction_units', c_uint8),
        ('min_direction', c_int32),
        ('max_direction', c_int32),
        ('level_units', c_uint8),

        # type 1 only
        ('datum_offset', c_float32),
        ('datum', c_int16),
        ('zone_offset', c_int32),
        ('expiration_date', c_uint32),
        ('months_on_station', c_uint16),
        ('last_date_on_station', c_uint32),
        ('confidence', c_uint8),
        ('amplitude', c_float32 * MAX_CONSTITUENTS),
        ('epoch', c_float32 * MAX_CONSTITUENTS),

        # type 2 only
        ('min_time_add', c_int32),
        ('min_level_add', c_float32),
        ('min_level_multiply', c_float32),
        ('max_time_add', c_int32),
        ('max_level_add', c_float32),
        ('max_level_multiply', c_float32),
        ('flood_begins', c_int32),
        ('ebb_begins', c_int32),
        ]


class Error(Exception):
    pass

_lib = cdll.LoadLibrary("libtcd.so.0")


def _check_bool(result, func, args):
    if not result:
        raise Error("%s failed" % func.__name__)
    return args

{'fraction_non_alphanumeric': 0.14133714467206607, 'fraction_numerical': 0.04033666825472447, 'mean_word_length': 2.8216019417475726, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3901572', 'n_tokens_mistral': 2410, 'n_tokens_neox': 2213, 'n_words': 409}