Scripts related to devnotes - lmmx/devnotes GitHub Wiki

After downloading the devnotes wiki as a git repo, it's helpful to use some scripting to work with the files

with os.scandir(path) as it:
    wl = [x for entry in it if not entry.name.startswith('.') and entry.is_file()]

wl.sort(key=lambda x: stat(x).st_mtime)
wl.reverse()
i = len([x for x in wl if stat(x).st_mtime == stat(wl[0]).st_mtime])
print('\n'.join([x.name+"\t"+x.stat() for x in wl[0:i]]))
  • note you can pass in these filenames in a $() enclosed subshell to grep (no flag needed, just after the search term) to search within them [rather than piping from ls etc.]

  • N.B. to get to normal datetime format:

    from datetime import datetime as dt
    str(dt.fromtimestamp(teststat.st_mtime)).split(' ')[0]
    
  • e.g. search the entries for "python"

    [x for x in wl if ([re.search(r'\bpython\b', y) for y in wikidict[x]].count(None) != len(wikidict[x]))]