def main(argv, stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr): errors = 0 if len(argv) > 1: for arg in argv[1:]: lexer = PorkLexer(ANTLRInputStream(open(arg))) parser = Pork(CommonTokenStream(lexer)) parser.porkfile() errors += parser._state.syntaxErrors if not errors: if True: for clazz in classDefs.values(): fileName = arg[arg.rfind('/') + 1:] print 'setting file name to ' + fileName clazz.setSourceFile(fileName) writeClasses() classDefs.clear() else: lexer = PorkLexer(ANTLRInputStream(stdin)) parser = Pork(CommonTokenStream(lexer)) parser.porkfile() errors = parser._state.syntaxErrors if not errors: writeClasses() return errors
def setUp(self): lexer = PorkLexer(ANTLRInputStream(open('prk/26-unused-constants.prk'))) parser = Pork(CommonTokenStream(lexer)) parser.porkfile() self.clazz = classDefs['org.joellercoaster.pork.UnusedConstants']
def setUp(self): # this is crap a sign that bug #31 is on the money classDefs.clear() lexer = PorkLexer(ANTLRInputStream(open(SOURCE_FILE))) parser = Pork(CommonTokenStream(lexer)) parser.porkfile() self.clazz = classDefs["org.joellercoaster.pork.LineNumbers"] self.clazz.setSourceFile(SOURCE_FILE)
def setUp(self): lexer = PorkLexer(ANTLRInputStream(open('prk/24-exceptions.prk'))) parser = Pork(CommonTokenStream(lexer)) parser.porkfile() self.clazz = classDefs['org.joellercoaster.pork.Exceptions']
def initiate(self): if self.user_id == "bigbrother": user_role = "Admin" access_list = ["Pork","Bacon","Vindaloo"] allow = True else: matching_entries = list(self.employees_list[self.employees_list["Employee ID"] == self.user_id]["Name"]) if len(matching_entries) == 0: allow = False else: allow = True user_role = list(self.employees_list[self.employees_list["Employee ID"] == self.user_id]["Role"])[0] access_list = list(self.employees_list[self.employees_list["Employee ID"] == self.user_id]["OINK Access Level"])[0].split(",") if not allow: self.alertMessage("User Error","This User either doesn't exist or he or she has been marked as an ex-employee. Unable to load OINK.") self.close() else: userDict = { "Copy Editor": Bacon, "Team Lead": Vindaloo, "Big Brother": Vindaloo, "Product Specialist": Bacon, "Manager": Vindaloo, "Assistant Manager": Vindaloo, "Admin": Pork, "Content Writer": Pork } if user_role not in userDict.keys(): self.alertMessage("Unauthorized User","This version of OINK is not coded for use by a %s. If you encounter this message, you're probably trying to use the compiled version of OINK that doesn't need Python. That version was developed for use by writers because it's easier to set up. If you'd like to use the source version instead, follow the initial setup chapter in the documentation."%user_role) else: if len(access_list)>1: self.window = OINKChooser(self.user_id, self.password, access_list, self.category_tree, self.employees_list, self.brand_list) self.window.show() elif len(access_list) == 1: if access_list[0].upper() == "PORK": self.window = Pork(self.user_id, self.password, self.category_tree, self.employees_list, self.brand_list) self.window.show() elif access_list[0].upper() == "VINDALOO": self.window = Vindaloo(self.user_id, self.password, self.category_tree, self.employees_list, self.brand_list) self.window.show() elif access_list[0].upper() == "BACON": self.window = Bacon(self.user_id, self.password, self.category_tree, self.employees_list, self.brand_list) self.window.show() else: self.alertMessage("Error","%s is not a valid option."%chosen_widget) else: self.alertMessage("No Access","You seem to have no specific to the OINK Database. Contact your Reporting Manager and ask him or her to grant you access if necessary. I'm going to open the default application for your role now.") self.window = userDict[user_role](self.user_id, self.password, self.category_tree, self.employees_list, self.brand_list) self.window.show()
def launchChosenWidget(self): chosen_widget = str(self.combo_box_widgets.currentText()) if chosen_widget.upper() == "PORK": self.pork_window = Pork(self.user_id, self.password, self.category_tree, self.employees_list, self.brands_list) elif chosen_widget.upper() == "VINDALOO": self.vindaloo_window = Vindaloo(self.user_id, self.password, self.category_tree, self.employees_list, self.brands_list) elif chosen_widget.upper() == "BACON": self.bacon_window = Bacon(self.user_id, self.password, self.category_tree, self.employees_list, self.brands_list) else: self.alertMessage("Error", "%s is not a valid option." % chosen_widget)