Python scripts now run without invoking Python

Changed my made python scripts so there is no need to invoke python:  just run with
`sudo ./<FILENAME>`
This commit is contained in:
mutto233
2018-07-06 18:44:57 -04:00
committed by GitHub
parent 91060e97c0
commit cc3514ea4d
2 changed files with 27 additions and 25 deletions

View File

@@ -1,26 +1,27 @@
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 26 23:31:00 2018
@author: Matt
"""
import re
import sys
def atoi(text):
return int(text) if text.isdigit() else text
def natural_keys(text):
'''
alist.sort(key=natural_keys) sorts in human order
http://nedbatchelder.com/blog/200712/human_sorting.html
(See Toothy's implementation in the comments)
'''
return [ atoi(c) for c in re.split('(\d+)', text) ]
temp_hold = list(sys.argv[1:])
temp_hold.sort(key=natural_keys)
file = open('Channels_Sorted.txt','w')
for item in temp_hold:
file.write(item + '\n')
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 26 23:31:00 2018
@author: Matt
"""
import re
import sys
def atoi(text):
return int(text) if text.isdigit() else text
def natural_keys(text):
'''
alist.sort(key=natural_keys) sorts in human order
http://nedbatchelder.com/blog/200712/human_sorting.html
(See Toothy's implementation in the comments)
'''
return [ atoi(c) for c in re.split('(\d+)', text) ]
temp_hold = list(sys.argv[1:])
temp_hold.sort(key=natural_keys)
file = open('Channels_Sorted.txt','w')
for item in temp_hold:
file.write(item + '\n')
file.close()

View File

@@ -1,3 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 28 17:33:59 2018