Instruction stringlengths 362 7.83k | output_code stringlengths 1 945 |
|---|---|
Given the following code snippet before the placeholder: <|code_start|> return direct
@property
def isDirectACK(self):
"""Test if the message is a direct ACK message type."""
return self._messageType == MESSAGE_TYPE_DIRECT_MESSAGE_ACK
@property
def isDirectNAK(self):
"""... | return self._messageType == MESSAGE_TYPE_ALL_LINK_CLEANUP_NAK |
Predict the next line for this snippet: <|code_start|> if hasattr(other, "messageType"):
return not self.__eq__(other)
return True
def matches_pattern(self, other):
"""Test if current message match a patterns or template."""
if hasattr(other, "messageType"):
m... | self._messageType & MESSAGE_TYPE_BROADCAST_MESSAGE |
Using the snippet: <|code_start|> else:
extendedIsEqual = self.extended == other.extended
return messageTypeIsEqual and extendedIsEqual
return False
@classmethod
def get_properties(cls):
"""Get all properties of the MessageFlags class."""
property_... | return self._messageType == MESSAGE_TYPE_DIRECT_MESSAGE_ACK |
Continue the code snippet: <|code_start|> @classmethod
def get_properties(cls):
"""Get all properties of the MessageFlags class."""
property_names = [p for p in dir(cls) if isinstance(getattr(cls, p), property)]
return property_names
@property
def isBroadcast(self):
"""Te... | return self._messageType == MESSAGE_TYPE_DIRECT_MESSAGE_NAK |
Given the code snippet: <|code_start|>
class DeveloperProfileForm(ModelForm):
header = forms.ImageField(required=False, widget=forms.FileInput, label=_('Change your header image and crop it!'))
header_cropping = forms.CharField(widget=forms.HiddenInput())
def __init__(self, *args, **kwargs):
super(... | model = Profile |
Using the snippet: <|code_start|>
class DeveloperProfileForm(ModelForm):
header = forms.ImageField(required=False, widget=forms.FileInput, label=_('Change your header image and crop it!'))
header_cropping = forms.CharField(widget=forms.HiddenInput())
def __init__(self, *args, **kwargs):
super(Devel... | achievements = Achievement.objects.filter(user=kwargs['instance'].dev_user) |
Continue the code snippet: <|code_start|># from django.conf import settings
# Create your models here.
class Developer(models.Model):
""" Main User Class
Every user on the platform will have the following
information related when 'register' their GitHub User
for the first time.
"""
... | badge = models.ManyToManyField(Badge, through='Achievement') |
Predict the next line for this snippet: <|code_start|> try:
self.experience
except:
self.experience = 0.0
given_exp = (float(self.experience) + float(badge.experience))
if given_exp > 100:
self.level += 1
self.experience = (given_exp - 100... | l = Language |
Given the code snippet: <|code_start|> given_exp = (float(self.experience) + float(badge.experience))
if given_exp > 100:
self.level += 1
self.experience = (given_exp - 100)
else:
self.experience = given_exp
# Update points
self.points = (self... | f = Fidelity |
Using the snippet: <|code_start|> else:
self.experience = given_exp
# Update points
self.points = (self.level * 100) + self.experience
self.save()
def check_badges(self):
"""
With this function, we check over all the badges still not given to a user. ... | f = Fork |
Based on the snippet: <|code_start|> self.save()
def check_badges(self):
"""
With this function, we check over all the badges still not given to a user. If the Developer
has the
"""
for badge in Badge.objects.all():
if not Achievement.objects.filt... | l = License |
Predict the next line for this snippet: <|code_start|> repos = requests.get(url)
lang_dict = {}
for repo in repos.json():
url = repo[u'languages_url']
url += "?client_id={}&client_secret={}".format(GITHUB1, GITHUB2)
languages = requests.get(url)
i... | s, created = Skill.objects.get_or_create(profile=self.profile, language=lang) |
Continue the code snippet: <|code_start|>
# Register your models here.
admin.site.register(CustomBadge)
admin.site.register(FidelityBadge)
admin.site.register(LanguageBadge)
<|code_end|>
. Use current file imports:
from django.contrib import admin
from .models import FidelityBadge, LanguageBadge, ForkBadge, LicenseBad... | admin.site.register(ForkBadge) |
Continue the code snippet: <|code_start|>
# Register your models here.
admin.site.register(CustomBadge)
admin.site.register(FidelityBadge)
admin.site.register(LanguageBadge)
admin.site.register(ForkBadge)
<|code_end|>
. Use current file imports:
from django.contrib import admin
from .models import FidelityBadge, Langu... | admin.site.register(LicenseBadge) |
Here is a snippet: <|code_start|>
# Create your views here.
def grant_custom_badge(request, code):
try:
b = CustomBadge.objects.get(code=code)
try:
Achievement.objects.get(user=request.user.django_user, badge=b)
return render_to_response('badges/custom_badge_error.html', {'... | except Badge.DoesNotExist: |
Given the following code snippet before the placeholder: <|code_start|>
# Create your views here.
def grant_custom_badge(request, code):
try:
b = CustomBadge.objects.get(code=code)
try:
<|code_end|>
, predict the next line using imports from the current file:
from django.shortcuts import render, ... | Achievement.objects.get(user=request.user.django_user, badge=b) |
Here is a snippet: <|code_start|># -*- coding: utf-8 -*-
"""Tests for Timezone information files (TZif)."""
class TimeZoneInformationFileTest(test_lib.BaseTestCase):
"""Timezone information file (TZif) tests."""
# pylint: disable=protected-access
def testDebugPrintFileHeader(self):
"""Tests the _DebugP... | test_file = tzif.TimeZoneInformationFile(output_writer=output_writer) |
Here is a snippet: <|code_start|> attribute_name (str): attribute name.
"""
def __init__(self):
"""Initializes a MacOS keychain database column."""
super(KeychainDatabaseColumn, self).__init__()
self.attribute_data_type = None
self.attribute_identifier = None
self.attribute_name = None
cla... | class KeychainDatabaseFile(data_format.BinaryDataFile): |
Predict the next line after this snippet: <|code_start|>
Raises:
ParseError: if the file header cannot be read.
"""
data_type_map = self._GetDataTypeMap('keychain_file_header')
file_header, _ = self._ReadStructureFromFileObject(
file_object, 0, data_type_map, 'file header')
if self._... | raise errors.ParseError( |
Given the code snippet: <|code_start|># -*- coding: utf-8 -*-
"""Script to calculate Windows Prefetch hashes."""
def Main():
"""The main program function.
Returns:
bool: True if successful or False if not.
"""
argument_parser = argparse.ArgumentParser(description=(
'Calculate Windows Prefetch has... | hash_value = prefetch.CalculatePrefetchHashXP(options.path) |
Given snippet: <|code_start|> date_time, record_header.expiration_time)
self._DebugPrintValue('Expiration time', value_string)
date_time = (datetime.datetime(2001, 1, 1) + datetime.timedelta(
seconds=int(record_header.creation_time)))
value_string = '{0!s} ({1:f})'.format(
date_time,... | except (ValueError, errors.ParseError) as exception: |
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*-
"""Tests for Windows Restore Point rp.log files."""
class RestorePointLogFileTest(test_lib.BaseTestCase):
"""Windows Restore Point rp.log file tests."""
# pylint: disable=protected-access
def testDebugPrintFileFooter(self):
... | test_file = rp_log.RestorePointLogFile(output_writer=output_writer) |
Continue the code snippet: <|code_start|> file_offset = file_object.tell()
data_type_map = self._GetDataTypeMap('gzip_member_footer')
member_footer, _ = self._ReadStructureFromFileObject(
file_object, file_offset, data_type_map, 'member footer')
if self._debug:
self._DebugPrintStructureOb... | raise errors.ParseError( |
Here is a snippet: <|code_start|># -*- coding: utf-8 -*-
"""Tests for Windows Recycler INFO2 files."""
class RecyclerInfo2FileTest(test_lib.BaseTestCase):
"""Windows Recycler INFO2 file tests."""
# pylint: disable=protected-access
# TODO: add test for _FormatANSIString
# TODO: add test for _ReadFileEntry... | test_file = recycler.RecyclerInfo2File(output_writer=output_writer) |
Using the snippet: <|code_start|># -*- coding: utf-8 -*-
"""Windows Restore Point change.log files."""
class ChangeLogEntry(object):
"""Windows Restore Point change log entry.
Attributes:
entry_type (int): entry type.
entry_flags (int): entry flags.
file_attribute_flags (int): file attribute flags.... | class RestorePointChangeLogFile(data_format.BinaryDataFile): |
Using the snippet: <|code_start|>
file_offset = file_object.tell()
while file_offset < self._file_size:
change_log_entry = self._ReadChangeLogEntry(file_object)
file_offset = file_object.tell()
self.entries.append(change_log_entry)
def _ReadChangeLogEntry(self, file_object):
"""Reads a... | raise errors.ParseError('Unsupported record type: {0:d}'.format( |
Predict the next line after this snippet: <|code_start|>
def Main():
"""The main program function.
Returns:
bool: True if successful or False if not.
"""
argument_parser = argparse.ArgumentParser(description=(
'Extracts information from Windows Recycle.Bin metadata ($I) files.'))
argument_parser.a... | output_writer = output_writers.StdoutWriter() |
Given the following code snippet before the placeholder: <|code_start|>
argument_parser.add_argument(
'-d', '--debug', dest='debug', action='store_true', default=False,
help='enable debug output.')
argument_parser.add_argument(
'source', nargs='?', action='store', metavar='PATH',
default=No... | metadata_file = recycle_bin.RecycleBinMetadataFile( |
Using the snippet: <|code_start|> ('file_entry_size', 'File entry size', '_FormatIntegerAsDecimal'),
('unknown3', 'Unknown3', '_FormatIntegerAsHexadecimal8')]
def __init__(self, debug=False, output_writer=None):
"""Initializes a Windows Recycler INFO2 file.
Args:
debug (Optional[bool]): Tru... | raise errors.ParseError( |
Using the snippet: <|code_start|>
def Main():
"""The main program function.
Returns:
bool: True if successful or False if not.
"""
argument_parser = argparse.ArgumentParser(description=(
'Extracts information from Windows Restore Point rp.log files.'))
argument_parser.add_argument(
'-d', '--... | output_writer = output_writers.StdoutWriter() |
Given snippet: <|code_start|>
argument_parser.add_argument(
'-d', '--debug', dest='debug', action='store_true', default=False,
help='enable debug output.')
argument_parser.add_argument(
'source', nargs='?', action='store', metavar='PATH',
default=None, help='path of the Windows Restore Poin... | log_file = rp_log.RestorePointLogFile( |
Given snippet: <|code_start|> file_type = 'cpio'
elif signature_data[:2] == self._GZIP_SIGNATURE:
file_type = 'gzip'
elif signature_data[:2] == self._BZIP_SIGNATURE:
file_type = 'bzip'
elif signature_data == self._XZ_SIGNATURE:
file_type = 'xz'
if no... | cpio_archive_file = cpio.CPIOArchiveFile(debug=self._debug) |
Based on the snippet: <|code_start|> signature_data = file_object.read(6)
file_type = None
if len(signature_data) > 2:
if (signature_data[:2] in (
self._CPIO_SIGNATURE_BINARY_BIG_ENDIAN,
self._CPIO_SIGNATURE_BINARY_LITTLE_ENDIAN) or
signature_data in (
... | compressed_data_file_object = data_range.DataRange( |
Given the following code snippet before the placeholder: <|code_start|> Returns:
bool: True if successful or False if not.
"""
argument_parser = argparse.ArgumentParser(description=(
'Extracts information from CPIO archive files.'))
argument_parser.add_argument(
'-d', '--debug', dest='debug', ac... | output_writer = output_writers.StdoutWriter() |
Given the code snippet: <|code_start|>
Returns:
str: stream formatted as a signature.
"""
return stream.decode('ascii')
def _ReadDataObject(self, file_object, file_offset):
"""Reads a data object.
Args:
file_object (file): file-like object.
file_offset (int): offset of the data... | raise errors.ParseError('Unsupported object type: {0:d}.'.format( |
Predict the next line after this snippet: <|code_start|>
class PropertyValueDataMap(object):
"""Property value data map.
Attributes:
data_type (int): property value data type.
name (str): name of the property.
offset (int): offset of the property in value data.
size (int): size of the property in ... | class IndexBinaryTreeFile(data_format.BinaryDataFile): |
Given the following code snippet before the placeholder: <|code_start|>
Args:
class_definitions (list[ClassDefinition]): the class definition and its
parent class definitions.
Raises:
ParseError: if the class map cannot be build.
"""
self.class_name = class_definitions[-1].name
... | raise errors.ParseError(( |
Given snippet: <|code_start|>
def Main():
"""The main program function.
Returns:
bool: True if successful or False if not.
"""
argument_parser = argparse.ArgumentParser(description=(
'Extracts information from Safari Cookies files.'))
argument_parser.add_argument(
'-d', '--debug', dest='debu... | output_writer = output_writers.StdoutWriter() |
Using the snippet: <|code_start|>
argument_parser.add_argument(
'-d', '--debug', dest='debug', action='store_true', default=False,
help='enable debug output.')
argument_parser.add_argument(
'source', nargs='?', action='store', metavar='PATH',
default=None, help='path of the Cookies.binaryco... | binary_cookies_file = safari_cookies.BinaryCookiesFile( |
Predict the next line for this snippet: <|code_start|># -*- coding: utf-8 -*-
"""Tests for GZip files."""
# Note: do not rename file to gzip.py this can cause the exception:
# AttributeError: 'module' object has no attribute 'GzipFile'
# when using pip.
class GZipFileTest(test_lib.BaseTestCase):
"""GZip file te... | test_file = gzipfile.GZipFile(output_writer=output_writer) |
Given snippet: <|code_start|> transition_times (tzif_transition_times): transition times.
"""
for index, transition_time in enumerate(transition_times):
description_string = 'Transition time: {0:d}'.format(index)
value_string = '{0:d}'.format(transition_time)
self._DebugPrintValue(descrip... | raise errors.ParseError('Unsupported file signature.') |
Here is a snippet: <|code_start|> self._last_charset_attribute = value
if self._debug:
self._DebugPrintText('\n')
def _ReadAttributesGroup(self, file_object):
"""Reads an attributes group.
Args:
file_object (file): file-like object.
Raises:
ParseError: if the attributes gr... | raise errors.ParseError(( |
Next line prediction: <|code_start|># -*- coding: utf-8 -*-
"""Tests for copy in and out (CPIO) archive format files."""
class CPIOArchiveFileEntryTest(test_lib.BaseTestCase):
"""CPIO archive file entry tests."""
_FILE_DATA = bytes(bytearray(range(128)))
def testInitialize(self):
"""Tests the __init__ ... | file_entry = cpio.CPIOArchiveFileEntry( |
Predict the next line for this snippet: <|code_start|># -*- coding: utf-8 -*-
"""Tests for CUPS Internet Printing Protocol (IPP) files."""
class CupsIppFileTest(test_lib.BaseTestCase):
"""CUPS Internet Printing Protocol (IPP) file tests."""
# pylint: disable=protected-access
# TODO: test _FormatIntegerAsTa... | test_file = cups_ipp.CupsIppFile(output_writer=output_writer) |
Given the code snippet: <|code_start|> if number_of_integers == 16:
return self._FormatArrayOfIntegersAsIPv6Address(array_of_integers)
return None
def _FormatIntegerAsEventType(self, integer):
"""Formats an integer as an event type.
Args:
integer (int): integer.
Returns:
str: ... | raise errors.ParseError('Unsupported net type: {0:d}'.format(integer)) |
Given snippet: <|code_start|>
def Main():
"""The main program function.
Returns:
bool: True if successful or False if not.
"""
argument_parser = argparse.ArgumentParser(description=(
'Extracts information from utmp files.'))
argument_parser.add_argument(
'-d', '--debug', dest='debug', action... | output_writer = output_writers.StdoutWriter() |
Given the code snippet: <|code_start|> argument_parser.add_argument(
'source', nargs='?', action='store', metavar='PATH',
default=None, help='path of the utmp file.')
options = argument_parser.parse_args()
if not options.source:
print('Source file missing.')
print('')
argument_parser.prin... | utmp_file = utmp.MacOSXUtmpxFile( |
Given the code snippet: <|code_start|>
def Main():
"""The main program function.
Returns:
bool: True if successful or False if not.
"""
argument_parser = argparse.ArgumentParser(description=(
'Extracts information from Windows Recycler INFO2 files.'))
argument_parser.add_argument(
'-d', '--d... | output_writer = output_writers.StdoutWriter() |
Given the code snippet: <|code_start|>
argument_parser.add_argument(
'-d', '--debug', dest='debug', action='store_true', default=False,
help='enable debug output.')
argument_parser.add_argument(
'source', nargs='?', action='store', metavar='PATH',
default=None, help='path of the Recycler IN... | info2_file = recycler.RecyclerInfo2File( |
Predict the next line for this snippet: <|code_start|> output_writer (Optional[OutputWriter]): output writer.
"""
super(RecycleBinMetadataFile, self).__init__(
debug=debug, output_writer=output_writer)
self.deletion_time = None
self.format_version = None
self.original_filename = None
... | raise errors.ParseError('Unsupported format version: {0:d}'.format( |
Next line prediction: <|code_start|> _ROOT_KEY_NAMES = frozenset([
'{11517b7c-e79d-4e20-961b-75a811715add}',
'{356c48f6-2fee-e7ef-2a64-39f59ec3be22}'])
def _GetValueDataAsObject(self, value):
"""Retrieves the value data as an object.
Args:
value (pyregf_value): value.
Returns:
... | raise errors.ParseError( |
Based on the snippet: <|code_start|> argument_parser.add_argument(
'-d', '--debug', dest='debug', action='store_true', default=False,
help='enable debug output.')
argument_parser.add_argument(
'source', nargs='?', action='store', metavar='PATH',
default=None, help='path of the Windows Jump L... | jump_list_file = jump_list.AutomaticDestinationsFile( |
Predict the next line for this snippet: <|code_start|>
def Main():
"""The main program function.
Returns:
bool: True if successful or False if not.
"""
argument_parser = argparse.ArgumentParser(description=(
'Extracts information from Windows Jump List files.'))
argument_parser.add_argument(
... | output_writer = output_writers.StdoutWriter() |
Using the snippet: <|code_start|> # conventions.
maxDiff = None
def _GetTestFilePath(self, path_segments):
"""Retrieves the path of a test file in the test data directory.
Args:
path_segments (list[str]): path segments inside the test data directory.
Returns:
str: path of the test file.
... | class TestOutputWriter(output_writers.OutputWriter): |
Continue the code snippet: <|code_start|># -*- coding: utf-8 -*-
"""Tests for Windows Recycle.Bin metadata ($I) files."""
class RecycleBinMetadataFileTest(test_lib.BaseTestCase):
"""Windows Recycle.Bin metadata ($I) file tests."""
# pylint: disable=protected-access
def testReadFileHeader(self):
"""Test... | test_file = recycle_bin.RecycleBinMetadataFile(output_writer=output_writer) |
Predict the next line for this snippet: <|code_start|>
argument_parser.add_argument(
'source', nargs='?', action='store', metavar='PATH',
default=None, help='path of the source file.')
options = argument_parser.parse_args()
if not options.definition:
print('Definition file missing.')
print('... | output_writer = output_writers.StdoutWriter() |
Given the code snippet: <|code_start|># -*- coding: utf-8 -*-
"""Tests for prefetch functions."""
class PrefetchTest(test_lib.BaseTestCase):
"""Prefetch function tests."""
def testCalculatePrefetchHashXP(self):
"""Tests the CalculatePrefetchHashXP function."""
# Path from Windows XP CMD.EXE-087B4001.p... | hash_value = prefetch.CalculatePrefetchHashXP(path) |
Predict the next line for this snippet: <|code_start|># -*- coding: utf-8 -*-
"""Tests for Windows Jump List files:
* .automaticDestinations-ms
* .customDestinations-ms
"""
class LNKFileEntryTest(test_lib.BaseTestCase):
"""Windows Shortcut (LNK) file entry tests."""
def testOpenClose(self):
"""Tests the ... | lnk_file_entry = jump_list.LNKFileEntry('test') |
Continue the code snippet: <|code_start|>
argument_parser.add_argument(
'-d', '--debug', dest='debug', action='store_true', default=False,
help='enable debug output.')
argument_parser.add_argument(
'source', nargs='?', action='store', metavar='PATH',
default=None, help='path of the CUPS IPP... | cups_ipp_file = cups_ipp.CupsIppFile( |
Next line prediction: <|code_start|>
def Main():
"""The main program function.
Returns:
bool: True if successful or False if not.
"""
argument_parser = argparse.ArgumentParser(description=(
'Extracts information from CUPS IPP files.'))
argument_parser.add_argument(
'-d', '--debug', dest='deb... | output_writer = output_writers.StdoutWriter() |
Given the code snippet: <|code_start|>
def Main():
"""The main program function.
Returns:
bool: True if successful or False if not.
"""
argument_parser = argparse.ArgumentParser(description=(
'Extracts information from Firefox cache version 1 files.'))
argument_parser.add_argument(
'-d', '--... | output_writer = output_writers.StdoutWriter() |
Predict the next line for this snippet: <|code_start|> '-d', '--debug', dest='debug', action='store_true', default=False,
help='enable debug output.')
argument_parser.add_argument(
'source', nargs='?', action='store', metavar='PATH',
default=None, help='path of the Firefox cache version 1 file... | cache_file = firefox_cache1.CacheMapFile( |
Next line prediction: <|code_start|># -*- coding: utf-8 -*-
"""Tests for utmp files."""
class LinuxLibc6UtmpFileTest(test_lib.BaseTestCase):
"""Linux libc6 utmp file tests."""
# pylint: disable=protected-access
def testDebugPrintEntry(self):
"""Tests the _DebugPrintEntry function."""
output_writer ... | test_file = utmp.LinuxLibc6UtmpFile(output_writer=output_writer) |
Given the code snippet: <|code_start|> output_writer = test_lib.TestOutputWriter()
test_file = safari_cookies.BinaryCookiesFile(output_writer=output_writer)
data_type_map = test_file._GetDataTypeMap('binarycookies_record_header')
record_header = data_type_map.CreateStructureValues(
creation_tim... | with self.assertRaises(errors.ParseError): |
Here is a snippet: <|code_start|> 0x00, 0x00, 0x00, 0xed, 0x00, 0x00, 0x00, 0xa6, 0x00, 0x00, 0x00, 0xa3,
0x00, 0x00, 0x00, 0x76]))
_FILE_HEADER_DATA_BAD_SIGNATURE = bytes(bytearray([
0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x76,
0x00, 0x00, 0x00, 0x95, 0x00, 0x00, 0x... | test_file = safari_cookies.BinaryCookiesFile(output_writer=output_writer) |
Here is a snippet: <|code_start|>
argument_parser.add_argument(
'-d', '--debug', dest='debug', action='store_true', default=False,
help='enable debug output.')
argument_parser.add_argument(
'source', nargs='?', action='store', metavar='PATH',
default=None, help='path of the Amcache.hve file... | amcache_file = amcache.WindowsAMCacheFile( |
Given the following code snippet before the placeholder: <|code_start|>
def Main():
"""The main program function.
Returns:
bool: True if successful or False if not.
"""
argument_parser = argparse.ArgumentParser(description=(
'Extracts information from Amcache.hve files.'))
argument_parser.add_argu... | output_writer = output_writers.StdoutWriter() |
Given the code snippet: <|code_start|> integer (int): integer.
Returns:
str: integer formatted as a cache location.
"""
return (
'block number: {0:d}, extra blocks: {1:d}, location selector: '
'{2:d}, reserved: {3:02x}, location flag: {4:d}').format(
integer & 0x00fff... | raise errors.ParseError('Unsupported major format version: {0:d}'.format( |
Given the code snippet: <|code_start|># -*- coding: utf-8 -*-
"""Tests for Windows Task Scheduler job files."""
class WindowsTaskSchedularJobFileTest(test_lib.BaseTestCase):
"""Windows Task Scheduler job file tests."""
# pylint: disable=protected-access
# TODO: add test for _FormatDataStream
# TODO: add ... | test_file = job.WindowsTaskSchedularJobFile( |
Next line prediction: <|code_start|> argument_parser.add_argument(
'-d', '--debug', dest='debug', action='store_true', default=False,
help='enable debug output.')
argument_parser.add_argument(
'source', nargs='?', action='store', metavar='PATH', default=None, help=(
'path of the Windows ... | detection_history.WindowsDefenderScanDetectionHistoryFile( |
Based on the snippet: <|code_start|>def Main():
"""The main program function.
Returns:
bool: True if successful or False if not.
"""
argument_parser = argparse.ArgumentParser(description=(
'Extracts information from a Windows Defender scan DetectionHistory '
'file.'))
argument_parser.add_arg... | output_writer = output_writers.StdoutWriter() |
Predict the next line after this snippet: <|code_start|> self.item_identifier = 0
self.last_update_time = 0
self.page_offset = page_offset
self.page_value_offset = page_value_offset
self.parent_identifier = 0
class SpotlightStoreRecordHeader(object):
"""Record header.
Attributes:
data_size... | class AppleSpotlightStoreDatabaseFile(data_format.BinaryDataFile): |
Given the following code snippet before the placeholder: <|code_start|> if value == 0:
date_time_string = 'Not set (0)'
else:
date_time = dfdatetime_posix_time.PosixTimeInMicroseconds(timestamp=value)
date_time_string = date_time.CopyToDateTimeString()
if date_time_string:
date_ti... | raise errors.ParseError(( |
Here is a snippet: <|code_start|> Returns:
dsc_file_header: a file header.
Raises:
ParseError: if the file header cannot be read.
"""
data_type_map = self._GetDataTypeMap('dsc_file_header')
file_header, _ = self._ReadStructureFromFileObject(
file_object, 0, data_type_map, 'file ... | raise errors.ParseError('Unsupported signature.') |
Here is a snippet: <|code_start|>
argument_parser.add_argument(
'-d', '--debug', dest='debug', action='store_true', default=False,
help='enable debug output.')
argument_parser.add_argument(
'source', nargs='?', action='store', metavar='PATH',
default=None, help='path of the USN change journ... | usn_records = usn_journal.USNRecords( |
Here is a snippet: <|code_start|>
def Main():
"""The main program function.
Returns:
bool: True if successful or False if not.
"""
argument_parser = argparse.ArgumentParser(description=(
'Extracts information from USN change journal records.'))
argument_parser.add_argument(
'-d', '--debug', ... | output_writer = output_writers.StdoutWriter() |
Continue the code snippet: <|code_start|>
argument_parser.add_argument(
'-d', '--debug', dest='debug', action='store_true', default=False,
help='enable debug output.')
argument_parser.add_argument(
'source', nargs='?', action='store', metavar='PATH',
default=None, help='path of the GZIP com... | gzip_file = gzipfile.GZipFile( |
Next line prediction: <|code_start|>
def Main():
"""The main program function.
Returns:
bool: True if successful or False if not.
"""
argument_parser = argparse.ArgumentParser(description=(
'Extracts information from GZIP compressed stream files.'))
argument_parser.add_argument(
'-d', '--deb... | output_writer = output_writers.StdoutWriter() |
Predict the next line for this snippet: <|code_start|> """Formats an integer as a POSIX date and time in microseconds value.
Args:
integer (int): integer.
Returns:
str: integer formatted as a POSIX date and time in microseconds value.
"""
if integer == 0:
return 'Not set (0)'
... | @decorators.deprecated |
Next line prediction: <|code_start|> the file-like object.
data_size (int): size of the data.
description (str): description of the data.
Returns:
bytes: byte stream containing the data.
Raises:
ParseError: if the data cannot be read.
ValueError: if the file-like object ... | raise errors.ParseError(( |
Here is a snippet: <|code_start|> file_object, record_strings_data_offset, record_strings_data_size,
'record strings data')
if self._debug:
self._DebugPrintData('Record strings data', record_strings_data)
data_type_map = self._GetDataTypeMap('asl_record')
record, record_data_size = s... | raise errors.ParseError('Invalid record additional data size.') |
Predict the next line for this snippet: <|code_start|>
def Main():
"""The main program function.
Returns:
bool: True if successful or False if not.
"""
argument_parser = argparse.ArgumentParser(description=(
'Extracts information from Windows Restore Point change.log files.'))
argument_parser.add_... | output_writer = output_writers.StdoutWriter() |
Given the code snippet: <|code_start|>
argument_parser.add_argument(
'-d', '--debug', dest='debug', action='store_true', default=False,
help='enable debug output.')
argument_parser.add_argument(
'source', nargs='?', action='store', metavar='PATH',
default=None, help='path of the Windows Res... | change_log_file = rp_change_log.RestorePointChangeLogFile( |
Next line prediction: <|code_start|> '0x{0:08x} (initialized: {1!s}, file type: {2:s}, '
'filename: {3:s}, block number: {4:d}, block offset: 0x{5:08x}, '
'block size: {6:d})').format(
self.value, self.is_initialized, file_type_description,
self.filename, self.block_number... | class DataBlockFile(data_format.BinaryDataFile): |
Predict the next line after this snippet: <|code_start|> integer (int): integer.
Returns:
str: integer formatted as a Chrome timestamp.
"""
date_string = (datetime.datetime(1601, 1, 1) +
datetime.timedelta(microseconds=integer))
return '{0!s} (0x{1:08x})'.format(date_strin... | raise errors.ParseError( |
Continue the code snippet: <|code_start|>
argument_parser.add_argument(
'-d', '--debug', dest='debug', action='store_true', default=False,
help='enable debug output.')
argument_parser.add_argument(
'source', nargs='?', action='store', metavar='PATH',
default=None, help='path of the Apple Sy... | asl_file = asl.AppleSystemLogFile( |
Given snippet: <|code_start|>
def Main():
"""The main program function.
Returns:
bool: True if successful or False if not.
"""
argument_parser = argparse.ArgumentParser(description=(
'Extracts information from Apple System Log files.'))
argument_parser.add_argument(
'-d', '--debug', dest='de... | output_writer = output_writers.StdoutWriter() |
Continue the code snippet: <|code_start|>
def GetShellItems(self):
"""Retrieves the shell items.
Yields:
pyfswi.item: shell item.
"""
if self._lnk_file.link_target_identifier_data: # pylint: disable=using-constant-test
shell_item_list = pyfwsi.item_list()
shell_item_list.copy_from_... | class AutomaticDestinationsFile(data_format.BinaryDataFile): |
Next line prediction: <|code_start|> file_object, file_offset, data_type_map, 'entry header')
except errors.ParseError as exception:
error_message = (
'Unable to parse file entry header at offset: 0x{0:08x} '
'with error: {1:s}').format(file_offset, exception)
... | lnk_file_object = data_range.DataRange( |
Continue the code snippet: <|code_start|> output_writer (Optional[OutputWriter]): output writer.
"""
super(AutomaticDestinationsFile, self).__init__(
debug=debug, output_writer=output_writer)
self._format_version = None
self.entries = []
self.recovered_entries = []
def _FormatInteger... | raise errors.ParseError('Missing DestList stream.') |
Predict the next line for this snippet: <|code_start|>
Returns:
str: decoded string.
"""
try:
string = byte_stream.decode(encoding)
except UnicodeDecodeError:
string = 'INVALID'
return string.rstrip('\x00')
def _ReadEntries(self, file_object):
"""Reads entries.
Args:
... | raise errors.ParseError('Unsupported file header signature.') |
Based on the snippet: <|code_start|># -*- coding: utf-8 -*-
"""Tests for Windows AMCache (AMCache.hve) files."""
class WindowsAMCacheFileTest(test_lib.BaseTestCase):
"""Windows AMCache (AMCache.hve) file tests."""
# pylint: disable=protected-access
# TODO: add test for _ReadFileKey
# TODO: add test for _... | test_file = amcache.WindowsAMCacheFile( |
Predict the next line for this snippet: <|code_start|>
def Main():
"""The main program function.
Returns:
bool: True if successful or False if not.
"""
argument_parser = argparse.ArgumentParser(description=(
'Extracts information from timezone information files.'))
argument_parser.add_argument(
... | output_writer = output_writers.StdoutWriter() |
Continue the code snippet: <|code_start|>
argument_parser.add_argument(
'-d', '--debug', dest='debug', action='store_true', default=False,
help='enable debug output.')
argument_parser.add_argument(
'source', nargs='?', action='store', metavar='PATH',
default=None, help='path of the timezone... | tzif_file = tzif.TimeZoneInformationFile( |
Here is a snippet: <|code_start|> data_size (int): size of the data.
group_identifier (int): group identifier (GID).
inode_number (int): inode number.
mode (int): file access mode.
modification_time (int): modification time, in number of seconds since
January 1, 1970 00:00:00.
path (str):... | class CPIOArchiveFile(data_format.BinaryDataFile): |
Predict the next line for this snippet: <|code_start|> """
if self.file_format == 'bin-big-endian':
data_type_map = self._GetDataTypeMap('cpio_binary_big_endian_file_entry')
elif self.file_format == 'bin-little-endian':
data_type_map = self._GetDataTypeMap(
'cpio_binary_little_endian_fi... | raise errors.ParseError( |
Based on the snippet: <|code_start|>
argument_parser.add_argument(
'-d', '--debug', dest='debug', action='store_true', default=False,
help='enable debug output.')
argument_parser.add_argument(
'source', nargs='?', action='store', metavar='PATH', default=None, help=(
'path of the Windows... | job_file = job.WindowsTaskSchedularJobFile( |
Predict the next line after this snippet: <|code_start|>
def Main():
"""The main program function.
Returns:
bool: True if successful or False if not.
"""
argument_parser = argparse.ArgumentParser(description=(
'Extracts information from a Windows Job file.'))
argument_parser.add_argument(
'-... | output_writer = output_writers.StdoutWriter() |
Given snippet: <|code_start|># -*- coding: utf-8 -*-
"""Tests for the data range file-like object."""
class DataRangeTest(test_lib.BaseTestCase):
"""In-file data range file-like object tests."""
_FILE_DATA = bytes(bytearray(range(128)))
def testRead(self):
"""Tests the read function."""
file_object... | test_range = data_range.DataRange( |
Using the snippet: <|code_start|> def testFormatPackedIPv6Address(self):
"""Tests the _FormatPackedIPv6Address function."""
test_format = TestBinaryDataFormat()
ip_address = test_format._FormatPackedIPv6Address([
0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
0x00,... | with self.assertRaises(errors.ParseError): |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.