Skip to content

Commit

Permalink
Worked on export script
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz committed May 6, 2024
1 parent 46c7e9f commit 5f0afa3
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 20 deletions.
20 changes: 10 additions & 10 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = winevtrc
version = 20240331
version = 20240505
description = Windows Event Log resources (winevtrc)
long_description = winevtrc is a Python module part of winevt-kb to allow easy reuse of the Windows Event Log resource extraction and database functionality.
long_description_content_type = text/plain
Expand All @@ -24,15 +24,6 @@ package_dir =
packages = find:
python_requires = >=3.8

[options.entry_points]
console_scripts =
eventlog_providers = winevtrc.scripts.eventlog_providers:Main
export = winevtrc.scripts.export:Main
extract = winevtrc.scripts.extract:Main
process_tree = winevtrc.scripts.process_tree:Main
query = winevtrc.scripts.query:Main
wevt_template = winevtrc.scripts.wevt_template:Main

[options.packages.find]
exclude =
docs
Expand All @@ -41,5 +32,14 @@ exclude =
utils
where = .

[options.entry_points]
console_scripts =
eventlog_providers = winevtrc.scripts.eventlog_providers:Main
export = winevtrc.scripts.export:Main
extract = winevtrc.scripts.extract:Main
process_tree = winevtrc.scripts.process_tree:Main
query = winevtrc.scripts.query:Main
wevt_template = winevtrc.scripts.wevt_template:Main

[bdist_wheel]
universal = 1
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@ deps =
commands =
docformatter --version
pylint --version
docformatter --check --diff --recursive scripts setup.py tests winevtrc
pylint --rcfile=.pylintrc scripts setup.py tests winevtrc
docformatter --check --diff --recursive setup.py tests winevtrc
pylint --rcfile=.pylintrc setup.py tests winevtrc
15 changes: 8 additions & 7 deletions winevtrc/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,8 @@ def PlaceHolderSpecifierReplacer(match_object):
return self._PLACE_HOLDER_SPECIFIER_RE.sub(
PlaceHolderSpecifierReplacer, message_string)

# pylint: disable=unused-argument

def _WriteMessage(
self, message_file, language_identifier, message_identifier,
message_string, table_name, has_table):
Expand Down Expand Up @@ -698,16 +700,14 @@ def _WriteMessage(
stored_message_string = values['message_string']
if message_string != stored_message_string:
logging.warning((
f'Message string mismatch for LCID: {language_identifier:s}, '
f'file version: {message_file.file_version:s}, message '
f'identifier: {message_identifier:s}.\nFound: '
f'Message string mismatch for LCID: 0x{language_identifier:04x}, '
f'message identifier: {message_identifier:s}.\nFound: '
f'{message_string:s}\nStored: {stored_message_string:s}\n'))

elif number_of_values != 0:
logging.warning((
f'More than one message string found for LCID: '
f'{language_identifier:s}, file version: '
f'{message_file.file_version:s}, message identifier: '
f'0x{language_identifier:04x}, message identifier: '
f'{message_identifier:s}.'))

# TODO: warn if new message has been found.
Expand Down Expand Up @@ -740,7 +740,7 @@ def _WriteMessageTableLanguage(self, message_file_key, language_identifier):

else:
condition = (
f'lcid = "{language_identifier:s}" AND '
f'lcid = {language_identifier:d} AND '
f'message_file_key = "{message_file_key:d}"')
values_list = list(self._database_file.GetValues(
[table_name], column_names, condition))
Expand Down Expand Up @@ -892,7 +892,8 @@ def WriteMessageTable(self, message_file, message_table):
logging.warning(
f'Missing message file key for: {message_file.windows_path:s}')

table_name = f'message_table_{message_file_key:d}_{message_table.lcid:s}'
table_name = (
f'message_table_{message_file_key:d}_0x{message_table.lcid:08x}')

has_table = self._database_file.HasTable(table_name)
if not has_table:
Expand Down
4 changes: 3 additions & 1 deletion winevtrc/scripts/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
class DatabaseOutputWriter(exporter.ExporterOutputWriter):
"""Database output writer."""

_VERSION = '20150315'

def __init__(self, database_path, string_format='wrc'):
"""Initializes a database output writer.
Expand All @@ -32,7 +34,7 @@ def __init__(self, database_path, string_format='wrc'):
def _WriteMetadata(self):
"""Writes the metadata."""
self._database_writer.WriteMetadataAttribute(
'version', '20150315')
'version', self._VERSION)
self._database_writer.WriteMetadataAttribute(
'string_format', self._string_format)

Expand Down

0 comments on commit 5f0afa3

Please sign in to comment.