<commit_before># -*- coding: utf-8 -*-

import os
import math
import string
import sys
import re

import arcpy
from arcpy.sa import *

import xml.etree.cElementTree as et
import glob

# import our local directory so we can import internal modules
local_path = os.path.dirname(__file__)
sys.path.insert(0, local_path)

# status messages
MSG_INVALID_GRID = "ESRI GRIDs must >= 13 characters and contain only " \
                   "letters, numbers and the underscore ('_') character."
MSG_INVALID_RADIUS = "Outer radius must exceed inner radius."

def raster_is_grid(raster_path):
    is_grid = False
    ext = os.path.splitext(raster_path)[1]
    # if the file has a GRID-like name but exists within a GDB, its a-ok
    if ext == "" and raster_path.lower().find(".gdb") == -1:
        is_grid = True
    return is_grid

# Validate ESRI GRID filenames. The file doesn't exist, so use naming to 
# validate a potential name.
def valid_grid_name(raster_path):
    valid = True
    # GRIDs are the default for any file without a trailing extension.
    if raster_is_grid(raster_path):
        if len(raster_path) > 128:
            valid = False
        else:
            grid_name = os.path.basename(raster_path)
            """
            Encode all the rules into a regular expression:
             - no longer than 13 characters
             - must start with a letter<commit_msg>ignore tempfile locations for grids.<commit_after># -*- coding: utf-8 -*-

import os
import math
import string
import sys
import re
import tempfile

import arcpy
from arcpy.sa import *

import xml.etree.cElementTree as et
import glob

# import our local directory so we can import internal modules
local_path = os.path.dirname(__file__)
sys.path.insert(0, local_path)

# status messages
MSG_INVALID_GRID = "ESRI GRIDs must >= 13 characters and contain only " \
                   "letters, numbers and the underscore ('_') character."
MSG_INVALID_RADIUS = "Outer radius must exceed inner radius."

def raster_is_grid(raster_path):
    is_grid = False
    ext = os.path.splitext(raster_path)[1]
    temp_dir = tempfile.gettempdir()
    if ext == "":
        # if the file has a GRID-like name but exists within a GDB, its a-ok
        if raster_path.lower().find(".gdb") == -1:
            is_grid = True
        # intermediate processing steps get generated by ModelBuilder
        # within the temp dir, skip these as they are only placeholder
        # names and work despite being invalid GRID names.
        if raster_path.lower().find(temp_dir) >= 0:
            is_grid = False
    return is_grid

# Validate ESRI GRID filenames. The file doesn't exist, so use naming to 
# validate a potential name.
def valid_grid_name(raster_path):
    valid = True
    # GRIDs are the default for any file without a trailing extension.
    if raster_is_grid(raster_path):
        if len(raster_path) > 128:
            valid = False
        else:
            grid_name = os.path.basename(raster_path)
            """
            Encode all the rules into a regular expression:
             - no longer than 13 characters
             - must start with a letter
{'fraction_non_alphanumeric': 0.07753669432035737, 'fraction_numerical': 0.007338864071474154, 'mean_word_length': 2.710059171597633, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '3478439', 'n_tokens_mistral': 939, 'n_tokens_neox': 912, 'n_words': 338}