repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
jasonfharris/sysexecute
sysexecute/execute.py
execute
def execute(cmd, verbosityThreshold = 1, **kwargs): '''execute the passed in command in the shell''' global exectue_defaults opts = merge(exectue_defaults, kwargs) # the options computed from the default options together with the passed in options. subopts = filterKWArgsForFunc(opts, subpro...
python
def execute(cmd, verbosityThreshold = 1, **kwargs): '''execute the passed in command in the shell''' global exectue_defaults opts = merge(exectue_defaults, kwargs) # the options computed from the default options together with the passed in options. subopts = filterKWArgsForFunc(opts, subpro...
[ "def", "execute", "(", "cmd", ",", "verbosityThreshold", "=", "1", ",", "*", "*", "kwargs", ")", ":", "global", "exectue_defaults", "opts", "=", "merge", "(", "exectue_defaults", ",", "kwargs", ")", "# the options computed from the default options together with the pa...
execute the passed in command in the shell
[ "execute", "the", "passed", "in", "command", "in", "the", "shell" ]
train
https://github.com/jasonfharris/sysexecute/blob/5fb0639364fa91452da93f99220bf622351d0b7a/sysexecute/execute.py#L190-L226
collectiveacuity/labPack
labpack/databases/sql.py
sqlClient._extract_columns
def _extract_columns(self, table_name): ''' a method to extract the column properties of an existing table ''' import re from sqlalchemy import MetaData, VARCHAR, INTEGER, BLOB, BOOLEAN, FLOAT from sqlalchemy.dialects.postgresql import DOUBLE_PRECISION, BIT, BYTEA ...
python
def _extract_columns(self, table_name): ''' a method to extract the column properties of an existing table ''' import re from sqlalchemy import MetaData, VARCHAR, INTEGER, BLOB, BOOLEAN, FLOAT from sqlalchemy.dialects.postgresql import DOUBLE_PRECISION, BIT, BYTEA ...
[ "def", "_extract_columns", "(", "self", ",", "table_name", ")", ":", "import", "re", "from", "sqlalchemy", "import", "MetaData", ",", "VARCHAR", ",", "INTEGER", ",", "BLOB", ",", "BOOLEAN", ",", "FLOAT", "from", "sqlalchemy", ".", "dialects", ".", "postgresq...
a method to extract the column properties of an existing table
[ "a", "method", "to", "extract", "the", "column", "properties", "of", "an", "existing", "table" ]
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/databases/sql.py#L268-L308
collectiveacuity/labPack
labpack/databases/sql.py
sqlClient._parse_columns
def _parse_columns(self): ''' a helper method for parsing the column properties from the record schema ''' # construct column list column_map = {} for key, value in self.model.keyMap.items(): record_key = key[1:] if record_key: if self.it...
python
def _parse_columns(self): ''' a helper method for parsing the column properties from the record schema ''' # construct column list column_map = {} for key, value in self.model.keyMap.items(): record_key = key[1:] if record_key: if self.it...
[ "def", "_parse_columns", "(", "self", ")", ":", "# construct column list", "column_map", "=", "{", "}", "for", "key", ",", "value", "in", "self", ".", "model", ".", "keyMap", ".", "items", "(", ")", ":", "record_key", "=", "key", "[", "1", ":", "]", ...
a helper method for parsing the column properties from the record schema
[ "a", "helper", "method", "for", "parsing", "the", "column", "properties", "from", "the", "record", "schema" ]
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/databases/sql.py#L310-L340
collectiveacuity/labPack
labpack/databases/sql.py
sqlClient._construct_columns
def _construct_columns(self, column_map): ''' a helper method for constructing the column objects for a table object ''' from sqlalchemy import Column, String, Boolean, Integer, Float, Binary column_args = [] for key, value in column_map.items(): recor...
python
def _construct_columns(self, column_map): ''' a helper method for constructing the column objects for a table object ''' from sqlalchemy import Column, String, Boolean, Integer, Float, Binary column_args = [] for key, value in column_map.items(): recor...
[ "def", "_construct_columns", "(", "self", ",", "column_map", ")", ":", "from", "sqlalchemy", "import", "Column", ",", "String", ",", "Boolean", ",", "Integer", ",", "Float", ",", "Binary", "column_args", "=", "[", "]", "for", "key", ",", "value", "in", "...
a helper method for constructing the column objects for a table object
[ "a", "helper", "method", "for", "constructing", "the", "column", "objects", "for", "a", "table", "object" ]
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/databases/sql.py#L342-L381
collectiveacuity/labPack
labpack/databases/sql.py
sqlClient._reconstruct_record
def _reconstruct_record(self, record_object): ''' a helper method for reconstructing record fields from record object ''' record_details = {} current_details = record_details for key, value in self.model.keyMap.items(): record_key = key[1:] if re...
python
def _reconstruct_record(self, record_object): ''' a helper method for reconstructing record fields from record object ''' record_details = {} current_details = record_details for key, value in self.model.keyMap.items(): record_key = key[1:] if re...
[ "def", "_reconstruct_record", "(", "self", ",", "record_object", ")", ":", "record_details", "=", "{", "}", "current_details", "=", "record_details", "for", "key", ",", "value", "in", "self", ".", "model", ".", "keyMap", ".", "items", "(", ")", ":", "recor...
a helper method for reconstructing record fields from record object
[ "a", "helper", "method", "for", "reconstructing", "record", "fields", "from", "record", "object" ]
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/databases/sql.py#L383-L408
collectiveacuity/labPack
labpack/databases/sql.py
sqlClient._compare_columns
def _compare_columns(self, new_columns, old_columns): ''' a helper method for generating differences between column properties ''' # print(new_columns) # print(old_columns) add_columns = {} remove_columns = {} rename_columns = {} retype_...
python
def _compare_columns(self, new_columns, old_columns): ''' a helper method for generating differences between column properties ''' # print(new_columns) # print(old_columns) add_columns = {} remove_columns = {} rename_columns = {} retype_...
[ "def", "_compare_columns", "(", "self", ",", "new_columns", ",", "old_columns", ")", ":", "# print(new_columns)", "# print(old_columns)", "add_columns", "=", "{", "}", "remove_columns", "=", "{", "}", "rename_columns", "=", "{", "}", "retype_columns", "=", "{", ...
a helper method for generating differences between column properties
[ "a", "helper", "method", "for", "generating", "differences", "between", "column", "properties" ]
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/databases/sql.py#L410-L439
collectiveacuity/labPack
labpack/databases/sql.py
sqlClient._construct_inserts
def _construct_inserts(self, record, new_columns, rename_columns, retype_columns, resize_columns): ''' a helper method for constructing the insert kwargs for a record ''' insert_kwargs = {} for key, value in new_columns.items(): # retrieve value for key (or from old key name) ...
python
def _construct_inserts(self, record, new_columns, rename_columns, retype_columns, resize_columns): ''' a helper method for constructing the insert kwargs for a record ''' insert_kwargs = {} for key, value in new_columns.items(): # retrieve value for key (or from old key name) ...
[ "def", "_construct_inserts", "(", "self", ",", "record", ",", "new_columns", ",", "rename_columns", ",", "retype_columns", ",", "resize_columns", ")", ":", "insert_kwargs", "=", "{", "}", "for", "key", ",", "value", "in", "new_columns", ".", "items", "(", ")...
a helper method for constructing the insert kwargs for a record
[ "a", "helper", "method", "for", "constructing", "the", "insert", "kwargs", "for", "a", "record" ]
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/databases/sql.py#L441-L499
collectiveacuity/labPack
labpack/databases/sql.py
sqlClient._rebuild_table
def _rebuild_table(self, new_name, old_name, new_columns, old_columns): ''' a helper method for rebuilding table (by renaming & migrating) ''' # verbosity print('Rebuilding %s table in %s database' % (self.table_name, self.database_name), end='', flush=True) from sqla...
python
def _rebuild_table(self, new_name, old_name, new_columns, old_columns): ''' a helper method for rebuilding table (by renaming & migrating) ''' # verbosity print('Rebuilding %s table in %s database' % (self.table_name, self.database_name), end='', flush=True) from sqla...
[ "def", "_rebuild_table", "(", "self", ",", "new_name", ",", "old_name", ",", "new_columns", ",", "old_columns", ")", ":", "# verbosity", "print", "(", "'Rebuilding %s table in %s database'", "%", "(", "self", ".", "table_name", ",", "self", ".", "database_name", ...
a helper method for rebuilding table (by renaming & migrating)
[ "a", "helper", "method", "for", "rebuilding", "table", "(", "by", "renaming", "&", "migrating", ")" ]
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/databases/sql.py#L501-L557
collectiveacuity/labPack
labpack/databases/sql.py
sqlClient.exists
def exists(self, primary_key): ''' a method to determine if record exists :param primary_key: string with primary key of record :return: boolean to indicate existence of record ''' select_statement = self.table.select(self.table).where(...
python
def exists(self, primary_key): ''' a method to determine if record exists :param primary_key: string with primary key of record :return: boolean to indicate existence of record ''' select_statement = self.table.select(self.table).where(...
[ "def", "exists", "(", "self", ",", "primary_key", ")", ":", "select_statement", "=", "self", ".", "table", ".", "select", "(", "self", ".", "table", ")", ".", "where", "(", "self", ".", "table", ".", "c", ".", "id", "==", "primary_key", ")", "record_...
a method to determine if record exists :param primary_key: string with primary key of record :return: boolean to indicate existence of record
[ "a", "method", "to", "determine", "if", "record", "exists", ":", "param", "primary_key", ":", "string", "with", "primary", "key", "of", "record", ":", "return", ":", "boolean", "to", "indicate", "existence", "of", "record" ]
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/databases/sql.py#L559-L572
collectiveacuity/labPack
labpack/databases/sql.py
sqlClient.list
def list(self, query_criteria=None, order_criteria=None): ''' a generator method to list records in table which match query criteria :param query_criteria: dictionary with schema dot-path field names and query qualifiers :param order_criteria: list of single key...
python
def list(self, query_criteria=None, order_criteria=None): ''' a generator method to list records in table which match query criteria :param query_criteria: dictionary with schema dot-path field names and query qualifiers :param order_criteria: list of single key...
[ "def", "list", "(", "self", ",", "query_criteria", "=", "None", ",", "order_criteria", "=", "None", ")", ":", "title", "=", "'%s.list'", "%", "self", ".", "__class__", ".", "__name__", "from", "sqlalchemy", "import", "desc", "as", "order_desc", "# validate i...
a generator method to list records in table which match query criteria :param query_criteria: dictionary with schema dot-path field names and query qualifiers :param order_criteria: list of single keypair dictionaries with field names to order by :return: generator object with stri...
[ "a", "generator", "method", "to", "list", "records", "in", "table", "which", "match", "query", "criteria", ":", "param", "query_criteria", ":", "dictionary", "with", "schema", "dot", "-", "path", "field", "names", "and", "query", "qualifiers", ":", "param", ...
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/databases/sql.py#L574-L733
collectiveacuity/labPack
labpack/databases/sql.py
sqlClient.create
def create(self, record_details): ''' a method to create a new record in the table NOTE: this class uses the id key as the primary key for all records if record_details includes an id field that is an integer, float or string, the...
python
def create(self, record_details): ''' a method to create a new record in the table NOTE: this class uses the id key as the primary key for all records if record_details includes an id field that is an integer, float or string, the...
[ "def", "create", "(", "self", ",", "record_details", ")", ":", "# validate inputs", "record_details", "=", "self", ".", "model", ".", "validate", "(", "record_details", ")", "# add fields to create request", "create_kwargs", "=", "{", "}", "for", "key", ",", "va...
a method to create a new record in the table NOTE: this class uses the id key as the primary key for all records if record_details includes an id field that is an integer, float or string, then it will be used as the primary key. if the id ...
[ "a", "method", "to", "create", "a", "new", "record", "in", "the", "table", "NOTE", ":", "this", "class", "uses", "the", "id", "key", "as", "the", "primary", "key", "for", "all", "records", "if", "record_details", "includes", "an", "id", "field", "that", ...
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/databases/sql.py#L735-L795
collectiveacuity/labPack
labpack/databases/sql.py
sqlClient.read
def read(self, primary_key): ''' a method to retrieve the details for a record in the table :param primary_key: string with primary key of record :return: dictionary with record fields ''' title = '%s.read' % self.__class__.__name__ ...
python
def read(self, primary_key): ''' a method to retrieve the details for a record in the table :param primary_key: string with primary key of record :return: dictionary with record fields ''' title = '%s.read' % self.__class__.__name__ ...
[ "def", "read", "(", "self", ",", "primary_key", ")", ":", "title", "=", "'%s.read'", "%", "self", ".", "__class__", ".", "__name__", "# retrieve record object", "# record_object = self.session.query(self.record).filter_by(id=primary_key).first()", "select_statement", "=", "...
a method to retrieve the details for a record in the table :param primary_key: string with primary key of record :return: dictionary with record fields
[ "a", "method", "to", "retrieve", "the", "details", "for", "a", "record", "in", "the", "table", ":", "param", "primary_key", ":", "string", "with", "primary", "key", "of", "record", ":", "return", ":", "dictionary", "with", "record", "fields" ]
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/databases/sql.py#L797-L818
collectiveacuity/labPack
labpack/databases/sql.py
sqlClient.update
def update(self, new_details, old_details=None): ''' a method to upsert changes to a record in the table :param new_details: dictionary with updated record fields :param old_details: [optional] dictionary with original record fields :return: list of dictionaries with u...
python
def update(self, new_details, old_details=None): ''' a method to upsert changes to a record in the table :param new_details: dictionary with updated record fields :param old_details: [optional] dictionary with original record fields :return: list of dictionaries with u...
[ "def", "update", "(", "self", ",", "new_details", ",", "old_details", "=", "None", ")", ":", "title", "=", "'%s.update'", "%", "self", ".", "__class__", ".", "__name__", "# validate inputs", "input_fields", "=", "{", "'new_details'", ":", "new_details", ",", ...
a method to upsert changes to a record in the table :param new_details: dictionary with updated record fields :param old_details: [optional] dictionary with original record fields :return: list of dictionaries with updated field details NOTE: if old_details is empty,...
[ "a", "method", "to", "upsert", "changes", "to", "a", "record", "in", "the", "table", ":", "param", "new_details", ":", "dictionary", "with", "updated", "record", "fields", ":", "param", "old_details", ":", "[", "optional", "]", "dictionary", "with", "origina...
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/databases/sql.py#L820-L913
collectiveacuity/labPack
labpack/databases/sql.py
sqlClient.delete
def delete(self, primary_key): ''' a method to delete a record in the table :param primary_key: string with primary key of record :return: string with status message ''' title = '%s.delete' % self.__class__.__name__ # delete obje...
python
def delete(self, primary_key): ''' a method to delete a record in the table :param primary_key: string with primary key of record :return: string with status message ''' title = '%s.delete' % self.__class__.__name__ # delete obje...
[ "def", "delete", "(", "self", ",", "primary_key", ")", ":", "title", "=", "'%s.delete'", "%", "self", ".", "__class__", ".", "__name__", "# delete object", "delete_statement", "=", "self", ".", "table", ".", "delete", "(", "self", ".", "table", ".", "c", ...
a method to delete a record in the table :param primary_key: string with primary key of record :return: string with status message
[ "a", "method", "to", "delete", "a", "record", "in", "the", "table", ":", "param", "primary_key", ":", "string", "with", "primary", "key", "of", "record", ":", "return", ":", "string", "with", "status", "message" ]
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/databases/sql.py#L915-L932
collectiveacuity/labPack
labpack/databases/sql.py
sqlClient.remove
def remove(self): ''' a method to remove the entire table :return string with status message ''' self.table.drop(self.engine) exit_msg = '%s table has been removed from %s database.' % (self.table_name, self.database_name) ...
python
def remove(self): ''' a method to remove the entire table :return string with status message ''' self.table.drop(self.engine) exit_msg = '%s table has been removed from %s database.' % (self.table_name, self.database_name) ...
[ "def", "remove", "(", "self", ")", ":", "self", ".", "table", ".", "drop", "(", "self", ".", "engine", ")", "exit_msg", "=", "'%s table has been removed from %s database.'", "%", "(", "self", ".", "table_name", ",", "self", ".", "database_name", ")", "self",...
a method to remove the entire table :return string with status message
[ "a", "method", "to", "remove", "the", "entire", "table", ":", "return", "string", "with", "status", "message" ]
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/databases/sql.py#L934-L947
collectiveacuity/labPack
labpack/databases/sql.py
sqlClient.export
def export(self, sql_client, merge_rule='skip', coerce=False): ''' a method to export all the records in table to another table :param sql_client: class object with sql client methods :param merge_rule: string with name of rule to adopt for pre-existing records :param coerc...
python
def export(self, sql_client, merge_rule='skip', coerce=False): ''' a method to export all the records in table to another table :param sql_client: class object with sql client methods :param merge_rule: string with name of rule to adopt for pre-existing records :param coerc...
[ "def", "export", "(", "self", ",", "sql_client", ",", "merge_rule", "=", "'skip'", ",", "coerce", "=", "False", ")", ":", "title", "=", "'%s.export'", "%", "self", ".", "__class__", ".", "__name__", "# validate sql client", "method_list", "=", "[", "'list'",...
a method to export all the records in table to another table :param sql_client: class object with sql client methods :param merge_rule: string with name of rule to adopt for pre-existing records :param coerce: boolean to enable migration even if table schemas don't match :return: string...
[ "a", "method", "to", "export", "all", "the", "records", "in", "table", "to", "another", "table" ]
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/databases/sql.py#L949-L1066
abusque/qng
qng/generator.py
QuebNameGenerator.generate
def generate(self, gender=None, part=None, snake_case=False, weighted=False): """Generate a Queb name. :param str gender: Gender of name to generate, one of 'male' or 'female'. If not specified, either gender can be generated. (optional) :param str part: Part of the name...
python
def generate(self, gender=None, part=None, snake_case=False, weighted=False): """Generate a Queb name. :param str gender: Gender of name to generate, one of 'male' or 'female'. If not specified, either gender can be generated. (optional) :param str part: Part of the name...
[ "def", "generate", "(", "self", ",", "gender", "=", "None", ",", "part", "=", "None", ",", "snake_case", "=", "False", ",", "weighted", "=", "False", ")", ":", "if", "weighted", ":", "get_random_name", "=", "self", ".", "_get_weighted_random_name", "else",...
Generate a Queb name. :param str gender: Gender of name to generate, one of 'male' or 'female'. If not specified, either gender can be generated. (optional) :param str part: Part of the name to generate, one of 'first' or 'last'. If not specified, full names are ...
[ "Generate", "a", "Queb", "name", "." ]
train
https://github.com/abusque/qng/blob/93d2efd637b2a6bba7d3872fb9ff2bb3fc5c979d/qng/generator.py#L30-L69
abusque/qng
qng/generator.py
QuebNameGenerator._read_name_file
def _read_name_file(self, filename): """Read a name file from the data directory :param filename: Name of the file to read. :return: A list of name entries. """ file_path = os.path.join(self._DATA_DIR, filename) with open(file_path) as f: names = json.load(f)...
python
def _read_name_file(self, filename): """Read a name file from the data directory :param filename: Name of the file to read. :return: A list of name entries. """ file_path = os.path.join(self._DATA_DIR, filename) with open(file_path) as f: names = json.load(f)...
[ "def", "_read_name_file", "(", "self", ",", "filename", ")", ":", "file_path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "_DATA_DIR", ",", "filename", ")", "with", "open", "(", "file_path", ")", "as", "f", ":", "names", "=", "json", ".",...
Read a name file from the data directory :param filename: Name of the file to read. :return: A list of name entries.
[ "Read", "a", "name", "file", "from", "the", "data", "directory" ]
train
https://github.com/abusque/qng/blob/93d2efd637b2a6bba7d3872fb9ff2bb3fc5c979d/qng/generator.py#L71-L81
abusque/qng
qng/generator.py
QuebNameGenerator._get_names
def _get_names(self): """Get the list of first names. :return: A list of first name entries. """ names = self._read_name_file('names.json') names = self._compute_weights(names) return names
python
def _get_names(self): """Get the list of first names. :return: A list of first name entries. """ names = self._read_name_file('names.json') names = self._compute_weights(names) return names
[ "def", "_get_names", "(", "self", ")", ":", "names", "=", "self", ".", "_read_name_file", "(", "'names.json'", ")", "names", "=", "self", ".", "_compute_weights", "(", "names", ")", "return", "names" ]
Get the list of first names. :return: A list of first name entries.
[ "Get", "the", "list", "of", "first", "names", "." ]
train
https://github.com/abusque/qng/blob/93d2efd637b2a6bba7d3872fb9ff2bb3fc5c979d/qng/generator.py#L83-L91
abusque/qng
qng/generator.py
QuebNameGenerator._get_surnames
def _get_surnames(self): """Get the list of surnames. :return: A list of surname entries. """ names = self._read_name_file('surnames.json') names = self._compute_weights(names) return names
python
def _get_surnames(self): """Get the list of surnames. :return: A list of surname entries. """ names = self._read_name_file('surnames.json') names = self._compute_weights(names) return names
[ "def", "_get_surnames", "(", "self", ")", ":", "names", "=", "self", ".", "_read_name_file", "(", "'surnames.json'", ")", "names", "=", "self", ".", "_compute_weights", "(", "names", ")", "return", "names" ]
Get the list of surnames. :return: A list of surname entries.
[ "Get", "the", "list", "of", "surnames", "." ]
train
https://github.com/abusque/qng/blob/93d2efd637b2a6bba7d3872fb9ff2bb3fc5c979d/qng/generator.py#L111-L119
abusque/qng
qng/generator.py
QuebNameGenerator._get_random_name
def _get_random_name(name_list): """Get a random name from a given list. The choice of the name is fully random. :param name_list: The list of names from which to pick. :return str: A randomly chosen name. """ length = len(name_list) index = random.randrange(len...
python
def _get_random_name(name_list): """Get a random name from a given list. The choice of the name is fully random. :param name_list: The list of names from which to pick. :return str: A randomly chosen name. """ length = len(name_list) index = random.randrange(len...
[ "def", "_get_random_name", "(", "name_list", ")", ":", "length", "=", "len", "(", "name_list", ")", "index", "=", "random", ".", "randrange", "(", "length", ")", "return", "name_list", "[", "index", "]", "[", "'name'", "]" ]
Get a random name from a given list. The choice of the name is fully random. :param name_list: The list of names from which to pick. :return str: A randomly chosen name.
[ "Get", "a", "random", "name", "from", "a", "given", "list", "." ]
train
https://github.com/abusque/qng/blob/93d2efd637b2a6bba7d3872fb9ff2bb3fc5c979d/qng/generator.py#L134-L145
abusque/qng
qng/generator.py
QuebNameGenerator._get_weighted_random_name
def _get_weighted_random_name(name_list): """Get a random name from a given list, according to its frequency. The choice of the name is random, but weighted in proportion to the relative frequency or popularity of each name in the list. If one name is twice as popular as another one, th...
python
def _get_weighted_random_name(name_list): """Get a random name from a given list, according to its frequency. The choice of the name is random, but weighted in proportion to the relative frequency or popularity of each name in the list. If one name is twice as popular as another one, th...
[ "def", "_get_weighted_random_name", "(", "name_list", ")", ":", "total_weight", "=", "name_list", "[", "-", "1", "]", "[", "'weight_high'", "]", "random_weight", "=", "random", ".", "randrange", "(", "total_weight", "+", "1", ")", "left", "=", "0", "right", ...
Get a random name from a given list, according to its frequency. The choice of the name is random, but weighted in proportion to the relative frequency or popularity of each name in the list. If one name is twice as popular as another one, then it is twice as likely to get chosen. ...
[ "Get", "a", "random", "name", "from", "a", "given", "list", "according", "to", "its", "frequency", "." ]
train
https://github.com/abusque/qng/blob/93d2efd637b2a6bba7d3872fb9ff2bb3fc5c979d/qng/generator.py#L148-L174
abusque/qng
qng/generator.py
QuebNameGenerator._format_name
def _format_name(self, name, surname, snake_case=False): """Format a first name and a surname into a cohesive string. Note that either name or surname can be empty strings, and formatting will still succeed. :param str name: A first name. :param str surname: A surname. ...
python
def _format_name(self, name, surname, snake_case=False): """Format a first name and a surname into a cohesive string. Note that either name or surname can be empty strings, and formatting will still succeed. :param str name: A first name. :param str surname: A surname. ...
[ "def", "_format_name", "(", "self", ",", "name", ",", "surname", ",", "snake_case", "=", "False", ")", ":", "if", "not", "name", "or", "not", "surname", ":", "sep", "=", "''", "elif", "snake_case", ":", "sep", "=", "'_'", "else", ":", "sep", "=", "...
Format a first name and a surname into a cohesive string. Note that either name or surname can be empty strings, and formatting will still succeed. :param str name: A first name. :param str surname: A surname. :param bool snake_case: If True, format the name as "sna...
[ "Format", "a", "first", "name", "and", "a", "surname", "into", "a", "cohesive", "string", "." ]
train
https://github.com/abusque/qng/blob/93d2efd637b2a6bba7d3872fb9ff2bb3fc5c979d/qng/generator.py#L176-L202
abusque/qng
qng/generator.py
QuebNameGenerator._snakify_name
def _snakify_name(self, name): """Snakify a name string. In this context, "to snakify" means to strip a name of all diacritics, convert it to lower case, and replace any spaces inside the name with hyphens. This way the name is made "machine-friendly", and ready to be c...
python
def _snakify_name(self, name): """Snakify a name string. In this context, "to snakify" means to strip a name of all diacritics, convert it to lower case, and replace any spaces inside the name with hyphens. This way the name is made "machine-friendly", and ready to be c...
[ "def", "_snakify_name", "(", "self", ",", "name", ")", ":", "name", "=", "self", ".", "_strip_diacritics", "(", "name", ")", "name", "=", "name", ".", "lower", "(", ")", "name", "=", "name", ".", "replace", "(", "' '", ",", "'-'", ")", "return", "n...
Snakify a name string. In this context, "to snakify" means to strip a name of all diacritics, convert it to lower case, and replace any spaces inside the name with hyphens. This way the name is made "machine-friendly", and ready to be combined with a second name component into ...
[ "Snakify", "a", "name", "string", "." ]
train
https://github.com/abusque/qng/blob/93d2efd637b2a6bba7d3872fb9ff2bb3fc5c979d/qng/generator.py#L204-L222
rameshg87/pyremotevbox
pyremotevbox/ZSI/wstools/c14n.py
_sorter
def _sorter(n1,n2): '''_sorter(n1,n2) -> int Sorting predicate for non-NS attributes.''' i = cmp(n1.namespaceURI, n2.namespaceURI) if i: return i return cmp(n1.localName, n2.localName)
python
def _sorter(n1,n2): '''_sorter(n1,n2) -> int Sorting predicate for non-NS attributes.''' i = cmp(n1.namespaceURI, n2.namespaceURI) if i: return i return cmp(n1.localName, n2.localName)
[ "def", "_sorter", "(", "n1", ",", "n2", ")", ":", "i", "=", "cmp", "(", "n1", ".", "namespaceURI", ",", "n2", ".", "namespaceURI", ")", "if", "i", ":", "return", "i", "return", "cmp", "(", "n1", ".", "localName", ",", "n2", ".", "localName", ")" ...
_sorter(n1,n2) -> int Sorting predicate for non-NS attributes.
[ "_sorter", "(", "n1", "n2", ")", "-", ">", "int", "Sorting", "predicate", "for", "non", "-", "NS", "attributes", "." ]
train
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/c14n.py#L74-L80
rameshg87/pyremotevbox
pyremotevbox/ZSI/wstools/c14n.py
_utilized
def _utilized(n, node, other_attrs, unsuppressedPrefixes): '''_utilized(n, node, other_attrs, unsuppressedPrefixes) -> boolean Return true if that nodespace is utilized within the node''' if n.startswith('xmlns:'): n = n[6:] elif n.startswith('xmlns'): n = n[5:] if (n=="" and node.pr...
python
def _utilized(n, node, other_attrs, unsuppressedPrefixes): '''_utilized(n, node, other_attrs, unsuppressedPrefixes) -> boolean Return true if that nodespace is utilized within the node''' if n.startswith('xmlns:'): n = n[6:] elif n.startswith('xmlns'): n = n[5:] if (n=="" and node.pr...
[ "def", "_utilized", "(", "n", ",", "node", ",", "other_attrs", ",", "unsuppressedPrefixes", ")", ":", "if", "n", ".", "startswith", "(", "'xmlns:'", ")", ":", "n", "=", "n", "[", "6", ":", "]", "elif", "n", ".", "startswith", "(", "'xmlns'", ")", "...
_utilized(n, node, other_attrs, unsuppressedPrefixes) -> boolean Return true if that nodespace is utilized within the node
[ "_utilized", "(", "n", "node", "other_attrs", "unsuppressedPrefixes", ")", "-", ">", "boolean", "Return", "true", "if", "that", "nodespace", "is", "utilized", "within", "the", "node" ]
train
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/c14n.py#L91-L108
rameshg87/pyremotevbox
pyremotevbox/ZSI/wstools/c14n.py
_inclusiveNamespacePrefixes
def _inclusiveNamespacePrefixes(node, context, unsuppressedPrefixes): '''http://www.w3.org/TR/xml-exc-c14n/ InclusiveNamespaces PrefixList parameter, which lists namespace prefixes that are handled in the manner described by the Canonical XML Recommendation''' inclusive = [] if node.prefix: ...
python
def _inclusiveNamespacePrefixes(node, context, unsuppressedPrefixes): '''http://www.w3.org/TR/xml-exc-c14n/ InclusiveNamespaces PrefixList parameter, which lists namespace prefixes that are handled in the manner described by the Canonical XML Recommendation''' inclusive = [] if node.prefix: ...
[ "def", "_inclusiveNamespacePrefixes", "(", "node", ",", "context", ",", "unsuppressedPrefixes", ")", ":", "inclusive", "=", "[", "]", "if", "node", ".", "prefix", ":", "usedPrefixes", "=", "[", "'xmlns:%s'", "%", "node", ".", "prefix", "]", "else", ":", "u...
http://www.w3.org/TR/xml-exc-c14n/ InclusiveNamespaces PrefixList parameter, which lists namespace prefixes that are handled in the manner described by the Canonical XML Recommendation
[ "http", ":", "//", "www", ".", "w3", ".", "org", "/", "TR", "/", "xml", "-", "exc", "-", "c14n", "/", "InclusiveNamespaces", "PrefixList", "parameter", "which", "lists", "namespace", "prefixes", "that", "are", "handled", "in", "the", "manner", "described",...
train
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/c14n.py#L111-L139
rameshg87/pyremotevbox
pyremotevbox/ZSI/wstools/c14n.py
Canonicalize
def Canonicalize(node, output=None, **kw): '''Canonicalize(node, output=None, **kw) -> UTF-8 Canonicalize a DOM document/element node and all descendents. Return the text; if output is specified then output.write will be called to output the text and None will be returned Keyword parameters: ...
python
def Canonicalize(node, output=None, **kw): '''Canonicalize(node, output=None, **kw) -> UTF-8 Canonicalize a DOM document/element node and all descendents. Return the text; if output is specified then output.write will be called to output the text and None will be returned Keyword parameters: ...
[ "def", "Canonicalize", "(", "node", ",", "output", "=", "None", ",", "*", "*", "kw", ")", ":", "if", "output", ":", "apply", "(", "_implementation", ",", "(", "node", ",", "output", ".", "write", ")", ",", "kw", ")", "else", ":", "s", "=", "Strin...
Canonicalize(node, output=None, **kw) -> UTF-8 Canonicalize a DOM document/element node and all descendents. Return the text; if output is specified then output.write will be called to output the text and None will be returned Keyword parameters: nsdict: a dictionary of prefix:uri namespace ent...
[ "Canonicalize", "(", "node", "output", "=", "None", "**", "kw", ")", "-", ">", "UTF", "-", "8" ]
train
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/c14n.py#L413-L433
rameshg87/pyremotevbox
pyremotevbox/ZSI/wstools/c14n.py
_implementation._inherit_context
def _inherit_context(self, node): '''_inherit_context(self, node) -> list Scan ancestors of attribute and namespace context. Used only for single element node canonicalization, not for subset canonicalization.''' # Collect the initial list of xml:foo attributes. xmlattr...
python
def _inherit_context(self, node): '''_inherit_context(self, node) -> list Scan ancestors of attribute and namespace context. Used only for single element node canonicalization, not for subset canonicalization.''' # Collect the initial list of xml:foo attributes. xmlattr...
[ "def", "_inherit_context", "(", "self", ",", "node", ")", ":", "# Collect the initial list of xml:foo attributes.", "xmlattrs", "=", "filter", "(", "_IN_XML_NS", ",", "_attrs", "(", "node", ")", ")", "# Walk up and get all xml:XXX attributes we inherit.", "inherited", ","...
_inherit_context(self, node) -> list Scan ancestors of attribute and namespace context. Used only for single element node canonicalization, not for subset canonicalization.
[ "_inherit_context", "(", "self", "node", ")", "-", ">", "list", "Scan", "ancestors", "of", "attribute", "and", "namespace", "context", ".", "Used", "only", "for", "single", "element", "node", "canonicalization", "not", "for", "subset", "canonicalization", "." ]
train
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/c14n.py#L180-L198
rameshg87/pyremotevbox
pyremotevbox/ZSI/wstools/c14n.py
_implementation._do_document
def _do_document(self, node): '''_do_document(self, node) -> None Process a document node. documentOrder holds whether the document element has been encountered such that PIs/comments can be written as specified.''' self.documentOrder = _LesserElement for child in node.c...
python
def _do_document(self, node): '''_do_document(self, node) -> None Process a document node. documentOrder holds whether the document element has been encountered such that PIs/comments can be written as specified.''' self.documentOrder = _LesserElement for child in node.c...
[ "def", "_do_document", "(", "self", ",", "node", ")", ":", "self", ".", "documentOrder", "=", "_LesserElement", "for", "child", "in", "node", ".", "childNodes", ":", "if", "child", ".", "nodeType", "==", "Node", ".", "ELEMENT_NODE", ":", "self", ".", "do...
_do_document(self, node) -> None Process a document node. documentOrder holds whether the document element has been encountered such that PIs/comments can be written as specified.
[ "_do_document", "(", "self", "node", ")", "-", ">", "None", "Process", "a", "document", "node", ".", "documentOrder", "holds", "whether", "the", "document", "element", "has", "been", "encountered", "such", "that", "PIs", "/", "comments", "can", "be", "writte...
train
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/c14n.py#L201-L220
rameshg87/pyremotevbox
pyremotevbox/ZSI/wstools/c14n.py
_implementation._do_text
def _do_text(self, node): '''_do_text(self, node) -> None Process a text or CDATA node. Render various special characters as their C14N entity representations.''' if not _in_subset(self.subset, node): return s = string.replace(node.data, "&", "&") s = string.replace(...
python
def _do_text(self, node): '''_do_text(self, node) -> None Process a text or CDATA node. Render various special characters as their C14N entity representations.''' if not _in_subset(self.subset, node): return s = string.replace(node.data, "&", "&") s = string.replace(...
[ "def", "_do_text", "(", "self", ",", "node", ")", ":", "if", "not", "_in_subset", "(", "self", ".", "subset", ",", "node", ")", ":", "return", "s", "=", "string", ".", "replace", "(", "node", ".", "data", ",", "\"&\"", ",", "\"&\"", ")", "s", ...
_do_text(self, node) -> None Process a text or CDATA node. Render various special characters as their C14N entity representations.
[ "_do_text", "(", "self", "node", ")", "-", ">", "None", "Process", "a", "text", "or", "CDATA", "node", ".", "Render", "various", "special", "characters", "as", "their", "C14N", "entity", "representations", "." ]
train
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/c14n.py#L224-L233
rameshg87/pyremotevbox
pyremotevbox/ZSI/wstools/c14n.py
_implementation._do_pi
def _do_pi(self, node): '''_do_pi(self, node) -> None Process a PI node. Render a leading or trailing #xA if the document order of the PI is greater or lesser (respectively) than the document element. ''' if not _in_subset(self.subset, node): return W = self.write...
python
def _do_pi(self, node): '''_do_pi(self, node) -> None Process a PI node. Render a leading or trailing #xA if the document order of the PI is greater or lesser (respectively) than the document element. ''' if not _in_subset(self.subset, node): return W = self.write...
[ "def", "_do_pi", "(", "self", ",", "node", ")", ":", "if", "not", "_in_subset", "(", "self", ".", "subset", ",", "node", ")", ":", "return", "W", "=", "self", ".", "write", "if", "self", ".", "documentOrder", "==", "_GreaterElement", ":", "W", "(", ...
_do_pi(self, node) -> None Process a PI node. Render a leading or trailing #xA if the document order of the PI is greater or lesser (respectively) than the document element.
[ "_do_pi", "(", "self", "node", ")", "-", ">", "None", "Process", "a", "PI", "node", ".", "Render", "a", "leading", "or", "trailing", "#xA", "if", "the", "document", "order", "of", "the", "PI", "is", "greater", "or", "lesser", "(", "respectively", ")", ...
train
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/c14n.py#L238-L254
rameshg87/pyremotevbox
pyremotevbox/ZSI/wstools/c14n.py
_implementation._do_comment
def _do_comment(self, node): '''_do_comment(self, node) -> None Process a comment node. Render a leading or trailing #xA if the document order of the comment is greater or lesser (respectively) than the document element. ''' if not _in_subset(self.subset, node): return ...
python
def _do_comment(self, node): '''_do_comment(self, node) -> None Process a comment node. Render a leading or trailing #xA if the document order of the comment is greater or lesser (respectively) than the document element. ''' if not _in_subset(self.subset, node): return ...
[ "def", "_do_comment", "(", "self", ",", "node", ")", ":", "if", "not", "_in_subset", "(", "self", ".", "subset", ",", "node", ")", ":", "return", "if", "self", ".", "comments", ":", "W", "=", "self", ".", "write", "if", "self", ".", "documentOrder", ...
_do_comment(self, node) -> None Process a comment node. Render a leading or trailing #xA if the document order of the comment is greater or lesser (respectively) than the document element.
[ "_do_comment", "(", "self", "node", ")", "-", ">", "None", "Process", "a", "comment", "node", ".", "Render", "a", "leading", "or", "trailing", "#xA", "if", "the", "document", "order", "of", "the", "comment", "is", "greater", "or", "lesser", "(", "respect...
train
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/c14n.py#L258-L271
rameshg87/pyremotevbox
pyremotevbox/ZSI/wstools/c14n.py
_implementation._do_attr
def _do_attr(self, n, value): ''''_do_attr(self, node) -> None Process an attribute.''' W = self.write W(' ') W(n) W('="') s = string.replace(value, "&", "&amp;") s = string.replace(s, "<", "&lt;") s = string.replace(s, '"', '&quot;') s = ...
python
def _do_attr(self, n, value): ''''_do_attr(self, node) -> None Process an attribute.''' W = self.write W(' ') W(n) W('="') s = string.replace(value, "&", "&amp;") s = string.replace(s, "<", "&lt;") s = string.replace(s, '"', '&quot;') s = ...
[ "def", "_do_attr", "(", "self", ",", "n", ",", "value", ")", ":", "W", "=", "self", ".", "write", "W", "(", "' '", ")", "W", "(", "n", ")", "W", "(", "'=\"'", ")", "s", "=", "string", ".", "replace", "(", "value", ",", "\"&\"", ",", "\"&amp;\...
_do_attr(self, node) -> None Process an attribute.
[ "_do_attr", "(", "self", "node", ")", "-", ">", "None", "Process", "an", "attribute", "." ]
train
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/c14n.py#L275-L290
rameshg87/pyremotevbox
pyremotevbox/ZSI/wstools/c14n.py
_implementation._do_element
def _do_element(self, node, initial_other_attrs = [], unused = None): '''_do_element(self, node, initial_other_attrs = [], unused = {}) -> None Process an element (and its children).''' # Get state (from the stack) make local copies. # ns_parent -- NS declarations in parent # ...
python
def _do_element(self, node, initial_other_attrs = [], unused = None): '''_do_element(self, node, initial_other_attrs = [], unused = {}) -> None Process an element (and its children).''' # Get state (from the stack) make local copies. # ns_parent -- NS declarations in parent # ...
[ "def", "_do_element", "(", "self", ",", "node", ",", "initial_other_attrs", "=", "[", "]", ",", "unused", "=", "None", ")", ":", "# Get state (from the stack) make local copies.", "# ns_parent -- NS declarations in parent", "# ns_rendered -- NS nodes rendered by ancestors",...
_do_element(self, node, initial_other_attrs = [], unused = {}) -> None Process an element (and its children).
[ "_do_element", "(", "self", "node", "initial_other_attrs", "=", "[]", "unused", "=", "{}", ")", "-", ">", "None", "Process", "an", "element", "(", "and", "its", "children", ")", "." ]
train
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/c14n.py#L293-L409
sassoo/goldman
goldman/utils/str_helpers.py
cmp_val_salt_hash
def cmp_val_salt_hash(val, salt, str_hash): """ Given a string, salt, & hash validate the string The salt & val will be concatented as in gen_salt_and hash() & compared to the provided hash. This will only ever work with hashes derived from gen_salt_and_hash() :param val: clear-text string :pa...
python
def cmp_val_salt_hash(val, salt, str_hash): """ Given a string, salt, & hash validate the string The salt & val will be concatented as in gen_salt_and hash() & compared to the provided hash. This will only ever work with hashes derived from gen_salt_and_hash() :param val: clear-text string :pa...
[ "def", "cmp_val_salt_hash", "(", "val", ",", "salt", ",", "str_hash", ")", ":", "computed_hash", "=", "hashlib", ".", "sha256", "(", "val", "+", "salt", ")", ".", "hexdigest", "(", ")", "return", "computed_hash", "==", "str_hash" ]
Given a string, salt, & hash validate the string The salt & val will be concatented as in gen_salt_and hash() & compared to the provided hash. This will only ever work with hashes derived from gen_salt_and_hash() :param val: clear-text string :param salt: string salt :param str_hash: existing ...
[ "Given", "a", "string", "salt", "&", "hash", "validate", "the", "string" ]
train
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/utils/str_helpers.py#L14-L28
sassoo/goldman
goldman/utils/str_helpers.py
gen_salt_and_hash
def gen_salt_and_hash(val=None): """ Generate a salt & hash If no string is provided then a random string will be used to hash & referred to as `val`. The salt will always be randomly generated & the hash will be a sha256 hex value of the `val` & the salt as a concatenated string. It follows t...
python
def gen_salt_and_hash(val=None): """ Generate a salt & hash If no string is provided then a random string will be used to hash & referred to as `val`. The salt will always be randomly generated & the hash will be a sha256 hex value of the `val` & the salt as a concatenated string. It follows t...
[ "def", "gen_salt_and_hash", "(", "val", "=", "None", ")", ":", "if", "not", "val", ":", "val", "=", "random_str", "(", ")", "str_salt", "=", "random_str", "(", ")", "str_hash", "=", "hashlib", ".", "sha256", "(", "val", "+", "str_salt", ")", ".", "he...
Generate a salt & hash If no string is provided then a random string will be used to hash & referred to as `val`. The salt will always be randomly generated & the hash will be a sha256 hex value of the `val` & the salt as a concatenated string. It follows the guidance here: crackstation.n...
[ "Generate", "a", "salt", "&", "hash" ]
train
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/utils/str_helpers.py#L31-L52
sassoo/goldman
goldman/utils/str_helpers.py
str_to_bool
def str_to_bool(val): """ Return a boolean if the string value represents one :param val: str :return: bool :raise: ValueError """ if isinstance(val, bool): return val elif val.lower() == 'true': return True elif val.lower() == 'false': return False else: ...
python
def str_to_bool(val): """ Return a boolean if the string value represents one :param val: str :return: bool :raise: ValueError """ if isinstance(val, bool): return val elif val.lower() == 'true': return True elif val.lower() == 'false': return False else: ...
[ "def", "str_to_bool", "(", "val", ")", ":", "if", "isinstance", "(", "val", ",", "bool", ")", ":", "return", "val", "elif", "val", ".", "lower", "(", ")", "==", "'true'", ":", "return", "True", "elif", "val", ".", "lower", "(", ")", "==", "'false'"...
Return a boolean if the string value represents one :param val: str :return: bool :raise: ValueError
[ "Return", "a", "boolean", "if", "the", "string", "value", "represents", "one" ]
train
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/utils/str_helpers.py#L67-L82
sassoo/goldman
goldman/utils/str_helpers.py
str_to_dt
def str_to_dt(val): """ Return a datetime object if the string value represents one Epoch integer or an ISO 8601 compatible string is supported. :param val: str :return: datetime :raise: ValueError """ if isinstance(val, dt): return val try: if val.isdigit(): ...
python
def str_to_dt(val): """ Return a datetime object if the string value represents one Epoch integer or an ISO 8601 compatible string is supported. :param val: str :return: datetime :raise: ValueError """ if isinstance(val, dt): return val try: if val.isdigit(): ...
[ "def", "str_to_dt", "(", "val", ")", ":", "if", "isinstance", "(", "val", ",", "dt", ")", ":", "return", "val", "try", ":", "if", "val", ".", "isdigit", "(", ")", ":", "return", "dt", ".", "utcfromtimestamp", "(", "float", "(", "val", ")", ")", "...
Return a datetime object if the string value represents one Epoch integer or an ISO 8601 compatible string is supported. :param val: str :return: datetime :raise: ValueError
[ "Return", "a", "datetime", "object", "if", "the", "string", "value", "represents", "one" ]
train
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/utils/str_helpers.py#L85-L105
metagriffin/secpass
secpass/engine.py
Engine.getProfile
def getProfile(self, profile=None): ''' Returns the specified profile (by ID or by name). If `profile` is ``None`` or omitted, returns the default profile. ''' if profile is None: # todo: what if the configuration `profile.default` does not exist? profile = self.config.get('DEFAULT', 'pr...
python
def getProfile(self, profile=None): ''' Returns the specified profile (by ID or by name). If `profile` is ``None`` or omitted, returns the default profile. ''' if profile is None: # todo: what if the configuration `profile.default` does not exist? profile = self.config.get('DEFAULT', 'pr...
[ "def", "getProfile", "(", "self", ",", "profile", "=", "None", ")", ":", "if", "profile", "is", "None", ":", "# todo: what if the configuration `profile.default` does not exist?", "profile", "=", "self", ".", "config", ".", "get", "(", "'DEFAULT'", ",", "'profile....
Returns the specified profile (by ID or by name). If `profile` is ``None`` or omitted, returns the default profile.
[ "Returns", "the", "specified", "profile", "(", "by", "ID", "or", "by", "name", ")", ".", "If", "profile", "is", "None", "or", "omitted", "returns", "the", "default", "profile", "." ]
train
https://github.com/metagriffin/secpass/blob/7ec29666e82cb8900e5c36552ab2ee3403021a6a/secpass/engine.py#L207-L223
pip-services3-python/pip-services3-components-python
pip_services3_components/log/Logger.py
Logger.configure
def configure(self, config): """ Configures component by passing configuration parameters. :param config: configuration parameters to be set. """ self._level = LogLevelConverter.to_log_level(config.get_as_object("level")) self._source = config.get_as_string_with_default(...
python
def configure(self, config): """ Configures component by passing configuration parameters. :param config: configuration parameters to be set. """ self._level = LogLevelConverter.to_log_level(config.get_as_object("level")) self._source = config.get_as_string_with_default(...
[ "def", "configure", "(", "self", ",", "config", ")", ":", "self", ".", "_level", "=", "LogLevelConverter", ".", "to_log_level", "(", "config", ".", "get_as_object", "(", "\"level\"", ")", ")", "self", ".", "_source", "=", "config", ".", "get_as_string_with_d...
Configures component by passing configuration parameters. :param config: configuration parameters to be set.
[ "Configures", "component", "by", "passing", "configuration", "parameters", "." ]
train
https://github.com/pip-services3-python/pip-services3-components-python/blob/1de9c1bb544cf1891111e9a5f5d67653f62c9b52/pip_services3_components/log/Logger.py#L35-L42
pip-services3-python/pip-services3-components-python
pip_services3_components/log/Logger.py
Logger.set_references
def set_references(self, references): """ Sets references to dependent components. :param references: references to locate the component dependencies. """ context_info = references.get_one_optional(Descriptor("pip-services", "context-info", "*", "*", "1.0")) if context_i...
python
def set_references(self, references): """ Sets references to dependent components. :param references: references to locate the component dependencies. """ context_info = references.get_one_optional(Descriptor("pip-services", "context-info", "*", "*", "1.0")) if context_i...
[ "def", "set_references", "(", "self", ",", "references", ")", ":", "context_info", "=", "references", ".", "get_one_optional", "(", "Descriptor", "(", "\"pip-services\"", ",", "\"context-info\"", ",", "\"*\"", ",", "\"*\"", ",", "\"1.0\"", ")", ")", "if", "con...
Sets references to dependent components. :param references: references to locate the component dependencies.
[ "Sets", "references", "to", "dependent", "components", "." ]
train
https://github.com/pip-services3-python/pip-services3-components-python/blob/1de9c1bb544cf1891111e9a5f5d67653f62c9b52/pip_services3_components/log/Logger.py#L44-L52
pip-services3-python/pip-services3-components-python
pip_services3_components/log/Logger.py
Logger._format_and_write
def _format_and_write(self, level, correlation_id, error, message, *args, **kwargs): """ Formats the log message and writes it to the logger destination. :param level: a log level. :param correlation_id: (optional) transaction id to trace execution through call chain. :param e...
python
def _format_and_write(self, level, correlation_id, error, message, *args, **kwargs): """ Formats the log message and writes it to the logger destination. :param level: a log level. :param correlation_id: (optional) transaction id to trace execution through call chain. :param e...
[ "def", "_format_and_write", "(", "self", ",", "level", ",", "correlation_id", ",", "error", ",", "message", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "message", "!=", "None", "and", "len", "(", "message", ")", ">", "0", "and", "len",...
Formats the log message and writes it to the logger destination. :param level: a log level. :param correlation_id: (optional) transaction id to trace execution through call chain. :param error: an error object associated with this message. :param message: a human-readable message to ...
[ "Formats", "the", "log", "message", "and", "writes", "it", "to", "the", "logger", "destination", "." ]
train
https://github.com/pip-services3-python/pip-services3-components-python/blob/1de9c1bb544cf1891111e9a5f5d67653f62c9b52/pip_services3_components/log/Logger.py#L84-L102
pip-services3-python/pip-services3-components-python
pip_services3_components/log/Logger.py
Logger.log
def log(self, level, correlation_id, error, message, *args, **kwargs): """ Logs a message at specified log level. :param level: a log level. :param correlation_id: (optional) transaction id to trace execution through call chain. :param error: an error object associated with th...
python
def log(self, level, correlation_id, error, message, *args, **kwargs): """ Logs a message at specified log level. :param level: a log level. :param correlation_id: (optional) transaction id to trace execution through call chain. :param error: an error object associated with th...
[ "def", "log", "(", "self", ",", "level", ",", "correlation_id", ",", "error", ",", "message", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_format_and_write", "(", "level", ",", "correlation_id", ",", "error", ",", "message", ",",...
Logs a message at specified log level. :param level: a log level. :param correlation_id: (optional) transaction id to trace execution through call chain. :param error: an error object associated with this message. :param message: a human-readable message to log. :param args:...
[ "Logs", "a", "message", "at", "specified", "log", "level", "." ]
train
https://github.com/pip-services3-python/pip-services3-components-python/blob/1de9c1bb544cf1891111e9a5f5d67653f62c9b52/pip_services3_components/log/Logger.py#L104-L120
pip-services3-python/pip-services3-components-python
pip_services3_components/log/Logger.py
Logger.fatal
def fatal(self, correlation_id, error, message, *args, **kwargs): """ Logs fatal (unrecoverable) message that caused the process to crash. :param correlation_id: (optional) transaction id to trace execution through call chain. :param error: an error object associated with this message....
python
def fatal(self, correlation_id, error, message, *args, **kwargs): """ Logs fatal (unrecoverable) message that caused the process to crash. :param correlation_id: (optional) transaction id to trace execution through call chain. :param error: an error object associated with this message....
[ "def", "fatal", "(", "self", ",", "correlation_id", ",", "error", ",", "message", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_format_and_write", "(", "LogLevel", ".", "Fatal", ",", "correlation_id", ",", "error", ",", "message", ...
Logs fatal (unrecoverable) message that caused the process to crash. :param correlation_id: (optional) transaction id to trace execution through call chain. :param error: an error object associated with this message. :param message: a human-readable message to log. :param args: argum...
[ "Logs", "fatal", "(", "unrecoverable", ")", "message", "that", "caused", "the", "process", "to", "crash", "." ]
train
https://github.com/pip-services3-python/pip-services3-components-python/blob/1de9c1bb544cf1891111e9a5f5d67653f62c9b52/pip_services3_components/log/Logger.py#L122-L136
pip-services3-python/pip-services3-components-python
pip_services3_components/log/Logger.py
Logger.error
def error(self, correlation_id, error, message, *args, **kwargs): """ Logs recoverable application error. :param correlation_id: (optional) transaction id to trace execution through call chain. :param error: an error object associated with this message. :param message: a human...
python
def error(self, correlation_id, error, message, *args, **kwargs): """ Logs recoverable application error. :param correlation_id: (optional) transaction id to trace execution through call chain. :param error: an error object associated with this message. :param message: a human...
[ "def", "error", "(", "self", ",", "correlation_id", ",", "error", ",", "message", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_format_and_write", "(", "LogLevel", ".", "Error", ",", "correlation_id", ",", "error", ",", "message", ...
Logs recoverable application error. :param correlation_id: (optional) transaction id to trace execution through call chain. :param error: an error object associated with this message. :param message: a human-readable message to log. :param args: arguments to parameterize the message....
[ "Logs", "recoverable", "application", "error", "." ]
train
https://github.com/pip-services3-python/pip-services3-components-python/blob/1de9c1bb544cf1891111e9a5f5d67653f62c9b52/pip_services3_components/log/Logger.py#L138-L152
pip-services3-python/pip-services3-components-python
pip_services3_components/log/Logger.py
Logger.warn
def warn(self, correlation_id, message, *args, **kwargs): """ Logs a warning that may or may not have a negative impact. :param correlation_id: (optional) transaction id to trace execution through call chain. :param message: a human-readable message to log. :param args: argume...
python
def warn(self, correlation_id, message, *args, **kwargs): """ Logs a warning that may or may not have a negative impact. :param correlation_id: (optional) transaction id to trace execution through call chain. :param message: a human-readable message to log. :param args: argume...
[ "def", "warn", "(", "self", ",", "correlation_id", ",", "message", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_format_and_write", "(", "LogLevel", ".", "Warn", ",", "correlation_id", ",", "None", ",", "message", ",", "args", ","...
Logs a warning that may or may not have a negative impact. :param correlation_id: (optional) transaction id to trace execution through call chain. :param message: a human-readable message to log. :param args: arguments to parameterize the message. :param kwargs: arguments to paramete...
[ "Logs", "a", "warning", "that", "may", "or", "may", "not", "have", "a", "negative", "impact", "." ]
train
https://github.com/pip-services3-python/pip-services3-components-python/blob/1de9c1bb544cf1891111e9a5f5d67653f62c9b52/pip_services3_components/log/Logger.py#L154-L166
pip-services3-python/pip-services3-components-python
pip_services3_components/log/Logger.py
Logger.info
def info(self, correlation_id, message, *args, **kwargs): """ Logs an important information message :param correlation_id: (optional) transaction id to trace execution through call chain. :param message: a human-readable message to log. :param args: arguments to parameterize t...
python
def info(self, correlation_id, message, *args, **kwargs): """ Logs an important information message :param correlation_id: (optional) transaction id to trace execution through call chain. :param message: a human-readable message to log. :param args: arguments to parameterize t...
[ "def", "info", "(", "self", ",", "correlation_id", ",", "message", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_format_and_write", "(", "LogLevel", ".", "Info", ",", "correlation_id", ",", "None", ",", "message", ",", "args", ","...
Logs an important information message :param correlation_id: (optional) transaction id to trace execution through call chain. :param message: a human-readable message to log. :param args: arguments to parameterize the message. :param kwargs: arguments to parameterize the message.
[ "Logs", "an", "important", "information", "message" ]
train
https://github.com/pip-services3-python/pip-services3-components-python/blob/1de9c1bb544cf1891111e9a5f5d67653f62c9b52/pip_services3_components/log/Logger.py#L168-L180
pip-services3-python/pip-services3-components-python
pip_services3_components/log/Logger.py
Logger.debug
def debug(self, correlation_id, message, *args, **kwargs): """ Logs a high-level debug information for troubleshooting. :param correlation_id: (optional) transaction id to trace execution through call chain. :param message: a human-readable message to log. :param args: argumen...
python
def debug(self, correlation_id, message, *args, **kwargs): """ Logs a high-level debug information for troubleshooting. :param correlation_id: (optional) transaction id to trace execution through call chain. :param message: a human-readable message to log. :param args: argumen...
[ "def", "debug", "(", "self", ",", "correlation_id", ",", "message", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_format_and_write", "(", "LogLevel", ".", "Debug", ",", "correlation_id", ",", "None", ",", "message", ",", "args", "...
Logs a high-level debug information for troubleshooting. :param correlation_id: (optional) transaction id to trace execution through call chain. :param message: a human-readable message to log. :param args: arguments to parameterize the message. :param kwargs: arguments to parameteri...
[ "Logs", "a", "high", "-", "level", "debug", "information", "for", "troubleshooting", "." ]
train
https://github.com/pip-services3-python/pip-services3-components-python/blob/1de9c1bb544cf1891111e9a5f5d67653f62c9b52/pip_services3_components/log/Logger.py#L182-L194
pip-services3-python/pip-services3-components-python
pip_services3_components/log/Logger.py
Logger.trace
def trace(self, correlation_id, message, *args, **kwargs): """ Logs a low-level debug information for troubleshooting. :param correlation_id: (optional) transaction id to trace execution through call chain. :param message: a human-readable message to log. :param args: argument...
python
def trace(self, correlation_id, message, *args, **kwargs): """ Logs a low-level debug information for troubleshooting. :param correlation_id: (optional) transaction id to trace execution through call chain. :param message: a human-readable message to log. :param args: argument...
[ "def", "trace", "(", "self", ",", "correlation_id", ",", "message", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_format_and_write", "(", "LogLevel", ".", "Trace", ",", "correlation_id", ",", "None", ",", "message", ",", "args", "...
Logs a low-level debug information for troubleshooting. :param correlation_id: (optional) transaction id to trace execution through call chain. :param message: a human-readable message to log. :param args: arguments to parameterize the message. :param kwargs: arguments to parameteriz...
[ "Logs", "a", "low", "-", "level", "debug", "information", "for", "troubleshooting", "." ]
train
https://github.com/pip-services3-python/pip-services3-components-python/blob/1de9c1bb544cf1891111e9a5f5d67653f62c9b52/pip_services3_components/log/Logger.py#L196-L208
chairbender/fantasy-football-auction
fantasy_football_auction/player.py
players_from_fantasypros_cheatsheet
def players_from_fantasypros_cheatsheet(file): """ :param File file: path to the file containing the player values in the standard CSV format used for fantasypros cheatsheets :return list(Player): a list of Players based on the info in the cheatsheet """ with open(file, newline='') as csvfile: ...
python
def players_from_fantasypros_cheatsheet(file): """ :param File file: path to the file containing the player values in the standard CSV format used for fantasypros cheatsheets :return list(Player): a list of Players based on the info in the cheatsheet """ with open(file, newline='') as csvfile: ...
[ "def", "players_from_fantasypros_cheatsheet", "(", "file", ")", ":", "with", "open", "(", "file", ",", "newline", "=", "''", ")", "as", "csvfile", ":", "# Note - considered using a generator for this, but I don't want to hold the file open", "# for a long time and it's pretty s...
:param File file: path to the file containing the player values in the standard CSV format used for fantasypros cheatsheets :return list(Player): a list of Players based on the info in the cheatsheet
[ ":", "param", "File", "file", ":", "path", "to", "the", "file", "containing", "the", "player", "values", "in", "the", "standard", "CSV", "format", "used", "for", "fantasypros", "cheatsheets", ":", "return", "list", "(", "Player", ")", ":", "a", "list", "...
train
https://github.com/chairbender/fantasy-football-auction/blob/f54868691ea37691c378b0a05b6b3280c2cbba11/fantasy_football_auction/player.py#L37-L61
django-py/django-doberman
doberman/contrib/ipware/__init__.py
check_ipv6
def check_ipv6(ip_str): """ Return True if is a valid IP v6 """ try: socket.inet_pton(socket.AF_INET6, ip_str) except socket.error: return False return True
python
def check_ipv6(ip_str): """ Return True if is a valid IP v6 """ try: socket.inet_pton(socket.AF_INET6, ip_str) except socket.error: return False return True
[ "def", "check_ipv6", "(", "ip_str", ")", ":", "try", ":", "socket", ".", "inet_pton", "(", "socket", ".", "AF_INET6", ",", "ip_str", ")", "except", "socket", ".", "error", ":", "return", "False", "return", "True" ]
Return True if is a valid IP v6
[ "Return", "True", "if", "is", "a", "valid", "IP", "v6" ]
train
https://github.com/django-py/django-doberman/blob/2e5959737a1b64234ed5a179c93f96a0de1c3e5c/doberman/contrib/ipware/__init__.py#L24-L33
django-py/django-doberman
doberman/contrib/ipware/__init__.py
check_ipv4
def check_ipv4(ip_str): """ Return True if is a valid IP v4 """ try: socket.inet_pton(socket.AF_INET, ip_str) except AttributeError: try: socket.inet_aton(ip_str) except socket.error: return False return ip_str.count('.') == 3 except socket...
python
def check_ipv4(ip_str): """ Return True if is a valid IP v4 """ try: socket.inet_pton(socket.AF_INET, ip_str) except AttributeError: try: socket.inet_aton(ip_str) except socket.error: return False return ip_str.count('.') == 3 except socket...
[ "def", "check_ipv4", "(", "ip_str", ")", ":", "try", ":", "socket", ".", "inet_pton", "(", "socket", ".", "AF_INET", ",", "ip_str", ")", "except", "AttributeError", ":", "try", ":", "socket", ".", "inet_aton", "(", "ip_str", ")", "except", "socket", ".",...
Return True if is a valid IP v4
[ "Return", "True", "if", "is", "a", "valid", "IP", "v4" ]
train
https://github.com/django-py/django-doberman/blob/2e5959737a1b64234ed5a179c93f96a0de1c3e5c/doberman/contrib/ipware/__init__.py#L36-L50
SkyLothar/requests-ucloud
ucloudauth/ufile.py
UFileAuth.gen_str_to_sign
def gen_str_to_sign(self, req): """Generate string to sign using giving prepared request""" url = urlsplit(req.url) bucket_name = url.netloc.split(".", 1)[0] logger.debug(req.headers.items()) ucloud_headers = [ (k, v.strip()) for k, v in sorted(req.header...
python
def gen_str_to_sign(self, req): """Generate string to sign using giving prepared request""" url = urlsplit(req.url) bucket_name = url.netloc.split(".", 1)[0] logger.debug(req.headers.items()) ucloud_headers = [ (k, v.strip()) for k, v in sorted(req.header...
[ "def", "gen_str_to_sign", "(", "self", ",", "req", ")", ":", "url", "=", "urlsplit", "(", "req", ".", "url", ")", "bucket_name", "=", "url", ".", "netloc", ".", "split", "(", "\".\"", ",", "1", ")", "[", "0", "]", "logger", ".", "debug", "(", "re...
Generate string to sign using giving prepared request
[ "Generate", "string", "to", "sign", "using", "giving", "prepared", "request" ]
train
https://github.com/SkyLothar/requests-ucloud/blob/986a81d323add8e6708367c6a31280e859210d87/ucloudauth/ufile.py#L112-L139
SkyLothar/requests-ucloud
ucloudauth/ufile.py
UFileAuth.fill_all_headers
def fill_all_headers(self, req): """Set content-type, content-md5, date to the request.""" url = urlsplit(req.url) content_type, __ = mimetypes.guess_type(url.path) if content_type is None: content_type = self.DEFAULT_TYPE logger.warn("can not determine mime-type...
python
def fill_all_headers(self, req): """Set content-type, content-md5, date to the request.""" url = urlsplit(req.url) content_type, __ = mimetypes.guess_type(url.path) if content_type is None: content_type = self.DEFAULT_TYPE logger.warn("can not determine mime-type...
[ "def", "fill_all_headers", "(", "self", ",", "req", ")", ":", "url", "=", "urlsplit", "(", "req", ".", "url", ")", "content_type", ",", "__", "=", "mimetypes", ".", "guess_type", "(", "url", ".", "path", ")", "if", "content_type", "is", "None", ":", ...
Set content-type, content-md5, date to the request.
[ "Set", "content", "-", "type", "content", "-", "md5", "date", "to", "the", "request", "." ]
train
https://github.com/SkyLothar/requests-ucloud/blob/986a81d323add8e6708367c6a31280e859210d87/ucloudauth/ufile.py#L141-L171
caioariede/docker-run-build
docker_rb/utils.py
get_old_options
def get_old_options(cli, image): """ Returns Dockerfile values for CMD and Entrypoint """ return { 'cmd': dockerapi.inspect_config(cli, image, 'Cmd'), 'entrypoint': dockerapi.inspect_config(cli, image, 'Entrypoint'), }
python
def get_old_options(cli, image): """ Returns Dockerfile values for CMD and Entrypoint """ return { 'cmd': dockerapi.inspect_config(cli, image, 'Cmd'), 'entrypoint': dockerapi.inspect_config(cli, image, 'Entrypoint'), }
[ "def", "get_old_options", "(", "cli", ",", "image", ")", ":", "return", "{", "'cmd'", ":", "dockerapi", ".", "inspect_config", "(", "cli", ",", "image", ",", "'Cmd'", ")", ",", "'entrypoint'", ":", "dockerapi", ".", "inspect_config", "(", "cli", ",", "im...
Returns Dockerfile values for CMD and Entrypoint
[ "Returns", "Dockerfile", "values", "for", "CMD", "and", "Entrypoint" ]
train
https://github.com/caioariede/docker-run-build/blob/76ca4802018a63d6778374ebdba082d6750816b2/docker_rb/utils.py#L13-L19
caioariede/docker-run-build
docker_rb/utils.py
restore_image_options
def restore_image_options(cli, image, options): """ Restores CMD and ENTRYPOINT values of the image This is needed because we force the overwrite of ENTRYPOINT and CMD in the `run_code_in_container` function, to be able to run the code in the container, through /bin/bash. """ dockerfile = io.St...
python
def restore_image_options(cli, image, options): """ Restores CMD and ENTRYPOINT values of the image This is needed because we force the overwrite of ENTRYPOINT and CMD in the `run_code_in_container` function, to be able to run the code in the container, through /bin/bash. """ dockerfile = io.St...
[ "def", "restore_image_options", "(", "cli", ",", "image", ",", "options", ")", ":", "dockerfile", "=", "io", ".", "StringIO", "(", ")", "dockerfile", ".", "write", "(", "u'FROM {image}\\nCMD {cmd}'", ".", "format", "(", "image", "=", "image", ",", "cmd", "...
Restores CMD and ENTRYPOINT values of the image This is needed because we force the overwrite of ENTRYPOINT and CMD in the `run_code_in_container` function, to be able to run the code in the container, through /bin/bash.
[ "Restores", "CMD", "and", "ENTRYPOINT", "values", "of", "the", "image" ]
train
https://github.com/caioariede/docker-run-build/blob/76ca4802018a63d6778374ebdba082d6750816b2/docker_rb/utils.py#L31-L47
caioariede/docker-run-build
docker_rb/utils.py
run_code_in_container
def run_code_in_container(cli, image, code, mount, entrypoint): """ Run `code` in a container, returning its ID """ kwargs = { 'image': image, } if entrypoint: kwargs['entrypoint'] = '/bin/bash' kwargs['command'] = '-c {}'.format(quote(code)) else: kwargs['comman...
python
def run_code_in_container(cli, image, code, mount, entrypoint): """ Run `code` in a container, returning its ID """ kwargs = { 'image': image, } if entrypoint: kwargs['entrypoint'] = '/bin/bash' kwargs['command'] = '-c {}'.format(quote(code)) else: kwargs['comman...
[ "def", "run_code_in_container", "(", "cli", ",", "image", ",", "code", ",", "mount", ",", "entrypoint", ")", ":", "kwargs", "=", "{", "'image'", ":", "image", ",", "}", "if", "entrypoint", ":", "kwargs", "[", "'entrypoint'", "]", "=", "'/bin/bash'", "kwa...
Run `code` in a container, returning its ID
[ "Run", "code", "in", "a", "container", "returning", "its", "ID" ]
train
https://github.com/caioariede/docker-run-build/blob/76ca4802018a63d6778374ebdba082d6750816b2/docker_rb/utils.py#L50-L91
mk-fg/unified2
unified2/parser.py
read
def read(src): 'Event generator from u2 stream.' parser, buff_agg = Parser(), '' while True: buff = parser.read(src) if not buff: break # EOF buff_agg += buff while True: buff_agg, ev = parser.process(buff_agg) if ev is None: break yield ev
python
def read(src): 'Event generator from u2 stream.' parser, buff_agg = Parser(), '' while True: buff = parser.read(src) if not buff: break # EOF buff_agg += buff while True: buff_agg, ev = parser.process(buff_agg) if ev is None: break yield ev
[ "def", "read", "(", "src", ")", ":", "parser", ",", "buff_agg", "=", "Parser", "(", ")", ",", "''", "while", "True", ":", "buff", "=", "parser", ".", "read", "(", "src", ")", "if", "not", "buff", ":", "break", "# EOF", "buff_agg", "+=", "buff", "...
Event generator from u2 stream.
[ "Event", "generator", "from", "u2", "stream", "." ]
train
https://github.com/mk-fg/unified2/blob/bf6f761a805c2971a61b5339adfb0842186b39d6/unified2/parser.py#L67-L77
PSU-OIT-ARC/django-local-settings
local_settings/__init__.py
load_and_check_settings
def load_and_check_settings(base_settings, file_name=None, section=None, base_path=None, strategy_type=INIJSONStrategy, disable=None, prompt=None, quiet=None): """Merge local settings from file with base settings, then check. Returns a new dict containing...
python
def load_and_check_settings(base_settings, file_name=None, section=None, base_path=None, strategy_type=INIJSONStrategy, disable=None, prompt=None, quiet=None): """Merge local settings from file with base settings, then check. Returns a new dict containing...
[ "def", "load_and_check_settings", "(", "base_settings", ",", "file_name", "=", "None", ",", "section", "=", "None", ",", "base_path", "=", "None", ",", "strategy_type", "=", "INIJSONStrategy", ",", "disable", "=", "None", ",", "prompt", "=", "None", ",", "qu...
Merge local settings from file with base settings, then check. Returns a new dict containing the base settings and the loaded settings. Includes: - base settings - settings from extended file(s), if any - settings from file Settings loaded from the specified file will override bas...
[ "Merge", "local", "settings", "from", "file", "with", "base", "settings", "then", "check", "." ]
train
https://github.com/PSU-OIT-ARC/django-local-settings/blob/758810fbd9411c2046a187afcac6532155cac694/local_settings/__init__.py#L21-L95
mbodenhamer/syn
syn/base_utils/alg.py
defer_reduce
def defer_reduce(func, items, test, accum=None): '''Recursively reduce items by func, but only the items that do not cause test(items, accum) to return False. Returns the reduced list (accum) and the list of remaining deferred items. ''' removals = [] for k, item in enumerate(items): if test(i...
python
def defer_reduce(func, items, test, accum=None): '''Recursively reduce items by func, but only the items that do not cause test(items, accum) to return False. Returns the reduced list (accum) and the list of remaining deferred items. ''' removals = [] for k, item in enumerate(items): if test(i...
[ "def", "defer_reduce", "(", "func", ",", "items", ",", "test", ",", "accum", "=", "None", ")", ":", "removals", "=", "[", "]", "for", "k", ",", "item", "in", "enumerate", "(", "items", ")", ":", "if", "test", "(", "item", ",", "accum", ")", ":", ...
Recursively reduce items by func, but only the items that do not cause test(items, accum) to return False. Returns the reduced list (accum) and the list of remaining deferred items.
[ "Recursively", "reduce", "items", "by", "func", "but", "only", "the", "items", "that", "do", "not", "cause", "test", "(", "items", "accum", ")", "to", "return", "False", ".", "Returns", "the", "reduced", "list", "(", "accum", ")", "and", "the", "list", ...
train
https://github.com/mbodenhamer/syn/blob/aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258/syn/base_utils/alg.py#L8-L26
rameshg87/pyremotevbox
pyremotevbox/ZSI/digest_auth.py
generate_response
def generate_response(chaldict,uri,username,passwd,method='GET',cnonce=None): """ Generate an authorization response dictionary. chaldict should contain the digest challenge in dict form. Use fetch_challenge to create a chaldict from a HTTPResponse object like this: fetch_challenge(res.getheaders()). returns...
python
def generate_response(chaldict,uri,username,passwd,method='GET',cnonce=None): """ Generate an authorization response dictionary. chaldict should contain the digest challenge in dict form. Use fetch_challenge to create a chaldict from a HTTPResponse object like this: fetch_challenge(res.getheaders()). returns...
[ "def", "generate_response", "(", "chaldict", ",", "uri", ",", "username", ",", "passwd", ",", "method", "=", "'GET'", ",", "cnonce", "=", "None", ")", ":", "authdict", "=", "{", "}", "qop", "=", "dict_fetch", "(", "chaldict", ",", "'qop'", ")", "domain...
Generate an authorization response dictionary. chaldict should contain the digest challenge in dict form. Use fetch_challenge to create a chaldict from a HTTPResponse object like this: fetch_challenge(res.getheaders()). returns dict (the authdict) Note. Use build_authorization_arg() to turn an authdict into t...
[ "Generate", "an", "authorization", "response", "dictionary", ".", "chaldict", "should", "contain", "the", "digest", "challenge", "in", "dict", "form", ".", "Use", "fetch_challenge", "to", "create", "a", "chaldict", "from", "a", "HTTPResponse", "object", "like", ...
train
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/digest_auth.py#L33-L74
rameshg87/pyremotevbox
pyremotevbox/ZSI/digest_auth.py
fetch_challenge
def fetch_challenge(http_header): """ apparently keywords Basic and Digest are not being checked anywhere and decisions are being made based on authorization configuration of client, so I guess you better know what you are doing. Here I am requiring one or the other be specified. challenge Basic auth_...
python
def fetch_challenge(http_header): """ apparently keywords Basic and Digest are not being checked anywhere and decisions are being made based on authorization configuration of client, so I guess you better know what you are doing. Here I am requiring one or the other be specified. challenge Basic auth_...
[ "def", "fetch_challenge", "(", "http_header", ")", ":", "m", "=", "fetch_challenge", ".", "wwwauth_header_re", ".", "match", "(", "http_header", ")", "if", "m", "is", "None", ":", "raise", "RuntimeError", ",", "'expecting \"WWW-Authenticate header [Basic,Digest]\"'", ...
apparently keywords Basic and Digest are not being checked anywhere and decisions are being made based on authorization configuration of client, so I guess you better know what you are doing. Here I am requiring one or the other be specified. challenge Basic auth_param challenge Digest auth_param
[ "apparently", "keywords", "Basic", "and", "Digest", "are", "not", "being", "checked", "anywhere", "and", "decisions", "are", "being", "made", "based", "on", "authorization", "configuration", "of", "client", "so", "I", "guess", "you", "better", "know", "what", ...
train
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/digest_auth.py#L77-L97
rameshg87/pyremotevbox
pyremotevbox/ZSI/digest_auth.py
build_authorization_arg
def build_authorization_arg(authdict): """ Create an "Authorization" header value from an authdict (created by generate_response()). """ vallist = [] for k in authdict.keys(): vallist += ['%s=%s' % (k,authdict[k])] return 'Digest '+', '.join(vallist)
python
def build_authorization_arg(authdict): """ Create an "Authorization" header value from an authdict (created by generate_response()). """ vallist = [] for k in authdict.keys(): vallist += ['%s=%s' % (k,authdict[k])] return 'Digest '+', '.join(vallist)
[ "def", "build_authorization_arg", "(", "authdict", ")", ":", "vallist", "=", "[", "]", "for", "k", "in", "authdict", ".", "keys", "(", ")", ":", "vallist", "+=", "[", "'%s=%s'", "%", "(", "k", ",", "authdict", "[", "k", "]", ")", "]", "return", "'D...
Create an "Authorization" header value from an authdict (created by generate_response()).
[ "Create", "an", "Authorization", "header", "value", "from", "an", "authdict", "(", "created", "by", "generate_response", "()", ")", "." ]
train
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/digest_auth.py#L103-L110
bwesterb/tkbd
src/mytimetable.py
MyTimetable.open_url
def open_url(self, url): """ Open's URL with apiToken in the headers """ try: c = pycurl.Curl() c.setopt(pycurl.FAILONERROR, True) c.setopt(pycurl.URL, "%s/api/v0/%s" % (self.url, url)) c.setopt(pycurl.HTTPHEADER, ["User-Agent: %s" % self.userAgent, ...
python
def open_url(self, url): """ Open's URL with apiToken in the headers """ try: c = pycurl.Curl() c.setopt(pycurl.FAILONERROR, True) c.setopt(pycurl.URL, "%s/api/v0/%s" % (self.url, url)) c.setopt(pycurl.HTTPHEADER, ["User-Agent: %s" % self.userAgent, ...
[ "def", "open_url", "(", "self", ",", "url", ")", ":", "try", ":", "c", "=", "pycurl", ".", "Curl", "(", ")", "c", ".", "setopt", "(", "pycurl", ".", "FAILONERROR", ",", "True", ")", "c", ".", "setopt", "(", "pycurl", ".", "URL", ",", "\"%s/api/v0...
Open's URL with apiToken in the headers
[ "Open", "s", "URL", "with", "apiToken", "in", "the", "headers" ]
train
https://github.com/bwesterb/tkbd/blob/fcf16977d38a93fe9b7fa198513007ab9921b650/src/mytimetable.py#L27-L50
bwesterb/tkbd
src/mytimetable.py
MyTimetable.fetch_room_ids
def fetch_room_ids(self, names): """ Fetches the ids of the rooms with the given names """ ret = dict() names_set = frozenset(names) for d in json.loads(self.open_url( 'timetables?type=location'))['timetable']: name = d['hostKey'] if na...
python
def fetch_room_ids(self, names): """ Fetches the ids of the rooms with the given names """ ret = dict() names_set = frozenset(names) for d in json.loads(self.open_url( 'timetables?type=location'))['timetable']: name = d['hostKey'] if na...
[ "def", "fetch_room_ids", "(", "self", ",", "names", ")", ":", "ret", "=", "dict", "(", ")", "names_set", "=", "frozenset", "(", "names", ")", "for", "d", "in", "json", ".", "loads", "(", "self", ".", "open_url", "(", "'timetables?type=location'", ")", ...
Fetches the ids of the rooms with the given names
[ "Fetches", "the", "ids", "of", "the", "rooms", "with", "the", "given", "names" ]
train
https://github.com/bwesterb/tkbd/blob/fcf16977d38a93fe9b7fa198513007ab9921b650/src/mytimetable.py#L53-L62
bwesterb/tkbd
src/mytimetable.py
MyTimetable.fetch_todays_schedule
def fetch_todays_schedule(self, rooms): """ Fetch the schedules for the given rooms. """ def _format_date(d): return d.strftime('%Y/%m/%d') room_ids = self.fetch_room_ids(rooms) ret = {} now = datetime.datetime.now() nowStr = _format_date(now) tomorrow...
python
def fetch_todays_schedule(self, rooms): """ Fetch the schedules for the given rooms. """ def _format_date(d): return d.strftime('%Y/%m/%d') room_ids = self.fetch_room_ids(rooms) ret = {} now = datetime.datetime.now() nowStr = _format_date(now) tomorrow...
[ "def", "fetch_todays_schedule", "(", "self", ",", "rooms", ")", ":", "def", "_format_date", "(", "d", ")", ":", "return", "d", ".", "strftime", "(", "'%Y/%m/%d'", ")", "room_ids", "=", "self", ".", "fetch_room_ids", "(", "rooms", ")", "ret", "=", "{", ...
Fetch the schedules for the given rooms.
[ "Fetch", "the", "schedules", "for", "the", "given", "rooms", "." ]
train
https://github.com/bwesterb/tkbd/blob/fcf16977d38a93fe9b7fa198513007ab9921b650/src/mytimetable.py#L65-L92
Nixiware/viper
nx/viper/module.py
Module._loadConfiguration
def _loadConfiguration(self): """ Load module configuration files. :return: <void> """ configPath = os.path.join(self.path, "config") if not os.path.isdir(configPath): return config = Config(configPath) Config.mergeDictionaries(config.getDat...
python
def _loadConfiguration(self): """ Load module configuration files. :return: <void> """ configPath = os.path.join(self.path, "config") if not os.path.isdir(configPath): return config = Config(configPath) Config.mergeDictionaries(config.getDat...
[ "def", "_loadConfiguration", "(", "self", ")", ":", "configPath", "=", "os", ".", "path", ".", "join", "(", "self", ".", "path", ",", "\"config\"", ")", "if", "not", "os", ".", "path", ".", "isdir", "(", "configPath", ")", ":", "return", "config", "=...
Load module configuration files. :return: <void>
[ "Load", "module", "configuration", "files", "." ]
train
https://github.com/Nixiware/viper/blob/fbe6057facd8d46103e9955880dfd99e63b7acb3/nx/viper/module.py#L24-L36
Nixiware/viper
nx/viper/module.py
Module._loadModels
def _loadModels(self): """ Load module models. :return: <void> """ modelsPath = os.path.join(self.path, "model") if not os.path.isdir(modelsPath): return for modelFile in os.listdir(modelsPath): modelName = modelFile.replace(".py", "") ...
python
def _loadModels(self): """ Load module models. :return: <void> """ modelsPath = os.path.join(self.path, "model") if not os.path.isdir(modelsPath): return for modelFile in os.listdir(modelsPath): modelName = modelFile.replace(".py", "") ...
[ "def", "_loadModels", "(", "self", ")", ":", "modelsPath", "=", "os", ".", "path", ".", "join", "(", "self", ".", "path", ",", "\"model\"", ")", "if", "not", "os", ".", "path", ".", "isdir", "(", "modelsPath", ")", ":", "return", "for", "modelFile", ...
Load module models. :return: <void>
[ "Load", "module", "models", "." ]
train
https://github.com/Nixiware/viper/blob/fbe6057facd8d46103e9955880dfd99e63b7acb3/nx/viper/module.py#L38-L67
Nixiware/viper
nx/viper/module.py
Module._loadServices
def _loadServices(self): """ Load module services. :return: <void> """ servicesPath = os.path.join(self.path, "service") if not os.path.isdir(servicesPath): return self._scanDirectoryForServices(servicesPath)
python
def _loadServices(self): """ Load module services. :return: <void> """ servicesPath = os.path.join(self.path, "service") if not os.path.isdir(servicesPath): return self._scanDirectoryForServices(servicesPath)
[ "def", "_loadServices", "(", "self", ")", ":", "servicesPath", "=", "os", ".", "path", ".", "join", "(", "self", ".", "path", ",", "\"service\"", ")", "if", "not", "os", ".", "path", ".", "isdir", "(", "servicesPath", ")", ":", "return", "self", ".",...
Load module services. :return: <void>
[ "Load", "module", "services", "." ]
train
https://github.com/Nixiware/viper/blob/fbe6057facd8d46103e9955880dfd99e63b7acb3/nx/viper/module.py#L69-L79
Nixiware/viper
nx/viper/module.py
Module._scanDirectoryForServices
def _scanDirectoryForServices(self, directoryPath): """ Scan a directory looking for service files. If another directory is found (excluding any python bytecode cache), the method recursively calls itself on that directory. If a .py file is found, a quiet attempt to load the serv...
python
def _scanDirectoryForServices(self, directoryPath): """ Scan a directory looking for service files. If another directory is found (excluding any python bytecode cache), the method recursively calls itself on that directory. If a .py file is found, a quiet attempt to load the serv...
[ "def", "_scanDirectoryForServices", "(", "self", ",", "directoryPath", ")", ":", "# checking if path is actually a directory", "if", "not", "os", ".", "path", ".", "isdir", "(", "directoryPath", ")", ":", "return", "for", "item", "in", "os", ".", "listdir", "(",...
Scan a directory looking for service files. If another directory is found (excluding any python bytecode cache), the method recursively calls itself on that directory. If a .py file is found, a quiet attempt to load the service from it is performed. :param: <str> path to look for servic...
[ "Scan", "a", "directory", "looking", "for", "service", "files", ".", "If", "another", "directory", "is", "found", "(", "excluding", "any", "python", "bytecode", "cache", ")", "the", "method", "recursively", "calls", "itself", "on", "that", "directory", ".", ...
train
https://github.com/Nixiware/viper/blob/fbe6057facd8d46103e9955880dfd99e63b7acb3/nx/viper/module.py#L81-L106
Nixiware/viper
nx/viper/module.py
Module._loadService
def _loadService(self, servicePath): """ Check if an application service can be found at the specified path. If found, instantiate it and add it to the application service pool. :param: <str> service file path :return: <void> """ serviceName = ntpath.basename(ser...
python
def _loadService(self, servicePath): """ Check if an application service can be found at the specified path. If found, instantiate it and add it to the application service pool. :param: <str> service file path :return: <void> """ serviceName = ntpath.basename(ser...
[ "def", "_loadService", "(", "self", ",", "servicePath", ")", ":", "serviceName", "=", "ntpath", ".", "basename", "(", "servicePath", ")", ".", "replace", "(", "\".py\"", ",", "\"\"", ")", "# importing service", "serviceSpec", "=", "importlib", ".", "util", "...
Check if an application service can be found at the specified path. If found, instantiate it and add it to the application service pool. :param: <str> service file path :return: <void>
[ "Check", "if", "an", "application", "service", "can", "be", "found", "at", "the", "specified", "path", ".", "If", "found", "instantiate", "it", "and", "add", "it", "to", "the", "application", "service", "pool", "." ]
train
https://github.com/Nixiware/viper/blob/fbe6057facd8d46103e9955880dfd99e63b7acb3/nx/viper/module.py#L108-L134
colab/colab-superarchives-plugin
src/colab_superarchives/views.py
EmailView.post
def post(self, request, key): """Create new email address that will wait for validation""" email = request.POST.get('email') user_id = request.POST.get('user') if not email: return http.HttpResponseBadRequest() try: EmailAddressValidation.objects.create(...
python
def post(self, request, key): """Create new email address that will wait for validation""" email = request.POST.get('email') user_id = request.POST.get('user') if not email: return http.HttpResponseBadRequest() try: EmailAddressValidation.objects.create(...
[ "def", "post", "(", "self", ",", "request", ",", "key", ")", ":", "email", "=", "request", ".", "POST", ".", "get", "(", "'email'", ")", "user_id", "=", "request", ".", "POST", ".", "get", "(", "'user'", ")", "if", "not", "email", ":", "return", ...
Create new email address that will wait for validation
[ "Create", "new", "email", "address", "that", "will", "wait", "for", "validation" ]
train
https://github.com/colab/colab-superarchives-plugin/blob/fe588a1d4fac874ccad2063ee19a857028a22721/src/colab_superarchives/views.py#L202-L219
radjkarl/fancyTools
fancytools/math/scale.py
scale
def scale(arr, mn=0, mx=1): """ Apply min-max scaling (normalize) then scale to (mn,mx) """ amn = arr.min() amx = arr.max() # normalize: arr = (arr - amn) / (amx - amn) # scale: if amn != mn or amx != mx: arr *= mx - mn arr += mn return arr
python
def scale(arr, mn=0, mx=1): """ Apply min-max scaling (normalize) then scale to (mn,mx) """ amn = arr.min() amx = arr.max() # normalize: arr = (arr - amn) / (amx - amn) # scale: if amn != mn or amx != mx: arr *= mx - mn arr += mn return arr
[ "def", "scale", "(", "arr", ",", "mn", "=", "0", ",", "mx", "=", "1", ")", ":", "amn", "=", "arr", ".", "min", "(", ")", "amx", "=", "arr", ".", "max", "(", ")", "# normalize:", "arr", "=", "(", "arr", "-", "amn", ")", "/", "(", "amx", "-...
Apply min-max scaling (normalize) then scale to (mn,mx)
[ "Apply", "min", "-", "max", "scaling", "(", "normalize", ")", "then", "scale", "to", "(", "mn", "mx", ")" ]
train
https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/math/scale.py#L2-L15
maxfischer2781/chainlet
chainlet/concurrency/base.py
multi_iter
def multi_iter(iterable, count=2): """Return `count` independent, thread-safe iterators for `iterable`""" # no need to special-case re-usable, container-like iterables if not isinstance( iterable, ( list, tuple, set, FutureChainResults, ...
python
def multi_iter(iterable, count=2): """Return `count` independent, thread-safe iterators for `iterable`""" # no need to special-case re-usable, container-like iterables if not isinstance( iterable, ( list, tuple, set, FutureChainResults, ...
[ "def", "multi_iter", "(", "iterable", ",", "count", "=", "2", ")", ":", "# no need to special-case re-usable, container-like iterables", "if", "not", "isinstance", "(", "iterable", ",", "(", "list", ",", "tuple", ",", "set", ",", "FutureChainResults", ",", "collec...
Return `count` independent, thread-safe iterators for `iterable`
[ "Return", "count", "independent", "thread", "-", "safe", "iterators", "for", "iterable" ]
train
https://github.com/maxfischer2781/chainlet/blob/4e17f9992b4780bd0d9309202e2847df640bffe8/chainlet/concurrency/base.py#L192-L203
maxfischer2781/chainlet
chainlet/concurrency/base.py
StoredFuture.realise
def realise(self): """ Realise the future if possible If the future has not been realised yet, do so in the current thread. This will block execution until the future is realised. Otherwise, do not block but return whether the result is already available. This will not ...
python
def realise(self): """ Realise the future if possible If the future has not been realised yet, do so in the current thread. This will block execution until the future is realised. Otherwise, do not block but return whether the result is already available. This will not ...
[ "def", "realise", "(", "self", ")", ":", "if", "self", ".", "_mutex", ".", "acquire", "(", "False", ")", ":", "# realise the future in this thread", "try", ":", "if", "self", ".", "_result", "is", "not", "None", ":", "return", "True", "call", ",", "args"...
Realise the future if possible If the future has not been realised yet, do so in the current thread. This will block execution until the future is realised. Otherwise, do not block but return whether the result is already available. This will not return the result nor propagate any exc...
[ "Realise", "the", "future", "if", "possible" ]
train
https://github.com/maxfischer2781/chainlet/blob/4e17f9992b4780bd0d9309202e2847df640bffe8/chainlet/concurrency/base.py#L30-L60
maxfischer2781/chainlet
chainlet/concurrency/base.py
StoredFuture.result
def result(self): """ The result from realising the future If the result is not available, block until done. :return: result of the future :raises: any exception encountered during realising the future """ if self._result is None: self.await_result()...
python
def result(self): """ The result from realising the future If the result is not available, block until done. :return: result of the future :raises: any exception encountered during realising the future """ if self._result is None: self.await_result()...
[ "def", "result", "(", "self", ")", ":", "if", "self", ".", "_result", "is", "None", ":", "self", ".", "await_result", "(", ")", "chunks", ",", "exception", "=", "self", ".", "_result", "if", "exception", "is", "None", ":", "return", "chunks", "raise", ...
The result from realising the future If the result is not available, block until done. :return: result of the future :raises: any exception encountered during realising the future
[ "The", "result", "from", "realising", "the", "future" ]
train
https://github.com/maxfischer2781/chainlet/blob/4e17f9992b4780bd0d9309202e2847df640bffe8/chainlet/concurrency/base.py#L71-L85
msvana/warcreader
warcreader/warcreader.py
WarcFile.get_warcinfo
def get_warcinfo(self): ''' Returns WARCINFO record from the archieve as a single string including WARC header. Expects the record to be in the beginning of the archieve, otherwise it will be not found. ''' if self.searched_for_warcinfo: return self.warcinfo prev_line = None in_warcinfo_rec...
python
def get_warcinfo(self): ''' Returns WARCINFO record from the archieve as a single string including WARC header. Expects the record to be in the beginning of the archieve, otherwise it will be not found. ''' if self.searched_for_warcinfo: return self.warcinfo prev_line = None in_warcinfo_rec...
[ "def", "get_warcinfo", "(", "self", ")", ":", "if", "self", ".", "searched_for_warcinfo", ":", "return", "self", ".", "warcinfo", "prev_line", "=", "None", "in_warcinfo_record", "=", "False", "self", ".", "searched_for_warcinfo", "=", "True", "for", "line", "i...
Returns WARCINFO record from the archieve as a single string including WARC header. Expects the record to be in the beginning of the archieve, otherwise it will be not found.
[ "Returns", "WARCINFO", "record", "from", "the", "archieve", "as", "a", "single", "string", "including", "WARC", "header", ".", "Expects", "the", "record", "to", "be", "in", "the", "beginning", "of", "the", "archieve", "otherwise", "it", "will", "be", "not", ...
train
https://github.com/msvana/warcreader/blob/c61454ce95a7b6e3e8560852dfd319dd64351bf0/warcreader/warcreader.py#L105-L132
msvana/warcreader
warcreader/warcreader.py
WarcFile.init_state
def init_state(self): ''' Sets the initial state of the state machine. ''' self.in_warc_response = False self.in_http_response = False self.in_payload = False
python
def init_state(self): ''' Sets the initial state of the state machine. ''' self.in_warc_response = False self.in_http_response = False self.in_payload = False
[ "def", "init_state", "(", "self", ")", ":", "self", ".", "in_warc_response", "=", "False", "self", ".", "in_http_response", "=", "False", "self", ".", "in_payload", "=", "False" ]
Sets the initial state of the state machine.
[ "Sets", "the", "initial", "state", "of", "the", "state", "machine", "." ]
train
https://github.com/msvana/warcreader/blob/c61454ce95a7b6e3e8560852dfd319dd64351bf0/warcreader/warcreader.py#L134-L138
sassoo/goldman
goldman/types/state.py
Type.to_native
def to_native(self, value, context=None): """ Schematics deserializer override We return a us.states.State object so the abbreviation or long name can be trivially accessed. Additionally, some geo type ops are available. TIP: The us.states library expects unicode so we ...
python
def to_native(self, value, context=None): """ Schematics deserializer override We return a us.states.State object so the abbreviation or long name can be trivially accessed. Additionally, some geo type ops are available. TIP: The us.states library expects unicode so we ...
[ "def", "to_native", "(", "self", ",", "value", ",", "context", "=", "None", ")", ":", "if", "isinstance", "(", "value", ",", "us", ".", "states", ".", "State", ")", ":", "return", "value", "try", ":", "state", "=", "us", ".", "states", ".", "lookup...
Schematics deserializer override We return a us.states.State object so the abbreviation or long name can be trivially accessed. Additionally, some geo type ops are available. TIP: The us.states library expects unicode so we must ensure value is encoded properly. :...
[ "Schematics", "deserializer", "override" ]
train
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/types/state.py#L21-L43
dossier/dossier.label
dossier/label/relation_label.py
RelationLabelStore._keys_from_label
def _keys_from_label(self, label): '''Convert a label into a kvl key. ''' k1 = (label.content_id1, label.content_id2, label.annotator_id, time_complement(label.epoch_ticks)) k2 = (label.content_id2, label.content_id1, label.annotator_id, time_complement(label....
python
def _keys_from_label(self, label): '''Convert a label into a kvl key. ''' k1 = (label.content_id1, label.content_id2, label.annotator_id, time_complement(label.epoch_ticks)) k2 = (label.content_id2, label.content_id1, label.annotator_id, time_complement(label....
[ "def", "_keys_from_label", "(", "self", ",", "label", ")", ":", "k1", "=", "(", "label", ".", "content_id1", ",", "label", ".", "content_id2", ",", "label", ".", "annotator_id", ",", "time_complement", "(", "label", ".", "epoch_ticks", ")", ")", "k2", "=...
Convert a label into a kvl key.
[ "Convert", "a", "label", "into", "a", "kvl", "key", "." ]
train
https://github.com/dossier/dossier.label/blob/d445e56b02ffd91ad46b0872cfbff62b9afef7ec/dossier/label/relation_label.py#L218-L225
dossier/dossier.label
dossier/label/relation_label.py
RelationLabelStore._value_from_label
def _value_from_label(self, label): '''Convert a label into a kvl value. ''' unser_val = (label.rel_strength.value, label.meta) return cbor.dumps(unser_val)
python
def _value_from_label(self, label): '''Convert a label into a kvl value. ''' unser_val = (label.rel_strength.value, label.meta) return cbor.dumps(unser_val)
[ "def", "_value_from_label", "(", "self", ",", "label", ")", ":", "unser_val", "=", "(", "label", ".", "rel_strength", ".", "value", ",", "label", ".", "meta", ")", "return", "cbor", ".", "dumps", "(", "unser_val", ")" ]
Convert a label into a kvl value.
[ "Convert", "a", "label", "into", "a", "kvl", "value", "." ]
train
https://github.com/dossier/dossier.label/blob/d445e56b02ffd91ad46b0872cfbff62b9afef7ec/dossier/label/relation_label.py#L227-L231
dossier/dossier.label
dossier/label/relation_label.py
RelationLabelStore._label_from_kvlayer
def _label_from_kvlayer(self, key, val): '''Make a label from a kvlayer row. ''' (content_id1, content_id2, annotator_id, inverted_epoch_ticks) = key epoch_ticks = time_complement(inverted_epoch_ticks) rel_strength, meta = cbor.loads(val) return RelationLabel(co...
python
def _label_from_kvlayer(self, key, val): '''Make a label from a kvlayer row. ''' (content_id1, content_id2, annotator_id, inverted_epoch_ticks) = key epoch_ticks = time_complement(inverted_epoch_ticks) rel_strength, meta = cbor.loads(val) return RelationLabel(co...
[ "def", "_label_from_kvlayer", "(", "self", ",", "key", ",", "val", ")", ":", "(", "content_id1", ",", "content_id2", ",", "annotator_id", ",", "inverted_epoch_ticks", ")", "=", "key", "epoch_ticks", "=", "time_complement", "(", "inverted_epoch_ticks", ")", "rel_...
Make a label from a kvlayer row.
[ "Make", "a", "label", "from", "a", "kvlayer", "row", "." ]
train
https://github.com/dossier/dossier.label/blob/d445e56b02ffd91ad46b0872cfbff62b9afef7ec/dossier/label/relation_label.py#L233-L243
dossier/dossier.label
dossier/label/relation_label.py
RelationLabelStore.get
def get(self, cid1, cid2, annotator_id): '''Retrieve a relation label from the store. ''' t = (cid1, cid2, annotator_id) for k, v in self.kvl.scan(self.TABLE, (t, t)): return self._label_from_kvlayer(k, v)
python
def get(self, cid1, cid2, annotator_id): '''Retrieve a relation label from the store. ''' t = (cid1, cid2, annotator_id) for k, v in self.kvl.scan(self.TABLE, (t, t)): return self._label_from_kvlayer(k, v)
[ "def", "get", "(", "self", ",", "cid1", ",", "cid2", ",", "annotator_id", ")", ":", "t", "=", "(", "cid1", ",", "cid2", ",", "annotator_id", ")", "for", "k", ",", "v", "in", "self", ".", "kvl", ".", "scan", "(", "self", ".", "TABLE", ",", "(", ...
Retrieve a relation label from the store.
[ "Retrieve", "a", "relation", "label", "from", "the", "store", "." ]
train
https://github.com/dossier/dossier.label/blob/d445e56b02ffd91ad46b0872cfbff62b9afef7ec/dossier/label/relation_label.py#L256-L261
dossier/dossier.label
dossier/label/relation_label.py
RelationLabelStore.get_related
def get_related(self, content_id, min_strength=None): '''Get positive relation labels for ``cid``. If ``min_strength`` is set, will restrict results to labels with a ``rel_strength`` greater or equal to the provided ``RelationStrength`` value. Note: ``min_strength`` should be of ...
python
def get_related(self, content_id, min_strength=None): '''Get positive relation labels for ``cid``. If ``min_strength`` is set, will restrict results to labels with a ``rel_strength`` greater or equal to the provided ``RelationStrength`` value. Note: ``min_strength`` should be of ...
[ "def", "get_related", "(", "self", ",", "content_id", ",", "min_strength", "=", "None", ")", ":", "def", "is_related", "(", "label", ")", ":", "if", "min_strength", "is", "not", "None", ":", "return", "label", ".", "rel_strength", ">=", "min_strength", "el...
Get positive relation labels for ``cid``. If ``min_strength`` is set, will restrict results to labels with a ``rel_strength`` greater or equal to the provided ``RelationStrength`` value. Note: ``min_strength`` should be of type ``RelationStrength``.
[ "Get", "positive", "relation", "labels", "for", "cid", "." ]
train
https://github.com/dossier/dossier.label/blob/d445e56b02ffd91ad46b0872cfbff62b9afef7ec/dossier/label/relation_label.py#L263-L278
dossier/dossier.label
dossier/label/relation_label.py
RelationLabelStore.get_related_ids
def get_related_ids(self, content_id, min_strength=None): '''Get identifiers for related identifiers. ''' related_labels = self.get_related(content_id, min_strength=min_strength) related_idents = set() for label in related_labels: ...
python
def get_related_ids(self, content_id, min_strength=None): '''Get identifiers for related identifiers. ''' related_labels = self.get_related(content_id, min_strength=min_strength) related_idents = set() for label in related_labels: ...
[ "def", "get_related_ids", "(", "self", ",", "content_id", ",", "min_strength", "=", "None", ")", ":", "related_labels", "=", "self", ".", "get_related", "(", "content_id", ",", "min_strength", "=", "min_strength", ")", "related_idents", "=", "set", "(", ")", ...
Get identifiers for related identifiers.
[ "Get", "identifiers", "for", "related", "identifiers", "." ]
train
https://github.com/dossier/dossier.label/blob/d445e56b02ffd91ad46b0872cfbff62b9afef7ec/dossier/label/relation_label.py#L280-L289
dossier/dossier.label
dossier/label/relation_label.py
RelationLabelStore.get_relationships_for_idents
def get_relationships_for_idents(self, cid, idents): '''Get relationships between ``idents`` and a ``cid``. Returns a dictionary mapping the identifiers in ``idents`` to either None, if no relationship label is found between the identifier and ``cid``, or a RelationshipType classifying ...
python
def get_relationships_for_idents(self, cid, idents): '''Get relationships between ``idents`` and a ``cid``. Returns a dictionary mapping the identifiers in ``idents`` to either None, if no relationship label is found between the identifier and ``cid``, or a RelationshipType classifying ...
[ "def", "get_relationships_for_idents", "(", "self", ",", "cid", ",", "idents", ")", ":", "keys", "=", "[", "(", "cid", ",", "ident", ",", ")", "for", "ident", "in", "idents", "]", "key_ranges", "=", "zip", "(", "keys", ",", "keys", ")", "mapping", "=...
Get relationships between ``idents`` and a ``cid``. Returns a dictionary mapping the identifiers in ``idents`` to either None, if no relationship label is found between the identifier and ``cid``, or a RelationshipType classifying the strength of the relationship between the identifier ...
[ "Get", "relationships", "between", "idents", "and", "a", "cid", "." ]
train
https://github.com/dossier/dossier.label/blob/d445e56b02ffd91ad46b0872cfbff62b9afef7ec/dossier/label/relation_label.py#L291-L309
dossier/dossier.label
dossier/label/relation_label.py
RelationLabelStore.everything
def everything(self, content_id=None): '''Returns a generator of all labels in the store. If ``content_id`` is set, will restrict results to labels containing the provided ``content_id``. ''' if content_id is not None: ranges = [((content_id,), (content_id,))] ...
python
def everything(self, content_id=None): '''Returns a generator of all labels in the store. If ``content_id`` is set, will restrict results to labels containing the provided ``content_id``. ''' if content_id is not None: ranges = [((content_id,), (content_id,))] ...
[ "def", "everything", "(", "self", ",", "content_id", "=", "None", ")", ":", "if", "content_id", "is", "not", "None", ":", "ranges", "=", "[", "(", "(", "content_id", ",", ")", ",", "(", "content_id", ",", ")", ")", "]", "else", ":", "ranges", "=", ...
Returns a generator of all labels in the store. If ``content_id`` is set, will restrict results to labels containing the provided ``content_id``.
[ "Returns", "a", "generator", "of", "all", "labels", "in", "the", "store", "." ]
train
https://github.com/dossier/dossier.label/blob/d445e56b02ffd91ad46b0872cfbff62b9afef7ec/dossier/label/relation_label.py#L311-L324
fogcitymarathoner/s3_mysql_backup
s3_mysql_backup/backup_db.py
backup_db
def backup_db( aws_access_key_id, aws_secret_access_key, bucket_name, s3_folder, database, mysql_host, mysql_port, db_user, db_pass, db_backups_dir, backup_aging_time): """ dumps databases into /backups, uploads to s3, d...
python
def backup_db( aws_access_key_id, aws_secret_access_key, bucket_name, s3_folder, database, mysql_host, mysql_port, db_user, db_pass, db_backups_dir, backup_aging_time): """ dumps databases into /backups, uploads to s3, d...
[ "def", "backup_db", "(", "aws_access_key_id", ",", "aws_secret_access_key", ",", "bucket_name", ",", "s3_folder", ",", "database", ",", "mysql_host", ",", "mysql_port", ",", "db_user", ",", "db_pass", ",", "db_backups_dir", ",", "backup_aging_time", ")", ":", "# ...
dumps databases into /backups, uploads to s3, deletes backups older than a month fab -f ./fabfile.py backup_dbs :param aws_access_key_id: :param aws_secret_access_key: :param bucket_name: :param database: :param mysql_host: :param mysql_port: :param db_pass: :param db_backups_dir: ...
[ "dumps", "databases", "into", "/", "backups", "uploads", "to", "s3", "deletes", "backups", "older", "than", "a", "month", "fab", "-", "f", ".", "/", "fabfile", ".", "py", "backup_dbs", ":", "param", "aws_access_key_id", ":", ":", "param", "aws_secret_access_...
train
https://github.com/fogcitymarathoner/s3_mysql_backup/blob/8a0fb3e51a7b873eb4287d4954548a0dbab0e734/s3_mysql_backup/backup_db.py#L11-L67
collectiveacuity/labPack
labpack/authentication/oauth2.py
oauth2Client.generate_url
def generate_url(self, service_scope=None, state_value='', additional_fields=None): ''' a method to generate an authorization url to oauth2 service for client :param service_scope: [optional] list with scope of permissions for agent :param state_value: [optional] string with unique identi...
python
def generate_url(self, service_scope=None, state_value='', additional_fields=None): ''' a method to generate an authorization url to oauth2 service for client :param service_scope: [optional] list with scope of permissions for agent :param state_value: [optional] string with unique identi...
[ "def", "generate_url", "(", "self", ",", "service_scope", "=", "None", ",", "state_value", "=", "''", ",", "additional_fields", "=", "None", ")", ":", "title", "=", "'%s.generate_url'", "%", "self", ".", "__class__", ".", "__name__", "# validate inputs\r", "in...
a method to generate an authorization url to oauth2 service for client :param service_scope: [optional] list with scope of permissions for agent :param state_value: [optional] string with unique identifier for callback :param additional_fields: [optional] dictionary with key value strings f...
[ "a", "method", "to", "generate", "an", "authorization", "url", "to", "oauth2", "service", "for", "client", ":", "param", "service_scope", ":", "[", "optional", "]", "list", "with", "scope", "of", "permissions", "for", "agent", ":", "param", "state_value", ":...
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/authentication/oauth2.py#L202-L253
collectiveacuity/labPack
labpack/authentication/oauth2.py
oauth2Client.renew_token
def renew_token(self, refresh_token): ''' a method to renew an access token from an oauth2 authorizing party :param auth_code: string with refresh token provided by service with access token :return: dictionary with access token details inside [json] key token_details = self.ob...
python
def renew_token(self, refresh_token): ''' a method to renew an access token from an oauth2 authorizing party :param auth_code: string with refresh token provided by service with access token :return: dictionary with access token details inside [json] key token_details = self.ob...
[ "def", "renew_token", "(", "self", ",", "refresh_token", ")", ":", "title", "=", "'%s.renew_token'", "%", "self", ".", "__class__", ".", "__name__", "# validate inputs\r", "input_args", "=", "{", "'refresh_token'", ":", "refresh_token", "}", "for", "key", ",", ...
a method to renew an access token from an oauth2 authorizing party :param auth_code: string with refresh token provided by service with access token :return: dictionary with access token details inside [json] key token_details = self.objects.token.schema
[ "a", "method", "to", "renew", "an", "access", "token", "from", "an", "oauth2", "authorizing", "party", ":", "param", "auth_code", ":", "string", "with", "refresh", "token", "provided", "by", "service", "with", "access", "token", ":", "return", ":", "dictiona...
train
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/authentication/oauth2.py#L314-L370
django-py/django-doberman
doberman/contrib/captcha/client.py
displayhtml
def displayhtml(public_key, attrs, use_ssl=False, error=None): """Gets the HTML to display for reCAPTCHA public_key -- The public api key use_ssl -- Should the request be sent over ssl? error -- An error message to display (from RecaptchaResponse.error_co...
python
def displayhtml(public_key, attrs, use_ssl=False, error=None): """Gets the HTML to display for reCAPTCHA public_key -- The public api key use_ssl -- Should the request be sent over ssl? error -- An error message to display (from RecaptchaResponse.error_co...
[ "def", "displayhtml", "(", "public_key", ",", "attrs", ",", "use_ssl", "=", "False", ",", "error", "=", "None", ")", ":", "error_param", "=", "''", "if", "error", ":", "error_param", "=", "'&error=%s'", "%", "error", "if", "use_ssl", ":", "server", "=", ...
Gets the HTML to display for reCAPTCHA public_key -- The public api key use_ssl -- Should the request be sent over ssl? error -- An error message to display (from RecaptchaResponse.error_code)
[ "Gets", "the", "HTML", "to", "display", "for", "reCAPTCHA" ]
train
https://github.com/django-py/django-doberman/blob/2e5959737a1b64234ed5a179c93f96a0de1c3e5c/doberman/contrib/captcha/client.py#L42-L71
django-py/django-doberman
doberman/contrib/captcha/client.py
submit
def submit(recaptcha_challenge_field, recaptcha_response_field, private_key, remoteip, use_ssl=False): """ Submits a reCAPTCHA request for verification. Returns RecaptchaResponse for the request recaptcha_challenge_field -- The value of recaptcha_challenge_fi...
python
def submit(recaptcha_challenge_field, recaptcha_response_field, private_key, remoteip, use_ssl=False): """ Submits a reCAPTCHA request for verification. Returns RecaptchaResponse for the request recaptcha_challenge_field -- The value of recaptcha_challenge_fi...
[ "def", "submit", "(", "recaptcha_challenge_field", ",", "recaptcha_response_field", ",", "private_key", ",", "remoteip", ",", "use_ssl", "=", "False", ")", ":", "if", "not", "(", "recaptcha_response_field", "and", "recaptcha_challenge_field", "and", "len", "(", "rec...
Submits a reCAPTCHA request for verification. Returns RecaptchaResponse for the request recaptcha_challenge_field -- The value of recaptcha_challenge_field from the form recaptcha_response_field -- The value of recaptcha_response_field from the form private_key -- your reCAPTCHA private key ...
[ "Submits", "a", "reCAPTCHA", "request", "for", "verification", ".", "Returns", "RecaptchaResponse", "for", "the", "request" ]
train
https://github.com/django-py/django-doberman/blob/2e5959737a1b64234ed5a179c93f96a0de1c3e5c/doberman/contrib/captcha/client.py#L74-L150
sassoo/goldman
goldman/queryparams/sort.py
_validate_field
def _validate_field(param, fields): """ Ensure the sortable field exists on the model """ if param.field not in fields: raise InvalidQueryParams(**{ 'detail': 'The sort query param value of "%s" is ' 'invalid. That field does not exist on the ' 'r...
python
def _validate_field(param, fields): """ Ensure the sortable field exists on the model """ if param.field not in fields: raise InvalidQueryParams(**{ 'detail': 'The sort query param value of "%s" is ' 'invalid. That field does not exist on the ' 'r...
[ "def", "_validate_field", "(", "param", ",", "fields", ")", ":", "if", "param", ".", "field", "not", "in", "fields", ":", "raise", "InvalidQueryParams", "(", "*", "*", "{", "'detail'", ":", "'The sort query param value of \"%s\" is '", "'invalid. That field does not...
Ensure the sortable field exists on the model
[ "Ensure", "the", "sortable", "field", "exists", "on", "the", "model" ]
train
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/queryparams/sort.py#L74-L84
sassoo/goldman
goldman/queryparams/sort.py
_validate_no_rels
def _validate_no_rels(param, rels): """ Ensure the sortable field is not on a relationship """ if param.field in rels: raise InvalidQueryParams(**{ 'detail': 'The sort query param value of "%s" is not ' 'supported. Sorting on relationships is not ' ...
python
def _validate_no_rels(param, rels): """ Ensure the sortable field is not on a relationship """ if param.field in rels: raise InvalidQueryParams(**{ 'detail': 'The sort query param value of "%s" is not ' 'supported. Sorting on relationships is not ' ...
[ "def", "_validate_no_rels", "(", "param", ",", "rels", ")", ":", "if", "param", ".", "field", "in", "rels", ":", "raise", "InvalidQueryParams", "(", "*", "*", "{", "'detail'", ":", "'The sort query param value of \"%s\" is not '", "'supported. Sorting on relationships...
Ensure the sortable field is not on a relationship
[ "Ensure", "the", "sortable", "field", "is", "not", "on", "a", "relationship" ]
train
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/queryparams/sort.py#L87-L97
sassoo/goldman
goldman/queryparams/sort.py
init
def init(req, model): """ Determine the sorting preference by query parameter Return an array of Sortable objects. """ rels = model.relationships fields = model.all_fields params = req.get_param_as_list('sort') or [goldman.config.SORT] params = [Sortable(param.lower()) for param in params...
python
def init(req, model): """ Determine the sorting preference by query parameter Return an array of Sortable objects. """ rels = model.relationships fields = model.all_fields params = req.get_param_as_list('sort') or [goldman.config.SORT] params = [Sortable(param.lower()) for param in params...
[ "def", "init", "(", "req", ",", "model", ")", ":", "rels", "=", "model", ".", "relationships", "fields", "=", "model", ".", "all_fields", "params", "=", "req", ".", "get_param_as_list", "(", "'sort'", ")", "or", "[", "goldman", ".", "config", ".", "SOR...
Determine the sorting preference by query parameter Return an array of Sortable objects.
[ "Determine", "the", "sorting", "preference", "by", "query", "parameter" ]
train
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/queryparams/sort.py#L100-L116
xtream1101/web-wrapper
web_wrapper/driver_requests.py
DriverRequests.set_proxy
def set_proxy(self, proxy): """ Set proxy for requests session """ # TODO: Validate proxy url format if proxy is None: self.driver.proxies = {'http': None, 'https': None } else: ...
python
def set_proxy(self, proxy): """ Set proxy for requests session """ # TODO: Validate proxy url format if proxy is None: self.driver.proxies = {'http': None, 'https': None } else: ...
[ "def", "set_proxy", "(", "self", ",", "proxy", ")", ":", "# TODO: Validate proxy url format", "if", "proxy", "is", "None", ":", "self", ".", "driver", ".", "proxies", "=", "{", "'http'", ":", "None", ",", "'https'", ":", "None", "}", "else", ":", "self",...
Set proxy for requests session
[ "Set", "proxy", "for", "requests", "session" ]
train
https://github.com/xtream1101/web-wrapper/blob/2bfc63caa7d316564088951f01a490db493ea240/web_wrapper/driver_requests.py#L54-L69
xtream1101/web-wrapper
web_wrapper/driver_requests.py
DriverRequests._create_session
def _create_session(self): """ Creates a fresh session with the default header (random UA) """ self.driver = requests.Session(**self.driver_args) # Set default headers self.update_headers(self.current_headers) self.update_cookies(self.current_cookies) self...
python
def _create_session(self): """ Creates a fresh session with the default header (random UA) """ self.driver = requests.Session(**self.driver_args) # Set default headers self.update_headers(self.current_headers) self.update_cookies(self.current_cookies) self...
[ "def", "_create_session", "(", "self", ")", ":", "self", ".", "driver", "=", "requests", ".", "Session", "(", "*", "*", "self", ".", "driver_args", ")", "# Set default headers", "self", ".", "update_headers", "(", "self", ".", "current_headers", ")", "self",...
Creates a fresh session with the default header (random UA)
[ "Creates", "a", "fresh", "session", "with", "the", "default", "header", "(", "random", "UA", ")" ]
train
https://github.com/xtream1101/web-wrapper/blob/2bfc63caa7d316564088951f01a490db493ea240/web_wrapper/driver_requests.py#L75-L83
xtream1101/web-wrapper
web_wrapper/driver_requests.py
DriverRequests._get_site
def _get_site(self, url, headers, cookies, timeout, driver_args, driver_kwargs): """ Try and return page content in the requested format using requests """ try: # Headers and cookies are combined to the ones stored in the requests session # Ones passed in here wi...
python
def _get_site(self, url, headers, cookies, timeout, driver_args, driver_kwargs): """ Try and return page content in the requested format using requests """ try: # Headers and cookies are combined to the ones stored in the requests session # Ones passed in here wi...
[ "def", "_get_site", "(", "self", ",", "url", ",", "headers", ",", "cookies", ",", "timeout", ",", "driver_args", ",", "driver_kwargs", ")", ":", "try", ":", "# Headers and cookies are combined to the ones stored in the requests session", "# Ones passed in here will overrid...
Try and return page content in the requested format using requests
[ "Try", "and", "return", "page", "content", "in", "the", "requested", "format", "using", "requests" ]
train
https://github.com/xtream1101/web-wrapper/blob/2bfc63caa7d316564088951f01a490db493ea240/web_wrapper/driver_requests.py#L99-L125
PyMLGame/pymlgame
pymlgame/controller.py
Controller._new_controller
def _new_controller(self, addr, port): """ Get an uid for your controller. :param addr: Address of the controller :param port: Port of the controller :type addr: str :type port: int :return: Unique id of the controller :rtype: str """ for ...
python
def _new_controller(self, addr, port): """ Get an uid for your controller. :param addr: Address of the controller :param port: Port of the controller :type addr: str :type port: int :return: Unique id of the controller :rtype: str """ for ...
[ "def", "_new_controller", "(", "self", ",", "addr", ",", "port", ")", ":", "for", "uid", ",", "controller", "in", "self", ".", "controllers", ".", "items", "(", ")", ":", "if", "controller", "[", "0", "]", "==", "addr", ":", "# duplicate address. sending...
Get an uid for your controller. :param addr: Address of the controller :param port: Port of the controller :type addr: str :type port: int :return: Unique id of the controller :rtype: str
[ "Get", "an", "uid", "for", "your", "controller", "." ]
train
https://github.com/PyMLGame/pymlgame/blob/450fe77d35f9a26c107586d6954f69c3895bf504/pymlgame/controller.py#L40-L70