All pastes #452932 Raw Edit

aib

public python v1 · immutable
·published 2007-04-22 16:55 UTC
rendered paste body
    (options, args) = parser.parse_args()    # Imports the module you specified                                                                                                                          feature_module = __import__(options.module)    # Connects to the database                                                                                                                                  dbConn = FeatureDB()    # Only add the feature if it isn't there already                                                                                                            if not options.feature in dbConn.getFeatureNames():        dbConn.addFeature(options.feature, options.type)    # pageList = dbConn.getRatedPages()                                                                                                                         f = open(args[0])    pageList = f.readlines()    f.close()    pageList = [id[:-1] for id in pageList if id[-1:] == '\n']    pageList = [int(id) for id in pageList]    for page in pageList:        # Now, using the text (and whatever else), calculate the feature.                                                                                           text = dbConn.getTextField(page, options.text)        try:            func = getattr(feature_module, options.function)        except AttributeError:            print "The specified method " + options.function + " doesn't exist!"            sys.exit(0)        else:            # This is where we call your function, and it returns the value                                                                                             value = func(text)        # Put the feature in the database                                                                                                                           dbConn.updateFeature(options.feature, page, value)    # Close the connection                                                                                                                                      dbConn.endSession()