-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#86 * Test cases dependencies to tlp runtime refactored
* Moved state image to TlpConfig items * Code refactorings
- Loading branch information
Showing
11 changed files
with
106 additions
and
105 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 |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "1.3.1-6" | ||
__version__ = "1.3.1-7" |
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
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,55 @@ | ||
|
||
import re | ||
from io import open | ||
from json import load | ||
|
||
|
||
def get_json_schema_object_from_file(objectname: str, filename: str) -> dict: | ||
jsonfile = open(filename) | ||
jsonobject = load(jsonfile) | ||
jsonfile.close() | ||
return jsonobject[objectname] | ||
|
||
|
||
class TlpDefaults: | ||
def __init__(self, name: str, value: str, enabled: bool): | ||
self.name = name | ||
self.value = value | ||
self.enabled = enabled | ||
|
||
def get_name(self) -> str: | ||
return self.name | ||
|
||
def get_value(self) -> str: | ||
return self.value | ||
|
||
def is_enabled(self) -> bool: | ||
return self.enabled | ||
|
||
|
||
def extract_default_tlp_configs(filename: str) -> dict: | ||
propertypattern = re.compile(r'^#?[A-Z_\d]+=') | ||
fileopener = open(filename) | ||
lines = fileopener.readlines() | ||
fileopener.close() | ||
|
||
tlpconfig_defaults = dict() | ||
for line in lines: | ||
if propertypattern.match(line): | ||
cleanline = line.lstrip().rstrip() | ||
|
||
if (cleanline.startswith('#')): | ||
enabled = False | ||
cleanline = cleanline.lstrip('#') | ||
else: | ||
enabled = True | ||
|
||
property = cleanline.split('=', maxsplit=1) | ||
propertyname = property[0] | ||
propertyvalue = property[1] | ||
|
||
if propertyvalue.startswith('\"') and propertyvalue.endswith('\"'): | ||
propertyvalue = propertyvalue.lstrip('\"').rstrip('\"') | ||
|
||
tlpconfig_defaults[propertyname] = TlpDefaults(propertyname, propertyvalue, enabled) | ||
return tlpconfig_defaults |
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 |
---|---|---|
|
@@ -24,4 +24,3 @@ | |
tlpconfig = dict() | ||
tlpconfig_original = dict() | ||
tlpconfig_defaults = dict() | ||
imagestate = dict() |
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