-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathstack_commands.py
More file actions
54 lines (45 loc) · 1.33 KB
/
stack_commands.py
File metadata and controls
54 lines (45 loc) · 1.33 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
import pickle
import variables as var
from datetime import datetime
def make_stack(username,project_name):
stack = []
element ={}
element["user"] = username
element["date-time"] = datetime.now()
path_to_stack = "/"+"/".join([project_name,"stack.txt"])
element["changes"] = {path_to_stack:"+"}
stack.append(element)
return stack
def load_g(project_name):
try:
f = open(var.global_destination+project_name+"/stack.txt","rb")
except:
print("Такого проекта не существует.\n")
return 0
global_stack = pickle.load(f)
f.close()
return global_stack
def load_l(username,project_name):
f = open(var.users_destination+username+"/"+project_name+"/stack.txt","rb")
local_stack = pickle.load(f)
f.close()
return local_stack
def dump_l(username,project_name,stack):
f = open(var.users_destination+username+"/"+project_name+"/stack.txt","wb")
pickle.dump(stack,f)
f.close()
return 0
def dump_g(project_name,stack):
f = open(var.global_destination+project_name+"/stack.txt","wb")
pickle.dump(stack,f)
f.close()
return 0
# def load_stack():
# f = open(var.global_destination+"version_control.txt","rb")
# global_version_control = pickle.load(f)
# f.close()
# return global_version_control
# def dump_stack(stack):
# f = open(var.global_destination+"version_control.txt","wb")
# pickle.dump(stack,f)
# f.close()