Mercurial > repos > damion > versioned_data
comparison data_stores/kipper.py @ 2:269d246ce6d0 draft default tip
Uploaded
| author | damion |
|---|---|
| date | Fri, 23 Oct 2015 17:53:29 -0400 |
| parents | 5c5027485f7d |
| children |
comparison
equal
deleted
inserted
replaced
| 1:5c5027485f7d | 2:269d246ce6d0 |
|---|---|
| 934 if len(old_line)>0: | 934 if len(old_line)>0: |
| 935 temp.write(old_line+self.nl) | 935 temp.write(old_line+self.nl) |
| 936 | 936 |
| 937 temp.close() | 937 temp.close() |
| 938 | 938 |
| 939 import stat | |
| 940 | |
| 941 # TEST sort failure: set it so temp file is read only. | |
| 942 #mode = os.stat(temp.name)[stat.ST_MODE] | |
| 943 #os.chmod(temp.name,mode & ~0222) | |
| 944 | |
| 939 # Is this a consideration for natural sort in Python vs bash sort?: | 945 # Is this a consideration for natural sort in Python vs bash sort?: |
| 940 # *** WARNING *** The locale specified by the environment affects sort order. | 946 # *** WARNING *** The locale specified by the environment affects sort order. |
| 941 # Set LC_ALL=C to get the traditional sort order that uses native byte values. | 947 # Set LC_ALL=C to get the traditional sort order that uses native byte values. |
| 942 #-s stable; -f ignore case; V natural sort (versioning) ; -k column, -t tab delimiter | 948 #-s stable; -f ignore case; V natural sort (versioning) ; -k column, -t tab delimiter |
| 943 sort_a = subprocess.call(['sort', '-sfV', '-t\t', '-k1,1', '-o',temp.name, temp.name]) | 949 try: |
| 944 | 950 subprocess.check_call(['sort', '-sfV', '-t\t', '-k1,1', '-o',temp.name, temp.name]) |
| 951 except subprocess.CalledProcessError as e: | |
| 952 stop_err("Error: Sort of import file could not be completed, sort() returned error code " + str(e.returncode) ) | |
| 953 except OSError as e: | |
| 954 stop_err("Error: Sort of import file could not be completed, sort command or %s file not found?" % temp.name) | |
| 955 | |
| 945 return temp #Enables temp file name to be used by caller. | 956 return temp #Enables temp file name to be used by caller. |
| 946 | 957 |
| 947 | 958 |
| 948 def postprocess_line(self, line): | 959 def postprocess_line(self, line): |
| 949 """ | 960 """ |
