-
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.
Merge pull request #146 from Origen-SDK/origen_metal
Reference File API
- Loading branch information
Showing
33 changed files
with
759 additions
and
273 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
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,7 @@ | ||
""" | ||
This module provides APIs that are closely related to creating features for an application framework | ||
like Origen, e.g. a logging system. | ||
They are generic enough to allow you to use them to create a similar feature in your own | ||
application framework, but they are not quite as generic as the APIs found in the origen_metal.utils module. | ||
""" |
75 changes: 75 additions & 0 deletions
75
python/origen_metal/origen_metal/framework/reference_files.py
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,75 @@ | ||
""" | ||
This module provides an API to implement Origen's reference file system, that is the system | ||
which records when output files are new or whether they have changed vs. a previously generated | ||
reference file, allowing the user to decide when and if to save the latest version as a new | ||
reference. | ||
Under the hood the API fully supports parallel recording of change/new file references, and is | ||
therefore fully compatible with references being recorded when batch processing on a system | ||
like LSF. | ||
""" | ||
|
||
|
||
def set_save_ref_dir(dir: str): | ||
""" | ||
**This must be called before using any other function**. | ||
It defines where you want the temporary files (the so called save_refs) to be stored. | ||
The given directory should not be under revision control. | ||
""" | ||
... | ||
|
||
|
||
def create_changed_ref(key: str, new_file: str, ref_file: str): | ||
""" | ||
When a change has been detected between a newly created file and reference file, call this | ||
to record the change. | ||
The given key can be later used to apply it (copy the new file over to the reference | ||
file location). | ||
""" | ||
... | ||
|
||
|
||
def create_new_ref(key: str, new_file: str, ref_file: str): | ||
""" | ||
When a new file has been detected (one that doesn't have an existing reference file to compare to), | ||
call this to record the new file. | ||
The given key can be later used to apply it (copy the new file over to the reference | ||
file location). | ||
""" | ||
... | ||
|
||
|
||
def apply_ref(key: str): | ||
""" | ||
Apply's a particular change or new file reference by copying the changed/new file over to the | ||
previously given reference file location. | ||
The key given to this function should match a key previously given to either | ||
origen_metal.framework.create_changed_ref() or origen_metal.framework.create_new_ref() | ||
""" | ||
... | ||
|
||
|
||
def apply_all_changed_refs(): | ||
""" | ||
Apply's all changed references that have been previously registered via origen_metal.framework.create_changed_ref() | ||
""" | ||
... | ||
|
||
|
||
def apply_all_new_refs(): | ||
""" | ||
Apply's all new file references that have been previously registered via origen_metal.framework.create_new_ref() | ||
""" | ||
... | ||
|
||
|
||
def clear_save_refs(): | ||
""" | ||
Clears all previously registered changed or new file references | ||
""" | ||
... |
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,4 @@ | ||
""" | ||
This module contains low-level APIs that are very generic and could be used in many | ||
different applications. | ||
""" |
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,38 @@ | ||
from typing import Optional, Tuple, List | ||
|
||
|
||
def has_diffs( | ||
file_a: str, | ||
file_b: str, | ||
ignore_comments: Optional[List[str]] = None, | ||
ignore_blocks: Optional[List[Tuple[str, str]]] = None, | ||
ignore_blank_lines: bool = True, | ||
) -> bool: | ||
""" | ||
This function compares the two ASCII files at the given paths and returns True if any | ||
differences are found between them. | ||
Blank lines will be ignored by default, so additional blank lines in one file will | ||
not result in a diff being reported if they are otherwise the same. | ||
Differences in comments can be ignored by specifying the comment char(s) to be used, | ||
and blocks of content can be ignored (e.g. C-style block comments) by specifying start | ||
and end characters. | ||
# Examples | ||
```python | ||
# Ignore Python style comments | ||
has_diffs("file_a.py", "file_b.py", ignore_comments=["#"]) | ||
# Ignore C++ style comments, including blocks | ||
has_diffs("file_a.cpp", "file_b.cpp", ignore_comments=["//"], ignore_blocks=[("/*", "*/")]) | ||
# Multiple entries can be given to both the ignore_comments and ignore_blocks arguments | ||
has_diffs("file_a.cpp", | ||
"file_b.cpp", | ||
ignore_comments=["//", "#"], | ||
ignore_blocks=[("/*", "*/"), ("{{", "}}")]) | ||
``` | ||
""" | ||
... |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.