Dataset Viewer
Auto-converted to Parquet Duplicate
nwo
stringlengths
6
76
sha
stringlengths
40
40
path
stringlengths
5
118
language
stringclasses
1 value
identifier
stringlengths
1
89
parameters
stringlengths
2
5.4k
argument_list
stringclasses
1 value
return_statement
stringlengths
0
51.1k
docstring
stringlengths
1
17.6k
docstring_summary
stringlengths
0
7.02k
docstring_tokens
sequence
function
stringlengths
30
51.1k
function_tokens
sequence
url
stringlengths
85
218
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
svm.py
python
toPyModel
(model_ptr)
return m
toPyModel(model_ptr) -> svm_model Convert a ctypes POINTER(svm_model) to a Python svm_model
toPyModel(model_ptr) -> svm_model
[ "toPyModel", "(", "model_ptr", ")", "-", ">", "svm_model" ]
def toPyModel(model_ptr): """ toPyModel(model_ptr) -> svm_model Convert a ctypes POINTER(svm_model) to a Python svm_model """ if bool(model_ptr) == False: raise ValueError("Null pointer") m = model_ptr.contents m.__createfrom__ = 'C' return m
[ "def", "toPyModel", "(", "model_ptr", ")", ":", "if", "bool", "(", "model_ptr", ")", "==", "False", ":", "raise", "ValueError", "(", "\"Null pointer\"", ")", "m", "=", "model_ptr", ".", "contents", "m", ".", "__createfrom__", "=", "'C'", "return", "m" ]
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/svm.py#L293-L303
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
svmutil.py
python
svm_read_problem
(data_file_name)
return (prob_y, prob_x)
svm_read_problem(data_file_name) -> [y, x] Read LIBSVM-format data from data_file_name and return labels y and data instances x.
svm_read_problem(data_file_name) -> [y, x]
[ "svm_read_problem", "(", "data_file_name", ")", "-", ">", "[", "y", "x", "]" ]
def svm_read_problem(data_file_name): """ svm_read_problem(data_file_name) -> [y, x] Read LIBSVM-format data from data_file_name and return labels y and data instances x. """ prob_y = [] prob_x = [] for line in open(data_file_name): line = line.split(None, 1) # In case an instance with all zero features ...
[ "def", "svm_read_problem", "(", "data_file_name", ")", ":", "prob_y", "=", "[", "]", "prob_x", "=", "[", "]", "for", "line", "in", "open", "(", "data_file_name", ")", ":", "line", "=", "line", ".", "split", "(", "None", ",", "1", ")", "# In case an ins...
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/svmutil.py#L14-L34
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
svmutil.py
python
svm_load_model
(model_file_name)
return model
svm_load_model(model_file_name) -> model Load a LIBSVM model from model_file_name and return.
svm_load_model(model_file_name) -> model
[ "svm_load_model", "(", "model_file_name", ")", "-", ">", "model" ]
def svm_load_model(model_file_name): """ svm_load_model(model_file_name) -> model Load a LIBSVM model from model_file_name and return. """ model = libsvm.svm_load_model(model_file_name.encode()) if not model: print("can't open model file %s" % model_file_name) return None model = toPyModel(model) return mo...
[ "def", "svm_load_model", "(", "model_file_name", ")", ":", "model", "=", "libsvm", ".", "svm_load_model", "(", "model_file_name", ".", "encode", "(", ")", ")", "if", "not", "model", ":", "print", "(", "\"can't open model file %s\"", "%", "model_file_name", ")", ...
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/svmutil.py#L36-L47
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
svmutil.py
python
svm_save_model
(model_file_name, model)
svm_save_model(model_file_name, model) -> None Save a LIBSVM model to the file model_file_name.
svm_save_model(model_file_name, model) -> None
[ "svm_save_model", "(", "model_file_name", "model", ")", "-", ">", "None" ]
def svm_save_model(model_file_name, model): """ svm_save_model(model_file_name, model) -> None Save a LIBSVM model to the file model_file_name. """ libsvm.svm_save_model(model_file_name.encode(), model)
[ "def", "svm_save_model", "(", "model_file_name", ",", "model", ")", ":", "libsvm", ".", "svm_save_model", "(", "model_file_name", ".", "encode", "(", ")", ",", "model", ")" ]
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/svmutil.py#L49-L55
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
svmutil.py
python
evaluations
(ty, pv)
return (ACC, MSE, SCC)
evaluations(ty, pv) -> (ACC, MSE, SCC) Calculate accuracy, mean squared error and squared correlation coefficient using the true values (ty) and predicted values (pv).
evaluations(ty, pv) -> (ACC, MSE, SCC)
[ "evaluations", "(", "ty", "pv", ")", "-", ">", "(", "ACC", "MSE", "SCC", ")" ]
def evaluations(ty, pv): """ evaluations(ty, pv) -> (ACC, MSE, SCC) Calculate accuracy, mean squared error and squared correlation coefficient using the true values (ty) and predicted values (pv). """ if len(ty) != len(pv): raise ValueError("len(ty) must equal to len(pv)") total_correct = total_error = 0 sum...
[ "def", "evaluations", "(", "ty", ",", "pv", ")", ":", "if", "len", "(", "ty", ")", "!=", "len", "(", "pv", ")", ":", "raise", "ValueError", "(", "\"len(ty) must equal to len(pv)\"", ")", "total_correct", "=", "total_error", "=", "0", "sumv", "=", "sumy",...
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/svmutil.py#L57-L84
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
svmutil.py
python
svm_train
(arg1, arg2=None, arg3=None)
svm_train(y, x [, options]) -> model | ACC | MSE svm_train(prob [, options]) -> model | ACC | MSE svm_train(prob, param) -> model | ACC| MSE Train an SVM model from data (y, x) or an svm_problem prob using 'options' or an svm_parameter param. If '-v' is specified in 'options' (i.e., cross validation) either accu...
svm_train(y, x [, options]) -> model | ACC | MSE svm_train(prob [, options]) -> model | ACC | MSE svm_train(prob, param) -> model | ACC| MSE
[ "svm_train", "(", "y", "x", "[", "options", "]", ")", "-", ">", "model", "|", "ACC", "|", "MSE", "svm_train", "(", "prob", "[", "options", "]", ")", "-", ">", "model", "|", "ACC", "|", "MSE", "svm_train", "(", "prob", "param", ")", "-", ">", "m...
def svm_train(arg1, arg2=None, arg3=None): """ svm_train(y, x [, options]) -> model | ACC | MSE svm_train(prob [, options]) -> model | ACC | MSE svm_train(prob, param) -> model | ACC| MSE Train an SVM model from data (y, x) or an svm_problem prob using 'options' or an svm_parameter param. If '-v' is specified i...
[ "def", "svm_train", "(", "arg1", ",", "arg2", "=", "None", ",", "arg3", "=", "None", ")", ":", "prob", ",", "param", "=", "None", ",", "None", "if", "isinstance", "(", "arg1", ",", "(", "list", ",", "tuple", ")", ")", ":", "assert", "isinstance", ...
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/svmutil.py#L86-L171
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
svmutil.py
python
svm_predict
(y, x, m, options="")
return pred_labels, (ACC, MSE, SCC), pred_values
svm_predict(y, x, m [, options]) -> (p_labels, p_acc, p_vals) Predict data (y, x) with the SVM model m. options: -b probability_estimates: whether to predict probability estimates, 0 or 1 (default 0); for one-class SVM only 0 is supported. -q : quiet mode (no outputs). The return tuple contains ...
svm_predict(y, x, m [, options]) -> (p_labels, p_acc, p_vals)
[ "svm_predict", "(", "y", "x", "m", "[", "options", "]", ")", "-", ">", "(", "p_labels", "p_acc", "p_vals", ")" ]
def svm_predict(y, x, m, options=""): """ svm_predict(y, x, m [, options]) -> (p_labels, p_acc, p_vals) Predict data (y, x) with the SVM model m. options: -b probability_estimates: whether to predict probability estimates, 0 or 1 (default 0); for one-class SVM only 0 is supported. -q : quiet mod...
[ "def", "svm_predict", "(", "y", ",", "x", ",", "m", ",", "options", "=", "\"\"", ")", ":", "def", "info", "(", "s", ")", ":", "print", "(", "s", ")", "predict_probability", "=", "0", "argv", "=", "options", ".", "split", "(", ")", "i", "=", "0"...
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/svmutil.py#L173-L260
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/modpython_example.py
python
test
(req, name=Tests.__all__[0])
return """<html> <head> <title>PyCAPTCHA Example</title> </head> <body> <h1>PyCAPTCHA Example (for mod_python)</h1> <p> <b>%s</b>: %s </p> <p><img src="image?id=%s"/></p> <p> <form action="solution" method="get"> Enter the word shown: <input type="text" name="word"/> <input type="hidden" name="id" va...
Show a newly generated CAPTCHA of the given class. Default is the first class name given in Tests.__all__
Show a newly generated CAPTCHA of the given class. Default is the first class name given in Tests.__all__
[ "Show", "a", "newly", "generated", "CAPTCHA", "of", "the", "given", "class", ".", "Default", "is", "the", "first", "class", "name", "given", "in", "Tests", ".", "__all__" ]
def test(req, name=Tests.__all__[0]): """Show a newly generated CAPTCHA of the given class. Default is the first class name given in Tests.__all__ """ test = _getFactory(req).new(getattr(Tests, name)) # Make a list of tests other than the one we're using others = [] for t in Tests.__a...
[ "def", "test", "(", "req", ",", "name", "=", "Tests", ".", "__all__", "[", "0", "]", ")", ":", "test", "=", "_getFactory", "(", "req", ")", ".", "new", "(", "getattr", "(", "Tests", ",", "name", ")", ")", "# Make a list of tests other than the one we're ...
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/modpython_example.py#L27-L69
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/modpython_example.py
python
image
(req, id)
return apache.OK
Generate an image for the CAPTCHA with the given ID string
Generate an image for the CAPTCHA with the given ID string
[ "Generate", "an", "image", "for", "the", "CAPTCHA", "with", "the", "given", "ID", "string" ]
def image(req, id): """Generate an image for the CAPTCHA with the given ID string""" test = _getFactory(req).get(id) if not test: raise apache.SERVER_RETURN, apache.HTTP_NOT_FOUND req.content_type = "image/jpeg" test.render().save(req, "JPEG") return apache.OK
[ "def", "image", "(", "req", ",", "id", ")", ":", "test", "=", "_getFactory", "(", "req", ")", ".", "get", "(", "id", ")", "if", "not", "test", ":", "raise", "apache", ".", "SERVER_RETURN", ",", "apache", ".", "HTTP_NOT_FOUND", "req", ".", "content_ty...
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/modpython_example.py#L72-L79
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/modpython_example.py
python
solution
(req, id, word)
return """<html> <head> <title>PyCAPTCHA Example</title> </head> <body> <h1>PyCAPTCHA Example</h1> <h2>%s</h2> <p><img src="image?id=%s"/></p> <p><b>%s</b></p> <p>You guessed: %s</p> <p>Possible solutions: %s</p> <p><a href="test">Try again</a></p> </body> </html> """ % (test.__class__.__name__, test.id, result, word, ...
Grade a CAPTCHA given a solution word
Grade a CAPTCHA given a solution word
[ "Grade", "a", "CAPTCHA", "given", "a", "solution", "word" ]
def solution(req, id, word): """Grade a CAPTCHA given a solution word""" test = _getFactory(req).get(id) if not test: raise apache.SERVER_RETURN, apache.HTTP_NOT_FOUND if not test.valid: # Invalid tests will always return False, to prevent # random trial-and-error attacks. This ...
[ "def", "solution", "(", "req", ",", "id", ",", "word", ")", ":", "test", "=", "_getFactory", "(", "req", ")", ".", "get", "(", "id", ")", "if", "not", "test", ":", "raise", "apache", ".", "SERVER_RETURN", ",", "apache", ".", "HTTP_NOT_FOUND", "if", ...
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/modpython_example.py#L82-L111
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/Captcha/Words.py
python
WordList.read
(self)
Read words from disk
Read words from disk
[ "Read", "words", "from", "disk" ]
def read(self): """Read words from disk""" f = open(os.path.join(File.dataDir, "words", self.fileName)) self.words = [] for line in f.xreadlines(): line = line.strip() if not line: continue if line[0] == '#': continue ...
[ "def", "read", "(", "self", ")", ":", "f", "=", "open", "(", "os", ".", "path", ".", "join", "(", "File", ".", "dataDir", ",", "\"words\"", ",", "self", ".", "fileName", ")", ")", "self", ".", "words", "=", "[", "]", "for", "line", "in", "f", ...
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/Captcha/Words.py#L26-L42
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/Captcha/Words.py
python
WordList.pick
(self)
return random.choice(self.words)
Pick a random word from the list, reading it in if necessary
Pick a random word from the list, reading it in if necessary
[ "Pick", "a", "random", "word", "from", "the", "list", "reading", "it", "in", "if", "necessary" ]
def pick(self): """Pick a random word from the list, reading it in if necessary""" if self.words is None: self.read() return random.choice(self.words)
[ "def", "pick", "(", "self", ")", ":", "if", "self", ".", "words", "is", "None", ":", "self", ".", "read", "(", ")", "return", "random", ".", "choice", "(", "self", ".", "words", ")" ]
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/Captcha/Words.py#L44-L48
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/Captcha/Base.py
python
BaseCaptcha.testSolutions
(self, solutions)
return numCorrect >= self.minCorrectSolutions and \ numIncorrect <= self.maxIncorrectSolutions
Test whether the given solutions are sufficient for this CAPTCHA. A given CAPTCHA can only be tested once, after that it is invalid and always returns False. This makes random guessing much less effective.
Test whether the given solutions are sufficient for this CAPTCHA. A given CAPTCHA can only be tested once, after that it is invalid and always returns False. This makes random guessing much less effective.
[ "Test", "whether", "the", "given", "solutions", "are", "sufficient", "for", "this", "CAPTCHA", ".", "A", "given", "CAPTCHA", "can", "only", "be", "tested", "once", "after", "that", "it", "is", "invalid", "and", "always", "returns", "False", ".", "This", "m...
def testSolutions(self, solutions): """Test whether the given solutions are sufficient for this CAPTCHA. A given CAPTCHA can only be tested once, after that it is invalid and always returns False. This makes random guessing much less effective. """ if not self.valid: ...
[ "def", "testSolutions", "(", "self", ",", "solutions", ")", ":", "if", "not", "self", ".", "valid", ":", "return", "False", "self", ".", "valid", "=", "False", "numCorrect", "=", "0", "numIncorrect", "=", "0", "for", "solution", "in", "solutions", ":", ...
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/Captcha/Base.py#L45-L64
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/Captcha/Base.py
python
Factory.new
(self, cls, *args, **kwargs)
return inst
Create a new instance of our assigned BaseCaptcha subclass, passing it any extra arguments we're given. This stores the result for later testing.
Create a new instance of our assigned BaseCaptcha subclass, passing it any extra arguments we're given. This stores the result for later testing.
[ "Create", "a", "new", "instance", "of", "our", "assigned", "BaseCaptcha", "subclass", "passing", "it", "any", "extra", "arguments", "we", "re", "given", ".", "This", "stores", "the", "result", "for", "later", "testing", "." ]
def new(self, cls, *args, **kwargs): """Create a new instance of our assigned BaseCaptcha subclass, passing it any extra arguments we're given. This stores the result for later testing. """ self.clean() inst = cls(*args, **kwargs) self.storedInstances[ins...
[ "def", "new", "(", "self", ",", "cls", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "clean", "(", ")", "inst", "=", "cls", "(", "*", "args", ",", "*", "*", "kwargs", ")", "self", ".", "storedInstances", "[", "inst", ".", ...
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/Captcha/Base.py#L76-L84
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/Captcha/Base.py
python
Factory.get
(self, id)
return self.storedInstances.get(id)
Retrieve the CAPTCHA with the given ID. If it's expired already, this will return None. A typical web application will need to new() a CAPTCHA when generating an html page, then get() it later when its images or sounds must be rendered.
Retrieve the CAPTCHA with the given ID. If it's expired already, this will return None. A typical web application will need to new() a CAPTCHA when generating an html page, then get() it later when its images or sounds must be rendered.
[ "Retrieve", "the", "CAPTCHA", "with", "the", "given", "ID", ".", "If", "it", "s", "expired", "already", "this", "will", "return", "None", ".", "A", "typical", "web", "application", "will", "need", "to", "new", "()", "a", "CAPTCHA", "when", "generating", ...
def get(self, id): """Retrieve the CAPTCHA with the given ID. If it's expired already, this will return None. A typical web application will need to new() a CAPTCHA when generating an html page, then get() it later when its images or sounds must be rendered. """ ...
[ "def", "get", "(", "self", ",", "id", ")", ":", "return", "self", ".", "storedInstances", ".", "get", "(", "id", ")" ]
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/Captcha/Base.py#L86-L92
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/Captcha/Base.py
python
Factory.clean
(self)
Removed expired tests
Removed expired tests
[ "Removed", "expired", "tests" ]
def clean(self): """Removed expired tests""" expiredIds = [] now = time.time() for inst in self.storedInstances.itervalues(): if inst.creationTime + self.lifetime < now: expiredIds.append(inst.id) for id in expiredIds: del self.storedInstan...
[ "def", "clean", "(", "self", ")", ":", "expiredIds", "=", "[", "]", "now", "=", "time", ".", "time", "(", ")", "for", "inst", "in", "self", ".", "storedInstances", ".", "itervalues", "(", ")", ":", "if", "inst", ".", "creationTime", "+", "self", "....
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/Captcha/Base.py#L94-L102
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/Captcha/Base.py
python
Factory.test
(self, id, solutions)
return result
Test the given list of solutions against the BaseCaptcha instance created earlier with the given id. Returns True if the test passed, False on failure. In either case, the test is invalidated. Returns False in the case of an invalid id.
Test the given list of solutions against the BaseCaptcha instance created earlier with the given id. Returns True if the test passed, False on failure. In either case, the test is invalidated. Returns False in the case of an invalid id.
[ "Test", "the", "given", "list", "of", "solutions", "against", "the", "BaseCaptcha", "instance", "created", "earlier", "with", "the", "given", "id", ".", "Returns", "True", "if", "the", "test", "passed", "False", "on", "failure", ".", "In", "either", "case", ...
def test(self, id, solutions): """Test the given list of solutions against the BaseCaptcha instance created earlier with the given id. Returns True if the test passed, False on failure. In either case, the test is invalidated. Returns False in the case of an invalid id. ...
[ "def", "test", "(", "self", ",", "id", ",", "solutions", ")", ":", "self", ".", "clean", "(", ")", "inst", "=", "self", ".", "storedInstances", ".", "get", "(", "id", ")", "if", "not", "inst", ":", "return", "False", "result", "=", "inst", ".", "...
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/Captcha/Base.py#L104-L115
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/Captcha/File.py
python
RandomFileFactory._checkExtension
(self, name)
return False
Check the file against our given list of extensions
Check the file against our given list of extensions
[ "Check", "the", "file", "against", "our", "given", "list", "of", "extensions" ]
def _checkExtension(self, name): """Check the file against our given list of extensions""" for ext in self.extensions: if name.endswith(ext): return True return False
[ "def", "_checkExtension", "(", "self", ",", "name", ")", ":", "for", "ext", "in", "self", ".", "extensions", ":", "if", "name", ".", "endswith", "(", "ext", ")", ":", "return", "True", "return", "False" ]
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/Captcha/File.py#L28-L33
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/Captcha/File.py
python
RandomFileFactory._findFullPaths
(self)
return paths
From our given file list, find a list of full paths to files
From our given file list, find a list of full paths to files
[ "From", "our", "given", "file", "list", "find", "a", "list", "of", "full", "paths", "to", "files" ]
def _findFullPaths(self): """From our given file list, find a list of full paths to files""" paths = [] for name in self.fileList: path = os.path.join(dataDir, self.basePath, name) if os.path.isdir(path): for content in os.listdir(path): ...
[ "def", "_findFullPaths", "(", "self", ")", ":", "paths", "=", "[", "]", "for", "name", "in", "self", ".", "fileList", ":", "path", "=", "os", ".", "path", ".", "join", "(", "dataDir", ",", "self", ".", "basePath", ",", "name", ")", "if", "os", "....
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/Captcha/File.py#L35-L46
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/Captcha/Visual/Base.py
python
ImageCaptcha.getImage
(self)
return self._image
Get a PIL image representing this CAPTCHA test, creating it if necessary
Get a PIL image representing this CAPTCHA test, creating it if necessary
[ "Get", "a", "PIL", "image", "representing", "this", "CAPTCHA", "test", "creating", "it", "if", "necessary" ]
def getImage(self): """Get a PIL image representing this CAPTCHA test, creating it if necessary""" if not self._image: self._image = self.render() return self._image
[ "def", "getImage", "(", "self", ")", ":", "if", "not", "self", ".", "_image", ":", "self", ".", "_image", "=", "self", ".", "render", "(", ")", "return", "self", ".", "_image" ]
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/Captcha/Visual/Base.py#L29-L33
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/Captcha/Visual/Base.py
python
ImageCaptcha.getLayers
(self)
return []
Subclasses must override this to return a list of Layer instances to render. Lists within the list of layers are recursively rendered.
Subclasses must override this to return a list of Layer instances to render. Lists within the list of layers are recursively rendered.
[ "Subclasses", "must", "override", "this", "to", "return", "a", "list", "of", "Layer", "instances", "to", "render", ".", "Lists", "within", "the", "list", "of", "layers", "are", "recursively", "rendered", "." ]
def getLayers(self): """Subclasses must override this to return a list of Layer instances to render. Lists within the list of layers are recursively rendered. """ return []
[ "def", "getLayers", "(", "self", ")", ":", "return", "[", "]" ]
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/Captcha/Visual/Base.py#L35-L39
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/Captcha/Visual/Base.py
python
ImageCaptcha.render
(self, size=None)
return self._renderList(self._layers, Image.new("RGB", size))
Render this CAPTCHA, returning a PIL image
Render this CAPTCHA, returning a PIL image
[ "Render", "this", "CAPTCHA", "returning", "a", "PIL", "image" ]
def render(self, size=None): """Render this CAPTCHA, returning a PIL image""" if size is None: size = self.defaultSize img = Image.new("RGB", size) return self._renderList(self._layers, Image.new("RGB", size))
[ "def", "render", "(", "self", ",", "size", "=", "None", ")", ":", "if", "size", "is", "None", ":", "size", "=", "self", ".", "defaultSize", "img", "=", "Image", ".", "new", "(", "\"RGB\"", ",", "size", ")", "return", "self", ".", "_renderList", "("...
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/Captcha/Visual/Base.py#L41-L46
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/Captcha/Visual/Text.py
python
FontFactory.pick
(self)
return (fileName, size)
Returns a (fileName, size) tuple that can be passed to ImageFont.truetype()
Returns a (fileName, size) tuple that can be passed to ImageFont.truetype()
[ "Returns", "a", "(", "fileName", "size", ")", "tuple", "that", "can", "be", "passed", "to", "ImageFont", ".", "truetype", "()" ]
def pick(self): """Returns a (fileName, size) tuple that can be passed to ImageFont.truetype()""" fileName = File.RandomFileFactory.pick(self) size = int(random.uniform(self.minSize, self.maxSize) + 0.5) return (fileName, size)
[ "def", "pick", "(", "self", ")", ":", "fileName", "=", "File", ".", "RandomFileFactory", ".", "pick", "(", "self", ")", "size", "=", "int", "(", "random", ".", "uniform", "(", "self", ".", "minSize", ",", "self", ".", "maxSize", ")", "+", "0.5", ")...
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/Captcha/Visual/Text.py#L34-L38
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/Captcha/Visual/Distortions.py
python
WarpBase.getTransform
(self, image)
return lambda x, y: (x, y)
Return a transformation function, subclasses should override this
Return a transformation function, subclasses should override this
[ "Return", "a", "transformation", "function", "subclasses", "should", "override", "this" ]
def getTransform(self, image): """Return a transformation function, subclasses should override this""" return lambda x, y: (x, y)
[ "def", "getTransform", "(", "self", ",", "image", ")", ":", "return", "lambda", "x", ",", "y", ":", "(", "x", ",", "y", ")" ]
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/Captcha/Visual/Distortions.py#L50-L52
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/setup/my_install_data.py
python
Data_Files.debug_print
(self, msg)
Print 'msg' to stdout if the global DEBUG (taken from the DISTUTILS_DEBUG environment variable) flag is true.
Print 'msg' to stdout if the global DEBUG (taken from the DISTUTILS_DEBUG environment variable) flag is true.
[ "Print", "msg", "to", "stdout", "if", "the", "global", "DEBUG", "(", "taken", "from", "the", "DISTUTILS_DEBUG", "environment", "variable", ")", "flag", "is", "true", "." ]
def debug_print (self, msg): """Print 'msg' to stdout if the global DEBUG (taken from the DISTUTILS_DEBUG environment variable) flag is true. """ from distutils.core import DEBUG if DEBUG: print msg
[ "def", "debug_print", "(", "self", ",", "msg", ")", ":", "from", "distutils", ".", "core", "import", "DEBUG", "if", "DEBUG", ":", "print", "msg" ]
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/setup/my_install_data.py#L72-L78
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/setup/my_install_data.py
python
Data_Files.finalize
(self)
complete the files list by processing the given template
complete the files list by processing the given template
[ "complete", "the", "files", "list", "by", "processing", "the", "given", "template" ]
def finalize(self): """ complete the files list by processing the given template """ if self.finalized: return if self.files == None: self.files = [] if self.template != None: if type(self.template) == StringType: self.template = string...
[ "def", "finalize", "(", "self", ")", ":", "if", "self", ".", "finalized", ":", "return", "if", "self", ".", "files", "==", "None", ":", "self", ".", "files", "=", "[", "]", "if", "self", ".", "template", "!=", "None", ":", "if", "type", "(", "sel...
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/setup/my_install_data.py#L81-L96
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/setup/my_install_data.py
python
my_install_data.check_data
(self,d)
return d
check if data are in new format, if not create a suitable object. returns finalized data object
check if data are in new format, if not create a suitable object. returns finalized data object
[ "check", "if", "data", "are", "in", "new", "format", "if", "not", "create", "a", "suitable", "object", ".", "returns", "finalized", "data", "object" ]
def check_data(self,d): """ check if data are in new format, if not create a suitable object. returns finalized data object """ if not isinstance(d, Data_Files): self.warn(("old-style data files list found " "-- please convert to Data_Files instanc...
[ "def", "check_data", "(", "self", ",", "d", ")", ":", "if", "not", "isinstance", "(", "d", ",", "Data_Files", ")", ":", "self", ".", "warn", "(", "(", "\"old-style data files list found \"", "\"-- please convert to Data_Files instance\"", ")", ")", "if", "type",...
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/setup/my_install_data.py#L105-L125
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/contrib/ezcaptcha.py
python
getChallenge
()
return key
Returns a string, which should be placed as a hidden field on a web form. This string identifies a particular challenge, and is needed later for: - retrieving the image file for viewing the challenge, via call to getImageData() - testing a response to the challenge, via call to testSol...
Returns a string, which should be placed as a hidden field on a web form. This string identifies a particular challenge, and is needed later for: - retrieving the image file for viewing the challenge, via call to getImageData() - testing a response to the challenge, via call to testSol...
[ "Returns", "a", "string", "which", "should", "be", "placed", "as", "a", "hidden", "field", "on", "a", "web", "form", ".", "This", "string", "identifies", "a", "particular", "challenge", "and", "is", "needed", "later", "for", ":", "-", "retrieving", "the", ...
def getChallenge(): """ Returns a string, which should be placed as a hidden field on a web form. This string identifies a particular challenge, and is needed later for: - retrieving the image file for viewing the challenge, via call to getImageData() - testing a response to th...
[ "def", "getChallenge", "(", ")", ":", "# get a CAPTCHA object", "g", "=", "PseudoGimpy", "(", ")", "# retrieve text solution", "answer", "=", "g", ".", "solutions", "[", "0", "]", "# generate a unique id under which to save it", "id", "=", "_generateId", "(", "answe...
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/contrib/ezcaptcha.py#L81-L120
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/contrib/ezcaptcha.py
python
testSolution
(key, guess)
Tests if guess is a correct solution
Tests if guess is a correct solution
[ "Tests", "if", "guess", "is", "a", "correct", "solution" ]
def testSolution(key, guess): """ Tests if guess is a correct solution """ try: id, expiry, sig = _decodeKey(key) # test for timeout if time.time() > expiry: # sorry, timed out, too late _delImage(id) return False # test for past usag...
[ "def", "testSolution", "(", "key", ",", "guess", ")", ":", "try", ":", "id", ",", "expiry", ",", "sig", "=", "_decodeKey", "(", "key", ")", "# test for timeout", "if", "time", ".", "time", "(", ")", ">", "expiry", ":", "# sorry, timed out, too late", "_d...
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/contrib/ezcaptcha.py#L126-L156
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/contrib/ezcaptcha.py
python
_encodeKey
(id, answer)
return key
Encodes the challenge ID and the answer into a string which is safe to give to a potentially hostile client The key is base64-encoding of 'id:expirytime:answer'
Encodes the challenge ID and the answer into a string which is safe to give to a potentially hostile client
[ "Encodes", "the", "challenge", "ID", "and", "the", "answer", "into", "a", "string", "which", "is", "safe", "to", "give", "to", "a", "potentially", "hostile", "client" ]
def _encodeKey(id, answer): """ Encodes the challenge ID and the answer into a string which is safe to give to a potentially hostile client The key is base64-encoding of 'id:expirytime:answer' """ expiryTime = int(time.time() + captchaTimeout) sig = _signChallenge(id, answer, expiryTime) ...
[ "def", "_encodeKey", "(", "id", ",", "answer", ")", ":", "expiryTime", "=", "int", "(", "time", ".", "time", "(", ")", "+", "captchaTimeout", ")", "sig", "=", "_signChallenge", "(", "id", ",", "answer", ",", "expiryTime", ")", "raw", "=", "\"%s:%x:%s\"...
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/contrib/ezcaptcha.py#L161-L172
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/contrib/ezcaptcha.py
python
_decodeKey
(key)
return id, expiry, sig
decodes a given key, returns id, expiry time and signature
decodes a given key, returns id, expiry time and signature
[ "decodes", "a", "given", "key", "returns", "id", "expiry", "time", "and", "signature" ]
def _decodeKey(key): """ decodes a given key, returns id, expiry time and signature """ raw = base64.decodestring(key) id, expiry, sig = raw.split(":", 2) expiry = int(expiry, 16) return id, expiry, sig
[ "def", "_decodeKey", "(", "key", ")", ":", "raw", "=", "base64", ".", "decodestring", "(", "key", ")", "id", ",", "expiry", ",", "sig", "=", "raw", ".", "split", "(", "\":\"", ",", "2", ")", "expiry", "=", "int", "(", "expiry", ",", "16", ")", ...
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/contrib/ezcaptcha.py#L174-L181
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/contrib/ezcaptcha.py
python
_generateId
(solution)
return sha.new( "%s%s%s" % ( captchaSecretKey, solution, random.random())).hexdigest()[:10]
returns a pseudo-random id under which picture gets stored
returns a pseudo-random id under which picture gets stored
[ "returns", "a", "pseudo", "-", "random", "id", "under", "which", "picture", "gets", "stored" ]
def _generateId(solution): """ returns a pseudo-random id under which picture gets stored """ return sha.new( "%s%s%s" % ( captchaSecretKey, solution, random.random())).hexdigest()[:10]
[ "def", "_generateId", "(", "solution", ")", ":", "return", "sha", ".", "new", "(", "\"%s%s%s\"", "%", "(", "captchaSecretKey", ",", "solution", ",", "random", ".", "random", "(", ")", ")", ")", ".", "hexdigest", "(", ")", "[", ":", "10", "]" ]
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/contrib/ezcaptcha.py#L187-L194
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/contrib/ezcaptcha.py
python
_delImage
(id)
deletes image from tmp dir, no longer wanted
deletes image from tmp dir, no longer wanted
[ "deletes", "image", "from", "tmp", "dir", "no", "longer", "wanted" ]
def _delImage(id): """ deletes image from tmp dir, no longer wanted """ try: imgPath = _getImagePath(id) if os.path.isfile(imgPath): os.unlink(imgPath) except: traceback.print_exc() pass
[ "def", "_delImage", "(", "id", ")", ":", "try", ":", "imgPath", "=", "_getImagePath", "(", "id", ")", "if", "os", ".", "path", ".", "isfile", "(", "imgPath", ")", ":", "os", ".", "unlink", "(", "imgPath", ")", "except", ":", "traceback", ".", "prin...
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/contrib/ezcaptcha.py#L199-L209
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/contrib/ezcaptcha.py
python
_demo
()
Presents a demo of this captcha module. If you run this file as a CGI in your web server, you'll see the demo in action
Presents a demo of this captcha module. If you run this file as a CGI in your web server, you'll see the demo in action
[ "Presents", "a", "demo", "of", "this", "captcha", "module", ".", "If", "you", "run", "this", "file", "as", "a", "CGI", "in", "your", "web", "server", "you", "ll", "see", "the", "demo", "in", "action" ]
def _demo(): """ Presents a demo of this captcha module. If you run this file as a CGI in your web server, you'll see the demo in action """ import cgi fields = cgi.FieldStorage() cmd = fields.getvalue("cmd", "") if not cmd: # first view key = getChallenge()...
[ "def", "_demo", "(", ")", ":", "import", "cgi", "fields", "=", "cgi", ".", "FieldStorage", "(", ")", "cmd", "=", "fields", ".", "getvalue", "(", "\"cmd\"", ",", "\"\"", ")", "if", "not", "cmd", ":", "# first view", "key", "=", "getChallenge", "(", ")...
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/contrib/ezcaptcha.py#L213-L301
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/build/lib/Captcha/Words.py
python
WordList.read
(self)
Read words from disk
Read words from disk
[ "Read", "words", "from", "disk" ]
def read(self): """Read words from disk""" f = open(os.path.join(File.dataDir, "words", self.fileName)) self.words = [] for line in f.xreadlines(): line = line.strip() if not line: continue if line[0] == '#': continue ...
[ "def", "read", "(", "self", ")", ":", "f", "=", "open", "(", "os", ".", "path", ".", "join", "(", "File", ".", "dataDir", ",", "\"words\"", ",", "self", ".", "fileName", ")", ")", "self", ".", "words", "=", "[", "]", "for", "line", "in", "f", ...
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/build/lib/Captcha/Words.py#L26-L42
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/build/lib/Captcha/Words.py
python
WordList.pick
(self)
return random.choice(self.words)
Pick a random word from the list, reading it in if necessary
Pick a random word from the list, reading it in if necessary
[ "Pick", "a", "random", "word", "from", "the", "list", "reading", "it", "in", "if", "necessary" ]
def pick(self): """Pick a random word from the list, reading it in if necessary""" if self.words is None: self.read() return random.choice(self.words)
[ "def", "pick", "(", "self", ")", ":", "if", "self", ".", "words", "is", "None", ":", "self", ".", "read", "(", ")", "return", "random", ".", "choice", "(", "self", ".", "words", ")" ]
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/build/lib/Captcha/Words.py#L44-L48
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/build/lib/Captcha/Base.py
python
BaseCaptcha.testSolutions
(self, solutions)
return numCorrect >= self.minCorrectSolutions and \ numIncorrect <= self.maxIncorrectSolutions
Test whether the given solutions are sufficient for this CAPTCHA. A given CAPTCHA can only be tested once, after that it is invalid and always returns False. This makes random guessing much less effective.
Test whether the given solutions are sufficient for this CAPTCHA. A given CAPTCHA can only be tested once, after that it is invalid and always returns False. This makes random guessing much less effective.
[ "Test", "whether", "the", "given", "solutions", "are", "sufficient", "for", "this", "CAPTCHA", ".", "A", "given", "CAPTCHA", "can", "only", "be", "tested", "once", "after", "that", "it", "is", "invalid", "and", "always", "returns", "False", ".", "This", "m...
def testSolutions(self, solutions): """Test whether the given solutions are sufficient for this CAPTCHA. A given CAPTCHA can only be tested once, after that it is invalid and always returns False. This makes random guessing much less effective. """ if not self.valid: ...
[ "def", "testSolutions", "(", "self", ",", "solutions", ")", ":", "if", "not", "self", ".", "valid", ":", "return", "False", "self", ".", "valid", "=", "False", "numCorrect", "=", "0", "numIncorrect", "=", "0", "for", "solution", "in", "solutions", ":", ...
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/build/lib/Captcha/Base.py#L45-L64
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/build/lib/Captcha/Base.py
python
Factory.new
(self, cls, *args, **kwargs)
return inst
Create a new instance of our assigned BaseCaptcha subclass, passing it any extra arguments we're given. This stores the result for later testing.
Create a new instance of our assigned BaseCaptcha subclass, passing it any extra arguments we're given. This stores the result for later testing.
[ "Create", "a", "new", "instance", "of", "our", "assigned", "BaseCaptcha", "subclass", "passing", "it", "any", "extra", "arguments", "we", "re", "given", ".", "This", "stores", "the", "result", "for", "later", "testing", "." ]
def new(self, cls, *args, **kwargs): """Create a new instance of our assigned BaseCaptcha subclass, passing it any extra arguments we're given. This stores the result for later testing. """ self.clean() inst = cls(*args, **kwargs) self.storedInstances[ins...
[ "def", "new", "(", "self", ",", "cls", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "clean", "(", ")", "inst", "=", "cls", "(", "*", "args", ",", "*", "*", "kwargs", ")", "self", ".", "storedInstances", "[", "inst", ".", ...
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/build/lib/Captcha/Base.py#L76-L84
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/build/lib/Captcha/Base.py
python
Factory.get
(self, id)
return self.storedInstances.get(id)
Retrieve the CAPTCHA with the given ID. If it's expired already, this will return None. A typical web application will need to new() a CAPTCHA when generating an html page, then get() it later when its images or sounds must be rendered.
Retrieve the CAPTCHA with the given ID. If it's expired already, this will return None. A typical web application will need to new() a CAPTCHA when generating an html page, then get() it later when its images or sounds must be rendered.
[ "Retrieve", "the", "CAPTCHA", "with", "the", "given", "ID", ".", "If", "it", "s", "expired", "already", "this", "will", "return", "None", ".", "A", "typical", "web", "application", "will", "need", "to", "new", "()", "a", "CAPTCHA", "when", "generating", ...
def get(self, id): """Retrieve the CAPTCHA with the given ID. If it's expired already, this will return None. A typical web application will need to new() a CAPTCHA when generating an html page, then get() it later when its images or sounds must be rendered. """ ...
[ "def", "get", "(", "self", ",", "id", ")", ":", "return", "self", ".", "storedInstances", ".", "get", "(", "id", ")" ]
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/build/lib/Captcha/Base.py#L86-L92
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/build/lib/Captcha/Base.py
python
Factory.clean
(self)
Removed expired tests
Removed expired tests
[ "Removed", "expired", "tests" ]
def clean(self): """Removed expired tests""" expiredIds = [] now = time.time() for inst in self.storedInstances.itervalues(): if inst.creationTime + self.lifetime < now: expiredIds.append(inst.id) for id in expiredIds: del self.storedInstan...
[ "def", "clean", "(", "self", ")", ":", "expiredIds", "=", "[", "]", "now", "=", "time", ".", "time", "(", ")", "for", "inst", "in", "self", ".", "storedInstances", ".", "itervalues", "(", ")", ":", "if", "inst", ".", "creationTime", "+", "self", "....
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/build/lib/Captcha/Base.py#L94-L102
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/build/lib/Captcha/Base.py
python
Factory.test
(self, id, solutions)
return result
Test the given list of solutions against the BaseCaptcha instance created earlier with the given id. Returns True if the test passed, False on failure. In either case, the test is invalidated. Returns False in the case of an invalid id.
Test the given list of solutions against the BaseCaptcha instance created earlier with the given id. Returns True if the test passed, False on failure. In either case, the test is invalidated. Returns False in the case of an invalid id.
[ "Test", "the", "given", "list", "of", "solutions", "against", "the", "BaseCaptcha", "instance", "created", "earlier", "with", "the", "given", "id", ".", "Returns", "True", "if", "the", "test", "passed", "False", "on", "failure", ".", "In", "either", "case", ...
def test(self, id, solutions): """Test the given list of solutions against the BaseCaptcha instance created earlier with the given id. Returns True if the test passed, False on failure. In either case, the test is invalidated. Returns False in the case of an invalid id. ...
[ "def", "test", "(", "self", ",", "id", ",", "solutions", ")", ":", "self", ".", "clean", "(", ")", "inst", "=", "self", ".", "storedInstances", ".", "get", "(", "id", ")", "if", "not", "inst", ":", "return", "False", "result", "=", "inst", ".", "...
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/build/lib/Captcha/Base.py#L104-L115
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/build/lib/Captcha/File.py
python
RandomFileFactory._checkExtension
(self, name)
return False
Check the file against our given list of extensions
Check the file against our given list of extensions
[ "Check", "the", "file", "against", "our", "given", "list", "of", "extensions" ]
def _checkExtension(self, name): """Check the file against our given list of extensions""" for ext in self.extensions: if name.endswith(ext): return True return False
[ "def", "_checkExtension", "(", "self", ",", "name", ")", ":", "for", "ext", "in", "self", ".", "extensions", ":", "if", "name", ".", "endswith", "(", "ext", ")", ":", "return", "True", "return", "False" ]
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/build/lib/Captcha/File.py#L28-L33
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/build/lib/Captcha/File.py
python
RandomFileFactory._findFullPaths
(self)
return paths
From our given file list, find a list of full paths to files
From our given file list, find a list of full paths to files
[ "From", "our", "given", "file", "list", "find", "a", "list", "of", "full", "paths", "to", "files" ]
def _findFullPaths(self): """From our given file list, find a list of full paths to files""" paths = [] for name in self.fileList: path = os.path.join(dataDir, self.basePath, name) if os.path.isdir(path): for content in os.listdir(path): ...
[ "def", "_findFullPaths", "(", "self", ")", ":", "paths", "=", "[", "]", "for", "name", "in", "self", ".", "fileList", ":", "path", "=", "os", ".", "path", ".", "join", "(", "dataDir", ",", "self", ".", "basePath", ",", "name", ")", "if", "os", "....
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/build/lib/Captcha/File.py#L35-L46
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/build/lib/Captcha/Visual/Base.py
python
ImageCaptcha.getImage
(self)
return self._image
Get a PIL image representing this CAPTCHA test, creating it if necessary
Get a PIL image representing this CAPTCHA test, creating it if necessary
[ "Get", "a", "PIL", "image", "representing", "this", "CAPTCHA", "test", "creating", "it", "if", "necessary" ]
def getImage(self): """Get a PIL image representing this CAPTCHA test, creating it if necessary""" if not self._image: self._image = self.render() return self._image
[ "def", "getImage", "(", "self", ")", ":", "if", "not", "self", ".", "_image", ":", "self", ".", "_image", "=", "self", ".", "render", "(", ")", "return", "self", ".", "_image" ]
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/build/lib/Captcha/Visual/Base.py#L29-L33
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/build/lib/Captcha/Visual/Base.py
python
ImageCaptcha.getLayers
(self)
return []
Subclasses must override this to return a list of Layer instances to render. Lists within the list of layers are recursively rendered.
Subclasses must override this to return a list of Layer instances to render. Lists within the list of layers are recursively rendered.
[ "Subclasses", "must", "override", "this", "to", "return", "a", "list", "of", "Layer", "instances", "to", "render", ".", "Lists", "within", "the", "list", "of", "layers", "are", "recursively", "rendered", "." ]
def getLayers(self): """Subclasses must override this to return a list of Layer instances to render. Lists within the list of layers are recursively rendered. """ return []
[ "def", "getLayers", "(", "self", ")", ":", "return", "[", "]" ]
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/build/lib/Captcha/Visual/Base.py#L35-L39
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/build/lib/Captcha/Visual/Base.py
python
ImageCaptcha.render
(self, size=None)
return self._renderList(self._layers, Image.new("RGB", size))
Render this CAPTCHA, returning a PIL image
Render this CAPTCHA, returning a PIL image
[ "Render", "this", "CAPTCHA", "returning", "a", "PIL", "image" ]
def render(self, size=None): """Render this CAPTCHA, returning a PIL image""" if size is None: size = self.defaultSize img = Image.new("RGB", size) return self._renderList(self._layers, Image.new("RGB", size))
[ "def", "render", "(", "self", ",", "size", "=", "None", ")", ":", "if", "size", "is", "None", ":", "size", "=", "self", ".", "defaultSize", "img", "=", "Image", ".", "new", "(", "\"RGB\"", ",", "size", ")", "return", "self", ".", "_renderList", "("...
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/build/lib/Captcha/Visual/Base.py#L41-L46
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/build/lib/Captcha/Visual/Text.py
python
FontFactory.pick
(self)
return (fileName, size)
Returns a (fileName, size) tuple that can be passed to ImageFont.truetype()
Returns a (fileName, size) tuple that can be passed to ImageFont.truetype()
[ "Returns", "a", "(", "fileName", "size", ")", "tuple", "that", "can", "be", "passed", "to", "ImageFont", ".", "truetype", "()" ]
def pick(self): """Returns a (fileName, size) tuple that can be passed to ImageFont.truetype()""" fileName = File.RandomFileFactory.pick(self) size = int(random.uniform(self.minSize, self.maxSize) + 0.5) return (fileName, size)
[ "def", "pick", "(", "self", ")", ":", "fileName", "=", "File", ".", "RandomFileFactory", ".", "pick", "(", "self", ")", "size", "=", "int", "(", "random", ".", "uniform", "(", "self", ".", "minSize", ",", "self", ".", "maxSize", ")", "+", "0.5", ")...
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/build/lib/Captcha/Visual/Text.py#L34-L38
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/build/lib/Captcha/Visual/Distortions.py
python
WarpBase.getTransform
(self, image)
return lambda x, y: (x, y)
Return a transformation function, subclasses should override this
Return a transformation function, subclasses should override this
[ "Return", "a", "transformation", "function", "subclasses", "should", "override", "this" ]
def getTransform(self, image): """Return a transformation function, subclasses should override this""" return lambda x, y: (x, y)
[ "def", "getTransform", "(", "self", ",", "image", ")", ":", "return", "lambda", "x", ",", "y", ":", "(", "x", ",", "y", ")" ]
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/build/lib/Captcha/Visual/Distortions.py#L50-L52
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/build/lib.linux-x86_64-2.7/Captcha/Words.py
python
WordList.read
(self)
Read words from disk
Read words from disk
[ "Read", "words", "from", "disk" ]
def read(self): """Read words from disk""" f = open(os.path.join(File.dataDir, "words", self.fileName)) self.words = [] for line in f.xreadlines(): line = line.strip() if not line: continue if line[0] == '#': continue ...
[ "def", "read", "(", "self", ")", ":", "f", "=", "open", "(", "os", ".", "path", ".", "join", "(", "File", ".", "dataDir", ",", "\"words\"", ",", "self", ".", "fileName", ")", ")", "self", ".", "words", "=", "[", "]", "for", "line", "in", "f", ...
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/build/lib.linux-x86_64-2.7/Captcha/Words.py#L26-L42
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/build/lib.linux-x86_64-2.7/Captcha/Words.py
python
WordList.pick
(self)
return random.choice(self.words)
Pick a random word from the list, reading it in if necessary
Pick a random word from the list, reading it in if necessary
[ "Pick", "a", "random", "word", "from", "the", "list", "reading", "it", "in", "if", "necessary" ]
def pick(self): """Pick a random word from the list, reading it in if necessary""" if self.words is None: self.read() return random.choice(self.words)
[ "def", "pick", "(", "self", ")", ":", "if", "self", ".", "words", "is", "None", ":", "self", ".", "read", "(", ")", "return", "random", ".", "choice", "(", "self", ".", "words", ")" ]
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/build/lib.linux-x86_64-2.7/Captcha/Words.py#L44-L48
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/build/lib.linux-x86_64-2.7/Captcha/Base.py
python
BaseCaptcha.testSolutions
(self, solutions)
return numCorrect >= self.minCorrectSolutions and \ numIncorrect <= self.maxIncorrectSolutions
Test whether the given solutions are sufficient for this CAPTCHA. A given CAPTCHA can only be tested once, after that it is invalid and always returns False. This makes random guessing much less effective.
Test whether the given solutions are sufficient for this CAPTCHA. A given CAPTCHA can only be tested once, after that it is invalid and always returns False. This makes random guessing much less effective.
[ "Test", "whether", "the", "given", "solutions", "are", "sufficient", "for", "this", "CAPTCHA", ".", "A", "given", "CAPTCHA", "can", "only", "be", "tested", "once", "after", "that", "it", "is", "invalid", "and", "always", "returns", "False", ".", "This", "m...
def testSolutions(self, solutions): """Test whether the given solutions are sufficient for this CAPTCHA. A given CAPTCHA can only be tested once, after that it is invalid and always returns False. This makes random guessing much less effective. """ if not self.valid: ...
[ "def", "testSolutions", "(", "self", ",", "solutions", ")", ":", "if", "not", "self", ".", "valid", ":", "return", "False", "self", ".", "valid", "=", "False", "numCorrect", "=", "0", "numIncorrect", "=", "0", "for", "solution", "in", "solutions", ":", ...
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/build/lib.linux-x86_64-2.7/Captcha/Base.py#L45-L64
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/build/lib.linux-x86_64-2.7/Captcha/Base.py
python
Factory.new
(self, cls, *args, **kwargs)
return inst
Create a new instance of our assigned BaseCaptcha subclass, passing it any extra arguments we're given. This stores the result for later testing.
Create a new instance of our assigned BaseCaptcha subclass, passing it any extra arguments we're given. This stores the result for later testing.
[ "Create", "a", "new", "instance", "of", "our", "assigned", "BaseCaptcha", "subclass", "passing", "it", "any", "extra", "arguments", "we", "re", "given", ".", "This", "stores", "the", "result", "for", "later", "testing", "." ]
def new(self, cls, *args, **kwargs): """Create a new instance of our assigned BaseCaptcha subclass, passing it any extra arguments we're given. This stores the result for later testing. """ self.clean() inst = cls(*args, **kwargs) self.storedInstances[ins...
[ "def", "new", "(", "self", ",", "cls", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "clean", "(", ")", "inst", "=", "cls", "(", "*", "args", ",", "*", "*", "kwargs", ")", "self", ".", "storedInstances", "[", "inst", ".", ...
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/build/lib.linux-x86_64-2.7/Captcha/Base.py#L76-L84
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/build/lib.linux-x86_64-2.7/Captcha/Base.py
python
Factory.get
(self, id)
return self.storedInstances.get(id)
Retrieve the CAPTCHA with the given ID. If it's expired already, this will return None. A typical web application will need to new() a CAPTCHA when generating an html page, then get() it later when its images or sounds must be rendered.
Retrieve the CAPTCHA with the given ID. If it's expired already, this will return None. A typical web application will need to new() a CAPTCHA when generating an html page, then get() it later when its images or sounds must be rendered.
[ "Retrieve", "the", "CAPTCHA", "with", "the", "given", "ID", ".", "If", "it", "s", "expired", "already", "this", "will", "return", "None", ".", "A", "typical", "web", "application", "will", "need", "to", "new", "()", "a", "CAPTCHA", "when", "generating", ...
def get(self, id): """Retrieve the CAPTCHA with the given ID. If it's expired already, this will return None. A typical web application will need to new() a CAPTCHA when generating an html page, then get() it later when its images or sounds must be rendered. """ ...
[ "def", "get", "(", "self", ",", "id", ")", ":", "return", "self", ".", "storedInstances", ".", "get", "(", "id", ")" ]
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/build/lib.linux-x86_64-2.7/Captcha/Base.py#L86-L92
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/build/lib.linux-x86_64-2.7/Captcha/Base.py
python
Factory.clean
(self)
Removed expired tests
Removed expired tests
[ "Removed", "expired", "tests" ]
def clean(self): """Removed expired tests""" expiredIds = [] now = time.time() for inst in self.storedInstances.itervalues(): if inst.creationTime + self.lifetime < now: expiredIds.append(inst.id) for id in expiredIds: del self.storedInstan...
[ "def", "clean", "(", "self", ")", ":", "expiredIds", "=", "[", "]", "now", "=", "time", ".", "time", "(", ")", "for", "inst", "in", "self", ".", "storedInstances", ".", "itervalues", "(", ")", ":", "if", "inst", ".", "creationTime", "+", "self", "....
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/build/lib.linux-x86_64-2.7/Captcha/Base.py#L94-L102
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/build/lib.linux-x86_64-2.7/Captcha/Base.py
python
Factory.test
(self, id, solutions)
return result
Test the given list of solutions against the BaseCaptcha instance created earlier with the given id. Returns True if the test passed, False on failure. In either case, the test is invalidated. Returns False in the case of an invalid id.
Test the given list of solutions against the BaseCaptcha instance created earlier with the given id. Returns True if the test passed, False on failure. In either case, the test is invalidated. Returns False in the case of an invalid id.
[ "Test", "the", "given", "list", "of", "solutions", "against", "the", "BaseCaptcha", "instance", "created", "earlier", "with", "the", "given", "id", ".", "Returns", "True", "if", "the", "test", "passed", "False", "on", "failure", ".", "In", "either", "case", ...
def test(self, id, solutions): """Test the given list of solutions against the BaseCaptcha instance created earlier with the given id. Returns True if the test passed, False on failure. In either case, the test is invalidated. Returns False in the case of an invalid id. ...
[ "def", "test", "(", "self", ",", "id", ",", "solutions", ")", ":", "self", ".", "clean", "(", ")", "inst", "=", "self", ".", "storedInstances", ".", "get", "(", "id", ")", "if", "not", "inst", ":", "return", "False", "result", "=", "inst", ".", "...
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/build/lib.linux-x86_64-2.7/Captcha/Base.py#L104-L115
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/build/lib.linux-x86_64-2.7/Captcha/File.py
python
RandomFileFactory._checkExtension
(self, name)
return False
Check the file against our given list of extensions
Check the file against our given list of extensions
[ "Check", "the", "file", "against", "our", "given", "list", "of", "extensions" ]
def _checkExtension(self, name): """Check the file against our given list of extensions""" for ext in self.extensions: if name.endswith(ext): return True return False
[ "def", "_checkExtension", "(", "self", ",", "name", ")", ":", "for", "ext", "in", "self", ".", "extensions", ":", "if", "name", ".", "endswith", "(", "ext", ")", ":", "return", "True", "return", "False" ]
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/build/lib.linux-x86_64-2.7/Captcha/File.py#L28-L33
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/build/lib.linux-x86_64-2.7/Captcha/File.py
python
RandomFileFactory._findFullPaths
(self)
return paths
From our given file list, find a list of full paths to files
From our given file list, find a list of full paths to files
[ "From", "our", "given", "file", "list", "find", "a", "list", "of", "full", "paths", "to", "files" ]
def _findFullPaths(self): """From our given file list, find a list of full paths to files""" paths = [] for name in self.fileList: path = os.path.join(dataDir, self.basePath, name) if os.path.isdir(path): for content in os.listdir(path): ...
[ "def", "_findFullPaths", "(", "self", ")", ":", "paths", "=", "[", "]", "for", "name", "in", "self", ".", "fileList", ":", "path", "=", "os", ".", "path", ".", "join", "(", "dataDir", ",", "self", ".", "basePath", ",", "name", ")", "if", "os", "....
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/build/lib.linux-x86_64-2.7/Captcha/File.py#L35-L46
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/build/lib.linux-x86_64-2.7/Captcha/Visual/Base.py
python
ImageCaptcha.getImage
(self)
return self._image
Get a PIL image representing this CAPTCHA test, creating it if necessary
Get a PIL image representing this CAPTCHA test, creating it if necessary
[ "Get", "a", "PIL", "image", "representing", "this", "CAPTCHA", "test", "creating", "it", "if", "necessary" ]
def getImage(self): """Get a PIL image representing this CAPTCHA test, creating it if necessary""" if not self._image: self._image = self.render() return self._image
[ "def", "getImage", "(", "self", ")", ":", "if", "not", "self", ".", "_image", ":", "self", ".", "_image", "=", "self", ".", "render", "(", ")", "return", "self", ".", "_image" ]
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/build/lib.linux-x86_64-2.7/Captcha/Visual/Base.py#L29-L33
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/build/lib.linux-x86_64-2.7/Captcha/Visual/Base.py
python
ImageCaptcha.getLayers
(self)
return []
Subclasses must override this to return a list of Layer instances to render. Lists within the list of layers are recursively rendered.
Subclasses must override this to return a list of Layer instances to render. Lists within the list of layers are recursively rendered.
[ "Subclasses", "must", "override", "this", "to", "return", "a", "list", "of", "Layer", "instances", "to", "render", ".", "Lists", "within", "the", "list", "of", "layers", "are", "recursively", "rendered", "." ]
def getLayers(self): """Subclasses must override this to return a list of Layer instances to render. Lists within the list of layers are recursively rendered. """ return []
[ "def", "getLayers", "(", "self", ")", ":", "return", "[", "]" ]
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/build/lib.linux-x86_64-2.7/Captcha/Visual/Base.py#L35-L39
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/build/lib.linux-x86_64-2.7/Captcha/Visual/Base.py
python
ImageCaptcha.render
(self, size=None)
return self._renderList(self._layers, Image.new("RGB", size))
Render this CAPTCHA, returning a PIL image
Render this CAPTCHA, returning a PIL image
[ "Render", "this", "CAPTCHA", "returning", "a", "PIL", "image" ]
def render(self, size=None): """Render this CAPTCHA, returning a PIL image""" if size is None: size = self.defaultSize img = Image.new("RGB", size) return self._renderList(self._layers, Image.new("RGB", size))
[ "def", "render", "(", "self", ",", "size", "=", "None", ")", ":", "if", "size", "is", "None", ":", "size", "=", "self", ".", "defaultSize", "img", "=", "Image", ".", "new", "(", "\"RGB\"", ",", "size", ")", "return", "self", ".", "_renderList", "("...
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/build/lib.linux-x86_64-2.7/Captcha/Visual/Base.py#L41-L46
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/build/lib.linux-x86_64-2.7/Captcha/Visual/Text.py
python
FontFactory.pick
(self)
return (fileName, size)
Returns a (fileName, size) tuple that can be passed to ImageFont.truetype()
Returns a (fileName, size) tuple that can be passed to ImageFont.truetype()
[ "Returns", "a", "(", "fileName", "size", ")", "tuple", "that", "can", "be", "passed", "to", "ImageFont", ".", "truetype", "()" ]
def pick(self): """Returns a (fileName, size) tuple that can be passed to ImageFont.truetype()""" fileName = File.RandomFileFactory.pick(self) size = int(random.uniform(self.minSize, self.maxSize) + 0.5) return (fileName, size)
[ "def", "pick", "(", "self", ")", ":", "fileName", "=", "File", ".", "RandomFileFactory", ".", "pick", "(", "self", ")", "size", "=", "int", "(", "random", ".", "uniform", "(", "self", ".", "minSize", ",", "self", ".", "maxSize", ")", "+", "0.5", ")...
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/build/lib.linux-x86_64-2.7/Captcha/Visual/Text.py#L34-L38
00nanhai/captchacker2
7609141b51ff0cf3329608b8101df967cb74752f
pycaptcha/build/lib.linux-x86_64-2.7/Captcha/Visual/Distortions.py
python
WarpBase.getTransform
(self, image)
return lambda x, y: (x, y)
Return a transformation function, subclasses should override this
Return a transformation function, subclasses should override this
[ "Return", "a", "transformation", "function", "subclasses", "should", "override", "this" ]
def getTransform(self, image): """Return a transformation function, subclasses should override this""" return lambda x, y: (x, y)
[ "def", "getTransform", "(", "self", ",", "image", ")", ":", "return", "lambda", "x", ",", "y", ":", "(", "x", ",", "y", ")" ]
https://github.com/00nanhai/captchacker2/blob/7609141b51ff0cf3329608b8101df967cb74752f/pycaptcha/build/lib.linux-x86_64-2.7/Captcha/Visual/Distortions.py#L50-L52
12dmodel/deep_motion_mag
485243bd7428d08059c313321b5e6ebfd7f61991
preprocessor.py
python
get_possion_noise
(image)
return tf.multiply(n, n_str)
Add poisson noise. This function approximate posson noise upto 2nd order. Assume images were in 0-255, and converted to the range of -1 to 1.
Add poisson noise.
[ "Add", "poisson", "noise", "." ]
def get_possion_noise(image): """Add poisson noise. This function approximate posson noise upto 2nd order. Assume images were in 0-255, and converted to the range of -1 to 1. """ n = tf.random_normal(shape=tf.shape(image), mean=0.0, stddev=1.0) # strength ~ sqrt image value in 255, divided by 1...
[ "def", "get_possion_noise", "(", "image", ")", ":", "n", "=", "tf", ".", "random_normal", "(", "shape", "=", "tf", ".", "shape", "(", "image", ")", ",", "mean", "=", "0.0", ",", "stddev", "=", "1.0", ")", "# strength ~ sqrt image value in 255, divided by 127...
https://github.com/12dmodel/deep_motion_mag/blob/485243bd7428d08059c313321b5e6ebfd7f61991/preprocessor.py#L16-L26
12dmodel/deep_motion_mag
485243bd7428d08059c313321b5e6ebfd7f61991
ops.py
python
expand_dims_1_to_4
(tensor, dims=None)
return tf.expand_dims( tf.expand_dims( tf.expand_dims(tensor, dims[0]), dims[1]), dims[2])
Expand dimension from 1 to 4. Useful for multiplying amplification factor.
Expand dimension from 1 to 4.
[ "Expand", "dimension", "from", "1", "to", "4", "." ]
def expand_dims_1_to_4(tensor, dims=None): """Expand dimension from 1 to 4. Useful for multiplying amplification factor. """ if not dims: dims = [-1, -1, -1] return tf.expand_dims( tf.expand_dims( tf.expand_dims(tensor, dims[0]), dims[1]), ...
[ "def", "expand_dims_1_to_4", "(", "tensor", ",", "dims", "=", "None", ")", ":", "if", "not", "dims", ":", "dims", "=", "[", "-", "1", ",", "-", "1", ",", "-", "1", "]", "return", "tf", ".", "expand_dims", "(", "tf", ".", "expand_dims", "(", "tf",...
https://github.com/12dmodel/deep_motion_mag/blob/485243bd7428d08059c313321b5e6ebfd7f61991/ops.py#L77-L88
12dmodel/deep_motion_mag
485243bd7428d08059c313321b5e6ebfd7f61991
magnet.py
python
MagNet3Frames.setup_for_inference
(self, checkpoint_dir, image_width, image_height)
Setup model for inference. Build computation graph, initialize variables, and load checkpoint.
Setup model for inference.
[ "Setup", "model", "for", "inference", "." ]
def setup_for_inference(self, checkpoint_dir, image_width, image_height): """Setup model for inference. Build computation graph, initialize variables, and load checkpoint. """ self.image_width = image_width self.image_height = image_height # Figure out image dimension ...
[ "def", "setup_for_inference", "(", "self", ",", "checkpoint_dir", ",", "image_width", ",", "image_height", ")", ":", "self", ".", "image_width", "=", "image_width", "self", ".", "image_height", "=", "image_height", "# Figure out image dimension", "self", ".", "_buil...
https://github.com/12dmodel/deep_motion_mag/blob/485243bd7428d08059c313321b5e6ebfd7f61991/magnet.py#L198-L215
12dmodel/deep_motion_mag
485243bd7428d08059c313321b5e6ebfd7f61991
magnet.py
python
MagNet3Frames.inference
(self, frameA, frameB, amplification_factor)
return out_amp
Run Magnification on two frames. Args: frameA: path to first frame frameB: path to second frame amplification_factor: float for amplification factor
Run Magnification on two frames.
[ "Run", "Magnification", "on", "two", "frames", "." ]
def inference(self, frameA, frameB, amplification_factor): """Run Magnification on two frames. Args: frameA: path to first frame frameB: path to second frame amplification_factor: float for amplification factor """ in_frames = [load_train_data([frameA...
[ "def", "inference", "(", "self", ",", "frameA", ",", "frameB", ",", "amplification_factor", ")", ":", "in_frames", "=", "[", "load_train_data", "(", "[", "frameA", ",", "frameB", ",", "frameB", "]", ",", "gray_scale", "=", "self", ".", "n_channels", "==", ...
https://github.com/12dmodel/deep_motion_mag/blob/485243bd7428d08059c313321b5e6ebfd7f61991/magnet.py#L217-L233
12dmodel/deep_motion_mag
485243bd7428d08059c313321b5e6ebfd7f61991
magnet.py
python
MagNet3Frames.run
(self, checkpoint_dir, vid_dir, frame_ext, out_dir, amplification_factor, velocity_mag=False)
Magnify a video in the two-frames mode. Args: checkpoint_dir: checkpoint directory. vid_dir: directory containing video frames videos are processed in sorted order. out_dir: directory to place output frames and resulting video. amplification_facto...
Magnify a video in the two-frames mode.
[ "Magnify", "a", "video", "in", "the", "two", "-", "frames", "mode", "." ]
def run(self, checkpoint_dir, vid_dir, frame_ext, out_dir, amplification_factor, velocity_mag=False): """Magnify a video in the two-frames mode. Args: checkpoint_dir: checkpoint directory. vid_dir: directory...
[ "def", "run", "(", "self", ",", "checkpoint_dir", ",", "vid_dir", ",", "frame_ext", ",", "out_dir", ",", "amplification_factor", ",", "velocity_mag", "=", "False", ")", ":", "vid_name", "=", "os", ".", "path", ".", "basename", "(", "out_dir", ")", "# make ...
https://github.com/12dmodel/deep_motion_mag/blob/485243bd7428d08059c313321b5e6ebfd7f61991/magnet.py#L235-L286
12dmodel/deep_motion_mag
485243bd7428d08059c313321b5e6ebfd7f61991
magnet.py
python
MagNet3Frames._build_IIR_filtering_graphs
(self)
Assume a_0 = 1
Assume a_0 = 1
[ "Assume", "a_0", "=", "1" ]
def _build_IIR_filtering_graphs(self): """ Assume a_0 = 1 """ self.input_image = tf.placeholder(tf.float32, [1, self.image_height, self.image_width, self.n_c...
[ "def", "_build_IIR_filtering_graphs", "(", "self", ")", ":", "self", ".", "input_image", "=", "tf", ".", "placeholder", "(", "tf", ".", "float32", ",", "[", "1", ",", "self", ".", "image_height", ",", "self", ".", "image_width", ",", "self", ".", "n_chan...
https://github.com/12dmodel/deep_motion_mag/blob/485243bd7428d08059c313321b5e6ebfd7f61991/magnet.py#L289-L329
12dmodel/deep_motion_mag
485243bd7428d08059c313321b5e6ebfd7f61991
magnet.py
python
MagNet3Frames.run_temporal
(self, checkpoint_dir, vid_dir, frame_ext, out_dir, amplification_factor, fl, fh, fs, n_filter_tap, filter_type)
Magnify video with a temporal filter. Args: checkpoint_dir: checkpoint directory. vid_dir: directory containing video frames videos are processed in sorted order. out_dir: directory to place output frames and resulting video. amplification_factor:...
Magnify video with a temporal filter.
[ "Magnify", "video", "with", "a", "temporal", "filter", "." ]
def run_temporal(self, checkpoint_dir, vid_dir, frame_ext, out_dir, amplification_factor, fl, fh, fs, n_filter_tap, filter_type): """Magnify vid...
[ "def", "run_temporal", "(", "self", ",", "checkpoint_dir", ",", "vid_dir", ",", "frame_ext", ",", "out_dir", ",", "amplification_factor", ",", "fl", ",", "fh", ",", "fs", ",", "n_filter_tap", ",", "filter_type", ")", ":", "nyq", "=", "fs", "/", "2.0", "i...
https://github.com/12dmodel/deep_motion_mag/blob/485243bd7428d08059c313321b5e6ebfd7f61991/magnet.py#L331-L512
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
siteinfo.py
python
SiteFacade.__init__
(self, verbose)
Class constructor. Simply creates a blank list and assigns it to instance variable _sites that will be filled with retrieved info from sites defined in the xml configuration file. Argument(s): No arguments are required. Return value(s): Nothing is returned from this Met...
Class constructor. Simply creates a blank list and assigns it to instance variable _sites that will be filled with retrieved info from sites defined in the xml configuration file.
[ "Class", "constructor", ".", "Simply", "creates", "a", "blank", "list", "and", "assigns", "it", "to", "instance", "variable", "_sites", "that", "will", "be", "filled", "with", "retrieved", "info", "from", "sites", "defined", "in", "the", "xml", "configuration"...
def __init__(self, verbose): """ Class constructor. Simply creates a blank list and assigns it to instance variable _sites that will be filled with retrieved info from sites defined in the xml configuration file. Argument(s): No arguments are required. Return va...
[ "def", "__init__", "(", "self", ",", "verbose", ")", ":", "self", ".", "_sites", "=", "[", "]", "self", ".", "_verbose", "=", "verbose" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/siteinfo.py#L57-L71
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
siteinfo.py
python
SiteFacade.runSiteAutomation
(self, webretrievedelay, proxy, targetlist, sourcelist, useragent, botoutputrequested, refreshremotexml, versionlocation)
Builds site objects representative of each site listed in the xml config file. Appends a Site object or one of it's subordinate objects to the _sites instance variable so retrieved information can be used. Returns nothing. Argument(s): webretrievedelay -- The amount of seconds t...
Builds site objects representative of each site listed in the xml config file. Appends a Site object or one of it's subordinate objects to the _sites instance variable so retrieved information can be used. Returns nothing.
[ "Builds", "site", "objects", "representative", "of", "each", "site", "listed", "in", "the", "xml", "config", "file", ".", "Appends", "a", "Site", "object", "or", "one", "of", "it", "s", "subordinate", "objects", "to", "the", "_sites", "instance", "variable",...
def runSiteAutomation(self, webretrievedelay, proxy, targetlist, sourcelist, useragent, botoutputrequested, refreshremotexml, versionlocation): """ Builds site objects representative of each site listed in the xml config file. Appends a Site object or one of it's subord...
[ "def", "runSiteAutomation", "(", "self", ",", "webretrievedelay", ",", "proxy", ",", "targetlist", ",", "sourcelist", ",", "useragent", ",", "botoutputrequested", ",", "refreshremotexml", ",", "versionlocation", ")", ":", "if", "refreshremotexml", ":", "SitesFile", ...
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/siteinfo.py#L73-L140
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
siteinfo.py
python
SiteFacade.Sites
(self)
return self._sites
Checks the instance variable _sites is empty or None. Returns _sites (the site list) or None if it is empty. Argument(s): No arguments are required. Return value(s): list -- of Site objects or its subordinates. None -- if _sites is empty or None. Restriction(s)...
Checks the instance variable _sites is empty or None. Returns _sites (the site list) or None if it is empty.
[ "Checks", "the", "instance", "variable", "_sites", "is", "empty", "or", "None", ".", "Returns", "_sites", "(", "the", "site", "list", ")", "or", "None", "if", "it", "is", "empty", "." ]
def Sites(self): """ Checks the instance variable _sites is empty or None. Returns _sites (the site list) or None if it is empty. Argument(s): No arguments are required. Return value(s): list -- of Site objects or its subordinates. None -- if _sites is e...
[ "def", "Sites", "(", "self", ")", ":", "if", "self", ".", "_sites", "is", "None", "or", "len", "(", "self", ".", "_sites", ")", "==", "0", ":", "return", "None", "return", "self", ".", "_sites" ]
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/siteinfo.py#L172-L189
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
siteinfo.py
python
SiteFacade.identifyTargetType
(self, target)
return "hostname"
Checks the target information provided to determine if it is a(n) IP Address in standard; CIDR or dash notation, or an MD5 hash, or a string hostname. Returns a string md5 if MD5 hash is identified. Returns the string ip if any IP Address format is found. Returns the string hostname ...
Checks the target information provided to determine if it is a(n) IP Address in standard; CIDR or dash notation, or an MD5 hash, or a string hostname. Returns a string md5 if MD5 hash is identified. Returns the string ip if any IP Address format is found. Returns the string hostname ...
[ "Checks", "the", "target", "information", "provided", "to", "determine", "if", "it", "is", "a", "(", "n", ")", "IP", "Address", "in", "standard", ";", "CIDR", "or", "dash", "notation", "or", "an", "MD5", "hash", "or", "a", "string", "hostname", ".", "R...
def identifyTargetType(self, target): """ Checks the target information provided to determine if it is a(n) IP Address in standard; CIDR or dash notation, or an MD5 hash, or a string hostname. Returns a string md5 if MD5 hash is identified. Returns the string ip if any IP...
[ "def", "identifyTargetType", "(", "self", ",", "target", ")", ":", "ipAddress", "=", "re", ".", "compile", "(", "'\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}'", ")", "ipFind", "=", "re", ".", "findall", "(", "ipAddress", ",", "target", ")", "if", "ipFind", "is",...
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/siteinfo.py#L191-L220
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
siteinfo.py
python
Site.__init__
(self, domainurl, webretrievedelay, proxy, targettype, reportstringforresult, target, useragent, friendlyname, regex, fullurl, boutoutputrequested, importantproperty, params, headers, method, postdata, verbose)
Class constructor. Sets the instance variables based on input from the arguments supplied when Automater is run and what the xml config file stores. Argument(s): domainurl -- string defined in xml in the domainurl XML tag. webretrievedelay -- the amount of seconds to wait betwee...
Class constructor. Sets the instance variables based on input from the arguments supplied when Automater is run and what the xml config file stores.
[ "Class", "constructor", ".", "Sets", "the", "instance", "variables", "based", "on", "input", "from", "the", "arguments", "supplied", "when", "Automater", "is", "run", "and", "what", "the", "xml", "config", "file", "stores", "." ]
def __init__(self, domainurl, webretrievedelay, proxy, targettype, reportstringforresult, target, useragent, friendlyname, regex, fullurl, boutoutputrequested, importantproperty, params, headers, method, postdata, verbose): """ Class constructor. Sets the instance varia...
[ "def", "__init__", "(", "self", ",", "domainurl", ",", "webretrievedelay", ",", "proxy", ",", "targettype", ",", "reportstringforresult", ",", "target", ",", "useragent", ",", "friendlyname", ",", "regex", ",", "fullurl", ",", "boutoutputrequested", ",", "import...
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/siteinfo.py#L282-L353
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
siteinfo.py
python
Site.buildSiteFromXML
(self, siteelement, webretrievedelay, proxy, targettype, target, useragent, botoutputrequested, verbose)
return Site(domainurl, webretrievedelay, proxy, targettype, reportstringforresult, target, useragent, sitefriendlyname, regex, fullurl, botoutputrequested, importantproperty, params, headers, method.upper(), postdata, verbose)
Utilizes the Class Methods within this Class to build the Site object. Returns a Site object that defines results returned during the web retrieval investigations. Argument(s): siteelement -- the siteelement object that will be used as the start element. webretrievedelay...
Utilizes the Class Methods within this Class to build the Site object. Returns a Site object that defines results returned during the web retrieval investigations.
[ "Utilizes", "the", "Class", "Methods", "within", "this", "Class", "to", "build", "the", "Site", "object", ".", "Returns", "a", "Site", "object", "that", "defines", "results", "returned", "during", "the", "web", "retrieval", "investigations", "." ]
def buildSiteFromXML(self, siteelement, webretrievedelay, proxy, targettype, target, useragent, botoutputrequested, verbose): """ Utilizes the Class Methods within this Class to build the Site object. Returns a Site object that defines results returned during the web ...
[ "def", "buildSiteFromXML", "(", "self", ",", "siteelement", ",", "webretrievedelay", ",", "proxy", ",", "targettype", ",", "target", ",", "useragent", ",", "botoutputrequested", ",", "verbose", ")", ":", "domainurl", "=", "siteelement", ".", "find", "(", "\"do...
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/siteinfo.py#L367-L411
1aN0rmus/TekDefense-Automater
42548cf454e862669c0a482955358fe27f7150e8
siteinfo.py
python
Site.buildStringOrListfromXML
(self, siteelement, elementstring)
return variablename
Takes in a siteelement and then elementstring and builds a string or list from multiple entry XML tags defined in the xml config file. Returns None if there are no entry XML tags for this specific elementstring. Returns a list of those entries if entry XML tags are found or a string of t...
Takes in a siteelement and then elementstring and builds a string or list from multiple entry XML tags defined in the xml config file. Returns None if there are no entry XML tags for this specific elementstring. Returns a list of those entries if entry XML tags are found or a string of t...
[ "Takes", "in", "a", "siteelement", "and", "then", "elementstring", "and", "builds", "a", "string", "or", "list", "from", "multiple", "entry", "XML", "tags", "defined", "in", "the", "xml", "config", "file", ".", "Returns", "None", "if", "there", "are", "no"...
def buildStringOrListfromXML(self, siteelement, elementstring): """ Takes in a siteelement and then elementstring and builds a string or list from multiple entry XML tags defined in the xml config file. Returns None if there are no entry XML tags for this specific elementstring. ...
[ "def", "buildStringOrListfromXML", "(", "self", ",", "siteelement", ",", "elementstring", ")", ":", "variablename", "=", "\"\"", "if", "len", "(", "siteelement", ".", "find", "(", "elementstring", ")", ".", "findall", "(", "\"entry\"", ")", ")", "==", "0", ...
https://github.com/1aN0rmus/TekDefense-Automater/blob/42548cf454e862669c0a482955358fe27f7150e8/siteinfo.py#L414-L450
End of preview. Expand in Data Studio

No dataset card yet

Downloads last month
10