Skip to content

WIP support for multi valued pick/enum fields #22

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

Open
wants to merge 1 commit into
base: py3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/pyreqif/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ def createDocument(id, title="title", comment="created by pyreqif"):
def addDocType(id, mydoc, lastChange=datetime.datetime.today().isoformat(), longName = "doc_type"):
mydoc.specificationTypes.add({"identifier": id, "lastChange": lastChange, "longName": longName})

def addDatatype(id, mydoc, type="document", lastChange=datetime.datetime.today().isoformat(), longName="xhtml", values = None):
def addDatatype(id, mydoc, type="document", lastChange=datetime.datetime.today().isoformat(), longName="xhtml", values = None, multiValued=False):
if values is None:
mydoc.addDatatype({"identifier":id, "type":type, "lastChange": lastChange, "longName":longName})
else:
mydoc.addDatatype({"identifier":id, "type":type, "lastChange": lastChange, "longName":longName, "values" : values})
mydoc.addDatatype({"identifier":id, "type":type, "lastChange": lastChange, "longName":longName, "values" : values, "multiValued" : multiValued})


def addSpecRelationType(id, mydoc, longName, lastChange=datetime.datetime.today().isoformat()):
Expand Down
5 changes: 4 additions & 1 deletion src/pyreqif/reqif.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,10 @@ def dump(doc, f):
attribDict = py2reqif(ref.toDict())
if "TYPE" in attribDict and attribDict["TYPE"] == "enum":
attribDict.pop("TYPE")
attribDict["MULTI-VALUED"] = "false"
if attribDict["multiValued"]:
attribDict["MULTI-VALUED"] = "true"
else:
attribDict["MULTI-VALUED"] = "false"
enumXml = createSubElement(attributesXml,"ATTRIBUTE-DEFINITION-ENUMERATION", attributes=attribDict)
# for value,label in attribDict.iteritems():
for value, label in attribDict.items():
Expand Down
5 changes: 4 additions & 1 deletion src/pyreqif/rif.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,10 @@ def dump(doc, f):
attribDict = py2reqif(ref.toDict())
if "TYPE" in attribDict and attribDict["TYPE"] == "enum":
attribDict.pop("TYPE")
attribDict["MULTI-VALUED"] = "false"
if attribDict["multiValued"]:
attribDict["MULTI-VALUED"] = "true"
else:
attribDict["MULTI-VALUED"] = "false"
enumXml = createSubElement(attributesXml,"ATTRIBUTE-DEFINITION-ENUMERATION", attributes=attribDict)
for value,label in attribDict.items():
if value == "typeRef":
Expand Down