repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
mansam/validator.py
validator/__init__.py
validate
def validate(validation, dictionary): """ Validate that a dictionary passes a set of key-based validators. If all of the keys in the dictionary are within the parameters specified by the validation mapping, then the validation passes. :param validation: a mapping of keys to validators :...
python
def validate(validation, dictionary): """ Validate that a dictionary passes a set of key-based validators. If all of the keys in the dictionary are within the parameters specified by the validation mapping, then the validation passes. :param validation: a mapping of keys to validators :...
[ "def", "validate", "(", "validation", ",", "dictionary", ")", ":", "errors", "=", "defaultdict", "(", "list", ")", "for", "key", "in", "validation", ":", "if", "isinstance", "(", "validation", "[", "key", "]", ",", "(", "list", ",", "tuple", ")", ")", ...
Validate that a dictionary passes a set of key-based validators. If all of the keys in the dictionary are within the parameters specified by the validation mapping, then the validation passes. :param validation: a mapping of keys to validators :type validation: dict :param dictionary: dict...
[ "Validate", "that", "a", "dictionary", "passes", "a", "set", "of", "key", "-", "based", "validators", ".", "If", "all", "of", "the", "keys", "in", "the", "dictionary", "are", "within", "the", "parameters", "specified", "by", "the", "validation", "mapping", ...
train
https://github.com/mansam/validator.py/blob/247f99c539c5c9aef3e5a6063026c687b8499090/validator/__init__.py#L635-L675
mansam/validator.py
validator/ext/__init__.py
ArgSpec
def ArgSpec(*args, **kwargs): """ Validate a function based on the given argspec. # Example: validations = { "foo": [ArgSpec("a", "b", c", bar="baz")] } def pass_func(a, b, c, bar="baz"): pass def fail_func(b, c, a, baz="bar"): pass ...
python
def ArgSpec(*args, **kwargs): """ Validate a function based on the given argspec. # Example: validations = { "foo": [ArgSpec("a", "b", c", bar="baz")] } def pass_func(a, b, c, bar="baz"): pass def fail_func(b, c, a, baz="bar"): pass ...
[ "def", "ArgSpec", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "argspec_lambda", "(", "value", ")", ":", "argspec", "=", "getargspec", "(", "value", ")", "argspec_kw_vals", "=", "(", ")", "if", "argspec", ".", "defaults", "is", "not", ...
Validate a function based on the given argspec. # Example: validations = { "foo": [ArgSpec("a", "b", c", bar="baz")] } def pass_func(a, b, c, bar="baz"): pass def fail_func(b, c, a, baz="bar"): pass passes = {"foo": pass_func} fail...
[ "Validate", "a", "function", "based", "on", "the", "given", "argspec", "." ]
train
https://github.com/mansam/validator.py/blob/247f99c539c5c9aef3e5a6063026c687b8499090/validator/ext/__init__.py#L35-L76
quantifiedcode/checkmate
checkmate/contrib/plugins/git/lib/repository_pygit2.py
get_first_date_for_group
def get_first_date_for_group(start_date,group_type,n): """ :param start: start date :n : how many groups we want to get :group_type : daily, weekly, monthly """ current_date = start_date if group_type == 'monthly': current_year = start_date.year current_month =...
python
def get_first_date_for_group(start_date,group_type,n): """ :param start: start date :n : how many groups we want to get :group_type : daily, weekly, monthly """ current_date = start_date if group_type == 'monthly': current_year = start_date.year current_month =...
[ "def", "get_first_date_for_group", "(", "start_date", ",", "group_type", ",", "n", ")", ":", "current_date", "=", "start_date", "if", "group_type", "==", "'monthly'", ":", "current_year", "=", "start_date", ".", "year", "current_month", "=", "start_date", ".", "...
:param start: start date :n : how many groups we want to get :group_type : daily, weekly, monthly
[ ":", "param", "start", ":", "start", "date", ":", "n", ":", "how", "many", "groups", "we", "want", "to", "get", ":", "group_type", ":", "daily", "weekly", "monthly" ]
train
https://github.com/quantifiedcode/checkmate/blob/1a4d010c8ef25c678d8d14dc8e37a9bed1883ca2/checkmate/contrib/plugins/git/lib/repository_pygit2.py#L36-L57
quantifiedcode/checkmate
checkmate/contrib/plugins/git/models.py
GitRepository.get_snapshots
def get_snapshots(self,**kwargs): """ Returns a list of snapshots in a given repository. """ commits = self.repository.get_commits(**kwargs) snapshots = [] for commit in commits: for key in ('committer_date','author_date'): commit[key] = dateti...
python
def get_snapshots(self,**kwargs): """ Returns a list of snapshots in a given repository. """ commits = self.repository.get_commits(**kwargs) snapshots = [] for commit in commits: for key in ('committer_date','author_date'): commit[key] = dateti...
[ "def", "get_snapshots", "(", "self", ",", "*", "*", "kwargs", ")", ":", "commits", "=", "self", ".", "repository", ".", "get_commits", "(", "*", "*", "kwargs", ")", "snapshots", "=", "[", "]", "for", "commit", "in", "commits", ":", "for", "key", "in"...
Returns a list of snapshots in a given repository.
[ "Returns", "a", "list", "of", "snapshots", "in", "a", "given", "repository", "." ]
train
https://github.com/quantifiedcode/checkmate/blob/1a4d010c8ef25c678d8d14dc8e37a9bed1883ca2/checkmate/contrib/plugins/git/models.py#L70-L86
quantifiedcode/checkmate
checkmate/lib/code/environment.py
diff_objects
def diff_objects(objects_a,objects_b,key,comparator = None,with_unchanged = False): """ Returns a "diff" between two lists of objects. :param key: The key that identifies objects with identical location in each set, such as files with the same path or code objects with the same URL. :pa...
python
def diff_objects(objects_a,objects_b,key,comparator = None,with_unchanged = False): """ Returns a "diff" between two lists of objects. :param key: The key that identifies objects with identical location in each set, such as files with the same path or code objects with the same URL. :pa...
[ "def", "diff_objects", "(", "objects_a", ",", "objects_b", ",", "key", ",", "comparator", "=", "None", ",", "with_unchanged", "=", "False", ")", ":", "objects_by_key", "=", "{", "'a'", ":", "defaultdict", "(", "list", ")", ",", "'b'", ":", "defaultdict", ...
Returns a "diff" between two lists of objects. :param key: The key that identifies objects with identical location in each set, such as files with the same path or code objects with the same URL. :param comparator: Comparison functions that decides if two objects are identical.
[ "Returns", "a", "diff", "between", "two", "lists", "of", "objects", "." ]
train
https://github.com/quantifiedcode/checkmate/blob/1a4d010c8ef25c678d8d14dc8e37a9bed1883ca2/checkmate/lib/code/environment.py#L46-L123
quantifiedcode/checkmate
checkmate/lib/code/environment.py
CodeEnvironment.diff_snapshots
def diff_snapshots(self,snapshot_a,snapshot_b,save = True, diff=None): """ Returns a list of """ file_revisions_a = snapshot_a.file_revisions file_revisions_b = snapshot_b.file_revisions file_revisions_diff = diff_objects(file_revisions_a, ...
python
def diff_snapshots(self,snapshot_a,snapshot_b,save = True, diff=None): """ Returns a list of """ file_revisions_a = snapshot_a.file_revisions file_revisions_b = snapshot_b.file_revisions file_revisions_diff = diff_objects(file_revisions_a, ...
[ "def", "diff_snapshots", "(", "self", ",", "snapshot_a", ",", "snapshot_b", ",", "save", "=", "True", ",", "diff", "=", "None", ")", ":", "file_revisions_a", "=", "snapshot_a", ".", "file_revisions", "file_revisions_b", "=", "snapshot_b", ".", "file_revisions", ...
Returns a list of
[ "Returns", "a", "list", "of" ]
train
https://github.com/quantifiedcode/checkmate/blob/1a4d010c8ef25c678d8d14dc8e37a9bed1883ca2/checkmate/lib/code/environment.py#L299-L420
quantifiedcode/checkmate
checkmate/lib/code/environment.py
CodeEnvironment.analyze
def analyze(self,file_revisions, save_if_empty = False, snapshot=None): """ Handling dependencies: * First, genreate a list of file revisions for this snapshot * Then, check which ones of of them already exist * For the existing ones, check their dependencies * If any o...
python
def analyze(self,file_revisions, save_if_empty = False, snapshot=None): """ Handling dependencies: * First, genreate a list of file revisions for this snapshot * Then, check which ones of of them already exist * For the existing ones, check their dependencies * If any o...
[ "def", "analyze", "(", "self", ",", "file_revisions", ",", "save_if_empty", "=", "False", ",", "snapshot", "=", "None", ")", ":", "logger", ".", "debug", "(", "\"Analyzing code environment...\"", ")", "if", "snapshot", "is", "None", ":", "snapshot", "=", "Sn...
Handling dependencies: * First, genreate a list of file revisions for this snapshot * Then, check which ones of of them already exist * For the existing ones, check their dependencies * If any of the dependencies are outdated, add the dependent file revision to the analyze list ...
[ "Handling", "dependencies", ":" ]
train
https://github.com/quantifiedcode/checkmate/blob/1a4d010c8ef25c678d8d14dc8e37a9bed1883ca2/checkmate/lib/code/environment.py#L567-L689
quantifiedcode/checkmate
checkmate/lib/code/environment.py
CodeEnvironment.save_file_revisions
def save_file_revisions(self,snapshot,file_revisions): """ We convert various items in the file revision to documents, so that we can easily search and retrieve them... """ annotations = defaultdict(list) for file_revision in file_revisions: issues_results =...
python
def save_file_revisions(self,snapshot,file_revisions): """ We convert various items in the file revision to documents, so that we can easily search and retrieve them... """ annotations = defaultdict(list) for file_revision in file_revisions: issues_results =...
[ "def", "save_file_revisions", "(", "self", ",", "snapshot", ",", "file_revisions", ")", ":", "annotations", "=", "defaultdict", "(", "list", ")", "for", "file_revision", "in", "file_revisions", ":", "issues_results", "=", "{", "}", "for", "analyzer_name", ",", ...
We convert various items in the file revision to documents, so that we can easily search and retrieve them...
[ "We", "convert", "various", "items", "in", "the", "file", "revision", "to", "documents", "so", "that", "we", "can", "easily", "search", "and", "retrieve", "them", "..." ]
train
https://github.com/quantifiedcode/checkmate/blob/1a4d010c8ef25c678d8d14dc8e37a9bed1883ca2/checkmate/lib/code/environment.py#L691-L774
quantifiedcode/checkmate
checkmate/helpers/settings.py
update
def update(d,ud): """ Recursively merge the values of ud into d. """ if ud is None: return for key,value in ud.items(): if not key in d: d[key] = value elif isinstance(value,dict): update(d[key],value) else: d[key] = value
python
def update(d,ud): """ Recursively merge the values of ud into d. """ if ud is None: return for key,value in ud.items(): if not key in d: d[key] = value elif isinstance(value,dict): update(d[key],value) else: d[key] = value
[ "def", "update", "(", "d", ",", "ud", ")", ":", "if", "ud", "is", "None", ":", "return", "for", "key", ",", "value", "in", "ud", ".", "items", "(", ")", ":", "if", "not", "key", "in", "d", ":", "d", "[", "key", "]", "=", "value", "elif", "i...
Recursively merge the values of ud into d.
[ "Recursively", "merge", "the", "values", "of", "ud", "into", "d", "." ]
train
https://github.com/quantifiedcode/checkmate/blob/1a4d010c8ef25c678d8d14dc8e37a9bed1883ca2/checkmate/helpers/settings.py#L2-L14
quantifiedcode/checkmate
checkmate/contrib/plugins/git/commands/init.py
Command.find_git_repository
def find_git_repository(self, path): """ Tries to find a directory with a .git repository """ while path is not None: git_path = os.path.join(path,'.git') if os.path.exists(git_path) and os.path.isdir(git_path): return path path = os.pa...
python
def find_git_repository(self, path): """ Tries to find a directory with a .git repository """ while path is not None: git_path = os.path.join(path,'.git') if os.path.exists(git_path) and os.path.isdir(git_path): return path path = os.pa...
[ "def", "find_git_repository", "(", "self", ",", "path", ")", ":", "while", "path", "is", "not", "None", ":", "git_path", "=", "os", ".", "path", ".", "join", "(", "path", ",", "'.git'", ")", "if", "os", ".", "path", ".", "exists", "(", "git_path", ...
Tries to find a directory with a .git repository
[ "Tries", "to", "find", "a", "directory", "with", "a", ".", "git", "repository" ]
train
https://github.com/quantifiedcode/checkmate/blob/1a4d010c8ef25c678d8d14dc8e37a9bed1883ca2/checkmate/contrib/plugins/git/commands/init.py#L26-L35
quantifiedcode/checkmate
checkmate/migrations/env.py
run_migrations_offline
def run_migrations_offline(): """Run migrations in 'offline' mode. This configures the context with just a URL and not an Engine, though an Engine is acceptable here as well. By skipping the Engine creation we don't even need a DBAPI to be available. Calls to context.execute() here emit the g...
python
def run_migrations_offline(): """Run migrations in 'offline' mode. This configures the context with just a URL and not an Engine, though an Engine is acceptable here as well. By skipping the Engine creation we don't even need a DBAPI to be available. Calls to context.execute() here emit the g...
[ "def", "run_migrations_offline", "(", ")", ":", "project_path", "=", "get_project_path", "(", ")", "project_config", "=", "get_project_config", "(", "project_path", ")", "backend", "=", "get_backend", "(", "project_path", ",", "project_config", ",", "initialize_db", ...
Run migrations in 'offline' mode. This configures the context with just a URL and not an Engine, though an Engine is acceptable here as well. By skipping the Engine creation we don't even need a DBAPI to be available. Calls to context.execute() here emit the given string to the script output.
[ "Run", "migrations", "in", "offline", "mode", "." ]
train
https://github.com/quantifiedcode/checkmate/blob/1a4d010c8ef25c678d8d14dc8e37a9bed1883ca2/checkmate/migrations/env.py#L12-L36
quantifiedcode/checkmate
checkmate/migrations/env.py
run_migrations_online
def run_migrations_online(): """Run migrations in 'online' mode. In this scenario we need to create an Engine and associate a connection with the context. """ print("Running migrations online") project_path = get_project_path() project_config = get_project_config(project_path) backen...
python
def run_migrations_online(): """Run migrations in 'online' mode. In this scenario we need to create an Engine and associate a connection with the context. """ print("Running migrations online") project_path = get_project_path() project_config = get_project_config(project_path) backen...
[ "def", "run_migrations_online", "(", ")", ":", "print", "(", "\"Running migrations online\"", ")", "project_path", "=", "get_project_path", "(", ")", "project_config", "=", "get_project_config", "(", "project_path", ")", "backend", "=", "get_backend", "(", "project_pa...
Run migrations in 'online' mode. In this scenario we need to create an Engine and associate a connection with the context.
[ "Run", "migrations", "in", "online", "mode", "." ]
train
https://github.com/quantifiedcode/checkmate/blob/1a4d010c8ef25c678d8d14dc8e37a9bed1883ca2/checkmate/migrations/env.py#L39-L59
quantifiedcode/checkmate
checkmate/helpers/hashing.py
get_hash
def get_hash(node,fields = None,exclude = ['pk','_id'],target = 'pk'): """ Here we generate a unique hash for a given node in the syntax tree. """ hasher = Hasher() def add_to_hash(value): if isinstance(value,dict): if target in value: add_to_hash(value[target]...
python
def get_hash(node,fields = None,exclude = ['pk','_id'],target = 'pk'): """ Here we generate a unique hash for a given node in the syntax tree. """ hasher = Hasher() def add_to_hash(value): if isinstance(value,dict): if target in value: add_to_hash(value[target]...
[ "def", "get_hash", "(", "node", ",", "fields", "=", "None", ",", "exclude", "=", "[", "'pk'", ",", "'_id'", "]", ",", "target", "=", "'pk'", ")", ":", "hasher", "=", "Hasher", "(", ")", "def", "add_to_hash", "(", "value", ")", ":", "if", "isinstanc...
Here we generate a unique hash for a given node in the syntax tree.
[ "Here", "we", "generate", "a", "unique", "hash", "for", "a", "given", "node", "in", "the", "syntax", "tree", "." ]
train
https://github.com/quantifiedcode/checkmate/blob/1a4d010c8ef25c678d8d14dc8e37a9bed1883ca2/checkmate/helpers/hashing.py#L35-L65
quantifiedcode/checkmate
checkmate/contrib/plugins/python/pylint/analyzer.py
Reporter.add_message
def add_message(self, msg_id, location, msg): """Client API to send a message""" self._messages.append((msg_id,location,msg))
python
def add_message(self, msg_id, location, msg): """Client API to send a message""" self._messages.append((msg_id,location,msg))
[ "def", "add_message", "(", "self", ",", "msg_id", ",", "location", ",", "msg", ")", ":", "self", ".", "_messages", ".", "append", "(", "(", "msg_id", ",", "location", ",", "msg", ")", ")" ]
Client API to send a message
[ "Client", "API", "to", "send", "a", "message" ]
train
https://github.com/quantifiedcode/checkmate/blob/1a4d010c8ef25c678d8d14dc8e37a9bed1883ca2/checkmate/contrib/plugins/python/pylint/analyzer.py#L99-L102
quantifiedcode/checkmate
checkmate/lib/analysis/base.py
BaseAnalyzer.get_fingerprint_from_code
def get_fingerprint_from_code(self,file_revision,location, extra_data=None): """ This function generates a fingerprint from a series of code snippets. Can be used by derived analyzers to generate fingerprints based on code if nothing better is available. """ code = file_...
python
def get_fingerprint_from_code(self,file_revision,location, extra_data=None): """ This function generates a fingerprint from a series of code snippets. Can be used by derived analyzers to generate fingerprints based on code if nothing better is available. """ code = file_...
[ "def", "get_fingerprint_from_code", "(", "self", ",", "file_revision", ",", "location", ",", "extra_data", "=", "None", ")", ":", "code", "=", "file_revision", ".", "get_file_content", "(", ")", "if", "not", "isinstance", "(", "code", ",", "unicode", ")", ":...
This function generates a fingerprint from a series of code snippets. Can be used by derived analyzers to generate fingerprints based on code if nothing better is available.
[ "This", "function", "generates", "a", "fingerprint", "from", "a", "series", "of", "code", "snippets", "." ]
train
https://github.com/quantifiedcode/checkmate/blob/1a4d010c8ef25c678d8d14dc8e37a9bed1883ca2/checkmate/lib/analysis/base.py#L34-L68
quantifiedcode/checkmate
checkmate/helpers/issue.py
group_issues_by_fingerprint
def group_issues_by_fingerprint(issues): """ Groups issues by fingerprint. Grouping is done by issue code in addition. IMPORTANT: It is assumed that all issues come from the SAME analyzer. """ issues_by_fingerprint = defaultdict(list) for issue in issues: if not 'fingerprint' in issue: ...
python
def group_issues_by_fingerprint(issues): """ Groups issues by fingerprint. Grouping is done by issue code in addition. IMPORTANT: It is assumed that all issues come from the SAME analyzer. """ issues_by_fingerprint = defaultdict(list) for issue in issues: if not 'fingerprint' in issue: ...
[ "def", "group_issues_by_fingerprint", "(", "issues", ")", ":", "issues_by_fingerprint", "=", "defaultdict", "(", "list", ")", "for", "issue", "in", "issues", ":", "if", "not", "'fingerprint'", "in", "issue", ":", "raise", "AttributeError", "(", "\"No fingerprint d...
Groups issues by fingerprint. Grouping is done by issue code in addition. IMPORTANT: It is assumed that all issues come from the SAME analyzer.
[ "Groups", "issues", "by", "fingerprint", ".", "Grouping", "is", "done", "by", "issue", "code", "in", "addition", ".", "IMPORTANT", ":", "It", "is", "assumed", "that", "all", "issues", "come", "from", "the", "SAME", "analyzer", "." ]
train
https://github.com/quantifiedcode/checkmate/blob/1a4d010c8ef25c678d8d14dc8e37a9bed1883ca2/checkmate/helpers/issue.py#L49-L98
quantifiedcode/checkmate
checkmate/lib/models.py
Project.get_issue_classes
def get_issue_classes(self,backend = None,enabled = True,sort = None,**kwargs): """ Retrieves the issue classes for a given backend :param backend: A backend to use. If None, the default backend will be used :param enabled: Whether to retrieve enabled or disabled issue classes. ...
python
def get_issue_classes(self,backend = None,enabled = True,sort = None,**kwargs): """ Retrieves the issue classes for a given backend :param backend: A backend to use. If None, the default backend will be used :param enabled: Whether to retrieve enabled or disabled issue classes. ...
[ "def", "get_issue_classes", "(", "self", ",", "backend", "=", "None", ",", "enabled", "=", "True", ",", "sort", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "backend", "is", "None", ":", "backend", "=", "self", ".", "backend", "query", "=", ...
Retrieves the issue classes for a given backend :param backend: A backend to use. If None, the default backend will be used :param enabled: Whether to retrieve enabled or disabled issue classes. Passing `None` will retrieve all issue classes.
[ "Retrieves", "the", "issue", "classes", "for", "a", "given", "backend" ]
train
https://github.com/quantifiedcode/checkmate/blob/1a4d010c8ef25c678d8d14dc8e37a9bed1883ca2/checkmate/lib/models.py#L413-L435
thombashi/pathvalidate
pathvalidate/_symbol.py
validate_symbol
def validate_symbol(text): """ Verifying whether symbol(s) included in the ``text`` or not. :param str text: Input text. :raises pathvalidate.InvalidCharError: If symbol(s) included in the ``text``. """ match_list = __RE_SYMBOL.findall(preprocess(text)) if match_list: raise...
python
def validate_symbol(text): """ Verifying whether symbol(s) included in the ``text`` or not. :param str text: Input text. :raises pathvalidate.InvalidCharError: If symbol(s) included in the ``text``. """ match_list = __RE_SYMBOL.findall(preprocess(text)) if match_list: raise...
[ "def", "validate_symbol", "(", "text", ")", ":", "match_list", "=", "__RE_SYMBOL", ".", "findall", "(", "preprocess", "(", "text", ")", ")", "if", "match_list", ":", "raise", "InvalidCharError", "(", "\"invalid symbols found: {}\"", ".", "format", "(", "match_li...
Verifying whether symbol(s) included in the ``text`` or not. :param str text: Input text. :raises pathvalidate.InvalidCharError: If symbol(s) included in the ``text``.
[ "Verifying", "whether", "symbol", "(", "s", ")", "included", "in", "the", "text", "or", "not", "." ]
train
https://github.com/thombashi/pathvalidate/blob/22d64038fb08c04aa9d0e8dd9fd1a955c1a9bfef/pathvalidate/_symbol.py#L36-L47
thombashi/pathvalidate
pathvalidate/_symbol.py
replace_symbol
def replace_symbol(text, replacement_text="", is_replace_consecutive_chars=False, is_strip=False): """ Replace all of the symbols in the ``text``. :param str text: Input text. :param str replacement_text: Replacement text. :return: A replacement string. :rtype: str :Examples: :ref...
python
def replace_symbol(text, replacement_text="", is_replace_consecutive_chars=False, is_strip=False): """ Replace all of the symbols in the ``text``. :param str text: Input text. :param str replacement_text: Replacement text. :return: A replacement string. :rtype: str :Examples: :ref...
[ "def", "replace_symbol", "(", "text", ",", "replacement_text", "=", "\"\"", ",", "is_replace_consecutive_chars", "=", "False", ",", "is_strip", "=", "False", ")", ":", "try", ":", "new_text", "=", "__RE_SYMBOL", ".", "sub", "(", "replacement_text", ",", "prepr...
Replace all of the symbols in the ``text``. :param str text: Input text. :param str replacement_text: Replacement text. :return: A replacement string. :rtype: str :Examples: :ref:`example-sanitize-symbol`
[ "Replace", "all", "of", "the", "symbols", "in", "the", "text", "." ]
train
https://github.com/thombashi/pathvalidate/blob/22d64038fb08c04aa9d0e8dd9fd1a955c1a9bfef/pathvalidate/_symbol.py#L50-L78
thombashi/pathvalidate
pathvalidate/_file.py
validate_filename
def validate_filename(filename, platform=None, min_len=1, max_len=_DEFAULT_MAX_FILENAME_LEN): """Verifying whether the ``filename`` is a valid file name or not. Args: filename (str): Filename to validate. platform (str, optional): .. include:: platform.txt min_le...
python
def validate_filename(filename, platform=None, min_len=1, max_len=_DEFAULT_MAX_FILENAME_LEN): """Verifying whether the ``filename`` is a valid file name or not. Args: filename (str): Filename to validate. platform (str, optional): .. include:: platform.txt min_le...
[ "def", "validate_filename", "(", "filename", ",", "platform", "=", "None", ",", "min_len", "=", "1", ",", "max_len", "=", "_DEFAULT_MAX_FILENAME_LEN", ")", ":", "FileNameSanitizer", "(", "platform", "=", "platform", ",", "min_len", "=", "min_len", ",", "max_le...
Verifying whether the ``filename`` is a valid file name or not. Args: filename (str): Filename to validate. platform (str, optional): .. include:: platform.txt min_len (int, optional): Minimum length of the ``filename``. The value must be greater or equal...
[ "Verifying", "whether", "the", "filename", "is", "a", "valid", "file", "name", "or", "not", "." ]
train
https://github.com/thombashi/pathvalidate/blob/22d64038fb08c04aa9d0e8dd9fd1a955c1a9bfef/pathvalidate/_file.py#L432-L474
thombashi/pathvalidate
pathvalidate/_file.py
validate_filepath
def validate_filepath(file_path, platform=None, min_len=1, max_len=None): """Verifying whether the ``file_path`` is a valid file path or not. Args: file_path (str): File path to validate. platform (str, optional): .. include:: platform.txt min_len (int, optional)...
python
def validate_filepath(file_path, platform=None, min_len=1, max_len=None): """Verifying whether the ``file_path`` is a valid file path or not. Args: file_path (str): File path to validate. platform (str, optional): .. include:: platform.txt min_len (int, optional)...
[ "def", "validate_filepath", "(", "file_path", ",", "platform", "=", "None", ",", "min_len", "=", "1", ",", "max_len", "=", "None", ")", ":", "FilePathSanitizer", "(", "platform", "=", "platform", ",", "min_len", "=", "min_len", ",", "max_len", "=", "max_le...
Verifying whether the ``file_path`` is a valid file path or not. Args: file_path (str): File path to validate. platform (str, optional): .. include:: platform.txt min_len (int, optional): Minimum length of the ``file_path``. The value must be greater or e...
[ "Verifying", "whether", "the", "file_path", "is", "a", "valid", "file", "path", "or", "not", "." ]
train
https://github.com/thombashi/pathvalidate/blob/22d64038fb08c04aa9d0e8dd9fd1a955c1a9bfef/pathvalidate/_file.py#L477-L515
thombashi/pathvalidate
pathvalidate/_file.py
sanitize_filename
def sanitize_filename( filename, replacement_text="", platform=None, max_len=_DEFAULT_MAX_FILENAME_LEN ): """Make a valid filename from a string. To make a valid filename the function does: - Replace invalid characters as file names included in the ``filename`` with the ``replacement_tex...
python
def sanitize_filename( filename, replacement_text="", platform=None, max_len=_DEFAULT_MAX_FILENAME_LEN ): """Make a valid filename from a string. To make a valid filename the function does: - Replace invalid characters as file names included in the ``filename`` with the ``replacement_tex...
[ "def", "sanitize_filename", "(", "filename", ",", "replacement_text", "=", "\"\"", ",", "platform", "=", "None", ",", "max_len", "=", "_DEFAULT_MAX_FILENAME_LEN", ")", ":", "return", "FileNameSanitizer", "(", "platform", "=", "platform", ",", "max_len", "=", "ma...
Make a valid filename from a string. To make a valid filename the function does: - Replace invalid characters as file names included in the ``filename`` with the ``replacement_text``. Invalid characters are: - unprintable characters - |invalid_filename_chars| ...
[ "Make", "a", "valid", "filename", "from", "a", "string", "." ]
train
https://github.com/thombashi/pathvalidate/blob/22d64038fb08c04aa9d0e8dd9fd1a955c1a9bfef/pathvalidate/_file.py#L533-L575
thombashi/pathvalidate
pathvalidate/_file.py
sanitize_filepath
def sanitize_filepath(file_path, replacement_text="", platform=None, max_len=None): """Make a valid file path from a string. Replace invalid characters for a file path within the ``file_path`` with the ``replacement_text``. Invalid characters are as followings: |invalid_file_path_chars|, |invalid_w...
python
def sanitize_filepath(file_path, replacement_text="", platform=None, max_len=None): """Make a valid file path from a string. Replace invalid characters for a file path within the ``file_path`` with the ``replacement_text``. Invalid characters are as followings: |invalid_file_path_chars|, |invalid_w...
[ "def", "sanitize_filepath", "(", "file_path", ",", "replacement_text", "=", "\"\"", ",", "platform", "=", "None", ",", "max_len", "=", "None", ")", ":", "return", "FilePathSanitizer", "(", "platform", "=", "platform", ",", "max_len", "=", "max_len", ")", "."...
Make a valid file path from a string. Replace invalid characters for a file path within the ``file_path`` with the ``replacement_text``. Invalid characters are as followings: |invalid_file_path_chars|, |invalid_win_file_path_chars| (and non printable characters). Args: file_path (str or Pa...
[ "Make", "a", "valid", "file", "path", "from", "a", "string", "." ]
train
https://github.com/thombashi/pathvalidate/blob/22d64038fb08c04aa9d0e8dd9fd1a955c1a9bfef/pathvalidate/_file.py#L578-L617
thombashi/pathvalidate
pathvalidate/_ltsv.py
validate_ltsv_label
def validate_ltsv_label(label): """ Verifying whether ``label`` is a valid `Labeled Tab-separated Values (LTSV) <http://ltsv.org/>`__ label or not. :param str label: Label to validate. :raises pathvalidate.NullNameError: If the ``label`` is empty. :raises pathvalidate.InvalidCharError: ...
python
def validate_ltsv_label(label): """ Verifying whether ``label`` is a valid `Labeled Tab-separated Values (LTSV) <http://ltsv.org/>`__ label or not. :param str label: Label to validate. :raises pathvalidate.NullNameError: If the ``label`` is empty. :raises pathvalidate.InvalidCharError: ...
[ "def", "validate_ltsv_label", "(", "label", ")", ":", "validate_null_string", "(", "label", ",", "error_msg", "=", "\"label is empty\"", ")", "match_list", "=", "__RE_INVALID_LTSV_LABEL", ".", "findall", "(", "preprocess", "(", "label", ")", ")", "if", "match_list...
Verifying whether ``label`` is a valid `Labeled Tab-separated Values (LTSV) <http://ltsv.org/>`__ label or not. :param str label: Label to validate. :raises pathvalidate.NullNameError: If the ``label`` is empty. :raises pathvalidate.InvalidCharError: If invalid character(s) found in the ``label...
[ "Verifying", "whether", "label", "is", "a", "valid", "Labeled", "Tab", "-", "separated", "Values", "(", "LTSV", ")", "<http", ":", "//", "ltsv", ".", "org", "/", ">", "__", "label", "or", "not", "." ]
train
https://github.com/thombashi/pathvalidate/blob/22d64038fb08c04aa9d0e8dd9fd1a955c1a9bfef/pathvalidate/_ltsv.py#L18-L35
thombashi/pathvalidate
pathvalidate/_ltsv.py
sanitize_ltsv_label
def sanitize_ltsv_label(label, replacement_text=""): """ Replace all of the symbols in text. :param str label: Input text. :param str replacement_text: Replacement text. :return: A replacement string. :rtype: str """ validate_null_string(label, error_msg="label is empty") return _...
python
def sanitize_ltsv_label(label, replacement_text=""): """ Replace all of the symbols in text. :param str label: Input text. :param str replacement_text: Replacement text. :return: A replacement string. :rtype: str """ validate_null_string(label, error_msg="label is empty") return _...
[ "def", "sanitize_ltsv_label", "(", "label", ",", "replacement_text", "=", "\"\"", ")", ":", "validate_null_string", "(", "label", ",", "error_msg", "=", "\"label is empty\"", ")", "return", "__RE_INVALID_LTSV_LABEL", ".", "sub", "(", "replacement_text", ",", "prepro...
Replace all of the symbols in text. :param str label: Input text. :param str replacement_text: Replacement text. :return: A replacement string. :rtype: str
[ "Replace", "all", "of", "the", "symbols", "in", "text", "." ]
train
https://github.com/thombashi/pathvalidate/blob/22d64038fb08c04aa9d0e8dd9fd1a955c1a9bfef/pathvalidate/_ltsv.py#L38-L50
labtocat/beautifier
beautifier/__init__.py
Url.param
def param(self): """ Returns params """ try: self.parameters = self._main_url.split('?')[1] return self.parameters.split('&') except: return self.parameters
python
def param(self): """ Returns params """ try: self.parameters = self._main_url.split('?')[1] return self.parameters.split('&') except: return self.parameters
[ "def", "param", "(", "self", ")", ":", "try", ":", "self", ".", "parameters", "=", "self", ".", "_main_url", ".", "split", "(", "'?'", ")", "[", "1", "]", "return", "self", ".", "parameters", ".", "split", "(", "'&'", ")", "except", ":", "return", ...
Returns params
[ "Returns", "params" ]
train
https://github.com/labtocat/beautifier/blob/5827edc2d6dc057e5f1f57596037fc94201ca8e7/beautifier/__init__.py#L40-L48
labtocat/beautifier
beautifier/__init__.py
Url.domain
def domain(self): """ Return domain from the url """ remove_pac = self.cleanup.replace( "https://", "").replace("http://", "").replace("www.", "") try: return remove_pac.split('/')[0] except: return None
python
def domain(self): """ Return domain from the url """ remove_pac = self.cleanup.replace( "https://", "").replace("http://", "").replace("www.", "") try: return remove_pac.split('/')[0] except: return None
[ "def", "domain", "(", "self", ")", ":", "remove_pac", "=", "self", ".", "cleanup", ".", "replace", "(", "\"https://\"", ",", "\"\"", ")", ".", "replace", "(", "\"http://\"", ",", "\"\"", ")", ".", "replace", "(", "\"www.\"", ",", "\"\"", ")", "try", ...
Return domain from the url
[ "Return", "domain", "from", "the", "url" ]
train
https://github.com/labtocat/beautifier/blob/5827edc2d6dc057e5f1f57596037fc94201ca8e7/beautifier/__init__.py#L58-L67
ccubed/PyMoe
Pymoe/Mal/Objects.py
Anime.to_xml
def to_xml(self): """ Convert data to XML String. :return: Str of valid XML data """ root = ET.Element("entry") for x in self.xml_tags: if getattr(self, x): if x in ['episodes', 'scores', 'status', 'dates', 'storage', 'rewatched', 'flags', 'tag...
python
def to_xml(self): """ Convert data to XML String. :return: Str of valid XML data """ root = ET.Element("entry") for x in self.xml_tags: if getattr(self, x): if x in ['episodes', 'scores', 'status', 'dates', 'storage', 'rewatched', 'flags', 'tag...
[ "def", "to_xml", "(", "self", ")", ":", "root", "=", "ET", ".", "Element", "(", "\"entry\"", ")", "for", "x", "in", "self", ".", "xml_tags", ":", "if", "getattr", "(", "self", ",", "x", ")", ":", "if", "x", "in", "[", "'episodes'", ",", "'scores'...
Convert data to XML String. :return: Str of valid XML data
[ "Convert", "data", "to", "XML", "String", ".", ":", "return", ":", "Str", "of", "valid", "XML", "data" ]
train
https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/Mal/Objects.py#L76-L132
ccubed/PyMoe
Pymoe/Kitsu/user.py
KitsuUser.search
def search(self, term): """ Search for a user by name. :param str term: What to search for. :return: The results as a SearchWrapper iterator or None if no results. :rtype: SearchWrapper or None """ r = requests.get(self.apiurl + "/users", params={"filter[name]": ...
python
def search(self, term): """ Search for a user by name. :param str term: What to search for. :return: The results as a SearchWrapper iterator or None if no results. :rtype: SearchWrapper or None """ r = requests.get(self.apiurl + "/users", params={"filter[name]": ...
[ "def", "search", "(", "self", ",", "term", ")", ":", "r", "=", "requests", ".", "get", "(", "self", ".", "apiurl", "+", "\"/users\"", ",", "params", "=", "{", "\"filter[name]\"", ":", "term", "}", ",", "headers", "=", "self", ".", "header", ")", "i...
Search for a user by name. :param str term: What to search for. :return: The results as a SearchWrapper iterator or None if no results. :rtype: SearchWrapper or None
[ "Search", "for", "a", "user", "by", "name", "." ]
train
https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/Kitsu/user.py#L11-L29
ccubed/PyMoe
Pymoe/Kitsu/user.py
KitsuUser.create
def create(self, data): """ Create a user. Please review the attributes required. You need only provide the attributes. :param data: A dictionary of the required attributes :return: Dictionary returned by server or a ServerError exception :rtype: Dictionary or Exception ...
python
def create(self, data): """ Create a user. Please review the attributes required. You need only provide the attributes. :param data: A dictionary of the required attributes :return: Dictionary returned by server or a ServerError exception :rtype: Dictionary or Exception ...
[ "def", "create", "(", "self", ",", "data", ")", ":", "final_dict", "=", "{", "\"data\"", ":", "{", "\"type\"", ":", "\"users\"", ",", "\"attributes\"", ":", "data", "}", "}", "r", "=", "requests", ".", "post", "(", "self", ".", "apiurl", "+", "\"/use...
Create a user. Please review the attributes required. You need only provide the attributes. :param data: A dictionary of the required attributes :return: Dictionary returned by server or a ServerError exception :rtype: Dictionary or Exception
[ "Create", "a", "user", ".", "Please", "review", "the", "attributes", "required", ".", "You", "need", "only", "provide", "the", "attributes", "." ]
train
https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/Kitsu/user.py#L31-L45
ccubed/PyMoe
Pymoe/Kitsu/user.py
KitsuUser.get
def get(self, uid): """ Get a user's information by their id. :param uid str: User ID :return: The user's information or None :rtype: Dictionary or None """ r = requests.get(self.apiurl + "/users/{}".format(uid), headers=self.header) if r.status_code != ...
python
def get(self, uid): """ Get a user's information by their id. :param uid str: User ID :return: The user's information or None :rtype: Dictionary or None """ r = requests.get(self.apiurl + "/users/{}".format(uid), headers=self.header) if r.status_code != ...
[ "def", "get", "(", "self", ",", "uid", ")", ":", "r", "=", "requests", ".", "get", "(", "self", ".", "apiurl", "+", "\"/users/{}\"", ".", "format", "(", "uid", ")", ",", "headers", "=", "self", ".", "header", ")", "if", "r", ".", "status_code", "...
Get a user's information by their id. :param uid str: User ID :return: The user's information or None :rtype: Dictionary or None
[ "Get", "a", "user", "s", "information", "by", "their", "id", "." ]
train
https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/Kitsu/user.py#L47-L65
ccubed/PyMoe
Pymoe/Kitsu/user.py
KitsuUser.update
def update(self, uid, data, token): """ Update a user's data. Requires an auth token. :param uid str: User ID to update :param data dict: The dictionary of data attributes to change. Just the attributes. :param token str: The authorization token for this user :return: Tr...
python
def update(self, uid, data, token): """ Update a user's data. Requires an auth token. :param uid str: User ID to update :param data dict: The dictionary of data attributes to change. Just the attributes. :param token str: The authorization token for this user :return: Tr...
[ "def", "update", "(", "self", ",", "uid", ",", "data", ",", "token", ")", ":", "final_dict", "=", "{", "\"data\"", ":", "{", "\"id\"", ":", "uid", ",", "\"type\"", ":", "\"users\"", ",", "\"attributes\"", ":", "data", "}", "}", "final_headers", "=", ...
Update a user's data. Requires an auth token. :param uid str: User ID to update :param data dict: The dictionary of data attributes to change. Just the attributes. :param token str: The authorization token for this user :return: True or Exception :rtype: Bool or ServerError
[ "Update", "a", "user", "s", "data", ".", "Requires", "an", "auth", "token", "." ]
train
https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/Kitsu/user.py#L67-L85
ccubed/PyMoe
Pymoe/Anilist/search.py
ASearch.character
def character(self, term, page = 1, perpage = 3): """ Search for a character by term. Results are paginated by default. Page specifies which page we're on. Perpage specifies how many per page to request. 3 is just the example from the API docs. :param term str: Name to s...
python
def character(self, term, page = 1, perpage = 3): """ Search for a character by term. Results are paginated by default. Page specifies which page we're on. Perpage specifies how many per page to request. 3 is just the example from the API docs. :param term str: Name to s...
[ "def", "character", "(", "self", ",", "term", ",", "page", "=", "1", ",", "perpage", "=", "3", ")", ":", "query_string", "=", "\"\"\"\\\n query ($query: String, $page: Int, $perpage: Int) {\n Page (page: $page, perPage: $perpage) {\n p...
Search for a character by term. Results are paginated by default. Page specifies which page we're on. Perpage specifies how many per page to request. 3 is just the example from the API docs. :param term str: Name to search by :param page int: Which page are we requesting? Starts...
[ "Search", "for", "a", "character", "by", "term", ".", "Results", "are", "paginated", "by", "default", ".", "Page", "specifies", "which", "page", "we", "re", "on", ".", "Perpage", "specifies", "how", "many", "per", "page", "to", "request", ".", "3", "is",...
train
https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/Anilist/search.py#L9-L54
ccubed/PyMoe
Pymoe/Anidb/aid.py
Aid.search
def search(term, lang=None): """ As a convenient alternative to downloading and parsing a dump, This function will instead query the AID search provided by Eloyard. This is the same information available at http://anisearch.outrance.pl/. :param str term: Search Term :par...
python
def search(term, lang=None): """ As a convenient alternative to downloading and parsing a dump, This function will instead query the AID search provided by Eloyard. This is the same information available at http://anisearch.outrance.pl/. :param str term: Search Term :par...
[ "def", "search", "(", "term", ",", "lang", "=", "None", ")", ":", "r", "=", "requests", ".", "get", "(", "\"http://anisearch.outrance.pl/index.php\"", ",", "params", "=", "{", "\"task\"", ":", "\"search\"", ",", "\"query\"", ":", "term", ",", "\"langs\"", ...
As a convenient alternative to downloading and parsing a dump, This function will instead query the AID search provided by Eloyard. This is the same information available at http://anisearch.outrance.pl/. :param str term: Search Term :param list lang: A list of language codes which dete...
[ "As", "a", "convenient", "alternative", "to", "downloading", "and", "parsing", "a", "dump", "This", "function", "will", "instead", "query", "the", "AID", "search", "provided", "by", "Eloyard", ".", "This", "is", "the", "same", "information", "available", "at",...
train
https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/Anidb/aid.py#L9-L41
ccubed/PyMoe
Pymoe/VNDB/__init__.py
VNDB.get
def get(self, stype, flags, filters, options=None): """ Send a request to the API to return results related to Visual Novels. :param str stype: What are we searching for? One of: vn, release, producer, character, votelist, vnlist, wishlist :param flags: See the D11 docs. A comma separat...
python
def get(self, stype, flags, filters, options=None): """ Send a request to the API to return results related to Visual Novels. :param str stype: What are we searching for? One of: vn, release, producer, character, votelist, vnlist, wishlist :param flags: See the D11 docs. A comma separat...
[ "def", "get", "(", "self", ",", "stype", ",", "flags", ",", "filters", ",", "options", "=", "None", ")", ":", "if", "not", "isinstance", "(", "flags", ",", "str", ")", ":", "if", "isinstance", "(", "flags", ",", "list", ")", ":", "finflags", "=", ...
Send a request to the API to return results related to Visual Novels. :param str stype: What are we searching for? One of: vn, release, producer, character, votelist, vnlist, wishlist :param flags: See the D11 docs. A comma separated list of flags for what data to return. Can be list or str. :p...
[ "Send", "a", "request", "to", "the", "API", "to", "return", "results", "related", "to", "Visual", "Novels", "." ]
train
https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/VNDB/__init__.py#L34-L80
ccubed/PyMoe
Pymoe/VNDB/__init__.py
VNDB.set
def set(self, stype, sid, fields): """ Send a request to the API to modify something in the database if logged in. :param str stype: What are we modifying? One of: votelist, vnlist, wishlist :param int sid: The ID that we're modifying. :param dict fields: A dictionary of the fie...
python
def set(self, stype, sid, fields): """ Send a request to the API to modify something in the database if logged in. :param str stype: What are we modifying? One of: votelist, vnlist, wishlist :param int sid: The ID that we're modifying. :param dict fields: A dictionary of the fie...
[ "def", "set", "(", "self", ",", "stype", ",", "sid", ",", "fields", ")", ":", "if", "stype", "not", "in", "[", "'votelist'", ",", "'vnlist'", ",", "'wishlist'", "]", ":", "raise", "SyntaxError", "(", "\"{} is not a valid type for set. Should be one of: votelist,...
Send a request to the API to modify something in the database if logged in. :param str stype: What are we modifying? One of: votelist, vnlist, wishlist :param int sid: The ID that we're modifying. :param dict fields: A dictionary of the fields and their values :raises ServerError: Raise...
[ "Send", "a", "request", "to", "the", "API", "to", "modify", "something", "in", "the", "database", "if", "logged", "in", "." ]
train
https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/VNDB/__init__.py#L82-L101
ccubed/PyMoe
Pymoe/Anilist/get.py
AGet.anime
def anime(self, item_id): """ The function to retrieve an anime's details. :param int item_id: the anime's ID :return: dict or None :rtype: dict or NoneType """ query_string = """\ query ($id: Int) { Media(id: $id, type: ANIME) { ...
python
def anime(self, item_id): """ The function to retrieve an anime's details. :param int item_id: the anime's ID :return: dict or None :rtype: dict or NoneType """ query_string = """\ query ($id: Int) { Media(id: $id, type: ANIME) { ...
[ "def", "anime", "(", "self", ",", "item_id", ")", ":", "query_string", "=", "\"\"\"\\\n query ($id: Int) {\n Media(id: $id, type: ANIME) {\n title {\n romaji\n english\n }\n ...
The function to retrieve an anime's details. :param int item_id: the anime's ID :return: dict or None :rtype: dict or NoneType
[ "The", "function", "to", "retrieve", "an", "anime", "s", "details", "." ]
train
https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/Anilist/get.py#L8-L65
ccubed/PyMoe
Pymoe/Anilist/get.py
AGet.review
def review(self, item_id, html = True): """ With the change to v2 of the api, reviews have their own IDs. This accepts the ID of the review. You can set html to False if you want the review body returned without html formatting. The API Default is true. :param item_id: the Id of...
python
def review(self, item_id, html = True): """ With the change to v2 of the api, reviews have their own IDs. This accepts the ID of the review. You can set html to False if you want the review body returned without html formatting. The API Default is true. :param item_id: the Id of...
[ "def", "review", "(", "self", ",", "item_id", ",", "html", "=", "True", ")", ":", "query_string", "=", "\"\"\"\\\n query ($id: Int, $html: Boolean) {\n Review (id: $id) {\n summary\n body(asHtml: $html)\n ...
With the change to v2 of the api, reviews have their own IDs. This accepts the ID of the review. You can set html to False if you want the review body returned without html formatting. The API Default is true. :param item_id: the Id of the review :param html: do you want the body return...
[ "With", "the", "change", "to", "v2", "of", "the", "api", "reviews", "have", "their", "own", "IDs", ".", "This", "accepts", "the", "ID", "of", "the", "review", ".", "You", "can", "set", "html", "to", "False", "if", "you", "want", "the", "review", "bod...
train
https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/Anilist/get.py#L219-L265
ccubed/PyMoe
Pymoe/Kitsu/mappings.py
KitsuMappings.get
def get(self, external_site: str, external_id: int): """ Get a kitsu mapping by external site ID :param str external_site: string representing the external site :param int external_id: ID of the entry in the external site. :return: Dictionary or None (for not found) :rty...
python
def get(self, external_site: str, external_id: int): """ Get a kitsu mapping by external site ID :param str external_site: string representing the external site :param int external_id: ID of the entry in the external site. :return: Dictionary or None (for not found) :rty...
[ "def", "get", "(", "self", ",", "external_site", ":", "str", ",", "external_id", ":", "int", ")", ":", "r", "=", "requests", ".", "get", "(", "self", ".", "apiurl", "+", "\"/mappings\"", ",", "params", "=", "{", "\"filter[externalSite]\"", ":", "external...
Get a kitsu mapping by external site ID :param str external_site: string representing the external site :param int external_id: ID of the entry in the external site. :return: Dictionary or None (for not found) :rtype: Dictionary or None :raises: :class:`Pymoe.errors.ServerError`
[ "Get", "a", "kitsu", "mapping", "by", "external", "site", "ID" ]
train
https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/Kitsu/mappings.py#L11-L36
ccubed/PyMoe
Pymoe/Kitsu/auth.py
KitsuAuth.authenticate
def authenticate(self, username, password): """ Obtain an oauth token. Pass username and password. Get a token back. If KitsuAuth is set to remember your tokens for this session, it will store the token under the username given. :param username: username :param password: passwor...
python
def authenticate(self, username, password): """ Obtain an oauth token. Pass username and password. Get a token back. If KitsuAuth is set to remember your tokens for this session, it will store the token under the username given. :param username: username :param password: passwor...
[ "def", "authenticate", "(", "self", ",", "username", ",", "password", ")", ":", "r", "=", "requests", ".", "post", "(", "self", ".", "apiurl", "+", "\"/token\"", ",", "params", "=", "{", "\"grant_type\"", ":", "\"password\"", ",", "\"username\"", ":", "u...
Obtain an oauth token. Pass username and password. Get a token back. If KitsuAuth is set to remember your tokens for this session, it will store the token under the username given. :param username: username :param password: password :param alias: A list of alternative names for a person...
[ "Obtain", "an", "oauth", "token", ".", "Pass", "username", "and", "password", ".", "Get", "a", "token", "back", ".", "If", "KitsuAuth", "is", "set", "to", "remember", "your", "tokens", "for", "this", "session", "it", "will", "store", "the", "token", "und...
train
https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/Kitsu/auth.py#L25-L48
ccubed/PyMoe
Pymoe/Kitsu/auth.py
KitsuAuth.refresh
def refresh(self, refresh_token): """ Renew an oauth token given an appropriate refresh token. :param refresh_token: The Refresh Token :return: A tuple of (token, expiration time in unix time stamp) """ r = requests.post(self.apiurl + "/token", params={"grant_type": "ref...
python
def refresh(self, refresh_token): """ Renew an oauth token given an appropriate refresh token. :param refresh_token: The Refresh Token :return: A tuple of (token, expiration time in unix time stamp) """ r = requests.post(self.apiurl + "/token", params={"grant_type": "ref...
[ "def", "refresh", "(", "self", ",", "refresh_token", ")", ":", "r", "=", "requests", ".", "post", "(", "self", ".", "apiurl", "+", "\"/token\"", ",", "params", "=", "{", "\"grant_type\"", ":", "\"refresh_token\"", ",", "\"client_id\"", ":", "self", ".", ...
Renew an oauth token given an appropriate refresh token. :param refresh_token: The Refresh Token :return: A tuple of (token, expiration time in unix time stamp)
[ "Renew", "an", "oauth", "token", "given", "an", "appropriate", "refresh", "token", "." ]
train
https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/Kitsu/auth.py#L50-L66
ccubed/PyMoe
Pymoe/Kitsu/auth.py
KitsuAuth.get
def get(self, username): """ If using the remember option and KitsuAuth is storing your tokens, this function will retrieve one. :param username: The username whose token we are retrieving :return: A token, NotFound or NotSaving error """ if not self.remember: ...
python
def get(self, username): """ If using the remember option and KitsuAuth is storing your tokens, this function will retrieve one. :param username: The username whose token we are retrieving :return: A token, NotFound or NotSaving error """ if not self.remember: ...
[ "def", "get", "(", "self", ",", "username", ")", ":", "if", "not", "self", ".", "remember", ":", "raise", "NotSaving", "if", "username", "not", "in", "self", ".", "token_storage", ":", "raise", "UserNotFound", "if", "self", ".", "token_storage", "[", "us...
If using the remember option and KitsuAuth is storing your tokens, this function will retrieve one. :param username: The username whose token we are retrieving :return: A token, NotFound or NotSaving error
[ "If", "using", "the", "remember", "option", "and", "KitsuAuth", "is", "storing", "your", "tokens", "this", "function", "will", "retrieve", "one", "." ]
train
https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/Kitsu/auth.py#L69-L88
ccubed/PyMoe
Pymoe/Anidb/dump.py
save
def save(url, destination): """ This is just the thread target. It's actually responsible for downloading and saving. :param str url: which dump to download :param str destination: a file path to save to """ r = requests.get(url, stream=True) with open(destination, 'wb') as fd: ...
python
def save(url, destination): """ This is just the thread target. It's actually responsible for downloading and saving. :param str url: which dump to download :param str destination: a file path to save to """ r = requests.get(url, stream=True) with open(destination, 'wb') as fd: ...
[ "def", "save", "(", "url", ",", "destination", ")", ":", "r", "=", "requests", ".", "get", "(", "url", ",", "stream", "=", "True", ")", "with", "open", "(", "destination", ",", "'wb'", ")", "as", "fd", ":", "for", "chunk", "in", "r", ".", "iter_c...
This is just the thread target. It's actually responsible for downloading and saving. :param str url: which dump to download :param str destination: a file path to save to
[ "This", "is", "just", "the", "thread", "target", ".", "It", "s", "actually", "responsible", "for", "downloading", "and", "saving", "." ]
train
https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/Anidb/dump.py#L40-L52
ccubed/PyMoe
Pymoe/Anidb/dump.py
Dump.download
def download(which, destination=None): """ I realize that the download for the dumps is going to take awhile. Given that, I've decided to approach this using threads. When you call this method, it will launch a thread to download the data. By default, the dump is dropped into the...
python
def download(which, destination=None): """ I realize that the download for the dumps is going to take awhile. Given that, I've decided to approach this using threads. When you call this method, it will launch a thread to download the data. By default, the dump is dropped into the...
[ "def", "download", "(", "which", ",", "destination", "=", "None", ")", ":", "if", "destination", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "destination", ")", ":", "os", ".", "makedirs", "(", "destination", ")", "pthread", "=", "threadin...
I realize that the download for the dumps is going to take awhile. Given that, I've decided to approach this using threads. When you call this method, it will launch a thread to download the data. By default, the dump is dropped into the current working directory. If the directory given ...
[ "I", "realize", "that", "the", "download", "for", "the", "dumps", "is", "going", "to", "take", "awhile", ".", "Given", "that", "I", "ve", "decided", "to", "approach", "this", "using", "threads", ".", "When", "you", "call", "this", "method", "it", "will",...
train
https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/Anidb/dump.py#L13-L37
ccubed/PyMoe
Pymoe/Kitsu/manga.py
KitsuManga.get
def get(self, aid): """ Get manga information by id. :param int aid: ID of the manga. :return: Dictionary or None (for not found) :rtype: Dictionary or None :raises: :class:`Pymoe.errors.ServerError` """ r = requests.get(self.apiurl + "/manga/{}".format(a...
python
def get(self, aid): """ Get manga information by id. :param int aid: ID of the manga. :return: Dictionary or None (for not found) :rtype: Dictionary or None :raises: :class:`Pymoe.errors.ServerError` """ r = requests.get(self.apiurl + "/manga/{}".format(a...
[ "def", "get", "(", "self", ",", "aid", ")", ":", "r", "=", "requests", ".", "get", "(", "self", ".", "apiurl", "+", "\"/manga/{}\"", ".", "format", "(", "aid", ")", ",", "headers", "=", "self", ".", "header", ")", "if", "r", ".", "status_code", "...
Get manga information by id. :param int aid: ID of the manga. :return: Dictionary or None (for not found) :rtype: Dictionary or None :raises: :class:`Pymoe.errors.ServerError`
[ "Get", "manga", "information", "by", "id", "." ]
train
https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/Kitsu/manga.py#L11-L28
ccubed/PyMoe
Pymoe/Bakatsuki/__init__.py
Bakatsuki.active
def active(self): """ Get a list of active projects. :return list: A list of tuples containing a title and pageid in that order. """ projects = [] r = requests.get(self.api, params={'action': 'query', 'list': 'categorymembers', 'cmpageid': self.a...
python
def active(self): """ Get a list of active projects. :return list: A list of tuples containing a title and pageid in that order. """ projects = [] r = requests.get(self.api, params={'action': 'query', 'list': 'categorymembers', 'cmpageid': self.a...
[ "def", "active", "(", "self", ")", ":", "projects", "=", "[", "]", "r", "=", "requests", ".", "get", "(", "self", ".", "api", ",", "params", "=", "{", "'action'", ":", "'query'", ",", "'list'", ":", "'categorymembers'", ",", "'cmpageid'", ":", "self"...
Get a list of active projects. :return list: A list of tuples containing a title and pageid in that order.
[ "Get", "a", "list", "of", "active", "projects", "." ]
train
https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/Bakatsuki/__init__.py#L26-L55
ccubed/PyMoe
Pymoe/Bakatsuki/__init__.py
Bakatsuki.light_novels
def light_novels(self, language="English"): """ Get a list of light novels under a certain language. :param str language: Defaults to English. Replace with whatever language you want to query. :return list: A list of tuples containing a title and pageid element in that order. ""...
python
def light_novels(self, language="English"): """ Get a list of light novels under a certain language. :param str language: Defaults to English. Replace with whatever language you want to query. :return list: A list of tuples containing a title and pageid element in that order. ""...
[ "def", "light_novels", "(", "self", ",", "language", "=", "\"English\"", ")", ":", "projects", "=", "[", "]", "r", "=", "requests", ".", "get", "(", "self", ".", "api", ",", "params", "=", "{", "'action'", ":", "'query'", ",", "'list'", ":", "'catego...
Get a list of light novels under a certain language. :param str language: Defaults to English. Replace with whatever language you want to query. :return list: A list of tuples containing a title and pageid element in that order.
[ "Get", "a", "list", "of", "light", "novels", "under", "a", "certain", "language", "." ]
train
https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/Bakatsuki/__init__.py#L57-L89
ccubed/PyMoe
Pymoe/Bakatsuki/__init__.py
Bakatsuki.chapters
def chapters(self, title): """ Get a list of chapters for a visual novel. Keep in mind, this can be slow. I've certainly tried to make it as fast as possible, but it's still pulling text out of a webpage. :param str title: The title of the novel you want chapters from :return OrderedDic...
python
def chapters(self, title): """ Get a list of chapters for a visual novel. Keep in mind, this can be slow. I've certainly tried to make it as fast as possible, but it's still pulling text out of a webpage. :param str title: The title of the novel you want chapters from :return OrderedDic...
[ "def", "chapters", "(", "self", ",", "title", ")", ":", "r", "=", "requests", ".", "get", "(", "\"https://www.baka-tsuki.org/project/index.php?title={}\"", ".", "format", "(", "title", ".", "replace", "(", "\" \"", ",", "\"_\"", ")", ")", ",", "headers", "="...
Get a list of chapters for a visual novel. Keep in mind, this can be slow. I've certainly tried to make it as fast as possible, but it's still pulling text out of a webpage. :param str title: The title of the novel you want chapters from :return OrderedDict: An OrderedDict which contains the chapters f...
[ "Get", "a", "list", "of", "chapters", "for", "a", "visual", "novel", ".", "Keep", "in", "mind", "this", "can", "be", "slow", ".", "I", "ve", "certainly", "tried", "to", "make", "it", "as", "fast", "as", "possible", "but", "it", "s", "still", "pulling...
train
https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/Bakatsuki/__init__.py#L159-L195
ccubed/PyMoe
Pymoe/Bakatsuki/__init__.py
Bakatsuki.cover
def cover(self, pageid): """ Get a cover image given a page id. :param str pageid: The pageid for the light novel you want a cover image for :return str: the image url """ r = requests.get(self.api, params={'action': 'query', 'prop': 'pageimages'...
python
def cover(self, pageid): """ Get a cover image given a page id. :param str pageid: The pageid for the light novel you want a cover image for :return str: the image url """ r = requests.get(self.api, params={'action': 'query', 'prop': 'pageimages'...
[ "def", "cover", "(", "self", ",", "pageid", ")", ":", "r", "=", "requests", ".", "get", "(", "self", ".", "api", ",", "params", "=", "{", "'action'", ":", "'query'", ",", "'prop'", ":", "'pageimages'", ",", "'pageids'", ":", "pageid", ",", "'format'"...
Get a cover image given a page id. :param str pageid: The pageid for the light novel you want a cover image for :return str: the image url
[ "Get", "a", "cover", "image", "given", "a", "page", "id", "." ]
train
https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/Bakatsuki/__init__.py#L197-L214
ccubed/PyMoe
Pymoe/Bakatsuki/__init__.py
Bakatsuki.get_text
def get_text(self, title): """ This will grab the html content of the chapter given by url. Technically you can use this to get the content of other pages too. :param title: Title for the page you want the content of :return: a string containing the html content """ r = ...
python
def get_text(self, title): """ This will grab the html content of the chapter given by url. Technically you can use this to get the content of other pages too. :param title: Title for the page you want the content of :return: a string containing the html content """ r = ...
[ "def", "get_text", "(", "self", ",", "title", ")", ":", "r", "=", "requests", ".", "get", "(", "self", ".", "api", ",", "params", "=", "{", "'action'", ":", "'parse'", ",", "'page'", ":", "title", ",", "'format'", ":", "'json'", "}", ",", "headers"...
This will grab the html content of the chapter given by url. Technically you can use this to get the content of other pages too. :param title: Title for the page you want the content of :return: a string containing the html content
[ "This", "will", "grab", "the", "html", "content", "of", "the", "chapter", "given", "by", "url", ".", "Technically", "you", "can", "use", "this", "to", "get", "the", "content", "of", "other", "pages", "too", "." ]
train
https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/Bakatsuki/__init__.py#L216-L227
ccubed/PyMoe
Pymoe/Mal/__init__.py
Mal._verify_credentials
def _verify_credentials(self): """ An internal method that verifies the credentials given at instantiation. :raises: :class:`Pymoe.errors.UserLoginFailed` """ r = requests.get(self.apiurl + "account/verify_credentials.xml", auth=HTTPBasicAuth(self._usern...
python
def _verify_credentials(self): """ An internal method that verifies the credentials given at instantiation. :raises: :class:`Pymoe.errors.UserLoginFailed` """ r = requests.get(self.apiurl + "account/verify_credentials.xml", auth=HTTPBasicAuth(self._usern...
[ "def", "_verify_credentials", "(", "self", ")", ":", "r", "=", "requests", ".", "get", "(", "self", ".", "apiurl", "+", "\"account/verify_credentials.xml\"", ",", "auth", "=", "HTTPBasicAuth", "(", "self", ".", "_username", ",", "self", ".", "_password", ")"...
An internal method that verifies the credentials given at instantiation. :raises: :class:`Pymoe.errors.UserLoginFailed`
[ "An", "internal", "method", "that", "verifies", "the", "credentials", "given", "at", "instantiation", "." ]
train
https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/Mal/__init__.py#L37-L47
ccubed/PyMoe
Pymoe/Mal/__init__.py
Mal._search
def _search(self, which, term): """ The real search method. :param which: 1 for anime, 2 for manga :param term: What to search for :rtype: list :return: list of :class:`Pymoe.Mal.Objects.Manga` or :class:`Pymoe.Mal.Objects.Anime` objects as per the type param. ""...
python
def _search(self, which, term): """ The real search method. :param which: 1 for anime, 2 for manga :param term: What to search for :rtype: list :return: list of :class:`Pymoe.Mal.Objects.Manga` or :class:`Pymoe.Mal.Objects.Anime` objects as per the type param. ""...
[ "def", "_search", "(", "self", ",", "which", ",", "term", ")", ":", "url", "=", "self", ".", "apiurl", "+", "\"{}/search.xml\"", ".", "format", "(", "'anime'", "if", "which", "==", "1", "else", "'manga'", ")", "r", "=", "requests", ".", "get", "(", ...
The real search method. :param which: 1 for anime, 2 for manga :param term: What to search for :rtype: list :return: list of :class:`Pymoe.Mal.Objects.Manga` or :class:`Pymoe.Mal.Objects.Anime` objects as per the type param.
[ "The", "real", "search", "method", "." ]
train
https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/Mal/__init__.py#L69-L134
ccubed/PyMoe
Pymoe/Mal/__init__.py
Mal._anime_add
def _anime_add(self, data): """ Adds an anime to a user's list. :param data: A :class:`Pymoe.Mal.Objects.Anime` object with the anime data :raises: SyntaxError on invalid data type :raises: ServerError on failure to add :rtype: Bool :return: True on success ...
python
def _anime_add(self, data): """ Adds an anime to a user's list. :param data: A :class:`Pymoe.Mal.Objects.Anime` object with the anime data :raises: SyntaxError on invalid data type :raises: ServerError on failure to add :rtype: Bool :return: True on success ...
[ "def", "_anime_add", "(", "self", ",", "data", ")", ":", "if", "isinstance", "(", "data", ",", "Anime", ")", ":", "xmlstr", "=", "data", ".", "to_xml", "(", ")", "r", "=", "requests", ".", "get", "(", "self", ".", "apiurl", "+", "\"animelist/add/{}.x...
Adds an anime to a user's list. :param data: A :class:`Pymoe.Mal.Objects.Anime` object with the anime data :raises: SyntaxError on invalid data type :raises: ServerError on failure to add :rtype: Bool :return: True on success
[ "Adds", "an", "anime", "to", "a", "user", "s", "list", "." ]
train
https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/Mal/__init__.py#L136-L157
ccubed/PyMoe
Pymoe/Mal/__init__.py
Mal.user
def user(self, name): """ Get a user's anime list and details. This returns an encapsulated data type. :param str name: The username to query :rtype: :class:`Pymoe.Mal.Objects.User` :return: A :class:`Pymoe.Mal.Objects.User` Object """ anime_data = requests.get(s...
python
def user(self, name): """ Get a user's anime list and details. This returns an encapsulated data type. :param str name: The username to query :rtype: :class:`Pymoe.Mal.Objects.User` :return: A :class:`Pymoe.Mal.Objects.User` Object """ anime_data = requests.get(s...
[ "def", "user", "(", "self", ",", "name", ")", ":", "anime_data", "=", "requests", ".", "get", "(", "self", ".", "apiusers", ",", "params", "=", "{", "'u'", ":", "name", ",", "'status'", ":", "'all'", ",", "'type'", ":", "'anime'", "}", ",", "header...
Get a user's anime list and details. This returns an encapsulated data type. :param str name: The username to query :rtype: :class:`Pymoe.Mal.Objects.User` :return: A :class:`Pymoe.Mal.Objects.User` Object
[ "Get", "a", "user", "s", "anime", "list", "and", "details", ".", "This", "returns", "an", "encapsulated", "data", "type", "." ]
train
https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/Mal/__init__.py#L270-L316
ccubed/PyMoe
Pymoe/VNDB/connection.py
VNDBConnection.login
def login(self, username, password): """ This handles login logic instead of stuffing all that in the __init__. :param username: The username to log in as or None :param password: The password for that user or None :return: Nothing :raises: :class:`Pymoe.errors.UserLogin...
python
def login(self, username, password): """ This handles login logic instead of stuffing all that in the __init__. :param username: The username to log in as or None :param password: The password for that user or None :return: Nothing :raises: :class:`Pymoe.errors.UserLogin...
[ "def", "login", "(", "self", ",", "username", ",", "password", ")", ":", "finvars", "=", "self", ".", "clientvars", "if", "username", "and", "password", ":", "finvars", "[", "'username'", "]", "=", "username", "finvars", "[", "'password'", "]", "=", "pas...
This handles login logic instead of stuffing all that in the __init__. :param username: The username to log in as or None :param password: The password for that user or None :return: Nothing :raises: :class:`Pymoe.errors.UserLoginFailed` - Didn't respond with Ok :raises: :class:...
[ "This", "handles", "login", "logic", "instead", "of", "stuffing", "all", "that", "in", "the", "__init__", "." ]
train
https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/VNDB/connection.py#L47-L68
ccubed/PyMoe
Pymoe/VNDB/connection.py
VNDBConnection.send_command
def send_command(self, command, args=None): """ Send a command to VNDB and then get the result. :param command: What command are we sending :param args: What are the json args for this command :return: Servers Response :rtype: Dictionary (See D11 docs on VNDB) ""...
python
def send_command(self, command, args=None): """ Send a command to VNDB and then get the result. :param command: What command are we sending :param args: What are the json args for this command :return: Servers Response :rtype: Dictionary (See D11 docs on VNDB) ""...
[ "def", "send_command", "(", "self", ",", "command", ",", "args", "=", "None", ")", ":", "if", "args", ":", "if", "isinstance", "(", "args", ",", "str", ")", ":", "final_command", "=", "command", "+", "' '", "+", "args", "+", "'\\x04'", "else", ":", ...
Send a command to VNDB and then get the result. :param command: What command are we sending :param args: What are the json args for this command :return: Servers Response :rtype: Dictionary (See D11 docs on VNDB)
[ "Send", "a", "command", "to", "VNDB", "and", "then", "get", "the", "result", "." ]
train
https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/VNDB/connection.py#L70-L88
ccubed/PyMoe
Pymoe/VNDB/connection.py
VNDBConnection._recv_data
def _recv_data(self): """ Receieves data until we reach the \x04 and then returns it. :return: The data received """ temp = "" while True: self.data_buffer = self.sslwrap.recv(1024) if '\x04' in self.data_buffer.decode('utf-8', 'ignore'): ...
python
def _recv_data(self): """ Receieves data until we reach the \x04 and then returns it. :return: The data received """ temp = "" while True: self.data_buffer = self.sslwrap.recv(1024) if '\x04' in self.data_buffer.decode('utf-8', 'ignore'): ...
[ "def", "_recv_data", "(", "self", ")", ":", "temp", "=", "\"\"", "while", "True", ":", "self", ".", "data_buffer", "=", "self", ".", "sslwrap", ".", "recv", "(", "1024", ")", "if", "'\\x04'", "in", "self", ".", "data_buffer", ".", "decode", "(", "'ut...
Receieves data until we reach the \x04 and then returns it. :return: The data received
[ "Receieves", "data", "until", "we", "reach", "the", "\\", "x04", "and", "then", "returns", "it", "." ]
train
https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/VNDB/connection.py#L90-L109
ccubed/PyMoe
Pymoe/Kitsu/library.py
KitsuLib.get
def get(self, uid, filters=None): """ Get a user's list of library entries. While individual entries on this list don't show what type of entry it is, you can use the filters provided by the Kitsu API to only select which ones you want :param uid: str: User ID to get library ent...
python
def get(self, uid, filters=None): """ Get a user's list of library entries. While individual entries on this list don't show what type of entry it is, you can use the filters provided by the Kitsu API to only select which ones you want :param uid: str: User ID to get library ent...
[ "def", "get", "(", "self", ",", "uid", ",", "filters", "=", "None", ")", ":", "filters", "=", "self", ".", "__format_filters", "(", "filters", ")", "r", "=", "requests", ".", "get", "(", "self", ".", "apiurl", "+", "\"/users/{}/library-entries\"", ".", ...
Get a user's list of library entries. While individual entries on this list don't show what type of entry it is, you can use the filters provided by the Kitsu API to only select which ones you want :param uid: str: User ID to get library entries for :param filters: dict: Dictionary of f...
[ "Get", "a", "user", "s", "list", "of", "library", "entries", ".", "While", "individual", "entries", "on", "this", "list", "don", "t", "show", "what", "type", "of", "entry", "it", "is", "you", "can", "use", "the", "filters", "provided", "by", "the", "Ki...
train
https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/Kitsu/library.py#L10-L33
ccubed/PyMoe
Pymoe/Kitsu/library.py
KitsuLib.create
def create(self, user_id, media_id, item_type, token, data): """ Create a library entry for a user. data should be just the attributes. Data at least needs a status and progress. :param user_id str: User ID that this Library Entry is for :param media_id str: ID for the media thi...
python
def create(self, user_id, media_id, item_type, token, data): """ Create a library entry for a user. data should be just the attributes. Data at least needs a status and progress. :param user_id str: User ID that this Library Entry is for :param media_id str: ID for the media thi...
[ "def", "create", "(", "self", ",", "user_id", ",", "media_id", ",", "item_type", ",", "token", ",", "data", ")", ":", "final_dict", "=", "{", "\"data\"", ":", "{", "\"type\"", ":", "\"libraryEntries\"", ",", "\"attributes\"", ":", "data", ",", "\"relations...
Create a library entry for a user. data should be just the attributes. Data at least needs a status and progress. :param user_id str: User ID that this Library Entry is for :param media_id str: ID for the media this entry relates to :param item_type str: anime, drama or manga depending ...
[ "Create", "a", "library", "entry", "for", "a", "user", ".", "data", "should", "be", "just", "the", "attributes", ".", "Data", "at", "least", "needs", "a", "status", "and", "progress", "." ]
train
https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/Kitsu/library.py#L35-L78
ccubed/PyMoe
Pymoe/Kitsu/library.py
KitsuLib.update
def update(self, eid, data, token): """ Update a given Library Entry. :param eid str: Entry ID :param data dict: Attributes :param token str: OAuth token :return: True or ServerError :rtype: Bool or Exception """ final_dict = {"data": {"id": eid, ...
python
def update(self, eid, data, token): """ Update a given Library Entry. :param eid str: Entry ID :param data dict: Attributes :param token str: OAuth token :return: True or ServerError :rtype: Bool or Exception """ final_dict = {"data": {"id": eid, ...
[ "def", "update", "(", "self", ",", "eid", ",", "data", ",", "token", ")", ":", "final_dict", "=", "{", "\"data\"", ":", "{", "\"id\"", ":", "eid", ",", "\"type\"", ":", "\"libraryEntries\"", ",", "\"attributes\"", ":", "data", "}", "}", "final_headers", ...
Update a given Library Entry. :param eid str: Entry ID :param data dict: Attributes :param token str: OAuth token :return: True or ServerError :rtype: Bool or Exception
[ "Update", "a", "given", "Library", "Entry", "." ]
train
https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/Kitsu/library.py#L80-L99
ccubed/PyMoe
Pymoe/Kitsu/library.py
KitsuLib.delete
def delete(self, eid, token): """ Delete a library entry. :param eid str: Entry ID :param token str: OAuth Token :return: True or ServerError :rtype: Bool or Exception """ final_headers = self.header final_headers['Authorization'] = "Bearer {}".fo...
python
def delete(self, eid, token): """ Delete a library entry. :param eid str: Entry ID :param token str: OAuth Token :return: True or ServerError :rtype: Bool or Exception """ final_headers = self.header final_headers['Authorization'] = "Bearer {}".fo...
[ "def", "delete", "(", "self", ",", "eid", ",", "token", ")", ":", "final_headers", "=", "self", ".", "header", "final_headers", "[", "'Authorization'", "]", "=", "\"Bearer {}\"", ".", "format", "(", "token", ")", "r", "=", "requests", ".", "delete", "(",...
Delete a library entry. :param eid str: Entry ID :param token str: OAuth Token :return: True or ServerError :rtype: Bool or Exception
[ "Delete", "a", "library", "entry", "." ]
train
https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/Kitsu/library.py#L101-L119
ccubed/PyMoe
Pymoe/Kitsu/library.py
KitsuLib.__format_filters
def __format_filters(filters): """ Format filters for the api query (to filter[<filter-name>]) :param filters: dict: can be None, filters for the query :return: the formatted filters, or None """ if filters is not None: for k in filters: if 'f...
python
def __format_filters(filters): """ Format filters for the api query (to filter[<filter-name>]) :param filters: dict: can be None, filters for the query :return: the formatted filters, or None """ if filters is not None: for k in filters: if 'f...
[ "def", "__format_filters", "(", "filters", ")", ":", "if", "filters", "is", "not", "None", ":", "for", "k", "in", "filters", ":", "if", "'filter['", "not", "in", "k", ":", "filters", "[", "'filter[{}]'", ".", "format", "(", "k", ")", "]", "=", "filte...
Format filters for the api query (to filter[<filter-name>]) :param filters: dict: can be None, filters for the query :return: the formatted filters, or None
[ "Format", "filters", "for", "the", "api", "query", "(", "to", "filter", "[", "<filter", "-", "name", ">", "]", ")" ]
train
https://github.com/ccubed/PyMoe/blob/5b2a2591bb113bd80d838e65aaa06f3a97ff3670/Pymoe/Kitsu/library.py#L122-L133
wecatch/app-turbo
turbo/mongo_model.py
convert_to_record
def convert_to_record(func): """Wrap mongodb record to a dict record with default value None """ @functools.wraps(func) def wrapper(self, *args, **kwargs): result = func(self, *args, **kwargs) if result is not None: if isinstance(result, dict): return _record(...
python
def convert_to_record(func): """Wrap mongodb record to a dict record with default value None """ @functools.wraps(func) def wrapper(self, *args, **kwargs): result = func(self, *args, **kwargs) if result is not None: if isinstance(result, dict): return _record(...
[ "def", "convert_to_record", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "wrapper", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "result", "=", "func", "(", "self", ",", "*", "args", ",", "*...
Wrap mongodb record to a dict record with default value None
[ "Wrap", "mongodb", "record", "to", "a", "dict", "record", "with", "default", "value", "None" ]
train
https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/turbo/mongo_model.py#L23-L36
wecatch/app-turbo
turbo/mongo_model.py
MixinModel.to_one_str
def to_one_str(cls, value, *args, **kwargs): """Convert single record's values to str """ if kwargs.get('wrapper'): return cls._wrapper_to_one_str(value) return _es.to_dict_str(value)
python
def to_one_str(cls, value, *args, **kwargs): """Convert single record's values to str """ if kwargs.get('wrapper'): return cls._wrapper_to_one_str(value) return _es.to_dict_str(value)
[ "def", "to_one_str", "(", "cls", ",", "value", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "kwargs", ".", "get", "(", "'wrapper'", ")", ":", "return", "cls", ".", "_wrapper_to_one_str", "(", "value", ")", "return", "_es", ".", "to_dict...
Convert single record's values to str
[ "Convert", "single", "record", "s", "values", "to", "str" ]
train
https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/turbo/mongo_model.py#L67-L73
wecatch/app-turbo
turbo/mongo_model.py
MixinModel.to_str
def to_str(cls, values, callback=None): """Convert many records's values to str """ if callback and callable(callback): if isinstance(values, dict): return callback(_es.to_str(values)) return [callback(_es.to_str(i)) for i in values] return _es.to...
python
def to_str(cls, values, callback=None): """Convert many records's values to str """ if callback and callable(callback): if isinstance(values, dict): return callback(_es.to_str(values)) return [callback(_es.to_str(i)) for i in values] return _es.to...
[ "def", "to_str", "(", "cls", ",", "values", ",", "callback", "=", "None", ")", ":", "if", "callback", "and", "callable", "(", "callback", ")", ":", "if", "isinstance", "(", "values", ",", "dict", ")", ":", "return", "callback", "(", "_es", ".", "to_s...
Convert many records's values to str
[ "Convert", "many", "records", "s", "values", "to", "str" ]
train
https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/turbo/mongo_model.py#L76-L84
wecatch/app-turbo
turbo/mongo_model.py
MixinModel.instance
def instance(cls, name): """Instantiate a model class according to import path args: name: class import path like `user.User` return: model instance """ if not cls._instance.get(name): model_name = name.split('.') ins_name = '.'.joi...
python
def instance(cls, name): """Instantiate a model class according to import path args: name: class import path like `user.User` return: model instance """ if not cls._instance.get(name): model_name = name.split('.') ins_name = '.'.joi...
[ "def", "instance", "(", "cls", ",", "name", ")", ":", "if", "not", "cls", ".", "_instance", ".", "get", "(", "name", ")", ":", "model_name", "=", "name", ".", "split", "(", "'.'", ")", "ins_name", "=", "'.'", ".", "join", "(", "[", "'models'", ",...
Instantiate a model class according to import path args: name: class import path like `user.User` return: model instance
[ "Instantiate", "a", "model", "class", "according", "to", "import", "path", "args", ":", "name", ":", "class", "import", "path", "like", "user", ".", "User", "return", ":", "model", "instance" ]
train
https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/turbo/mongo_model.py#L116-L129
wecatch/app-turbo
turbo/mongo_model.py
MixinModel.import_model
def import_model(cls, ins_name): """Import model class in models package """ try: package_space = getattr(cls, 'package_space') except AttributeError: raise ValueError('package_space not exist') else: return import_object(ins_name, package_spac...
python
def import_model(cls, ins_name): """Import model class in models package """ try: package_space = getattr(cls, 'package_space') except AttributeError: raise ValueError('package_space not exist') else: return import_object(ins_name, package_spac...
[ "def", "import_model", "(", "cls", ",", "ins_name", ")", ":", "try", ":", "package_space", "=", "getattr", "(", "cls", ",", "'package_space'", ")", "except", "AttributeError", ":", "raise", "ValueError", "(", "'package_space not exist'", ")", "else", ":", "ret...
Import model class in models package
[ "Import", "model", "class", "in", "models", "package" ]
train
https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/turbo/mongo_model.py#L132-L140
wecatch/app-turbo
turbo/register.py
register_app
def register_app(app_name, app_setting, web_application_setting, mainfile, package_space): """insert current project root path into sys path """ from turbo import log app_config.app_name = app_name app_config.app_setting = app_setting app_config.project_name = os.path.basename(get_base_dir(mainf...
python
def register_app(app_name, app_setting, web_application_setting, mainfile, package_space): """insert current project root path into sys path """ from turbo import log app_config.app_name = app_name app_config.app_setting = app_setting app_config.project_name = os.path.basename(get_base_dir(mainf...
[ "def", "register_app", "(", "app_name", ",", "app_setting", ",", "web_application_setting", ",", "mainfile", ",", "package_space", ")", ":", "from", "turbo", "import", "log", "app_config", ".", "app_name", "=", "app_name", "app_config", ".", "app_setting", "=", ...
insert current project root path into sys path
[ "insert", "current", "project", "root", "path", "into", "sys", "path" ]
train
https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/turbo/register.py#L14-L25
wecatch/app-turbo
turbo/register.py
register_url
def register_url(url, handler, name=None, kwargs=None): """insert url into tornado application handlers group :arg str url: url :handler object handler: url mapping handler :name reverse url name :kwargs dict tornado handler initlize args """ if name is None and kwargs is None: app_...
python
def register_url(url, handler, name=None, kwargs=None): """insert url into tornado application handlers group :arg str url: url :handler object handler: url mapping handler :name reverse url name :kwargs dict tornado handler initlize args """ if name is None and kwargs is None: app_...
[ "def", "register_url", "(", "url", ",", "handler", ",", "name", "=", "None", ",", "kwargs", "=", "None", ")", ":", "if", "name", "is", "None", "and", "kwargs", "is", "None", ":", "app_config", ".", "urls", ".", "append", "(", "(", "url", ",", "hand...
insert url into tornado application handlers group :arg str url: url :handler object handler: url mapping handler :name reverse url name :kwargs dict tornado handler initlize args
[ "insert", "url", "into", "tornado", "application", "handlers", "group" ]
train
https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/turbo/register.py#L28-L44
wecatch/app-turbo
demos/db-server/apps/base.py
BaseHandler.write_error
def write_error(self, status_code, **kwargs): """Override to implement custom error pages. http://tornado.readthedocs.org/en/stable/_modules/tornado/web.html#RequestHandler.write_error """ super(BaseHandler, self).write_error(status_code, **kwargs)
python
def write_error(self, status_code, **kwargs): """Override to implement custom error pages. http://tornado.readthedocs.org/en/stable/_modules/tornado/web.html#RequestHandler.write_error """ super(BaseHandler, self).write_error(status_code, **kwargs)
[ "def", "write_error", "(", "self", ",", "status_code", ",", "*", "*", "kwargs", ")", ":", "super", "(", "BaseHandler", ",", "self", ")", ".", "write_error", "(", "status_code", ",", "*", "*", "kwargs", ")" ]
Override to implement custom error pages. http://tornado.readthedocs.org/en/stable/_modules/tornado/web.html#RequestHandler.write_error
[ "Override", "to", "implement", "custom", "error", "pages", ".", "http", ":", "//", "tornado", ".", "readthedocs", ".", "org", "/", "en", "/", "stable", "/", "_modules", "/", "tornado", "/", "web", ".", "html#RequestHandler", ".", "write_error" ]
train
https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/demos/db-server/apps/base.py#L55-L59
wecatch/app-turbo
turbo/app.py
BaseBaseHandler.parameter
def parameter(self): ''' according to request method config to filter all request paremter if value is invalid then set None ''' method = self.request.method.lower() arguments = self.request.arguments files = self.request.files rpd = {} # request paramet...
python
def parameter(self): ''' according to request method config to filter all request paremter if value is invalid then set None ''' method = self.request.method.lower() arguments = self.request.arguments files = self.request.files rpd = {} # request paramet...
[ "def", "parameter", "(", "self", ")", ":", "method", "=", "self", ".", "request", ".", "method", ".", "lower", "(", ")", "arguments", "=", "self", ".", "request", ".", "arguments", "files", "=", "self", ".", "request", ".", "files", "rpd", "=", "{", ...
according to request method config to filter all request paremter if value is invalid then set None
[ "according", "to", "request", "method", "config", "to", "filter", "all", "request", "paremter", "if", "value", "is", "invalid", "then", "set", "None" ]
train
https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/turbo/app.py#L173-L250
wecatch/app-turbo
turbo/app.py
BaseBaseHandler.wo_resp
def wo_resp(self, resp): """ can override for other style """ if self._data is not None: resp['res'] = self.to_str(self._data) return self.wo_json(resp)
python
def wo_resp(self, resp): """ can override for other style """ if self._data is not None: resp['res'] = self.to_str(self._data) return self.wo_json(resp)
[ "def", "wo_resp", "(", "self", ",", "resp", ")", ":", "if", "self", ".", "_data", "is", "not", "None", ":", "resp", "[", "'res'", "]", "=", "self", ".", "to_str", "(", "self", ".", "_data", ")", "return", "self", ".", "wo_json", "(", "resp", ")" ...
can override for other style
[ "can", "override", "for", "other", "style" ]
train
https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/turbo/app.py#L307-L314
wecatch/app-turbo
turbo/model.py
BaseBaseModel.insert
def insert(self, doc_or_docs, **kwargs): """Insert method """ check = kwargs.pop('check', True) if isinstance(doc_or_docs, dict): if check is True: doc_or_docs = self._valid_record(doc_or_docs) result = self.__collect.insert_one(doc_or_docs, **kwar...
python
def insert(self, doc_or_docs, **kwargs): """Insert method """ check = kwargs.pop('check', True) if isinstance(doc_or_docs, dict): if check is True: doc_or_docs = self._valid_record(doc_or_docs) result = self.__collect.insert_one(doc_or_docs, **kwar...
[ "def", "insert", "(", "self", ",", "doc_or_docs", ",", "*", "*", "kwargs", ")", ":", "check", "=", "kwargs", ".", "pop", "(", "'check'", ",", "True", ")", "if", "isinstance", "(", "doc_or_docs", ",", "dict", ")", ":", "if", "check", "is", "True", "...
Insert method
[ "Insert", "method" ]
train
https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/turbo/model.py#L35-L49
wecatch/app-turbo
turbo/model.py
BaseBaseModel.save
def save(self, to_save, **kwargs): """save method """ check = kwargs.pop('check', True) if check: self._valid_record(to_save) if '_id' in to_save: self.__collect.replace_one( {'_id': to_save['_id']}, to_save, **kwargs) return to...
python
def save(self, to_save, **kwargs): """save method """ check = kwargs.pop('check', True) if check: self._valid_record(to_save) if '_id' in to_save: self.__collect.replace_one( {'_id': to_save['_id']}, to_save, **kwargs) return to...
[ "def", "save", "(", "self", ",", "to_save", ",", "*", "*", "kwargs", ")", ":", "check", "=", "kwargs", ".", "pop", "(", "'check'", ",", "True", ")", "if", "check", ":", "self", ".", "_valid_record", "(", "to_save", ")", "if", "'_id'", "in", "to_sav...
save method
[ "save", "method" ]
train
https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/turbo/model.py#L51-L63
wecatch/app-turbo
turbo/model.py
BaseBaseModel.update
def update(self, filter_, document, multi=False, **kwargs): """update method """ self._valide_update_document(document) if multi: return self.__collect.update_many(filter_, document, **kwargs) else: return self.__collect.update_one(filter_, document, **kwa...
python
def update(self, filter_, document, multi=False, **kwargs): """update method """ self._valide_update_document(document) if multi: return self.__collect.update_many(filter_, document, **kwargs) else: return self.__collect.update_one(filter_, document, **kwa...
[ "def", "update", "(", "self", ",", "filter_", ",", "document", ",", "multi", "=", "False", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_valide_update_document", "(", "document", ")", "if", "multi", ":", "return", "self", ".", "__collect", ".", "up...
update method
[ "update", "method" ]
train
https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/turbo/model.py#L65-L72
wecatch/app-turbo
turbo/model.py
BaseBaseModel.remove
def remove(self, filter_=None, **kwargs): """collection remove method warning: if you want to remove all documents, you must override _remove_all method to make sure you understand the result what you do """ if isinstance(filter_, dict) and filter_ == ...
python
def remove(self, filter_=None, **kwargs): """collection remove method warning: if you want to remove all documents, you must override _remove_all method to make sure you understand the result what you do """ if isinstance(filter_, dict) and filter_ == ...
[ "def", "remove", "(", "self", ",", "filter_", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "filter_", ",", "dict", ")", "and", "filter_", "==", "{", "}", ":", "raise", "ValueError", "(", "'not allowed remove all documents'", "...
collection remove method warning: if you want to remove all documents, you must override _remove_all method to make sure you understand the result what you do
[ "collection", "remove", "method", "warning", ":", "if", "you", "want", "to", "remove", "all", "documents", "you", "must", "override", "_remove_all", "method", "to", "make", "sure", "you", "understand", "the", "result", "what", "you", "do" ]
train
https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/turbo/model.py#L74-L90
wecatch/app-turbo
turbo/model.py
BaseBaseModel.insert_one
def insert_one(self, doc_or_docs, **kwargs): """Insert method """ check = kwargs.pop('check', True) if check is True: self._valid_record(doc_or_docs) return self.__collect.insert_one(doc_or_docs, **kwargs)
python
def insert_one(self, doc_or_docs, **kwargs): """Insert method """ check = kwargs.pop('check', True) if check is True: self._valid_record(doc_or_docs) return self.__collect.insert_one(doc_or_docs, **kwargs)
[ "def", "insert_one", "(", "self", ",", "doc_or_docs", ",", "*", "*", "kwargs", ")", ":", "check", "=", "kwargs", ".", "pop", "(", "'check'", ",", "True", ")", "if", "check", "is", "True", ":", "self", ".", "_valid_record", "(", "doc_or_docs", ")", "r...
Insert method
[ "Insert", "method" ]
train
https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/turbo/model.py#L92-L99
wecatch/app-turbo
turbo/model.py
BaseBaseModel.insert_many
def insert_many(self, doc_or_docs, **kwargs): """Insert method """ check = kwargs.pop('check', True) if check is True: for i in doc_or_docs: i = self._valid_record(i) return self.__collect.insert_many(doc_or_docs, **kwargs)
python
def insert_many(self, doc_or_docs, **kwargs): """Insert method """ check = kwargs.pop('check', True) if check is True: for i in doc_or_docs: i = self._valid_record(i) return self.__collect.insert_many(doc_or_docs, **kwargs)
[ "def", "insert_many", "(", "self", ",", "doc_or_docs", ",", "*", "*", "kwargs", ")", ":", "check", "=", "kwargs", ".", "pop", "(", "'check'", ",", "True", ")", "if", "check", "is", "True", ":", "for", "i", "in", "doc_or_docs", ":", "i", "=", "self"...
Insert method
[ "Insert", "method" ]
train
https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/turbo/model.py#L101-L109
wecatch/app-turbo
turbo/model.py
BaseBaseModel.find_one
def find_one(self, filter_=None, *args, **kwargs): """find_one method """ wrapper = kwargs.pop('wrapper', False) if wrapper is True: return self._wrapper_find_one(filter_, *args, **kwargs) return self.__collect.find_one(filter_, *args, **kwargs)
python
def find_one(self, filter_=None, *args, **kwargs): """find_one method """ wrapper = kwargs.pop('wrapper', False) if wrapper is True: return self._wrapper_find_one(filter_, *args, **kwargs) return self.__collect.find_one(filter_, *args, **kwargs)
[ "def", "find_one", "(", "self", ",", "filter_", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "wrapper", "=", "kwargs", ".", "pop", "(", "'wrapper'", ",", "False", ")", "if", "wrapper", "is", "True", ":", "return", "self", ".", ...
find_one method
[ "find_one", "method" ]
train
https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/turbo/model.py#L111-L118
wecatch/app-turbo
turbo/model.py
BaseBaseModel.find
def find(self, *args, **kwargs): """collection find method """ wrapper = kwargs.pop('wrapper', False) if wrapper is True: return self._wrapper_find(*args, **kwargs) return self.__collect.find(*args, **kwargs)
python
def find(self, *args, **kwargs): """collection find method """ wrapper = kwargs.pop('wrapper', False) if wrapper is True: return self._wrapper_find(*args, **kwargs) return self.__collect.find(*args, **kwargs)
[ "def", "find", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "wrapper", "=", "kwargs", ".", "pop", "(", "'wrapper'", ",", "False", ")", "if", "wrapper", "is", "True", ":", "return", "self", ".", "_wrapper_find", "(", "*", "args"...
collection find method
[ "collection", "find", "method" ]
train
https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/turbo/model.py#L120-L128
wecatch/app-turbo
turbo/model.py
BaseBaseModel._wrapper_find_one
def _wrapper_find_one(self, filter_=None, *args, **kwargs): """Convert record to a dict that has no key error """ return self.__collect.find_one(filter_, *args, **kwargs)
python
def _wrapper_find_one(self, filter_=None, *args, **kwargs): """Convert record to a dict that has no key error """ return self.__collect.find_one(filter_, *args, **kwargs)
[ "def", "_wrapper_find_one", "(", "self", ",", "filter_", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__collect", ".", "find_one", "(", "filter_", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Convert record to a dict that has no key error
[ "Convert", "record", "to", "a", "dict", "that", "has", "no", "key", "error" ]
train
https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/turbo/model.py#L131-L134
wecatch/app-turbo
turbo/model.py
BaseBaseModel.update_one
def update_one(self, filter_, document, **kwargs): """update method """ self._valide_update_document(document) return self.__collect.update_one(filter_, document, **kwargs)
python
def update_one(self, filter_, document, **kwargs): """update method """ self._valide_update_document(document) return self.__collect.update_one(filter_, document, **kwargs)
[ "def", "update_one", "(", "self", ",", "filter_", ",", "document", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_valide_update_document", "(", "document", ")", "return", "self", ".", "__collect", ".", "update_one", "(", "filter_", ",", "document", ",",...
update method
[ "update", "method" ]
train
https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/turbo/model.py#L142-L146
wecatch/app-turbo
turbo/model.py
BaseBaseModel.find_by_id
def find_by_id(self, _id, projection=None): """find record by _id """ if isinstance(_id, list) or isinstance(_id, tuple): return list(self.__collect.find( {'_id': {'$in': [self._to_primary_key(i) for i in _id]}}, projection)) document_id = self._to_primary_ke...
python
def find_by_id(self, _id, projection=None): """find record by _id """ if isinstance(_id, list) or isinstance(_id, tuple): return list(self.__collect.find( {'_id': {'$in': [self._to_primary_key(i) for i in _id]}}, projection)) document_id = self._to_primary_ke...
[ "def", "find_by_id", "(", "self", ",", "_id", ",", "projection", "=", "None", ")", ":", "if", "isinstance", "(", "_id", ",", "list", ")", "or", "isinstance", "(", "_id", ",", "tuple", ")", ":", "return", "list", "(", "self", ".", "__collect", ".", ...
find record by _id
[ "find", "record", "by", "_id" ]
train
https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/turbo/model.py#L161-L173
wecatch/app-turbo
turbo/model.py
BaseModel.create_model
def create_model(cls, name, field=None): """dynamic create new model :args field table field, if field is None or {}, this model can not use create method """ if field: attrs = {'name': name, 'field': field} else: attrs = {'name': name, 'field': {'_id': Ob...
python
def create_model(cls, name, field=None): """dynamic create new model :args field table field, if field is None or {}, this model can not use create method """ if field: attrs = {'name': name, 'field': field} else: attrs = {'name': name, 'field': {'_id': Ob...
[ "def", "create_model", "(", "cls", ",", "name", ",", "field", "=", "None", ")", ":", "if", "field", ":", "attrs", "=", "{", "'name'", ":", "name", ",", "'field'", ":", "field", "}", "else", ":", "attrs", "=", "{", "'name'", ":", "name", ",", "'fi...
dynamic create new model :args field table field, if field is None or {}, this model can not use create method
[ "dynamic", "create", "new", "model", ":", "args", "field", "table", "field", "if", "field", "is", "None", "or", "{}", "this", "model", "can", "not", "use", "create", "method" ]
train
https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/turbo/model.py#L232-L241
wecatch/app-turbo
turbo/util.py
to_list_str
def to_list_str(value, encode=None): """recursively convert list content into string :arg list value: The list that need to be converted. :arg function encode: Function used to encode object. """ result = [] for index, v in enumerate(value): if isinstance(v, dict): result.ap...
python
def to_list_str(value, encode=None): """recursively convert list content into string :arg list value: The list that need to be converted. :arg function encode: Function used to encode object. """ result = [] for index, v in enumerate(value): if isinstance(v, dict): result.ap...
[ "def", "to_list_str", "(", "value", ",", "encode", "=", "None", ")", ":", "result", "=", "[", "]", "for", "index", ",", "v", "in", "enumerate", "(", "value", ")", ":", "if", "isinstance", "(", "v", ",", "dict", ")", ":", "result", ".", "append", ...
recursively convert list content into string :arg list value: The list that need to be converted. :arg function encode: Function used to encode object.
[ "recursively", "convert", "list", "content", "into", "string" ]
train
https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/turbo/util.py#L29-L50
wecatch/app-turbo
turbo/util.py
to_dict_str
def to_dict_str(origin_value, encode=None): """recursively convert dict content into string """ value = copy.deepcopy(origin_value) for k, v in value.items(): if isinstance(v, dict): value[k] = to_dict_str(v, encode) continue if isinstance(v, list): v...
python
def to_dict_str(origin_value, encode=None): """recursively convert dict content into string """ value = copy.deepcopy(origin_value) for k, v in value.items(): if isinstance(v, dict): value[k] = to_dict_str(v, encode) continue if isinstance(v, list): v...
[ "def", "to_dict_str", "(", "origin_value", ",", "encode", "=", "None", ")", ":", "value", "=", "copy", ".", "deepcopy", "(", "origin_value", ")", "for", "k", ",", "v", "in", "value", ".", "items", "(", ")", ":", "if", "isinstance", "(", "v", ",", "...
recursively convert dict content into string
[ "recursively", "convert", "dict", "content", "into", "string" ]
train
https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/turbo/util.py#L53-L71
wecatch/app-turbo
turbo/util.py
default_encode
def default_encode(v): """convert ObjectId, datetime, date into string """ if isinstance(v, ObjectId): return unicode_type(v) if isinstance(v, datetime): return format_time(v) if isinstance(v, date): return format_time(v) return v
python
def default_encode(v): """convert ObjectId, datetime, date into string """ if isinstance(v, ObjectId): return unicode_type(v) if isinstance(v, datetime): return format_time(v) if isinstance(v, date): return format_time(v) return v
[ "def", "default_encode", "(", "v", ")", ":", "if", "isinstance", "(", "v", ",", "ObjectId", ")", ":", "return", "unicode_type", "(", "v", ")", "if", "isinstance", "(", "v", ",", "datetime", ")", ":", "return", "format_time", "(", "v", ")", "if", "isi...
convert ObjectId, datetime, date into string
[ "convert", "ObjectId", "datetime", "date", "into", "string" ]
train
https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/turbo/util.py#L74-L86
wecatch/app-turbo
turbo/util.py
to_str
def to_str(v, encode=None): """convert any list, dict, iterable and primitives object to string """ if isinstance(v, basestring_type): return v if isinstance(v, dict): return to_dict_str(v, encode) if isinstance(v, Iterable): return to_list_str(v, encode) if encode: ...
python
def to_str(v, encode=None): """convert any list, dict, iterable and primitives object to string """ if isinstance(v, basestring_type): return v if isinstance(v, dict): return to_dict_str(v, encode) if isinstance(v, Iterable): return to_list_str(v, encode) if encode: ...
[ "def", "to_str", "(", "v", ",", "encode", "=", "None", ")", ":", "if", "isinstance", "(", "v", ",", "basestring_type", ")", ":", "return", "v", "if", "isinstance", "(", "v", ",", "dict", ")", ":", "return", "to_dict_str", "(", "v", ",", "encode", "...
convert any list, dict, iterable and primitives object to string
[ "convert", "any", "list", "dict", "iterable", "and", "primitives", "object", "to", "string" ]
train
https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/turbo/util.py#L89-L104
wecatch/app-turbo
turbo/util.py
to_objectid
def to_objectid(objid): """字符对象转换成objectid """ if objid is None: return objid try: objid = ObjectId(objid) except: util_log.error('%s is invalid objectid' % objid) return None return objid
python
def to_objectid(objid): """字符对象转换成objectid """ if objid is None: return objid try: objid = ObjectId(objid) except: util_log.error('%s is invalid objectid' % objid) return None return objid
[ "def", "to_objectid", "(", "objid", ")", ":", "if", "objid", "is", "None", ":", "return", "objid", "try", ":", "objid", "=", "ObjectId", "(", "objid", ")", "except", ":", "util_log", ".", "error", "(", "'%s is invalid objectid'", "%", "objid", ")", "retu...
字符对象转换成objectid
[ "字符对象转换成objectid" ]
train
https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/turbo/util.py#L113-L125
wecatch/app-turbo
turbo/util.py
get_base_dir
def get_base_dir(currfile, dir_level_num=3): """ find certain path according to currfile """ root_path = os.path.abspath(currfile) for i in range(0, dir_level_num): root_path = os.path.dirname(root_path) return root_path
python
def get_base_dir(currfile, dir_level_num=3): """ find certain path according to currfile """ root_path = os.path.abspath(currfile) for i in range(0, dir_level_num): root_path = os.path.dirname(root_path) return root_path
[ "def", "get_base_dir", "(", "currfile", ",", "dir_level_num", "=", "3", ")", ":", "root_path", "=", "os", ".", "path", ".", "abspath", "(", "currfile", ")", "for", "i", "in", "range", "(", "0", ",", "dir_level_num", ")", ":", "root_path", "=", "os", ...
find certain path according to currfile
[ "find", "certain", "path", "according", "to", "currfile" ]
train
https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/turbo/util.py#L188-L196
wecatch/app-turbo
turbo/util.py
join_sys_path
def join_sys_path(currfile, dir_level_num=3): """ find certain path then load into sys path """ if os.path.isdir(currfile): root_path = currfile else: root_path = get_base_dir(currfile, dir_level_num) sys.path.append(root_path)
python
def join_sys_path(currfile, dir_level_num=3): """ find certain path then load into sys path """ if os.path.isdir(currfile): root_path = currfile else: root_path = get_base_dir(currfile, dir_level_num) sys.path.append(root_path)
[ "def", "join_sys_path", "(", "currfile", ",", "dir_level_num", "=", "3", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "currfile", ")", ":", "root_path", "=", "currfile", "else", ":", "root_path", "=", "get_base_dir", "(", "currfile", ",", "dir_l...
find certain path then load into sys path
[ "find", "certain", "path", "then", "load", "into", "sys", "path" ]
train
https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/turbo/util.py#L199-L208
wecatch/app-turbo
turbo/util.py
camel_to_underscore
def camel_to_underscore(name): """ convert CamelCase style to under_score_case """ as_list = [] length = len(name) for index, i in enumerate(name): if index != 0 and index != length - 1 and i.isupper(): as_list.append('_%s' % i.lower()) else: as_list.appen...
python
def camel_to_underscore(name): """ convert CamelCase style to under_score_case """ as_list = [] length = len(name) for index, i in enumerate(name): if index != 0 and index != length - 1 and i.isupper(): as_list.append('_%s' % i.lower()) else: as_list.appen...
[ "def", "camel_to_underscore", "(", "name", ")", ":", "as_list", "=", "[", "]", "length", "=", "len", "(", "name", ")", "for", "index", ",", "i", "in", "enumerate", "(", "name", ")", ":", "if", "index", "!=", "0", "and", "index", "!=", "length", "-"...
convert CamelCase style to under_score_case
[ "convert", "CamelCase", "style", "to", "under_score_case" ]
train
https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/turbo/util.py#L224-L236
wecatch/app-turbo
turbo/util.py
to_basestring
def to_basestring(value): """Converts a string argument to a subclass of basestring. In python2, byte and unicode strings are mostly interchangeable, so functions that deal with a user-supplied argument in combination with ascii string constants can use either and should return the type the user su...
python
def to_basestring(value): """Converts a string argument to a subclass of basestring. In python2, byte and unicode strings are mostly interchangeable, so functions that deal with a user-supplied argument in combination with ascii string constants can use either and should return the type the user su...
[ "def", "to_basestring", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "_BASESTRING_TYPES", ")", ":", "return", "value", "if", "not", "isinstance", "(", "value", ",", "bytes", ")", ":", "raise", "TypeError", "(", "\"Expected bytes, unicode, or ...
Converts a string argument to a subclass of basestring. In python2, byte and unicode strings are mostly interchangeable, so functions that deal with a user-supplied argument in combination with ascii string constants can use either and should return the type the user supplied. In python3, the two type...
[ "Converts", "a", "string", "argument", "to", "a", "subclass", "of", "basestring", "." ]
train
https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/turbo/util.py#L364-L379
wecatch/app-turbo
turbo/httputil.py
encode_http_params
def encode_http_params(**kw): ''' url paremeter encode ''' try: _fo = lambda k, v: '{name}={value}'.format( name=k, value=to_basestring(quote(v))) except: _fo = lambda k, v: '%s=%s' % (k, to_basestring(quote(v))) _en = utf8 return '&'.join([_fo(k, _en(v)) for k,...
python
def encode_http_params(**kw): ''' url paremeter encode ''' try: _fo = lambda k, v: '{name}={value}'.format( name=k, value=to_basestring(quote(v))) except: _fo = lambda k, v: '%s=%s' % (k, to_basestring(quote(v))) _en = utf8 return '&'.join([_fo(k, _en(v)) for k,...
[ "def", "encode_http_params", "(", "*", "*", "kw", ")", ":", "try", ":", "_fo", "=", "lambda", "k", ",", "v", ":", "'{name}={value}'", ".", "format", "(", "name", "=", "k", ",", "value", "=", "to_basestring", "(", "quote", "(", "v", ")", ")", ")", ...
url paremeter encode
[ "url", "paremeter", "encode" ]
train
https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/turbo/httputil.py#L25-L37
wecatch/app-turbo
turbo/log.py
_init_file_logger
def _init_file_logger(logger, level, log_path, log_size, log_count): """ one logger only have one level RotatingFileHandler """ if level not in [logging.NOTSET, logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL]: level = logging.DEBUG for h in logger.handlers: ...
python
def _init_file_logger(logger, level, log_path, log_size, log_count): """ one logger only have one level RotatingFileHandler """ if level not in [logging.NOTSET, logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL]: level = logging.DEBUG for h in logger.handlers: ...
[ "def", "_init_file_logger", "(", "logger", ",", "level", ",", "log_path", ",", "log_size", ",", "log_count", ")", ":", "if", "level", "not", "in", "[", "logging", ".", "NOTSET", ",", "logging", ".", "DEBUG", ",", "logging", ".", "INFO", ",", "logging", ...
one logger only have one level RotatingFileHandler
[ "one", "logger", "only", "have", "one", "level", "RotatingFileHandler" ]
train
https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/turbo/log.py#L21-L37
wecatch/app-turbo
turbo/session.py
Session._processor
def _processor(self): """Application processor to setup session for every request""" self.store.cleanup(self._config.timeout) self._load()
python
def _processor(self): """Application processor to setup session for every request""" self.store.cleanup(self._config.timeout) self._load()
[ "def", "_processor", "(", "self", ")", ":", "self", ".", "store", ".", "cleanup", "(", "self", ".", "_config", ".", "timeout", ")", "self", ".", "_load", "(", ")" ]
Application processor to setup session for every request
[ "Application", "processor", "to", "setup", "session", "for", "every", "request" ]
train
https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/turbo/session.py#L94-L97
wecatch/app-turbo
turbo/session.py
Session._load
def _load(self): """Load the session from the store, by the id from cookie""" self.session_id = self._session_object.get_session_id() # protection against session_id tampering if self.session_id and not self._valid_session_id(self.session_id): self.session_id = None ...
python
def _load(self): """Load the session from the store, by the id from cookie""" self.session_id = self._session_object.get_session_id() # protection against session_id tampering if self.session_id and not self._valid_session_id(self.session_id): self.session_id = None ...
[ "def", "_load", "(", "self", ")", ":", "self", ".", "session_id", "=", "self", ".", "_session_object", ".", "get_session_id", "(", ")", "# protection against session_id tampering", "if", "self", ".", "session_id", "and", "not", "self", ".", "_valid_session_id", ...
Load the session from the store, by the id from cookie
[ "Load", "the", "session", "from", "the", "store", "by", "the", "id", "from", "cookie" ]
train
https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/turbo/session.py#L99-L120
wecatch/app-turbo
turbo/session.py
SessionObject.generate_session_id
def generate_session_id(self): """Generate a random id for session""" secret_key = self._config.secret_key while True: rand = os.urandom(16) now = time.time() session_id = sha1(utf8("%s%s%s%s" % ( rand, now, self.handler.request.remote_ip, secr...
python
def generate_session_id(self): """Generate a random id for session""" secret_key = self._config.secret_key while True: rand = os.urandom(16) now = time.time() session_id = sha1(utf8("%s%s%s%s" % ( rand, now, self.handler.request.remote_ip, secr...
[ "def", "generate_session_id", "(", "self", ")", ":", "secret_key", "=", "self", ".", "_config", ".", "secret_key", "while", "True", ":", "rand", "=", "os", ".", "urandom", "(", "16", ")", "now", "=", "time", ".", "time", "(", ")", "session_id", "=", ...
Generate a random id for session
[ "Generate", "a", "random", "id", "for", "session" ]
train
https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/turbo/session.py#L159-L171
wecatch/app-turbo
turbo/session.py
Store.encode
def encode(self, session_data): """encodes session dict as a string""" pickled = pickle.dumps(session_data) return to_basestring(encodebytes(pickled))
python
def encode(self, session_data): """encodes session dict as a string""" pickled = pickle.dumps(session_data) return to_basestring(encodebytes(pickled))
[ "def", "encode", "(", "self", ",", "session_data", ")", ":", "pickled", "=", "pickle", ".", "dumps", "(", "session_data", ")", "return", "to_basestring", "(", "encodebytes", "(", "pickled", ")", ")" ]
encodes session dict as a string
[ "encodes", "session", "dict", "as", "a", "string" ]
train
https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/turbo/session.py#L231-L234
wecatch/app-turbo
turbo/session.py
Store.decode
def decode(self, session_data): """decodes the data to get back the session dict """ pickled = decodebytes(utf8(session_data)) return pickle.loads(pickled)
python
def decode(self, session_data): """decodes the data to get back the session dict """ pickled = decodebytes(utf8(session_data)) return pickle.loads(pickled)
[ "def", "decode", "(", "self", ",", "session_data", ")", ":", "pickled", "=", "decodebytes", "(", "utf8", "(", "session_data", ")", ")", "return", "pickle", ".", "loads", "(", "pickled", ")" ]
decodes the data to get back the session dict
[ "decodes", "the", "data", "to", "get", "back", "the", "session", "dict" ]
train
https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/turbo/session.py#L236-L239