def makeTree(self, dir, CLAN, head, head_p1=''): tp = Tree(os.path.join(dir, TREE_NODE), getLinkMaker(None), absLinks=False) dave = Person(tp, os.path.join(CLAN, head, head_p1, 'Dave')) jane = Person(tp, os.path.join('CLAN2', 'Baz', 'Jane')) dave.marry(jane, 'w')
def __init__(self, dryrun, rootPath, oldRootNode, link_type, absLinks): self.dryrun = dryrun self.rootPath = os.path.abspath(rootPath) self.oldRootNode = oldRootNode self.mklnk = getLinkMaker(link_type) self.newLnkSuffix = getLinkSuffix(self.mklnk) self.absLinks = absLinks if (self.mklnk is not os.symlink) and (not self.absLinks): print("Forcing absolute links") self.absLinks = True
def bond(other_path, relationship=PartnerLink.REL_PARTNER, linkType=None, me_path=None, force=False, absLink=False, quiet=False): mklnk = getLinkMaker(linkType) if me_path is None: me_path = os.path.abspath('.') me_name = extractPersonName(me_path) if (not isClan(me_name[0])) or (not isPerson(me_name[1])): raise Exception("my path %s is not a valid person" % (me_path)) other_name = extractPersonName(other_path) if (not isClan(other_name[0])) or (not isPerson(other_name[1])): raise Exception("spouse path %s is not a valid person" % (other_path)) me_rel = PartnerLink.getMyRelationship(relationship) me_to_other_lnk = os.path.join( me_path, relationship + '. ' + other_name[1] + ' ' + other_name[0]) other_to_me_lnk = os.path.join( other_path, me_rel + '. ' + me_name[1] + ' ' + me_name[0]) if os.path.exists(me_to_other_lnk) and not force: raise Exception("Spouse link already exists @ %s" % (me_to_other_lnk)) if os.path.exists(other_to_me_lnk) and not force: raise Exception("Spouse link already exists @ %s" % (other_to_me_lnk)) if not quiet: print("create: '%s' -> '%s'" % (me_to_other_lnk, other_path)) print("create: '%s' -> '%s'" % (other_to_me_lnk, me_path)) if quiet or oktodo("OK to create links?"): if os.path.exists(me_to_other_lnk): os.remove(me_to_other_lnk) if os.path.exists(other_to_me_lnk): os.remove(other_to_me_lnk) _create_spouse_link(me_to_other_lnk, other_path, mklnk, absLink) _create_spouse_link(other_to_me_lnk, me_path, mklnk, absLink)
def Backlink(self, link1, linkTgt1, link2, linkTgt2): mklnk = getLinkMaker(link1) makelink_withbck(linkTgt2, link2, mklnk, dryrun=self.dryrun)
def Auto(self, link, link_origTgt, link_revisedTgt, status): mklnk = getLinkMaker(link) makelink_withbck(link_revisedTgt, link, mklnk, dryrun=self.dryrun)