Browse Source

Commit my current pinboard data and a script to populate a DB with it

Getty Ritter 4 years ago
parent
commit
3c47da2fac
4 changed files with 785 additions and 0 deletions
  1. 0 0
      scripts/__init__.py
  2. 751 0
      scripts/aisamanra.json
  3. 28 0
      scripts/populate.py
  4. 6 0
      tasks.py

+ 0 - 0
scripts/__init__.py


File diff suppressed because it is too large
+ 751 - 0
scripts/aisamanra.json


+ 28 - 0
scripts/populate.py

@@ -0,0 +1,28 @@
+#!/usr/bin/env python3
+
+import json
+
+import lc.config
+import lc.model as m
+import lc.request as r
+
+
+def main():
+    lc.config.DB.init("test.db")
+    u, _ = m.User.get_or_create(name="gdritter",)
+    print(u)
+    with open("scripts/aisamanra.json") as f:
+        links = json.load(f)
+    for l in links:
+        req = r.Link(
+            url=l["href"],
+            name=l["description"],
+            description=l["extended"],
+            private=l["shared"] == "yes",
+            tags=l["tags"].split(),
+        )
+        print(m.Link.from_request(u, req))
+
+
+if __name__ == "__main__":
+    main()

+ 6 - 0
tasks.py

@@ -35,3 +35,9 @@ def fmt(c):
         c.run(f"git commit -a -m 'Automatic formatting commit: {date}'")
     else:
         print("Uncommitted change exist; skipping commit")
+
+
+@task
+def populate(c):
+    """Populate the test database with fake-ish data"""
+    c.run("PYTHONPATH=$(pwd) poetry run python3 ./scripts/populate.py")