File: fixpy2.py

package info (click to toggle)
lysdr 1.0~git20141206+dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 832 kB
  • ctags: 1,685
  • sloc: python: 11,659; ansic: 1,335; makefile: 24
file content (50 lines) | stat: -rw-r--r-- 1,032 bytes parent folder | download | duplicates (13)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
#! /usr/bin/env python
# encoding: utf-8
# WARNING! All changes made to this file will be lost!

import os
all_modifs={}
def fixdir(dir):
	global all_modifs
	for k in all_modifs:
		for v in all_modifs[k]:
			modif(os.path.join(dir,'waflib'),k,v)
def modif(dir,name,fun):
	if name=='*':
		lst=[]
		for y in'. Tools extras'.split():
			for x in os.listdir(os.path.join(dir,y)):
				if x.endswith('.py'):
					lst.append(y+os.sep+x)
		for x in lst:
			modif(dir,x,fun)
		return
	filename=os.path.join(dir,name)
	f=open(filename,'r')
	txt=f.read()
	f.close()
	txt=fun(txt)
	f=open(filename,'w')
	f.write(txt)
	f.close()
def subst(*k):
	def do_subst(fun):
		global all_modifs
		for x in k:
			try:
				all_modifs[x].append(fun)
			except KeyError:
				all_modifs[x]=[fun]
		return fun
	return do_subst
def r1(code):
	code=code.replace(',e:',',e:')
	code=code.replace("",'')
	code=code.replace('','')
	return code
def r4(code):
	code=code.replace('next(self.biter)','self.biter.next()')
	return code

subst('*')(r1)
subst('Runner.py')(r4)