示例#1
0
def new_mergelist(listpath, notespath):
    themelist = defaultdict(list)
    newentries, replacements, deletions, new_themes = get_changes(listpath)
    if '--test' in sys.argv:
        return report_changes(newentries, replacements, deletions, new_themes)
    to = themeontology.read(notespath)

    # delete keywords and replace if needed
    for key in deletions:
        (sid, oldweight, oldtheme) = key
        kwfield = to.story[sid].get(oldweight)
        idx = kwfield.delete(oldtheme)
        for nw, nt, nc, ncapacity in replacements[key]:
            assert oldweight == nw, "replacement listed but weights don't match, illogical"
            kwfield.insert(idx, nt, nc,
                           ncapacity)  ## {notes} not supported yet
        del replacements[key]

    # add remaining replacements, if any
    for key in replacements:
        (sid, oldweight, oldtheme) = key
        kwfield = to.story[sid].get(oldweight)
        for nw, nt, nc, ncapacity in replacements[key]:
            lib.log.warn("REPLACEMENT TARGET MISSING, APPENDING: %s -> %s",
                         key, nt)
            assert oldweight == nw, "replacement listed but weights don't match, illogical"
            kwfield.insert(None, nt, nc, ncapacity)

    for sid in newentries:
        for fieldname in newentries[sid]:
            for theme, comment, ncapacity in newentries[sid][fieldname]:
                kwfield = to.story[sid].get(fieldname)
                kwfield.insert(None, theme, comment, ncapacity)

    to.write_clean(verbose=True)
示例#2
0
def main():
    """
    Entry point.
    """
    path = os.path.join(credentials.GIT_THEMING_PATH, "notes")
    to = themeontology.read(path)
    to.write_clean()
示例#3
0
 def test_all(self):
     """
     Read all data in main themeing repo.
     """
     path = os.path.join(credentials.GIT_THEMING_PATH, "notes")
     to = themeontology.read(path)
     for warning in to.validate():
         print(warning.encode("ascii", "replace"))
示例#4
0
def main():
    """
    Entry point.
    """
    path = os.path.join(credentials.GIT_THEMING_PATH, "notes")
    to = themeontology.read(path)
    for story in to.stories():
        nchoice = len(list(story.get("Choice Themes").iter_parts()))
        if nchoice > 5:
            lib.log.warn("[NChoice] Story '%s' has %s choice themes.",
                         story.name, nchoice)
示例#5
0
def get_ontology():
    paths = set()
    for arg in sys.argv[2:-1]:
        for item in glob.glob(arg):
            paths.add(item)
    return themeontology.read(sorted(paths))