Ejemplo n.º 1
0
def embedgroupdata(extract_func, fname, debug):
    """insert group info into extracted idd"""

    astr = _readfname(fname)

    # fname is exhausted by the above read
    # reconstitute fname as a StringIO
    fname = StringIO(astr)

    try:
        astr = astr.decode("ISO-8859-2")
    except Exception as e:
        pass  # for python 3
    glist = iddgroups.iddtxt2grouplist(astr)

    blocklst, commlst, commdct = extract_func(fname)
    # add group information to commlst and commdct
    # glist = getglist(fname)
    commlst = iddgroups.group2commlst(commlst, glist)
    commdct = iddgroups.group2commdct(commdct, glist)
    return blocklst, commlst, commdct
Ejemplo n.º 2
0
def embedgroupdata(extract_func, fname, debug):
    """insert group info into extracted idd"""
    
    astr = _readfname(fname)
    
    # fname is exhausted by the above read
    # reconstitute fname as a StringIO
    fname = StringIO(astr)

    try:
        astr = astr.decode('ISO-8859-2')
    except Exception as e:
        pass # for python 3
    glist = iddgroups.iddtxt2grouplist(astr)
    
    
    blocklst, commlst, commdct = extract_func(fname)
    # add group information to commlst and commdct
    # glist = getglist(fname)
    commlst = iddgroups.group2commlst(commlst, glist)
    commdct = iddgroups.group2commdct(commdct, glist)
    return blocklst, commlst, commdct
Ejemplo n.º 3
0
def test_group2commdct():
    """py.test for group2commdct"""
    data = ((
    [
     [{'group':None, 'idfobj':'Lead Input'}],
     [{'group':None, 'idfobj':'Simulation Data'}],
     [{'group':'G1', 'idfobj':'Version', u'format': [u'singleLine'], u'unique-object': [u'']},
      {u'default': [u'7.0'],
       u'field': [u'Version Identifier'],
       u'required-field': [u'']}],
     [{'group':'G1', 'idfobj':'Version1', u'format': [u'singleLine'], u'unique-object': [u'']},
      {u'default': [u'7.0'],
       u'field': [u'Version Identifier'],
       u'required-field': [u'']}],
     [{'group':'G1', 'idfobj':'Version2', u'format': [u'singleLine'], u'unique-object': [u'']},
      {u'default': [u'7.0'],
       u'field': [u'Version Identifier'],
       u'required-field': [u'']}],
     [{'group':'G2', 'idfobj':'VersionG', u'format': [u'singleLine'], u'unique-object': [u'']},
      {u'default': [u'7.0'],
       u'field': [u'Version Identifier'],
       u'required-field': [u'']}],
     [{'group':'G2', 'idfobj':'VersionG1', u'format': [u'singleLine'], u'unique-object': [u'']},
      {u'default': [u'7.0'],
       u'field': [u'Version Identifier'],
       u'required-field': [u'']}],
     [{'group':'G2', 'idfobj':'VersionG2', u'format': [u'singleLine'], u'unique-object': [u'']},
      {u'default': [u'7.0'],
       u'field': [u'Version Identifier'],
       u'required-field': [u'']}]],
       ), # groupcommdct
    )
    for groupcommdct, in data:
        glist = iddgroups.iddtxt2grouplist(iddtxt)
        result = iddgroups.group2commdct(idf_commdct, glist)
        # assert result == groupcommdct
        for r, g in zip(result, groupcommdct):
            assert r == g
