-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
extended FSWTabDict class #377
base: master
Are you sure you want to change the base?
Changes from all commits
eacbb9f
a6dd09c
9fbae8b
763ce15
7def8d4
b0daf40
3ed3b43
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
# laws and regulations. User has the responsibility to obtain export licenses, | ||
# or other export authority as may be required before exporting such | ||
# information to foreign countries or providing access to foreign persons. | ||
|
||
import datetime | ||
import hashlib | ||
import io | ||
|
@@ -205,6 +206,7 @@ class FSWTabDefn(object): | |
single column. This includes the column name, its opcode, | ||
subsystem, description and a list of argument definitions. Name and | ||
opcode are required. All others are optional. | ||
|
||
""" | ||
|
||
def __init__(self, *args, **kwargs): | ||
|
@@ -375,6 +377,7 @@ def _decode_table_row(self, in_stream, raw=False): | |
Raises: | ||
ValueError: When an EOFError is encountered while decoding any column | ||
but the first or if any column decode returns None. | ||
|
||
""" | ||
|
||
row = [] | ||
|
@@ -406,6 +409,7 @@ class FSWTabDict(dict): | |
|
||
Table Dictionaries provide a Python dictionary (i.e. hashtable) | ||
interface mapping Tables names to Column Definitions. | ||
|
||
""" | ||
|
||
def __init__(self, *args, **kwargs): | ||
|
@@ -429,7 +433,7 @@ def create(self, name, *args): | |
tab = None | ||
defn = self.get(name, None) | ||
if defn: | ||
tab = FSWTab(defn, *args) | ||
tab = createFSWTab(defn, *args) | ||
return tab | ||
|
||
def load(self, filename): | ||
|
@@ -463,7 +467,7 @@ def dirty(self): | |
def load(self): | ||
if self.fswtabdict is None: | ||
if self.dirty(): | ||
self.fswtabdict = FSWTabDict(self.filename) | ||
self.fswtabdict = createFSWTabDict(self.filename) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
self.update() | ||
else: | ||
with open(self.pcklname, "rb") as stream: | ||
|
@@ -499,14 +503,14 @@ def getDefaultDict(): # noqa: N802 | |
|
||
def YAMLCtor_FSWColDefn(loader, node): # noqa: N802 | ||
fields = loader.construct_mapping(node, deep=True) | ||
return FSWColDefn(**fields) | ||
return createFSWColDefn(**fields) | ||
|
||
|
||
def YAMLCtor_FSWTabDefn(loader, node): # noqa: N802 | ||
fields = loader.construct_mapping(node, deep=True) | ||
fields["fswheaderdefns"] = fields.pop("header", None) | ||
fields["coldefns"] = fields.pop("columns", None) | ||
return FSWTabDefn(**fields) | ||
return createFSWTabDefn(**fields) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
|
||
|
||
def encode_to_file(tbl_type, in_path, out_path): | ||
|
@@ -544,3 +548,5 @@ def decode_to_file(tbl_type, in_path, out_path): | |
|
||
yaml.add_constructor("!FSWTable", YAMLCtor_FSWTabDefn) | ||
yaml.add_constructor("!FSWColumn", YAMLCtor_FSWColDefn) | ||
|
||
util.__init_extensions__(__name__, globals()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
createFSWTab
method not definedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done