<commit_before>#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright 2012 The Plaso Project Authors.
# Please see the AUTHORS file for details on individual authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The interface for Windows Registry related objects."""
import abc
import logging
import struct


class WinRegKey(object):
  """Abstract class to represent the Windows Registry Key interface."""

  PATH_SEPARATOR = u'\\'

  @abc.abstractproperty
  def path(self):
    """The path of the key."""

  @abc.abstractproperty
  def name(self):
    """The name of the key."""

  @abc.abstractproperty
  def offset(self):
    """The offset of the key within the Registry File."""

  # TODO: have a more descriptive name for this property.
  @abc.abstractproperty
  def timestamp(self):
    """The last written time of the key represented as a timestamp."""

  # TODO: refactor this to a number of values or values count property.
  @abc.abstractmethod
  def GetValueCount(self):
    """Retrieves the number of values within the key."""

  @abc.abstractmethod
  def GetValue(self, name):
    """Retrieves a value by name.

    Args:
      name: Name of the value or an empty string for the default value.

    Returns:
      An instance of a Windows Registry Value object (WinRegValue) if
      a corresponding value was found or None if not.
    """

  # TODO: refactor this to a values property.
  @abc.abstractmethod
  def GetValues(self):
    """Retrieves all values within the key.

    Yields:
      Instances of Windows Registry Value objects (WinRegValue) that represent
      the values stored within the key.
    """

  # TODO: refactor this to a number of subkeys or subkeys count property.
  @abc.abstractmethod
  def GetSubkeyCount(self):
    """Retrieves the number of subkeys within the key."""

  @abc.abstractmethod
  def HasSubkeys(self):
    """Determines if the key has subkeys."""
    return False

  # TODO: refactor this to a subkeys property.
  @abc.abstractmethod
  def GetSubkeys(self):
    """Retrieves all subkeys within the key.

    Yields:
      Instances of Windows Registry Key objects (WinRegKey) that represent
      the subkeys stored within the key.
    """


class WinRegValue(object):
  """Abstract class to represent the Windows Registry Value interface."""

  REG_NONE = 0
  REG_SZ = 1
  REG_EXPAND_SZ = 1
  REG_BINARY = 3
  REG_DWORD = 4
  REG_DWORD_LITTLE_ENDIAN = 4
  REG_DWORD_BIG_ENDIAN = 5
  REG_LINK = 6
  REG_MULTI_SZ = 7
  REG_RESOURCE_LIST = 8
  REG_FULL_RESOURCE_DESCRIPTOR = 9
  REG_RESOURCE_REQUIREMENT_LIST = 10
  REG_QWORD = 11

  # TODO: refactor the string representations, if no longer needed remove
  # otherwise change to a frozenset of a list of strings.
  TYPES = {
      0: 'NONE',
      1: 'SZ',
      2: 'EXPAND_SZ',<commit_msg>Code review: 10776043:  Bug fix, for issue introduced in winreg refactor<commit_after>#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright 2012 The Plaso Project Authors.
# Please see the AUTHORS file for details on individual authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The interface for Windows Registry related objects."""
import abc
import logging
import struct


class WinRegKey(object):
  """Abstract class to represent the Windows Registry Key interface."""

  PATH_SEPARATOR = u'\\'

  @abc.abstractproperty
  def path(self):
    """The path of the key."""

  @abc.abstractproperty
  def name(self):
    """The name of the key."""

  @abc.abstractproperty
  def offset(self):
    """The offset of the key within the Registry File."""

  # TODO: have a more descriptive name for this property.
  @abc.abstractproperty
  def timestamp(self):
    """The last written time of the key represented as a timestamp."""

  # TODO: refactor this to a number of values or values count property.
  @abc.abstractmethod
  def GetValueCount(self):
    """Retrieves the number of values within the key."""

  @abc.abstractmethod
  def GetValue(self, name):
    """Retrieves a value by name.

    Args:
      name: Name of the value or an empty string for the default value.

    Returns:
      An instance of a Windows Registry Value object (WinRegValue) if
      a corresponding value was found or None if not.
    """

  # TODO: refactor this to a values property.
  @abc.abstractmethod
  def GetValues(self):
    """Retrieves all values within the key.

    Yields:
      Instances of Windows Registry Value objects (WinRegValue) that represent
      the values stored within the key.
    """

  # TODO: refactor this to a number of subkeys or subkeys count property.
  @abc.abstractmethod
  def GetSubkeyCount(self):
    """Retrieves the number of subkeys within the key."""

  @abc.abstractmethod
  def HasSubkeys(self):
    """Determines if the key has subkeys."""
    return False

  # TODO: refactor this to a subkeys property.
  @abc.abstractmethod
  def GetSubkeys(self):
    """Retrieves all subkeys within the key.

    Yields:
      Instances of Windows Registry Key objects (WinRegKey) that represent
      the subkeys stored within the key.
    """


class WinRegValue(object):
  """Abstract class to represent the Windows Registry Value interface."""

  REG_NONE = 0
  REG_SZ = 1
  REG_EXPAND_SZ = 2
  REG_BINARY = 3
  REG_DWORD = 4
  REG_DWORD_LITTLE_ENDIAN = 4
  REG_DWORD_BIG_ENDIAN = 5
  REG_LINK = 6
  REG_MULTI_SZ = 7
  REG_RESOURCE_LIST = 8
  REG_FULL_RESOURCE_DESCRIPTOR = 9
  REG_RESOURCE_REQUIREMENT_LIST = 10
  REG_QWORD = 11

  # TODO: refactor the string representations, if no longer needed remove
  # otherwise change to a frozenset of a list of strings.
  TYPES = {
      0: 'NONE',
      1: 'SZ',
      2: 'EXPAND_SZ',
{'fraction_non_alphanumeric': 0.0821938392186326, 'fraction_numerical': 0.009316303531179564, 'mean_word_length': 3.4314247669773636, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '631287', 'n_tokens_mistral': 2009, 'n_tokens_neox': 1891, 'n_words': 813}