Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class topicData:
- def __init__(self):
- self.board = "";
- self.thread= "";
- self.message= "";
- self.name= "";
- self.email= "";
- self.file = "";
- def setBoard(self, board):
- self.board = board;
- def getBoard(self):
- return self.board;
- def setThread(self, thread):
- self.thread = thread;
- def getThread(self):
- return self.thread;
- def setMessage(self, message):
- self.message = message;
- def getMessage(self):
- return self.message;
- def setName(self, name):
- self.name = name;
- def getName(self):
- return self.name;
- def setEmail(self, email):
- self.email = email;
- def getEmail(self):
- return self.email;
- def setFile(self, filePath):
- self.file = filePath;
- def getFile(self):
- return self.file;
- class CustomParser:
- def validateARGS(args, argType):
- if (args!=NONE and args!=argType and (args!="-b" and args!="-t" and args!="-m" and args!="-n" and args!="-e" and args!="-f")):
- return TRUE;
- elif (args!=NONE and args==argType):
- return TRUE;
- else:
- return FALSE;
- def checkListPOS():
- try:
- if (lista[count]==NONE):
- return TRUE;
- else:
- return FALSE;
- except:
- return FALSE;
- def argTypeSET(argType, ptrList, args):
- if(argType=="-b"):
- ptrList.setBoard(args);
- elif(argType=="-t"):
- ptrList.setThread(args);
- elif(argType=="-m"):
- ptrList.setMessage(args);
- elif(argType=="-n"):
- ptrList.setName(args);
- elif(argType=="-e"):
- ptrList.setEmail(args);
- elif(argType=="-f"):
- ptrList.setFile(args);
- def parser(argType, argvsub):
- count = 0;
- for args in argvsub:
- if (validateARGS(args, argType)):
- bllPOS=checkListaPOS(count);
- if (bllPOS):
- ptrList=topicData();
- self.lista.append( ptrList );
- else:
- ptrList=lista[count];
- count+=1;
- argTypeSET(argType, ptrList, args);
- else:
- break;
- def getList(self):
- return self.lista;
- def __init__(argsv):
- for args in argv:
- if (args=="-b"):
- parser("-b", args[1:]);
- elif (args=="-t"):
- parser("-t", args[1:]);
- elif (args=="-m"):
- parser("-m", args[1:]);
- elif (args=="-n"):
- parser("-n", args[1:]);
- elif (args=="-e"):
- parser("-e", args[1:]);
- elif (args=="-f"):
- parser("-f", args[1:]);
- def testarObjeto():
- testOBJ = topicData();
- testOBJ.setBoard("board");
- testOBJ.setThread("threadNumber");
- testOBJ.setMessage("message");
- testOBJ.setName("Nome");
- testOBJ.setEmail("teste@gmail.com");
- testOBJ.setFile("Coisinha.jpg");
- print("{0}, {1}, {2}, {3}, {4}, {5}".format(testOBJ.getBoard(), testOBJ.getThread(), testOBJ.getMessage(), testOBJ.getEmail(), testOBJ.getFile(), testOBJ.getName()));
- def testarParser():
- stringteste="python.py -b board1 board2 board3 -t thread1 thread2 thread3 -m oixakulinha1 oixerxinho2 oimiguxinhu3 -e teste1@gmail.com teste2@gmail.com teste3@gmail.com -f arquivo1.jpg, arquivo2.jpg, arquivo3.jpg";
- objParser = CustomParser(stringteste[1:]);
- listaTeste = objParser.getList();
- for listaTST in listaTeste:
- print("board: {0}\nthread: {1}\nmessage: {2}\nemail: {3}\nfile: {4}\nname: {5}\n\n".format(listaTST.board, listaTST.thread, listaTS.message, listaTST.email, listaTST.file, listaTST.name));
- def testarMODULOS():
- testarObjeto();
- testarParser();
- print("teste");
- testarMODULOS();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement