id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
48,800
openpaperwork/paperwork-backend
paperwork_backend/labels.py
LabelGuesser.rename
def rename(self, old_label_name, new_label_name): """ Take into account that a label has been renamed """ assert(old_label_name != new_label_name) self._bayes.pop(old_label_name) old_baye_dir = self._get_baye_dir(old_label_name) new_baye_dir = self._get_baye_dir(n...
python
def rename(self, old_label_name, new_label_name): """ Take into account that a label has been renamed """ assert(old_label_name != new_label_name) self._bayes.pop(old_label_name) old_baye_dir = self._get_baye_dir(old_label_name) new_baye_dir = self._get_baye_dir(n...
[ "def", "rename", "(", "self", ",", "old_label_name", ",", "new_label_name", ")", ":", "assert", "(", "old_label_name", "!=", "new_label_name", ")", "self", ".", "_bayes", ".", "pop", "(", "old_label_name", ")", "old_baye_dir", "=", "self", ".", "_get_baye_dir"...
Take into account that a label has been renamed
[ "Take", "into", "account", "that", "a", "label", "has", "been", "renamed" ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/labels.py#L292-L303
48,801
openpaperwork/paperwork-backend
paperwork_backend/common/page.py
BasicPage._get_filepath
def _get_filepath(self, ext): """ Returns a file path relative to this page """ filename = ("%s%d.%s" % (self.FILE_PREFIX, self.page_nb + 1, ext)) return self.fs.join(self.doc.path, filename)
python
def _get_filepath(self, ext): """ Returns a file path relative to this page """ filename = ("%s%d.%s" % (self.FILE_PREFIX, self.page_nb + 1, ext)) return self.fs.join(self.doc.path, filename)
[ "def", "_get_filepath", "(", "self", ",", "ext", ")", ":", "filename", "=", "(", "\"%s%d.%s\"", "%", "(", "self", ".", "FILE_PREFIX", ",", "self", ".", "page_nb", "+", "1", ",", "ext", ")", ")", "return", "self", ".", "fs", ".", "join", "(", "self"...
Returns a file path relative to this page
[ "Returns", "a", "file", "path", "relative", "to", "this", "page" ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/common/page.py#L166-L171
48,802
openpaperwork/paperwork-backend
paperwork_backend/common/page.py
BasicPage.__make_thumbnail
def __make_thumbnail(self, width, height): """ Create the page's thumbnail """ (w, h) = self.size factor = max( (float(w) / width), (float(h) / height) ) w /= factor h /= factor return self.get_image((round(w), round(h)))
python
def __make_thumbnail(self, width, height): """ Create the page's thumbnail """ (w, h) = self.size factor = max( (float(w) / width), (float(h) / height) ) w /= factor h /= factor return self.get_image((round(w), round(h)))
[ "def", "__make_thumbnail", "(", "self", ",", "width", ",", "height", ")", ":", "(", "w", ",", "h", ")", "=", "self", ".", "size", "factor", "=", "max", "(", "(", "float", "(", "w", ")", "/", "width", ")", ",", "(", "float", "(", "h", ")", "/"...
Create the page's thumbnail
[ "Create", "the", "page", "s", "thumbnail" ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/common/page.py#L173-L184
48,803
openpaperwork/paperwork-backend
paperwork_backend/common/page.py
BasicPage.get_thumbnail
def get_thumbnail(self, width, height): """ thumbnail with a memory cache """ # get from the file thumb_path = self._get_thumb_path() try: doc_file_path = self.get_doc_file_path() if (self.fs.exists(thumb_path) and self.fs.getm...
python
def get_thumbnail(self, width, height): """ thumbnail with a memory cache """ # get from the file thumb_path = self._get_thumb_path() try: doc_file_path = self.get_doc_file_path() if (self.fs.exists(thumb_path) and self.fs.getm...
[ "def", "get_thumbnail", "(", "self", ",", "width", ",", "height", ")", ":", "# get from the file", "thumb_path", "=", "self", ".", "_get_thumb_path", "(", ")", "try", ":", "doc_file_path", "=", "self", ".", "get_doc_file_path", "(", ")", "if", "(", "self", ...
thumbnail with a memory cache
[ "thumbnail", "with", "a", "memory", "cache" ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/common/page.py#L189-L224
48,804
openpaperwork/paperwork-backend
paperwork_backend/common/page.py
BasicPage.__get_keywords
def __get_keywords(self): """ Get all the keywords related of this page Returns: An array of strings """ txt = self.text for line in txt: for word in split_words(line): yield(word)
python
def __get_keywords(self): """ Get all the keywords related of this page Returns: An array of strings """ txt = self.text for line in txt: for word in split_words(line): yield(word)
[ "def", "__get_keywords", "(", "self", ")", ":", "txt", "=", "self", ".", "text", "for", "line", "in", "txt", ":", "for", "word", "in", "split_words", "(", "line", ")", ":", "yield", "(", "word", ")" ]
Get all the keywords related of this page Returns: An array of strings
[ "Get", "all", "the", "keywords", "related", "of", "this", "page" ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/common/page.py#L272-L282
48,805
openpaperwork/paperwork-backend
paperwork_backend/util.py
strip_accents
def strip_accents(string): """ Strip all the accents from the string """ return u''.join( (character for character in unicodedata.normalize('NFD', string) if unicodedata.category(character) != 'Mn'))
python
def strip_accents(string): """ Strip all the accents from the string """ return u''.join( (character for character in unicodedata.normalize('NFD', string) if unicodedata.category(character) != 'Mn'))
[ "def", "strip_accents", "(", "string", ")", ":", "return", "u''", ".", "join", "(", "(", "character", "for", "character", "in", "unicodedata", ".", "normalize", "(", "'NFD'", ",", "string", ")", "if", "unicodedata", ".", "category", "(", "character", ")", ...
Strip all the accents from the string
[ "Strip", "all", "the", "accents", "from", "the", "string" ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/util.py#L50-L56
48,806
openpaperwork/paperwork-backend
paperwork_backend/util.py
rm_rf
def rm_rf(path): """ Act as 'rm -rf' in the shell """ if os.path.isfile(path): os.unlink(path) elif os.path.isdir(path): for root, dirs, files in os.walk(path, topdown=False): for filename in files: filepath = os.path.join(root, filename) l...
python
def rm_rf(path): """ Act as 'rm -rf' in the shell """ if os.path.isfile(path): os.unlink(path) elif os.path.isdir(path): for root, dirs, files in os.walk(path, topdown=False): for filename in files: filepath = os.path.join(root, filename) l...
[ "def", "rm_rf", "(", "path", ")", ":", "if", "os", ".", "path", ".", "isfile", "(", "path", ")", ":", "os", ".", "unlink", "(", "path", ")", "elif", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "for", "root", ",", "dirs", ",", "fil...
Act as 'rm -rf' in the shell
[ "Act", "as", "rm", "-", "rf", "in", "the", "shell" ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/util.py#L204-L225
48,807
openpaperwork/paperwork-backend
paperwork_backend/util.py
surface2image
def surface2image(surface): """ Convert a cairo surface into a PIL image """ # TODO(Jflesch): Python 3 problem # cairo.ImageSurface.get_data() raises NotImplementedYet ... # import PIL.ImageDraw # # if surface is None: # return None # dimension = (surface.get_width(), surfac...
python
def surface2image(surface): """ Convert a cairo surface into a PIL image """ # TODO(Jflesch): Python 3 problem # cairo.ImageSurface.get_data() raises NotImplementedYet ... # import PIL.ImageDraw # # if surface is None: # return None # dimension = (surface.get_width(), surfac...
[ "def", "surface2image", "(", "surface", ")", ":", "# TODO(Jflesch): Python 3 problem", "# cairo.ImageSurface.get_data() raises NotImplementedYet ...", "# import PIL.ImageDraw", "#", "# if surface is None:", "# return None", "# dimension = (surface.get_width(), surface.get_height())", "...
Convert a cairo surface into a PIL image
[ "Convert", "a", "cairo", "surface", "into", "a", "PIL", "image" ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/util.py#L228-L260
48,808
openpaperwork/paperwork-backend
paperwork_backend/util.py
image2surface
def image2surface(img): """ Convert a PIL image into a Cairo surface """ if not CAIRO_AVAILABLE: raise Exception("Cairo not available(). image2surface() cannot work.") # TODO(Jflesch): Python 3 problem # cairo.ImageSurface.create_for_data() raises NotImplementedYet ... # img.putalp...
python
def image2surface(img): """ Convert a PIL image into a Cairo surface """ if not CAIRO_AVAILABLE: raise Exception("Cairo not available(). image2surface() cannot work.") # TODO(Jflesch): Python 3 problem # cairo.ImageSurface.create_for_data() raises NotImplementedYet ... # img.putalp...
[ "def", "image2surface", "(", "img", ")", ":", "if", "not", "CAIRO_AVAILABLE", ":", "raise", "Exception", "(", "\"Cairo not available(). image2surface() cannot work.\"", ")", "# TODO(Jflesch): Python 3 problem", "# cairo.ImageSurface.create_for_data() raises NotImplementedYet ...", ...
Convert a PIL image into a Cairo surface
[ "Convert", "a", "PIL", "image", "into", "a", "Cairo", "surface" ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/util.py#L263-L287
48,809
xflows/rdm
rdm/db/mapper.py
domain_map
def domain_map(features, feature_format, train_context, test_context, intervals={}, format='arff', positive_class=None): ''' Use the features returned by a propositionalization method to map unseen test examples into the new feature space. :param features:...
python
def domain_map(features, feature_format, train_context, test_context, intervals={}, format='arff', positive_class=None): ''' Use the features returned by a propositionalization method to map unseen test examples into the new feature space. :param features:...
[ "def", "domain_map", "(", "features", ",", "feature_format", ",", "train_context", ",", "test_context", ",", "intervals", "=", "{", "}", ",", "format", "=", "'arff'", ",", "positive_class", "=", "None", ")", ":", "dataset", "=", "None", "if", "feature_format...
Use the features returned by a propositionalization method to map unseen test examples into the new feature space. :param features: string of features as returned by rsd, aleph or treeliker :param feature_format: 'rsd', 'aleph', 'treeliker' :param train_context: DBContext with training examples ...
[ "Use", "the", "features", "returned", "by", "a", "propositionalization", "method", "to", "map", "unseen", "test", "examples", "into", "the", "new", "feature", "space", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/db/mapper.py#L23-L99
48,810
openpaperwork/paperwork-backend
paperwork_backend/img/page.py
ImgPage._get_text
def _get_text(self): """ Get the text corresponding to this page """ boxes = self.boxes txt = [] for line in boxes: txt_line = u"" for box in line.word_boxes: txt_line += u" " + box.content txt.append(txt_line) r...
python
def _get_text(self): """ Get the text corresponding to this page """ boxes = self.boxes txt = [] for line in boxes: txt_line = u"" for box in line.word_boxes: txt_line += u" " + box.content txt.append(txt_line) r...
[ "def", "_get_text", "(", "self", ")", ":", "boxes", "=", "self", ".", "boxes", "txt", "=", "[", "]", "for", "line", "in", "boxes", ":", "txt_line", "=", "u\"\"", "for", "box", "in", "line", ".", "word_boxes", ":", "txt_line", "+=", "u\" \"", "+", "...
Get the text corresponding to this page
[ "Get", "the", "text", "corresponding", "to", "this", "page" ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/img/page.py#L82-L93
48,811
openpaperwork/paperwork-backend
paperwork_backend/img/page.py
ImgPage.__get_img
def __get_img(self): """ Returns an image object corresponding to the page """ with self.fs.open(self.__img_path, 'rb') as fd: img = PIL.Image.open(fd) img.load() return img
python
def __get_img(self): """ Returns an image object corresponding to the page """ with self.fs.open(self.__img_path, 'rb') as fd: img = PIL.Image.open(fd) img.load() return img
[ "def", "__get_img", "(", "self", ")", ":", "with", "self", ".", "fs", ".", "open", "(", "self", ".", "__img_path", ",", "'rb'", ")", "as", "fd", ":", "img", "=", "PIL", ".", "Image", ".", "open", "(", "fd", ")", "img", ".", "load", "(", ")", ...
Returns an image object corresponding to the page
[ "Returns", "an", "image", "object", "corresponding", "to", "the", "page" ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/img/page.py#L129-L136
48,812
openpaperwork/paperwork-backend
paperwork_backend/img/page.py
ImgPage.change_index
def change_index(self, offset=0): """ Move the page number by a given offset. Beware to not let any hole in the page numbers when doing this. Make sure also that the wanted number is available. Will also change the page number of the current object. """ src = {} ...
python
def change_index(self, offset=0): """ Move the page number by a given offset. Beware to not let any hole in the page numbers when doing this. Make sure also that the wanted number is available. Will also change the page number of the current object. """ src = {} ...
[ "def", "change_index", "(", "self", ",", "offset", "=", "0", ")", ":", "src", "=", "{", "}", "src", "[", "\"box\"", "]", "=", "self", ".", "__get_box_path", "(", ")", "src", "[", "\"img\"", "]", "=", "self", ".", "__get_img_path", "(", ")", "src", ...
Move the page number by a given offset. Beware to not let any hole in the page numbers when doing this. Make sure also that the wanted number is available. Will also change the page number of the current object.
[ "Move", "the", "page", "number", "by", "a", "given", "offset", ".", "Beware", "to", "not", "let", "any", "hole", "in", "the", "page", "numbers", "when", "doing", "this", ".", "Make", "sure", "also", "that", "the", "wanted", "number", "is", "available", ...
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/img/page.py#L200-L231
48,813
openpaperwork/paperwork-backend
paperwork_backend/img/page.py
ImgPage.destroy
def destroy(self): """ Delete the page. May delete the whole document if it's actually the last page. """ logger.info("Destroying page: %s" % self) if self.doc.nb_pages <= 1: self.doc.destroy() return doc_pages = self.doc.pages[:] c...
python
def destroy(self): """ Delete the page. May delete the whole document if it's actually the last page. """ logger.info("Destroying page: %s" % self) if self.doc.nb_pages <= 1: self.doc.destroy() return doc_pages = self.doc.pages[:] c...
[ "def", "destroy", "(", "self", ")", ":", "logger", ".", "info", "(", "\"Destroying page: %s\"", "%", "self", ")", "if", "self", ".", "doc", ".", "nb_pages", "<=", "1", ":", "self", ".", "doc", ".", "destroy", "(", ")", "return", "doc_pages", "=", "se...
Delete the page. May delete the whole document if it's actually the last page.
[ "Delete", "the", "page", ".", "May", "delete", "the", "whole", "document", "if", "it", "s", "actually", "the", "last", "page", "." ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/img/page.py#L233-L254
48,814
transitland/mapzen-gtfs
mzgtfs/entity.py
Entity.pclink
def pclink(self, parent, child): """Create a parent-child relationship.""" if parent._children is None: parent._children = set() if child._parents is None: child._parents = set() parent._children.add(child) child._parents.add(parent)
python
def pclink(self, parent, child): """Create a parent-child relationship.""" if parent._children is None: parent._children = set() if child._parents is None: child._parents = set() parent._children.add(child) child._parents.add(parent)
[ "def", "pclink", "(", "self", ",", "parent", ",", "child", ")", ":", "if", "parent", ".", "_children", "is", "None", ":", "parent", ".", "_children", "=", "set", "(", ")", "if", "child", ".", "_parents", "is", "None", ":", "child", ".", "_parents", ...
Create a parent-child relationship.
[ "Create", "a", "parent", "-", "child", "relationship", "." ]
d445f1588ed10713eea9a1ca2878eef792121eca
https://github.com/transitland/mapzen-gtfs/blob/d445f1588ed10713eea9a1ca2878eef792121eca/mzgtfs/entity.py#L118-L125
48,815
gopalkoduri/intonation
intonation/pitch.py
Pitch.discretize
def discretize(self, intervals, slope_thresh=1500, cents_thresh=50): """ This function takes the pitch data and returns it quantized to given set of intervals. All transactions must happen in cent scale. slope_thresh is the bound beyond which the pitch contour is said to transit ...
python
def discretize(self, intervals, slope_thresh=1500, cents_thresh=50): """ This function takes the pitch data and returns it quantized to given set of intervals. All transactions must happen in cent scale. slope_thresh is the bound beyond which the pitch contour is said to transit ...
[ "def", "discretize", "(", "self", ",", "intervals", ",", "slope_thresh", "=", "1500", ",", "cents_thresh", "=", "50", ")", ":", "#eps = np.finfo(float).eps", "#pitch = median_filter(pitch, 7)+eps", "self", ".", "pitch", "=", "median_filter", "(", "self", ".", "pit...
This function takes the pitch data and returns it quantized to given set of intervals. All transactions must happen in cent scale. slope_thresh is the bound beyond which the pitch contour is said to transit from one svara to another. It is specified in cents/sec. cents_thresh is a limi...
[ "This", "function", "takes", "the", "pitch", "data", "and", "returns", "it", "quantized", "to", "given", "set", "of", "intervals", ".", "All", "transactions", "must", "happen", "in", "cent", "scale", "." ]
7f50d2b572755840be960ea990416a7b27f20312
https://github.com/gopalkoduri/intonation/blob/7f50d2b572755840be960ea990416a7b27f20312/intonation/pitch.py#L16-L54
48,816
edibledinos/pwnypack
pwnypack/target.py
Target.assume
def assume(self, other): """ Assume the identity of another target. This can be useful to make the global target assume the identity of an ELF executable. Arguments: other(:class:`Target`): The target whose identity to assume. Example: >>> from pwny impo...
python
def assume(self, other): """ Assume the identity of another target. This can be useful to make the global target assume the identity of an ELF executable. Arguments: other(:class:`Target`): The target whose identity to assume. Example: >>> from pwny impo...
[ "def", "assume", "(", "self", ",", "other", ")", ":", "self", ".", "_arch", "=", "other", ".", "_arch", "self", ".", "_bits", "=", "other", ".", "_bits", "self", ".", "_endian", "=", "other", ".", "_endian", "self", ".", "_mode", "=", "other", ".",...
Assume the identity of another target. This can be useful to make the global target assume the identity of an ELF executable. Arguments: other(:class:`Target`): The target whose identity to assume. Example: >>> from pwny import * >>> target.assume(ELF('my-ex...
[ "Assume", "the", "identity", "of", "another", "target", ".", "This", "can", "be", "useful", "to", "make", "the", "global", "target", "assume", "the", "identity", "of", "an", "ELF", "executable", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/target.py#L170-L186
48,817
RacingTadpole/django-private-media
private_media/permissions.py
DefaultPrivatePermissions.has_read_permission
def has_read_permission(self, request, path): """ Just return True if the user is an authenticated staff member. Extensions could base the permissions on the path too. """ user = request.user if not user.is_authenticated(): return False elif user.is_su...
python
def has_read_permission(self, request, path): """ Just return True if the user is an authenticated staff member. Extensions could base the permissions on the path too. """ user = request.user if not user.is_authenticated(): return False elif user.is_su...
[ "def", "has_read_permission", "(", "self", ",", "request", ",", "path", ")", ":", "user", "=", "request", ".", "user", "if", "not", "user", ".", "is_authenticated", "(", ")", ":", "return", "False", "elif", "user", ".", "is_superuser", ":", "return", "Tr...
Just return True if the user is an authenticated staff member. Extensions could base the permissions on the path too.
[ "Just", "return", "True", "if", "the", "user", "is", "an", "authenticated", "staff", "member", ".", "Extensions", "could", "base", "the", "permissions", "on", "the", "path", "too", "." ]
7510f2f63ddf0653679b4134a0542cd78317a5c8
https://github.com/RacingTadpole/django-private-media/blob/7510f2f63ddf0653679b4134a0542cd78317a5c8/private_media/permissions.py#L4-L17
48,818
xflows/rdm
rdm/db/context.py
DBContext.rows
def rows(self, table, cols): ''' Fetches rows from the local cache or from the db if there's no cache. :param table: table name to select :cols: list of columns to select :return: list of rows :rtype: list ''' if self.orng_tables: ...
python
def rows(self, table, cols): ''' Fetches rows from the local cache or from the db if there's no cache. :param table: table name to select :cols: list of columns to select :return: list of rows :rtype: list ''' if self.orng_tables: ...
[ "def", "rows", "(", "self", ",", "table", ",", "cols", ")", ":", "if", "self", ".", "orng_tables", ":", "data", "=", "[", "]", "for", "ex", "in", "self", ".", "orng_tables", "[", "table", "]", ":", "data", ".", "append", "(", "[", "ex", "[", "s...
Fetches rows from the local cache or from the db if there's no cache. :param table: table name to select :cols: list of columns to select :return: list of rows :rtype: list
[ "Fetches", "rows", "from", "the", "local", "cache", "or", "from", "the", "db", "if", "there", "s", "no", "cache", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/db/context.py#L138-L153
48,819
xflows/rdm
rdm/db/context.py
DBContext.select_where
def select_where(self, table, cols, pk_att, pk): ''' SELECT with WHERE clause. :param table: target table :param cols: list of columns to select :param pk_att: attribute for the where clause :param pk: the id that the pk_att should match :retu...
python
def select_where(self, table, cols, pk_att, pk): ''' SELECT with WHERE clause. :param table: target table :param cols: list of columns to select :param pk_att: attribute for the where clause :param pk: the id that the pk_att should match :retu...
[ "def", "select_where", "(", "self", ",", "table", ",", "cols", ",", "pk_att", ",", "pk", ")", ":", "if", "self", ".", "orng_tables", ":", "data", "=", "[", "]", "for", "ex", "in", "self", ".", "orng_tables", "[", "table", "]", ":", "if", "str", "...
SELECT with WHERE clause. :param table: target table :param cols: list of columns to select :param pk_att: attribute for the where clause :param pk: the id that the pk_att should match :return: rows from the given table and cols, with the condition pk_att==pk...
[ "SELECT", "with", "WHERE", "clause", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/db/context.py#L155-L173
48,820
nagius/snmp_passpersist
snmp_passpersist.py
PassPersist.encode
def encode(string): """ Encode the given string as an OID. >>> import snmp_passpersist as snmp >>> snmp.PassPersist.encode("hello") '5.104.101.108.108.111' >>> """ result=".".join([ str(ord(s)) for s in string ]) return "%s." % (len(string)) + result
python
def encode(string): """ Encode the given string as an OID. >>> import snmp_passpersist as snmp >>> snmp.PassPersist.encode("hello") '5.104.101.108.108.111' >>> """ result=".".join([ str(ord(s)) for s in string ]) return "%s." % (len(string)) + result
[ "def", "encode", "(", "string", ")", ":", "result", "=", "\".\"", ".", "join", "(", "[", "str", "(", "ord", "(", "s", ")", ")", "for", "s", "in", "string", "]", ")", "return", "\"%s.\"", "%", "(", "len", "(", "string", ")", ")", "+", "result" ]
Encode the given string as an OID. >>> import snmp_passpersist as snmp >>> snmp.PassPersist.encode("hello") '5.104.101.108.108.111' >>>
[ "Encode", "the", "given", "string", "as", "an", "OID", "." ]
8cc584d2e90c920ae98a318164a55bde209a18f7
https://github.com/nagius/snmp_passpersist/blob/8cc584d2e90c920ae98a318164a55bde209a18f7/snmp_passpersist.py#L106-L117
48,821
nagius/snmp_passpersist
snmp_passpersist.py
PassPersist.get
def get(self,oid): """Return snmp value for the given OID.""" try: self.lock.acquire() if oid not in self.data: return "NONE" else: return self.base_oid + oid + '\n' + self.data[oid]['type'] + '\n' + str(self.data[oid]['value']) finally: self.lock.release()
python
def get(self,oid): """Return snmp value for the given OID.""" try: self.lock.acquire() if oid not in self.data: return "NONE" else: return self.base_oid + oid + '\n' + self.data[oid]['type'] + '\n' + str(self.data[oid]['value']) finally: self.lock.release()
[ "def", "get", "(", "self", ",", "oid", ")", ":", "try", ":", "self", ".", "lock", ".", "acquire", "(", ")", "if", "oid", "not", "in", "self", ".", "data", ":", "return", "\"NONE\"", "else", ":", "return", "self", ".", "base_oid", "+", "oid", "+",...
Return snmp value for the given OID.
[ "Return", "snmp", "value", "for", "the", "given", "OID", "." ]
8cc584d2e90c920ae98a318164a55bde209a18f7
https://github.com/nagius/snmp_passpersist/blob/8cc584d2e90c920ae98a318164a55bde209a18f7/snmp_passpersist.py#L141-L150
48,822
nagius/snmp_passpersist
snmp_passpersist.py
PassPersist.get_next
def get_next(self,oid): """Return snmp value for the next OID.""" try: # Nested try..except because of Python 2.4 self.lock.acquire() try: # remove trailing zeroes from the oid while len(oid) > 0 and oid[-2:] == ".0" and oid not in self.data: oid = oid[:-2]; return self.get(self.data_idx[self...
python
def get_next(self,oid): """Return snmp value for the next OID.""" try: # Nested try..except because of Python 2.4 self.lock.acquire() try: # remove trailing zeroes from the oid while len(oid) > 0 and oid[-2:] == ".0" and oid not in self.data: oid = oid[:-2]; return self.get(self.data_idx[self...
[ "def", "get_next", "(", "self", ",", "oid", ")", ":", "try", ":", "# Nested try..except because of Python 2.4", "self", ".", "lock", ".", "acquire", "(", ")", "try", ":", "# remove trailing zeroes from the oid", "while", "len", "(", "oid", ")", ">", "0", "and"...
Return snmp value for the next OID.
[ "Return", "snmp", "value", "for", "the", "next", "OID", "." ]
8cc584d2e90c920ae98a318164a55bde209a18f7
https://github.com/nagius/snmp_passpersist/blob/8cc584d2e90c920ae98a318164a55bde209a18f7/snmp_passpersist.py#L152-L170
48,823
nagius/snmp_passpersist
snmp_passpersist.py
PassPersist.get_first
def get_first(self): """Return snmp value for the first OID.""" try: # Nested try..except because of Python 2.4 self.lock.acquire() try: return self.get(self.data_idx[0]) except (IndexError, ValueError): return "NONE" finally: self.lock.release()
python
def get_first(self): """Return snmp value for the first OID.""" try: # Nested try..except because of Python 2.4 self.lock.acquire() try: return self.get(self.data_idx[0]) except (IndexError, ValueError): return "NONE" finally: self.lock.release()
[ "def", "get_first", "(", "self", ")", ":", "try", ":", "# Nested try..except because of Python 2.4", "self", ".", "lock", ".", "acquire", "(", ")", "try", ":", "return", "self", ".", "get", "(", "self", ".", "data_idx", "[", "0", "]", ")", "except", "(",...
Return snmp value for the first OID.
[ "Return", "snmp", "value", "for", "the", "first", "OID", "." ]
8cc584d2e90c920ae98a318164a55bde209a18f7
https://github.com/nagius/snmp_passpersist/blob/8cc584d2e90c920ae98a318164a55bde209a18f7/snmp_passpersist.py#L172-L181
48,824
nagius/snmp_passpersist
snmp_passpersist.py
PassPersist.cut_oid
def cut_oid(self,full_oid): """ Remove the base OID from the given string. >>> import snmp_passpersist as snmp >>> pp=snmp.PassPersist(".1.3.6.1.3.53.8") >>> pp.cut_oid(".1.3.6.1.3.53.8.28.12") '28.12' """ if not full_oid.startswith(self.base_oid.rstrip('.')): return None else: return full_oid[...
python
def cut_oid(self,full_oid): """ Remove the base OID from the given string. >>> import snmp_passpersist as snmp >>> pp=snmp.PassPersist(".1.3.6.1.3.53.8") >>> pp.cut_oid(".1.3.6.1.3.53.8.28.12") '28.12' """ if not full_oid.startswith(self.base_oid.rstrip('.')): return None else: return full_oid[...
[ "def", "cut_oid", "(", "self", ",", "full_oid", ")", ":", "if", "not", "full_oid", ".", "startswith", "(", "self", ".", "base_oid", ".", "rstrip", "(", "'.'", ")", ")", ":", "return", "None", "else", ":", "return", "full_oid", "[", "len", "(", "self"...
Remove the base OID from the given string. >>> import snmp_passpersist as snmp >>> pp=snmp.PassPersist(".1.3.6.1.3.53.8") >>> pp.cut_oid(".1.3.6.1.3.53.8.28.12") '28.12'
[ "Remove", "the", "base", "OID", "from", "the", "given", "string", "." ]
8cc584d2e90c920ae98a318164a55bde209a18f7
https://github.com/nagius/snmp_passpersist/blob/8cc584d2e90c920ae98a318164a55bde209a18f7/snmp_passpersist.py#L183-L195
48,825
nagius/snmp_passpersist
snmp_passpersist.py
PassPersist.add_oid_entry
def add_oid_entry(self, oid, type, value, label=None): """General function to add an oid entry to the MIB subtree.""" if self.debug: print('DEBUG: %s %s %s %s'%(oid,type,value,label)) item={'type': str(type), 'value': str(value)} if label is not None: item['label']=str(label) self.pending[oid]=item
python
def add_oid_entry(self, oid, type, value, label=None): """General function to add an oid entry to the MIB subtree.""" if self.debug: print('DEBUG: %s %s %s %s'%(oid,type,value,label)) item={'type': str(type), 'value': str(value)} if label is not None: item['label']=str(label) self.pending[oid]=item
[ "def", "add_oid_entry", "(", "self", ",", "oid", ",", "type", ",", "value", ",", "label", "=", "None", ")", ":", "if", "self", ".", "debug", ":", "print", "(", "'DEBUG: %s %s %s %s'", "%", "(", "oid", ",", "type", ",", "value", ",", "label", ")", "...
General function to add an oid entry to the MIB subtree.
[ "General", "function", "to", "add", "an", "oid", "entry", "to", "the", "MIB", "subtree", "." ]
8cc584d2e90c920ae98a318164a55bde209a18f7
https://github.com/nagius/snmp_passpersist/blob/8cc584d2e90c920ae98a318164a55bde209a18f7/snmp_passpersist.py#L197-L204
48,826
nagius/snmp_passpersist
snmp_passpersist.py
PassPersist.add_oid
def add_oid(self,oid,value,label=None): """Short helper to add an object ID value to the MIB subtree.""" self.add_oid_entry(oid,'OBJECTID',value,label=label)
python
def add_oid(self,oid,value,label=None): """Short helper to add an object ID value to the MIB subtree.""" self.add_oid_entry(oid,'OBJECTID',value,label=label)
[ "def", "add_oid", "(", "self", ",", "oid", ",", "value", ",", "label", "=", "None", ")", ":", "self", ".", "add_oid_entry", "(", "oid", ",", "'OBJECTID'", ",", "value", ",", "label", "=", "label", ")" ]
Short helper to add an object ID value to the MIB subtree.
[ "Short", "helper", "to", "add", "an", "object", "ID", "value", "to", "the", "MIB", "subtree", "." ]
8cc584d2e90c920ae98a318164a55bde209a18f7
https://github.com/nagius/snmp_passpersist/blob/8cc584d2e90c920ae98a318164a55bde209a18f7/snmp_passpersist.py#L206-L208
48,827
nagius/snmp_passpersist
snmp_passpersist.py
PassPersist.add_int
def add_int(self,oid,value,label=None): """Short helper to add an integer value to the MIB subtree.""" self.add_oid_entry(oid,'INTEGER',value,label=label)
python
def add_int(self,oid,value,label=None): """Short helper to add an integer value to the MIB subtree.""" self.add_oid_entry(oid,'INTEGER',value,label=label)
[ "def", "add_int", "(", "self", ",", "oid", ",", "value", ",", "label", "=", "None", ")", ":", "self", ".", "add_oid_entry", "(", "oid", ",", "'INTEGER'", ",", "value", ",", "label", "=", "label", ")" ]
Short helper to add an integer value to the MIB subtree.
[ "Short", "helper", "to", "add", "an", "integer", "value", "to", "the", "MIB", "subtree", "." ]
8cc584d2e90c920ae98a318164a55bde209a18f7
https://github.com/nagius/snmp_passpersist/blob/8cc584d2e90c920ae98a318164a55bde209a18f7/snmp_passpersist.py#L210-L212
48,828
nagius/snmp_passpersist
snmp_passpersist.py
PassPersist.add_oct
def add_oct(self,oid,value,label=None): """Short helper to add an octet value to the MIB subtree.""" self.add_oid_entry(oid,'OCTET',value,label=label)
python
def add_oct(self,oid,value,label=None): """Short helper to add an octet value to the MIB subtree.""" self.add_oid_entry(oid,'OCTET',value,label=label)
[ "def", "add_oct", "(", "self", ",", "oid", ",", "value", ",", "label", "=", "None", ")", ":", "self", ".", "add_oid_entry", "(", "oid", ",", "'OCTET'", ",", "value", ",", "label", "=", "label", ")" ]
Short helper to add an octet value to the MIB subtree.
[ "Short", "helper", "to", "add", "an", "octet", "value", "to", "the", "MIB", "subtree", "." ]
8cc584d2e90c920ae98a318164a55bde209a18f7
https://github.com/nagius/snmp_passpersist/blob/8cc584d2e90c920ae98a318164a55bde209a18f7/snmp_passpersist.py#L214-L216
48,829
nagius/snmp_passpersist
snmp_passpersist.py
PassPersist.add_str
def add_str(self,oid,value,label=None): """Short helper to add a string value to the MIB subtree.""" self.add_oid_entry(oid,'STRING',value,label=label)
python
def add_str(self,oid,value,label=None): """Short helper to add a string value to the MIB subtree.""" self.add_oid_entry(oid,'STRING',value,label=label)
[ "def", "add_str", "(", "self", ",", "oid", ",", "value", ",", "label", "=", "None", ")", ":", "self", ".", "add_oid_entry", "(", "oid", ",", "'STRING'", ",", "value", ",", "label", "=", "label", ")" ]
Short helper to add a string value to the MIB subtree.
[ "Short", "helper", "to", "add", "a", "string", "value", "to", "the", "MIB", "subtree", "." ]
8cc584d2e90c920ae98a318164a55bde209a18f7
https://github.com/nagius/snmp_passpersist/blob/8cc584d2e90c920ae98a318164a55bde209a18f7/snmp_passpersist.py#L218-L220
48,830
nagius/snmp_passpersist
snmp_passpersist.py
PassPersist.add_ip
def add_ip(self,oid,value,label=None): """Short helper to add an IP address value to the MIB subtree.""" self.add_oid_entry(oid,'IPADDRESS',value,label=label)
python
def add_ip(self,oid,value,label=None): """Short helper to add an IP address value to the MIB subtree.""" self.add_oid_entry(oid,'IPADDRESS',value,label=label)
[ "def", "add_ip", "(", "self", ",", "oid", ",", "value", ",", "label", "=", "None", ")", ":", "self", ".", "add_oid_entry", "(", "oid", ",", "'IPADDRESS'", ",", "value", ",", "label", "=", "label", ")" ]
Short helper to add an IP address value to the MIB subtree.
[ "Short", "helper", "to", "add", "an", "IP", "address", "value", "to", "the", "MIB", "subtree", "." ]
8cc584d2e90c920ae98a318164a55bde209a18f7
https://github.com/nagius/snmp_passpersist/blob/8cc584d2e90c920ae98a318164a55bde209a18f7/snmp_passpersist.py#L222-L224
48,831
nagius/snmp_passpersist
snmp_passpersist.py
PassPersist.add_cnt_32bit
def add_cnt_32bit(self,oid,value,label=None): """Short helper to add a 32 bit counter value to the MIB subtree.""" # Truncate integer to 32bits ma,x self.add_oid_entry(oid,'Counter32',int(value)%4294967296,label=label)
python
def add_cnt_32bit(self,oid,value,label=None): """Short helper to add a 32 bit counter value to the MIB subtree.""" # Truncate integer to 32bits ma,x self.add_oid_entry(oid,'Counter32',int(value)%4294967296,label=label)
[ "def", "add_cnt_32bit", "(", "self", ",", "oid", ",", "value", ",", "label", "=", "None", ")", ":", "# Truncate integer to 32bits ma,x", "self", ".", "add_oid_entry", "(", "oid", ",", "'Counter32'", ",", "int", "(", "value", ")", "%", "4294967296", ",", "l...
Short helper to add a 32 bit counter value to the MIB subtree.
[ "Short", "helper", "to", "add", "a", "32", "bit", "counter", "value", "to", "the", "MIB", "subtree", "." ]
8cc584d2e90c920ae98a318164a55bde209a18f7
https://github.com/nagius/snmp_passpersist/blob/8cc584d2e90c920ae98a318164a55bde209a18f7/snmp_passpersist.py#L226-L229
48,832
nagius/snmp_passpersist
snmp_passpersist.py
PassPersist.add_cnt_64bit
def add_cnt_64bit(self,oid,value,label=None): """Short helper to add a 64 bit counter value to the MIB subtree.""" # Truncate integer to 64bits ma,x self.add_oid_entry(oid,'Counter64',int(value)%18446744073709551615,label=label)
python
def add_cnt_64bit(self,oid,value,label=None): """Short helper to add a 64 bit counter value to the MIB subtree.""" # Truncate integer to 64bits ma,x self.add_oid_entry(oid,'Counter64',int(value)%18446744073709551615,label=label)
[ "def", "add_cnt_64bit", "(", "self", ",", "oid", ",", "value", ",", "label", "=", "None", ")", ":", "# Truncate integer to 64bits ma,x", "self", ".", "add_oid_entry", "(", "oid", ",", "'Counter64'", ",", "int", "(", "value", ")", "%", "18446744073709551615", ...
Short helper to add a 64 bit counter value to the MIB subtree.
[ "Short", "helper", "to", "add", "a", "64", "bit", "counter", "value", "to", "the", "MIB", "subtree", "." ]
8cc584d2e90c920ae98a318164a55bde209a18f7
https://github.com/nagius/snmp_passpersist/blob/8cc584d2e90c920ae98a318164a55bde209a18f7/snmp_passpersist.py#L231-L234
48,833
nagius/snmp_passpersist
snmp_passpersist.py
PassPersist.add_gau
def add_gau(self,oid,value,label=None): """Short helper to add a gauge value to the MIB subtree.""" self.add_oid_entry(oid,'GAUGE',value,label=label)
python
def add_gau(self,oid,value,label=None): """Short helper to add a gauge value to the MIB subtree.""" self.add_oid_entry(oid,'GAUGE',value,label=label)
[ "def", "add_gau", "(", "self", ",", "oid", ",", "value", ",", "label", "=", "None", ")", ":", "self", ".", "add_oid_entry", "(", "oid", ",", "'GAUGE'", ",", "value", ",", "label", "=", "label", ")" ]
Short helper to add a gauge value to the MIB subtree.
[ "Short", "helper", "to", "add", "a", "gauge", "value", "to", "the", "MIB", "subtree", "." ]
8cc584d2e90c920ae98a318164a55bde209a18f7
https://github.com/nagius/snmp_passpersist/blob/8cc584d2e90c920ae98a318164a55bde209a18f7/snmp_passpersist.py#L236-L238
48,834
nagius/snmp_passpersist
snmp_passpersist.py
PassPersist.add_tt
def add_tt(self,oid,value,label=None): """Short helper to add a timeticks value to the MIB subtree.""" self.add_oid_entry(oid,'TIMETICKS',value,label=label)
python
def add_tt(self,oid,value,label=None): """Short helper to add a timeticks value to the MIB subtree.""" self.add_oid_entry(oid,'TIMETICKS',value,label=label)
[ "def", "add_tt", "(", "self", ",", "oid", ",", "value", ",", "label", "=", "None", ")", ":", "self", ".", "add_oid_entry", "(", "oid", ",", "'TIMETICKS'", ",", "value", ",", "label", "=", "label", ")" ]
Short helper to add a timeticks value to the MIB subtree.
[ "Short", "helper", "to", "add", "a", "timeticks", "value", "to", "the", "MIB", "subtree", "." ]
8cc584d2e90c920ae98a318164a55bde209a18f7
https://github.com/nagius/snmp_passpersist/blob/8cc584d2e90c920ae98a318164a55bde209a18f7/snmp_passpersist.py#L240-L242
48,835
nagius/snmp_passpersist
snmp_passpersist.py
PassPersist.main_passpersist
def main_passpersist(self): """ Main function that handle SNMP's pass_persist protocol, called by the start method. Direct call is unnecessary. """ line = sys.stdin.readline().strip() if not line: raise EOFError() if 'PING' in line: print("PONG") elif 'getnext' in line: oid = self.cut_oid(sy...
python
def main_passpersist(self): """ Main function that handle SNMP's pass_persist protocol, called by the start method. Direct call is unnecessary. """ line = sys.stdin.readline().strip() if not line: raise EOFError() if 'PING' in line: print("PONG") elif 'getnext' in line: oid = self.cut_oid(sy...
[ "def", "main_passpersist", "(", "self", ")", ":", "line", "=", "sys", ".", "stdin", ".", "readline", "(", ")", ".", "strip", "(", ")", "if", "not", "line", ":", "raise", "EOFError", "(", ")", "if", "'PING'", "in", "line", ":", "print", "(", "\"PONG...
Main function that handle SNMP's pass_persist protocol, called by the start method. Direct call is unnecessary.
[ "Main", "function", "that", "handle", "SNMP", "s", "pass_persist", "protocol", "called", "by", "the", "start", "method", ".", "Direct", "call", "is", "unnecessary", "." ]
8cc584d2e90c920ae98a318164a55bde209a18f7
https://github.com/nagius/snmp_passpersist/blob/8cc584d2e90c920ae98a318164a55bde209a18f7/snmp_passpersist.py#L244-L281
48,836
nagius/snmp_passpersist
snmp_passpersist.py
PassPersist.main_update
def main_update(self): """ Main function called by the updater thread. Direct call is unnecessary. """ # Renice updater thread to limit overload try: os.nice(1) except AttributeError as er: pass # os.nice is not available on windows time.sleep(self.refresh) try: while True: # We pick a t...
python
def main_update(self): """ Main function called by the updater thread. Direct call is unnecessary. """ # Renice updater thread to limit overload try: os.nice(1) except AttributeError as er: pass # os.nice is not available on windows time.sleep(self.refresh) try: while True: # We pick a t...
[ "def", "main_update", "(", "self", ")", ":", "# Renice updater thread to limit overload", "try", ":", "os", ".", "nice", "(", "1", ")", "except", "AttributeError", "as", "er", ":", "pass", "# os.nice is not available on windows", "time", ".", "sleep", "(", "self",...
Main function called by the updater thread. Direct call is unnecessary.
[ "Main", "function", "called", "by", "the", "updater", "thread", ".", "Direct", "call", "is", "unnecessary", "." ]
8cc584d2e90c920ae98a318164a55bde209a18f7
https://github.com/nagius/snmp_passpersist/blob/8cc584d2e90c920ae98a318164a55bde209a18f7/snmp_passpersist.py#L303-L339
48,837
nagius/snmp_passpersist
snmp_passpersist.py
PassPersist.get_setter
def get_setter(self, oid): """ Retrieve the nearest parent setter function for an OID """ if hasattr(self.setter, oid): return self.setter[oid] parents = [ poid for poid in list(self.setter.keys()) if oid.startswith(poid) ] if parents: return self.setter[max(parents)] return self.default_setter
python
def get_setter(self, oid): """ Retrieve the nearest parent setter function for an OID """ if hasattr(self.setter, oid): return self.setter[oid] parents = [ poid for poid in list(self.setter.keys()) if oid.startswith(poid) ] if parents: return self.setter[max(parents)] return self.default_setter
[ "def", "get_setter", "(", "self", ",", "oid", ")", ":", "if", "hasattr", "(", "self", ".", "setter", ",", "oid", ")", ":", "return", "self", ".", "setter", "[", "oid", "]", "parents", "=", "[", "poid", "for", "poid", "in", "list", "(", "self", "....
Retrieve the nearest parent setter function for an OID
[ "Retrieve", "the", "nearest", "parent", "setter", "function", "for", "an", "OID" ]
8cc584d2e90c920ae98a318164a55bde209a18f7
https://github.com/nagius/snmp_passpersist/blob/8cc584d2e90c920ae98a318164a55bde209a18f7/snmp_passpersist.py#L341-L350
48,838
nagius/snmp_passpersist
snmp_passpersist.py
PassPersist.set
def set(self, oid, typevalue): """ Call the default or user setter function if available """ success = False type_ = typevalue.split()[0] value = typevalue.lstrip(type_).strip().strip('"') ret_value = self.get_setter(oid)(oid, type_, value) if ret_value: if ret_value in ErrorValues or ret_value == '...
python
def set(self, oid, typevalue): """ Call the default or user setter function if available """ success = False type_ = typevalue.split()[0] value = typevalue.lstrip(type_).strip().strip('"') ret_value = self.get_setter(oid)(oid, type_, value) if ret_value: if ret_value in ErrorValues or ret_value == '...
[ "def", "set", "(", "self", ",", "oid", ",", "typevalue", ")", ":", "success", "=", "False", "type_", "=", "typevalue", ".", "split", "(", ")", "[", "0", "]", "value", "=", "typevalue", ".", "lstrip", "(", "type_", ")", ".", "strip", "(", ")", "."...
Call the default or user setter function if available
[ "Call", "the", "default", "or", "user", "setter", "function", "if", "available" ]
8cc584d2e90c920ae98a318164a55bde209a18f7
https://github.com/nagius/snmp_passpersist/blob/8cc584d2e90c920ae98a318164a55bde209a18f7/snmp_passpersist.py#L363-L381
48,839
nagius/snmp_passpersist
snmp_passpersist.py
PassPersist.start
def start(self, user_func, refresh): """ Start the SNMP's protocol handler and the updater thread user_func is a reference to an update function, ran every 'refresh' seconds. """ self.update=user_func self.refresh=refresh self.error=None # First load self.update() self.commit() # Start updater t...
python
def start(self, user_func, refresh): """ Start the SNMP's protocol handler and the updater thread user_func is a reference to an update function, ran every 'refresh' seconds. """ self.update=user_func self.refresh=refresh self.error=None # First load self.update() self.commit() # Start updater t...
[ "def", "start", "(", "self", ",", "user_func", ",", "refresh", ")", ":", "self", ".", "update", "=", "user_func", "self", ".", "refresh", "=", "refresh", "self", ".", "error", "=", "None", "# First load", "self", ".", "update", "(", ")", "self", ".", ...
Start the SNMP's protocol handler and the updater thread user_func is a reference to an update function, ran every 'refresh' seconds.
[ "Start", "the", "SNMP", "s", "protocol", "handler", "and", "the", "updater", "thread", "user_func", "is", "a", "reference", "to", "an", "update", "function", "ran", "every", "refresh", "seconds", "." ]
8cc584d2e90c920ae98a318164a55bde209a18f7
https://github.com/nagius/snmp_passpersist/blob/8cc584d2e90c920ae98a318164a55bde209a18f7/snmp_passpersist.py#L383-L407
48,840
specialunderwear/django-easymode
easymode/tree/introspection.py
_get_members_of_type
def _get_members_of_type(obj, member_type): """ Finds members of a certain type in obj. :param obj: A model instance or class. :param member_type: The type of the menber we are trying to find. :rtype: A :class:`list` of ``member_type`` found in ``obj`` """ if not issubclass(type(obj), Mode...
python
def _get_members_of_type(obj, member_type): """ Finds members of a certain type in obj. :param obj: A model instance or class. :param member_type: The type of the menber we are trying to find. :rtype: A :class:`list` of ``member_type`` found in ``obj`` """ if not issubclass(type(obj), Mode...
[ "def", "_get_members_of_type", "(", "obj", ",", "member_type", ")", ":", "if", "not", "issubclass", "(", "type", "(", "obj", ")", ",", "ModelBase", ")", ":", "obj", "=", "obj", ".", "__class__", "key_hash", "=", "[", "]", "for", "key", "in", "dir", "...
Finds members of a certain type in obj. :param obj: A model instance or class. :param member_type: The type of the menber we are trying to find. :rtype: A :class:`list` of ``member_type`` found in ``obj``
[ "Finds", "members", "of", "a", "certain", "type", "in", "obj", "." ]
92f674b91fb8c54d6e379e2664e2000872d9c95e
https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/easymode/tree/introspection.py#L24-L49
48,841
openpaperwork/paperwork-backend
paperwork_backend/img/doc.py
_ImgPagesIterator.next
def next(self): """ Provide the next element of the list. """ if self.idx >= len(self.page_list): raise StopIteration() page = self.page_list[self.idx] self.idx += 1 return page
python
def next(self): """ Provide the next element of the list. """ if self.idx >= len(self.page_list): raise StopIteration() page = self.page_list[self.idx] self.idx += 1 return page
[ "def", "next", "(", "self", ")", ":", "if", "self", ".", "idx", ">=", "len", "(", "self", ".", "page_list", ")", ":", "raise", "StopIteration", "(", ")", "page", "=", "self", ".", "page_list", "[", "self", ".", "idx", "]", "self", ".", "idx", "+=...
Provide the next element of the list.
[ "Provide", "the", "next", "element", "of", "the", "list", "." ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/img/doc.py#L241-L249
48,842
openpaperwork/paperwork-backend
paperwork_backend/img/doc.py
ImgDoc._get_nb_pages
def _get_nb_pages(self): """ Compute the number of pages in the document. It basically counts how many JPG files there are in the document. """ try: filelist = self.fs.listdir(self.path) count = 0 for filepath in filelist: filen...
python
def _get_nb_pages(self): """ Compute the number of pages in the document. It basically counts how many JPG files there are in the document. """ try: filelist = self.fs.listdir(self.path) count = 0 for filepath in filelist: filen...
[ "def", "_get_nb_pages", "(", "self", ")", ":", "try", ":", "filelist", "=", "self", ".", "fs", ".", "listdir", "(", "self", ".", "path", ")", "count", "=", "0", "for", "filepath", "in", "filelist", ":", "filename", "=", "self", ".", "fs", ".", "bas...
Compute the number of pages in the document. It basically counts how many JPG files there are in the document.
[ "Compute", "the", "number", "of", "pages", "in", "the", "document", ".", "It", "basically", "counts", "how", "many", "JPG", "files", "there", "are", "in", "the", "document", "." ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/img/doc.py#L341-L367
48,843
openpaperwork/paperwork-backend
paperwork_backend/img/doc.py
ImgDoc.steal_page
def steal_page(self, page): """ Steal a page from another document """ if page.doc == self: return self.fs.mkdir_p(self.path) new_page = ImgPage(self, self.nb_pages) logger.info("%s --> %s" % (str(page), str(new_page))) new_page._steal_content...
python
def steal_page(self, page): """ Steal a page from another document """ if page.doc == self: return self.fs.mkdir_p(self.path) new_page = ImgPage(self, self.nb_pages) logger.info("%s --> %s" % (str(page), str(new_page))) new_page._steal_content...
[ "def", "steal_page", "(", "self", ",", "page", ")", ":", "if", "page", ".", "doc", "==", "self", ":", "return", "self", ".", "fs", ".", "mkdir_p", "(", "self", ".", "path", ")", "new_page", "=", "ImgPage", "(", "self", ",", "self", ".", "nb_pages",...
Steal a page from another document
[ "Steal", "a", "page", "from", "another", "document" ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/img/doc.py#L384-L394
48,844
specialunderwear/django-easymode
easymode/utils/__init__.py
recursion_depth
def recursion_depth(key): """ A context manager used to guard recursion depth for some function. Multiple functions can be kept separately because it will be counted per key. Any exceptions raise in the recursive function will reset the counter, because the stack will be unwinded. usage:: ...
python
def recursion_depth(key): """ A context manager used to guard recursion depth for some function. Multiple functions can be kept separately because it will be counted per key. Any exceptions raise in the recursive function will reset the counter, because the stack will be unwinded. usage:: ...
[ "def", "recursion_depth", "(", "key", ")", ":", "try", ":", "if", "not", "getattr", "(", "RECURSION_LEVEL_DICT", ",", "'key'", ",", "False", ")", ":", "RECURSION_LEVEL_DICT", ".", "key", "=", "0", "RECURSION_LEVEL_DICT", ".", "key", "+=", "1", "yield", "RE...
A context manager used to guard recursion depth for some function. Multiple functions can be kept separately because it will be counted per key. Any exceptions raise in the recursive function will reset the counter, because the stack will be unwinded. usage:: with recursion_depth('some_fu...
[ "A", "context", "manager", "used", "to", "guard", "recursion", "depth", "for", "some", "function", ".", "Multiple", "functions", "can", "be", "kept", "separately", "because", "it", "will", "be", "counted", "per", "key", "." ]
92f674b91fb8c54d6e379e2664e2000872d9c95e
https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/easymode/utils/__init__.py#L36-L63
48,845
specialunderwear/django-easymode
easymode/utils/__init__.py
first_match
def first_match(predicate, lst): """ returns the first value of predicate applied to list, which does not return None >>> >>> def return_if_even(x): ... if x % 2 is 0: ... return x ... return None >>> >>> first_match(return_if_even, [1, 3, 4, 7]) 4 >>> fi...
python
def first_match(predicate, lst): """ returns the first value of predicate applied to list, which does not return None >>> >>> def return_if_even(x): ... if x % 2 is 0: ... return x ... return None >>> >>> first_match(return_if_even, [1, 3, 4, 7]) 4 >>> fi...
[ "def", "first_match", "(", "predicate", ",", "lst", ")", ":", "for", "item", "in", "lst", ":", "val", "=", "predicate", "(", "item", ")", "if", "val", "is", "not", "None", ":", "return", "val", "return", "None" ]
returns the first value of predicate applied to list, which does not return None >>> >>> def return_if_even(x): ... if x % 2 is 0: ... return x ... return None >>> >>> first_match(return_if_even, [1, 3, 4, 7]) 4 >>> first_match(return_if_even, [1, 3, 5, 7]) >...
[ "returns", "the", "first", "value", "of", "predicate", "applied", "to", "list", "which", "does", "not", "return", "None" ]
92f674b91fb8c54d6e379e2664e2000872d9c95e
https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/easymode/utils/__init__.py#L65-L90
48,846
specialunderwear/django-easymode
easymode/utils/__init__.py
bases_walker
def bases_walker(cls): """ Loop through all bases of cls >>> str = u'hai' >>> for base in bases_walker(unicode): ... isinstance(str, base) True True :param cls: The class in which we want to loop through the base classes. """ for base in cls.__bases__: yield base ...
python
def bases_walker(cls): """ Loop through all bases of cls >>> str = u'hai' >>> for base in bases_walker(unicode): ... isinstance(str, base) True True :param cls: The class in which we want to loop through the base classes. """ for base in cls.__bases__: yield base ...
[ "def", "bases_walker", "(", "cls", ")", ":", "for", "base", "in", "cls", ".", "__bases__", ":", "yield", "base", "for", "more", "in", "bases_walker", "(", "base", ")", ":", "yield", "more" ]
Loop through all bases of cls >>> str = u'hai' >>> for base in bases_walker(unicode): ... isinstance(str, base) True True :param cls: The class in which we want to loop through the base classes.
[ "Loop", "through", "all", "bases", "of", "cls" ]
92f674b91fb8c54d6e379e2664e2000872d9c95e
https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/easymode/utils/__init__.py#L180-L195
48,847
specialunderwear/django-easymode
easymode/utils/__init__.py
url_add_params
def url_add_params(url, **kwargs): """ Add parameters to an url >>> url_add_params('http://example.com/', a=1, b=3) 'http://example.com/?a=1&b=3' >>> url_add_params('http://example.com/?c=8', a=1, b=3) 'http://example.com/?c=8&a=1&b=3' >>> url_add_params('http://example.com/#/irock', a=1, b...
python
def url_add_params(url, **kwargs): """ Add parameters to an url >>> url_add_params('http://example.com/', a=1, b=3) 'http://example.com/?a=1&b=3' >>> url_add_params('http://example.com/?c=8', a=1, b=3) 'http://example.com/?c=8&a=1&b=3' >>> url_add_params('http://example.com/#/irock', a=1, b...
[ "def", "url_add_params", "(", "url", ",", "*", "*", "kwargs", ")", ":", "parsed_url", "=", "urlparse", ".", "urlsplit", "(", "url", ")", "params", "=", "urlparse", ".", "parse_qsl", "(", "parsed_url", ".", "query", ")", "parsed_url", "=", "list", "(", ...
Add parameters to an url >>> url_add_params('http://example.com/', a=1, b=3) 'http://example.com/?a=1&b=3' >>> url_add_params('http://example.com/?c=8', a=1, b=3) 'http://example.com/?c=8&a=1&b=3' >>> url_add_params('http://example.com/#/irock', a=1, b=3) 'http://example.com/?a=1&b=3#/irock' ...
[ "Add", "parameters", "to", "an", "url" ]
92f674b91fb8c54d6e379e2664e2000872d9c95e
https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/easymode/utils/__init__.py#L197-L218
48,848
xflows/rdm
rdm/wrappers/treeliker/treeliker.py
TreeLiker.run
def run(self, cleanup=True, printOutput=False): ''' Runs TreeLiker with the given settings. :param cleanup: deletes temporary files after completion :param printOutput: print algorithm output to the terminal ''' self._copy_data() self._batch() du...
python
def run(self, cleanup=True, printOutput=False): ''' Runs TreeLiker with the given settings. :param cleanup: deletes temporary files after completion :param printOutput: print algorithm output to the terminal ''' self._copy_data() self._batch() du...
[ "def", "run", "(", "self", ",", "cleanup", "=", "True", ",", "printOutput", "=", "False", ")", ":", "self", ".", "_copy_data", "(", ")", "self", ".", "_batch", "(", ")", "dumpFile", "=", "None", "if", "not", "printOutput", ":", "dumpFile", "=", "temp...
Runs TreeLiker with the given settings. :param cleanup: deletes temporary files after completion :param printOutput: print algorithm output to the terminal
[ "Runs", "TreeLiker", "with", "the", "given", "settings", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/wrappers/treeliker/treeliker.py#L38-L69
48,849
xflows/rdm
rdm/wrappers/treeliker/treeliker.py
TreeLiker._batch
def _batch(self): ''' Creates the batch file to run the experiment. ''' self.batch = '%s/%s.treeliker' % (self.tmpdir, self.basename) commands = [] if not self.test_dataset: commands.append('set(output_type, single)') commands.append("set(examples...
python
def _batch(self): ''' Creates the batch file to run the experiment. ''' self.batch = '%s/%s.treeliker' % (self.tmpdir, self.basename) commands = [] if not self.test_dataset: commands.append('set(output_type, single)') commands.append("set(examples...
[ "def", "_batch", "(", "self", ")", ":", "self", ".", "batch", "=", "'%s/%s.treeliker'", "%", "(", "self", ".", "tmpdir", ",", "self", ".", "basename", ")", "commands", "=", "[", "]", "if", "not", "self", ".", "test_dataset", ":", "commands", ".", "ap...
Creates the batch file to run the experiment.
[ "Creates", "the", "batch", "file", "to", "run", "the", "experiment", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/wrappers/treeliker/treeliker.py#L71-L100
48,850
transitland/mapzen-gtfs
mzgtfs/feed.py
Feed.iterread
def iterread(self, table): """Iteratively read data from a GTFS table. Returns namedtuples.""" self.log('Reading: %s'%table) # Entity class cls = self.FACTORIES[table] f = self._open(table) # csv reader if unicodecsv: data = unicodecsv.reader(f, encoding='utf-8-sig') else: da...
python
def iterread(self, table): """Iteratively read data from a GTFS table. Returns namedtuples.""" self.log('Reading: %s'%table) # Entity class cls = self.FACTORIES[table] f = self._open(table) # csv reader if unicodecsv: data = unicodecsv.reader(f, encoding='utf-8-sig') else: da...
[ "def", "iterread", "(", "self", ",", "table", ")", ":", "self", ".", "log", "(", "'Reading: %s'", "%", "table", ")", "# Entity class", "cls", "=", "self", ".", "FACTORIES", "[", "table", "]", "f", "=", "self", ".", "_open", "(", "table", ")", "# csv ...
Iteratively read data from a GTFS table. Returns namedtuples.
[ "Iteratively", "read", "data", "from", "a", "GTFS", "table", ".", "Returns", "namedtuples", "." ]
d445f1588ed10713eea9a1ca2878eef792121eca
https://github.com/transitland/mapzen-gtfs/blob/d445f1588ed10713eea9a1ca2878eef792121eca/mzgtfs/feed.py#L78-L104
48,851
transitland/mapzen-gtfs
mzgtfs/feed.py
Feed.write
def write(self, filename, entities, sortkey=None, columns=None): """Write entities out to filename in csv format. Note: this doesn't write directly into a Zip archive, because this behavior is difficult to achieve with Zip archives. Use make_zip() to create a new GTFS Zip archive. """ if os.pat...
python
def write(self, filename, entities, sortkey=None, columns=None): """Write entities out to filename in csv format. Note: this doesn't write directly into a Zip archive, because this behavior is difficult to achieve with Zip archives. Use make_zip() to create a new GTFS Zip archive. """ if os.pat...
[ "def", "write", "(", "self", ",", "filename", ",", "entities", ",", "sortkey", "=", "None", ",", "columns", "=", "None", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "filename", ")", ":", "raise", "IOError", "(", "'File exists: %s'", "%", "...
Write entities out to filename in csv format. Note: this doesn't write directly into a Zip archive, because this behavior is difficult to achieve with Zip archives. Use make_zip() to create a new GTFS Zip archive.
[ "Write", "entities", "out", "to", "filename", "in", "csv", "format", "." ]
d445f1588ed10713eea9a1ca2878eef792121eca
https://github.com/transitland/mapzen-gtfs/blob/d445f1588ed10713eea9a1ca2878eef792121eca/mzgtfs/feed.py#L130-L152
48,852
transitland/mapzen-gtfs
mzgtfs/feed.py
Feed.make_zip
def make_zip(self, filename, files=None, path=None, clone=None, compress=True): """Create a Zip archive. Provide any of the following: files - A list of files path - A directory of .txt files clone - Copy any files from a zip archive not specified above Duplicate files will be ignored. T...
python
def make_zip(self, filename, files=None, path=None, clone=None, compress=True): """Create a Zip archive. Provide any of the following: files - A list of files path - A directory of .txt files clone - Copy any files from a zip archive not specified above Duplicate files will be ignored. T...
[ "def", "make_zip", "(", "self", ",", "filename", ",", "files", "=", "None", ",", "path", "=", "None", ",", "clone", "=", "None", ",", "compress", "=", "True", ")", ":", "if", "filename", "and", "os", ".", "path", ".", "exists", "(", "filename", ")"...
Create a Zip archive. Provide any of the following: files - A list of files path - A directory of .txt files clone - Copy any files from a zip archive not specified above Duplicate files will be ignored. The 'files' argument will be used first, then files found in the specified 'path', t...
[ "Create", "a", "Zip", "archive", "." ]
d445f1588ed10713eea9a1ca2878eef792121eca
https://github.com/transitland/mapzen-gtfs/blob/d445f1588ed10713eea9a1ca2878eef792121eca/mzgtfs/feed.py#L154-L205
48,853
transitland/mapzen-gtfs
mzgtfs/feed.py
Feed.shapes
def shapes(self): """Return the route shapes as a dictionary.""" # Todo: Cache? if self._shapes: return self._shapes # Group together by shape_id self.log("Generating shapes...") ret = collections.defaultdict(entities.ShapeLine) for point in self.read('shapes'): ret[point['shape_...
python
def shapes(self): """Return the route shapes as a dictionary.""" # Todo: Cache? if self._shapes: return self._shapes # Group together by shape_id self.log("Generating shapes...") ret = collections.defaultdict(entities.ShapeLine) for point in self.read('shapes'): ret[point['shape_...
[ "def", "shapes", "(", "self", ")", ":", "# Todo: Cache?", "if", "self", ".", "_shapes", ":", "return", "self", ".", "_shapes", "# Group together by shape_id", "self", ".", "log", "(", "\"Generating shapes...\"", ")", "ret", "=", "collections", ".", "defaultdict"...
Return the route shapes as a dictionary.
[ "Return", "the", "route", "shapes", "as", "a", "dictionary", "." ]
d445f1588ed10713eea9a1ca2878eef792121eca
https://github.com/transitland/mapzen-gtfs/blob/d445f1588ed10713eea9a1ca2878eef792121eca/mzgtfs/feed.py#L264-L275
48,854
transitland/mapzen-gtfs
mzgtfs/feed.py
Feed.validate
def validate(self, validator=None, skip_relations=False): """Validate a GTFS :param validator: a ValidationReport :param (bool) skip_relations: skip validation of relations between entities (e.g. stop_times to stops) :return: """ validator = validation.make_validator(validator) self.log('Lo...
python
def validate(self, validator=None, skip_relations=False): """Validate a GTFS :param validator: a ValidationReport :param (bool) skip_relations: skip validation of relations between entities (e.g. stop_times to stops) :return: """ validator = validation.make_validator(validator) self.log('Lo...
[ "def", "validate", "(", "self", ",", "validator", "=", "None", ",", "skip_relations", "=", "False", ")", ":", "validator", "=", "validation", ".", "make_validator", "(", "validator", ")", "self", ".", "log", "(", "'Loading...'", ")", "self", ".", "preload"...
Validate a GTFS :param validator: a ValidationReport :param (bool) skip_relations: skip validation of relations between entities (e.g. stop_times to stops) :return:
[ "Validate", "a", "GTFS" ]
d445f1588ed10713eea9a1ca2878eef792121eca
https://github.com/transitland/mapzen-gtfs/blob/d445f1588ed10713eea9a1ca2878eef792121eca/mzgtfs/feed.py#L293-L339
48,855
edibledinos/pwnypack
pwnypack/shellcode/base.py
BaseEnvironment.alloc_data
def alloc_data(self, value): """ Allocate a piece of data that will be included in the shellcode body. Arguments: value(...): The value to add to the shellcode. Can be bytes or string type. Returns: ~pwnypack.types.Offset: The offset used to addr...
python
def alloc_data(self, value): """ Allocate a piece of data that will be included in the shellcode body. Arguments: value(...): The value to add to the shellcode. Can be bytes or string type. Returns: ~pwnypack.types.Offset: The offset used to addr...
[ "def", "alloc_data", "(", "self", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "six", ".", "binary_type", ")", ":", "return", "self", ".", "_alloc_data", "(", "value", ")", "elif", "isinstance", "(", "value", ",", "six", ".", "text_ty...
Allocate a piece of data that will be included in the shellcode body. Arguments: value(...): The value to add to the shellcode. Can be bytes or string type. Returns: ~pwnypack.types.Offset: The offset used to address the data.
[ "Allocate", "a", "piece", "of", "data", "that", "will", "be", "included", "in", "the", "shellcode", "body", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/shellcode/base.py#L83-L100
48,856
edibledinos/pwnypack
pwnypack/shellcode/base.py
BaseEnvironment.compile
def compile(self, ops): """ Translate a list of operations into its assembler source. Arguments: ops(list): A list of shellcode operations. Returns: str: The assembler source code that implements the shellcode. """ def _compile(): co...
python
def compile(self, ops): """ Translate a list of operations into its assembler source. Arguments: ops(list): A list of shellcode operations. Returns: str: The assembler source code that implements the shellcode. """ def _compile(): co...
[ "def", "compile", "(", "self", ",", "ops", ")", ":", "def", "_compile", "(", ")", ":", "code", "=", "[", "]", "for", "op", "in", "ops", ":", "if", "isinstance", "(", "op", ",", "SyscallInvoke", ")", ":", "code", ".", "extend", "(", "self", ".", ...
Translate a list of operations into its assembler source. Arguments: ops(list): A list of shellcode operations. Returns: str: The assembler source code that implements the shellcode.
[ "Translate", "a", "list", "of", "operations", "into", "its", "assembler", "source", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/shellcode/base.py#L285-L312
48,857
edibledinos/pwnypack
pwnypack/shellcode/base.py
BaseEnvironment.assemble
def assemble(self, ops): """ Assemble a list of operations into executable code. Arguments: ops(list): A list of shellcode operations. Returns: bytes: The executable code that implements the shellcode. """ return pwnypack.asm.asm(self.compile(op...
python
def assemble(self, ops): """ Assemble a list of operations into executable code. Arguments: ops(list): A list of shellcode operations. Returns: bytes: The executable code that implements the shellcode. """ return pwnypack.asm.asm(self.compile(op...
[ "def", "assemble", "(", "self", ",", "ops", ")", ":", "return", "pwnypack", ".", "asm", ".", "asm", "(", "self", ".", "compile", "(", "ops", ")", ",", "target", "=", "self", ".", "target", ")" ]
Assemble a list of operations into executable code. Arguments: ops(list): A list of shellcode operations. Returns: bytes: The executable code that implements the shellcode.
[ "Assemble", "a", "list", "of", "operations", "into", "executable", "code", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/shellcode/base.py#L314-L325
48,858
gopalkoduri/intonation
intonation/utils.py
find_nearest_index
def find_nearest_index(arr, value): """For a given value, the function finds the nearest value in the array and returns its index.""" arr = np.array(arr) index = (abs(arr-value)).argmin() return index
python
def find_nearest_index(arr, value): """For a given value, the function finds the nearest value in the array and returns its index.""" arr = np.array(arr) index = (abs(arr-value)).argmin() return index
[ "def", "find_nearest_index", "(", "arr", ",", "value", ")", ":", "arr", "=", "np", ".", "array", "(", "arr", ")", "index", "=", "(", "abs", "(", "arr", "-", "value", ")", ")", ".", "argmin", "(", ")", "return", "index" ]
For a given value, the function finds the nearest value in the array and returns its index.
[ "For", "a", "given", "value", "the", "function", "finds", "the", "nearest", "value", "in", "the", "array", "and", "returns", "its", "index", "." ]
7f50d2b572755840be960ea990416a7b27f20312
https://github.com/gopalkoduri/intonation/blob/7f50d2b572755840be960ea990416a7b27f20312/intonation/utils.py#L3-L8
48,859
edibledinos/pwnypack
pwnypack/flow.py
SocketChannel.kill
def kill(self): """ Shut down the socket immediately. """ self._socket.shutdown(socket.SHUT_RDWR) self._socket.close()
python
def kill(self): """ Shut down the socket immediately. """ self._socket.shutdown(socket.SHUT_RDWR) self._socket.close()
[ "def", "kill", "(", "self", ")", ":", "self", ".", "_socket", ".", "shutdown", "(", "socket", ".", "SHUT_RDWR", ")", "self", ".", "_socket", ".", "close", "(", ")" ]
Shut down the socket immediately.
[ "Shut", "down", "the", "socket", "immediately", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/flow.py#L218-L224
48,860
edibledinos/pwnypack
pwnypack/flow.py
Flow.read_eof
def read_eof(self, echo=None): """ Read until the channel is closed. Args: echo(bool): Whether to write the read data to stdout. Returns: bytes: The read data. """ d = b'' while True: try: d += self.read(1, ec...
python
def read_eof(self, echo=None): """ Read until the channel is closed. Args: echo(bool): Whether to write the read data to stdout. Returns: bytes: The read data. """ d = b'' while True: try: d += self.read(1, ec...
[ "def", "read_eof", "(", "self", ",", "echo", "=", "None", ")", ":", "d", "=", "b''", "while", "True", ":", "try", ":", "d", "+=", "self", ".", "read", "(", "1", ",", "echo", ")", "except", "EOFError", ":", "return", "d" ]
Read until the channel is closed. Args: echo(bool): Whether to write the read data to stdout. Returns: bytes: The read data.
[ "Read", "until", "the", "channel", "is", "closed", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/flow.py#L408-L424
48,861
edibledinos/pwnypack
pwnypack/flow.py
Flow.read_until
def read_until(self, s, echo=None): """ Read until a certain string is encountered.. Args: s(bytes): The string to wait for. echo(bool): Whether to write the read data to stdout. Returns: bytes: The data up to and including *s*. Raises: ...
python
def read_until(self, s, echo=None): """ Read until a certain string is encountered.. Args: s(bytes): The string to wait for. echo(bool): Whether to write the read data to stdout. Returns: bytes: The data up to and including *s*. Raises: ...
[ "def", "read_until", "(", "self", ",", "s", ",", "echo", "=", "None", ")", ":", "s_len", "=", "len", "(", "s", ")", "buf", "=", "self", ".", "read", "(", "s_len", ",", "echo", ")", "while", "buf", "[", "-", "s_len", ":", "]", "!=", "s", ":", ...
Read until a certain string is encountered.. Args: s(bytes): The string to wait for. echo(bool): Whether to write the read data to stdout. Returns: bytes: The data up to and including *s*. Raises: EOFError: If the channel was closed.
[ "Read", "until", "a", "certain", "string", "is", "encountered", ".." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/flow.py#L426-L447
48,862
edibledinos/pwnypack
pwnypack/flow.py
Flow.write
def write(self, data, echo=None): """ Write data to channel. Args: data(bytes): The data to write to the channel. echo(bool): Whether to echo the written data to stdout. Raises: EOFError: If the channel was closed before all data was sent. ""...
python
def write(self, data, echo=None): """ Write data to channel. Args: data(bytes): The data to write to the channel. echo(bool): Whether to echo the written data to stdout. Raises: EOFError: If the channel was closed before all data was sent. ""...
[ "def", "write", "(", "self", ",", "data", ",", "echo", "=", "None", ")", ":", "if", "echo", "or", "(", "echo", "is", "None", "and", "self", ".", "echo", ")", ":", "sys", ".", "stdout", ".", "write", "(", "data", ".", "decode", "(", "'latin1'", ...
Write data to channel. Args: data(bytes): The data to write to the channel. echo(bool): Whether to echo the written data to stdout. Raises: EOFError: If the channel was closed before all data was sent.
[ "Write", "data", "to", "channel", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/flow.py#L487-L502
48,863
edibledinos/pwnypack
pwnypack/flow.py
Flow.writeline
def writeline(self, line=b'', sep=b'\n', echo=None): """ Write a byte sequences to the channel and terminate it with carriage return and line feed. Args: line(bytes): The line to send. sep(bytes): The separator to use after each line. echo(bool): Whet...
python
def writeline(self, line=b'', sep=b'\n', echo=None): """ Write a byte sequences to the channel and terminate it with carriage return and line feed. Args: line(bytes): The line to send. sep(bytes): The separator to use after each line. echo(bool): Whet...
[ "def", "writeline", "(", "self", ",", "line", "=", "b''", ",", "sep", "=", "b'\\n'", ",", "echo", "=", "None", ")", ":", "self", ".", "writelines", "(", "[", "line", "]", ",", "sep", ",", "echo", ")" ]
Write a byte sequences to the channel and terminate it with carriage return and line feed. Args: line(bytes): The line to send. sep(bytes): The separator to use after each line. echo(bool): Whether to echo the written data to stdout. Raises: EOFE...
[ "Write", "a", "byte", "sequences", "to", "the", "channel", "and", "terminate", "it", "with", "carriage", "return", "and", "line", "feed", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/flow.py#L520-L534
48,864
edibledinos/pwnypack
pwnypack/flow.py
Flow.interact
def interact(self): """ Interact with the socket. This will send all keyboard input to the socket and input from the socket to the console until an EOF occurs. """ sockets = [sys.stdin, self.channel] while True: ready = select.select(sockets, [], [])[0] ...
python
def interact(self): """ Interact with the socket. This will send all keyboard input to the socket and input from the socket to the console until an EOF occurs. """ sockets = [sys.stdin, self.channel] while True: ready = select.select(sockets, [], [])[0] ...
[ "def", "interact", "(", "self", ")", ":", "sockets", "=", "[", "sys", ".", "stdin", ",", "self", ".", "channel", "]", "while", "True", ":", "ready", "=", "select", ".", "select", "(", "sockets", ",", "[", "]", ",", "[", "]", ")", "[", "0", "]",...
Interact with the socket. This will send all keyboard input to the socket and input from the socket to the console until an EOF occurs.
[ "Interact", "with", "the", "socket", ".", "This", "will", "send", "all", "keyboard", "input", "to", "the", "socket", "and", "input", "from", "the", "socket", "to", "the", "console", "until", "an", "EOF", "occurs", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/flow.py#L550-L567
48,865
openpaperwork/paperwork-backend
paperwork_backend/docimport.py
get_possible_importers
def get_possible_importers(file_uris, current_doc=None): """ Return all the importer objects that can handle the specified files. Possible imports may vary depending on the currently active document """ importers = [] for importer in IMPORTERS: if importer.can_import(file_uris, current_...
python
def get_possible_importers(file_uris, current_doc=None): """ Return all the importer objects that can handle the specified files. Possible imports may vary depending on the currently active document """ importers = [] for importer in IMPORTERS: if importer.can_import(file_uris, current_...
[ "def", "get_possible_importers", "(", "file_uris", ",", "current_doc", "=", "None", ")", ":", "importers", "=", "[", "]", "for", "importer", "in", "IMPORTERS", ":", "if", "importer", ".", "can_import", "(", "file_uris", ",", "current_doc", ")", ":", "importe...
Return all the importer objects that can handle the specified files. Possible imports may vary depending on the currently active document
[ "Return", "all", "the", "importer", "objects", "that", "can", "handle", "the", "specified", "files", "." ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/docimport.py#L485-L495
48,866
openpaperwork/paperwork-backend
paperwork_backend/docimport.py
PdfImporter.can_import
def can_import(self, file_uris, current_doc=None): """ Check that the specified file looks like a PDF """ if len(file_uris) <= 0: return False for uri in file_uris: uri = self.fs.safe(uri) if not self.check_file_type(uri): retur...
python
def can_import(self, file_uris, current_doc=None): """ Check that the specified file looks like a PDF """ if len(file_uris) <= 0: return False for uri in file_uris: uri = self.fs.safe(uri) if not self.check_file_type(uri): retur...
[ "def", "can_import", "(", "self", ",", "file_uris", ",", "current_doc", "=", "None", ")", ":", "if", "len", "(", "file_uris", ")", "<=", "0", ":", "return", "False", "for", "uri", "in", "file_uris", ":", "uri", "=", "self", ".", "fs", ".", "safe", ...
Check that the specified file looks like a PDF
[ "Check", "that", "the", "specified", "file", "looks", "like", "a", "PDF" ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/docimport.py#L151-L161
48,867
openpaperwork/paperwork-backend
paperwork_backend/docimport.py
PdfImporter.import_doc
def import_doc(self, file_uris, docsearch, current_doc=None): """ Import the specified PDF file """ doc = None docs = [] pages = [] file_uris = [self.fs.safe(uri) for uri in file_uris] imported = [] for file_uri in file_uris: if docsea...
python
def import_doc(self, file_uris, docsearch, current_doc=None): """ Import the specified PDF file """ doc = None docs = [] pages = [] file_uris = [self.fs.safe(uri) for uri in file_uris] imported = [] for file_uri in file_uris: if docsea...
[ "def", "import_doc", "(", "self", ",", "file_uris", ",", "docsearch", ",", "current_doc", "=", "None", ")", ":", "doc", "=", "None", "docs", "=", "[", "]", "pages", "=", "[", "]", "file_uris", "=", "[", "self", ".", "fs", ".", "safe", "(", "uri", ...
Import the specified PDF file
[ "Import", "the", "specified", "PDF", "file" ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/docimport.py#L163-L199
48,868
openpaperwork/paperwork-backend
paperwork_backend/docimport.py
PdfDirectoryImporter.can_import
def can_import(self, file_uris, current_doc=None): """ Check that the specified file looks like a directory containing many pdf files """ if len(file_uris) <= 0: return False try: for file_uri in file_uris: file_uri = self.fs.safe(f...
python
def can_import(self, file_uris, current_doc=None): """ Check that the specified file looks like a directory containing many pdf files """ if len(file_uris) <= 0: return False try: for file_uri in file_uris: file_uri = self.fs.safe(f...
[ "def", "can_import", "(", "self", ",", "file_uris", ",", "current_doc", "=", "None", ")", ":", "if", "len", "(", "file_uris", ")", "<=", "0", ":", "return", "False", "try", ":", "for", "file_uri", "in", "file_uris", ":", "file_uri", "=", "self", ".", ...
Check that the specified file looks like a directory containing many pdf files
[ "Check", "that", "the", "specified", "file", "looks", "like", "a", "directory", "containing", "many", "pdf", "files" ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/docimport.py#L225-L240
48,869
openpaperwork/paperwork-backend
paperwork_backend/docimport.py
ImageImporter.can_import
def can_import(self, file_uris, current_doc=None): """ Check that the specified file looks like an image supported by PIL """ if len(file_uris) <= 0: return False for file_uri in file_uris: file_uri = self.fs.safe(file_uri) if not self.check_fi...
python
def can_import(self, file_uris, current_doc=None): """ Check that the specified file looks like an image supported by PIL """ if len(file_uris) <= 0: return False for file_uri in file_uris: file_uri = self.fs.safe(file_uri) if not self.check_fi...
[ "def", "can_import", "(", "self", ",", "file_uris", ",", "current_doc", "=", "None", ")", ":", "if", "len", "(", "file_uris", ")", "<=", "0", ":", "return", "False", "for", "file_uri", "in", "file_uris", ":", "file_uri", "=", "self", ".", "fs", ".", ...
Check that the specified file looks like an image supported by PIL
[ "Check", "that", "the", "specified", "file", "looks", "like", "an", "image", "supported", "by", "PIL" ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/docimport.py#L407-L417
48,870
edibledinos/pwnypack
pwnypack/codec.py
xor
def xor(key, data): """ Perform cyclical exclusive or operations on ``data``. The ``key`` can be a an integer *(0 <= key < 256)* or a byte sequence. If the key is smaller than the provided ``data``, the ``key`` will be repeated. Args: key(int or bytes): The key to xor ``data`` with. ...
python
def xor(key, data): """ Perform cyclical exclusive or operations on ``data``. The ``key`` can be a an integer *(0 <= key < 256)* or a byte sequence. If the key is smaller than the provided ``data``, the ``key`` will be repeated. Args: key(int or bytes): The key to xor ``data`` with. ...
[ "def", "xor", "(", "key", ",", "data", ")", ":", "if", "type", "(", "key", ")", "is", "int", ":", "key", "=", "six", ".", "int2byte", "(", "key", ")", "key_len", "=", "len", "(", "key", ")", "return", "b''", ".", "join", "(", "six", ".", "int...
Perform cyclical exclusive or operations on ``data``. The ``key`` can be a an integer *(0 <= key < 256)* or a byte sequence. If the key is smaller than the provided ``data``, the ``key`` will be repeated. Args: key(int or bytes): The key to xor ``data`` with. data(bytes): The data to p...
[ "Perform", "cyclical", "exclusive", "or", "operations", "on", "data", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/codec.py#L41-L75
48,871
edibledinos/pwnypack
pwnypack/codec.py
caesar
def caesar(shift, data, shift_ranges=('az', 'AZ')): """ Apply a caesar cipher to a string. The caesar cipher is a substition cipher where each letter in the given alphabet is replaced by a letter some fixed number down the alphabet. If ``shift`` is ``1``, *A* will become *B*, *B* will become *C*, ...
python
def caesar(shift, data, shift_ranges=('az', 'AZ')): """ Apply a caesar cipher to a string. The caesar cipher is a substition cipher where each letter in the given alphabet is replaced by a letter some fixed number down the alphabet. If ``shift`` is ``1``, *A* will become *B*, *B* will become *C*, ...
[ "def", "caesar", "(", "shift", ",", "data", ",", "shift_ranges", "=", "(", "'az'", ",", "'AZ'", ")", ")", ":", "alphabet", "=", "dict", "(", "(", "chr", "(", "c", ")", ",", "chr", "(", "(", "c", "-", "s", "+", "shift", ")", "%", "(", "e", "...
Apply a caesar cipher to a string. The caesar cipher is a substition cipher where each letter in the given alphabet is replaced by a letter some fixed number down the alphabet. If ``shift`` is ``1``, *A* will become *B*, *B* will become *C*, etc... You can define the alphabets that will be shift by s...
[ "Apply", "a", "caesar", "cipher", "to", "a", "string", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/codec.py#L175-L210
48,872
edibledinos/pwnypack
pwnypack/codec.py
enhex
def enhex(d, separator=''): """ Convert bytes to their hexadecimal representation, optionally joined by a given separator. Args: d(bytes): The data to convert to hexadecimal representation. separator(str): The separator to insert between hexadecimal tuples. Returns: str: Th...
python
def enhex(d, separator=''): """ Convert bytes to their hexadecimal representation, optionally joined by a given separator. Args: d(bytes): The data to convert to hexadecimal representation. separator(str): The separator to insert between hexadecimal tuples. Returns: str: Th...
[ "def", "enhex", "(", "d", ",", "separator", "=", "''", ")", ":", "v", "=", "binascii", ".", "hexlify", "(", "d", ")", ".", "decode", "(", "'ascii'", ")", "if", "separator", ":", "return", "separator", ".", "join", "(", "v", "[", "i", ":", "i", ...
Convert bytes to their hexadecimal representation, optionally joined by a given separator. Args: d(bytes): The data to convert to hexadecimal representation. separator(str): The separator to insert between hexadecimal tuples. Returns: str: The hexadecimal representation of ``d``. ...
[ "Convert", "bytes", "to", "their", "hexadecimal", "representation", "optionally", "joined", "by", "a", "given", "separator", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/codec.py#L234-L261
48,873
edibledinos/pwnypack
pwnypack/codec.py
xor_app
def xor_app(parser, cmd, args): # pragma: no cover """ Xor a value with a key. """ parser.add_argument( '-d', '--dec', help='interpret the key as a decimal integer', dest='type', action='store_const', const=int ) parser.add_argument( '-x', '--hex...
python
def xor_app(parser, cmd, args): # pragma: no cover """ Xor a value with a key. """ parser.add_argument( '-d', '--dec', help='interpret the key as a decimal integer', dest='type', action='store_const', const=int ) parser.add_argument( '-x', '--hex...
[ "def", "xor_app", "(", "parser", ",", "cmd", ",", "args", ")", ":", "# pragma: no cover", "parser", ".", "add_argument", "(", "'-d'", ",", "'--dec'", ",", "help", "=", "'interpret the key as a decimal integer'", ",", "dest", "=", "'type'", ",", "action", "=", ...
Xor a value with a key.
[ "Xor", "a", "value", "with", "a", "key", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/codec.py#L410-L436
48,874
edibledinos/pwnypack
pwnypack/codec.py
caesar_app
def caesar_app(parser, cmd, args): # pragma: no cover """ Caesar crypt a value with a key. """ parser.add_argument('shift', type=int, help='the shift to apply') parser.add_argument('value', help='the value to caesar crypt, read from stdin if omitted', nargs='?') parser.add_argument( '-...
python
def caesar_app(parser, cmd, args): # pragma: no cover """ Caesar crypt a value with a key. """ parser.add_argument('shift', type=int, help='the shift to apply') parser.add_argument('value', help='the value to caesar crypt, read from stdin if omitted', nargs='?') parser.add_argument( '-...
[ "def", "caesar_app", "(", "parser", ",", "cmd", ",", "args", ")", ":", "# pragma: no cover", "parser", ".", "add_argument", "(", "'shift'", ",", "type", "=", "int", ",", "help", "=", "'the shift to apply'", ")", "parser", ".", "add_argument", "(", "'value'",...
Caesar crypt a value with a key.
[ "Caesar", "crypt", "a", "value", "with", "a", "key", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/codec.py#L440-L458
48,875
edibledinos/pwnypack
pwnypack/codec.py
rot13_app
def rot13_app(parser, cmd, args): # pragma: no cover """ rot13 encrypt a value. """ parser.add_argument('value', help='the value to rot13, read from stdin if omitted', nargs='?') args = parser.parse_args(args) return rot13(pwnypack.main.string_value_or_stdin(args.value))
python
def rot13_app(parser, cmd, args): # pragma: no cover """ rot13 encrypt a value. """ parser.add_argument('value', help='the value to rot13, read from stdin if omitted', nargs='?') args = parser.parse_args(args) return rot13(pwnypack.main.string_value_or_stdin(args.value))
[ "def", "rot13_app", "(", "parser", ",", "cmd", ",", "args", ")", ":", "# pragma: no cover", "parser", ".", "add_argument", "(", "'value'", ",", "help", "=", "'the value to rot13, read from stdin if omitted'", ",", "nargs", "=", "'?'", ")", "args", "=", "parser",...
rot13 encrypt a value.
[ "rot13", "encrypt", "a", "value", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/codec.py#L462-L469
48,876
edibledinos/pwnypack
pwnypack/codec.py
enb64_app
def enb64_app(parser, cmd, args): # pragma: no cover """ base64 encode a value. """ parser.add_argument('value', help='the value to base64 encode, read from stdin if omitted', nargs='?') args = parser.parse_args(args) return enb64(pwnypack.main.binary_value_or_stdin(args.value))
python
def enb64_app(parser, cmd, args): # pragma: no cover """ base64 encode a value. """ parser.add_argument('value', help='the value to base64 encode, read from stdin if omitted', nargs='?') args = parser.parse_args(args) return enb64(pwnypack.main.binary_value_or_stdin(args.value))
[ "def", "enb64_app", "(", "parser", ",", "cmd", ",", "args", ")", ":", "# pragma: no cover", "parser", ".", "add_argument", "(", "'value'", ",", "help", "=", "'the value to base64 encode, read from stdin if omitted'", ",", "nargs", "=", "'?'", ")", "args", "=", "...
base64 encode a value.
[ "base64", "encode", "a", "value", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/codec.py#L473-L480
48,877
edibledinos/pwnypack
pwnypack/codec.py
deb64_app
def deb64_app(parser, cmd, args): # pragma: no cover """ base64 decode a value. """ parser.add_argument('value', help='the value to base64 decode, read from stdin if omitted', nargs='?') args = parser.parse_args(args) return deb64(pwnypack.main.string_value_or_stdin(args.value))
python
def deb64_app(parser, cmd, args): # pragma: no cover """ base64 decode a value. """ parser.add_argument('value', help='the value to base64 decode, read from stdin if omitted', nargs='?') args = parser.parse_args(args) return deb64(pwnypack.main.string_value_or_stdin(args.value))
[ "def", "deb64_app", "(", "parser", ",", "cmd", ",", "args", ")", ":", "# pragma: no cover", "parser", ".", "add_argument", "(", "'value'", ",", "help", "=", "'the value to base64 decode, read from stdin if omitted'", ",", "nargs", "=", "'?'", ")", "args", "=", "...
base64 decode a value.
[ "base64", "decode", "a", "value", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/codec.py#L484-L491
48,878
edibledinos/pwnypack
pwnypack/codec.py
enhex_app
def enhex_app(parser, cmd, args): # pragma: no cover """ hex encode a value. """ parser.add_argument('value', help='the value to hex encode, read from stdin if omitted', nargs='?') parser.add_argument( '--separator', '-s', default='', help='the separator to place between he...
python
def enhex_app(parser, cmd, args): # pragma: no cover """ hex encode a value. """ parser.add_argument('value', help='the value to hex encode, read from stdin if omitted', nargs='?') parser.add_argument( '--separator', '-s', default='', help='the separator to place between he...
[ "def", "enhex_app", "(", "parser", ",", "cmd", ",", "args", ")", ":", "# pragma: no cover", "parser", ".", "add_argument", "(", "'value'", ",", "help", "=", "'the value to hex encode, read from stdin if omitted'", ",", "nargs", "=", "'?'", ")", "parser", ".", "a...
hex encode a value.
[ "hex", "encode", "a", "value", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/codec.py#L495-L507
48,879
edibledinos/pwnypack
pwnypack/codec.py
dehex_app
def dehex_app(parser, cmd, args): # pragma: no cover """ hex decode a value. """ parser.add_argument('value', help='the value to base64 decode, read from stdin if omitted', nargs='?') args = parser.parse_args(args) return dehex(pwnypack.main.string_value_or_stdin(args.value))
python
def dehex_app(parser, cmd, args): # pragma: no cover """ hex decode a value. """ parser.add_argument('value', help='the value to base64 decode, read from stdin if omitted', nargs='?') args = parser.parse_args(args) return dehex(pwnypack.main.string_value_or_stdin(args.value))
[ "def", "dehex_app", "(", "parser", ",", "cmd", ",", "args", ")", ":", "# pragma: no cover", "parser", ".", "add_argument", "(", "'value'", ",", "help", "=", "'the value to base64 decode, read from stdin if omitted'", ",", "nargs", "=", "'?'", ")", "args", "=", "...
hex decode a value.
[ "hex", "decode", "a", "value", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/codec.py#L511-L518
48,880
edibledinos/pwnypack
pwnypack/codec.py
enurlform_app
def enurlform_app(parser, cmd, args): # pragma: no cover """ encode a series of key=value pairs into a query string. """ parser.add_argument('values', help='the key=value pairs to URL encode', nargs='+') args = parser.parse_args(args) return enurlform(dict(v.split('=', 1) for v in args.values)...
python
def enurlform_app(parser, cmd, args): # pragma: no cover """ encode a series of key=value pairs into a query string. """ parser.add_argument('values', help='the key=value pairs to URL encode', nargs='+') args = parser.parse_args(args) return enurlform(dict(v.split('=', 1) for v in args.values)...
[ "def", "enurlform_app", "(", "parser", ",", "cmd", ",", "args", ")", ":", "# pragma: no cover", "parser", ".", "add_argument", "(", "'values'", ",", "help", "=", "'the key=value pairs to URL encode'", ",", "nargs", "=", "'+'", ")", "args", "=", "parser", ".", ...
encode a series of key=value pairs into a query string.
[ "encode", "a", "series", "of", "key", "=", "value", "pairs", "into", "a", "query", "string", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/codec.py#L522-L529
48,881
edibledinos/pwnypack
pwnypack/codec.py
deurlform_app
def deurlform_app(parser, cmd, args): # pragma: no cover """ decode a query string into its key value pairs. """ parser.add_argument('value', help='the query string to decode') args = parser.parse_args(args) return ' '.join('%s=%s' % (key, value) for key, values in deurlform(args.value).items(...
python
def deurlform_app(parser, cmd, args): # pragma: no cover """ decode a query string into its key value pairs. """ parser.add_argument('value', help='the query string to decode') args = parser.parse_args(args) return ' '.join('%s=%s' % (key, value) for key, values in deurlform(args.value).items(...
[ "def", "deurlform_app", "(", "parser", ",", "cmd", ",", "args", ")", ":", "# pragma: no cover", "parser", ".", "add_argument", "(", "'value'", ",", "help", "=", "'the query string to decode'", ")", "args", "=", "parser", ".", "parse_args", "(", "args", ")", ...
decode a query string into its key value pairs.
[ "decode", "a", "query", "string", "into", "its", "key", "value", "pairs", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/codec.py#L533-L540
48,882
edibledinos/pwnypack
pwnypack/codec.py
frequency_app
def frequency_app(parser, cmd, args): # pragma: no cover """ perform frequency analysis on a value. """ parser.add_argument('value', help='the value to analyse, read from stdin if omitted', nargs='?') args = parser.parse_args(args) data = frequency(six.iterbytes(pwnypack.main.binary_value_or_s...
python
def frequency_app(parser, cmd, args): # pragma: no cover """ perform frequency analysis on a value. """ parser.add_argument('value', help='the value to analyse, read from stdin if omitted', nargs='?') args = parser.parse_args(args) data = frequency(six.iterbytes(pwnypack.main.binary_value_or_s...
[ "def", "frequency_app", "(", "parser", ",", "cmd", ",", "args", ")", ":", "# pragma: no cover", "parser", ".", "add_argument", "(", "'value'", ",", "help", "=", "'the value to analyse, read from stdin if omitted'", ",", "nargs", "=", "'?'", ")", "args", "=", "pa...
perform frequency analysis on a value.
[ "perform", "frequency", "analysis", "on", "a", "value", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/codec.py#L544-L557
48,883
edgeware/python-circuit
circuit/breaker.py
CircuitBreaker.error
def error(self, err=None): """Update the circuit breaker with an error event.""" if self.state == 'half-open': self.test_fail_count = min(self.test_fail_count + 1, 16) self.errors.append(self.clock()) if len(self.errors) > self.maxfail: time = self.clock() - self....
python
def error(self, err=None): """Update the circuit breaker with an error event.""" if self.state == 'half-open': self.test_fail_count = min(self.test_fail_count + 1, 16) self.errors.append(self.clock()) if len(self.errors) > self.maxfail: time = self.clock() - self....
[ "def", "error", "(", "self", ",", "err", "=", "None", ")", ":", "if", "self", ".", "state", "==", "'half-open'", ":", "self", ".", "test_fail_count", "=", "min", "(", "self", ".", "test_fail_count", "+", "1", ",", "16", ")", "self", ".", "errors", ...
Update the circuit breaker with an error event.
[ "Update", "the", "circuit", "breaker", "with", "an", "error", "event", "." ]
a40b107e5d539d3118ff495b03aedc08c3d011eb
https://github.com/edgeware/python-circuit/blob/a40b107e5d539d3118ff495b03aedc08c3d011eb/circuit/breaker.py#L82-L94
48,884
edgeware/python-circuit
circuit/breaker.py
CircuitBreakerSet.context
def context(self, id): """Return a circuit breaker for the given ID.""" if id not in self.circuits: self.circuits[id] = self.factory(self.clock, self.log.getChild(id), self.error_types, self.maxfail, se...
python
def context(self, id): """Return a circuit breaker for the given ID.""" if id not in self.circuits: self.circuits[id] = self.factory(self.clock, self.log.getChild(id), self.error_types, self.maxfail, se...
[ "def", "context", "(", "self", ",", "id", ")", ":", "if", "id", "not", "in", "self", ".", "circuits", ":", "self", ".", "circuits", "[", "id", "]", "=", "self", ".", "factory", "(", "self", ".", "clock", ",", "self", ".", "log", ".", "getChild", ...
Return a circuit breaker for the given ID.
[ "Return", "a", "circuit", "breaker", "for", "the", "given", "ID", "." ]
a40b107e5d539d3118ff495b03aedc08c3d011eb
https://github.com/edgeware/python-circuit/blob/a40b107e5d539d3118ff495b03aedc08c3d011eb/circuit/breaker.py#L182-L191
48,885
edibledinos/pwnypack
pwnypack/shell.py
shell
def shell(_parser, cmd, args): # pragma: no cover """ Start an interactive python interpreter with pwny imported globally. """ parser = argparse.ArgumentParser( prog=_parser.prog, description=_parser.description, ) group = parser.add_mutually_exclusive_group() group.set_de...
python
def shell(_parser, cmd, args): # pragma: no cover """ Start an interactive python interpreter with pwny imported globally. """ parser = argparse.ArgumentParser( prog=_parser.prog, description=_parser.description, ) group = parser.add_mutually_exclusive_group() group.set_de...
[ "def", "shell", "(", "_parser", ",", "cmd", ",", "args", ")", ":", "# pragma: no cover", "parser", "=", "argparse", ".", "ArgumentParser", "(", "prog", "=", "_parser", ".", "prog", ",", "description", "=", "_parser", ".", "description", ",", ")", "group", ...
Start an interactive python interpreter with pwny imported globally.
[ "Start", "an", "interactive", "python", "interpreter", "with", "pwny", "imported", "globally", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/shell.py#L26-L81
48,886
transitland/mapzen-gtfs
mzgtfs/trip.py
Trip.stop_sequence
def stop_sequence(self): """Return the sorted StopTimes for this trip.""" return sorted( self.stop_times(), key=lambda x:int(x.get('stop_sequence')) )
python
def stop_sequence(self): """Return the sorted StopTimes for this trip.""" return sorted( self.stop_times(), key=lambda x:int(x.get('stop_sequence')) )
[ "def", "stop_sequence", "(", "self", ")", ":", "return", "sorted", "(", "self", ".", "stop_times", "(", ")", ",", "key", "=", "lambda", "x", ":", "int", "(", "x", ".", "get", "(", "'stop_sequence'", ")", ")", ")" ]
Return the sorted StopTimes for this trip.
[ "Return", "the", "sorted", "StopTimes", "for", "this", "trip", "." ]
d445f1588ed10713eea9a1ca2878eef792121eca
https://github.com/transitland/mapzen-gtfs/blob/d445f1588ed10713eea9a1ca2878eef792121eca/mzgtfs/trip.py#L37-L42
48,887
asweigart/moosegesture
moosegesture/__init__.py
getGestureAndSegments
def getGestureAndSegments(points): """ Returns a list of tuples. The first item in the tuple is the directional integer, and the second item is a tuple of integers for the start and end indexes of the points that make up the stroke. """ strokes, strokeSegments = _identifyStrokes(points) retu...
python
def getGestureAndSegments(points): """ Returns a list of tuples. The first item in the tuple is the directional integer, and the second item is a tuple of integers for the start and end indexes of the points that make up the stroke. """ strokes, strokeSegments = _identifyStrokes(points) retu...
[ "def", "getGestureAndSegments", "(", "points", ")", ":", "strokes", ",", "strokeSegments", "=", "_identifyStrokes", "(", "points", ")", "return", "list", "(", "zip", "(", "strokes", ",", "strokeSegments", ")", ")" ]
Returns a list of tuples. The first item in the tuple is the directional integer, and the second item is a tuple of integers for the start and end indexes of the points that make up the stroke.
[ "Returns", "a", "list", "of", "tuples", ".", "The", "first", "item", "in", "the", "tuple", "is", "the", "directional", "integer", "and", "the", "second", "item", "is", "a", "tuple", "of", "integers", "for", "the", "start", "and", "end", "indexes", "of", ...
7d7998ac7c91b5a006c48bfd1efddbef85c11e0e
https://github.com/asweigart/moosegesture/blob/7d7998ac7c91b5a006c48bfd1efddbef85c11e0e/moosegesture/__init__.py#L89-L96
48,888
asweigart/moosegesture
moosegesture/__init__.py
levenshteinDistance
def levenshteinDistance(s1, s2): """ Returns the Levenshtein Distance between two strings, `s1` and `s2` as an integer. http://en.wikipedia.org/wiki/Levenshtein_distance The Levenshtein Distance (aka edit distance) is how many changes (i.e. insertions, deletions, substitutions) have to be made ...
python
def levenshteinDistance(s1, s2): """ Returns the Levenshtein Distance between two strings, `s1` and `s2` as an integer. http://en.wikipedia.org/wiki/Levenshtein_distance The Levenshtein Distance (aka edit distance) is how many changes (i.e. insertions, deletions, substitutions) have to be made ...
[ "def", "levenshteinDistance", "(", "s1", ",", "s2", ")", ":", "singleLetterMapping", "=", "{", "DOWNLEFT", ":", "'1'", ",", "DOWN", ":", "'2'", ",", "DOWNRIGHT", ":", "'3'", ",", "LEFT", ":", "'4'", ",", "RIGHT", ":", "'6'", ",", "UPLEFT", ":", "'7'"...
Returns the Levenshtein Distance between two strings, `s1` and `s2` as an integer. http://en.wikipedia.org/wiki/Levenshtein_distance The Levenshtein Distance (aka edit distance) is how many changes (i.e. insertions, deletions, substitutions) have to be made to convert one string into another. ...
[ "Returns", "the", "Levenshtein", "Distance", "between", "two", "strings", "s1", "and", "s2", "as", "an", "integer", "." ]
7d7998ac7c91b5a006c48bfd1efddbef85c11e0e
https://github.com/asweigart/moosegesture/blob/7d7998ac7c91b5a006c48bfd1efddbef85c11e0e/moosegesture/__init__.py#L123-L154
48,889
specialunderwear/django-easymode
easymode/i18n/admin/forms.py
make_localised_form
def make_localised_form(model, form, exclude=None): """ This is a factory function that creates a form for a model with internationalised field. The model should be decorated with the L10N decorater. """ newfields = {} for localized_field in model.localized_fields: # get the...
python
def make_localised_form(model, form, exclude=None): """ This is a factory function that creates a form for a model with internationalised field. The model should be decorated with the L10N decorater. """ newfields = {} for localized_field in model.localized_fields: # get the...
[ "def", "make_localised_form", "(", "model", ",", "form", ",", "exclude", "=", "None", ")", ":", "newfields", "=", "{", "}", "for", "localized_field", "in", "model", ".", "localized_fields", ":", "# get the descriptor, which contains the form field", "default_field_des...
This is a factory function that creates a form for a model with internationalised field. The model should be decorated with the L10N decorater.
[ "This", "is", "a", "factory", "function", "that", "creates", "a", "form", "for", "a", "model", "with", "internationalised", "field", ".", "The", "model", "should", "be", "decorated", "with", "the", "L10N", "decorater", "." ]
92f674b91fb8c54d6e379e2664e2000872d9c95e
https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/easymode/i18n/admin/forms.py#L131-L164
48,890
specialunderwear/django-easymode
easymode/i18n/admin/forms.py
LocalisedForm.save
def save(self, commit=True): """ Override save method to also save the localised fields. """ # set the localised fields for localized_field in self.instance.localized_fields: setattr(self.instance, localized_field, self.cleaned_data[localized_field]) return s...
python
def save(self, commit=True): """ Override save method to also save the localised fields. """ # set the localised fields for localized_field in self.instance.localized_fields: setattr(self.instance, localized_field, self.cleaned_data[localized_field]) return s...
[ "def", "save", "(", "self", ",", "commit", "=", "True", ")", ":", "# set the localised fields", "for", "localized_field", "in", "self", ".", "instance", ".", "localized_fields", ":", "setattr", "(", "self", ".", "instance", ",", "localized_field", ",", "self",...
Override save method to also save the localised fields.
[ "Override", "save", "method", "to", "also", "save", "the", "localised", "fields", "." ]
92f674b91fb8c54d6e379e2664e2000872d9c95e
https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/easymode/i18n/admin/forms.py#L48-L56
48,891
specialunderwear/django-easymode
easymode/i18n/admin/forms.py
LocalisedForm.validate_unique
def validate_unique(self): """ Validates the uniqueness of fields, but also handles the localized_fields. """ form_errors = [] try: super(LocalisedForm, self).validate_unique() except ValidationError as e: form_errors += e.messages # add u...
python
def validate_unique(self): """ Validates the uniqueness of fields, but also handles the localized_fields. """ form_errors = [] try: super(LocalisedForm, self).validate_unique() except ValidationError as e: form_errors += e.messages # add u...
[ "def", "validate_unique", "(", "self", ")", ":", "form_errors", "=", "[", "]", "try", ":", "super", "(", "LocalisedForm", ",", "self", ")", ".", "validate_unique", "(", ")", "except", "ValidationError", "as", "e", ":", "form_errors", "+=", "e", ".", "mes...
Validates the uniqueness of fields, but also handles the localized_fields.
[ "Validates", "the", "uniqueness", "of", "fields", "but", "also", "handles", "the", "localized_fields", "." ]
92f674b91fb8c54d6e379e2664e2000872d9c95e
https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/easymode/i18n/admin/forms.py#L58-L81
48,892
specialunderwear/django-easymode
easymode/i18n/admin/forms.py
LocalisedForm._get_localized_field_checks
def _get_localized_field_checks(self): """ Get the checks we must perform for the localized fields. """ localized_fields_checks = [] for localized_field in self.instance.localized_fields: if self.cleaned_data.get(localized_field) is None: continue ...
python
def _get_localized_field_checks(self): """ Get the checks we must perform for the localized fields. """ localized_fields_checks = [] for localized_field in self.instance.localized_fields: if self.cleaned_data.get(localized_field) is None: continue ...
[ "def", "_get_localized_field_checks", "(", "self", ")", ":", "localized_fields_checks", "=", "[", "]", "for", "localized_field", "in", "self", ".", "instance", ".", "localized_fields", ":", "if", "self", ".", "cleaned_data", ".", "get", "(", "localized_field", "...
Get the checks we must perform for the localized fields.
[ "Get", "the", "checks", "we", "must", "perform", "for", "the", "localized", "fields", "." ]
92f674b91fb8c54d6e379e2664e2000872d9c95e
https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/easymode/i18n/admin/forms.py#L83-L97
48,893
specialunderwear/django-easymode
easymode/i18n/admin/forms.py
LocalisedForm._perform_unique_localized_field_checks
def _perform_unique_localized_field_checks(self, unique_checks): """ Do the checks for the localized fields. """ bad_fields = set() form_errors = [] for (field_name, local_field_name) in unique_checks: lookup_kwargs = {} lookup_value ...
python
def _perform_unique_localized_field_checks(self, unique_checks): """ Do the checks for the localized fields. """ bad_fields = set() form_errors = [] for (field_name, local_field_name) in unique_checks: lookup_kwargs = {} lookup_value ...
[ "def", "_perform_unique_localized_field_checks", "(", "self", ",", "unique_checks", ")", ":", "bad_fields", "=", "set", "(", ")", "form_errors", "=", "[", "]", "for", "(", "field_name", ",", "local_field_name", ")", "in", "unique_checks", ":", "lookup_kwargs", "...
Do the checks for the localized fields.
[ "Do", "the", "checks", "for", "the", "localized", "fields", "." ]
92f674b91fb8c54d6e379e2664e2000872d9c95e
https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/easymode/i18n/admin/forms.py#L99-L129
48,894
openpaperwork/paperwork-backend
paperwork_backend/deps.py
find_missing_modules
def find_missing_modules(): """ look for dependency that setuptools cannot check or that are too painful to install with setuptools """ missing_modules = [] for module in MODULES: try: __import__(module[1]) except ImportError: missing_modules.append(modul...
python
def find_missing_modules(): """ look for dependency that setuptools cannot check or that are too painful to install with setuptools """ missing_modules = [] for module in MODULES: try: __import__(module[1]) except ImportError: missing_modules.append(modul...
[ "def", "find_missing_modules", "(", ")", ":", "missing_modules", "=", "[", "]", "for", "module", "in", "MODULES", ":", "try", ":", "__import__", "(", "module", "[", "1", "]", ")", "except", "ImportError", ":", "missing_modules", ".", "append", "(", "module...
look for dependency that setuptools cannot check or that are too painful to install with setuptools
[ "look", "for", "dependency", "that", "setuptools", "cannot", "check", "or", "that", "are", "too", "painful", "to", "install", "with", "setuptools" ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/deps.py#L63-L75
48,895
specialunderwear/django-easymode
easymode/middleware.py
NoVaryOnCookieSessionMiddleWare.process_response
def process_response(self, request, response): """ If ``request.session was modified``, or if the configuration is to save the session every time, save the changes and set a session cookie. """ try: modified = request.session.modified except AttributeError: ...
python
def process_response(self, request, response): """ If ``request.session was modified``, or if the configuration is to save the session every time, save the changes and set a session cookie. """ try: modified = request.session.modified except AttributeError: ...
[ "def", "process_response", "(", "self", ",", "request", ",", "response", ")", ":", "try", ":", "modified", "=", "request", ".", "session", ".", "modified", "except", "AttributeError", ":", "pass", "else", ":", "if", "modified", "or", "settings", ".", "SESS...
If ``request.session was modified``, or if the configuration is to save the session every time, save the changes and set a session cookie.
[ "If", "request", ".", "session", "was", "modified", "or", "if", "the", "configuration", "is", "to", "save", "the", "session", "every", "time", "save", "the", "changes", "and", "set", "a", "session", "cookie", "." ]
92f674b91fb8c54d6e379e2664e2000872d9c95e
https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/easymode/middleware.py#L85-L110
48,896
saeschdivara/ArangoPy
arangodb/query/simple.py
SimpleQuery.all
def all(cls, collection, skip=None, limit=None): """ Returns all documents of the collection :param collection Collection instance :param skip The number of documents to skip in the query :param limit The maximal amount of documents to return. The skip is applie...
python
def all(cls, collection, skip=None, limit=None): """ Returns all documents of the collection :param collection Collection instance :param skip The number of documents to skip in the query :param limit The maximal amount of documents to return. The skip is applie...
[ "def", "all", "(", "cls", ",", "collection", ",", "skip", "=", "None", ",", "limit", "=", "None", ")", ":", "kwargs", "=", "{", "'skip'", ":", "skip", ",", "'limit'", ":", "limit", ",", "}", "return", "cls", ".", "_construct_query", "(", "name", "=...
Returns all documents of the collection :param collection Collection instance :param skip The number of documents to skip in the query :param limit The maximal amount of documents to return. The skip is applied before the limit restriction. :returns Document list
[ "Returns", "all", "documents", "of", "the", "collection" ]
b924cc57bed71520fc2ef528b917daeb98e10eca
https://github.com/saeschdivara/ArangoPy/blob/b924cc57bed71520fc2ef528b917daeb98e10eca/arangodb/query/simple.py#L14-L31
48,897
saeschdivara/ArangoPy
arangodb/query/simple.py
SimpleQuery.update_by_example
def update_by_example(cls, collection, example_data, new_value, keep_null=False, wait_for_sync=None, limit=None): """ This will find all documents in the collection that match the specified example object, and partially update the document body with the new value specified. Note that doc...
python
def update_by_example(cls, collection, example_data, new_value, keep_null=False, wait_for_sync=None, limit=None): """ This will find all documents in the collection that match the specified example object, and partially update the document body with the new value specified. Note that doc...
[ "def", "update_by_example", "(", "cls", ",", "collection", ",", "example_data", ",", "new_value", ",", "keep_null", "=", "False", ",", "wait_for_sync", "=", "None", ",", "limit", "=", "None", ")", ":", "kwargs", "=", "{", "'newValue'", ":", "new_value", ",...
This will find all documents in the collection that match the specified example object, and partially update the document body with the new value specified. Note that document meta-attributes such as _id, _key, _from, _to etc. cannot be replaced. Note: the limit attribute is not sup...
[ "This", "will", "find", "all", "documents", "in", "the", "collection", "that", "match", "the", "specified", "example", "object", "and", "partially", "update", "the", "document", "body", "with", "the", "new", "value", "specified", ".", "Note", "that", "document...
b924cc57bed71520fc2ef528b917daeb98e10eca
https://github.com/saeschdivara/ArangoPy/blob/b924cc57bed71520fc2ef528b917daeb98e10eca/arangodb/query/simple.py#L59-L99
48,898
saeschdivara/ArangoPy
arangodb/query/simple.py
SimpleQuery.remove_by_example
def remove_by_example(cls, collection, example_data, wait_for_sync=None, limit=None): """ This will find all documents in the collection that match the specified example object. Note: the limit attribute is not supported on sharded collections. Using it will result in an error. ...
python
def remove_by_example(cls, collection, example_data, wait_for_sync=None, limit=None): """ This will find all documents in the collection that match the specified example object. Note: the limit attribute is not supported on sharded collections. Using it will result in an error. ...
[ "def", "remove_by_example", "(", "cls", ",", "collection", ",", "example_data", ",", "wait_for_sync", "=", "None", ",", "limit", "=", "None", ")", ":", "kwargs", "=", "{", "'options'", ":", "{", "'waitForSync'", ":", "wait_for_sync", ",", "'limit'", ":", "...
This will find all documents in the collection that match the specified example object. Note: the limit attribute is not supported on sharded collections. Using it will result in an error. The options attributes waitForSync and limit can given yet without an ecapsulation into a json object. ...
[ "This", "will", "find", "all", "documents", "in", "the", "collection", "that", "match", "the", "specified", "example", "object", "." ]
b924cc57bed71520fc2ef528b917daeb98e10eca
https://github.com/saeschdivara/ArangoPy/blob/b924cc57bed71520fc2ef528b917daeb98e10eca/arangodb/query/simple.py#L143-L173
48,899
saeschdivara/ArangoPy
arangodb/query/simple.py
SimpleIndexQuery.get_by_example_hash
def get_by_example_hash(cls, collection, index_id, example_data, allow_multiple=False, skip=None, limit=None): """ This will find all documents matching a given example, using the specified hash index. :param collection Collection instance :param index_id ID of the index whi...
python
def get_by_example_hash(cls, collection, index_id, example_data, allow_multiple=False, skip=None, limit=None): """ This will find all documents matching a given example, using the specified hash index. :param collection Collection instance :param index_id ID of the index whi...
[ "def", "get_by_example_hash", "(", "cls", ",", "collection", ",", "index_id", ",", "example_data", ",", "allow_multiple", "=", "False", ",", "skip", "=", "None", ",", "limit", "=", "None", ")", ":", "kwargs", "=", "{", "'index'", ":", "index_id", ",", "'...
This will find all documents matching a given example, using the specified hash index. :param collection Collection instance :param index_id ID of the index which should be used for the query :param example_data The example document :param allow_multiple If the query can...
[ "This", "will", "find", "all", "documents", "matching", "a", "given", "example", "using", "the", "specified", "hash", "index", "." ]
b924cc57bed71520fc2ef528b917daeb98e10eca
https://github.com/saeschdivara/ArangoPy/blob/b924cc57bed71520fc2ef528b917daeb98e10eca/arangodb/query/simple.py#L231-L253