GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Python/~script.py at master · ikvm/Python Expand file tree/ Copy path~script.pyMore file actions 70 lines (60 loc) · 1.83 KB / Copy path~script.pyFile metadata and controls70 lines (60 loc) · 1.83 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 """ This is a simple script that will scan through the current directory and generate the corresponding DIRECTORY.md file, can also specify files or folders to be ignored. """ import os # Target URL (master) URL = "https://github.com/TheAlgorithms/Python/blob/master/" def tree(d, ignores, ignores_ext): return _markdown(d, ignores, ignores_ext, 0) def _markdown(parent, ignores, ignores_ext, depth): out = "" dirs, files = [], [] for i in os.listdir(parent): full = os.path.join(parent, i) name, ext = os.path.splitext(i) if i in ignores or ext in ignores_ext: continue if os.path.isfile(full): # generate list pre = parent.replace("./", "").replace(" ", "%20") # replace all spaces to safe URL child = i.replace(" ", "%20") files.append((pre, child, name)) else: dirs.append(i) # Sort files files.sort(key=lambda e: e[2].lower()) for f in files: pre, child, name = f out += " " * depth + "* [" + name.replace("_", " ") + "](" + URL + pre + "/" + child + ")\n" # Sort directories dirs.sort() for i in dirs: full = os.path.join(parent, i) i = i.replace("_", " ").title() if depth == 0: out += "## " + i + "\n" else: out += " " * depth + "* " + i + "\n" out += _markdown(full, ignores, ignores_ext, depth+1) return out # Specific files or folders with the given names will be ignored ignores = [".vs", ".gitignore", ".git", "script.py", "__init__.py", ] # Files with given entensions will be ignored ignores_ext = [ ".md", ".ipynb", ".png", ".jpg", ".yml" ] if __name__ == "__main__": with open("DIRECTORY.md", "w+") as f: f.write(tree(".", ignores, ignores_ext)) |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |