Tpayne101 commited on
Commit
35ff4c9
·
verified ·
1 Parent(s): bd2451d

Create motionid.py

Browse files
Files changed (1) hide show
  1. motionid.py +24 -0
motionid.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import uuid
2
+ import json
3
+ from pathlib import Path
4
+
5
+ DATA_FILE = Path("data/motion_ids.json")
6
+
7
+ def load_ids():
8
+ if DATA_FILE.exists():
9
+ return json.load(open(DATA_FILE))
10
+ return {}
11
+
12
+ def save_ids(ids):
13
+ json.dump(ids, open(DATA_FILE, "w"), indent=2)
14
+
15
+ def create_motion_id(user_name):
16
+ motion_id = str(uuid.uuid4())
17
+ ids = load_ids()
18
+ ids[motion_id] = {
19
+ "name": user_name,
20
+ "created_at": str(datetime.datetime.now()),
21
+ "usage_count": 0
22
+ }
23
+ save_ids(ids)
24
+ return motion_id