python - Should I create a factory class or a getobj method? -
i've been reading stackoverflow years, , first post. i've tried searching, can't find both understand, , matches scenario. yes, i'm total oop newbie, please explain things plainly possible.
ok, i'm trying write python script calls rsync make backup.
i'm calling script root's crontab. because opens security issues, i'm going reading in directories need backed (and few options rsync command each directory) configuration file in form configparser module understand.
so, i'm @ point want create objects represent backup directory. question thus:
do make separate object factory class, , send of relevant information gleaned while parsing config file? alternatively, put object creation stuff in method in existing configuration parsing class?
i hope @ least of makes sense.
please note both production use , learning project me learn object oriented programming , design, yes, overkill go oop on this, want learn stuff!
thanks advice , help!
here's of i'm got far (pseudo code):
import configparser import logging import os class parseconf(object): [set logging facilities] def __init__(self,conffile = "/etc/pybackup/pyback.conf"): self.conffile = conffile self.confvals = {} def getdirs(): create configparser instance read config file add values dictionary self.confvals def getdirobj(): either create list of objects here or send self.confvals factory object returns list of objects.
Comments
Post a Comment