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,700
edibledinos/pwnypack
pwnypack/elf.py
ELF.parse_file
def parse_file(self, f): """ Parse an ELF file and fill the class' properties. Arguments: f(file or str): The (path to) the ELF file to read. """ if type(f) is str: self.f = open(f, 'rb') else: self.f = f self._parse_header(se...
python
def parse_file(self, f): """ Parse an ELF file and fill the class' properties. Arguments: f(file or str): The (path to) the ELF file to read. """ if type(f) is str: self.f = open(f, 'rb') else: self.f = f self._parse_header(se...
[ "def", "parse_file", "(", "self", ",", "f", ")", ":", "if", "type", "(", "f", ")", "is", "str", ":", "self", ".", "f", "=", "open", "(", "f", ",", "'rb'", ")", "else", ":", "self", ".", "f", "=", "f", "self", ".", "_parse_header", "(", "self"...
Parse an ELF file and fill the class' properties. Arguments: f(file or str): The (path to) the ELF file to read.
[ "Parse", "an", "ELF", "file", "and", "fill", "the", "class", "properties", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/elf.py#L756-L768
48,701
edibledinos/pwnypack
pwnypack/elf.py
ELF.get_section_header
def get_section_header(self, section): """ Get a specific section header by index or name. Args: section(int or str): The index or name of the section header to return. Returns: :class:`~ELF.SectionHeader`: The section header. Raises: KeyErr...
python
def get_section_header(self, section): """ Get a specific section header by index or name. Args: section(int or str): The index or name of the section header to return. Returns: :class:`~ELF.SectionHeader`: The section header. Raises: KeyErr...
[ "def", "get_section_header", "(", "self", ",", "section", ")", ":", "self", ".", "_ensure_section_headers_loaded", "(", ")", "if", "type", "(", "section", ")", "is", "int", ":", "return", "self", ".", "_section_headers_by_index", "[", "section", "]", "else", ...
Get a specific section header by index or name. Args: section(int or str): The index or name of the section header to return. Returns: :class:`~ELF.SectionHeader`: The section header. Raises: KeyError: The requested section header does not exist.
[ "Get", "a", "specific", "section", "header", "by", "index", "or", "name", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/elf.py#L837-L855
48,702
edibledinos/pwnypack
pwnypack/elf.py
ELF.get_symbol
def get_symbol(self, symbol): """ Get a specific symbol by index or name. Args: symbol(int or str): The index or name of the symbol to return. Returns: ELF.Symbol: The symbol. Raises: KeyError: The requested symbol does not exist. ""...
python
def get_symbol(self, symbol): """ Get a specific symbol by index or name. Args: symbol(int or str): The index or name of the symbol to return. Returns: ELF.Symbol: The symbol. Raises: KeyError: The requested symbol does not exist. ""...
[ "def", "get_symbol", "(", "self", ",", "symbol", ")", ":", "self", ".", "_ensure_symbols_loaded", "(", ")", "if", "type", "(", "symbol", ")", "is", "int", ":", "return", "self", ".", "_symbols_by_index", "[", "symbol", "]", "else", ":", "return", "self",...
Get a specific symbol by index or name. Args: symbol(int or str): The index or name of the symbol to return. Returns: ELF.Symbol: The symbol. Raises: KeyError: The requested symbol does not exist.
[ "Get", "a", "specific", "symbol", "by", "index", "or", "name", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/elf.py#L911-L929
48,703
xflows/rdm
rdm/db/datasource.py
DataSource.connected
def connected(self, tables, cols, find_connections=False): ''' Returns a list of tuples of connected table pairs. :param tables: a list of table names :param cols: a list of column names :param find_connections: set this to True to detect relationships from column na...
python
def connected(self, tables, cols, find_connections=False): ''' Returns a list of tuples of connected table pairs. :param tables: a list of table names :param cols: a list of column names :param find_connections: set this to True to detect relationships from column na...
[ "def", "connected", "(", "self", ",", "tables", ",", "cols", ",", "find_connections", "=", "False", ")", ":", "connected", "=", "defaultdict", "(", "list", ")", "fkeys", "=", "defaultdict", "(", "set", ")", "reverse_fkeys", "=", "{", "}", "pkeys", "=", ...
Returns a list of tuples of connected table pairs. :param tables: a list of table names :param cols: a list of column names :param find_connections: set this to True to detect relationships from column names. :return: a tuple (connected, pkeys, fkeys, reverse_fkeys)
[ "Returns", "a", "list", "of", "tuples", "of", "connected", "table", "pairs", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/db/datasource.py#L49-L87
48,704
edibledinos/pwnypack
pwnypack/marshal.py
pyc_load
def pyc_load(fp): """ Load a .pyc file from a file-like object. Arguments: fp(file): The file-like object to read. Returns: PycFile: The parsed representation of the .pyc file. """ magic_1 = U16(fp.read(2), target=MARSHAL_TARGET) magic_2 = U16(fp.read(2), target=MARSHAL_TA...
python
def pyc_load(fp): """ Load a .pyc file from a file-like object. Arguments: fp(file): The file-like object to read. Returns: PycFile: The parsed representation of the .pyc file. """ magic_1 = U16(fp.read(2), target=MARSHAL_TARGET) magic_2 = U16(fp.read(2), target=MARSHAL_TA...
[ "def", "pyc_load", "(", "fp", ")", ":", "magic_1", "=", "U16", "(", "fp", ".", "read", "(", "2", ")", ",", "target", "=", "MARSHAL_TARGET", ")", "magic_2", "=", "U16", "(", "fp", ".", "read", "(", "2", ")", ",", "target", "=", "MARSHAL_TARGET", "...
Load a .pyc file from a file-like object. Arguments: fp(file): The file-like object to read. Returns: PycFile: The parsed representation of the .pyc file.
[ "Load", "a", ".", "pyc", "file", "from", "a", "file", "-", "like", "object", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/marshal.py#L286-L316
48,705
xflows/rdm
rdm/db/converters.py
ILPConverter.mode
def mode(self, predicate, args, recall=1, head=False): ''' Emits mode declarations in Aleph-like format. :param predicate: predicate name :param args: predicate arguments with input/output specification, e.g.: >>> [('+', 'train'), ('-', 'car')] :param r...
python
def mode(self, predicate, args, recall=1, head=False): ''' Emits mode declarations in Aleph-like format. :param predicate: predicate name :param args: predicate arguments with input/output specification, e.g.: >>> [('+', 'train'), ('-', 'car')] :param r...
[ "def", "mode", "(", "self", ",", "predicate", ",", "args", ",", "recall", "=", "1", ",", "head", "=", "False", ")", ":", "return", "':- mode%s(%s, %s(%s)).'", "%", "(", "'h'", "if", "head", "else", "'b'", ",", "str", "(", "recall", ")", ",", "predica...
Emits mode declarations in Aleph-like format. :param predicate: predicate name :param args: predicate arguments with input/output specification, e.g.: >>> [('+', 'train'), ('-', 'car')] :param recall: recall setting (see `Aleph manual <http://www.cs.ox.ac.uk/activities...
[ "Emits", "mode", "declarations", "in", "Aleph", "-", "like", "format", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/db/converters.py#L51-L64
48,706
xflows/rdm
rdm/db/converters.py
RSDConverter.all_examples
def all_examples(self, pred_name=None): ''' Emits all examples in prolog form for RSD. :param pred_name: override for the emitted predicate name ''' target = self.db.target_table pred_name = pred_name if pred_name else target examples = self.db.rows(target, [...
python
def all_examples(self, pred_name=None): ''' Emits all examples in prolog form for RSD. :param pred_name: override for the emitted predicate name ''' target = self.db.target_table pred_name = pred_name if pred_name else target examples = self.db.rows(target, [...
[ "def", "all_examples", "(", "self", ",", "pred_name", "=", "None", ")", ":", "target", "=", "self", ".", "db", ".", "target_table", "pred_name", "=", "pred_name", "if", "pred_name", "else", "target", "examples", "=", "self", ".", "db", ".", "rows", "(", ...
Emits all examples in prolog form for RSD. :param pred_name: override for the emitted predicate name
[ "Emits", "all", "examples", "in", "prolog", "form", "for", "RSD", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/db/converters.py#L157-L166
48,707
xflows/rdm
rdm/db/converters.py
RSDConverter.background_knowledge
def background_knowledge(self): ''' Emits the background knowledge in prolog form for RSD. ''' modeslist, getters = [self.mode(self.db.target_table, [('+', self.db.target_table)], head=True)], [] for (table, ref_table) in self.db.connected.keys(): if ref_table == self...
python
def background_knowledge(self): ''' Emits the background knowledge in prolog form for RSD. ''' modeslist, getters = [self.mode(self.db.target_table, [('+', self.db.target_table)], head=True)], [] for (table, ref_table) in self.db.connected.keys(): if ref_table == self...
[ "def", "background_knowledge", "(", "self", ")", ":", "modeslist", ",", "getters", "=", "[", "self", ".", "mode", "(", "self", ".", "db", ".", "target_table", ",", "[", "(", "'+'", ",", "self", ".", "db", ".", "target_table", ")", "]", ",", "head", ...
Emits the background knowledge in prolog form for RSD.
[ "Emits", "the", "background", "knowledge", "in", "prolog", "form", "for", "RSD", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/db/converters.py#L168-L187
48,708
xflows/rdm
rdm/db/converters.py
AlephConverter.background_knowledge
def background_knowledge(self): ''' Emits the background knowledge in prolog form for Aleph. ''' modeslist, getters = [self.mode(self.__target_predicate(), [('+', self.db.target_table)], head=True)], [] determinations, types = [], [] for (table, ref_table) in self.db.conn...
python
def background_knowledge(self): ''' Emits the background knowledge in prolog form for Aleph. ''' modeslist, getters = [self.mode(self.__target_predicate(), [('+', self.db.target_table)], head=True)], [] determinations, types = [], [] for (table, ref_table) in self.db.conn...
[ "def", "background_knowledge", "(", "self", ")", ":", "modeslist", ",", "getters", "=", "[", "self", ".", "mode", "(", "self", ".", "__target_predicate", "(", ")", ",", "[", "(", "'+'", ",", "self", ".", "db", ".", "target_table", ")", "]", ",", "hea...
Emits the background knowledge in prolog form for Aleph.
[ "Emits", "the", "background", "knowledge", "in", "prolog", "form", "for", "Aleph", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/db/converters.py#L249-L274
48,709
xflows/rdm
rdm/db/converters.py
OrangeConverter.target_Orange_table
def target_Orange_table(self): ''' Returns the target table as an Orange example table. :rtype: orange.ExampleTable ''' table, cls_att = self.db.target_table, self.db.target_att if not self.db.orng_tables: return self.convert_table(table, cls_att=cls_att)...
python
def target_Orange_table(self): ''' Returns the target table as an Orange example table. :rtype: orange.ExampleTable ''' table, cls_att = self.db.target_table, self.db.target_att if not self.db.orng_tables: return self.convert_table(table, cls_att=cls_att)...
[ "def", "target_Orange_table", "(", "self", ")", ":", "table", ",", "cls_att", "=", "self", ".", "db", ".", "target_table", ",", "self", ".", "db", ".", "target_att", "if", "not", "self", ".", "db", ".", "orng_tables", ":", "return", "self", ".", "conve...
Returns the target table as an Orange example table. :rtype: orange.ExampleTable
[ "Returns", "the", "target", "table", "as", "an", "Orange", "example", "table", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/db/converters.py#L304-L314
48,710
xflows/rdm
rdm/db/converters.py
OrangeConverter.other_Orange_tables
def other_Orange_tables(self): ''' Returns the related tables as Orange example tables. :rtype: list ''' target_table = self.db.target_table if not self.db.orng_tables: return [self.convert_table(table, None) for table in self.db.tables if table != ta...
python
def other_Orange_tables(self): ''' Returns the related tables as Orange example tables. :rtype: list ''' target_table = self.db.target_table if not self.db.orng_tables: return [self.convert_table(table, None) for table in self.db.tables if table != ta...
[ "def", "other_Orange_tables", "(", "self", ")", ":", "target_table", "=", "self", ".", "db", ".", "target_table", "if", "not", "self", ".", "db", ".", "orng_tables", ":", "return", "[", "self", ".", "convert_table", "(", "table", ",", "None", ")", "for",...
Returns the related tables as Orange example tables. :rtype: list
[ "Returns", "the", "related", "tables", "as", "Orange", "example", "tables", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/db/converters.py#L316-L326
48,711
xflows/rdm
rdm/db/converters.py
OrangeConverter.convert_table
def convert_table(self, table_name, cls_att=None): ''' Returns the specified table as an orange example table. :param table_name: table name to convert :cls_att: class attribute name :rtype: orange.ExampleTable ''' import Orange cols = self.d...
python
def convert_table(self, table_name, cls_att=None): ''' Returns the specified table as an orange example table. :param table_name: table name to convert :cls_att: class attribute name :rtype: orange.ExampleTable ''' import Orange cols = self.d...
[ "def", "convert_table", "(", "self", ",", "table_name", ",", "cls_att", "=", "None", ")", ":", "import", "Orange", "cols", "=", "self", ".", "db", ".", "cols", "[", "table_name", "]", "attributes", ",", "metas", ",", "class_var", "=", "[", "]", ",", ...
Returns the specified table as an orange example table. :param table_name: table name to convert :cls_att: class attribute name :rtype: orange.ExampleTable
[ "Returns", "the", "specified", "table", "as", "an", "orange", "example", "table", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/db/converters.py#L328-L369
48,712
xflows/rdm
rdm/db/converters.py
OrangeConverter.orng_type
def orng_type(self, table_name, col): ''' Returns an Orange datatype for a given mysql column. :param table_name: target table name :param col: column to determine the Orange datatype ''' mysql_type = self.types[table_name][col] n_vals = len(self.db.col_v...
python
def orng_type(self, table_name, col): ''' Returns an Orange datatype for a given mysql column. :param table_name: target table name :param col: column to determine the Orange datatype ''' mysql_type = self.types[table_name][col] n_vals = len(self.db.col_v...
[ "def", "orng_type", "(", "self", ",", "table_name", ",", "col", ")", ":", "mysql_type", "=", "self", ".", "types", "[", "table_name", "]", "[", "col", "]", "n_vals", "=", "len", "(", "self", ".", "db", ".", "col_vals", "[", "table_name", "]", "[", ...
Returns an Orange datatype for a given mysql column. :param table_name: target table name :param col: column to determine the Orange datatype
[ "Returns", "an", "Orange", "datatype", "for", "a", "given", "mysql", "column", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/db/converters.py#L371-L386
48,713
xflows/rdm
rdm/db/converters.py
TreeLikerConverter._discretize_check
def _discretize_check(self, table, att, col): ''' Replaces the value with an appropriate interval symbol, if available. ''' label = "'%s'" % col if table in self.discr_intervals and att in self.discr_intervals[table]: intervals = self.discr_intervals[table][att] ...
python
def _discretize_check(self, table, att, col): ''' Replaces the value with an appropriate interval symbol, if available. ''' label = "'%s'" % col if table in self.discr_intervals and att in self.discr_intervals[table]: intervals = self.discr_intervals[table][att] ...
[ "def", "_discretize_check", "(", "self", ",", "table", ",", "att", ",", "col", ")", ":", "label", "=", "\"'%s'\"", "%", "col", "if", "table", "in", "self", ".", "discr_intervals", "and", "att", "in", "self", ".", "discr_intervals", "[", "table", "]", "...
Replaces the value with an appropriate interval symbol, if available.
[ "Replaces", "the", "value", "with", "an", "appropriate", "interval", "symbol", "if", "available", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/db/converters.py#L516-L545
48,714
xflows/rdm
rdm/db/converters.py
TreeLikerConverter.dataset
def dataset(self): ''' Returns the DBContext as a list of interpretations, i.e., a list of facts true for each example in the format for TreeLiker. ''' target = self.db.target_table db_examples = self.db.rows(target, [self.db.target_att, self.db.pkeys[target]]) e...
python
def dataset(self): ''' Returns the DBContext as a list of interpretations, i.e., a list of facts true for each example in the format for TreeLiker. ''' target = self.db.target_table db_examples = self.db.rows(target, [self.db.target_att, self.db.pkeys[target]]) e...
[ "def", "dataset", "(", "self", ")", ":", "target", "=", "self", ".", "db", ".", "target_table", "db_examples", "=", "self", ".", "db", ".", "rows", "(", "target", ",", "[", "self", ".", "db", ".", "target_att", ",", "self", ".", "db", ".", "pkeys",...
Returns the DBContext as a list of interpretations, i.e., a list of facts true for each example in the format for TreeLiker.
[ "Returns", "the", "DBContext", "as", "a", "list", "of", "interpretations", "i", ".", "e", ".", "a", "list", "of", "facts", "true", "for", "each", "example", "in", "the", "format", "for", "TreeLiker", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/db/converters.py#L547-L560
48,715
xflows/rdm
rdm/db/converters.py
PrdFctConverter.create_prd_file
def create_prd_file(self): ''' Emits the background knowledge in prd format. ''' prd_str = '' prd_str += '--INDIVIDUAL\n' prd_str += '%s 1 %s cwa\n' % (self.db.target_table, self.db.target_table) prd_str += '--STRUCTURAL\n' for ftable, ptable in self.db.re...
python
def create_prd_file(self): ''' Emits the background knowledge in prd format. ''' prd_str = '' prd_str += '--INDIVIDUAL\n' prd_str += '%s 1 %s cwa\n' % (self.db.target_table, self.db.target_table) prd_str += '--STRUCTURAL\n' for ftable, ptable in self.db.re...
[ "def", "create_prd_file", "(", "self", ")", ":", "prd_str", "=", "''", "prd_str", "+=", "'--INDIVIDUAL\\n'", "prd_str", "+=", "'%s 1 %s cwa\\n'", "%", "(", "self", ".", "db", ".", "target_table", ",", "self", ".", "db", ".", "target_table", ")", "prd_str", ...
Emits the background knowledge in prd format.
[ "Emits", "the", "background", "knowledge", "in", "prd", "format", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/db/converters.py#L583-L600
48,716
xflows/rdm
rdm/db/converters.py
PrdFctConverter.create_fct_file
def create_fct_file(self): ''' Emits examples in fct format. ''' fct_str = '' fct_str += self.fct_rec(self.db.target_table) return fct_str
python
def create_fct_file(self): ''' Emits examples in fct format. ''' fct_str = '' fct_str += self.fct_rec(self.db.target_table) return fct_str
[ "def", "create_fct_file", "(", "self", ")", ":", "fct_str", "=", "''", "fct_str", "+=", "self", ".", "fct_rec", "(", "self", ".", "db", ".", "target_table", ")", "return", "fct_str" ]
Emits examples in fct format.
[ "Emits", "examples", "in", "fct", "format", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/db/converters.py#L602-L608
48,717
transitland/mapzen-gtfs
mzgtfs/geom.py
convex_hull
def convex_hull(features): """Returns points on convex hull of an array of points in CCW order.""" points = sorted([s.point() for s in features]) l = reduce(_keep_left, points, []) u = reduce(_keep_left, reversed(points), []) return l.extend(u[i] for i in xrange(1, len(u) - 1)) or l
python
def convex_hull(features): """Returns points on convex hull of an array of points in CCW order.""" points = sorted([s.point() for s in features]) l = reduce(_keep_left, points, []) u = reduce(_keep_left, reversed(points), []) return l.extend(u[i] for i in xrange(1, len(u) - 1)) or l
[ "def", "convex_hull", "(", "features", ")", ":", "points", "=", "sorted", "(", "[", "s", ".", "point", "(", ")", "for", "s", "in", "features", "]", ")", "l", "=", "reduce", "(", "_keep_left", ",", "points", ",", "[", "]", ")", "u", "=", "reduce",...
Returns points on convex hull of an array of points in CCW order.
[ "Returns", "points", "on", "convex", "hull", "of", "an", "array", "of", "points", "in", "CCW", "order", "." ]
d445f1588ed10713eea9a1ca2878eef792121eca
https://github.com/transitland/mapzen-gtfs/blob/d445f1588ed10713eea9a1ca2878eef792121eca/mzgtfs/geom.py#L30-L35
48,718
edibledinos/pwnypack
pwnypack/bytecode.py
CodeObject.disassemble
def disassemble(self, annotate=False, blocks=False): """ Disassemble the bytecode of this code object into a series of opcodes and labels. Can also annotate the opcodes and group the opcodes into blocks based on the labels. Arguments: annotate(bool): Whether to annot...
python
def disassemble(self, annotate=False, blocks=False): """ Disassemble the bytecode of this code object into a series of opcodes and labels. Can also annotate the opcodes and group the opcodes into blocks based on the labels. Arguments: annotate(bool): Whether to annot...
[ "def", "disassemble", "(", "self", ",", "annotate", "=", "False", ",", "blocks", "=", "False", ")", ":", "ops", "=", "disassemble", "(", "self", ".", "co_code", ",", "self", ".", "internals", ")", "if", "annotate", ":", "ops", "=", "[", "self", ".", ...
Disassemble the bytecode of this code object into a series of opcodes and labels. Can also annotate the opcodes and group the opcodes into blocks based on the labels. Arguments: annotate(bool): Whether to annotate the operations. blocks(bool): Whether to group the operat...
[ "Disassemble", "the", "bytecode", "of", "this", "code", "object", "into", "a", "series", "of", "opcodes", "and", "labels", ".", "Can", "also", "annotate", "the", "opcodes", "and", "group", "the", "opcodes", "into", "blocks", "based", "on", "the", "labels", ...
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/bytecode.py#L607-L630
48,719
edibledinos/pwnypack
pwnypack/bytecode.py
CodeObject.to_code
def to_code(self): """ Convert this instance back into a native python code object. This only works if the internals of the code object are compatible with those of the running python version. Returns: types.CodeType: The native python code object. """ ...
python
def to_code(self): """ Convert this instance back into a native python code object. This only works if the internals of the code object are compatible with those of the running python version. Returns: types.CodeType: The native python code object. """ ...
[ "def", "to_code", "(", "self", ")", ":", "if", "self", ".", "internals", "is", "not", "get_py_internals", "(", ")", ":", "raise", "ValueError", "(", "'CodeObject is not compatible with the running python internals.'", ")", "if", "six", ".", "PY2", ":", "return", ...
Convert this instance back into a native python code object. This only works if the internals of the code object are compatible with those of the running python version. Returns: types.CodeType: The native python code object.
[ "Convert", "this", "instance", "back", "into", "a", "native", "python", "code", "object", ".", "This", "only", "works", "if", "the", "internals", "of", "the", "code", "object", "are", "compatible", "with", "those", "of", "the", "running", "python", "version"...
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/bytecode.py#L653-L677
48,720
openpaperwork/paperwork-backend
paperwork_backend/docsearch.py
DocSearch.reload_index
def reload_index(self, progress_cb=dummy_progress_cb): """ Read the index, and load the document list from it Arguments: callback --- called during the indexation (may be called *often*). step : DocSearch.INDEX_STEP_READING or DocSearch.INDEX_STEP...
python
def reload_index(self, progress_cb=dummy_progress_cb): """ Read the index, and load the document list from it Arguments: callback --- called during the indexation (may be called *often*). step : DocSearch.INDEX_STEP_READING or DocSearch.INDEX_STEP...
[ "def", "reload_index", "(", "self", ",", "progress_cb", "=", "dummy_progress_cb", ")", ":", "nb_results", "=", "self", ".", "index", ".", "start_reload_index", "(", ")", "progress", "=", "0", "while", "self", ".", "index", ".", "continue_reload_index", "(", ...
Read the index, and load the document list from it Arguments: callback --- called during the indexation (may be called *often*). step : DocSearch.INDEX_STEP_READING or DocSearch.INDEX_STEP_SORTING progression : how many elements done yet ...
[ "Read", "the", "index", "and", "load", "the", "document", "list", "from", "it" ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/docsearch.py#L308-L327
48,721
openpaperwork/paperwork-backend
paperwork_backend/docsearch.py
DocSearch.update_label
def update_label(self, old_label, new_label, callback=dummy_progress_cb): """ Replace 'old_label' by 'new_label' on all the documents. Takes care of updating the index. """ current = 0 total = self.index.get_nb_docs() self.index.start_update_label(old_label, new_l...
python
def update_label(self, old_label, new_label, callback=dummy_progress_cb): """ Replace 'old_label' by 'new_label' on all the documents. Takes care of updating the index. """ current = 0 total = self.index.get_nb_docs() self.index.start_update_label(old_label, new_l...
[ "def", "update_label", "(", "self", ",", "old_label", ",", "new_label", ",", "callback", "=", "dummy_progress_cb", ")", ":", "current", "=", "0", "total", "=", "self", ".", "index", ".", "get_nb_docs", "(", ")", "self", ".", "index", ".", "start_update_lab...
Replace 'old_label' by 'new_label' on all the documents. Takes care of updating the index.
[ "Replace", "old_label", "by", "new_label", "on", "all", "the", "documents", ".", "Takes", "care", "of", "updating", "the", "index", "." ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/docsearch.py#L405-L419
48,722
openpaperwork/paperwork-backend
paperwork_backend/docsearch.py
DocSearch.destroy_label
def destroy_label(self, label, callback=dummy_progress_cb): """ Remove the label 'label' from all the documents. Takes care of updating the index. """ current = 0 total = self.index.get_nb_docs() self.index.start_destroy_label(label) while True: ...
python
def destroy_label(self, label, callback=dummy_progress_cb): """ Remove the label 'label' from all the documents. Takes care of updating the index. """ current = 0 total = self.index.get_nb_docs() self.index.start_destroy_label(label) while True: ...
[ "def", "destroy_label", "(", "self", ",", "label", ",", "callback", "=", "dummy_progress_cb", ")", ":", "current", "=", "0", "total", "=", "self", ".", "index", ".", "get_nb_docs", "(", ")", "self", ".", "index", ".", "start_destroy_label", "(", "label", ...
Remove the label 'label' from all the documents. Takes care of updating the index.
[ "Remove", "the", "label", "label", "from", "all", "the", "documents", ".", "Takes", "care", "of", "updating", "the", "index", "." ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/docsearch.py#L421-L435
48,723
xflows/rdm
rdm/db/library.py
_update_context
def _update_context(context, postdata): ''' Updates the default selections with user's selections. ''' listCheck = lambda el: el[0] if type(el) == list else el # For handling lists of size 1 widget_id = listCheck(postdata.get('widget_id')) context.target_table = listCheck(postdata.get('target_t...
python
def _update_context(context, postdata): ''' Updates the default selections with user's selections. ''' listCheck = lambda el: el[0] if type(el) == list else el # For handling lists of size 1 widget_id = listCheck(postdata.get('widget_id')) context.target_table = listCheck(postdata.get('target_t...
[ "def", "_update_context", "(", "context", ",", "postdata", ")", ":", "listCheck", "=", "lambda", "el", ":", "el", "[", "0", "]", "if", "type", "(", "el", ")", "==", "list", "else", "el", "# For handling lists of size 1", "widget_id", "=", "listCheck", "(",...
Updates the default selections with user's selections.
[ "Updates", "the", "default", "selections", "with", "user", "s", "selections", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/db/library.py#L39-L66
48,724
xflows/rdm
rdm/db/library.py
do_map
def do_map(input_dict, feature_format, positive_class=None): ''' Maps a new example to a set of features. ''' # Context of the unseen example(s) train_context = input_dict['train_ctx'] test_context = input_dict['test_ctx'] # Currently known examples & background knowledge features = inp...
python
def do_map(input_dict, feature_format, positive_class=None): ''' Maps a new example to a set of features. ''' # Context of the unseen example(s) train_context = input_dict['train_ctx'] test_context = input_dict['test_ctx'] # Currently known examples & background knowledge features = inp...
[ "def", "do_map", "(", "input_dict", ",", "feature_format", ",", "positive_class", "=", "None", ")", ":", "# Context of the unseen example(s)", "train_context", "=", "input_dict", "[", "'train_ctx'", "]", "test_context", "=", "input_dict", "[", "'test_ctx'", "]", "# ...
Maps a new example to a set of features.
[ "Maps", "a", "new", "example", "to", "a", "set", "of", "features", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/db/library.py#L133-L148
48,725
specialunderwear/django-easymode
easymode/tree/xml/serializers.py
RecursiveXmlSerializer.serialize
def serialize(self, queryset, **options): """ Serialize a queryset. THE OUTPUT OF THIS SERIALIZER IS NOT MEANT TO BE SERIALIZED BACK INTO THE DB. """ self.options = options self.stream = options.get("stream", StringIO()) self.selected_fields = opt...
python
def serialize(self, queryset, **options): """ Serialize a queryset. THE OUTPUT OF THIS SERIALIZER IS NOT MEANT TO BE SERIALIZED BACK INTO THE DB. """ self.options = options self.stream = options.get("stream", StringIO()) self.selected_fields = opt...
[ "def", "serialize", "(", "self", ",", "queryset", ",", "*", "*", "options", ")", ":", "self", ".", "options", "=", "options", "self", ".", "stream", "=", "options", ".", "get", "(", "\"stream\"", ",", "StringIO", "(", ")", ")", "self", ".", "selected...
Serialize a queryset. THE OUTPUT OF THIS SERIALIZER IS NOT MEANT TO BE SERIALIZED BACK INTO THE DB.
[ "Serialize", "a", "queryset", ".", "THE", "OUTPUT", "OF", "THIS", "SERIALIZER", "IS", "NOT", "MEANT", "TO", "BE", "SERIALIZED", "BACK", "INTO", "THE", "DB", "." ]
92f674b91fb8c54d6e379e2664e2000872d9c95e
https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/easymode/tree/xml/serializers.py#L44-L67
48,726
specialunderwear/django-easymode
easymode/tree/xml/serializers.py
RecursiveXmlSerializer.serialize_object
def serialize_object(self, obj): """ Write one item to the object stream """ self.start_object(obj) for field in obj._meta.local_fields: if field.serialize and getattr(field, 'include_in_xml', True): if field.rel is None: if self.se...
python
def serialize_object(self, obj): """ Write one item to the object stream """ self.start_object(obj) for field in obj._meta.local_fields: if field.serialize and getattr(field, 'include_in_xml', True): if field.rel is None: if self.se...
[ "def", "serialize_object", "(", "self", ",", "obj", ")", ":", "self", ".", "start_object", "(", "obj", ")", "for", "field", "in", "obj", ".", "_meta", ".", "local_fields", ":", "if", "field", ".", "serialize", "and", "getattr", "(", "field", ",", "'inc...
Write one item to the object stream
[ "Write", "one", "item", "to", "the", "object", "stream" ]
92f674b91fb8c54d6e379e2664e2000872d9c95e
https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/easymode/tree/xml/serializers.py#L69-L121
48,727
specialunderwear/django-easymode
easymode/tree/xml/serializers.py
RecursiveXmlSerializer.handle_m2m_field
def handle_m2m_field(self, obj, field): """ while easymode follows inverse relations for foreign keys, for manytomayfields it follows the forward relation. While easymode excludes all relations to "self" you could still create a loop if you add one extra level of indirec...
python
def handle_m2m_field(self, obj, field): """ while easymode follows inverse relations for foreign keys, for manytomayfields it follows the forward relation. While easymode excludes all relations to "self" you could still create a loop if you add one extra level of indirec...
[ "def", "handle_m2m_field", "(", "self", ",", "obj", ",", "field", ")", ":", "if", "field", ".", "rel", ".", "through", ".", "_meta", ".", "auto_created", ":", "# and obj.__class__ is not field.rel.to:", "# keep approximate recursion level", "with", "recursion_depth",...
while easymode follows inverse relations for foreign keys, for manytomayfields it follows the forward relation. While easymode excludes all relations to "self" you could still create a loop if you add one extra level of indirection.
[ "while", "easymode", "follows", "inverse", "relations", "for", "foreign", "keys", "for", "manytomayfields", "it", "follows", "the", "forward", "relation", ".", "While", "easymode", "excludes", "all", "relations", "to", "self", "you", "could", "still", "create", ...
92f674b91fb8c54d6e379e2664e2000872d9c95e
https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/easymode/tree/xml/serializers.py#L204-L227
48,728
edibledinos/pwnypack
pwnypack/asm.py
prepare_capstone
def prepare_capstone(syntax=AsmSyntax.att, target=None): """ Prepare a capstone disassembler instance for a given target and syntax. Args: syntax(AsmSyntax): The assembler syntax (Intel or AT&T). target(~pwnypack.target.Target): The target to create a disassembler instance for. ...
python
def prepare_capstone(syntax=AsmSyntax.att, target=None): """ Prepare a capstone disassembler instance for a given target and syntax. Args: syntax(AsmSyntax): The assembler syntax (Intel or AT&T). target(~pwnypack.target.Target): The target to create a disassembler instance for. ...
[ "def", "prepare_capstone", "(", "syntax", "=", "AsmSyntax", ".", "att", ",", "target", "=", "None", ")", ":", "if", "not", "HAVE_CAPSTONE", ":", "raise", "NotImplementedError", "(", "'pwnypack requires capstone to disassemble to AT&T and Intel syntax'", ")", "if", "ta...
Prepare a capstone disassembler instance for a given target and syntax. Args: syntax(AsmSyntax): The assembler syntax (Intel or AT&T). target(~pwnypack.target.Target): The target to create a disassembler instance for. The global target is used if this argument is ``None``. ...
[ "Prepare", "a", "capstone", "disassembler", "instance", "for", "a", "given", "target", "and", "syntax", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/asm.py#L320-L384
48,729
edibledinos/pwnypack
pwnypack/asm.py
disasm
def disasm(code, addr=0, syntax=None, target=None): """ Disassemble machine readable code into human readable statements. Args: code(bytes): The machine code that is to be disassembled. addr(int): The memory address of the code (used for relative references). syntax(AsmS...
python
def disasm(code, addr=0, syntax=None, target=None): """ Disassemble machine readable code into human readable statements. Args: code(bytes): The machine code that is to be disassembled. addr(int): The memory address of the code (used for relative references). syntax(AsmS...
[ "def", "disasm", "(", "code", ",", "addr", "=", "0", ",", "syntax", "=", "None", ",", "target", "=", "None", ")", ":", "if", "target", "is", "None", ":", "target", "=", "pwnypack", ".", "target", ".", "target", "if", "syntax", "is", "None", ":", ...
Disassemble machine readable code into human readable statements. Args: code(bytes): The machine code that is to be disassembled. addr(int): The memory address of the code (used for relative references). syntax(AsmSyntax): The output assembler syntax. This defaults to ...
[ "Disassemble", "machine", "readable", "code", "into", "human", "readable", "statements", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/asm.py#L387-L458
48,730
edibledinos/pwnypack
pwnypack/asm.py
asm_app
def asm_app(parser, cmd, args): # pragma: no cover """ Assemble code from commandline or stdin. Please not that all semi-colons are replaced with carriage returns unless source is read from stdin. """ parser.add_argument('source', help='the code to assemble, read from stdin if omitted', nargs...
python
def asm_app(parser, cmd, args): # pragma: no cover """ Assemble code from commandline or stdin. Please not that all semi-colons are replaced with carriage returns unless source is read from stdin. """ parser.add_argument('source', help='the code to assemble, read from stdin if omitted', nargs...
[ "def", "asm_app", "(", "parser", ",", "cmd", ",", "args", ")", ":", "# pragma: no cover", "parser", ".", "add_argument", "(", "'source'", ",", "help", "=", "'the code to assemble, read from stdin if omitted'", ",", "nargs", "=", "'?'", ")", "pwnypack", ".", "mai...
Assemble code from commandline or stdin. Please not that all semi-colons are replaced with carriage returns unless source is read from stdin.
[ "Assemble", "code", "from", "commandline", "or", "stdin", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/asm.py#L462-L500
48,731
edibledinos/pwnypack
pwnypack/asm.py
disasm_app
def disasm_app(_parser, cmd, args): # pragma: no cover """ Disassemble code from commandline or stdin. """ parser = argparse.ArgumentParser( prog=_parser.prog, description=_parser.description, ) parser.add_argument('code', help='the code to disassemble, read from stdin if omitt...
python
def disasm_app(_parser, cmd, args): # pragma: no cover """ Disassemble code from commandline or stdin. """ parser = argparse.ArgumentParser( prog=_parser.prog, description=_parser.description, ) parser.add_argument('code', help='the code to disassemble, read from stdin if omitt...
[ "def", "disasm_app", "(", "_parser", ",", "cmd", ",", "args", ")", ":", "# pragma: no cover", "parser", "=", "argparse", ".", "ArgumentParser", "(", "prog", "=", "_parser", ".", "prog", ",", "description", "=", "_parser", ".", "description", ",", ")", "par...
Disassemble code from commandline or stdin.
[ "Disassemble", "code", "from", "commandline", "or", "stdin", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/asm.py#L504-L550
48,732
edibledinos/pwnypack
pwnypack/asm.py
disasm_symbol_app
def disasm_symbol_app(_parser, _, args): # pragma: no cover """ Disassemble a symbol from an ELF file. """ parser = argparse.ArgumentParser( prog=_parser.prog, description=_parser.description, ) parser.add_argument( '--syntax', '-s', choices=AsmSyntax.__members_...
python
def disasm_symbol_app(_parser, _, args): # pragma: no cover """ Disassemble a symbol from an ELF file. """ parser = argparse.ArgumentParser( prog=_parser.prog, description=_parser.description, ) parser.add_argument( '--syntax', '-s', choices=AsmSyntax.__members_...
[ "def", "disasm_symbol_app", "(", "_parser", ",", "_", ",", "args", ")", ":", "# pragma: no cover", "parser", "=", "argparse", ".", "ArgumentParser", "(", "prog", "=", "_parser", ".", "prog", ",", "description", "=", "_parser", ".", "description", ",", ")", ...
Disassemble a symbol from an ELF file.
[ "Disassemble", "a", "symbol", "from", "an", "ELF", "file", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/asm.py#L554-L578
48,733
xflows/rdm
rdm/wrappers/rsd/rsd.py
RSD.settingsAsFacts
def settingsAsFacts(self, settings): """ Parses a string of settings. :param setting: String of settings in the form: ``set(name1, val1), set(name2, val2)...`` """ pattern = re.compile('set\(([a-zA-Z0-9_]+),(\[a-zA-Z0-9_]+)\)') pairs = pattern.findall(se...
python
def settingsAsFacts(self, settings): """ Parses a string of settings. :param setting: String of settings in the form: ``set(name1, val1), set(name2, val2)...`` """ pattern = re.compile('set\(([a-zA-Z0-9_]+),(\[a-zA-Z0-9_]+)\)') pairs = pattern.findall(se...
[ "def", "settingsAsFacts", "(", "self", ",", "settings", ")", ":", "pattern", "=", "re", ".", "compile", "(", "'set\\(([a-zA-Z0-9_]+),(\\[a-zA-Z0-9_]+)\\)'", ")", "pairs", "=", "pattern", ".", "findall", "(", "settings", ")", "for", "name", ",", "val", "in", ...
Parses a string of settings. :param setting: String of settings in the form: ``set(name1, val1), set(name2, val2)...``
[ "Parses", "a", "string", "of", "settings", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/wrappers/rsd/rsd.py#L78-L89
48,734
xflows/rdm
rdm/wrappers/rsd/rsd.py
RSD.__scripts
def __scripts(self, filestem): """ Generates the required scripts. """ script_construct = open('%s/%s' % (self.tmpdir, RSD.CONSTRUCT), 'w') script_save = open('%s/%s' % (self.tmpdir, RSD.SAVE), 'w') script_subgroups = open('%s/%s' % (self.tmpdir, RSD.SUBGROUPS), 'w') ...
python
def __scripts(self, filestem): """ Generates the required scripts. """ script_construct = open('%s/%s' % (self.tmpdir, RSD.CONSTRUCT), 'w') script_save = open('%s/%s' % (self.tmpdir, RSD.SAVE), 'w') script_subgroups = open('%s/%s' % (self.tmpdir, RSD.SUBGROUPS), 'w') ...
[ "def", "__scripts", "(", "self", ",", "filestem", ")", ":", "script_construct", "=", "open", "(", "'%s/%s'", "%", "(", "self", ".", "tmpdir", ",", "RSD", ".", "CONSTRUCT", ")", ",", "'w'", ")", "script_save", "=", "open", "(", "'%s/%s'", "%", "(", "s...
Generates the required scripts.
[ "Generates", "the", "required", "scripts", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/wrappers/rsd/rsd.py#L184-L233
48,735
edibledinos/pwnypack
pwnypack/util.py
deBruijn
def deBruijn(n, k): """ An implementation of the FKM algorithm for generating the de Bruijn sequence containing all k-ary strings of length n, as described in "Combinatorial Generation" by Frank Ruskey. """ a = [ 0 ] * (n + 1) def gen(t, p): if t > n: for v in a[1:p + 1...
python
def deBruijn(n, k): """ An implementation of the FKM algorithm for generating the de Bruijn sequence containing all k-ary strings of length n, as described in "Combinatorial Generation" by Frank Ruskey. """ a = [ 0 ] * (n + 1) def gen(t, p): if t > n: for v in a[1:p + 1...
[ "def", "deBruijn", "(", "n", ",", "k", ")", ":", "a", "=", "[", "0", "]", "*", "(", "n", "+", "1", ")", "def", "gen", "(", "t", ",", "p", ")", ":", "if", "t", ">", "n", ":", "for", "v", "in", "a", "[", "1", ":", "p", "+", "1", "]", ...
An implementation of the FKM algorithm for generating the de Bruijn sequence containing all k-ary strings of length n, as described in "Combinatorial Generation" by Frank Ruskey.
[ "An", "implementation", "of", "the", "FKM", "algorithm", "for", "generating", "the", "de", "Bruijn", "sequence", "containing", "all", "k", "-", "ary", "strings", "of", "length", "n", "as", "described", "in", "Combinatorial", "Generation", "by", "Frank", "Ruske...
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/util.py#L24-L48
48,736
edibledinos/pwnypack
pwnypack/util.py
cycle_find
def cycle_find(key, width=4): """ Given an element of a de Bruijn sequence, find its index in that sequence. Args: key(str): The piece of the de Bruijn sequence to find. width(int): The width of each element in the sequence. Returns: int: The index of ``key`` in the de Bruijn s...
python
def cycle_find(key, width=4): """ Given an element of a de Bruijn sequence, find its index in that sequence. Args: key(str): The piece of the de Bruijn sequence to find. width(int): The width of each element in the sequence. Returns: int: The index of ``key`` in the de Bruijn s...
[ "def", "cycle_find", "(", "key", ",", "width", "=", "4", ")", ":", "key_len", "=", "len", "(", "key", ")", "buf", "=", "''", "it", "=", "deBruijn", "(", "width", ",", "26", ")", "for", "i", "in", "range", "(", "key_len", ")", ":", "buf", "+=", ...
Given an element of a de Bruijn sequence, find its index in that sequence. Args: key(str): The piece of the de Bruijn sequence to find. width(int): The width of each element in the sequence. Returns: int: The index of ``key`` in the de Bruijn sequence.
[ "Given", "an", "element", "of", "a", "de", "Bruijn", "sequence", "find", "its", "index", "in", "that", "sequence", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/util.py#L76-L104
48,737
edibledinos/pwnypack
pwnypack/util.py
cycle_app
def cycle_app(parser, cmd, args): # pragma: no cover """ Generate a de Bruijn sequence of a given length. """ parser.add_argument('-w', '--width', type=int, default=4, help='the length of the cycled value') parser.add_argument('length', type=int, help='the cycle length to generate') args = par...
python
def cycle_app(parser, cmd, args): # pragma: no cover """ Generate a de Bruijn sequence of a given length. """ parser.add_argument('-w', '--width', type=int, default=4, help='the length of the cycled value') parser.add_argument('length', type=int, help='the cycle length to generate') args = par...
[ "def", "cycle_app", "(", "parser", ",", "cmd", ",", "args", ")", ":", "# pragma: no cover", "parser", ".", "add_argument", "(", "'-w'", ",", "'--width'", ",", "type", "=", "int", ",", "default", "=", "4", ",", "help", "=", "'the length of the cycled value'",...
Generate a de Bruijn sequence of a given length.
[ "Generate", "a", "de", "Bruijn", "sequence", "of", "a", "given", "length", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/util.py#L164-L172
48,738
edibledinos/pwnypack
pwnypack/util.py
cycle_find_app
def cycle_find_app(_parser, cmd, args): # pragma: no cover """ Find the first position of a value in a de Bruijn sequence. """ parser = argparse.ArgumentParser( prog=_parser.prog, description=_parser.description, ) parser.add_argument('-w', '--width', type=int, default=4, help=...
python
def cycle_find_app(_parser, cmd, args): # pragma: no cover """ Find the first position of a value in a de Bruijn sequence. """ parser = argparse.ArgumentParser( prog=_parser.prog, description=_parser.description, ) parser.add_argument('-w', '--width', type=int, default=4, help=...
[ "def", "cycle_find_app", "(", "_parser", ",", "cmd", ",", "args", ")", ":", "# pragma: no cover", "parser", "=", "argparse", ".", "ArgumentParser", "(", "prog", "=", "_parser", ".", "prog", ",", "description", "=", "_parser", ".", "description", ",", ")", ...
Find the first position of a value in a de Bruijn sequence.
[ "Find", "the", "first", "position", "of", "a", "value", "in", "a", "de", "Bruijn", "sequence", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/util.py#L176-L193
48,739
specialunderwear/django-easymode
easymode/utils/xmlutils.py
unescape_all
def unescape_all(string): """Resolve all html entities to their corresponding unicode character""" def escape_single(matchobj): return _unicode_for_entity_with_name(matchobj.group(1)) return entities.sub(escape_single, string)
python
def unescape_all(string): """Resolve all html entities to their corresponding unicode character""" def escape_single(matchobj): return _unicode_for_entity_with_name(matchobj.group(1)) return entities.sub(escape_single, string)
[ "def", "unescape_all", "(", "string", ")", ":", "def", "escape_single", "(", "matchobj", ")", ":", "return", "_unicode_for_entity_with_name", "(", "matchobj", ".", "group", "(", "1", ")", ")", "return", "entities", ".", "sub", "(", "escape_single", ",", "str...
Resolve all html entities to their corresponding unicode character
[ "Resolve", "all", "html", "entities", "to", "their", "corresponding", "unicode", "character" ]
92f674b91fb8c54d6e379e2664e2000872d9c95e
https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/easymode/utils/xmlutils.py#L26-L30
48,740
specialunderwear/django-easymode
easymode/utils/xmlutils.py
is_valid
def is_valid(xml_string): """validates a unicode string containing xml""" xml_file = StringIO.StringIO(xml_string.encode('utf-8')) parser = XmlScanner() parser.setContentHandler(ContentHandler()) try: parser.parse(xml_file) except SAXParseException: return False ret...
python
def is_valid(xml_string): """validates a unicode string containing xml""" xml_file = StringIO.StringIO(xml_string.encode('utf-8')) parser = XmlScanner() parser.setContentHandler(ContentHandler()) try: parser.parse(xml_file) except SAXParseException: return False ret...
[ "def", "is_valid", "(", "xml_string", ")", ":", "xml_file", "=", "StringIO", ".", "StringIO", "(", "xml_string", ".", "encode", "(", "'utf-8'", ")", ")", "parser", "=", "XmlScanner", "(", ")", "parser", ".", "setContentHandler", "(", "ContentHandler", "(", ...
validates a unicode string containing xml
[ "validates", "a", "unicode", "string", "containing", "xml" ]
92f674b91fb8c54d6e379e2664e2000872d9c95e
https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/easymode/utils/xmlutils.py#L32-L43
48,741
openpaperwork/paperwork-backend
paperwork_backend/index.py
PaperworkIndex.__inst_doc
def __inst_doc(self, docid, doc_type_name=None): """ Instantiate a document based on its document id. The information are taken from the whoosh index. """ doc = None docpath = self.fs.join(self.rootdir, docid) if not self.fs.exists(docpath): return Non...
python
def __inst_doc(self, docid, doc_type_name=None): """ Instantiate a document based on its document id. The information are taken from the whoosh index. """ doc = None docpath = self.fs.join(self.rootdir, docid) if not self.fs.exists(docpath): return Non...
[ "def", "__inst_doc", "(", "self", ",", "docid", ",", "doc_type_name", "=", "None", ")", ":", "doc", "=", "None", "docpath", "=", "self", ".", "fs", ".", "join", "(", "self", ".", "rootdir", ",", "docid", ")", "if", "not", "self", ".", "fs", ".", ...
Instantiate a document based on its document id. The information are taken from the whoosh index.
[ "Instantiate", "a", "document", "based", "on", "its", "document", "id", ".", "The", "information", "are", "taken", "from", "the", "whoosh", "index", "." ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/index.py#L204-L232
48,742
openpaperwork/paperwork-backend
paperwork_backend/index.py
PaperworkIndex.get_doc_from_docid
def get_doc_from_docid(self, docid, doc_type_name=None, inst=True): """ Try to find a document based on its document id. if inst=True, if it hasn't been instantiated yet, it will be. """ assert(docid is not None) if docid in self._docs_by_id: return self._docs...
python
def get_doc_from_docid(self, docid, doc_type_name=None, inst=True): """ Try to find a document based on its document id. if inst=True, if it hasn't been instantiated yet, it will be. """ assert(docid is not None) if docid in self._docs_by_id: return self._docs...
[ "def", "get_doc_from_docid", "(", "self", ",", "docid", ",", "doc_type_name", "=", "None", ",", "inst", "=", "True", ")", ":", "assert", "(", "docid", "is", "not", "None", ")", "if", "docid", "in", "self", ".", "_docs_by_id", ":", "return", "self", "."...
Try to find a document based on its document id. if inst=True, if it hasn't been instantiated yet, it will be.
[ "Try", "to", "find", "a", "document", "based", "on", "its", "document", "id", ".", "if", "inst", "=", "True", "if", "it", "hasn", "t", "been", "instantiated", "yet", "it", "will", "be", "." ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/index.py#L280-L294
48,743
openpaperwork/paperwork-backend
paperwork_backend/index.py
PaperworkIndex._delete_doc_from_index
def _delete_doc_from_index(index_writer, docid): """ Remove a document from the index """ query = whoosh.query.Term("docid", docid) index_writer.delete_by_query(query)
python
def _delete_doc_from_index(index_writer, docid): """ Remove a document from the index """ query = whoosh.query.Term("docid", docid) index_writer.delete_by_query(query)
[ "def", "_delete_doc_from_index", "(", "index_writer", ",", "docid", ")", ":", "query", "=", "whoosh", ".", "query", ".", "Term", "(", "\"docid\"", ",", "docid", ")", "index_writer", ".", "delete_by_query", "(", "query", ")" ]
Remove a document from the index
[ "Remove", "a", "document", "from", "the", "index" ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/index.py#L380-L385
48,744
openpaperwork/paperwork-backend
paperwork_backend/index.py
PaperworkIndex.upd_doc
def upd_doc(self, doc, index_update=True, label_guesser_update=True): """ Update a document in the index """ if not self.index_writer and index_update: self.index_writer = self.index.writer() if not self.label_guesser_updater and label_guesser_update: self...
python
def upd_doc(self, doc, index_update=True, label_guesser_update=True): """ Update a document in the index """ if not self.index_writer and index_update: self.index_writer = self.index.writer() if not self.label_guesser_updater and label_guesser_update: self...
[ "def", "upd_doc", "(", "self", ",", "doc", ",", "index_update", "=", "True", ",", "label_guesser_update", "=", "True", ")", ":", "if", "not", "self", ".", "index_writer", "and", "index_update", ":", "self", ".", "index_writer", "=", "self", ".", "index", ...
Update a document in the index
[ "Update", "a", "document", "in", "the", "index" ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/index.py#L403-L415
48,745
openpaperwork/paperwork-backend
paperwork_backend/index.py
PaperworkIndex.cancel
def cancel(self): """ Forget about the changes """ logger.info("Index: Index update cancelled") if self.index_writer: self.index_writer.cancel() del self.index_writer self.index_writer = None if self.label_guesser_updater: self....
python
def cancel(self): """ Forget about the changes """ logger.info("Index: Index update cancelled") if self.index_writer: self.index_writer.cancel() del self.index_writer self.index_writer = None if self.label_guesser_updater: self....
[ "def", "cancel", "(", "self", ")", ":", "logger", ".", "info", "(", "\"Index: Index update cancelled\"", ")", "if", "self", ".", "index_writer", ":", "self", ".", "index_writer", ".", "cancel", "(", ")", "del", "self", ".", "index_writer", "self", ".", "in...
Forget about the changes
[ "Forget", "about", "the", "changes" ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/index.py#L457-L468
48,746
openpaperwork/paperwork-backend
paperwork_backend/index.py
PaperworkIndex.get
def get(self, obj_id): """ Get a document or a page using its ID Won't instantiate them if they are not yet available """ if BasicPage.PAGE_ID_SEPARATOR in obj_id: (docid, page_nb) = obj_id.split(BasicPage.PAGE_ID_SEPARATOR) page_nb = int(page_nb) ...
python
def get(self, obj_id): """ Get a document or a page using its ID Won't instantiate them if they are not yet available """ if BasicPage.PAGE_ID_SEPARATOR in obj_id: (docid, page_nb) = obj_id.split(BasicPage.PAGE_ID_SEPARATOR) page_nb = int(page_nb) ...
[ "def", "get", "(", "self", ",", "obj_id", ")", ":", "if", "BasicPage", ".", "PAGE_ID_SEPARATOR", "in", "obj_id", ":", "(", "docid", ",", "page_nb", ")", "=", "obj_id", ".", "split", "(", "BasicPage", ".", "PAGE_ID_SEPARATOR", ")", "page_nb", "=", "int", ...
Get a document or a page using its ID Won't instantiate them if they are not yet available
[ "Get", "a", "document", "or", "a", "page", "using", "its", "ID", "Won", "t", "instantiate", "them", "if", "they", "are", "not", "yet", "available" ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/index.py#L495-L504
48,747
openpaperwork/paperwork-backend
paperwork_backend/index.py
PaperworkIndex.find_documents
def find_documents(self, sentence, limit=None, must_sort=True, search_type='fuzzy'): """ Returns all the documents matching the given keywords Arguments: sentence --- a sentenced query Returns: An array of document (doc objects) """...
python
def find_documents(self, sentence, limit=None, must_sort=True, search_type='fuzzy'): """ Returns all the documents matching the given keywords Arguments: sentence --- a sentenced query Returns: An array of document (doc objects) """...
[ "def", "find_documents", "(", "self", ",", "sentence", ",", "limit", "=", "None", ",", "must_sort", "=", "True", ",", "search_type", "=", "'fuzzy'", ")", ":", "sentence", "=", "sentence", ".", "strip", "(", ")", "sentence", "=", "strip_accents", "(", "se...
Returns all the documents matching the given keywords Arguments: sentence --- a sentenced query Returns: An array of document (doc objects)
[ "Returns", "all", "the", "documents", "matching", "the", "given", "keywords" ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/index.py#L506-L564
48,748
openpaperwork/paperwork-backend
paperwork_backend/index.py
PaperworkIndex.find_suggestions
def find_suggestions(self, sentence): """ Search all possible suggestions. Suggestions returned always have at least one document matching. Arguments: sentence --- keywords (single strings) for which we want suggestions Return: An array of...
python
def find_suggestions(self, sentence): """ Search all possible suggestions. Suggestions returned always have at least one document matching. Arguments: sentence --- keywords (single strings) for which we want suggestions Return: An array of...
[ "def", "find_suggestions", "(", "self", ",", "sentence", ")", ":", "if", "not", "isinstance", "(", "sentence", ",", "str", ")", ":", "sentence", "=", "str", "(", "sentence", ")", "keywords", "=", "sentence", ".", "split", "(", "\" \"", ")", "query_parser...
Search all possible suggestions. Suggestions returned always have at least one document matching. Arguments: sentence --- keywords (single strings) for which we want suggestions Return: An array of sets of keywords. Each set of keywords (-> one string) ...
[ "Search", "all", "possible", "suggestions", ".", "Suggestions", "returned", "always", "have", "at", "least", "one", "document", "matching", "." ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/index.py#L566-L611
48,749
openpaperwork/paperwork-backend
paperwork_backend/index.py
PaperworkIndex.add_label
def add_label(self, doc, label, update_index=True): """ Add a label on a document. Arguments: label --- The new label (see labels.Label) doc --- The first document on which this label has been added """ label = copy.copy(label) assert(label in sel...
python
def add_label(self, doc, label, update_index=True): """ Add a label on a document. Arguments: label --- The new label (see labels.Label) doc --- The first document on which this label has been added """ label = copy.copy(label) assert(label in sel...
[ "def", "add_label", "(", "self", ",", "doc", ",", "label", ",", "update_index", "=", "True", ")", ":", "label", "=", "copy", ".", "copy", "(", "label", ")", "assert", "(", "label", "in", "self", ".", "labels", ".", "values", "(", ")", ")", "doc", ...
Add a label on a document. Arguments: label --- The new label (see labels.Label) doc --- The first document on which this label has been added
[ "Add", "a", "label", "on", "a", "document", "." ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/index.py#L631-L644
48,750
openpaperwork/paperwork-backend
paperwork_backend/index.py
PaperworkIndex.destroy_index
def destroy_index(self): """ Destroy the index. Don't use this Index object anymore after this call. Index will have to be rebuilt from scratch """ self.close() logger.info("Destroying the index ...") rm_rf(self.indexdir) rm_rf(self.label_guesser_dir) ...
python
def destroy_index(self): """ Destroy the index. Don't use this Index object anymore after this call. Index will have to be rebuilt from scratch """ self.close() logger.info("Destroying the index ...") rm_rf(self.indexdir) rm_rf(self.label_guesser_dir) ...
[ "def", "destroy_index", "(", "self", ")", ":", "self", ".", "close", "(", ")", "logger", ".", "info", "(", "\"Destroying the index ...\"", ")", "rm_rf", "(", "self", ".", "indexdir", ")", "rm_rf", "(", "self", ".", "label_guesser_dir", ")", "logger", ".", ...
Destroy the index. Don't use this Index object anymore after this call. Index will have to be rebuilt from scratch
[ "Destroy", "the", "index", ".", "Don", "t", "use", "this", "Index", "object", "anymore", "after", "this", "call", ".", "Index", "will", "have", "to", "be", "rebuilt", "from", "scratch" ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/index.py#L732-L741
48,751
openpaperwork/paperwork-backend
paperwork_backend/index.py
PaperworkIndex.is_hash_in_index
def is_hash_in_index(self, filehash): """ Check if there is a document using this file hash """ filehash = (u"%X" % filehash) results = self.__searcher.search( whoosh.query.Term('docfilehash', filehash)) return bool(results)
python
def is_hash_in_index(self, filehash): """ Check if there is a document using this file hash """ filehash = (u"%X" % filehash) results = self.__searcher.search( whoosh.query.Term('docfilehash', filehash)) return bool(results)
[ "def", "is_hash_in_index", "(", "self", ",", "filehash", ")", ":", "filehash", "=", "(", "u\"%X\"", "%", "filehash", ")", "results", "=", "self", ".", "__searcher", ".", "search", "(", "whoosh", ".", "query", ".", "Term", "(", "'docfilehash'", ",", "file...
Check if there is a document using this file hash
[ "Check", "if", "there", "is", "a", "document", "using", "this", "file", "hash" ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/index.py#L743-L750
48,752
specialunderwear/django-easymode
easymode/i18n/meta/utils.py
get_fallback_languages
def get_fallback_languages(): """Retrieve the fallback languages from the settings.py""" lang = translation.get_language() fallback_list = settings.FALLBACK_LANGUAGES.get(lang, None) if fallback_list: return fallback_list return settings.FALLBACK_LANGUAGES.get(lang[:2], [])
python
def get_fallback_languages(): """Retrieve the fallback languages from the settings.py""" lang = translation.get_language() fallback_list = settings.FALLBACK_LANGUAGES.get(lang, None) if fallback_list: return fallback_list return settings.FALLBACK_LANGUAGES.get(lang[:2], [])
[ "def", "get_fallback_languages", "(", ")", ":", "lang", "=", "translation", ".", "get_language", "(", ")", "fallback_list", "=", "settings", ".", "FALLBACK_LANGUAGES", ".", "get", "(", "lang", ",", "None", ")", "if", "fallback_list", ":", "return", "fallback_l...
Retrieve the fallback languages from the settings.py
[ "Retrieve", "the", "fallback", "languages", "from", "the", "settings", ".", "py" ]
92f674b91fb8c54d6e379e2664e2000872d9c95e
https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/easymode/i18n/meta/utils.py#L17-L24
48,753
specialunderwear/django-easymode
easymode/i18n/meta/utils.py
get_localized_field_name
def get_localized_field_name(context, field): """Get the name of the localized field""" attrs = [ translation.get_language(), translation.get_language()[:2], settings.LANGUAGE_CODE ] def predicate(x): field_name = get_real_fieldname(f...
python
def get_localized_field_name(context, field): """Get the name of the localized field""" attrs = [ translation.get_language(), translation.get_language()[:2], settings.LANGUAGE_CODE ] def predicate(x): field_name = get_real_fieldname(f...
[ "def", "get_localized_field_name", "(", "context", ",", "field", ")", ":", "attrs", "=", "[", "translation", ".", "get_language", "(", ")", ",", "translation", ".", "get_language", "(", ")", "[", ":", "2", "]", ",", "settings", ".", "LANGUAGE_CODE", "]", ...
Get the name of the localized field
[ "Get", "the", "name", "of", "the", "localized", "field" ]
92f674b91fb8c54d6e379e2664e2000872d9c95e
https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/easymode/i18n/meta/utils.py#L53-L67
48,754
specialunderwear/django-easymode
easymode/i18n/meta/utils.py
get_field_from_model_by_name
def get_field_from_model_by_name(model_class, field_name): """ Get a field by name from a model class without messing with the app cache. """ return first_match(lambda x: x if x.name == field_name else None, model_class._meta.fields)
python
def get_field_from_model_by_name(model_class, field_name): """ Get a field by name from a model class without messing with the app cache. """ return first_match(lambda x: x if x.name == field_name else None, model_class._meta.fields)
[ "def", "get_field_from_model_by_name", "(", "model_class", ",", "field_name", ")", ":", "return", "first_match", "(", "lambda", "x", ":", "x", "if", "x", ".", "name", "==", "field_name", "else", "None", ",", "model_class", ".", "_meta", ".", "fields", ")" ]
Get a field by name from a model class without messing with the app cache.
[ "Get", "a", "field", "by", "name", "from", "a", "model", "class", "without", "messing", "with", "the", "app", "cache", "." ]
92f674b91fb8c54d6e379e2664e2000872d9c95e
https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/easymode/i18n/meta/utils.py#L69-L73
48,755
yoch/sparse-som
python/sparse_som/classifier.py
SomClassifier.fit
def fit(self, data, labels, **kwargs): """\ Training the SOM on the the data and calibrate itself. After the training, `self.quant_error` and `self.topog_error` are respectively set. :param data: sparse input matrix (ideal dtype is `numpy.float32`) :type data: :class:`...
python
def fit(self, data, labels, **kwargs): """\ Training the SOM on the the data and calibrate itself. After the training, `self.quant_error` and `self.topog_error` are respectively set. :param data: sparse input matrix (ideal dtype is `numpy.float32`) :type data: :class:`...
[ "def", "fit", "(", "self", ",", "data", ",", "labels", ",", "*", "*", "kwargs", ")", ":", "# train the network", "self", ".", "_som", ".", "train", "(", "data", ",", "*", "*", "kwargs", ")", "# retrieve first and second bmus and distances", "bmus", ",", "q...
\ Training the SOM on the the data and calibrate itself. After the training, `self.quant_error` and `self.topog_error` are respectively set. :param data: sparse input matrix (ideal dtype is `numpy.float32`) :type data: :class:`scipy.sparse.csr_matrix` :param labels: th...
[ "\\", "Training", "the", "SOM", "on", "the", "the", "data", "and", "calibrate", "itself", "." ]
327ee76b0da1da7f846d9b3fce0c39bace841f64
https://github.com/yoch/sparse-som/blob/327ee76b0da1da7f846d9b3fce0c39bace841f64/python/sparse_som/classifier.py#L21-L44
48,756
yoch/sparse-som
python/sparse_som/classifier.py
SomClassifier._calibrate
def _calibrate(self, data, labels): """\ Calibrate the network using `self._bmus`. """ # network calibration classifier = defaultdict(Counter) for (i,j), label in zip(self._bmus, labels): classifier[i,j][label] += 1 self.classifier = {} for ij,...
python
def _calibrate(self, data, labels): """\ Calibrate the network using `self._bmus`. """ # network calibration classifier = defaultdict(Counter) for (i,j), label in zip(self._bmus, labels): classifier[i,j][label] += 1 self.classifier = {} for ij,...
[ "def", "_calibrate", "(", "self", ",", "data", ",", "labels", ")", ":", "# network calibration", "classifier", "=", "defaultdict", "(", "Counter", ")", "for", "(", "i", ",", "j", ")", ",", "label", "in", "zip", "(", "self", ".", "_bmus", ",", "labels",...
\ Calibrate the network using `self._bmus`.
[ "\\", "Calibrate", "the", "network", "using", "self", ".", "_bmus", "." ]
327ee76b0da1da7f846d9b3fce0c39bace841f64
https://github.com/yoch/sparse-som/blob/327ee76b0da1da7f846d9b3fce0c39bace841f64/python/sparse_som/classifier.py#L46-L58
48,757
yoch/sparse-som
python/sparse_som/classifier.py
SomClassifier.predict
def predict(self, data, unkown=None): """\ Classify data according to previous calibration. :param data: sparse input matrix (ideal dtype is `numpy.float32`) :type data: :class:`scipy.sparse.csr_matrix` :param unkown: the label to attribute if no label is known :returns:...
python
def predict(self, data, unkown=None): """\ Classify data according to previous calibration. :param data: sparse input matrix (ideal dtype is `numpy.float32`) :type data: :class:`scipy.sparse.csr_matrix` :param unkown: the label to attribute if no label is known :returns:...
[ "def", "predict", "(", "self", ",", "data", ",", "unkown", "=", "None", ")", ":", "assert", "self", ".", "classifier", "is", "not", "None", ",", "'not calibrated'", "bmus", "=", "self", ".", "_som", ".", "bmus", "(", "data", ")", "return", "self", "....
\ Classify data according to previous calibration. :param data: sparse input matrix (ideal dtype is `numpy.float32`) :type data: :class:`scipy.sparse.csr_matrix` :param unkown: the label to attribute if no label is known :returns: the labels guessed for data :rtype: `num...
[ "\\", "Classify", "data", "according", "to", "previous", "calibration", "." ]
327ee76b0da1da7f846d9b3fce0c39bace841f64
https://github.com/yoch/sparse-som/blob/327ee76b0da1da7f846d9b3fce0c39bace841f64/python/sparse_som/classifier.py#L86-L98
48,758
yoch/sparse-som
python/sparse_som/classifier.py
SomClassifier.fit_predict
def fit_predict(self, data, labels, unkown=None): """\ Fit and classify data efficiently. :param data: sparse input matrix (ideal dtype is `numpy.float32`) :type data: :class:`scipy.sparse.csr_matrix` :param labels: the labels associated with data :type labels: iterable ...
python
def fit_predict(self, data, labels, unkown=None): """\ Fit and classify data efficiently. :param data: sparse input matrix (ideal dtype is `numpy.float32`) :type data: :class:`scipy.sparse.csr_matrix` :param labels: the labels associated with data :type labels: iterable ...
[ "def", "fit_predict", "(", "self", ",", "data", ",", "labels", ",", "unkown", "=", "None", ")", ":", "self", ".", "fit", "(", "data", ",", "labels", ")", "return", "self", ".", "_predict_from_bmus", "(", "self", ".", "_bmus", ",", "unkown", ")" ]
\ Fit and classify data efficiently. :param data: sparse input matrix (ideal dtype is `numpy.float32`) :type data: :class:`scipy.sparse.csr_matrix` :param labels: the labels associated with data :type labels: iterable :param unkown: the label to attribute if no label is ...
[ "\\", "Fit", "and", "classify", "data", "efficiently", "." ]
327ee76b0da1da7f846d9b3fce0c39bace841f64
https://github.com/yoch/sparse-som/blob/327ee76b0da1da7f846d9b3fce0c39bace841f64/python/sparse_som/classifier.py#L100-L113
48,759
yoch/sparse-som
python/sparse_som/classifier.py
SomClassifier.histogram
def histogram(self, bmus=None): """\ Return a 2D histogram of bmus. :param bmus: the best-match units indexes for underlying data. :type bmus: :class:`numpy.ndarray` :returns: the computed 2D histogram of bmus. :rtype: :class:`numpy.ndarray` """ if bmus i...
python
def histogram(self, bmus=None): """\ Return a 2D histogram of bmus. :param bmus: the best-match units indexes for underlying data. :type bmus: :class:`numpy.ndarray` :returns: the computed 2D histogram of bmus. :rtype: :class:`numpy.ndarray` """ if bmus i...
[ "def", "histogram", "(", "self", ",", "bmus", "=", "None", ")", ":", "if", "bmus", "is", "None", ":", "assert", "self", ".", "_bmus", "is", "not", "None", ",", "'not trained'", "bmus", "=", "self", ".", "_bmus", "arr", "=", "np", ".", "zeros", "(",...
\ Return a 2D histogram of bmus. :param bmus: the best-match units indexes for underlying data. :type bmus: :class:`numpy.ndarray` :returns: the computed 2D histogram of bmus. :rtype: :class:`numpy.ndarray`
[ "\\", "Return", "a", "2D", "histogram", "of", "bmus", "." ]
327ee76b0da1da7f846d9b3fce0c39bace841f64
https://github.com/yoch/sparse-som/blob/327ee76b0da1da7f846d9b3fce0c39bace841f64/python/sparse_som/classifier.py#L126-L141
48,760
edibledinos/pwnypack
pwnypack/pickle.py
get_protocol_version
def get_protocol_version(protocol=None, target=None): """ Return a suitable pickle protocol version for a given target. Arguments: target: The internals description of the targeted python version. If this is ``None`` the specification of the currently running python version ...
python
def get_protocol_version(protocol=None, target=None): """ Return a suitable pickle protocol version for a given target. Arguments: target: The internals description of the targeted python version. If this is ``None`` the specification of the currently running python version ...
[ "def", "get_protocol_version", "(", "protocol", "=", "None", ",", "target", "=", "None", ")", ":", "target", "=", "get_py_internals", "(", "target", ")", "if", "protocol", "is", "None", ":", "protocol", "=", "target", "[", "'pickle_default_protocol'", "]", "...
Return a suitable pickle protocol version for a given target. Arguments: target: The internals description of the targeted python version. If this is ``None`` the specification of the currently running python version will be used. protocol(None or int): The requested protoco...
[ "Return", "a", "suitable", "pickle", "protocol", "version", "for", "a", "given", "target", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/pickle.py#L28-L57
48,761
edibledinos/pwnypack
pwnypack/pickle.py
translate_opcodes
def translate_opcodes(code_obj, target): """ Very crude inter-python version opcode translator. Raises SyntaxError when the opcode doesn't exist in the destination opmap. Used to transcribe python code objects between python versions. Arguments: code_obj(pwnypack.bytecode.CodeObject): The c...
python
def translate_opcodes(code_obj, target): """ Very crude inter-python version opcode translator. Raises SyntaxError when the opcode doesn't exist in the destination opmap. Used to transcribe python code objects between python versions. Arguments: code_obj(pwnypack.bytecode.CodeObject): The c...
[ "def", "translate_opcodes", "(", "code_obj", ",", "target", ")", ":", "target", "=", "get_py_internals", "(", "target", ")", "src_ops", "=", "code_obj", ".", "disassemble", "(", ")", "dst_opmap", "=", "target", "[", "'opmap'", "]", "dst_ops", "=", "[", "]"...
Very crude inter-python version opcode translator. Raises SyntaxError when the opcode doesn't exist in the destination opmap. Used to transcribe python code objects between python versions. Arguments: code_obj(pwnypack.bytecode.CodeObject): The code object representation to translate. ...
[ "Very", "crude", "inter", "-", "python", "version", "opcode", "translator", ".", "Raises", "SyntaxError", "when", "the", "opcode", "doesn", "t", "exist", "in", "the", "destination", "opmap", ".", "Used", "to", "transcribe", "python", "code", "objects", "betwee...
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/pickle.py#L96-L153
48,762
transitland/mapzen-gtfs
mzgtfs/route.py
Route.stops
def stops(self): """Return stops served by this route.""" serves = set() for trip in self.trips(): for stop_time in trip.stop_times(): serves |= stop_time.stops() return serves
python
def stops(self): """Return stops served by this route.""" serves = set() for trip in self.trips(): for stop_time in trip.stop_times(): serves |= stop_time.stops() return serves
[ "def", "stops", "(", "self", ")", ":", "serves", "=", "set", "(", ")", "for", "trip", "in", "self", ".", "trips", "(", ")", ":", "for", "stop_time", "in", "trip", ".", "stop_times", "(", ")", ":", "serves", "|=", "stop_time", ".", "stops", "(", "...
Return stops served by this route.
[ "Return", "stops", "served", "by", "this", "route", "." ]
d445f1588ed10713eea9a1ca2878eef792121eca
https://github.com/transitland/mapzen-gtfs/blob/d445f1588ed10713eea9a1ca2878eef792121eca/mzgtfs/route.py#L226-L232
48,763
edibledinos/pwnypack
pwnypack/packing.py
P
def P(value, bits=None, endian=None, target=None): """ Pack an unsigned pointer for a given target. Args: value(int): The value to pack. bits(:class:`~pwnypack.target.Target.Bits`): Override the default word size. If ``None`` it will look at the word size of ``target...
python
def P(value, bits=None, endian=None, target=None): """ Pack an unsigned pointer for a given target. Args: value(int): The value to pack. bits(:class:`~pwnypack.target.Target.Bits`): Override the default word size. If ``None`` it will look at the word size of ``target...
[ "def", "P", "(", "value", ",", "bits", "=", "None", ",", "endian", "=", "None", ",", "target", "=", "None", ")", ":", "return", "globals", "(", ")", "[", "'P%d'", "%", "_get_bits", "(", "bits", ",", "target", ")", "]", "(", "value", ",", "endian"...
Pack an unsigned pointer for a given target. Args: value(int): The value to pack. bits(:class:`~pwnypack.target.Target.Bits`): Override the default word size. If ``None`` it will look at the word size of ``target``. endian(:class:`~pwnypack.target.Target.Endian`): Ov...
[ "Pack", "an", "unsigned", "pointer", "for", "a", "given", "target", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/packing.py#L140-L157
48,764
edibledinos/pwnypack
pwnypack/packing.py
p
def p(value, bits=None, endian=None, target=None): """ Pack a signed pointer for a given target. Args: value(int): The value to pack. bits(:class:`pwnypack.target.Target.Bits`): Override the default word size. If ``None`` it will look at the word size of ``target``. ...
python
def p(value, bits=None, endian=None, target=None): """ Pack a signed pointer for a given target. Args: value(int): The value to pack. bits(:class:`pwnypack.target.Target.Bits`): Override the default word size. If ``None`` it will look at the word size of ``target``. ...
[ "def", "p", "(", "value", ",", "bits", "=", "None", ",", "endian", "=", "None", ",", "target", "=", "None", ")", ":", "return", "globals", "(", ")", "[", "'p%d'", "%", "_get_bits", "(", "bits", ",", "target", ")", "]", "(", "value", ",", "endian"...
Pack a signed pointer for a given target. Args: value(int): The value to pack. bits(:class:`pwnypack.target.Target.Bits`): Override the default word size. If ``None`` it will look at the word size of ``target``. endian(:class:`~pwnypack.target.Target.Endian`): Overri...
[ "Pack", "a", "signed", "pointer", "for", "a", "given", "target", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/packing.py#L160-L177
48,765
edibledinos/pwnypack
pwnypack/packing.py
U
def U(data, bits=None, endian=None, target=None): """ Unpack an unsigned pointer for a given target. Args: data(bytes): The data to unpack. bits(:class:`pwnypack.target.Target.Bits`): Override the default word size. If ``None`` it will look at the word size of ``targ...
python
def U(data, bits=None, endian=None, target=None): """ Unpack an unsigned pointer for a given target. Args: data(bytes): The data to unpack. bits(:class:`pwnypack.target.Target.Bits`): Override the default word size. If ``None`` it will look at the word size of ``targ...
[ "def", "U", "(", "data", ",", "bits", "=", "None", ",", "endian", "=", "None", ",", "target", "=", "None", ")", ":", "return", "globals", "(", ")", "[", "'U%d'", "%", "_get_bits", "(", "bits", ",", "target", ")", "]", "(", "data", ",", "endian", ...
Unpack an unsigned pointer for a given target. Args: data(bytes): The data to unpack. bits(:class:`pwnypack.target.Target.Bits`): Override the default word size. If ``None`` it will look at the word size of ``target``. endian(:class:`~pwnypack.target.Target.Endian`):...
[ "Unpack", "an", "unsigned", "pointer", "for", "a", "given", "target", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/packing.py#L180-L200
48,766
edibledinos/pwnypack
pwnypack/packing.py
u
def u(data, bits=None, endian=None, target=None): """ Unpack a signed pointer for a given target. Args: data(bytes): The data to unpack. bits(:class:`pwnypack.target.Target.Bits`): Override the default word size. If ``None`` it will look at the word size of ``target`...
python
def u(data, bits=None, endian=None, target=None): """ Unpack a signed pointer for a given target. Args: data(bytes): The data to unpack. bits(:class:`pwnypack.target.Target.Bits`): Override the default word size. If ``None`` it will look at the word size of ``target`...
[ "def", "u", "(", "data", ",", "bits", "=", "None", ",", "endian", "=", "None", ",", "target", "=", "None", ")", ":", "return", "globals", "(", ")", "[", "'u%d'", "%", "_get_bits", "(", "bits", ",", "target", ")", "]", "(", "data", ",", "endian", ...
Unpack a signed pointer for a given target. Args: data(bytes): The data to unpack. bits(:class:`pwnypack.target.Target.Bits`): Override the default word size. If ``None`` it will look at the word size of ``target``. endian(:class:`~pwnypack.target.Target.Endian`): Ov...
[ "Unpack", "a", "signed", "pointer", "for", "a", "given", "target", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/packing.py#L203-L223
48,767
transitland/mapzen-gtfs
mzgtfs/agency.py
Agency.trips
def trips(self): """Return all trips for this agency.""" trips = set() for route in self.routes(): trips |= route.trips() return trips
python
def trips(self): """Return all trips for this agency.""" trips = set() for route in self.routes(): trips |= route.trips() return trips
[ "def", "trips", "(", "self", ")", ":", "trips", "=", "set", "(", ")", "for", "route", "in", "self", ".", "routes", "(", ")", ":", "trips", "|=", "route", ".", "trips", "(", ")", "return", "trips" ]
Return all trips for this agency.
[ "Return", "all", "trips", "for", "this", "agency", "." ]
d445f1588ed10713eea9a1ca2878eef792121eca
https://github.com/transitland/mapzen-gtfs/blob/d445f1588ed10713eea9a1ca2878eef792121eca/mzgtfs/agency.py#L81-L86
48,768
transitland/mapzen-gtfs
mzgtfs/agency.py
Agency.stops
def stops(self): """Return all stops visited by trips for this agency.""" stops = set() for stop_time in self.stop_times(): stops |= stop_time.stops() return stops
python
def stops(self): """Return all stops visited by trips for this agency.""" stops = set() for stop_time in self.stop_times(): stops |= stop_time.stops() return stops
[ "def", "stops", "(", "self", ")", ":", "stops", "=", "set", "(", ")", "for", "stop_time", "in", "self", ".", "stop_times", "(", ")", ":", "stops", "|=", "stop_time", ".", "stops", "(", ")", "return", "stops" ]
Return all stops visited by trips for this agency.
[ "Return", "all", "stops", "visited", "by", "trips", "for", "this", "agency", "." ]
d445f1588ed10713eea9a1ca2878eef792121eca
https://github.com/transitland/mapzen-gtfs/blob/d445f1588ed10713eea9a1ca2878eef792121eca/mzgtfs/agency.py#L92-L97
48,769
transitland/mapzen-gtfs
mzgtfs/agency.py
Agency.stop_times
def stop_times(self): """Return all stop_times for this agency.""" stop_times = set() for trip in self.trips(): stop_times |= trip.stop_times() return stop_times
python
def stop_times(self): """Return all stop_times for this agency.""" stop_times = set() for trip in self.trips(): stop_times |= trip.stop_times() return stop_times
[ "def", "stop_times", "(", "self", ")", ":", "stop_times", "=", "set", "(", ")", "for", "trip", "in", "self", ".", "trips", "(", ")", ":", "stop_times", "|=", "trip", ".", "stop_times", "(", ")", "return", "stop_times" ]
Return all stop_times for this agency.
[ "Return", "all", "stop_times", "for", "this", "agency", "." ]
d445f1588ed10713eea9a1ca2878eef792121eca
https://github.com/transitland/mapzen-gtfs/blob/d445f1588ed10713eea9a1ca2878eef792121eca/mzgtfs/agency.py#L103-L108
48,770
specialunderwear/django-easymode
easymode/i18n/meta/__init__.py
localize_fields
def localize_fields(cls, localized_fields): """ For each field name in localized_fields, for each language in settings.LANGUAGES, add fields to cls, and remove the original field, instead replace it with a DefaultFieldDescriptor, which always returns the field in the current language. ""...
python
def localize_fields(cls, localized_fields): """ For each field name in localized_fields, for each language in settings.LANGUAGES, add fields to cls, and remove the original field, instead replace it with a DefaultFieldDescriptor, which always returns the field in the current language. ""...
[ "def", "localize_fields", "(", "cls", ",", "localized_fields", ")", ":", "# never do this twice", "if", "hasattr", "(", "cls", ",", "'localized_fields'", ")", ":", "return", "cls", "# MSGID_LANGUAGE is the language that is used for the gettext message id's.", "# If it is not ...
For each field name in localized_fields, for each language in settings.LANGUAGES, add fields to cls, and remove the original field, instead replace it with a DefaultFieldDescriptor, which always returns the field in the current language.
[ "For", "each", "field", "name", "in", "localized_fields", "for", "each", "language", "in", "settings", ".", "LANGUAGES", "add", "fields", "to", "cls", "and", "remove", "the", "original", "field", "instead", "replace", "it", "with", "a", "DefaultFieldDescriptor",...
92f674b91fb8c54d6e379e2664e2000872d9c95e
https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/easymode/i18n/meta/__init__.py#L25-L111
48,771
openpaperwork/paperwork-backend
paperwork_backend/common/doc.py
BasicDoc.__get_labels
def __get_labels(self): """ Read the label file of the documents and extract all the labels Returns: An array of labels.Label objects """ labels = [] try: with self.fs.open(self.fs.join(self.path, self.LABEL_FILE), ...
python
def __get_labels(self): """ Read the label file of the documents and extract all the labels Returns: An array of labels.Label objects """ labels = [] try: with self.fs.open(self.fs.join(self.path, self.LABEL_FILE), ...
[ "def", "__get_labels", "(", "self", ")", ":", "labels", "=", "[", "]", "try", ":", "with", "self", ".", "fs", ".", "open", "(", "self", ".", "fs", ".", "join", "(", "self", ".", "path", ",", "self", ".", "LABEL_FILE", ")", ",", "'r'", ")", "as"...
Read the label file of the documents and extract all the labels Returns: An array of labels.Label objects
[ "Read", "the", "label", "file", "of", "the", "documents", "and", "extract", "all", "the", "labels" ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/common/doc.py#L152-L170
48,772
openpaperwork/paperwork-backend
paperwork_backend/common/doc.py
BasicDoc.__set_labels
def __set_labels(self, labels): """ Add a label on the document. """ with self.fs.open(self.fs.join(self.path, self.LABEL_FILE), 'w') \ as file_desc: for label in labels: file_desc.write("%s,%s\n" % (label.name, ...
python
def __set_labels(self, labels): """ Add a label on the document. """ with self.fs.open(self.fs.join(self.path, self.LABEL_FILE), 'w') \ as file_desc: for label in labels: file_desc.write("%s,%s\n" % (label.name, ...
[ "def", "__set_labels", "(", "self", ",", "labels", ")", ":", "with", "self", ".", "fs", ".", "open", "(", "self", ".", "fs", ".", "join", "(", "self", ".", "path", ",", "self", ".", "LABEL_FILE", ")", ",", "'w'", ")", "as", "file_desc", ":", "for...
Add a label on the document.
[ "Add", "a", "label", "on", "the", "document", "." ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/common/doc.py#L172-L180
48,773
openpaperwork/paperwork-backend
paperwork_backend/common/doc.py
BasicDoc.update_label
def update_label(self, old_label, new_label): """ Update a label Replace 'old_label' by 'new_label' """ logger.info("%s : Updating label ([%s] -> [%s])" % (str(self), old_label.name, new_label.name)) labels = self.labels try: label...
python
def update_label(self, old_label, new_label): """ Update a label Replace 'old_label' by 'new_label' """ logger.info("%s : Updating label ([%s] -> [%s])" % (str(self), old_label.name, new_label.name)) labels = self.labels try: label...
[ "def", "update_label", "(", "self", ",", "old_label", ",", "new_label", ")", ":", "logger", ".", "info", "(", "\"%s : Updating label ([%s] -> [%s])\"", "%", "(", "str", "(", "self", ")", ",", "old_label", ".", "name", ",", "new_label", ".", "name", ")", ")...
Update a label Replace 'old_label' by 'new_label'
[ "Update", "a", "label" ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/common/doc.py#L213-L235
48,774
openpaperwork/paperwork-backend
paperwork_backend/common/doc.py
BasicDoc.__doc_cmp
def __doc_cmp(self, other): """ Comparison function. Can be used to sort docs alphabetically. """ if other is None: return -1 if self.is_new and other.is_new: return 0 if self.__docid < other.__docid: return -1 elif self.__docid...
python
def __doc_cmp(self, other): """ Comparison function. Can be used to sort docs alphabetically. """ if other is None: return -1 if self.is_new and other.is_new: return 0 if self.__docid < other.__docid: return -1 elif self.__docid...
[ "def", "__doc_cmp", "(", "self", ",", "other", ")", ":", "if", "other", "is", "None", ":", "return", "-", "1", "if", "self", ".", "is_new", "and", "other", ".", "is_new", ":", "return", "0", "if", "self", ".", "__docid", "<", "other", ".", "__docid...
Comparison function. Can be used to sort docs alphabetically.
[ "Comparison", "function", ".", "Can", "be", "used", "to", "sort", "docs", "alphabetically", "." ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/common/doc.py#L259-L272
48,775
xflows/rdm
rdm/helpers.py
arff_to_orange_table
def arff_to_orange_table(arff): ''' Convert a string in arff format to an Orange table. :param arff: string in arff format :return: Orange data table object constructed from the arff string :rtype: orange.ExampleTable ''' with tempfile.NamedTemporaryFile(suffix='.arff', delete=...
python
def arff_to_orange_table(arff): ''' Convert a string in arff format to an Orange table. :param arff: string in arff format :return: Orange data table object constructed from the arff string :rtype: orange.ExampleTable ''' with tempfile.NamedTemporaryFile(suffix='.arff', delete=...
[ "def", "arff_to_orange_table", "(", "arff", ")", ":", "with", "tempfile", ".", "NamedTemporaryFile", "(", "suffix", "=", "'.arff'", ",", "delete", "=", "True", ")", "as", "f", ":", "f", ".", "write", "(", "arff", ")", "f", ".", "flush", "(", ")", "ta...
Convert a string in arff format to an Orange table. :param arff: string in arff format :return: Orange data table object constructed from the arff string :rtype: orange.ExampleTable
[ "Convert", "a", "string", "in", "arff", "format", "to", "an", "Orange", "table", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/helpers.py#L5-L18
48,776
specialunderwear/django-easymode
easymode/i18n/meta/fields.py
DefaultFieldDescriptor.value_to_string
def value_to_string(self, obj): """This descriptor acts as a Field, as far as the serializer is concerned.""" try: return force_unicode(self.__get__(obj)) except TypeError: return str(self.__get__(obj))
python
def value_to_string(self, obj): """This descriptor acts as a Field, as far as the serializer is concerned.""" try: return force_unicode(self.__get__(obj)) except TypeError: return str(self.__get__(obj))
[ "def", "value_to_string", "(", "self", ",", "obj", ")", ":", "try", ":", "return", "force_unicode", "(", "self", ".", "__get__", "(", "obj", ")", ")", "except", "TypeError", ":", "return", "str", "(", "self", ".", "__get__", "(", "obj", ")", ")" ]
This descriptor acts as a Field, as far as the serializer is concerned.
[ "This", "descriptor", "acts", "as", "a", "Field", "as", "far", "as", "the", "serializer", "is", "concerned", "." ]
92f674b91fb8c54d6e379e2664e2000872d9c95e
https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/easymode/i18n/meta/fields.py#L127-L132
48,777
specialunderwear/django-easymode
easymode/i18n/gettext.py
MakeModelMessages.poify
def poify(self, model): """turn a django model into a po file.""" if not hasattr(model, 'localized_fields'): return None # create po stream with header po_stream = polibext.PoStream(StringIO.StringIO(self.po_header)).parse() for (name, field) in easymode.tree.intros...
python
def poify(self, model): """turn a django model into a po file.""" if not hasattr(model, 'localized_fields'): return None # create po stream with header po_stream = polibext.PoStream(StringIO.StringIO(self.po_header)).parse() for (name, field) in easymode.tree.intros...
[ "def", "poify", "(", "self", ",", "model", ")", ":", "if", "not", "hasattr", "(", "model", ",", "'localized_fields'", ")", ":", "return", "None", "# create po stream with header", "po_stream", "=", "polibext", ".", "PoStream", "(", "StringIO", ".", "StringIO",...
turn a django model into a po file.
[ "turn", "a", "django", "model", "into", "a", "po", "file", "." ]
92f674b91fb8c54d6e379e2664e2000872d9c95e
https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/easymode/i18n/gettext.py#L139-L162
48,778
specialunderwear/django-easymode
easymode/i18n/gettext.py
MakeModelMessages.xgettext
def xgettext(self, template): """Extracts to be translated strings from template and turns it into po format.""" cmd = 'xgettext -d django -L Python --keyword=gettext_noop \ --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --from-code=UTF-8 \ --output=- -' p = subproc...
python
def xgettext(self, template): """Extracts to be translated strings from template and turns it into po format.""" cmd = 'xgettext -d django -L Python --keyword=gettext_noop \ --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --from-code=UTF-8 \ --output=- -' p = subproc...
[ "def", "xgettext", "(", "self", ",", "template", ")", ":", "cmd", "=", "'xgettext -d django -L Python --keyword=gettext_noop \\\n --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --from-code=UTF-8 \\\n --output=- -'", "p", "=", "subprocess", ".", "Popen", "(",...
Extracts to be translated strings from template and turns it into po format.
[ "Extracts", "to", "be", "translated", "strings", "from", "template", "and", "turns", "it", "into", "po", "format", "." ]
92f674b91fb8c54d6e379e2664e2000872d9c95e
https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/easymode/i18n/gettext.py#L165-L183
48,779
specialunderwear/django-easymode
easymode/i18n/gettext.py
MakeModelMessages.msgmerge
def msgmerge(self, locale_file, po_string): """ Runs msgmerge on a locale_file and po_string """ cmd = "msgmerge -q %s -" % locale_file p = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (msg, err) = p...
python
def msgmerge(self, locale_file, po_string): """ Runs msgmerge on a locale_file and po_string """ cmd = "msgmerge -q %s -" % locale_file p = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (msg, err) = p...
[ "def", "msgmerge", "(", "self", ",", "locale_file", ",", "po_string", ")", ":", "cmd", "=", "\"msgmerge -q %s -\"", "%", "locale_file", "p", "=", "subprocess", ".", "Popen", "(", "cmd", ",", "shell", "=", "True", ",", "stdin", "=", "subprocess", ".", "PI...
Runs msgmerge on a locale_file and po_string
[ "Runs", "msgmerge", "on", "a", "locale_file", "and", "po_string" ]
92f674b91fb8c54d6e379e2664e2000872d9c95e
https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/easymode/i18n/gettext.py#L191-L205
48,780
specialunderwear/django-easymode
easymode/i18n/gettext.py
MakeModelMessages.msguniq
def msguniq(self, locale_file): """ run msgunique on the locale_file """ # group related language strings together. # except if no real entries where written or the header will be removed. p = subprocess.Popen('msguniq --to-code=utf-8 %s' % (locale_file,), sh...
python
def msguniq(self, locale_file): """ run msgunique on the locale_file """ # group related language strings together. # except if no real entries where written or the header will be removed. p = subprocess.Popen('msguniq --to-code=utf-8 %s' % (locale_file,), sh...
[ "def", "msguniq", "(", "self", ",", "locale_file", ")", ":", "# group related language strings together.", "# except if no real entries where written or the header will be removed.", "p", "=", "subprocess", ".", "Popen", "(", "'msguniq --to-code=utf-8 %s'", "%", "(", "locale_fi...
run msgunique on the locale_file
[ "run", "msgunique", "on", "the", "locale_file" ]
92f674b91fb8c54d6e379e2664e2000872d9c95e
https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/easymode/i18n/gettext.py#L208-L231
48,781
jaepil/twkorean
twkorean/escape.py
to_utf8
def to_utf8(obj): """Walks a simple data structure, converting unicode to byte string. Supports lists, tuples, and dictionaries. """ if isinstance(obj, unicode_type): return _utf8(obj) elif isinstance(obj, dict): return dict((to_utf8(k), to_utf8(v)) for (k, v) in obj.items()) el...
python
def to_utf8(obj): """Walks a simple data structure, converting unicode to byte string. Supports lists, tuples, and dictionaries. """ if isinstance(obj, unicode_type): return _utf8(obj) elif isinstance(obj, dict): return dict((to_utf8(k), to_utf8(v)) for (k, v) in obj.items()) el...
[ "def", "to_utf8", "(", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "unicode_type", ")", ":", "return", "_utf8", "(", "obj", ")", "elif", "isinstance", "(", "obj", ",", "dict", ")", ":", "return", "dict", "(", "(", "to_utf8", "(", "k", ")"...
Walks a simple data structure, converting unicode to byte string. Supports lists, tuples, and dictionaries.
[ "Walks", "a", "simple", "data", "structure", "converting", "unicode", "to", "byte", "string", "." ]
f9b9264852b0a10edf7535fd98479afff7d7e6b1
https://github.com/jaepil/twkorean/blob/f9b9264852b0a10edf7535fd98479afff7d7e6b1/twkorean/escape.py#L72-L86
48,782
xflows/rdm
rdm/wrappers/aleph/aleph.py
Aleph.setPostScript
def setPostScript(self, goal, script): """ After learning call the given script using 'goal'. :param goal: goal name :param script: prolog script to call """ self.postGoal = goal self.postScript = script
python
def setPostScript(self, goal, script): """ After learning call the given script using 'goal'. :param goal: goal name :param script: prolog script to call """ self.postGoal = goal self.postScript = script
[ "def", "setPostScript", "(", "self", ",", "goal", ",", "script", ")", ":", "self", ".", "postGoal", "=", "goal", "self", ".", "postScript", "=", "script" ]
After learning call the given script using 'goal'. :param goal: goal name :param script: prolog script to call
[ "After", "learning", "call", "the", "given", "script", "using", "goal", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/wrappers/aleph/aleph.py#L102-L111
48,783
xflows/rdm
rdm/wrappers/aleph/aleph.py
Aleph.induce
def induce(self, mode, pos, neg, b, filestem='default', printOutput=False): """ Induce a theory or features in 'mode'. :param filestem: The base name of this experiment. :param mode: In which mode to induce rules/features. :param pos: String of positive examples. ...
python
def induce(self, mode, pos, neg, b, filestem='default', printOutput=False): """ Induce a theory or features in 'mode'. :param filestem: The base name of this experiment. :param mode: In which mode to induce rules/features. :param pos: String of positive examples. ...
[ "def", "induce", "(", "self", ",", "mode", ",", "pos", ",", "neg", ",", "b", ",", "filestem", "=", "'default'", ",", "printOutput", "=", "False", ")", ":", "# Write the inputs to appropriate files.", "self", ".", "__prepare", "(", "filestem", ",", "pos", "...
Induce a theory or features in 'mode'. :param filestem: The base name of this experiment. :param mode: In which mode to induce rules/features. :param pos: String of positive examples. :param neg: String of negative examples. :param b: String of background kno...
[ "Induce", "a", "theory", "or", "features", "in", "mode", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/wrappers/aleph/aleph.py#L113-L164
48,784
xflows/rdm
rdm/wrappers/aleph/aleph.py
Aleph.__script
def __script(self, mode, filestem): """ Makes the script file to be run by yap. """ scriptPath = '%s/%s' % (self.tmpdir, Aleph.SCRIPT) script = open(scriptPath, 'w') # Permit the owner to execute and read this script os.chmod(scriptPath, S_IREAD | S_IEXEC) ...
python
def __script(self, mode, filestem): """ Makes the script file to be run by yap. """ scriptPath = '%s/%s' % (self.tmpdir, Aleph.SCRIPT) script = open(scriptPath, 'w') # Permit the owner to execute and read this script os.chmod(scriptPath, S_IREAD | S_IEXEC) ...
[ "def", "__script", "(", "self", ",", "mode", ",", "filestem", ")", ":", "scriptPath", "=", "'%s/%s'", "%", "(", "self", ".", "tmpdir", ",", "Aleph", ".", "SCRIPT", ")", "script", "=", "open", "(", "scriptPath", ",", "'w'", ")", "# Permit the owner to exe...
Makes the script file to be run by yap.
[ "Makes", "the", "script", "file", "to", "be", "run", "by", "yap", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/wrappers/aleph/aleph.py#L192-L225
48,785
specialunderwear/django-easymode
example/foobar/views.py
raw
def raw(request): """shows untransformed hierarchical xml output""" foos = foobar_models.Foo.objects.all() return HttpResponse(tree.xml(foos), mimetype='text/xml')
python
def raw(request): """shows untransformed hierarchical xml output""" foos = foobar_models.Foo.objects.all() return HttpResponse(tree.xml(foos), mimetype='text/xml')
[ "def", "raw", "(", "request", ")", ":", "foos", "=", "foobar_models", ".", "Foo", ".", "objects", ".", "all", "(", ")", "return", "HttpResponse", "(", "tree", ".", "xml", "(", "foos", ")", ",", "mimetype", "=", "'text/xml'", ")" ]
shows untransformed hierarchical xml output
[ "shows", "untransformed", "hierarchical", "xml", "output" ]
92f674b91fb8c54d6e379e2664e2000872d9c95e
https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/example/foobar/views.py#L15-L18
48,786
specialunderwear/django-easymode
example/foobar/views.py
chain
def chain(request): """shows how the XmlQuerySetChain can be used instead of @toxml decorator""" bars = foobar_models.Bar.objects.all() bazs = foobar_models.Baz.objects.all() qsc = XmlQuerySetChain(bars, bazs) return HttpResponse(tree.xml(qsc), mimetype='text/xml')
python
def chain(request): """shows how the XmlQuerySetChain can be used instead of @toxml decorator""" bars = foobar_models.Bar.objects.all() bazs = foobar_models.Baz.objects.all() qsc = XmlQuerySetChain(bars, bazs) return HttpResponse(tree.xml(qsc), mimetype='text/xml')
[ "def", "chain", "(", "request", ")", ":", "bars", "=", "foobar_models", ".", "Bar", ".", "objects", ".", "all", "(", ")", "bazs", "=", "foobar_models", ".", "Baz", ".", "objects", ".", "all", "(", ")", "qsc", "=", "XmlQuerySetChain", "(", "bars", ","...
shows how the XmlQuerySetChain can be used instead of @toxml decorator
[ "shows", "how", "the", "XmlQuerySetChain", "can", "be", "used", "instead", "of" ]
92f674b91fb8c54d6e379e2664e2000872d9c95e
https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/example/foobar/views.py#L20-L25
48,787
specialunderwear/django-easymode
example/foobar/views.py
xslt
def xslt(request): """Shows xml output transformed with standard xslt""" foos = foobar_models.Foo.objects.all() return render_xslt_to_response('xslt/model-to-xml.xsl', foos, mimetype='text/xml')
python
def xslt(request): """Shows xml output transformed with standard xslt""" foos = foobar_models.Foo.objects.all() return render_xslt_to_response('xslt/model-to-xml.xsl', foos, mimetype='text/xml')
[ "def", "xslt", "(", "request", ")", ":", "foos", "=", "foobar_models", ".", "Foo", ".", "objects", ".", "all", "(", ")", "return", "render_xslt_to_response", "(", "'xslt/model-to-xml.xsl'", ",", "foos", ",", "mimetype", "=", "'text/xml'", ")" ]
Shows xml output transformed with standard xslt
[ "Shows", "xml", "output", "transformed", "with", "standard", "xslt" ]
92f674b91fb8c54d6e379e2664e2000872d9c95e
https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/example/foobar/views.py#L27-L30
48,788
gopalkoduri/intonation
intonation/recording.py
Recording.label_contours
def label_contours(self, intervals, window=150, hop=30): """ In a very flowy contour, it is not trivial to say which pitch value corresponds to what interval. This function labels pitch contours with intervals by guessing from the characteristics of the contour and its melodic context....
python
def label_contours(self, intervals, window=150, hop=30): """ In a very flowy contour, it is not trivial to say which pitch value corresponds to what interval. This function labels pitch contours with intervals by guessing from the characteristics of the contour and its melodic context....
[ "def", "label_contours", "(", "self", ",", "intervals", ",", "window", "=", "150", ",", "hop", "=", "30", ")", ":", "window", "/=", "1000.0", "hop", "/=", "1000.0", "exposure", "=", "int", "(", "window", "/", "hop", ")", "boundary", "=", "window", "-...
In a very flowy contour, it is not trivial to say which pitch value corresponds to what interval. This function labels pitch contours with intervals by guessing from the characteristics of the contour and its melodic context. :param window: the size of window over which the context is gauged,...
[ "In", "a", "very", "flowy", "contour", "it", "is", "not", "trivial", "to", "say", "which", "pitch", "value", "corresponds", "to", "what", "interval", ".", "This", "function", "labels", "pitch", "contours", "with", "intervals", "by", "guessing", "from", "the"...
7f50d2b572755840be960ea990416a7b27f20312
https://github.com/gopalkoduri/intonation/blob/7f50d2b572755840be960ea990416a7b27f20312/intonation/recording.py#L168-L213
48,789
gopalkoduri/intonation
intonation/recording.py
Recording.plot_contour_labels
def plot_contour_labels(self, new_fig=True): """ Plots the labelled contours! """ timestamps = [] pitch = [] if new_fig: p.figure() for interval, contours in self.contour_labels.items(): for contour in contours: x = self.pi...
python
def plot_contour_labels(self, new_fig=True): """ Plots the labelled contours! """ timestamps = [] pitch = [] if new_fig: p.figure() for interval, contours in self.contour_labels.items(): for contour in contours: x = self.pi...
[ "def", "plot_contour_labels", "(", "self", ",", "new_fig", "=", "True", ")", ":", "timestamps", "=", "[", "]", "pitch", "=", "[", "]", "if", "new_fig", ":", "p", ".", "figure", "(", ")", "for", "interval", ",", "contours", "in", "self", ".", "contour...
Plots the labelled contours!
[ "Plots", "the", "labelled", "contours!" ]
7f50d2b572755840be960ea990416a7b27f20312
https://github.com/gopalkoduri/intonation/blob/7f50d2b572755840be960ea990416a7b27f20312/intonation/recording.py#L215-L233
48,790
xflows/rdm
rdm/wrappers/wordification/wordification.py
wordify_example
def wordify_example(name_to_table, connecting_tables, context, cached_sentences, index_by_value, target_table_name, word_att_length, data_name, ex, searched_connections): """ Recursively constructs the 'wordification' document for the given example. :param data: The given examples E...
python
def wordify_example(name_to_table, connecting_tables, context, cached_sentences, index_by_value, target_table_name, word_att_length, data_name, ex, searched_connections): """ Recursively constructs the 'wordification' document for the given example. :param data: The given examples E...
[ "def", "wordify_example", "(", "name_to_table", ",", "connecting_tables", ",", "context", ",", "cached_sentences", ",", "index_by_value", ",", "target_table_name", ",", "word_att_length", ",", "data_name", ",", "ex", ",", "searched_connections", ")", ":", "debug", "...
Recursively constructs the 'wordification' document for the given example. :param data: The given examples ExampleTable :param ex: Example for which the document is constructed
[ "Recursively", "constructs", "the", "wordification", "document", "for", "the", "given", "example", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/wrappers/wordification/wordification.py#L31-L90
48,791
xflows/rdm
rdm/wrappers/wordification/wordification.py
Wordification.run
def run(self, num_of_processes=multiprocessing.cpu_count()): """ Applies the wordification methodology on the target table :param num_of_processes: number of processes """ # class + wordification on every example of the main table p = multiprocessing.Pool(num_of_pr...
python
def run(self, num_of_processes=multiprocessing.cpu_count()): """ Applies the wordification methodology on the target table :param num_of_processes: number of processes """ # class + wordification on every example of the main table p = multiprocessing.Pool(num_of_pr...
[ "def", "run", "(", "self", ",", "num_of_processes", "=", "multiprocessing", ".", "cpu_count", "(", ")", ")", ":", "# class + wordification on every example of the main table", "p", "=", "multiprocessing", ".", "Pool", "(", "num_of_processes", ")", "indices", "=", "c...
Applies the wordification methodology on the target table :param num_of_processes: number of processes
[ "Applies", "the", "wordification", "methodology", "on", "the", "target", "table" ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/wrappers/wordification/wordification.py#L152-L173
48,792
xflows/rdm
rdm/wrappers/wordification/wordification.py
Wordification.calculate_weights
def calculate_weights(self, measure='tfidf'): """ Counts word frequency and calculates tf-idf values for words in every document. :param measure: example weights approach (can be one of ``tfidf, binary, tf``). """ from math import log # TODO replace with spipy matri...
python
def calculate_weights(self, measure='tfidf'): """ Counts word frequency and calculates tf-idf values for words in every document. :param measure: example weights approach (can be one of ``tfidf, binary, tf``). """ from math import log # TODO replace with spipy matri...
[ "def", "calculate_weights", "(", "self", ",", "measure", "=", "'tfidf'", ")", ":", "from", "math", "import", "log", "# TODO replace with spipy matrices (and calculate with scikit)", "if", "measure", "==", "'tfidf'", ":", "self", ".", "calculate_idf", "(", ")", "for"...
Counts word frequency and calculates tf-idf values for words in every document. :param measure: example weights approach (can be one of ``tfidf, binary, tf``).
[ "Counts", "word", "frequency", "and", "calculates", "tf", "-", "idf", "values", "for", "words", "in", "every", "document", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/wrappers/wordification/wordification.py#L175-L203
48,793
xflows/rdm
rdm/wrappers/wordification/wordification.py
Wordification.to_arff
def to_arff(self): ''' Returns the "wordified" representation in ARFF. :rtype: str ''' arff_string = "@RELATION " + self.target_table.name + "\n\n" words = set() for document in self.resulting_documents: for word in document: words...
python
def to_arff(self): ''' Returns the "wordified" representation in ARFF. :rtype: str ''' arff_string = "@RELATION " + self.target_table.name + "\n\n" words = set() for document in self.resulting_documents: for word in document: words...
[ "def", "to_arff", "(", "self", ")", ":", "arff_string", "=", "\"@RELATION \"", "+", "self", ".", "target_table", ".", "name", "+", "\"\\n\\n\"", "words", "=", "set", "(", ")", "for", "document", "in", "self", ".", "resulting_documents", ":", "for", "word",...
Returns the "wordified" representation in ARFF. :rtype: str
[ "Returns", "the", "wordified", "representation", "in", "ARFF", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/wrappers/wordification/wordification.py#L220-L253
48,794
xflows/rdm
rdm/wrappers/wordification/wordification.py
Wordification.prune
def prune(self, minimum_word_frequency_percentage=1): """ Filter out words that occur less than minimum_word_frequency times. :param minimum_word_frequency_percentage: minimum frequency of words to keep """ pruned_resulting_documents = [] for document in self.result...
python
def prune(self, minimum_word_frequency_percentage=1): """ Filter out words that occur less than minimum_word_frequency times. :param minimum_word_frequency_percentage: minimum frequency of words to keep """ pruned_resulting_documents = [] for document in self.result...
[ "def", "prune", "(", "self", ",", "minimum_word_frequency_percentage", "=", "1", ")", ":", "pruned_resulting_documents", "=", "[", "]", "for", "document", "in", "self", ".", "resulting_documents", ":", "new_document", "=", "[", "]", "for", "word", "in", "docum...
Filter out words that occur less than minimum_word_frequency times. :param minimum_word_frequency_percentage: minimum frequency of words to keep
[ "Filter", "out", "words", "that", "occur", "less", "than", "minimum_word_frequency", "times", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/wrappers/wordification/wordification.py#L255-L270
48,795
xflows/rdm
rdm/wrappers/wordification/wordification.py
Wordification.wordify
def wordify(self): """ Constructs string of all documents. :return: document representation of the dataset, one line per document :rtype: str """ string_documents = [] for klass, document in zip(self.resulting_classes, self.resulting_documents): ...
python
def wordify(self): """ Constructs string of all documents. :return: document representation of the dataset, one line per document :rtype: str """ string_documents = [] for klass, document in zip(self.resulting_classes, self.resulting_documents): ...
[ "def", "wordify", "(", "self", ")", ":", "string_documents", "=", "[", "]", "for", "klass", ",", "document", "in", "zip", "(", "self", ".", "resulting_classes", ",", "self", ".", "resulting_documents", ")", ":", "string_documents", ".", "append", "(", "\"!...
Constructs string of all documents. :return: document representation of the dataset, one line per document :rtype: str
[ "Constructs", "string", "of", "all", "documents", "." ]
d984e2a0297e5fa8d799953bbd0dba79b05d403d
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/wrappers/wordification/wordification.py#L272-L282
48,796
edibledinos/pwnypack
pwnypack/main.py
binary_value_or_stdin
def binary_value_or_stdin(value): """ Return fsencoded value or read raw data from stdin if value is None. """ if value is None: reader = io.open(sys.stdin.fileno(), mode='rb', closefd=False) return reader.read() elif six.PY3: return os.fsencode(value) else: retur...
python
def binary_value_or_stdin(value): """ Return fsencoded value or read raw data from stdin if value is None. """ if value is None: reader = io.open(sys.stdin.fileno(), mode='rb', closefd=False) return reader.read() elif six.PY3: return os.fsencode(value) else: retur...
[ "def", "binary_value_or_stdin", "(", "value", ")", ":", "if", "value", "is", "None", ":", "reader", "=", "io", ".", "open", "(", "sys", ".", "stdin", ".", "fileno", "(", ")", ",", "mode", "=", "'rb'", ",", "closefd", "=", "False", ")", "return", "r...
Return fsencoded value or read raw data from stdin if value is None.
[ "Return", "fsencoded", "value", "or", "read", "raw", "data", "from", "stdin", "if", "value", "is", "None", "." ]
e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6
https://github.com/edibledinos/pwnypack/blob/e0a5a8e6ef3f4f1f7e1b91ee379711f4a49cb0e6/pwnypack/main.py#L36-L46
48,797
openpaperwork/paperwork-backend
paperwork_backend/labels.py
Label.__label_cmp
def __label_cmp(self, other): """ Comparaison function. Can be used to sort labels alphabetically. """ if other is None: return -1 label_name = strip_accents(self.name).lower() other_name = strip_accents(other.name).lower() if label_name < other_name:...
python
def __label_cmp(self, other): """ Comparaison function. Can be used to sort labels alphabetically. """ if other is None: return -1 label_name = strip_accents(self.name).lower() other_name = strip_accents(other.name).lower() if label_name < other_name:...
[ "def", "__label_cmp", "(", "self", ",", "other", ")", ":", "if", "other", "is", "None", ":", "return", "-", "1", "label_name", "=", "strip_accents", "(", "self", ".", "name", ")", ".", "lower", "(", ")", "other_name", "=", "strip_accents", "(", "other"...
Comparaison function. Can be used to sort labels alphabetically.
[ "Comparaison", "function", ".", "Can", "be", "used", "to", "sort", "labels", "alphabetically", "." ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/labels.py#L67-L88
48,798
openpaperwork/paperwork-backend
paperwork_backend/labels.py
Label.get_html_color
def get_html_color(self): """ get a string representing the color, using HTML notation """ color = self.color return ("#%02x%02x%02x" % ( int(color.red), int(color.green), int(color.blue) ))
python
def get_html_color(self): """ get a string representing the color, using HTML notation """ color = self.color return ("#%02x%02x%02x" % ( int(color.red), int(color.green), int(color.blue) ))
[ "def", "get_html_color", "(", "self", ")", ":", "color", "=", "self", ".", "color", "return", "(", "\"#%02x%02x%02x\"", "%", "(", "int", "(", "color", ".", "red", ")", ",", "int", "(", "color", ".", "green", ")", ",", "int", "(", "color", ".", "blu...
get a string representing the color, using HTML notation
[ "get", "a", "string", "representing", "the", "color", "using", "HTML", "notation" ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/labels.py#L111-L118
48,799
openpaperwork/paperwork-backend
paperwork_backend/labels.py
LabelGuesser.forget
def forget(self, label_name): """ Forget training for label 'label_name' """ self._bayes.pop(label_name) baye_dir = self._get_baye_dir(label_name) logger.info("Deleting label training {} : {}".format( label_name, baye_dir )) rm_rf(baye_dir)
python
def forget(self, label_name): """ Forget training for label 'label_name' """ self._bayes.pop(label_name) baye_dir = self._get_baye_dir(label_name) logger.info("Deleting label training {} : {}".format( label_name, baye_dir )) rm_rf(baye_dir)
[ "def", "forget", "(", "self", ",", "label_name", ")", ":", "self", ".", "_bayes", ".", "pop", "(", "label_name", ")", "baye_dir", "=", "self", ".", "_get_baye_dir", "(", "label_name", ")", "logger", ".", "info", "(", "\"Deleting label training {} : {}\"", "....
Forget training for label 'label_name'
[ "Forget", "training", "for", "label", "label_name" ]
114b831e94e039e68b339751fd18250877abad76
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/labels.py#L281-L290