Skip to content

Commit

Permalink
Test library formatting corrected
Browse files Browse the repository at this point in the history
  • Loading branch information
mikahanninen committed Nov 28, 2012
1 parent bd417bb commit 5f50fb0
Showing 1 changed file with 20 additions and 30 deletions.
50 changes: 20 additions & 30 deletions rfgen.py
Expand Up @@ -45,25 +45,21 @@ def _create_test_libraries(path, filecount = 10, keywords=10):
libs.append(lib_name) libs.append(lib_name)
db_cursor.execute("INSERT INTO source (path,type) VALUES ('%s','CUSTOMLIBRARY')" % lib_name) db_cursor.execute("INSERT INTO source (path,type) VALUES ('%s','CUSTOMLIBRARY')" % lib_name)
libfile = open("%s/%s.py" % (path,lib_name),"w") libfile = open("%s/%s.py" % (path,lib_name),"w")
lib_doc = '"""Library documentation:\n'\ lib_doc = '\t"""Library documentation:\n' + \
'\t%s"""' % lib_name '\t\t%s"""' % lib_name
libfile.write(\ libfile.write("import os,time\n" + \
""" "class %s:\n" % lib_name + \
import os,time "\tdef __init__(self):\n" + \
"\t%s\n" % lib_doc)
class %s:
def __init__(self): directory_looper = "\tfor dirname, dirnames, filenames in os.walk('.'):\n" + \
%s "\t\tfor subdirname in dirnames:\n" + \
""" % (lib_name, lib_doc)) "\t\t\tprint os.path.join(dirname, subdirname)\n" + \

"\t\tfor filename in filenames:\n" + \
directory_looper = """for dirname, dirnames, filenames in os.walk('.'): "\t\t\tprint os.path.join(dirname, filename)\n"
for subdirname in dirnames: sleeper = "time.sleep(1)\n"
print os.path.join(dirname, subdirname)
for filename in filenames: libfile.write("\t\t%s" % random.choice([directory_looper, sleeper]) + "\n")
print os.path.join(dirname, filename)"""
sleeper = "time.sleep(1)"

libfile.write("\t" + random.choice([directory_looper, sleeper]) + "\n")


temp_verb = copy.copy(verbs) temp_verb = copy.copy(verbs)
counter = 1 counter = 1
Expand All @@ -76,17 +72,11 @@ def __init__(self):
kw_name = verb + "_" + lib_main kw_name = verb + "_" + lib_main
db_cursor.execute("INSERT INTO keywords (name,source) VALUES ('%s','%s')" % (kw_name,lib_name)) db_cursor.execute("INSERT INTO keywords (name,source) VALUES ('%s','%s')" % (kw_name,lib_name))
kw_doc = '"""Keyword documentation for %s"""' % kw_name kw_doc = '"""Keyword documentation for %s"""' % kw_name
libfile.write(\ libfile.write("\tdef %s(self):\n" % kw_name + \
""" "\t\t%s\n" % kw_doc + \
def %s(self): "\t\t%s\n" % random.choice([directory_looper, sleeper, "pass\n"]))
%s
%s libfile.write("myinstance = %s()" % lib_name)
""" % (kw_name,kw_doc,random.choice([directory_looper, sleeper, "pass"])))

libfile.write(\
"""
myinstance = %s()
""" % lib_name)
libfile.close() libfile.close()


#initfile_lines = open("%s/__init__.txt" % path).readlines() #initfile_lines = open("%s/__init__.txt" % path).readlines()
Expand Down

0 comments on commit 5f50fb0

Please sign in to comment.