<commit_before>#
#       License:        BSD
#       Created:        September 4, 2002
#       Author:  <NAME> - <EMAIL>
#
#       $Source: /home/ivan/_/programari/pytables/svn/cvs/pytables/pytables/tables/File.py,v $
#       $Id: File.py,v 1.94 2004/12/24 18:16:01 falted Exp $
#
########################################################################

"""Create PyTables files and the object tree.

This module support importing generic HDF5 files, on top of which
PyTables files are created, read or extended. If a file exists, an
object tree mirroring their hierarchical structure is created in
memory. File class offer methods to traverse the tree, as well as to
create new nodes.

Classes:

    File

Functions:

    copyFile(srcFilename, dstFilename [, title] [, filters]
             [, copyuserattrs] [, overwrite])
    openFile(name [, mode = "r"] [, title] [, trMap])

Misc variables:

    __version__
    format_version
    compatible_formats

"""

__version__ = "$Revision: 1.94 $"
#format_version = "1.0" # Initial format
#format_version = "1.1" # Changes in ucl compression
#format_version = "1.2"  # Support for enlargeable arrays and VLA's
                        # 1.2 was introduced in pytables 0.8
format_version = "1.3"  # Support for indexes in Tables
                        # 1.3 was introduced in pytables 0.9
compatible_formats = [] # Old format versions we can read
                        # Empty means that we support all the old formats

from __future__ import generators

import sys
import warnings
import time
import os, os.path
from fnmatch import fnmatch
import cPickle

import hdf5Extension
from Group import Group
from Leaf import Leaf, Filters
from Table import Table
from Array import Array
from EArray import EArray
from VLArray import VLArray
from UnImplemented import UnImplemented
from AttributeSet import AttributeSet
from exceptions import NodeError
import numarray

def _checkFilters(filters, compress=None, complib=None):
    if (filters is None) and ((compress is not None) or
                              (complib is not None)):
        warnings.warn("The use of compress or complib parameters is deprecated. Please, use a Filters() instance instead.", DeprecationWarning)
        fprops = Filters(complevel=compress, complib=complib)
    elif filters is None:
        fprops = None
    elif isinstance(filters, Filters):
        fprops = filters
    else:
        raise ValueError, "filter parameter has to be None or a Filter instance and the passed type is: '%s'" % type(filters)
    return fprops


def copyFile(srcFilename = None, dstFilename=None, title=None,
             filters=None, copyuserattrs=1, overwrite=0):
    """Copy srcFilename to dstFilename

    The "srcFilename" should exist and "dstFilename" should not. But
    if "dsFilename" exists and "overwrite" is true, it is
    overwritten. "title" lets you put another title to the destination
    file. "copyuserattrs" specifies whether the user attrs in origin
    nodes should be copied or not; the default is copy them. Finally,
    specifiying a "filters" parameter overrides the original filter
    properties of nodes in "srcFilename".

    It returns the number of copied groups, leaves and bytes in the
    form (ngroups, nleaves, nbytes).

    """

    # Open the src file<commit_msg>Fixed exception when using a wrong type for a filter.<commit_after>#
#       License:        BSD
#       Created:        September 4, 2002
#       Author:  <NAME> - <EMAIL>
#
#       $Source: /home/ivan/_/programari/pytables/svn/cvs/pytables/pytables/tables/File.py,v $
#       $Id: File.py,v 1.95 2004/12/29 20:12:49 ivilata Exp $
#
########################################################################

"""Create PyTables files and the object tree.

This module support importing generic HDF5 files, on top of which
PyTables files are created, read or extended. If a file exists, an
object tree mirroring their hierarchical structure is created in
memory. File class offer methods to traverse the tree, as well as to
create new nodes.

Classes:

    File

Functions:

    copyFile(srcFilename, dstFilename [, title] [, filters]
             [, copyuserattrs] [, overwrite])
    openFile(name [, mode = "r"] [, title] [, trMap])

Misc variables:

    __version__
    format_version
    compatible_formats

"""

__version__ = "$Revision: 1.95 $"
#format_version = "1.0" # Initial format
#format_version = "1.1" # Changes in ucl compression
#format_version = "1.2"  # Support for enlargeable arrays and VLA's
                        # 1.2 was introduced in pytables 0.8
format_version = "1.3"  # Support for indexes in Tables
                        # 1.3 was introduced in pytables 0.9
compatible_formats = [] # Old format versions we can read
                        # Empty means that we support all the old formats

from __future__ import generators

import sys
import warnings
import time
import os, os.path
from fnmatch import fnmatch
import cPickle

import hdf5Extension
from Group import Group
from Leaf import Leaf, Filters
from Table import Table
from Array import Array
from EArray import EArray
from VLArray import VLArray
from UnImplemented import UnImplemented
from AttributeSet import AttributeSet
from exceptions import NodeError
import numarray

def _checkFilters(filters, compress=None, complib=None):
    if (filters is None) and ((compress is not None) or
                              (complib is not None)):
        warnings.warn("The use of compress or complib parameters is deprecated. Please, use a Filters() instance instead.", DeprecationWarning)
        fprops = Filters(complevel=compress, complib=complib)
    elif filters is None:
        fprops = None
    elif isinstance(filters, Filters):
        fprops = filters
    else:
        raise TypeError, "filter parameter has to be None or a Filter instance and the passed type is: '%s'" % type(filters)
    return fprops


def copyFile(srcFilename = None, dstFilename=None, title=None,
             filters=None, copyuserattrs=1, overwrite=0):
    """Copy srcFilename to dstFilename

    The "srcFilename" should exist and "dstFilename" should not. But
    if "dsFilename" exists and "overwrite" is true, it is
    overwritten. "title" lets you put another title to the destination
    file. "copyuserattrs" specifies whether the user attrs in origin
    nodes should be copied or not; the default is copy them. Finally,
    specifiying a "filters" parameter overrides the original filter
    properties of nodes in "srcFilename".

    It returns the number of copied groups, leaves and bytes in the
    form (ngroups, nleaves, nbytes).

    """

    # Open the src file
{'fraction_non_alphanumeric': 0.0934873949579832, 'fraction_numerical': 0.013505402160864346, 'mean_word_length': 3.231746031746032, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4689197', 'n_tokens_mistral': 1899, 'n_tokens_neox': 1790, 'n_words': 754}