Skip to content

Commit 978bf79

Browse files
committed
Fixed a little.
1 parent 8c8d92b commit 978bf79

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

Scripts/fix_copyright.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@
119119

120120
thePatterns = [re.compile(thePattern, re.MULTILINE) for thePattern in thePatterns]
121121

122-
path = '/Users/schwa/Development/Source/Mercurial/small-society/small-society/Externals/touchcode'
123-
os.chdir(path)
122+
path = '.'
124123

125124
def files():
126125
for root, dirs, files in os.walk('.'):
@@ -146,15 +145,19 @@ def files():
146145
]
147146

148147
def SanitizeCopyright(s):
149-
theMatches = [thePattern.match(s) for thePattern in theCopyrightPatterns]
150-
theMatches = [theMatch for theMatch in theMatches if theMatch]
151-
theMatch = theMatches[0]
152-
d = theMatch.groupdict()
153-
if d['owner'] in ['Jonathan Wight', '__MyCompanyName__', 'Toxic Software', 'TouchCode']:
154-
d['owner'] = 'toxicsoftware.com'
148+
try:
149+
theMatches = [thePattern.match(s) for thePattern in theCopyrightPatterns]
150+
theMatches = [theMatch for theMatch in theMatches if theMatch]
151+
theMatch = theMatches[0]
152+
d = theMatch.groupdict()
153+
if d['owner'] in ['Jonathan Wight', '__MyCompanyName__', 'Toxic Software', 'TouchCode']:
154+
d['owner'] = 'toxicsoftware.com'
155155

156-
s = '%(year)s %(owner)s. All rights reserved.' % d
157-
return s
156+
return '%(year)s %(owner)s. All rights reserved.' % d
157+
except Exception, e:
158+
print 'Exception', e
159+
print '>', s
160+
print type(s)
158161

159162

160163
########################################################################
@@ -184,6 +187,8 @@ def SanitizeCopyright(s):
184187
d['filename'] = os.path.split(f)[1]
185188
del d['block']
186189

190+
if d['copyright'] == 'None':
191+
raise Exception('Copyright is None: ' + f)
187192
d['copyright'] = SanitizeCopyright(d['copyright'])
188193

189194
theReplacement = FORMAT % d

0 commit comments

Comments
 (0)