summaryrefslogtreecommitdiffstats
path: root/test/AS/fixture/myas.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/AS/fixture/myas.py')
-rw-r--r--test/AS/fixture/myas.py37
1 files changed, 25 insertions, 12 deletions
diff --git a/test/AS/fixture/myas.py b/test/AS/fixture/myas.py
index 3d05c79..a348ace 100644
--- a/test/AS/fixture/myas.py
+++ b/test/AS/fixture/myas.py
@@ -1,6 +1,7 @@
import sys
-if sys.platform == 'win32':
+
+def my_win32_as():
args = sys.argv[1:]
inf = None
while args:
@@ -10,29 +11,41 @@ if sys.platform == 'win32':
args = args[2:]
continue
args = args[1:]
- if not a[0] in "/-":
+ if not a[0] in '/-':
if not inf:
inf = a
continue
- if a[:3] == '/Fo': out = a[3:]
+ if a[:3] == '/Fo':
+ out = a[3:]
+
with open(inf, 'rb') as ifp, open(out, 'wb') as ofp:
- for l in ifp.readlines():
- if l[:3] != b'#as':
- ofp.write(l)
- sys.exit(0)
+ for line in ifp:
+ if not line.startswith(b'#as'):
+ ofp.write(line)
+
-else:
+def my_as():
import getopt
+
try:
opts, args = getopt.getopt(sys.argv[1:], 'co:')
except getopt.GetoptError:
# we may be called with --version, just quit if so
sys.exit(0)
for opt, arg in opts:
- if opt == '-o': out = arg
+ if opt == '-o':
+ out = arg
+
if args:
with open(args[0], 'rb') as ifp, open(out, 'wb') as ofp:
- for l in ifp.readlines():
- if l[:3] != b'#as':
- ofp.write(l)
+ for line in ifp:
+ if not line.startswith(b'#as'):
+ ofp.write(line)
+
+
+if __name__ == "__main__":
+ if sys.platform == 'win32':
+ my_win32_as()
+ else:
+ my_as()
sys.exit(0)