Last active
August 26, 2021 12:03
-
-
Save pakdev/f5a21d108329ebeb8e72 to your computer and use it in GitHub Desktop.
Revisions
-
pakdev revised this gist
Dec 16, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -25,7 +25,7 @@ # The first part is any text that appears before either 'using' or # 'namespace' - perhaps an old copyright. The second part *should* be # the actual code beginning with 'using' or 'namespace'. match = re.search(r"^.*?((using|namespace|/\*|#).+)$", contents, re.DOTALL) if match: # Make the file's now contain the user defined copyright (below) # followed by a blank line followed by the actual code. -
pakdev revised this gist
Oct 30, 2014 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- import os import re import fnmatch import argparse from textwrap import dedent -
pakdev revised this gist
Oct 30, 2014 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,13 +14,13 @@ # Descend into the 'root' directory and find all *.cs files files = [] for root, dirnames, filenames in os.walk(args.root[0]): for filename in fnmatch.filter(filenames, "*.cs"): files.append(os.path.join(root, filename)) print "Found {0} *.cs files".format(len(files)) for filepath in files: with open(filepath) as f: contents = f.read() # This regex will separate the contents of a *.cs file into two parts. # The first part is any text that appears before either 'using' or @@ -30,14 +30,14 @@ if match: # Make the file's now contain the user defined copyright (below) # followed by a blank line followed by the actual code. contents = dedent('''\ // **************************************************************************** // <copyright file="{0}" company="Insert Company Here"> // Copyright © Insert Company Here 2014 // </copyright> // **************************************************************************** ''').format(os.path.basename(filepath)) + match.group(1) with open(filepath, 'w') as f: f.write(contents) print "Wrote new: {0}".format(filepath) -
pakdev revised this gist
Oct 30, 2014 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -31,11 +31,11 @@ # Make the file's now contain the user defined copyright (below) # followed by a blank line followed by the actual code. contents = dedent('''\ // **************************************************************************** // <copyright file="{0}" company="Insert Company Here"> // Copyright © Insert Company Here 2014 // </copyright> // **************************************************************************** ''').format(os.path.basename(filepath)) + match.group(1) with open(filepath, 'w') as f: -
pakdev revised this gist
Oct 30, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -39,5 +39,5 @@ ''').format(os.path.basename(filepath)) + match.group(1) with open(filepath, 'w') as f: f.write(contents) print "Wrote new: {0}".format(filepath) -
pakdev revised this gist
Oct 30, 2014 . 1 changed file with 2 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,12 +16,11 @@ for root, dirnames, filenames in os.walk(args.root[0]): for filename in fnmatch.filter(filenames, "*.cs"): files.append(os.path.join(root, filename)) print "Found {0} *.cs files".format(len(files)) for filepath in files: with open(filepath) as f: contents = f.read() # This regex will separate the contents of a *.cs file into two parts. # The first part is any text that appears before either 'using' or -
pakdev revised this gist
Oct 30, 2014 . 1 changed file with 23 additions and 23 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,40 +5,40 @@ import fnmatch import argparse from textwrap import dedent parser = argparse.ArgumentParser(description='Add/update copyright on C# files') parser.add_argument('root', nargs=1, help='Path to the root of the C# project') args = parser.parse_args() # Descend into the 'root' directory and find all *.cs files files = [] for root, dirnames, filenames in os.walk(args.root[0]): for filename in fnmatch.filter(filenames, "*.cs"): files.append(os.path.join(root, filename)) print "Found {0} *.cs files".format(len(files)) for filepath in files: with open(filepath) as f: contents = f.read() # This regex will separate the contents of a *.cs file into two parts. # The first part is any text that appears before either 'using' or # 'namespace' - perhaps an old copyright. The second part *should* be # the actual code beginning with 'using' or 'namespace'. match = re.search(r"^.+?((using|namespace).+)$", contents, re.DOTALL) if match: # Make the file's now contain the user defined copyright (below) # followed by a blank line followed by the actual code. contents = dedent('''\ // **************************************************************************** // <copyright file="{0}" company="Insert Company Here"> // Copyright © Insert Company Here 2014 // </copyright> // **************************************************************************** ''').format(os.path.basename(filepath)) + match.group(1) with open(filepath, 'w') as f: f.write(contents) print "Wrote new: {0}".format(filepath) -
pakdev created this gist
Oct 30, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ # -*- coding: utf-8 -*- import os import re import codecs import fnmatch import argparse from textwrap import dedent parser = argparse.ArgumentParser(description='Add/update copyright on C# files') parser.add_argument('root', nargs=1, help='Path to the root of the C# project') args = parser.parse_args() # Descend into the 'root' directory and find all *.cs files files = [] for root, dirnames, filenames in os.walk(args.root[0]): for filename in fnmatch.filter(filenames, "*.cs"): files.append(os.path.join(root, filename)) print "Found {0} *.cs files".format(len(files)) for filepath in files: with open(filepath) as f: contents = f.read() # This regex will separate the contents of a *.cs file into two parts. # The first part is any text that appears before either 'using' or # 'namespace' - perhaps an old copyright. The second part *should* be # the actual code beginning with 'using' or 'namespace'. match = re.search(r"^.+?((using|namespace).+)$", contents, re.DOTALL) if match: # Make the file's now contain the user defined copyright (below) # followed by a blank line followed by the actual code. contents = dedent('''\ // **************************************************************************** // <copyright file="{0}" company="Insert Company Here"> // Copyright © Insert Company Here 2014 // </copyright> // **************************************************************************** ''').format(os.path.basename(filepath)) + match.group(1) with open(filepath, 'w') as f: f.write(contents) print "Wrote new: {0}".format(filepath)