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 characters
| #!/usr/bin/python | |
| import matplotlib | |
| import numpy as np | |
| import matplotlib.cm as cm | |
| import matplotlib.mlab as mlab | |
| import matplotlib.pyplot as plt | |
| import sys,getopt | |
| #class dosedata: |
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 characters
| #!/usr/bin/python | |
| import os, sys, shutil, re | |
| source_file = open(sys.argv[1]) | |
| source_name = sys.argv[1].rstrip(".egsinp") | |
| dst_file1_name = source_name + "_colli50mm.egsinp" | |
| dst_file2_name = source_name + "_colli40mm.egsinp" | |
| dst_file3_name = source_name + "_colli30mm.egsinp" | |
| dst_file4_name = source_name + "_colli25mm.egsinp" |
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 characters
| class Rule: | |
| """ | |
| Base class for all rules. | |
| """ | |
| def action(self, block, handler): | |
| handler.start(self.type) | |
| handler.feed(block) | |
| handler.end(self.type) | |
| return True |
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 characters
| import sys, re | |
| from handlers import * | |
| from util import * | |
| from rules import * | |
| class Parser: | |
| """ | |
| A Parser reads a text file, applying rules and controlling a | |
| handler. | |
| """ |
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 characters
| class Handler: | |
| """ | |
| An object that handles method calls from the Parser. | |
| The Parser will call the start() and end() methods at the | |
| beginning of each block, with the proper block name as a | |
| parameter. The sub() method will be used in regular expression | |
| substitution. When called with a name such as 'emphasis', it will | |
| return a proper substitution function. | |
| """ |
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 characters
| """ | |
| handle text in an open file | |
| lines: yield every line in the open file; | |
| blocks: yield every block ine open file. A block is many lines containing no empty lines. | |
| """ | |
| def lines(file): | |
| for line in file: yield line | |
| # yield '\n' |
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 characters
| # -*- coding: utf-8 -*- | |
| """ | |
| 根据给定的范围,用混合进制的方式输出所有元组。 | |
| """ | |
| def tuplesGen(ranges): | |
| """ | |
| >>> ranges = (2,3,4) | |
| >>> for t in tuplesGen(ranges): |
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 characters
| Here is a list of scopes to use in Sublime Text 2 snippets - | |
| ActionScript: source.actionscript.2 | |
| AppleScript: source.applescript | |
| ASP: source.asp | |
| Batch FIle: source.dosbatch | |
| C#: source.cs | |
| C++: source.c++ | |
| Clojure: source.clojure | |
| CoffeeScript: source.coffee |
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 characters
| # -*- coding: utf-8 -*- | |
| def mkdir(path, relative = True): | |
| import os | |
| currentPath = os.getcwd().replace("\\",'/') | |
| path = path.strip() | |
| path = currentPath + '/' + path.replace("\\",'/').rstrip('/') | |
| if not os.path.exists(path): | |
| print 'The Directory ' + path + ' has been created.' | |
| os.makedirs(path) |
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 characters
| # OLS_4 = [[(0, 0), (2, 2), (3, 3), (1, 1)], | |
| # [(2, 3), (0, 1), (1, 0), (3, 2)], | |
| # [(3, 1), (1, 3), (0, 2), (2, 0)], | |
| # [(1, 2), (3, 0), (2, 1), (0, 3)]] | |
| # OLS_5 = [[(0, 0), (1, 1), (2, 2), (3, 3), (4, 4)], | |
| # [(1, 2), (2, 3), (3, 4), (4, 0), (0, 1)], | |
| # [(2, 4), (3, 0), (4, 1), (0, 2), (1, 3)], | |
| # [(3, 1), (4, 2), (0, 3), (1, 4), (2, 0)], | |
| # [(4, 3), (0, 4), (1, 0), (2, 1), (3, 2)]] |
OlderNewer