def main(argv=None): if argv is None: argv = sys.argv try: try: opts, args = getopt.getopt(argv[1:], "ho:v", ["help", "output="]) except getopt.error, msg: raise Usage(msg) # option processing for option, value in opts: if option == "-v": verbose = True if option in ("-h", "--help"): raise Usage(help_message) if option in ("-o", "--output"): output = value print args fname, objkey, oldname, newname, newfname = args objkey = objkey.upper() iddfile = "../iddfiles/Energy+V6_0.idd" block,commlst,commdct=parse_idd.extractidddata(iddfile) theidd=eplusdata.idd(block,2) data, commdct = readidf.readdatacommdct(fname, iddfile=theidd, commdct=commdct) idd = eplus_functions.Idd(commdct, commlst, theidd, block) idfw = eplus_functions.IdfWrapper(data, idd) # --- eplus_functions.rename_name(idfw, key, oldname, newname) txt = `data` open(newfname, 'w').write(txt)
def test_rename_name(): """py.test for rename_name""" thedata = (("""Zone,SPACE1__1,0,0,0,0,1,1,2.438400269,239.247360229;People,SPACE1__1_People_1,SPACE1__1,OCCUPY__1,people,11,,,0.3,,ActSchd;""", "ZONE", "SPACE1__1", "LOBBY" , """Zone,LOBBY,0,0,0,0,1,1,2.438400269,239.247360229;People,SPACE1__1_People_1,LOBBY,OCCUPY__1,people,11,,,0.3,,ActSchd;""" ),# idftxt, objkey, oldname, newname, newidf ) for idftxt, objkey, oldname, newname, newidf in thedata: fname = StringIO(idftxt) data, commdct = readidf.readdatacommdct(fname, iddfile=iddV6_0.theidd, commdct=iddV6_0.commdct) idd = eplus_functions.Idd(iddV6_0.commdct, iddV6_0.commlst, iddV6_0.theidd, iddV6_0.block) idfw = eplus_functions.IdfWrapper(data, idd) result = eplus_functions.rename_name(idfw, objkey, oldname, newname) data = idfw.idf txt = `data` lst = txt.split() rtxt = ''.join(lst) print rtxt print newidf assert rtxt == newidf
theidd=eplusdata.idd(block,2) fname = "../idffiles/a.idf" data, commdct = readidf.readdatacommdct(fname, iddfile=theidd, commdct=commdct) idd = eplus_functions.Idd(commdct, commlst, theidd, block) idfw = eplus_functions.IdfWrapper(data, idd) # --- key = 'zone'.upper() fieldid = 1 oldname = 'SPACE1__1' newname = 'LOBBY' eplus_functions.rename_name(idfw, key, oldname, newname) txt = `data` fname = 'a.idf' open(fname, 'w').write(txt) def main(argv=None): if argv is None: argv = sys.argv try: try: opts, args = getopt.getopt(argv[1:], "ho:v", ["help", "output="]) except getopt.error, msg: raise Usage(msg) # option processing for option, value in opts: