-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add logging, update readme and test files (#8)
* initial check-in of working version. * add file containing dependencies to install * updated lint rules * add mention of regex to README * Move process impl into the base class FileProcessor. * use file_extension as key to look up the right FileWriter class * add command line arg processing * move FileReader responsibility out of the FileProcessor * expose FileReader and message linter * modify FileProcessor to accept FileReader and FileWriter * add more command line usages * rename to message_lint (from str_res_lint) * update README to reflect the renaming to message_lint (from str_res_lint) * remove static method (build_output_folder) from FileWriter * add test files * change --dest option to --output_folder * clean up table. remove need for --file option. rename --dest option to `output_folder` * fix indentation issue * add unit tests for filereader and filewriter. * remove commented code * add examples to help reader learn how to use message_lint * correct / clean up some of the rules * add overview diagram * add diagram * Isolate version number. Also, add logging * updated rules. check for empty message resources. * correct rule for empty messages * add "Getting Started" section * add table of issues the tool will find and how to resolve each issue * minor edits * move main function out of bin/message_lint and put it in its own folder. that way, it can be unit tested. * add placeholder for unit test * update diagram adding mention of product source content * add two simple test (source content) files * clarify mention of supporting plural noun forms * commented out debug print statements. Will remove them at some point. * add mention of regex * move fileprocessor under message_lint app folder * move fileprocessor out of utils to the app folder * add type hints * move linter to app folder * add command line option "verbose" * update test files with improved example messages with L12y issues * remove print statements * update version
- Loading branch information
Showing
21 changed files
with
437 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from message_lint.main import main | ||
|
||
__version__ = "0.1.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
from .linter import lint | ||
from pprint import PrettyPrinter | ||
|
||
pp = PrettyPrinter( | ||
indent=2, | ||
width=100, | ||
compact=True | ||
) | ||
|
||
|
||
class FileProcessor: | ||
def __init__(self, reader, writer, logger): | ||
self.reader = reader | ||
self.writer = writer | ||
self.logger = logger | ||
self.content = {} | ||
|
||
def execute(self) -> dict: | ||
try: | ||
self.content = self.reader.read() | ||
# pp.pprint(self.content) | ||
except FileNotFoundError: | ||
print("Error: File Not Found: {0}".format(self.reader.filename)) | ||
return {} | ||
|
||
# lookup-table that maps a message to its findings | ||
findings = {} | ||
for message_id, message in self.content.items(): | ||
if message is None: | ||
continue | ||
|
||
self.logger.log_info("Processing...\"{0}\": \"{1}\"".format(message_id, message)) | ||
|
||
if type(message) is dict and message['message'] is not None: | ||
message = message['message'] | ||
elif type(message) is not str: | ||
continue | ||
else: # type(message) is str | ||
pass | ||
|
||
findings[message_id] = { | ||
"message": message, | ||
"linted": [] | ||
} | ||
|
||
found_something = lint(message) | ||
|
||
if len(found_something): | ||
print(">>> '{0}': \"{1}\"".format(message_id, message)) | ||
for something in found_something: | ||
findings[message_id]["linted"].append(something['desc']) | ||
print(">>> {0}".format(something['desc'])) | ||
print('~' * 10) | ||
self.writer.write(findings) | ||
return findings | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from message_lint.linter.str_lint import lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.