#import copy import os #import sys #import lxml.etree as etree #import subprocess #from datetime import datetime import docing import filing #from lxml.builder import ElementMaker from nitpo import Nitpo from emailer import Emailer #from surks import Surks from xpaths import Xpaths from profile import Profile class Anpro(Nitpo): def __init__(self, do_verbose=False): """profile surveys""" super().__init__() #ns = self.const['ns'] #self.nsmap = {None: ns} #self.N = "{%s}" % self.const['ns'] #self.E = ElementMaker(nsmap=self.const['nsmap']) #self.check_conf('folders', 'profile') #self.to_print = '' self.profile = Profile() self.emailer = Emailer() self.xpaths = Xpaths() #self.event = {} self.do_verbose = do_verbose def from_emad(self, emad): fufi = self.profile.fufi_from_emad(emad) digest = filing.md5(fufi) base = 'anpro/' + digest doc = self.profile.load(emad) # # if there are no live subscriptions quit if not self.xpaths.has_it(doc, '/n:profile/n:live/n:surk'): ## supposed to run the command line, so ok to print print('anpro sees no live surk.') return None # # take the base from the doc self.emailer.prepare(doc, empro='anpro', base=base) def from_doc(self, doc): digest = filing.md5(docing.show(doc)) base = 'anpro/' + digest # # if there are no live subscriptions quit #if not self.xpaths.has_it(doc, '/n:profile/n:live/n:surk'): # # print('anpro sees no live surk.') # return None # # take the base from the doc self.emailer.prepare(doc, empro='anpro', base=base)