<commit_before>#!/usr/bin/env python

# Copyright (c) 2001, MetaSlash Inc.  All rights reserved.

"""
Module to hold manipulation of elements on the stack.
"""

import types


DATA_UNKNOWN = "-unknown-"

# These should really be defined by subclasses
TYPE_FUNC_RETURN = "-return-value-"
TYPE_ATTRIBUTE = "-attribute-"
TYPE_COMPARISON = "-comparison-"
TYPE_GLOBAL = "-global-"

class Item :
    "Representation of data on the stack"

    def __init__(self, data, dataType, const = 0, length = 0) :
        self.data = data
        self.type = dataType
        self.const = const
        self.length = length

    def __str__(self) :
        return str(self.data)

    def isMethodCall(self, c) :
        return self.type == TYPE_ATTRIBUTE and c != None and \
               len(self.data) == 2 and self.data[0] == 'self'

    def getName(self, module) :
        if self.type == TYPE_ATTRIBUTE and \
           type(self.data) != types.StringType :
            strValue, data = "", self.data
            # handle:  from XXX import YYY to munge the name 
            # into looking like: XXX.YYY
            if hasattr(module.module, self.data[0]) :
                globalObject = getattr(module.module, self.data[0])
                if type(globalObject) != types.ModuleType :
                    strValue = "." + str(globalObject)<commit_msg>add method to check if stack value is None (using global None or implicit on return)<commit_after>#!/usr/bin/env python

# Copyright (c) 2001, MetaSlash Inc.  All rights reserved.

"""
Module to hold manipulation of elements on the stack.
"""

import types


DATA_UNKNOWN = "-unknown-"

# These should really be defined by subclasses
TYPE_FUNC_RETURN = "-return-value-"
TYPE_ATTRIBUTE = "-attribute-"
TYPE_COMPARISON = "-comparison-"
TYPE_GLOBAL = "-global-"

class Item :
    "Representation of data on the stack"

    def __init__(self, data, dataType, const = 0, length = 0) :
        self.data = data
        self.type = dataType
        self.const = const
        self.length = length

    def __str__(self) :
        return str(self.data)

    def isNone(self) :
        return self.data is None or (self.data == 'None' and not self.const)

    def isMethodCall(self, c) :
        return self.type == TYPE_ATTRIBUTE and c != None and \
               len(self.data) == 2 and self.data[0] == 'self'

    def getName(self, module) :
        if self.type == TYPE_ATTRIBUTE and \
           type(self.data) != types.StringType :
            strValue, data = "", self.data
            # handle:  from XXX import YYY to munge the name 
            # into looking like: XXX.YYY
            if hasattr(module.module, self.data[0]) :
                globalObject = getattr(module.module, self.data[0])
                if type(globalObject) != types.ModuleType :
                    strValue = "." + str(globalObject)
{'fraction_non_alphanumeric': 0.1107217939733707, 'fraction_numerical': 0.00700770847932726, 'mean_word_length': 2.296766743648961, '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': '1633342', 'n_tokens_mistral': 875, 'n_tokens_neox': 829, 'n_words': 260}