-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExampleSort.py
More file actions
61 lines (28 loc) · 1006 Bytes
/
ExampleSort.py
File metadata and controls
61 lines (28 loc) · 1006 Bytes
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
import os
import pickle
import numpy
dirname = os.path.dirname(os.path.abspath(__file__))
class MyProjectObjectList(object):
"""
MyProjectObject is a class that groups all data needed:
it's possible to get:
- sort object by id
- get all data from file
"""
file = os.path.join(dirname, "project_object.pickle")
def __init__(self, list=None):
if list is None:
list = []
self.list = list
def __load_file(self, filename=None):
"""Load file"""
pfile = open((filename or self.file), 'rb+')
def __save_file(self, filename=None):
"""Save file"""
pfile = open((filename or self.file), 'wb+')
pickle.dump(self.list, pfile)
def __reading_file(self):
# Return a file with list of lines
# Open the file for reading.
with open('my_file.txt', 'r') as infile:
data = infile.read() # Read the contents of the file into memory.