Ejemplo n.º 4
0
def test_group2commdct():
    """py.test for group2commdct"""
    data = (
        ([[{
            'group': None,
            'idfobj': 'Lead Input'
        }], [{
            'group': None,
            'idfobj': 'Simulation Data'
        }],
          [{
              'group': 'G1',
              'idfobj': 'Version',
              u'format': [u'singleLine'],
              u'unique-object': [u'']
          }, {
              u'default': [u'7.0'],
              u'field': [u'Version Identifier'],
              u'required-field': [u'']
          }],
          [{
              'group': 'G1',
              'idfobj': 'Version1',
              u'format': [u'singleLine'],
              u'unique-object': [u'']
          }, {
              u'default': [u'7.0'],
              u'field': [u'Version Identifier'],
              u'required-field': [u'']
          }],
          [{
              'group': 'G1',
              'idfobj': 'Version2',
              u'format': [u'singleLine'],
              u'unique-object': [u'']
          }, {
              u'default': [u'7.0'],
              u'field': [u'Version Identifier'],
              u'required-field': [u'']
          }],
          [{
              'group': 'G2',
              'idfobj': 'VersionG',
              u'format': [u'singleLine'],
              u'unique-object': [u'']
          }, {
              u'default': [u'7.0'],
              u'field': [u'Version Identifier'],
              u'required-field': [u'']
          }],
          [{
              'group': 'G2',
              'idfobj': 'VersionG1',
              u'format': [u'singleLine'],
              u'unique-object': [u'']
          }, {
              u'default': [u'7.0'],
              u'field': [u'Version Identifier'],
              u'required-field': [u'']
          }],
          [{
              'group': 'G2',
              'idfobj': 'VersionG2',
              u'format': [u'singleLine'],
              u'unique-object': [u'']
          }, {
              u'default': [u'7.0'],
              u'field': [u'Version Identifier'],
              u'required-field': [u'']
          }]], ),  # groupcommdct
    )
    for groupcommdct, in data:
        glist = iddgroups.iddtxt2grouplist(iddtxt)
        result = iddgroups.group2commdct(idf_commdct, glist)
        # assert result == groupcommdct
        for r, g in zip(result, groupcommdct):
            assert r == g
Ejemplo n.º 5
0
def test_group2commdct():
    """py.test for group2commdct"""
    data = (
        ([
            [{
                "group": None,
                "idfobj": "Lead Input"
            }],
            [{
                "group": None,
                "idfobj": "Simulation Data"
            }],
            [
                {
                    "group": "G1",
                    "idfobj": "Version",
                    "format": ["singleLine"],
                    "unique-object": [""],
                },
                {
                    "default": ["7.0"],
                    "field": ["Version Identifier"],
                    "required-field": [""],
                },
            ],
            [
                {
                    "group": "G1",
                    "idfobj": "Version1",
                    "format": ["singleLine"],
                    "unique-object": [""],
                },
                {
                    "default": ["7.0"],
                    "field": ["Version Identifier"],
                    "required-field": [""],
                },
            ],
            [
                {
                    "group": "G1",
                    "idfobj": "Version2",
                    "format": ["singleLine"],
                    "unique-object": [""],
                },
                {
                    "default": ["7.0"],
                    "field": ["Version Identifier"],
                    "required-field": [""],
                },
            ],
            [
                {
                    "group": "G2",
                    "idfobj": "VersionG",
                    "format": ["singleLine"],
                    "unique-object": [""],
                },
                {
                    "default": ["7.0"],
                    "field": ["Version Identifier"],
                    "required-field": [""],
                },
            ],
            [
                {
                    "group": "G2",
                    "idfobj": "VersionG1",
                    "format": ["singleLine"],
                    "unique-object": [""],
                },
                {
                    "default": ["7.0"],
                    "field": ["Version Identifier"],
                    "required-field": [""],
                },
            ],
            [
                {
                    "group": "G2",
                    "idfobj": "VersionG2",
                    "format": ["singleLine"],
                    "unique-object": [""],
                },
                {
                    "default": ["7.0"],
                    "field": ["Version Identifier"],
                    "required-field": [""],
                },
            ],
        ], ),  # groupcommdct
    )
    for (groupcommdct, ) in data:
        glist = iddgroups.iddtxt2grouplist(iddtxt)
        result = iddgroups.group2commdct(idf_commdct, glist)
        # assert result == groupcommdct
        for r, g in zip(result, groupcommdct):
            assert r == g