@@ -1,67 +1,67 | |||||
1 | ''' No newline at end of file |
|
1 | ''' | |
2 | Created on May 2, 2013 No newline at end of file |
|
2 | Created on May 2, 2013 | |
3 | No newline at end of file |
|
3 | ||
4 | @author: Jose Antonio Sal y Rosas Celi No newline at end of file |
|
4 | @author: Jose Antonio Sal y Rosas Celi | |
5 | @contact: jose.salyrosas@jro.igp.gob.pe No newline at end of file |
|
5 | @contact: jose.salyrosas@jro.igp.gob.pe | |
6 | ''' No newline at end of file |
|
6 | ''' | |
7 | from datetime import datetime No newline at end of file |
|
7 | from datetime import datetime | |
8 | import os No newline at end of file |
|
8 | import os | |
9 | No newline at end of file |
|
9 | ||
10 | class saveABSFile(object): No newline at end of file |
|
10 | class saveABSFile(object): | |
11 | No newline at end of file |
|
11 | ||
12 | __scriptName = "saveABSFile.py" No newline at end of file |
|
12 | __scriptName = "saveABSFile.py" | |
13 | No newline at end of file |
|
13 | ||
14 | def __init__(self): No newline at end of file |
|
14 | def __init__(self): | |
15 | self.path = "" No newline at end of file |
|
15 | self.path = "" | |
16 | self.number_patterns = 0 No newline at end of file |
|
16 | self.number_patterns = 0 | |
17 | self.patterns = [] No newline at end of file |
|
17 | self.patterns = [] | |
18 | No newline at end of file |
|
18 | ||
19 | def save(self): No newline at end of file |
|
19 | def save(self): | |
20 | #filename = "%s.txt" % (self.setFilename()) |
|
20 | #filename = "%s.txt" % (self.setFilename()) | |
No newline at end of file |
|
21 | filename = "%s.abs" % (self.exp_name) No newline at end of file | ||
21 | filename = "%s.txt" % (self.exp_name) No newline at end of file |
|
|||
22 | final_path = os.path.join(self.path, filename) No newline at end of file |
|
22 | final_path = os.path.join(self.path, filename) | |
23 | self.saveFile(final_path) No newline at end of file |
|
23 | self.saveFile(final_path) | |
24 | filesize = os.path.getsize(final_path) No newline at end of file |
|
24 | filesize = os.path.getsize(final_path) | |
25 | No newline at end of file |
|
25 | ||
26 | return final_path, filesize No newline at end of file |
|
26 | return final_path, filesize | |
27 | No newline at end of file |
|
27 | ||
28 | def setParameters(self, path, exp_name, lsPatterns): No newline at end of file |
|
28 | def setParameters(self, path, exp_name, lsPatterns): | |
29 | self.path = path No newline at end of file |
|
29 | self.path = path | |
30 | self.exp_name = exp_name No newline at end of file |
|
30 | self.exp_name = exp_name | |
31 | strExperimentName = " title ='%s'" % exp_name No newline at end of file |
|
31 | strExperimentName = " title ='%s'" % exp_name | |
32 | self.patterns = lsPatterns No newline at end of file |
|
32 | self.patterns = lsPatterns | |
33 | number_patterns = len(lsPatterns) No newline at end of file |
|
33 | number_patterns = len(lsPatterns) | |
34 | self.number_patterns = " #Experiments = %d" % number_patterns No newline at end of file |
|
34 | self.number_patterns = " #Experiments = %d" % number_patterns | |
35 | contentPatterns = "" No newline at end of file |
|
35 | contentPatterns = "" | |
36 | for element in lsPatterns: No newline at end of file |
|
36 | for element in lsPatterns: | |
37 | valueUp = self.convertValue(element["up"]) No newline at end of file |
|
37 | valueUp = self.convertValue(element["up"]) | |
38 | valueDown = self.convertValue(element["down"]) No newline at end of file |
|
38 | valueDown = self.convertValue(element["down"]) | |
39 | contentPatterns += "\n%d = \n%s\n%s" % (element["number"], valueUp, valueDown) No newline at end of file |
|
39 | contentPatterns += "\n%d = \n%s\n%s" % (element["number"], valueUp, valueDown) | |
40 | contentPatterns = contentPatterns.replace("]],$", "]]") No newline at end of file |
|
40 | contentPatterns = contentPatterns.replace("]],$", "]]") | |
41 | self.content = "%s\r\n\n%s\r\n%s" % (strExperimentName, self.number_patterns, contentPatterns) No newline at end of file |
|
41 | self.content = "%s\r\n\n%s\r\n%s" % (strExperimentName, self.number_patterns, contentPatterns) | |
42 | No newline at end of file |
|
42 | ||
43 | def convertValue(self, strAntenna): No newline at end of file |
|
43 | def convertValue(self, strAntenna): | |
44 | value = "" No newline at end of file |
|
44 | value = "" | |
45 | strAntenna = strAntenna.replace("],[","]+[") No newline at end of file |
|
45 | strAntenna = strAntenna.replace("],[","]+[") | |
46 | lsAntenna = strAntenna.split("+") No newline at end of file |
|
46 | lsAntenna = strAntenna.split("+") | |
47 | for element in lsAntenna: |
|
47 | for element in lsAntenna: | |
No newline at end of file |
|
48 | value += " %s,$\n" % element No newline at end of file | ||
48 | value += "\t%s,$\n" % element No newline at end of file |
|
|||
49 | No newline at end of file |
|
49 | ||
50 | return value No newline at end of file |
|
50 | return value | |
51 | No newline at end of file |
|
51 | ||
52 | def setFilename(self): No newline at end of file |
|
52 | def setFilename(self): | |
53 | initialTime = datetime.today() No newline at end of file |
|
53 | initialTime = datetime.today() | |
54 | filename = str(initialTime) No newline at end of file |
|
54 | filename = str(initialTime) | |
55 | No newline at end of file |
|
55 | ||
56 | filename = filename.replace("-","") No newline at end of file |
|
56 | filename = filename.replace("-","") | |
57 | filename = filename.replace(":","") No newline at end of file |
|
57 | filename = filename.replace(":","") | |
58 | filename = filename.replace(".","") No newline at end of file |
|
58 | filename = filename.replace(".","") | |
59 | filename = filename.replace(" ","") No newline at end of file |
|
59 | filename = filename.replace(" ","") | |
60 | No newline at end of file |
|
60 | ||
61 | return filename No newline at end of file |
|
61 | return filename | |
62 | No newline at end of file |
|
62 | ||
63 | def saveFile(self, filename): No newline at end of file |
|
63 | def saveFile(self, filename): | |
64 | f = open(filename, 'a+') No newline at end of file |
|
64 | f = open(filename, 'a+') | |
65 | f.write(self.content) No newline at end of file |
|
65 | f.write(self.content) | |
66 | f.close() No newline at end of file |
|
66 | f.close() | |
67 | No newline at end of file |
|
67 |
General Comments 0
You need to be logged in to leave comments.
Login now