<commit_before># nc_diag_attr

from netCDF4 import Dataset, getlibversion
import netCDF4
import argparse
import sys
import traceback
import numpy

try:
    import ujson as json
except:
    import json

# Version information
__version__ = "0.9b"

VERSION_STR = 'nc_diag_attr v' + __version__ + "\n\n" + \
    "Using the following library/runtime versions:\n" + \
    ("    netcdf4-python v%s\n" % netCDF4.__version__) + \
    ("    NetCDF v%s\n" % getlibversion()) + \
    ("    HDF5 v%s\n" % netCDF4.__hdf5libversion__) + \
    ("    Python v%s\n" % sys.version.split("\n")[0].strip())

# CLI Arguments
global args

def parse_cli_args():
    global args
    parser = argparse.ArgumentParser( #prog='ipush',
    formatter_class=argparse.RawDescriptionHelpFormatter,
    description="Tool to add/modify global and variable attributes for NetCDF files",
    version = VERSION_STR)
    
    disable_group = parser.add_mutually_exclusive_group()
    
    parser.add_argument("-V", "--verbose", 
        dest="verbose", action="store_true", default=False,
        help = "enable verbose output")
    parser.add_argument("-p", "--pretty", 
        dest="pretty_output", action="store_true", default=False,
        help = "enable colorful, pretty output - don't enable if logging")
    
    disable_group.add_argument("-ng", "--no-global",
        dest="global_attributes", action="store_false", default=True,
        help = "disable global attribute adding/modifying")
    disable_group.add_argument("-nv", "--no-var", 
        dest="var_attributes", action="store_false", default=True,
        help = "disable variable attribute adding/modifying")
    
    parser.add_argument("-i", metavar = "RESOURCE_FILE", dest="resource_file",
        help = "input JSON resource file name with attributes to write", required = True)
    parser.add_argument("nc4_files", help = "NetCDF4 files to apply attributes to", nargs="+")<commit_msg>Changed resource file option -i to -rc to standardize with GMAO tools<commit_after># nc_diag_attr

from netCDF4 import Dataset, getlibversion
import netCDF4
import argparse
import sys
import traceback
import numpy

try:
    import ujson as json
except:
    import json

# Version information
__version__ = "0.9b"

VERSION_STR = 'nc_diag_attr v' + __version__ + "\n\n" + \
    "Using the following library/runtime versions:\n" + \
    ("    netcdf4-python v%s\n" % netCDF4.__version__) + \
    ("    NetCDF v%s\n" % getlibversion()) + \
    ("    HDF5 v%s\n" % netCDF4.__hdf5libversion__) + \
    ("    Python v%s\n" % sys.version.split("\n")[0].strip())

# CLI Arguments
global args

def parse_cli_args():
    global args
    parser = argparse.ArgumentParser( #prog='ipush',
    formatter_class=argparse.RawDescriptionHelpFormatter,
    description="Tool to add/modify global and variable attributes for NetCDF files",
    version = VERSION_STR)
    
    disable_group = parser.add_mutually_exclusive_group()
    
    parser.add_argument("-V", "--verbose", 
        dest="verbose", action="store_true", default=False,
        help = "enable verbose output")
    parser.add_argument("-p", "--pretty", 
        dest="pretty_output", action="store_true", default=False,
        help = "enable colorful, pretty output - don't enable if logging")
    
    disable_group.add_argument("-ng", "--no-global",
        dest="global_attributes", action="store_false", default=True,
        help = "disable global attribute adding/modifying")
    disable_group.add_argument("-nv", "--no-var", 
        dest="var_attributes", action="store_false", default=True,
        help = "disable variable attribute adding/modifying")
    
    parser.add_argument("-rc", metavar = "RESOURCE_FILE", dest="resource_file",
        help = "input JSON resource file name with attributes to write", required = True)
    parser.add_argument("nc4_files", help = "NetCDF4 files to apply attributes to", nargs="+")
{'fraction_non_alphanumeric': 0.1276595744680851, 'fraction_numerical': 0.006152268649064343, 'mean_word_length': 3.590588235294118, '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': '2461536', 'n_tokens_mistral': 1211, 'n_tokens_neox': 1202, 'n_words': 300}